[2] | 1 | <? |
---|
| 2 | /*********************************************************************** |
---|
| 3 | ** Title.........: Image Manager, draws the thumbnails and directies |
---|
| 4 | ** Version.......: 1.01 |
---|
| 5 | ** Author........: Xiang Wei ZHUO <wei@zhuo.org> |
---|
| 6 | ** Filename......: images.php |
---|
| 7 | ** Last changed..: 8 Mar 2003 |
---|
| 8 | ** Notes.........: Configuration in config.inc.php |
---|
| 9 | |
---|
| 10 | Functions |
---|
| 11 | - create a new folder, |
---|
| 12 | - delete folder, |
---|
| 13 | - upload new image |
---|
| 14 | - use cached thumbnail views |
---|
| 15 | |
---|
| 16 | ***********************************************************************/ |
---|
| 17 | |
---|
| 18 | include 'config.inc.php'; |
---|
| 19 | |
---|
| 20 | if(isset($_GET['dir'])) { |
---|
| 21 | $dirParam = $_GET['dir']; |
---|
| 22 | |
---|
| 23 | if(strlen($dirParam) > 0) |
---|
| 24 | { |
---|
| 25 | if(substr($dirParam,0,1)=='/') |
---|
| 26 | $IMG_ROOT .= $dirParam; |
---|
| 27 | else |
---|
| 28 | $IMG_ROOT = $dirParam; |
---|
| 29 | } |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | $refresh_dirs = false; |
---|
| 33 | $clearUploads = false; |
---|
| 34 | |
---|
| 35 | if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1) |
---|
| 36 | $IMG_ROOT .= '/'; |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | if(isset($_GET['create']) && isset($_GET['dir']) && $SAFE_MODE == false) |
---|
| 40 | { |
---|
| 41 | create_folder(); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | if(isset($_GET['delFile']) && isset($_GET['dir'])) |
---|
| 45 | { |
---|
| 46 | delete_file($_GET['delFile']); |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | if(isset($_GET['delFolder']) && isset($_GET['dir'])) |
---|
| 50 | { |
---|
| 51 | delete_folder($_GET['delFolder']); |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | if(isset($_FILES['upload']) && is_array($_FILES['upload']) && isset($_POST['dirPath'])) |
---|
| 55 | { |
---|
| 56 | |
---|
| 57 | $dirPathPost = $_POST['dirPath']; |
---|
| 58 | |
---|
| 59 | if(strlen($dirPathPost) > 0) |
---|
| 60 | { |
---|
| 61 | if(substr($dirPathPost,0,1)=='/') |
---|
| 62 | $IMG_ROOT .= $dirPathPost; |
---|
| 63 | else |
---|
| 64 | $IMG_ROOT = $dirPathPost; |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1) |
---|
| 68 | $IMG_ROOT .= '/'; |
---|
| 69 | |
---|
| 70 | do_upload($_FILES['upload'], $BASE_DIR.$BASE_ROOT.$dirPathPost.'/'); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | function do_upload($file, $dest_dir) |
---|
| 74 | { |
---|
| 75 | global $clearUploads; |
---|
| 76 | |
---|
| 77 | if(is_file($file['tmp_name'])) |
---|
| 78 | { |
---|
| 79 | //var_dump($file); echo "DIR:$dest_dir"; |
---|
| 80 | move_uploaded_file($file['tmp_name'], $dest_dir.$file['name']); |
---|
| 81 | chmod($dest_dir.$file['name'], 0666); |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | $clearUploads = true; |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | function delete_folder($folder) |
---|
| 90 | { |
---|
| 91 | global $BASE_DIR, $refresh_dirs; |
---|
| 92 | //var_dump($BASE_DIR); |
---|
| 93 | $del_folder = dir_name($BASE_DIR).$folder; |
---|
| 94 | //echo $del_folder; |
---|
| 95 | if(is_dir($del_folder) && num_files($del_folder) <= 0) { |
---|
| 96 | //echo $del_folder.'<br>'; |
---|
| 97 | rm_all_dir($del_folder); |
---|
| 98 | $refresh_dirs = true; |
---|
| 99 | } |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | function rm_all_dir($dir) |
---|
| 103 | { |
---|
| 104 | //$dir = dir_name($dir); |
---|
| 105 | //echo "OPEN:".$dir.'<Br>'; |
---|
| 106 | if(is_dir($dir)) |
---|
| 107 | { |
---|
| 108 | $d = @dir($dir); |
---|
| 109 | |
---|
| 110 | while (false !== ($entry = $d->read())) |
---|
| 111 | { |
---|
| 112 | //echo "#".$entry.'<br>'; |
---|
| 113 | if($entry != '.' && $entry != '..') |
---|
| 114 | { |
---|
| 115 | $node = $dir.'/'.$entry; |
---|
| 116 | //echo "NODE:".$node; |
---|
| 117 | if(is_file($node)) { |
---|
| 118 | //echo " - is file<br>"; |
---|
| 119 | unlink($node); |
---|
| 120 | } |
---|
| 121 | else if(is_dir($node)) { |
---|
| 122 | //echo " - is Dir<br>"; |
---|
| 123 | rm_all_dir($node); |
---|
| 124 | } |
---|
| 125 | } |
---|
| 126 | } |
---|
| 127 | $d->close(); |
---|
| 128 | |
---|
| 129 | rmdir($dir); |
---|
| 130 | } |
---|
| 131 | //echo "RM: $dir <br>"; |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | function delete_file($file) |
---|
| 135 | { |
---|
| 136 | global $BASE_DIR; |
---|
| 137 | |
---|
| 138 | $del_image = dir_name($BASE_DIR).$file; |
---|
| 139 | |
---|
| 140 | $del_thumb = dir_name($del_image).'.'.basename($del_image); |
---|
| 141 | |
---|
| 142 | if(is_file($del_image)) { |
---|
| 143 | unlink($del_image); |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | if(is_file($del_thumb)) { |
---|
| 147 | unlink($del_thumb); |
---|
| 148 | } |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | function create_folder() |
---|
| 152 | { |
---|
| 153 | global $BASE_DIR, $IMG_ROOT, $refresh_dirs; |
---|
| 154 | |
---|
| 155 | $folder_name = $_GET['foldername']; |
---|
| 156 | |
---|
| 157 | if(strlen($folder_name) >0) |
---|
| 158 | { |
---|
| 159 | $folder = $BASE_DIR.$IMG_ROOT.$folder_name; |
---|
| 160 | |
---|
| 161 | if(!is_dir($folder) && !is_file($folder)) |
---|
| 162 | { |
---|
| 163 | mkdir($folder,0777); |
---|
| 164 | chmod($folder,0777); |
---|
| 165 | $refresh_dirs = true; |
---|
| 166 | } |
---|
| 167 | } |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | function num_files($dir) |
---|
| 171 | { |
---|
| 172 | $total = 0; |
---|
| 173 | |
---|
| 174 | if(is_dir($dir)) |
---|
| 175 | { |
---|
| 176 | $d = @dir($dir); |
---|
| 177 | |
---|
| 178 | while (false !== ($entry = $d->read())) |
---|
| 179 | { |
---|
| 180 | //echo $entry."<br>"; |
---|
| 181 | if(substr($entry,0,1) != '.') { |
---|
| 182 | $total++; |
---|
| 183 | } |
---|
| 184 | } |
---|
| 185 | $d->close(); |
---|
| 186 | } |
---|
| 187 | return $total; |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | function dirs($dir,$abs_path) |
---|
| 191 | { |
---|
| 192 | $d = dir($dir); |
---|
| 193 | //echo "Handle: ".$d->handle."<br>\n"; |
---|
| 194 | //echo "Path: ".$d->path."<br>\n"; |
---|
| 195 | $dirs = array(); |
---|
| 196 | while (false !== ($entry = $d->read())) { |
---|
| 197 | if(is_dir($dir.'/'.$entry) && substr($entry,0,1) != '.') |
---|
| 198 | { |
---|
| 199 | //dirs($dir.'/'.$entry, $prefix.$prefix); |
---|
| 200 | //echo $prefix.$entry."<br>\n"; |
---|
| 201 | $path['path'] = $dir.'/'.$entry; |
---|
| 202 | $path['name'] = $entry; |
---|
| 203 | $dirs[$entry] = $path; |
---|
| 204 | } |
---|
| 205 | } |
---|
| 206 | $d->close(); |
---|
| 207 | |
---|
| 208 | ksort($dirs); |
---|
| 209 | for($i=0; $i<count($dirs); $i++) |
---|
| 210 | { |
---|
| 211 | $name = key($dirs); |
---|
| 212 | $current_dir = $abs_path.'/'.$dirs[$name]['name']; |
---|
| 213 | echo ", \"$current_dir\"\n"; |
---|
| 214 | dirs($dirs[$name]['path'],$current_dir); |
---|
| 215 | next($dirs); |
---|
| 216 | } |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | function parse_size($size) |
---|
| 220 | { |
---|
| 221 | if($size < 1024) |
---|
| 222 | return $size.' btyes'; |
---|
| 223 | else if($size >= 1024 && $size < 1024*1024) |
---|
| 224 | { |
---|
| 225 | return sprintf('%01.2f',$size/1024.0).' Kb'; |
---|
| 226 | } |
---|
| 227 | else |
---|
| 228 | { |
---|
| 229 | return sprintf('%01.2f',$size/(1024.0*1024)).' Mb'; |
---|
| 230 | } |
---|
| 231 | } |
---|
| 232 | |
---|
| 233 | function show_image($img, $file, $info, $size) |
---|
| 234 | { |
---|
| 235 | global $BASE_DIR, $BASE_URL, $newPath; |
---|
| 236 | |
---|
| 237 | $img_path = dir_name($img); |
---|
| 238 | $img_file = basename($img); |
---|
| 239 | |
---|
| 240 | $thumb_image = 'thumbs.php?img='.urlencode($img); |
---|
| 241 | |
---|
| 242 | $img_url = $BASE_URL.$img_path.'/'.$img_file; |
---|
| 243 | |
---|
| 244 | $filesize = parse_size($size); |
---|
| 245 | |
---|
| 246 | ?> |
---|
| 247 | <td> |
---|
| 248 | <table width="102" border="0" cellpadding="0" cellspacing="2"> |
---|
| 249 | <tr> |
---|
| 250 | <td align="center" class="imgBorder" onMouseOver="pviiClassNew(this,'imgBorderHover')" onMouseOut="pviiClassNew(this,'imgBorder')"> |
---|
| 251 | <a href="javascript:;" onClick="javascript:imageSelected('<? echo $img_url; ?>', <? echo $info[0];?>, <? echo $info[1]; ?>,'<? echo $file; ?>');"><img src="<? echo $thumb_image; ?>" alt="<? echo $file; ?> - <? echo $filesize; ?>" border="0"></a></td> |
---|
| 252 | </tr> |
---|
| 253 | <tr> |
---|
| 254 | <td><table width="100%" border="0" cellspacing="0" cellpadding="2"> |
---|
| 255 | <tr> |
---|
| 256 | <td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')"> |
---|
| 257 | <a href="javascript:;" onClick="javascript:preview('<? echo $img_url; ?>', '<? echo $file; ?>', ' <? echo $filesize; ?>',<? echo $info[0].','.$info[1]; ?>);"><img src="edit_pencil.gif" width="15" height="15" border="0"></a></td> |
---|
| 258 | <td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')"> |
---|
| 259 | <a href="images.php?delFile=<? echo $img_url; ?>&dir=<? echo $newPath; ?>" onClick="return deleteImage('<? echo $file; ?>');"><img src="edit_trash.gif" width="15" height="15" border="0"></a></td> |
---|
| 260 | <td width="98%" class="imgCaption"><? echo $info[0].'x'.$info[1]; ?></td> |
---|
| 261 | </tr> |
---|
| 262 | </table></td> |
---|
| 263 | </tr> |
---|
| 264 | </table> |
---|
| 265 | </td> |
---|
| 266 | <? |
---|
| 267 | } |
---|
| 268 | |
---|
| 269 | function show_dir($path, $dir) |
---|
| 270 | { |
---|
| 271 | global $newPath, $BASE_DIR, $BASE_URL; |
---|
| 272 | |
---|
| 273 | $num_files = num_files($BASE_DIR.$path); |
---|
| 274 | ?> |
---|
| 275 | <td> |
---|
| 276 | <table width="102" border="0" cellpadding="0" cellspacing="2"> |
---|
| 277 | <tr> |
---|
| 278 | <td align="center" class="imgBorder" onMouseOver="pviiClassNew(this,'imgBorderHover')" onMouseOut="pviiClassNew(this,'imgBorder')"> |
---|
| 279 | <a href="images.php?dir=<? echo $path; ?>" onClick="changeLoadingStatus('load')"> |
---|
| 280 | <img src="folder.gif" width="80" height="80" border=0 alt="<? echo $dir; ?>"> |
---|
| 281 | </a> |
---|
| 282 | </td> |
---|
| 283 | </tr> |
---|
| 284 | <tr> |
---|
| 285 | <td><table width="100%" border="0" cellspacing="1" cellpadding="2"> |
---|
| 286 | <tr> |
---|
| 287 | <td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')"> |
---|
| 288 | <a href="images.php?delFolder=<? echo $BASE_URL.$path; ?>&dir=<? echo $newPath; ?>" onClick="return deleteFolder('<? echo $dir; ?>', <? echo $num_files; ?>);"><img src="edit_trash.gif" width="15" height="15" border="0"></a></td> |
---|
| 289 | <td width="99%" class="imgCaption"><? echo $dir; ?></td> |
---|
| 290 | </tr> |
---|
| 291 | </table></td> |
---|
| 292 | </tr> |
---|
| 293 | </table> |
---|
| 294 | </td> |
---|
| 295 | <? |
---|
| 296 | } |
---|
| 297 | |
---|
| 298 | function draw_no_results() |
---|
| 299 | { |
---|
| 300 | ?> |
---|
| 301 | <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"> |
---|
| 302 | <tr> |
---|
| 303 | <td><div align="center" style="font-size:large;font-weight:bold;color:#CCCCCC;font-family: Helvetica, sans-serif;">No Images Found</div></td> |
---|
| 304 | </tr> |
---|
| 305 | </table> |
---|
| 306 | <? |
---|
| 307 | } |
---|
| 308 | |
---|
| 309 | function draw_no_dir() |
---|
| 310 | { |
---|
| 311 | global $BASE_DIR, $BASE_ROOT; |
---|
| 312 | ?> |
---|
| 313 | <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"> |
---|
| 314 | <tr> |
---|
| 315 | <td><div align="center" style="font-size:small;font-weight:bold;color:#CC0000;font-family: Helvetica, sans-serif;">Configuration Problem: "<? echo $BASE_DIR.$BASE_ROOT; ?>" does not exist.</div></td> |
---|
| 316 | </tr> |
---|
| 317 | </table> |
---|
| 318 | <? |
---|
| 319 | } |
---|
| 320 | |
---|
| 321 | |
---|
| 322 | function draw_table_header() |
---|
| 323 | { |
---|
| 324 | echo '<table border="0" cellpadding="0" cellspacing="2">'; |
---|
| 325 | echo '<tr>'; |
---|
| 326 | } |
---|
| 327 | |
---|
| 328 | function draw_table_footer() |
---|
| 329 | { |
---|
| 330 | echo '</tr>'; |
---|
| 331 | echo '</table>'; |
---|
| 332 | } |
---|
| 333 | |
---|
| 334 | ?> |
---|
| 335 | <html> |
---|
| 336 | <head> |
---|
| 337 | <title>Image Browser</title> |
---|
| 338 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
| 339 | <style type="text/css"> |
---|
| 340 | <!-- |
---|
| 341 | .imgBorder { |
---|
| 342 | height: 96px; |
---|
| 343 | border: 1px solid threedface; |
---|
| 344 | vertical-align: middle; |
---|
| 345 | } |
---|
| 346 | .imgBorderHover { |
---|
| 347 | height: 96px; |
---|
| 348 | border: 1px solid threedface; |
---|
| 349 | vertical-align: middle; |
---|
| 350 | background: #FFFFCC; |
---|
| 351 | cursor: hand; |
---|
| 352 | } |
---|
| 353 | |
---|
| 354 | .buttonHover { |
---|
| 355 | border: 1px solid; |
---|
| 356 | border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; |
---|
| 357 | cursor: hand; |
---|
| 358 | background: #FFFFCC; |
---|
| 359 | } |
---|
| 360 | .buttonOut |
---|
| 361 | { |
---|
| 362 | border: 1px solid; |
---|
| 363 | border-color: white; |
---|
| 364 | } |
---|
| 365 | |
---|
| 366 | .imgCaption { |
---|
| 367 | font-size: 9pt; |
---|
| 368 | font-family: "MS Shell Dlg", Helvetica, sans-serif; |
---|
| 369 | text-align: center; |
---|
| 370 | } |
---|
| 371 | .dirField { |
---|
| 372 | font-size: 9pt; |
---|
| 373 | font-family: "MS Shell Dlg", Helvetica, sans-serif; |
---|
| 374 | width:110px; |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | --> |
---|
| 378 | </style> |
---|
| 379 | <? |
---|
| 380 | $dirPath = eregi_replace($BASE_ROOT,'',$IMG_ROOT); |
---|
| 381 | |
---|
| 382 | $paths = explode('/', $dirPath); |
---|
| 383 | $upDirPath = '/'; |
---|
| 384 | for($i=0; $i<count($paths)-2; $i++) |
---|
| 385 | { |
---|
| 386 | $path = $paths[$i]; |
---|
| 387 | if(strlen($path) > 0) |
---|
| 388 | { |
---|
| 389 | $upDirPath .= $path.'/'; |
---|
| 390 | } |
---|
| 391 | } |
---|
| 392 | |
---|
| 393 | $slashIndex = strlen($dirPath); |
---|
| 394 | $newPath = $dirPath; |
---|
| 395 | if($slashIndex > 1 && substr($dirPath, $slashIndex-1, $slashIndex) == '/') |
---|
| 396 | { |
---|
| 397 | $newPath = substr($dirPath, 0,$slashIndex-1); |
---|
| 398 | } |
---|
| 399 | ?> |
---|
| 400 | <script type="text/javascript" src="../popup.js"></script> |
---|
| 401 | <script type="text/javascript" src="../../../../dialog.js"></script> |
---|
| 402 | <script language="JavaScript" type="text/JavaScript"> |
---|
| 403 | <!-- |
---|
| 404 | function pviiClassNew(obj, new_style) { //v2.6 by PVII |
---|
| 405 | obj.className=new_style; |
---|
| 406 | } |
---|
| 407 | |
---|
| 408 | function goUp() |
---|
| 409 | { |
---|
| 410 | location.href = "ImageManager/images.php?dir=<? echo $upDirPath; ?>"; |
---|
| 411 | } |
---|
| 412 | |
---|
| 413 | function changeDir(newDir) |
---|
| 414 | { |
---|
| 415 | location.href = "ImageManager/images.php?dir="+newDir; |
---|
| 416 | } |
---|
| 417 | |
---|
| 418 | function newFolder(oldDir, newFolder) |
---|
| 419 | { |
---|
| 420 | location.href = "ImageManager/images.php?dir="+oldDir+'&create=folder&foldername='+newFolder; |
---|
| 421 | } |
---|
| 422 | |
---|
| 423 | function updateDir() |
---|
| 424 | { |
---|
| 425 | var newPath = "<? echo $newPath; ?>"; |
---|
| 426 | if(window.top.document.forms[0] != null) { |
---|
| 427 | |
---|
| 428 | var allPaths = window.top.document.forms[0].dirPath.options; |
---|
| 429 | //alert("new:"+newPath); |
---|
| 430 | for(i=0; i<allPaths.length; i++) |
---|
| 431 | { |
---|
| 432 | //alert(allPaths.item(i).value); |
---|
| 433 | allPaths.item(i).selected = false; |
---|
| 434 | if((allPaths.item(i).value)==newPath) |
---|
| 435 | { |
---|
| 436 | allPaths.item(i).selected = true; |
---|
| 437 | } |
---|
| 438 | } |
---|
| 439 | |
---|
| 440 | <? |
---|
| 441 | if($clearUploads) { |
---|
| 442 | ?> |
---|
| 443 | var topDoc = window.top.document.forms[0]; |
---|
| 444 | topDoc.upload.value = null; |
---|
| 445 | //topDoc.upload.disabled = true; |
---|
| 446 | <? |
---|
| 447 | } |
---|
| 448 | ?> |
---|
| 449 | |
---|
| 450 | } |
---|
| 451 | |
---|
| 452 | } |
---|
| 453 | |
---|
| 454 | <? if ($refresh_dirs) { ?> |
---|
| 455 | function refreshDirs() |
---|
| 456 | { |
---|
| 457 | var allPaths = window.top.document.forms[0].dirPath.options; |
---|
| 458 | var fields = ["/" <? dirs($BASE_DIR.$BASE_ROOT,'');?>]; |
---|
| 459 | |
---|
| 460 | var newPath = "<? echo $newPath; ?>"; |
---|
| 461 | |
---|
| 462 | while(allPaths.length > 0) |
---|
| 463 | { |
---|
| 464 | for(i=0; i<allPaths.length; i++) |
---|
| 465 | { |
---|
| 466 | allPaths.remove(i); |
---|
| 467 | } |
---|
| 468 | } |
---|
| 469 | |
---|
| 470 | for(i=0; i<fields.length; i++) |
---|
| 471 | { |
---|
| 472 | var newElem = document.createElement("OPTION"); |
---|
| 473 | var newValue = fields[i]; |
---|
| 474 | newElem.text = newValue; |
---|
| 475 | newElem.value = newValue; |
---|
| 476 | |
---|
| 477 | if(newValue == newPath) |
---|
| 478 | newElem.selected = true; |
---|
| 479 | else |
---|
| 480 | newElem.selected = false; |
---|
| 481 | |
---|
| 482 | allPaths.add(newElem); |
---|
| 483 | } |
---|
| 484 | } |
---|
| 485 | refreshDirs(); |
---|
| 486 | <? } ?> |
---|
| 487 | |
---|
| 488 | function imageSelected(filename, width, height, alt) |
---|
| 489 | { |
---|
| 490 | var topDoc = window.top.document.forms[0]; |
---|
| 491 | topDoc.f_url.value = filename; |
---|
| 492 | topDoc.f_width.value= width; |
---|
| 493 | topDoc.f_height.value = height; |
---|
| 494 | topDoc.f_alt.value = alt; |
---|
| 495 | topDoc.orginal_width.value = width; |
---|
| 496 | topDoc.orginal_height.value = height; |
---|
| 497 | |
---|
| 498 | } |
---|
| 499 | |
---|
| 500 | function preview(file, image, size, width, height) |
---|
| 501 | { |
---|
| 502 | /* |
---|
| 503 | var predoc = '<img src="'+file+'" alt="'+image+' ('+width+'x'+height+', '+size+')">'; |
---|
| 504 | var w = 450; |
---|
| 505 | var h = 400; |
---|
| 506 | var LeftPosition=(screen.width)?(screen.width-w)/2:100; |
---|
| 507 | var TopPosition=(screen.height)?(screen.height-h)/2:100; |
---|
| 508 | |
---|
| 509 | var win = window.open('','image_preview','toolbar=no,location=no,menubar=no,status=yes,scrollbars=yes,resizable=yes,width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition); |
---|
| 510 | var doc=win.document.open(); |
---|
| 511 | |
---|
| 512 | doc.writeln('<html>\n<head>\n<title>Image Preview - '+image+' ('+width+'x'+height+', '+size+')</title>'); |
---|
| 513 | doc.writeln('</head>\n<body>'); |
---|
| 514 | doc.writeln(predoc); |
---|
| 515 | doc.writeln('</body>\n</html>\n'); |
---|
| 516 | doc=win.document.close(); |
---|
| 517 | win.focus();*/ |
---|
| 518 | //alert(file); |
---|
| 519 | Dialog("../ImageEditor/ImageEditor.php?img="+escape(file), function(param) { |
---|
| 520 | if (!param) { // user must have pressed Cancel |
---|
| 521 | return false; |
---|
| 522 | } |
---|
| 523 | }, null); |
---|
| 524 | return; |
---|
| 525 | } |
---|
| 526 | |
---|
| 527 | function deleteImage(file) |
---|
| 528 | { |
---|
| 529 | if(confirm("Delete image \""+file+"\"?")) |
---|
| 530 | return true; |
---|
| 531 | |
---|
| 532 | return false; |
---|
| 533 | } |
---|
| 534 | |
---|
| 535 | function deleteFolder(folder, numFiles) |
---|
| 536 | { |
---|
| 537 | if(numFiles > 0) { |
---|
| 538 | alert("There are "+numFiles+" files/folders in \""+folder+"\".\n\nPlease delete all files/folder in \""+folder+"\" first."); |
---|
| 539 | return false; |
---|
| 540 | } |
---|
| 541 | |
---|
| 542 | if(confirm("Delete folder \""+folder+"\"?")) |
---|
| 543 | return true; |
---|
| 544 | |
---|
| 545 | return false; |
---|
| 546 | } |
---|
| 547 | |
---|
| 548 | function MM_findObj(n, d) { //v4.01 |
---|
| 549 | var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { |
---|
| 550 | d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} |
---|
| 551 | if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; |
---|
| 552 | for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); |
---|
| 553 | if(!x && d.getElementById) x=d.getElementById(n); return x; |
---|
| 554 | } |
---|
| 555 | |
---|
| 556 | function MM_showHideLayers() { //v6.0 |
---|
| 557 | var i,p,v,obj,args=MM_showHideLayers.arguments; |
---|
| 558 | for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i],window.top.document))!=null) { v=args[i+2]; |
---|
| 559 | if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; } |
---|
| 560 | obj.visibility=v; } |
---|
| 561 | } |
---|
| 562 | |
---|
| 563 | function changeLoadingStatus(state) |
---|
| 564 | { |
---|
| 565 | var statusText = null; |
---|
| 566 | if(state == 'load') { |
---|
| 567 | statusText = 'Loading Images'; |
---|
| 568 | } |
---|
| 569 | else if(state == 'upload') { |
---|
| 570 | statusText = 'Uploading Files'; |
---|
| 571 | } |
---|
| 572 | if(statusText != null) { |
---|
| 573 | var obj = MM_findObj('loadingStatus', window.top.document); |
---|
| 574 | //alert(obj.innerHTML); |
---|
| 575 | if (obj != null && obj.innerHTML != null) |
---|
| 576 | obj.innerHTML = statusText; |
---|
| 577 | MM_showHideLayers('loading','','show') |
---|
| 578 | } |
---|
| 579 | } |
---|
| 580 | |
---|
| 581 | //--> |
---|
| 582 | </script> |
---|
| 583 | </head> |
---|
| 584 | <body onLoad="updateDir();" bgcolor="#FFFFFF"> |
---|
| 585 | |
---|
| 586 | <? |
---|
| 587 | //var_dump($_GET); |
---|
| 588 | //echo $dirParam.':'.$upDirPath; |
---|
| 589 | //echo '<br>'; |
---|
| 590 | $d = @dir($BASE_DIR.$IMG_ROOT); |
---|
| 591 | |
---|
| 592 | if($d) |
---|
| 593 | { |
---|
| 594 | //var_dump($d); |
---|
| 595 | $images = array(); |
---|
| 596 | $folders = array(); |
---|
| 597 | while (false !== ($entry = $d->read())) |
---|
| 598 | { |
---|
| 599 | $img_file = $IMG_ROOT.$entry; |
---|
| 600 | |
---|
| 601 | if(is_file($BASE_DIR.$img_file) && substr($entry,0,1) != '.') |
---|
| 602 | { |
---|
| 603 | $image_info = @getimagesize($BASE_DIR.$img_file); |
---|
| 604 | if(is_array($image_info)) |
---|
| 605 | { |
---|
| 606 | $file_details['file'] = $img_file; |
---|
| 607 | $file_details['img_info'] = $image_info; |
---|
| 608 | $file_details['size'] = filesize($BASE_DIR.$img_file); |
---|
| 609 | $images[$entry] = $file_details; |
---|
| 610 | //show_image($img_file, $entry, $image_info); |
---|
| 611 | } |
---|
| 612 | } |
---|
| 613 | else if(is_dir($BASE_DIR.$img_file) && substr($entry,0,1) != '.') |
---|
| 614 | { |
---|
| 615 | $folders[$entry] = $img_file; |
---|
| 616 | //show_dir($img_file, $entry); |
---|
| 617 | } |
---|
| 618 | } |
---|
| 619 | $d->close(); |
---|
| 620 | |
---|
| 621 | if(count($images) > 0 || count($folders) > 0) |
---|
| 622 | { |
---|
| 623 | //now sort the folders and images by name. |
---|
| 624 | ksort($images); |
---|
| 625 | ksort($folders); |
---|
| 626 | |
---|
| 627 | draw_table_header(); |
---|
| 628 | |
---|
| 629 | for($i=0; $i<count($folders); $i++) |
---|
| 630 | { |
---|
| 631 | $folder_name = key($folders); |
---|
| 632 | show_dir($folders[$folder_name], $folder_name); |
---|
| 633 | next($folders); |
---|
| 634 | } |
---|
| 635 | for($i=0; $i<count($images); $i++) |
---|
| 636 | { |
---|
| 637 | $image_name = key($images); |
---|
| 638 | show_image($images[$image_name]['file'], $image_name, $images[$image_name]['img_info'], $images[$image_name]['size']); |
---|
| 639 | next($images); |
---|
| 640 | } |
---|
| 641 | draw_table_footer(); |
---|
| 642 | } |
---|
| 643 | else |
---|
| 644 | { |
---|
| 645 | draw_no_results(); |
---|
| 646 | } |
---|
| 647 | } |
---|
| 648 | else |
---|
| 649 | { |
---|
| 650 | draw_no_dir(); |
---|
| 651 | } |
---|
| 652 | |
---|
| 653 | ?> |
---|
| 654 | <script language="JavaScript" type="text/JavaScript"> |
---|
| 655 | MM_showHideLayers('loading','','hide') |
---|
| 656 | </script> |
---|
| 657 | </body> |
---|
| 658 | </html> |
---|