|
|
1 |
<?PHP
|
|
|
2 |
|
|
|
3 |
if($member_db[1] > 3 or ($member_db[1] != 1 and $action == "doimagedelete")){ msg("error", "Access Denied", "You don't have permission to manage images"); }
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
$allowed_extensions = array("gif", "jpg", "png", "bmp", "jpe", "jpeg");
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
// ********************************************************************************
|
|
|
15 |
|
|
|
16 |
// Show Preview of Image
|
|
|
17 |
|
|
|
18 |
// ********************************************************************************
|
|
|
19 |
if($action == "preview"){
|
|
|
20 |
|
|
|
21 |
echo <<<PREVIEWHTML
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
<HTML>
|
|
|
25 |
<HEAD>
|
|
|
26 |
<TITLE>Image Preview</TITLE>
|
|
|
27 |
<script language='javascript'>
|
|
|
28 |
var NS = (navigator.appName=="Netscape")?true:false;
|
|
|
29 |
|
|
|
30 |
function fitPic() {
|
|
|
31 |
iWidth = (NS)?window.innerWidth:document.body.clientWidth;
|
|
|
32 |
iHeight = (NS)?window.innerHeight:document.body.clientHeight;
|
|
|
33 |
iWidth = document.images[0].width - iWidth;
|
|
|
34 |
iHeight = document.images[0].height - iHeight;
|
|
|
35 |
window.resizeBy(iWidth, iHeight-1);
|
|
|
36 |
self.focus();
|
|
|
37 |
};
|
|
|
38 |
</script>
|
|
|
39 |
</HEAD>
|
|
|
40 |
<BODY bgcolor="#FFFFFF" onload='fitPic();' topmargin="0" marginheight="0" leftmargin="0" marginwidth="0">
|
|
|
41 |
<script language='javascript'>
|
|
|
42 |
document.write( "<img src='$config_http_script_dir/data/upimages/$image' border=0>" );
|
|
|
43 |
</script>
|
|
|
44 |
</BODY>
|
|
|
45 |
|
|
|
46 |
</HTML>
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
PREVIEWHTML;
|
|
|
50 |
|
|
|
51 |
}
|
|
|
52 |
// ********************************************************************************
|
|
|
53 |
|
|
|
54 |
// Show Images List
|
|
|
55 |
|
|
|
56 |
// ********************************************************************************
|
|
|
57 |
|
|
|
58 |
elseif($action != "doimagedelete")
|
|
|
59 |
|
|
|
60 |
{
|
|
|
61 |
|
|
|
62 |
if($action == "quick")
|
|
|
63 |
|
|
|
64 |
{
|
|
|
65 |
|
|
|
66 |
echo"<html>
|
|
|
67 |
|
|
|
68 |
<head>
|
|
|
69 |
|
|
|
70 |
<title>Insert Image</title>
|
|
|
71 |
|
|
|
72 |
<style type=\"text/css\">
|
|
|
73 |
|
|
|
74 |
<!--
|
|
|
75 |
|
|
|
76 |
select, option, textarea, input {
|
|
|
77 |
|
|
|
78 |
BORDER: #808080 1px solid;
|
|
|
79 |
|
|
|
80 |
COLOR: #000000;
|
|
|
81 |
|
|
|
82 |
FONT-SIZE: 11px;
|
|
|
83 |
|
|
|
84 |
FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffff
|
|
|
85 |
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
BODY, TD {text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;}
|
|
|
89 |
|
|
|
90 |
a:active,a:visited,a:link {font-size : 10px; color: #808080; font-family: verdana; text-decoration: none;}
|
|
|
91 |
|
|
|
92 |
a:hover {font-size : 10px; color: darkblue; font-weight:bold; text-decoration: none; }
|
|
|
93 |
.panel { border: 1px dotted silver; background-color: #F7F6F4;}
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
-->
|
|
|
97 |
|
|
|
98 |
</style>
|
|
|
99 |
|
|
|
100 |
</head>
|
|
|
101 |
|
|
|
102 |
<body bgcolor=#FFFFFF>
|
|
|
103 |
|
|
|
104 |
<script language=\"javascript\" type=\"text/javascript\">
|
|
|
105 |
|
|
|
106 |
<!--
|
|
|
107 |
|
|
|
108 |
function insertimage(selectedImage) {
|
|
|
109 |
var area = '$area';
|
|
|
110 |
|
|
|
111 |
alternativeText = document.forms['properties'].alternativeText.value;
|
|
|
112 |
imageAlign = document.forms['properties'].imageAlign.value;
|
|
|
113 |
imageBorder = document.forms['properties'].imageBorder.value;
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
//finalImage = \" <img style=\\\"border:\"+ imageBorder +\"; vertical-align:\"+ imageAlign +\";\\\" alt=\\\"\"+ alternativeText +\"\\\" src=\\\"$config_http_script_dir/data/upimages/\"+ selectedImage +\"\\\">\";
|
|
|
117 |
|
|
|
118 |
finalImage = \" <img border=\\\"\"+ imageBorder +\"\\\" align=\\\"\"+ imageAlign +\"\\\" alt=\\\"\"+ alternativeText +\"\\\" src=\\\"$config_http_script_dir/data/upimages/\"+ selectedImage +\"\\\">\";
|
|
|
119 |
";
|
|
|
120 |
|
|
|
121 |
if($wysiwyg){
|
|
|
122 |
|
|
|
123 |
echo"
|
|
|
124 |
MYRTE=window.opener.document.getElementById(area).contentWindow;
|
|
|
125 |
window.opener.currentRTE=area; MYRTE.document.execCommand('InsertImage', false, '-my-temp-img-url-');
|
|
|
126 |
replacement = \"$config_http_script_dir/data/upimages/\" + selectedImage + \"\\\" alt=\\\"\" + alternativeText + \"\\\" border=\\\"\" + imageBorder + \"\\\" align=\\\"\" + imageAlign;
|
|
|
127 |
MYRTE.document.body.innerHTML = MYRTE.document.body.innerHTML.replace(/-my-temp-img-url-/gi,replacement);
|
|
|
128 |
|
|
|
129 |
";
|
|
|
130 |
|
|
|
131 |
|
|
|
132 |
}
|
|
|
133 |
else{ echo"opener.document.getElementById(area).value += finalImage;"; }
|
|
|
134 |
|
|
|
135 |
// echo"alert(finalImage);";
|
|
|
136 |
|
|
|
137 |
echo"
|
|
|
138 |
|
|
|
139 |
window.close();
|
|
|
140 |
//opener.document.getElementById(area).focus();
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
function PopupPic(sPicURL) {
|
|
|
146 |
window.open('$PHP_SELF?mod=images&action=preview&image='+sPicURL, '', 'resizable=1,HEIGHT=200,WIDTH=200');
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
window.resizeTo(410, 550);
|
|
|
150 |
self.focus();
|
|
|
151 |
|
|
|
152 |
//-->
|
|
|
153 |
|
|
|
154 |
</script>";
|
|
|
155 |
|
|
|
156 |
}else{ echoheader("images","Manage Images"); }
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
// ********************************************************************************
|
|
|
161 |
|
|
|
162 |
// Upload Image(s)
|
|
|
163 |
|
|
|
164 |
// ********************************************************************************
|
|
|
165 |
|
|
|
166 |
if($subaction == "upload")
|
|
|
167 |
{
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
for ($image_i = 1; $image_i < ($images_number+1); $image_i++) {
|
|
|
172 |
$current_image = 'image_'.$image_i;
|
|
|
173 |
|
|
|
174 |
$image = $_FILES[$current_image]['tmp_name'];
|
|
|
175 |
$image_name = $_FILES[$current_image]['name'];
|
|
|
176 |
$image_name = str_replace(" ", "_", $image_name);
|
|
|
177 |
|
|
|
178 |
$img_name_arr = explode(".",$image_name);
|
|
|
179 |
$type = end($img_name_arr);
|
|
|
180 |
|
|
|
181 |
|
|
|
182 |
if($image_name == ""){ $img_result .= "<br><font color=red>$current_image -> No File Specified For Upload!</font>"; }
|
|
|
183 |
elseif( !isset($overwrite) and file_exists($config_path_image_upload."/".$image_name)){ $img_result .= "<br><font color=red>$image_name -> Image already exist!</font>";}
|
|
|
184 |
elseif( !(in_array($type, $allowed_extensions) or in_array(strtolower($type), $allowed_extensions)) ){
|
|
|
185 |
$img_result .= "<br><font color=red>$image_name ->This type of file is not allowed !!!</font>";
|
|
|
186 |
}
|
|
|
187 |
else{ //Image is OK, upload it
|
|
|
188 |
|
|
|
189 |
@copy($image, $config_path_image_upload."/".$image_name) or $img_result .= "<br><font color=red>$image_name -> Couldn't copy image to server</font><br />Check if file_uploads is allowed in the php.ini file of your server";
|
|
|
190 |
if(file_exists($config_path_image_upload."/".$image_name))
|
|
|
191 |
{
|
|
|
192 |
$img_result .= "<br><font color=green>$image_name -> Image was uploaded</font>";
|
|
|
193 |
if($action == "quick"){
|
|
|
194 |
$img_result .= " <a title=\"Inser this image in the $my_area\" href=\"javascript:insertimage('$image_name');\">[insert it]</a>";
|
|
|
195 |
}
|
|
|
196 |
}//if file is uploaded succesfully
|
|
|
197 |
|
|
|
198 |
}
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
//
|
|
|
207 |
// Add the JS for multyple image upload.
|
|
|
208 |
//
|
|
|
209 |
echo<<<HTMLJS
|
|
|
210 |
|
|
|
211 |
<script language='javascript'>
|
|
|
212 |
|
|
|
213 |
function AddRowsToTable() {
|
|
|
214 |
var tbl = document.getElementById('tblSample');
|
|
|
215 |
var lastRow = tbl.rows.length;
|
|
|
216 |
|
|
|
217 |
// if there's no header row in the table, then iteration = lastRow + 1
|
|
|
218 |
var iteration = lastRow+1;
|
|
|
219 |
var row = tbl.insertRow(lastRow);
|
|
|
220 |
|
|
|
221 |
var cellRight = row.insertCell(0);
|
|
|
222 |
var el = document.createElement('input');
|
|
|
223 |
el.setAttribute('type', 'file');
|
|
|
224 |
el.setAttribute('name', 'image_' + iteration);
|
|
|
225 |
el.setAttribute('size', '30');
|
|
|
226 |
el.setAttribute('value', iteration);
|
|
|
227 |
cellRight.appendChild(el);
|
|
|
228 |
|
|
|
229 |
document.getElementById('images_number').value = iteration;
|
|
|
230 |
}
|
|
|
231 |
function RemoveRowFromTable() {
|
|
|
232 |
var tbl = document.getElementById('tblSample');
|
|
|
233 |
var lastRow = tbl.rows.length;
|
|
|
234 |
if (lastRow > 1){
|
|
|
235 |
tbl.deleteRow(lastRow - 1);
|
|
|
236 |
document.getElementById('images_number').value = document.getElementById('images_number').value - 1;
|
|
|
237 |
}
|
|
|
238 |
}
|
|
|
239 |
|
|
|
240 |
</script>
|
|
|
241 |
|
|
|
242 |
HTMLJS;
|
|
|
243 |
|
|
|
244 |
|
|
|
245 |
|
|
|
246 |
echo<<<HTML
|
|
|
247 |
<form name="form" id="form" action="$PHP_SELF?mod=images" method="post" enctype="multipart/form-data">
|
|
|
248 |
|
|
|
249 |
|
|
|
250 |
<table border=0 cellpading=0 cellspacing=0 width=100%>
|
|
|
251 |
<td height=33>
|
|
|
252 |
<b>Upload Image</b>
|
|
|
253 |
<table border=0 cellpading=0 cellspacing=0 class="panel" cellpadding=8>
|
|
|
254 |
<tr>
|
|
|
255 |
<td height=25>
|
|
|
256 |
|
|
|
257 |
<table border="0" cellspacing="0" cellpadding="0" id="tblSample">
|
|
|
258 |
<tr id="row">
|
|
|
259 |
<td width="1" colspan="2"><input type="file" size="30" name="image_1"></td>
|
|
|
260 |
</tr>
|
|
|
261 |
</table>
|
|
|
262 |
<table border="0" cellspacing="0" cellpadding="0" style="margin-top:5px;">
|
|
|
263 |
<tr>
|
|
|
264 |
<td>
|
|
|
265 |
<INPUT TYPE="SUBMIT" name="submit" VALUE="Upload" style="font-weight:bold;">
|
|
|
266 |
<input type=button value='-' style="font-weight:bold; width:22px;" title='Remove last file input box' onClick="RemoveRowFromTable();return false;">
|
|
|
267 |
<input type=button value='+' style="font-weight:bold; width:22px;" title='Add another file input box' onClick="AddRowsToTable();return false;">
|
|
|
268 |
<input style="border:0px; background-color:#F7F6F4;" type=checkbox name=overwrite id=overwrite value=1><label title='Overwrite file(s) if exist' for=overwrite> Overwrite</label>
|
|
|
269 |
|
|
|
270 |
</td>
|
|
|
271 |
</tr>
|
|
|
272 |
</table>
|
|
|
273 |
$img_result
|
|
|
274 |
</table>
|
|
|
275 |
|
|
|
276 |
<input type=hidden name=wysiwyg value='$wysiwyg'>
|
|
|
277 |
<input type=hidden name=subaction value=upload>
|
|
|
278 |
<input type=hidden name=area value='$area'>
|
|
|
279 |
<input type=hidden name=action value='$action'>
|
|
|
280 |
<input type=hidden name='images_number' id='images_number' value='1'>
|
|
|
281 |
</form>
|
|
|
282 |
|
|
|
283 |
HTML;
|
|
|
284 |
|
|
|
285 |
|
|
|
286 |
if($action == "quick"){
|
|
|
287 |
echo"
|
|
|
288 |
<form name=properties>
|
|
|
289 |
<table style='margin-top:10px;' border=0 cellpading=0 cellspacing=0 width=100%>
|
|
|
290 |
|
|
|
291 |
<td height=33>
|
|
|
292 |
<b>Image Properties</b>
|
|
|
293 |
<table border=0 cellpading=0 cellspacing=0 class=\"panel\" style='padding:5px'width=290px; >
|
|
|
294 |
|
|
|
295 |
|
|
|
296 |
<tr>
|
|
|
297 |
<td width=80>Alt. Text: </td>
|
|
|
298 |
<td><input tabindex=1 type=text name=alternativeText style=\"width:150;\"></td>
|
|
|
299 |
</tr>
|
|
|
300 |
|
|
|
301 |
<tr>
|
|
|
302 |
<td>Image Align</td>
|
|
|
303 |
<td>
|
|
|
304 |
<select name='imageAlign' style='width:150'>
|
|
|
305 |
<option value=none>None</option>
|
|
|
306 |
<option value=left>Left</option>
|
|
|
307 |
<option value=right>Right</option>
|
|
|
308 |
</select>
|
|
|
309 |
</td>
|
|
|
310 |
</tr>
|
|
|
311 |
|
|
|
312 |
<tr>
|
|
|
313 |
<td>Border</td>
|
|
|
314 |
<td><input type=text value='0' name=imageBorder style=\"width:35\"> pixels</td>
|
|
|
315 |
</tr>
|
|
|
316 |
|
|
|
317 |
</table>
|
|
|
318 |
</table></form>";
|
|
|
319 |
}
|
|
|
320 |
|
|
|
321 |
|
|
|
322 |
|
|
|
323 |
echo"<tr><td><img height=1 style=\"height: 13px !important; height: 1px;\" border=0 src=\"skins/images/blank.gif\" width=1></tr><tr><td>
|
|
|
324 |
<b>Uploaded Images</b>
|
|
|
325 |
</tr>
|
|
|
326 |
|
|
|
327 |
<tr >
|
|
|
328 |
|
|
|
329 |
<td height=1>
|
|
|
330 |
<FORM action='$PHP_SELF?mod=images' METHOD='POST'>
|
|
|
331 |
<table width=100% height=100% cellspacing=0 cellpadding=0>";
|
|
|
332 |
|
|
|
333 |
$img_dir = opendir($config_path_image_upload);
|
|
|
334 |
|
|
|
335 |
|
|
|
336 |
|
|
|
337 |
$i = 0;
|
|
|
338 |
|
|
|
339 |
while ($file = readdir($img_dir))
|
|
|
340 |
{
|
|
|
341 |
//Yes we'll store them in array for sorting
|
|
|
342 |
$images_in_dir[] = $file;
|
|
|
343 |
}
|
|
|
344 |
natcasesort($images_in_dir);
|
|
|
345 |
reset($images_in_dir);
|
|
|
346 |
foreach ($images_in_dir as $file) {
|
|
|
347 |
|
|
|
348 |
|
|
|
349 |
|
|
|
350 |
|
|
|
351 |
$img_name_arr = explode(".",$file);
|
|
|
352 |
$img_type = end($img_name_arr);
|
|
|
353 |
|
|
|
354 |
|
|
|
355 |
if ( (in_array($img_type, $allowed_extensions) or in_array(strtolower($img_type), $allowed_extensions)) and $file != ".." and $file != "." and is_file($config_path_image_upload."/".$file))
|
|
|
356 |
|
|
|
357 |
{
|
|
|
358 |
|
|
|
359 |
$i++;
|
|
|
360 |
|
|
|
361 |
$this_size = filesize($config_path_image_upload."/".$file);
|
|
|
362 |
|
|
|
363 |
$total_size += $this_size;
|
|
|
364 |
|
|
|
365 |
$img_info = getimagesize($config_path_image_upload."/".$file);
|
|
|
366 |
|
|
|
367 |
if( $i%2 != 0 ){ $bg = "bgcolor=#F7F6F4"; }
|
|
|
368 |
|
|
|
369 |
else{ $bg = ""; }
|
|
|
370 |
|
|
|
371 |
|
|
|
372 |
|
|
|
373 |
if($action == "quick")
|
|
|
374 |
|
|
|
375 |
{
|
|
|
376 |
|
|
|
377 |
$my_area = str_replace("_", " ", $area);
|
|
|
378 |
|
|
|
379 |
echo"
|
|
|
380 |
|
|
|
381 |
<tr $bg><td height=16 width=1px> <a title='Preview this image' href=\"javascript:PopupPic('$file')\"><img style='border:0px;' src='skins/images/view_image.gif'></a>
|
|
|
382 |
<td height=16 width=100%>
|
|
|
383 |
|
|
|
384 |
<a title=\"Insert this image in the $my_area\" href=\"javascript:insertimage('$file')\">$file</a>
|
|
|
385 |
|
|
|
386 |
|
|
|
387 |
|
|
|
388 |
<td height=16 align=right>
|
|
|
389 |
|
|
|
390 |
$img_info[0]x$img_info[1]
|
|
|
391 |
|
|
|
392 |
|
|
|
393 |
|
|
|
394 |
<td height=16 align=right>
|
|
|
395 |
|
|
|
396 |
". formatsize($this_size) ."
|
|
|
397 |
|
|
|
398 |
</tr>";
|
|
|
399 |
|
|
|
400 |
}
|
|
|
401 |
|
|
|
402 |
else
|
|
|
403 |
|
|
|
404 |
{
|
|
|
405 |
|
|
|
406 |
echo"<tr $bg><td height=16>
|
|
|
407 |
|
|
|
408 |
|
|
|
409 |
|
|
|
410 |
<td height=16 width=63% >
|
|
|
411 |
|
|
|
412 |
<a target=_blank href=\"". $config_path_image_upload ."/$file\">$file</a>
|
|
|
413 |
|
|
|
414 |
|
|
|
415 |
|
|
|
416 |
<td height=16 align=right>
|
|
|
417 |
|
|
|
418 |
$img_info[0]x$img_info[1]
|
|
|
419 |
|
|
|
420 |
|
|
|
421 |
|
|
|
422 |
<td height=16 align=right>
|
|
|
423 |
|
|
|
424 |
". formatsize($this_size) ."
|
|
|
425 |
|
|
|
426 |
<td width=70 height=16 align=right>
|
|
|
427 |
<input type=checkbox name=images[$file] value=\"$file\">
|
|
|
428 |
|
|
|
429 |
</tr>";
|
|
|
430 |
|
|
|
431 |
}
|
|
|
432 |
|
|
|
433 |
}
|
|
|
434 |
|
|
|
435 |
}
|
|
|
436 |
|
|
|
437 |
|
|
|
438 |
|
|
|
439 |
if($i > 0){
|
|
|
440 |
|
|
|
441 |
echo"<tr ><td height=16>";
|
|
|
442 |
|
|
|
443 |
|
|
|
444 |
if($action != "quick"){
|
|
|
445 |
echo" <td colspan=4 align=right>
|
|
|
446 |
<br><input type=submit value='Delete Selected Images'>
|
|
|
447 |
</tr>";
|
|
|
448 |
|
|
|
449 |
}
|
|
|
450 |
|
|
|
451 |
echo"<tr heigh=1>
|
|
|
452 |
<td width=14>
|
|
|
453 |
|
|
|
454 |
<td >
|
|
|
455 |
<br /><b>Total size</b>
|
|
|
456 |
<td>
|
|
|
457 |
<td align=right>
|
|
|
458 |
|
|
|
459 |
<br /><b>". formatsize($total_size) .'</b>
|
|
|
460 |
|
|
|
461 |
</tr>';
|
|
|
462 |
|
|
|
463 |
}
|
|
|
464 |
|
|
|
465 |
echo'
|
|
|
466 |
</table><input type=hidden name=action value=doimagedelete></form></table>';
|
|
|
467 |
|
|
|
468 |
if($action != "quick"){ echofooter(); }
|
|
|
469 |
|
|
|
470 |
}
|
|
|
471 |
|
|
|
472 |
// ********************************************************************************
|
|
|
473 |
|
|
|
474 |
// Delete Image
|
|
|
475 |
|
|
|
476 |
// ********************************************************************************
|
|
|
477 |
|
|
|
478 |
elseif($action == "doimagedelete")
|
|
|
479 |
|
|
|
480 |
{
|
|
|
481 |
if(!isset($images)){ msg("info","No Images selected","You must select images to be deleted.", "$PHP_SELF?mod=images"); }
|
|
|
482 |
// if(!file_exists($config_path_image_upload."/".$image) or !$image){ msg("error","Error !!!","Could not delete image", "$PHP_SELF?mod=images"); }
|
|
|
483 |
foreach($images as $image){
|
|
|
484 |
unlink($config_path_image_upload."/".$image) or print("Could not delete image <b>$file</b>");
|
|
|
485 |
}
|
|
|
486 |
msg("info","Image(s) Deleted","The image was successfully deleted.", "$PHP_SELF?mod=images");
|
|
|
487 |
|
|
|
488 |
}
|
|
|
489 |
|
|
|
490 |
|
|
|
491 |
|
|
|
492 |
?> |