Changeset 1823
- Timestamp:
- Feb 15, 2007, 7:50:08 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/site_manager.php
r1775 r1823 193 193 $template->assign_vars(array('REMOTE_SITE_TITLE'=>$title)); 194 194 remote_output($galleries_url.'create_listing_file.php?action=clean'); 195 break;196 }197 case 'protect' :198 {199 $title = $galleries_url.' : '.l10n('remote_site_protect');200 $template->assign_vars(array('REMOTE_SITE_TITLE'=>$title));201 remote_output($galleries_url.'create_listing_file.php?action=protect');202 195 break; 203 196 } … … 275 268 'U_GENERATE' => $row['galleries_url'].'create_listing_file.php?action=generate', 276 269 'U_CLEAN' => $base_url.'clean', 277 'U_PROTECT' => $base_url.'protect'278 270 ) 279 271 ); -
trunk/language/en_UK.iso-8859-1/admin.lang.php
r1821 r1823 359 359 $lang['registration_date'] = 'registration date'; 360 360 $lang['remote_site'] = 'Remote site'; 361 $lang['remote_site_protect'] = 'protect';362 $lang['remote_site_protect_hint'] = 'create index.php in all directories';363 361 $lang['remote_site_clean'] = 'clean'; 364 362 $lang['remote_site_clean_hint'] = 'remove remote listing.xml file'; -
trunk/language/fr_FR.iso-8859-1/admin.lang.php
r1821 r1823 359 359 $lang['registration_date'] = 'date d\'enregistrement'; 360 360 $lang['remote_site'] = 'Site distant'; 361 $lang['remote_site_protect'] = 'protéger';362 $lang['remote_site_protect_hint'] = 'créer un fichier index.php dans chaque répertoire';363 361 $lang['remote_site_clean'] = 'nettoyer'; 364 362 $lang['remote_site_clean_hint'] = 'supprimer le fichier listing.xml distant'; -
trunk/template/yoga/admin/site_manager.tpl
r1780 r1823 48 48 <br> 49 49 [<a href="{sites.site.remote.U_TEST}" title="{lang:remote_site_test_hint}" {TAG_INPUT_ENABLED}>{lang:remote_site_test}</a>] 50 [<a href="{sites.site.remote.U_GENERATE}" title="{lang:remote_site_generate_hint}" target="_blank"{TAG_INPUT_ENABLED}>{lang:remote_site_generate}</a>]50 [<a href="{sites.site.remote.U_GENERATE}" title="{lang:remote_site_generate_hint}" {TAG_INPUT_ENABLED}>{lang:remote_site_generate}</a>] 51 51 [<a href="{sites.site.remote.U_CLEAN}" title="{lang:remote_site_clean_hint}" {TAG_INPUT_ENABLED}>{lang:remote_site_clean}</a>] 52 [<a href="{sites.site.remote.U_PROTECT}" title="{lang:remote_site_protect_hint}" {TAG_INPUT_ENABLED}>{lang:remote_site_protect}</a>]53 52 <!-- END remote --> 54 53 <!-- BEGIN plugin_links --> -
trunk/tools/create_listing_file.php
r1775 r1823 30 30 // +-----------------------------------------------------------------------+ 31 31 32 // ****** Gallery configuration ****** // 32 33 // Srcipt version 33 34 $conf['version'] = 'Alligator'; 34 35 36 // URL of main gallery 37 $conf['gallery'] = 'http://'; 38 35 39 // prefix for thumbnails in "thumbnail" sub directories 36 40 $conf['prefix_thumbnail'] = 'TN-'; 37 41 38 42 // $conf['file_ext'] lists all extensions (case insensitive) allowed for your PhpWebGallery installation 39 $conf['file_ext'] = array('jpg','JPG',' png','PNG','gif','GIF','mpg','zip', 'avi','mp3','ogg');43 $conf['file_ext'] = array('jpg','JPG','jpeg','JPEG','png','PNG','gif','GIF','mpg','zip', 'avi','mp3','ogg'); 40 44 41 45 // $conf['picture_ext'] must be a subset of $conf['file_ext'] 42 $conf['picture_ext'] = array('jpg','JPG','png','PNG','gif','GIF'); 43 44 // URL of main gallery 45 $conf['gallery'] = 'http://'; 46 47 // max excution time before refresh in seconds 46 $conf['picture_ext'] = array('jpg','JPG','jpeg','JPEG','png','PNG','gif','GIF'); 47 48 // ****** Time limitation functionality ****** // 49 // max execution time before refresh in seconds 48 50 $conf['max_execution_time'] = (5*ini_get('max_execution_time'))/6; // 25 seconds with default PHP configuration 49 51 … … 51 53 $conf['refresh_delay'] = 0; 52 54 53 // $conf['file_ext'] lists all extensions (case insensitive) allowed for your PhpWebGallery installation 54 $conf['file_ext'] = array('jpg','JPG','jpeg','JPEG','png','PNG','gif','GIF','mpg','zip', 'avi','mp3','ogg'); 55 55 // ****** EXIF support functionality ****** // 56 56 // $conf['use_exif'] set to true if you want to use Exif information 57 $conf['use_exif'] = true;57 $conf['use_exif'] = false; 58 58 59 59 // use_exif_mapping: same behaviour as use_iptc_mapping … … 62 62 ); 63 63 64 // ****** IPTC support functionality ****** // 64 65 // $conf['use_iptc'] set to true if you want to use IPTC informations of the 65 66 // element according to get_sync_iptc_data function mapping, otherwise, set … … 77 78 'comment' => '2#120'); 78 79 80 // ****** Directory protection functionality ****** // 81 // Define if directories have to be protected if they are not 82 $conf['protect'] = false; 83 79 84 // index.php content for command 'protect' 80 85 $conf['protect_content'] = '<?php header("Location: '.$conf['gallery'].'") ?>'; 81 86 87 // true/false : show/hide warnings 88 $conf['protect_warnings'] = true; 89 90 // ****** Thumbnails generation functionality ****** // 91 // Define if images have to be reduced if they are not 92 $conf['thumbnail'] = false; 93 94 // Define method to generate thumbnails : 95 // - fixed (width and height required); 96 // - width (only width required); 97 // - height (only height required); 98 // - ratio (only ratio is required) 99 // - exif (no other parameter required) 100 $conf['thumbnail_method'] = 'ratio'; 101 102 // Height in pixels (greater than 0) 103 $conf['thumbnail_height'] = 96; 104 105 // Width in pixels (greater than 0) 106 $conf['thumbnail_width'] = 96; 107 108 // Ratio between original and thumbnail size (strictly between 0 and 1) 109 $conf['thumbnail_ratio'] = 0.2; 110 111 // Define thumbnail format : jpeg, png or gif (will be verified) 112 $conf['thumbnail_format'] = 'jpeg'; 113 114 // ****** Directory mapping ****** // 82 115 // directories names 83 116 $conf['thumbs'] = 'thumbnail'; // thumbnails … … 93 126 94 127 // list of actions managed by this script 95 $pwg_conf['scan_action'] = array('clean', 'test', 'generate' , 'protect');128 $pwg_conf['scan_action'] = array('clean', 'test', 'generate'); 96 129 97 130 // url of this script … … 107 140 $pwg_conf['safe_mode'] = (ini_get('safe_mode') == '1') ? true : false; 108 141 109 // Error level management110 // true : show warnings 111 // false : hide warnings 112 $pwg_conf[' warning']['protect'] = true;142 // This parameter will be fixed in pwg_init() 143 $pwg_conf['gd_version_major'] = ''; 144 $pwg_conf['gd_version_full'] = ''; 145 $pwg_conf['gd_supported_format'] = array(); 113 146 114 147 // +-----------------------------------------------------------------------+ 115 // | functions |148 // | Functions | 116 149 // +-----------------------------------------------------------------------+ 117 150 … … 127 160 fwrite($log_file, $line); 128 161 fclose($log_file); 162 } 163 164 /** 165 * Check web server graphical capabilities 166 * 167 * @return string 168 */ 169 function pwg_check_graphics() 170 { 171 //~ pwg_log('>>>>> pwg_check_graphics() >>>>>'."\n"); 172 173 global $conf, $pwg_conf; 174 $log = ''; 175 176 // Verify gd library for thumbnail generation 177 if ($conf['thumbnail'] and !is_callable('gd_info')) 178 { 179 $log .= ' <code class="warning">Warning -</code> Your server can not generate thumbnails. Thumbnail creation switched off.<br />'."\n"; 180 // Switch off thumbnail generation 181 $conf['thumbnail'] = false; 182 return $log; 183 } 184 185 // Verify thumnail format 186 if ($conf['thumbnail']) 187 { 188 $info = gd_info(); 189 190 // Backup GD major version 191 $pwg_conf['gd_version_full'] = ereg_replace('[[:alpha:][:space:]()]+', '', $info['GD Version']); 192 list($pwg_conf['gd_version_major']) = preg_split('/[.]+/', $pwg_conf['gd_version_full']); 193 194 // Backup input/output format support 195 array_push($pwg_conf['gd_supported_format'], $info['JPG Support'] ? 'jpeg' : NULL); 196 array_push($pwg_conf['gd_supported_format'], $info['PNG Support'] ? 'png' : NULL); 197 array_push($pwg_conf['gd_supported_format'], ($info['GIF Read Support'] and $info['GIF Create Support']) ? 'gif' : NULL); 198 199 // Check output format support 200 if (!in_array($conf['thumbnail_format'], $pwg_conf['gd_supported_format'])) 201 { 202 $log .= ' <code class="warning">Warning -</code> Your server does not support thumbnail\'s <code>'; 203 $log .= $conf['thumbnail_format'].'</code> format. Thumbnail creation switched off.<br />'."\n"; 204 } 205 206 switch ($conf['thumbnail_method']) 207 { 208 case 'exif': 209 { 210 // exif_thumbnail() must be callable 211 if (!is_callable('exif_thumbnail')) 212 { 213 $log .= ' <code class="warning">Warning -</code> Your server does not support thumbnail creation through EXIF datas. Thumbnail creation switched off.<br />'."\n"; 214 } 215 break; 216 } 217 case 'fixed': 218 { 219 // $conf['thumbnail_width'] > 0 220 if (!is_numeric($conf['thumbnail_width']) or $conf['thumbnail_width'] <= 0) 221 { 222 $log .= ' <code class="failure">Failure -</code> Bad value <code>thumbnail_width = '; 223 $log .= var_export($conf['thumbnail_width'], true).'</code>. Thumbnail creation switched off.<br />'."\n"; 224 } 225 // $conf['thumbnail_height'] > 0 226 if (!is_numeric($conf['thumbnail_height']) or $conf['thumbnail_height'] <= 0) 227 { 228 $log .= ' <code class="failure">Failure -</code> Bad value <code>thumbnail_height = '; 229 $log .= var_export($conf['thumbnail_height'], true).'</code>. Thumbnail creation switched off.<br />'."\n"; 230 } 231 break; 232 } 233 case 'ratio': 234 { 235 // 0 < $conf['thumbnail_ratio'] < 1 236 if (!is_numeric($conf['thumbnail_ratio']) or $conf['thumbnail_ratio'] <= 0 or $conf['thumbnail_ratio'] >= 1) 237 { 238 $log .= ' <code class="failure">Failure -</code> Bad value <code>thumbnail_ratio = '; 239 $log .= var_export($conf['thumbnail_ratio'], true).'</code>. Thumbnail creation switched off.<br />'."\n"; 240 } 241 break; 242 } 243 case 'width': 244 { 245 // $conf['thumbnail_width'] > 0 246 if (!is_numeric($conf['thumbnail_width']) or $conf['thumbnail_width'] <= 0) 247 { 248 $log .= ' <code class="failure">Failure -</code> Bad value <code>thumbnail_width = '; 249 $log .= var_export($conf['thumbnail_width'], true).'</code>. Thumbnail creation switched off.<br />'."\n"; 250 } 251 break; 252 } 253 case 'height': 254 { 255 // $conf['thumbnail_height'] > 0 256 if (!is_numeric($conf['thumbnail_height']) or $conf['thumbnail_height'] <= 0) 257 { 258 $log .= ' <code class="failure">Failure -</code> Bad value <code>thumbnail_height = '; 259 $log .= var_export($conf['thumbnail_height'], true).'</code>. Thumbnail creation switched off.<br />'."\n"; 260 } 261 break; 262 } 263 default: 264 { 265 // unknown method 266 $log .= ' <code class="failure">Failure -</code> Bad value <code>thumbnail_method = '; 267 $log .= var_export($conf['thumbnail_method'], true).'</code>. Thumbnail creation switched off.<br />'."\n"; 268 break; 269 } 270 } 271 272 if (strlen($log)) 273 { 274 $conf['thumbnail'] = false; 275 } 276 } 277 278 //~ pwg_log('<<<<< pwg_check_graphics() returns '.var_export($log, TRUE).' <<<<<'."\n"); 279 return $log; 129 280 } 130 281 … … 335 486 336 487 /** 337 * return extension of the thumbnail 488 * return extension of the thumbnail and complete error_log 338 489 * 339 490 * @param string $file_dir 340 491 * @param string $file_short 492 * @param string $file_ext 493 * @param string &$error_log 341 494 * @return string 342 495 */ 343 function pwg_get_thumbnail_ext($file_dir, $file_short )496 function pwg_get_thumbnail_ext($file_dir, $file_short, $file_ext, &$error_log) 344 497 { 345 498 //~ pwg_log('>>>>> pwg_get_thumbnail_ext($file_dir = '.var_export($file_dir, TRUE).', $file_short = '.var_export($file_short, TRUE).') >>>>>'."\n"); … … 357 510 } 358 511 512 if ($thumb_ext == '') 513 { 514 if ($conf['thumbnail']) 515 { 516 $log = pwg_icon_file($file_dir, $file_short, $file_ext); 517 if (strpos($log, 'success')) 518 { 519 $thumb_ext = $conf['thumbnail_format']; 520 } 521 $error_log .= $log; 522 } 523 } 524 359 525 //~ pwg_log('<<<<< pwg_get_thumbnail_ext() returns '.var_export($thumb_ext, TRUE).' <<<<<'."\n"); 360 526 return $thumb_ext; 527 } 528 529 530 /** 531 * return error logs 532 * 533 * @param string $file_dir 534 * @param string $file_short 535 * @param string $file_ext 536 * @return string 537 */ 538 function pwg_icon_file($file_dir, $file_short, $file_ext) 539 { 540 //~ pwg_log('>>>>> pwg_icon_file($file_dir = '.var_export($file_dir, TRUE).', $file_short = '.var_export($file_short, TRUE).') >>>>>'."\n"); 541 542 global $conf, $pwg_conf; 543 544 $error_log = ''; 545 546 // Get original properties (width, height) 547 if ($image_size = getimagesize($file_dir.'/'.$file_short.'.'.$file_ext)) 548 { 549 $src_width = $image_size[0]; 550 $src_height = $image_size[1]; 551 } 552 else 553 { 554 $error_log .= ' <code class="failure">Failure -</code> Can not generate icon for <code>'; 555 $error_log .= $file_dir.'/'.$file_short.'.'.$file_ext.'</code>'; 556 $error_log .= ' <img src="'.$pwg_conf['icon_dir'].'add_tag.png" title="width/height are unreadable" /><br />'."\n"; 557 return $error_log; 558 } 559 560 // Check input format 561 $dst_format = $conf['thumbnail_format']; 562 $src_format = ($file_ext == 'jpg' or $file_ext == 'JPG') ? 'jpeg' : strtolower($file_ext); 563 if (!in_array($src_format, $pwg_conf['gd_supported_format'])) 564 { 565 $error_log .= ' <code class="failure">Failure -</code> Can not generate icon for <code>'; 566 $error_log .= $file_dir.'/'.$file_short.'.'.$file_ext.'</code>'; 567 $error_log .= ' <img src="'.$pwg_conf['icon_dir'].'add_tag.png" title="format not supported" /><br />'."\n"; 568 return $error_log; 569 } 570 571 // Calculate icon properties (width, height) 572 switch ($conf['thumbnail_method']) 573 { 574 case 'fixed': 575 { 576 $dst_width = $conf['thumbnail_width']; 577 $dst_height = $conf['thumbnail_height']; 578 break; 579 } 580 case 'width': 581 { 582 $dst_width = $conf['thumbnail_width']; 583 $dst_height = $dst_width * $src_height / $src_width; 584 break; 585 } 586 case 'height': 587 { 588 $dst_height = $conf['thumbnail_height']; 589 $dst_width = $dst_height * $src_width / $src_height; 590 break; 591 } 592 case 'ratio': 593 { 594 $dst_width = round($src_width * $conf['thumbnail_ratio']); 595 $dst_height = round($src_height * $conf['thumbnail_ratio']); 596 break; 597 } 598 case 'exif': 599 default: 600 { 601 // Nothing to do 602 } 603 } 604 605 // Creating icon 606 if ($conf['thumbnail_method'] == 'exif') 607 { 608 $src = exif_thumbnail($file_dir.'/'.$file_short.'.'.$file_ext, $width, $height, $imagetype); 609 if ($src === false) 610 { 611 $error_log .= ' <code class="failure">Failure -</code> No EXIF thumbnail in <code>'; 612 $error_log .= $file_dir.'/'.$file_short.'.'.$file_ext.'</code><br />'."\n"; 613 return $error_log; 614 } 615 $dst = imagecreatefromstring($src); 616 if ($src === false) 617 { 618 $error_log .= ' <code class="failure">Failure -</code> EXIF thumbnail format not supported in <code>'; 619 $error_log .= $file_dir.'/'.$file_short.'.'.$file_ext.'</code><br />'."\n"; 620 return $error_log; 621 } 622 } 623 else 624 { 625 if (($pwg_conf['gd_version_major'] != 2)) // or ($conf['thumbnail_format'] == 'gif')) 626 { 627 $dst = imagecreate($dst_width, $dst_height); 628 } 629 else 630 { 631 $dst = imagecreatetruecolor($dst_width, $dst_height); 632 } 633 $src = call_user_func('imagecreatefrom'.$src_format, $file_dir.'/'.$file_short.'.'.$file_ext); 634 if (!$src) 635 { 636 $error_log .= ' <code class="failure">Failure -</code> Internal error for <code>imagecreatefrom'.$src_format.'()</code>'; 637 $error_log .= 'with <code>'.$file_dir.'/'.$file_short.'.'.$file_ext.'</code><br />'."\n"; 638 return $error_log; 639 } 640 641 if (($pwg_conf['gd_version_major'] != 2)) 642 { 643 if (!imagecopyresized($dst, $src, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height)) 644 { 645 $error_log .= ' <code class="failure">Failure -</code> Internal error for <code>imagecopyresized()</code>'; 646 $error_log .= 'with <code>'.$file_dir.'/'.$file_short.'.'.$file_ext.'</code><br />'."\n"; 647 return $error_log; 648 } 649 } 650 else 651 { 652 if (!imagecopyresampled($dst, $src, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height)) 653 { 654 $error_log .= ' <code class="failure">Failure -</code> Internal error for <code>imagecopyresampled()</code>'; 655 $error_log .= 'with <code>'.$file_dir.'/'.$file_short.'.'.$file_ext.'</code><br />'."\n"; 656 return $error_log; 657 } 658 } 659 } 660 661 if (!call_user_func('image'.$dst_format, $dst, $file_dir.'/'.$conf['thumbs'].'/'.$conf['prefix_thumbnail'].$file_short.'.'.$conf['thumbnail_format'])) 662 { 663 $error_log .= ' <code class="failure">Failure -</code> Can not write <code>'; 664 $error_log .= $file_dir.'/'.$conf['thumbs'].'/'.$conf['prefix_thumbnail'].$file_short.'.'.$file_ext.'</code> to generate thumbnail<br />'."\n"; 665 return $error_log; 666 } 667 668 $error_log .= ' <code class="success">Success -</code> Thumbnail generated for <code>'; 669 $error_log .= $file_dir.'/'.$file_short.'.'.$file_ext.'</code><br />'."\n"; 670 671 //~ pwg_log('<<<<< pwg_icon_file() returns '.var_export($error_log, TRUE).' <<<<<'."\n"); 672 return $error_log; 361 673 } 362 674 … … 387 699 { 388 700 // Here we scan a picture : thumbnail is mandatory, high is optionnal, representative is not scanned 389 $element['tn_ext'] = pwg_get_thumbnail_ext($file_dir, $file_short );701 $element['tn_ext'] = pwg_get_thumbnail_ext($file_dir, $file_short, $file_ext, $error_log); 390 702 if ($element['tn_ext'] != '') 391 703 { … … 540 852 function pwg_protect_directories($directory) 541 853 { 542 global $conf, $pwg_conf;543 544 854 //~ pwg_log('>>>>> pwg_protect_directories($directory = '.var_export($directory, true).') >>>>>'."\n"); 855 856 global $conf; 857 545 858 $error_log = ''; 546 859 $dirlist = array($directory, $directory.'/'.$conf['thumbs'], $directory.'/'.$conf['high'], $directory.'/'.$conf['represent']); … … 555 868 if ($file != false) 556 869 { 557 fwrite($file, $ pwg_conf['protect_content']); // the return code should be verified870 fwrite($file, $conf['protect_content']); // the return code should be verified 558 871 $error_log .= ' <code class="success">Success -</code> index.php created in directory <a href="'.$dir.'">'.$dir."</a><br />\n"; 559 $_SESSION['scan_cnt_fold']++;560 872 } 561 873 else … … 566 878 else 567 879 { 568 if ($ pwg_conf['warning']['protect'])880 if ($conf['protect_warnings']) 569 881 { 570 882 $error_log .= ' <code class="warning">Warning -</code> index.php already exists in directory <a href="'.$dir.'">'.$dir."</a><br />\n"; 571 $_SESSION['scan_cnt_fold']++;572 883 } 573 884 } … … 694 1005 $response = false; 695 1006 $server = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']; 696 $caller = $_SERVER['HTTP_REFERER'];1007 $caller = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : ''; 697 1008 698 1009 if (strcasecmp($server, $caller) == 0) { … … 705 1016 706 1017 // +-----------------------------------------------------------------------+ 707 // | pwg_<ACTION>_<STEP> F UNCTIONS|1018 // | pwg_<ACTION>_<STEP> Functions | 708 1019 // +-----------------------------------------------------------------------+ 709 1020 … … 743 1054 { 744 1055 $g_header = ' : <span class="success">Test</span>'."\n"; 745 $g_message = ' This script is tagged : <code class="failure">'.$conf['version'].'</code>'."\n";746 1056 $g_footer = '<a href="'.$pwg_conf['this_url'].'" title="Main menu"><img src="'.$pwg_conf['icon_dir'].'up.png" /></a>'."\n"; 1057 1058 // Write version 1059 $g_message = ' <h3>Script version</h3>'."\n"; 1060 $g_message .= ' This script is tagged : <code class="failure">'.$conf['version'].'</code>'."\n"; 1061 // write GD support 1062 if (!is_callable('gd_info')) 1063 { 1064 $g_message .= ' <code class="failure">Failure -</code> Your server can not generate imagess<br />'."\n"; 1065 } 1066 else 1067 { 1068 $info = gd_info(); 1069 $gd_full_version = ereg_replace('[[:alpha:][:space:]()]+', '', $info['GD Version']); 1070 list($gd_version) = preg_split('/[.]+/', $gd_full_version); 1071 1072 $g_message .= ' <h3>Image generation</h3>'."\n"; 1073 $g_message .= ' <code class="success">Success -</code> Your server can generate images<br />'."\n"; 1074 $g_message .= ' <code class="warning">Warning -</code> Your server support GD'.$gd_version.' (v'.$gd_full_version.')<br />'."\n"; 1075 $format_list = array(); 1076 $format = ($info['GIF Create Support']) ? '<code>gif</code>' : NULL; 1077 array_push($format_list, $format); 1078 $format = ($info['JPG Support']) ? '<code>jpg</code>' : NULL; 1079 array_push($format_list, $format); 1080 $format = ($info['PNG Support']) ? '<code>png</code>' : NULL; 1081 array_push($format_list, $format); 1082 $g_message .= ' <code class="warning">Warning -</code> Your server support format: '.implode(', ', $format_list)."\n"; 1083 } 1084 1085 $g_message .= ' <h3>Directory parsing</h3>'."\n"; 1086 if ($pwg_conf['safe_mode']) 1087 { 1088 $g_message .= ' <code class="warning">Warning -</code> Your server does not support to resize execution time'."\n"; 1089 } 1090 else 1091 { 1092 $g_message .= ' <code class="success">Success -</code> Your server supports to resize execution time'."\n"; 1093 } 747 1094 } 748 1095 else … … 814 1161 815 1162 //~ pwg_log('<<<<< pwg_clean_exit() <<<<<'."\n"); 816 }817 818 function pwg_protect_start()819 {820 //~ pwg_log('>>>>> pwg_protect_start() >>>>>'."\n");821 822 $_SESSION['scan_logs'] = pwg_get_file_list('.');823 sort($_SESSION['scan_list_fold']);824 825 // Erase first file list because root directory does not contain images.826 $_SESSION['scan_list_file'] = array();827 828 // What are we doing at next step829 if(count($_SESSION['scan_list_fold']) > 0)830 {831 $_SESSION['scan_step'] = 'list';832 }833 else834 {835 $_SESSION['scan_step'] = 'stop';836 }837 838 //~ pwg_log('<<<<< pwg_protect_start() <<<<<'."\n");839 }840 841 function pwg_protect_list()842 {843 //~ pwg_log('>>>>> pwg_protect_list() >>>>>'."\n");844 845 // Get list of files and directories846 $_SESSION['scan_logs'] .= pwg_get_file_list($_SESSION['scan_list_fold'][0]);847 sort($_SESSION['scan_list_fold']);848 849 // Delete unused file list850 $_SESSION['scan_list_file'] = array();851 852 // Position next step853 $_SESSION['scan_step'] = 'scan';854 855 //~ pwg_log('<<<<< pwg_protect_list() <<<<<'."\n");856 }857 858 function pwg_protect_scan()859 {860 //~ pwg_log('>>>>> pwg_protect_scan() >>>>>'."\n");861 862 $_SESSION['scan_logs'] .= pwg_protect_directories($_SESSION['scan_list_fold'][0]);863 864 if (isset($_SESSION['scan_list_fold'][1]))865 {866 array_shift($_SESSION['scan_list_fold']);867 $_SESSION['scan_step'] = 'list';868 }869 else870 {871 $_SESSION['scan_step'] = 'stop';872 }873 874 //~ pwg_log('<<<<< pwg_protect_scan() <<<<<'."\n");875 }876 877 function pwg_protect_stop()878 {879 //~ pwg_log('>>>>> pwg_protect_stop() >>>>>'."\n");880 881 global $g_header, $g_message, $g_footer, $pwg_conf;882 883 $time_elapsed = number_format(pwg_get_moment() - $_SESSION['scan_time'], 3, '.', ' ');884 885 $g_header = ' : <span class="success">Protect</span>';886 $g_message = ' <div>'."\n".$_SESSION['scan_logs'].' </div>'."\n";887 $g_message .= ' <div><code class="success">'.$_SESSION['scan_cnt_fold'].'</code> directories protected</div>'."\n";888 $g_message .= ' <div style="{text-align: right;}">Gallery protected in : <code>'.$time_elapsed.' s</code></div>';889 $g_footer = '<a href="'.$pwg_conf['this_url'].'" title="Main menu"><img src="'.$pwg_conf['icon_dir'].'up.png" /></a>';890 891 // What are we doing at next step892 $_SESSION['scan_step'] = 'exit';893 894 //~ pwg_log('<<<<< pwg_protect_stop() <<<<<'."\n");895 1163 } 896 1164 … … 930 1198 $_SESSION['scan_list_fold'] = array(); 931 1199 $_SESSION['scan_list_file'] = array(); 932 $_SESSION['scan_logs'] = pwg_get_file_list('.');1200 $_SESSION['scan_logs'] .= pwg_get_file_list('.'); 933 1201 sort($_SESSION['scan_list_fold']); 934 1202 … … 983 1251 //~ pwg_log("GENARATE scan >>>\n".var_export($_SESSION['scan_list_fold'], true)."\n".var_export($_SESSION['scan_list_file'], true)."\nGENERATE scan >>>\n"); 984 1252 985 global $g_listing ;1253 global $g_listing, $conf; 986 1254 987 1255 while (pwg_continue() and count($_SESSION['scan_list_file']) > 0) … … 989 1257 $line = ''; 990 1258 $_SESSION['scan_logs'] .= pwg_scan_file($_SESSION['scan_list_file'][0], $line); 1259 991 1260 if (strlen($line) > 0) 992 1261 { … … 1000 1269 if (count($_SESSION['scan_list_file']) <= 0) 1001 1270 { 1002 // Flush line </root> 1003 $line = pwg_get_indent('root').'</root>'."\n"; 1004 fwrite($g_listing, $line); 1005 1006 // How many directories to close 1007 $current_level = pwg_get_level($_SESSION['scan_list_fold'][0]); 1008 if (isset($_SESSION['scan_list_fold'][1])) 1009 { 1010 //~ pwg_log('---<< Pull of $_SESSION[scan_list_fold] value "'.$_SESSION['scan_list_fold'][0].'"'."\n"); 1011 array_shift($_SESSION['scan_list_fold']); 1012 $_SESSION['scan_cnt_fold']++; 1013 $next_level = pwg_get_level($_SESSION['scan_list_fold'][0]); 1014 $_SESSION['scan_step'] = 'list'; 1015 } 1016 else 1017 { 1018 $next_level = -1; 1019 $_SESSION['scan_step'] = 'stop'; 1020 } 1021 1022 if ($current_level == $next_level) 1023 { 1024 fwrite($g_listing, pwg_close_level($current_level, 1)); 1025 } 1026 else 1027 { 1028 if (($current_level > $next_level)) 1029 { 1030 fwrite($g_listing, pwg_close_level($current_level, $current_level-$next_level+1)); 1031 } // Nothing to do if current_level < next_level 1032 } 1271 $_SESSION['scan_step'] = 'prot'; 1033 1272 } 1034 1273 1035 1274 //~ pwg_log("GENERATE scan <<<\n".var_export($_SESSION['scan_list_fold'], true)."\n".var_export($_SESSION['scan_list_file'], true)."\nGENERATE scan <<<\n"); 1036 1275 //~ pwg_log('<<<<< pwg_generate_scan() <<<<<'."\n"); 1276 } 1277 1278 function pwg_generate_prot() 1279 { 1280 //~ pwg_log('>>>>> pwg_generate_prot() >>>>>'."\n"); 1281 //~ pwg_log("GENARATE prot >>>\n".var_export($_SESSION['scan_list_fold'], true)."\n".var_export($_SESSION['scan_list_file'], true)."\nGENERATE prot >>>\n"); 1282 1283 global $conf, $g_listing; 1284 1285 // Flush line </root> 1286 $line = pwg_get_indent('root').'</root>'."\n"; 1287 fwrite($g_listing, $line); 1288 1289 if ($conf['protect']) 1290 { 1291 $_SESSION['scan_logs'] .= pwg_protect_directories($_SESSION['scan_list_fold'][0]); 1292 } 1293 1294 // How many directories to close 1295 $current_level = pwg_get_level($_SESSION['scan_list_fold'][0]); 1296 if (isset($_SESSION['scan_list_fold'][1])) 1297 { 1298 //~ pwg_log('---<< Pull of $_SESSION[scan_list_fold] value "'.$_SESSION['scan_list_fold'][0].'"'."\n"); 1299 array_shift($_SESSION['scan_list_fold']); 1300 $_SESSION['scan_cnt_fold']++; 1301 $next_level = pwg_get_level($_SESSION['scan_list_fold'][0]); 1302 $_SESSION['scan_step'] = 'list'; 1303 } 1304 else 1305 { 1306 $next_level = -1; 1307 $_SESSION['scan_cnt_fold']++; 1308 $_SESSION['scan_step'] = 'stop'; 1309 } 1310 1311 if ($current_level == $next_level) 1312 { 1313 fwrite($g_listing, pwg_close_level($current_level, 1)); 1314 } 1315 else 1316 { 1317 if (($current_level > $next_level)) 1318 { 1319 fwrite($g_listing, pwg_close_level($current_level, $current_level-$next_level+1)); 1320 } // Nothing to do if current_level < next_level 1321 } 1322 1323 //~ pwg_log("GENERATE prot <<<\n".var_export($_SESSION['scan_list_fold'], true)."\n".var_export($_SESSION['scan_list_file'], true)."\nGENERATE prot <<<\n"); 1324 //~ pwg_log('<<<<< pwg_generate_prot() <<<<<'."\n"); 1037 1325 } 1038 1326 … … 1153 1441 1154 1442 global $g_message, $g_listing, $g_footer, $conf, $pwg_conf, $start_time; 1443 $init_message = ''; 1155 1444 1156 1445 // Lock other script sessions, this lock will be remove during 'exit' step … … 1219 1508 $g_message .= ' <li><a href="'.$pwg_conf['this_url'].'?action=clean" title="Delete listing.xml if exists">Clean</a></li>'."\n"; 1220 1509 $g_message .= ' <li><a href="'.$pwg_conf['this_url'].'?action=generate" title="Scan all images from this directory and write informations in listing.xml">Listing</a></li>'."\n"; 1221 $g_message .= ' <li><a href="'.$pwg_conf['this_url'].'?action=protect" title="Protect all directories from this point with index.php">Protect</a></li>'."\n";1222 1510 $g_message .= ' </ul>'."\n"; 1223 1511 $g_footer = '<a href="'.$conf['gallery'].'/admin.php?page=site_manager" title="Main gallery :: site manager">'; 1224 1512 $g_footer .= '<img src="'.$pwg_conf['icon_dir'].'home.png" /></a>'."\n"; 1225 1513 $_SESSION['scan_step'] = 'exit'; 1226 } 1227 1228 // Open listing.xml 1514 $_SESSION['scan_action'] = ''; 1515 } 1516 1517 // Actions to do at the init of generate 1229 1518 if ($_SESSION['scan_action'] == 'generate') 1230 1519 { 1520 // Open XML file 1231 1521 $mode = ($_SESSION['scan_step'] == 'init') ? 'w' : 'a'; // Erase old listing.xml at the beginning of generation (mode w) 1232 1522 $g_listing = @fopen('listing.xml', $mode); … … 1241 1531 return; 1242 1532 } 1243 } 1244 1533 1534 // Check graphical capabilities 1535 $init_message = pwg_check_graphics(); 1536 } 1537 1245 1538 // Initializing session counters. This counters will be completely unset during step 'exit' 1246 1539 if ($_SESSION['scan_step'] == 'init') … … 1252 1545 $_SESSION['scan_time'] = $start_time; 1253 1546 $_SESSION['scan_step'] = 'start'; 1254 $_SESSION['scan_logs'] = '';1547 $_SESSION['scan_logs'] = $init_message; 1255 1548 } 1256 1549 … … 1291 1584 unset($_SESSION['scan_action']); 1292 1585 unset($_SESSION['scan_logs']); 1293 1294 1586 session_destroy(); 1587 1295 1588 // Call specific action post process 1296 1589 if (is_callable('pwg_'.$local_action.'_exit')) … … 1303 1596 1304 1597 // +-----------------------------------------------------------------------+ 1305 // | script |1598 // | Script | 1306 1599 // +-----------------------------------------------------------------------+ 1600 session_save_path('.'); 1307 1601 session_start(); 1308 1602
Note: See TracChangeset
for help on using the changeset viewer.