-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregenhtml.php
72 lines (66 loc) · 3.69 KB
/
regenhtml.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
<?php
session_start();
if(!(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true)){// make sure user is logged in
header("location: login.php");
exit;
}
if($_SERVER["REQUEST_METHOD"] == "POST"){
$year = '2020';//default to 2020
if(!empty(trim($_POST["year"]))){
$year = trim($_POST["year"]);
}
$html = file_get_contents('start.html');//this is the html "code" that will be written to the file. start.html contains some one time stuff like <head> and css
//$imgslist = "var imgs = [";
$imgslistnospace = "var imgsns = [";// spaghetti? sorry i dont speak italian
$cycle = ["gallery_thin","gallery_wide","gallery_thin","gallery_wide","gallery_thin","gallery_wide","gallery_wide","gallery_wide","gallery_wide"];// css cycle
$cycle2 = ["_thumbs_square","_thumbs","_thumbs_square","_thumbs","_thumbs_square","_thumbs","_thumbs","_thumbs","_thumbs"];// filename cycle. these cycles give the page the square/8:5 structure
$c = 0;//cycle index
if ($handle = opendir('imgAliases/'.$year)) {
while (false !== ($entry = readdir($handle))) {
if (!is_dir('imgAliases/'.$entry) && $entry != '.DS_Store') {//ds store because i have a mac and that file always gets generated and cant be removed
$c = 0;
$html .= "\n<div class = \"gallery_label\">".file_get_contents('imgAliases/'.$year.'/'.$entry)."</div>\n";
if ($handle2 = opendir('images/'.$entry)) {
while (false !== ($entry2 = readdir($handle2))) {
if (!is_dir('images/'.$entry2) && $entry2 != '.DS_Store') {
// $html .= "<div onclick=\"mediashow('".$entry."/".$entry2."')\" class=\"".$cycle[$c]."\"><img src=\"images/".$entry.$cycle2[$c]."/".$entry2."\"></div>\n";
$html .= "<div onclick=\"mediashow(this)\" class=\"".$cycle[$c]."\"><img src=\"images/".$entry.$cycle2[$c]."/".$entry2."\"></div>\n";
$imgslistnospace .= str_replace(' ','%20',"\"".$entry.'/'.$entry2.'",');
// $imgslist .= "\"".$entry.'/'.$entry2.'",';
$c = ($c+1)%count($cycle);
}
}
closedir($handle2);
}
}
}
closedir($handle);
}
//$jsfile = "var path = \"images/\";//var path = \"gallery".$year."/\";\n".substr($imgslist,0,strlen($imgslist)-1)."];\n".substr($imgslistnospace,0,strlen($imgslistnospace)-1)."];\n";
$jsfile = "var path = \"images/\";//var path = \"gallery".$year."/\";\n".substr($imgslistnospace,0,strlen($imgslistnospace)-1)."];\n";
//$html .= "<script>\nvar path = \"images/\";//var path = \"gallery".$year."/\";\n".substr($imgslist,0,strlen($imgslist)-1)."];\n".substr($imgslistnospace,0,strlen($imgslistnospace)-1)."];\n";
$jsfile .= file_get_contents('end.html');//add the file contents to the variable
//$html .= file_get_contents('end.html');//add the file contents to the variable
$html .= '<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.0.2/gsap.min.js"></script><script src="gallery'.$year.'.js"> </script></body></html>';
$f = fopen('gallery'.$year.'.html','w');//html file
fwrite($f,$html);
fclose($f);
$j = fopen('gallery'.$year.'.js','w');//js file
fwrite($j,$jsfile);
fclose($j);
echo "Mission passed, <br /><a href=\"gallery".$year.".html\">View gallery</a>";}
?>
<form action="" method="post">
<div>
<label>Year</label>
<input type="text" name="year" value="2020">
</div>
<div class="form-group">
<input type="submit" class="btn" value="Confirm">
</div>
</form>
<br />
regenerates the html file for the gallery
<br />
<a href="admin.php">Admin Portal</a>
<br />