-
Notifications
You must be signed in to change notification settings - Fork 1
/
edit_imgs.php
executable file
·78 lines (75 loc) · 2.19 KB
/
edit_imgs.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
<?php
session_start();
if(!$_SESSION['username']) {
header("Location: ./index.php");
}
if (isset($_GET['page'])) {
$selected_page = $_GET['page'];
} else {
header('location: index.php');
}
if (isset($_GET['status'])) {
$status = $_GET['status'];
}
if (isset($_POST['cap']) && isset($_POST['img'])) {
$img = $_POST['img'];
$caption = $_POST['cap'];
$array = array_combine($img, $caption);
foreach ($array as $src => $text) {
$file = file_get_contents("./pages/$selected_page/images.php");
$line = "<div class=\"img-container\"><img src=\"$src\" title=\"$text\"/></div>";
$file = str_replace($line, "\n", $file);
$file = preg_replace('/^[ \t]*[\r\n]+/m', '', $file);
file_put_contents("./pages/$selected_page/images.php", $file);
unlink("./$src");
header("locaton: ./edit_imgs.php?page=$selected_page&status=Deleted");
}
} else {
header("locaton: ./edit_imgs.php?page=$selected_page&status=Failed");
}
echo "<title>$selected_page</title>";
?>
<html>
<head>
<?php include("header.php"); ?>
<script src="./js/logoslide.js"></script>
<script src="./js/imgPreview.js"></script>
<script src="./js/selectImg.js"></script>
</head>
<div class="container">
<section class="main">
<?php
include("slider.php");
?>
<header role="banner"> <!-- begin content for the page -->
<h1>Edit <?php echo $selected_page_title; ?></h1>
</header> <!-- end [role="banner"] -->
<section class="img-display">
<div class="display-container">
<form action="<?php echo $_SERVER['PHP_SELF']."?page=$selected_page"; ?>" method="POST">
<?php
// include first 16 lines of images.php
$array = file("./pages/John/images.php");
$count = count($array);
for($i = 0; $i < $count; $i++) {
echo $array[$i];
}
// create blank images so total fills 4 by 4 grid
$line_count = count($array);
if($line_count[1] == '') {
$line_count--;
}
?>
<div id="selected">
</div>
</div>
<section class="full-display">
<p>Select the image(s) you want to delete</p>
<input type="submit" value="Delete">
</section>
</form>
</section> <!-- end section.img-display -->
</section> <!-- end section.main -->
</div> <!-- end div.container -->
</body>
</html>