14 if (!defined(
'IN_PEEL')) {
33 function thumbs($source_filename, $width, $height, $method =
'fit', $source_folder = null, $thumb_folder = null, $thumb_rename =
true, $return_absolute_path=
false)
36 if (empty($source_filename)) {
41 $source_filename =
'logoPDF_small.png';
42 $source_folder =
$GLOBALS[
'dirroot'] .
'/images/';
45 $source_filename =
'zip.png';
46 $source_folder =
$GLOBALS[
'dirroot'] .
'/images/';
49 $source_filename =
'document.png';
50 $source_folder =
$GLOBALS[
'dirroot'] .
'/images/';
52 if (empty($thumb_folder)) {
53 if(strpos($source_filename,
'//') !==
false || strpos($source_filename,
'/'.
$GLOBALS[
'site_parameters'][
'cache_folder'].
'/') ===
false) {
54 $thumb_folder =
$GLOBALS[
'uploaddir'] .
'/thumbs/';
55 if(!empty(
$GLOBALS[
'site_parameters'][
'thumbs_using_subfolders'])) {
56 $use_subfolders =
true;
59 $thumb_folder =
$GLOBALS[
'dirroot'].
'/'.
$GLOBALS[
'site_parameters'][
'cache_folder'].
'/';
62 if(strpos($source_filename,
'//')!==
false) {
64 $source_path = str_replace(
' ',
'%20', $source_filename);
68 if ($source_folder === null) {
69 if(strpos($source_filename,
'/'.
$GLOBALS[
'site_parameters'][
'cache_folder'].
'/') ===
false) {
70 $source_folder =
$GLOBALS[
'uploaddir'];
72 $source_folder =
$GLOBALS[
'dirroot'];
76 $source_folder .=
'/';
78 $source_path = $source_folder . $source_filename;
80 $srcTime = @filemtime($source_path);
83 if(empty($srcTime) && strpos($source_filename,
'//')===
false && !file_exists($source_path)){
86 if (!empty(
$GLOBALS[
'display_errors']) &&
a_priv(
'admin*',
false)) {
87 $GLOBALS[
'notification_output_array'][] =
$GLOBALS[
'tplEngine']->createTemplate(
'global_error.tpl', array(
'message' =>
$GLOBALS[
'STR_MODULE_THUMBS_IMAGE_NOT_AVAILABLE_MESSAGE'] .
' '. $source_path))->fetch();
92 if (empty($thumb_rename)) {
94 $thumb_filename = @basename($source_filename);
95 $thumb_path = $thumb_folder . $thumb_filename;
96 }
elseif($thumb_rename ===
true) {
97 $extension = @pathinfo($source_path , PATHINFO_EXTENSION);
98 $nom = @basename($source_path,
'.' .
$extension);
100 $inWidth =
vb($width);
101 $inHeight =
vb($height);
103 $folder_hash =
String::substr(md5($source_path .
'-' . $width .
'x' . $height .
'-' . $method), 0,
vn(
$GLOBALS[
'site_parameters'][
'thumbs_name_suffix_length'], 6));
104 $thumb_filename = $nom .
'-' . $folder_hash .
'.' .
$extension;
105 if(!empty($use_subfolders)) {
108 $thumb_path = $thumb_folder . $folder1 .
'/' . (!empty($folder2) ? $folder2 .
'/':
'') . $thumb_filename;
110 $thumb_path = $thumb_folder . $thumb_filename;
113 $thumb_filename = $thumb_rename;
114 $thumb_path = $thumb_folder . $thumb_filename;
116 $thumb_path_filemtime=@filemtime($thumb_path);
121 if ((!empty($_GET[
'update']) && $_GET[
'update'] == 1) || (!empty($srcTime) && $srcTime > $thumb_path_filemtime) || (empty($srcTime) && (empty($thumb_path_filemtime) || time()-24*10*3600>$thumb_path_filemtime))) {
122 if(!empty(
$GLOBALS[
'site_parameters'][
'skip_images_keywords'])){
124 foreach(
$GLOBALS[
'site_parameters'][
'skip_images_keywords'] as $this_keyword){
125 if(strpos($source_filename, $this_keyword)!==
false) {
127 $skip_creation =
true;
131 if(empty($skip_creation)){
132 $imgInfo = @getimagesize($source_path);
135 if (!empty(
$GLOBALS[
'display_errors']) &&
a_priv(
'admin*',
false)) {
136 $GLOBALS[
'notification_output_array'][] =
$GLOBALS[
'tplEngine']->createTemplate(
'global_error.tpl', array(
'message' =>
$GLOBALS[
'STR_MODULE_THUMBS_PICTURE_NOT_SUPPORTED'] .
' ' . $source_path))->fetch();
138 $skip_creation =
true;
141 if(!empty($skip_creation)){
142 if(empty($thumb_path_filemtime)){
150 }
elseif(empty($skip_creation)){
152 $srcWidth = $imgInfo[0];
153 $srcHeight = $imgInfo[1];
154 $srcType = $imgInfo[2];
156 case 1 : $srcType =
"gif";
158 case 2 : $srcType =
"jpeg";
160 case 3 : $srcType =
"png";
162 default: $srcType =
"???";
164 if ($method ==
"stretch") {
168 $outHeight = $height;
172 $xRatio = ($width) ? ($srcWidth / $width) : 0;
173 $yRatio = ($height) ? ($srcHeight / $height): 0;
174 $ratio = max($xRatio, $yRatio, 1);
175 $outWidth = intval($srcWidth / $ratio);
176 $outHeight = intval($srcHeight / $ratio);
179 $outImg = imagecreatetruecolor ($outWidth, $outHeight);
183 $srcImg = imagecreatefrompng($source_path);
186 imagealphablending($outImg,
false);
188 imagesavealpha($outImg,
true);
191 $srcImg = imagecreatefromgif($source_path);
193 $src_transparent_index = imagecolortransparent($srcImg);
194 if($src_transparent_index!=(-1) && $src_transparent_index<imagecolorstotal($srcImg)) {
195 $transparent_color = imagecolorsforindex($srcImg, $src_transparent_index);
197 if(!empty($transparent_color))
199 $out_transparent = imagecolorallocate($outImg, $transparent_color[
'red'], $transparent_color[
'green'], $transparent_color[
'blue']);
200 $background = imagecolortransparent($outImg, $out_transparent);
204 $srcImg = imagecreatefromjpeg($source_path);
207 if (!empty(
$GLOBALS[
'display_errors']) &&
a_priv(
'admin*',
false)) {
208 $GLOBALS[
'notification_output_array'][] =
$GLOBALS[
'tplEngine']->createTemplate(
'global_error.tpl', array(
'message' =>
$GLOBALS[
'STR_MODULE_THUMBS_PICTURE_NOT_SUPPORTED'] .
' ' . $source_path))->fetch();
212 if(!empty($srcImg)) {
213 if(empty($background)) {
215 $background = imagecolorallocate($outImg, 255, 255, 255);
217 imagefill($outImg, 0, 0, $background);
219 imagecopyresampled($outImg, $srcImg, 0, 0, 0, 0, $outWidth, $outHeight, $srcWidth, $srcHeight);
220 if(!empty($use_subfolders)) {
221 if(!is_dir($thumb_folder . $folder1)) {
222 mkdir($thumb_folder . $folder1);
224 if(!empty($folder2) && !is_dir($thumb_folder . $folder1 .
'/' . $folder2)) {
225 mkdir($thumb_folder . $folder1 .
'/'. $folder2);
231 $res = imagepng($outImg, $thumb_path);
234 $res = imagegif($outImg, $thumb_path);
237 $res = imagejpeg($outImg, $thumb_path,
vn(
$GLOBALS[
'site_parameters'][
'jpeg_quality']));
243 if (!empty(
$GLOBALS[
'display_errors']) &&
a_priv(
'admin*',
false)) {
244 $GLOBALS[
'notification_output_array'][] =
$GLOBALS[
'tplEngine']->createTemplate(
'global_error.tpl', array(
'message' =>
$GLOBALS[
'STR_MODULE_THUMBS_CANNOT_SAVE_PICTURE']))->fetch();
246 if(empty($thumb_path_filemtime)){
256 if(!empty($return_absolute_path)) {
257 if($return_absolute_path ===
true) {
if(!defined('IN_PEEL')) $GLOBALS['page_types_array']
if(!defined('IN_PEEL')) thumbs($source_filename, $width, $height, $method= 'fit', $source_folder=null, $thumb_folder=null, $thumb_rename=true, $return_absolute_path=false)
Charge l'image dont le nom est $source_filename dans le répertoire d'upload, et crée une vignette pou...
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
get_file_type($filename)
get_file_type()
a_priv($requested_priv, $demo_allowed=false, $site_configuration_modification=false, $user_id=null)
Renvoie true si l'utilisateur de la session a le privilège $requested_priv ou un droit supérieur Des ...
static substr($string, $start, $length=null)
Returns the portion of string specified by the start and length parameters.
static rawurlencode($string, $avoid_slash=true)
Returns string compatible with Apache without the AllowEncodedSlashes directive ON => avoids systemat...