Changeset 31245 for extensions/GDThumb/admin.php
- Timestamp:
- Jul 20, 2015, 1:45:59 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GDThumb/admin.php
r31060 r31245 3 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 4 5 function delete_gdthumb_cache($height) { 6 $pattern = '#.*-cu_s9999x'.$height.'\.[a-zA-Z0-9]{3,4}$#'; 7 if ($contents = @opendir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR)): 5 function int_delete_gdthumb_cache($pattern) { 6 if ($contents = @opendir(PHPWG_ROOT_PATH . PWG_DERIVATIVE_DIR)): 8 7 while (($node = readdir($contents)) !== false): 9 8 if ($node != '.' 10 9 and $node != '..' 11 and is_dir(PHPWG_ROOT_PATH .PWG_DERIVATIVE_DIR.$node)):12 clear_derivative_cache_rec(PHPWG_ROOT_PATH .PWG_DERIVATIVE_DIR.$node, $pattern);10 and is_dir(PHPWG_ROOT_PATH . PWG_DERIVATIVE_DIR . $node)): 11 clear_derivative_cache_rec(PHPWG_ROOT_PATH . PWG_DERIVATIVE_DIR . $node, $pattern); 13 12 endif; 14 13 endwhile; … … 16 15 endif; 17 16 } 17 18 function delete_gdthumb_cache($height) { 19 int_delete_gdthumb_cache('#.*-cu_s9999x' . $height . '\.[a-zA-Z0-9]{3,4}$#'); 20 int_delete_gdthumb_cache('#.*-cu_s' . $height . 'x9999\.[a-zA-Z0-9]{3,4}$#'); 21 } 22 23 global $template, $conf, $page; 24 25 load_language('plugin.lang', GDTHUMB_PATH); 26 include(dirname(__FILE__).'/config_default.inc.php'); 27 $params = $conf['gdThumb']; 18 28 19 29 if (isset($_GET['getMissingDerivative'])) { … … 43 53 if ($src_image->is_mimetype()) 44 54 continue; 45 $derivative = new DerivativeImage(ImageStdParams::get_custom(9999, $conf['gdThumb']['height']), $src_image); 55 if (($params['method'] == "slide") || ($params['method'] == "square")): 56 $derivative = new DerivativeImage(ImageStdParams::get_custom($params['height'], 9999), $src_image); 57 else: 58 $derivative = new DerivativeImage(ImageStdParams::get_custom(9999, $params['height']), $src_image); 59 endif; 46 60 if (@filemtime($derivative->get_path())===false) { 47 61 $urls[] = $derivative->get_url().$uid; … … 64 78 } 65 79 66 global $template, $conf, $page;67 68 load_language('plugin.lang', GDTHUMB_PATH);69 include(dirname(__FILE__).'/config_default.inc.php');70 $params = $conf['gdThumb'];71 72 80 // Delete cache 73 81 if (isset($_POST['cachedelete'])) { 74 82 check_pwg_token(); 75 delete_gdthumb_cache($ conf['gdThumb']['height']);76 delete_gdthumb_cache($ conf['gdThumb']['height'] * 2 + $conf['gdThumb']['margin']);83 delete_gdthumb_cache($params['height']); 84 delete_gdthumb_cache($params['height'] * 2 + $params['margin']); 77 85 redirect('admin.php?page=plugin-GDThumb'); 78 86 } … … 92 100 endif; 93 101 94 $big_thumb = !empty($_POST['big_thumb']); 102 $big_thumb = !empty($_POST['big_thumb']); 103 $big_thumb_noinpw = !empty($_POST['big_thumb_noinpw']); 104 $thumb_animate = !empty($_POST['thumb_animate']); 105 $thumb_mode_album = $_POST['thumb_mode_album']; 106 $thumb_mode_photo = $_POST['thumb_mode_photo']; 107 108 if ($method == "slide"): 109 if ($big_thumb): 110 $big_thumb = false; 111 array_push($page['warnings'], l10n('Big thumb cannot be used in Slide mode. Disabled')); 112 endif; 113 if ($thumb_animate): 114 $thumb_animate = false; 115 array_push($page['warnings'], l10n('Thumb animation cannot be used in Slide mode. Disabled')); 116 endif; 117 118 if (($thumb_mode_album == "overlay-ex") || ($thumb_mode_album == "overlay") || ($thumb_mode_album == "top") || ($thumb_mode_album == "bottom")): 119 $thumb_mode_album = "bottom_static"; 120 array_push($page['warnings'], l10n('This Thumb mode cannot be used in Slide mode. Changed to default')); 121 endif; 122 123 if (($thumb_mode_photo == "overlay-ex") || ($thumb_mode_photo == "overlay") || ($thumb_mode_photo == "top") || ($thumb_mode_photo == "bottom")): 124 $thumb_mode_photo = "bottom_static"; 125 array_push($page['warnings'], l10n('This Thumb mode cannot be used in Slide mode. Changed to default')); 126 endif; 127 endif; 128 129 if (($big_thumb_noinpw) && (!$big_thumb)): 130 $big_thumb_noinpw = false; 131 endif; 132 95 133 $params = array( 96 134 'height' => $_POST['height'] … … 98 136 , 'nb_image_page' => $_POST['nb_image_page'] 99 137 , 'big_thumb' => $big_thumb 100 , 'big_thumb_noinpw'=> !empty($_POST['big_thumb_noinpw'])138 , 'big_thumb_noinpw'=> $big_thumb_noinpw 101 139 , 'cache_big_thumb' => !empty($_POST['cache_big_thumb']) 102 140 , 'normalize_title' => $normalize 103 141 , 'method' => $method 104 , 'thumb_mode_album'=> $ _POST['thumb_mode_album']105 , 'thumb_mode_photo'=> $ _POST['thumb_mode_photo']142 , 'thumb_mode_album'=> $thumb_mode_album 143 , 'thumb_mode_photo'=> $thumb_mode_photo 106 144 , 'thumb_metamode' => $_POST['thumb_metamode'] 107 145 , 'no_wordwrap' => !empty($_POST['no_wordwrap']) 108 , 'thumb_animate' => !empty($_POST['thumb_animate'])146 , 'thumb_animate' => $thumb_animate 109 147 ); 110 148 111 149 if (!is_numeric($params['height'])) { 112 array_push($page['errors'], 'Thumbnails max height must be an integer.');150 array_push($page['errors'], l10n('Thumbnails max height must be an integer')); 113 151 } 114 152 if (!is_numeric($params['margin'])) { 115 array_push($page['errors'], 'Margin between thumbnails must be an integer.');153 array_push($page['errors'], l10n('Margin between thumbnails must be an integer')); 116 154 } 117 155 if (!is_numeric($params['nb_image_page'])) { 118 array_push($page['errors'], 'Number of photos per page must be an integer.');156 array_push($page['errors'], l10n('Number of photos per page must be an integer')); 119 157 } 120 158 … … 127 165 128 166 if (empty($page['errors'])) { 129 $query = ' 130 UPDATE ' . CONFIG_TABLE . ' 131 SET value="' . addslashes(serialize($params)) . '" 132 WHERE param="gdThumb" 133 LIMIT 1'; 134 pwg_query($query); 135 167 conf_update_param('gdThumb', $params); 136 168 array_push($page['infos'], l10n('Information data registered in database')); 137 169 }
Note: See TracChangeset
for help on using the changeset viewer.