This repository has been archived by the owner on Feb 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
190 lines (180 loc) · 5.73 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
?>
<!DOCTYPE html>
<!--
Author: Brennan Cain
Email: brennan@brennancain.com
-->
<html>
<head>
<?php
if(isset($_GET["clear"]))
{
session_unset();
}
if(isset($_POST["project"]))
{
$_SESSION["project"] = $_POST["project"];
}
if(isset($_POST["slide"]))
{
$_SESSION["slide"] = $_POST["slide"];
}
if(isset($_GET["project"]))
{
$_SESSION["project"] = $_GET["project"];
}
if(isset($_GET["slide"]))
{
$_SESSION["slide"] = $_GET["slide"];
}
?>
<meta charset="UTF-8">
<!-- Description -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="highlights.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body onLoad="loaded()">
<div class="col-md-2 listpanel" style="top: 0; bottom:0; overflow-y: scroll;">
<a href="/"><h1>Snapper</h1></a>
<!-- OPEN PROJECT SECTION -->
<form action="index.php" method="post">
<table>
<tr>
<td><textarea name="project" required><?php if(isset($_SESSION["project"])) {echo($_SESSION["project"]);}?></textarea></td>
<td><input value="open" type='submit'></td>
</tr>
</table>
</form>
<?php
$dir = "snaps/";
if (is_dir($dir)){
if ($dh = opendir($dir)){
echo("<ul>");
while (($project = readdir($dh)) !== false){
if($project[0]!==".")
{
echo("<li><a href='index.php?project=$project'>$project</a></li>");
}
}
echo("</ul>");
}
}
?>
<hr>
<!-- LIST SLIDES AND CREATE FORWARD/BACKWARD Buttons-->
<?php
if(isset($_SESSION["project"])) {
$dir = "snaps/" . $_SESSION["project"];
if (is_dir($dir)){
if ($dh = opendir($dir)){
$files = array();
while (($file = readdir($dh)) !== false){
if($file[0]!==".")
{
array_push($files,$file);
}
}
sort($files);
closedir($dh);
$currentIndex=0;
if(isset($_SESSION["slide"])) {
if($_SESSION["slide"]===0)
{
$currentIndex=$files[0];
}
else
{
$currentIndex=array_search($_SESSION["slide"],$files);//gets index of slide
}
}
echo("<div class='col-md-6'>");
if($currentIndex>0){
$prev = $files[$currentIndex-1];
echo("<a href='index.php?slide=$prev'><span class='glyphicon glyphicon-chevron-left' aria-hidden='true'></span>");
}
echo("</div>");
echo("<div class='col-md-6'>");
if($currentIndex<count($files)-1)
{
$next = $files[$currentIndex+1];
echo("<a href='index.php?slide=$next'><span class='glyphicon glyphicon-chevron-right' aria-hidden='true'></span></a>");
}
echo("</div><br>");
echo("<ul>\n");
for($i=0; $i<count($files);$i++) {// CREATE LIST OF SLIDES HERE
$file=$files[$i];
if($file==$_SESSION["slide"]) {
echo("<li><a href='index.php?slide=$file'><strong>$file</strong></a></li>\n");
}
else {
echo("<li><a href='index.php?slide=$file'>$file</a></li>\n");
}
}
echo("</ul><br>");
}
else("Could not open directory");
}
else {
echo("Directory not found<br>");
}
}
?>
<hr>
<br>
<!-- ZIP UPLOAD SECTION -->
<form action="upload.php" method="post" enctype="multipart/form-data">
<table>
<tr>
<td>Zip file:</td>
<td><input type="file" name="zip"/></td>
</tr>
<tr>
<td>Trackable file:</td>
<td><input type="text" name="filename"/></td>
</tr>
<tr>
<td> </td>
<td><input value="open" type='submit'></td>
</tr>
</table>
</form>
<br>
<form action="index.php" method="get">
<input type="text" name="clear" value="kill" hidden/></td>
<td><input value="Exit" type='submit'></td>
</form>
</div>
<div class="col-md-5 codepanel" style="top: 0; bottom:0; overflow-y: scroll;">
<h2>Code</h2>
<hr>
<div id="codepanel">
<ol>
<?php
if(isset($_SESSION["project"]) and isset($_SESSION["slide"])) {
include("snaps/" . $_SESSION["project"] . "/" . $_SESSION["slide"]."/code.html");
}
?>
</ol>
</div>
</div>
<div class="col-md-5 outputpanel" style="top: 0; bottom:0; overflow-y: scroll;">
<h2>Output</h2>
<hr>
<?php
if(isset($_SESSION["project"]) and isset($_SESSION["slide"])) {
include("snaps/" . $_SESSION["project"] . "/" . $_SESSION["slide"]."/output.html");
}
?>
</div>
</body>
</html>