-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
205 lines (198 loc) · 5.06 KB
/
Copy pathindex.php
File metadata and controls
205 lines (198 loc) · 5.06 KB
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
$images = array();
$newImages = array();
$images1 = array();
$notification = "";
$newNotif = "";
$deletedNotif = "";
// momentalen folder
$f = getcwd();
$curUrl = $f.$_SERVER['REQUEST_URI'];
if ($curUrl != $f.'/'){
if(is_dir($curUrl)){
// proverka dali ima sliki, i vnesuvanje na slikite vo niza ako ima
$empty = true;
$folder = opendir($curUrl);
$pic_types = array("jpg", "jpeg", "gif", "png");
while ($file = readdir ($folder)) {
$parts = explode(".", $file);
$ext = strtolower($parts[count($parts) - 1]);
if(in_array($ext, $pic_types))
{
array_push($images, $file);
$empty = false;
}
}
closedir($folder);
// proveruva dali postoi .conf file,
$filename = '.conf';
$filename = $curUrl.$filename;
//ako ne postoi SAMO go kreira,
if(!file_exists($filename)){
if ($empty == false){
$fp = fopen($filename,"w");
foreach($images as $key => $value){
fwrite($fp,$value."\r\n");
}
fclose($fp);
$notification = "Images added.";
}
else{
$fp = fopen($filename,"w");
fclose($fp);
$notification = "Configuration file created.";
}
}
else{
if ($empty == false){
//ako postoi I NE E PRAZEN,
$isEmpty = filesize($filename);
if($isEmpty > 0){
//proveruva dali ima novi sliki i gi dodava POSLE veke POSTOECKITE,
$oldImages = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$imagesSize = sizeof($images);
$oldImagesSize = sizeof($oldImages);
$i = 0;
for($i=0;$i<$imagesSize;$i++){
if (!(in_array($images[$i],$oldImages))){
array_push($newImages, $images[$i]);
}
}
$fp = fopen($filename,"a");
foreach($newImages as $key => $value){
fwrite($fp,$value."\r\n");
$newNotif = "New images added.";
}
fclose($fp);
//ako ima izbriseni sliki, gi dodava SITE sliki ODNOVO zaedno so NOVITE
$oldImages = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
for($i=0;$i<$oldImagesSize;$i++){
if (!(in_array($oldImages[$i],$images))){
unset($oldImages[$i]);
}
}
$oldImages = array_values($oldImages);
$fp = fopen($filename,"w");
foreach($oldImages as $key => $value){
fwrite($fp,$value."\r\n");
$deletedNotif = "Images deleted.";
}
fclose($fp);
$notification = "Images refreshed.";
}
//ako postoi I E PRAZEN, gi zapisuva iminjata na slikite,
else{
$fp = fopen($filename,"w");
foreach($images as $key => $value){
fwrite($fp,$value."\r\n");
}
fclose($fp);
$notification = "Images added.";
}
}
else{
if(file_exists($filename)){
$fp = fopen($filename,"w");
fclose($fp);
$notification = "Folder empty.";
}
}
}
$images1 = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
}
else{
$notification = "Folder does not exists.";
}
}
$fixPath = $_SERVER['REQUEST_URI'];
?>
<html>
<head>
<title>Images</title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="../js/jquery.flexslider-min.js"></script>
<script src="../js/modernizr.js"></script>
<link rel="stylesheet" type="text/css" href="../css/style.css">
<link rel="stylesheet" href="../css/flexslider.css" type="text/css" media="screen" />
<script type="text/javascript">
$(function(){
SyntaxHighlighter.all();
});
$(window).load(function(){
$('#carousel').flexslider({
animation: "slide",
controlNav: false,
animationLoop: false,
slideshow: false,
itemWidth: 210,
itemMargin: 5,
asNavFor: '#slider'
});
$('#slider').flexslider({
animation: "slide",
controlNav: false,
animationLoop: false,
slideshow: false,
sync: "#carousel",
start: function(slider){
$('body').removeClass('loading');
}
});
});
</script>
<!-- Syntax Highlighter -->
<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shBrushXml.js"></script>
<script type="text/javascript" src="../js/shBrushJScript.js"></script>
<!-- Optional FlexSlider Additions -->
<script src="../js/jquery.easing.js"></script>
<script src="../js/jquery.mousewheel.js"></script>
</head>
<body>
<div class="wrapper">
<div class="content">
<?php
if(sizeof($images1) == 0){
echo "<div class='notification'>".$notification."</div>";
}
else{
if (sizeof($newNotif) > 0 && sizeof($deletedNotif) > 0){
}
if (sizeof($newNotif) > 0){}
if (sizeof($deletedNotif) > 0){
}
echo "<div class='notification'>".$notification."</div>";
?>
<div id="slider" class="flexslider">
<ul class="slides">
<?php
$i = 0;
for($i=0;$i<sizeof($images1);$i++){
?>
<li>
<img src="<?php echo $images1[$i]; ?>" height="auto" width="500"/>
</li>
<?php
}
?>
</ul>
</div>
<div id="carousel" class="flexslider">
<ul class="slides">
<?php
$i = 0;
for($i=0;$i<sizeof($images1);$i++){
?>
<li>
<img src="<?php echo $images1[$i]; ?>" height="auto" width="500"/>
</li>
<?php
}
?>
</ul>
</div>
<?php } ?>
</div>
</div>
</body>
</html>