function localPicture($img_list, &$content, $zoom = 700) { global $db, $setting, $req, $pic_list; for ($i = 0, $m = count($img_list); $i < $m; $i++) { if (array_search($img_list[$i], $pic_list) === false) { array_push($pic_list, $img_list[$i]); } else { continue; } if (strpos($img_list[$i], $setting['web']['url']) !== false) { continue; } if (strpos($img_list[$i], getSetting('web', 'url')) !== false) { continue; } $the_time = GetMicrotime(); $old_name = strtolower(basename($img_list[$i])); $ext = "." . GetFileExt($img_list[$i]); $ext = preg_replace("/\\?.*\$/", "", $ext); $old_name = preg_replace("/\\?.*\$/", "", $old_name); $old_name = preg_replace("/[;,&\\=]/", "", $old_name); //if(strpos("*.jpg.bmp.gif.png",$ext)===false) continue; if ($ext == ".") { $ext = ".jpg"; $old_name .= $ext; } if (strlen($old_name) > 120) { $old_name = substr($old_name, -120); } $new_name = $the_time . $ext; $the_path = ROOT_PATH . "/" . $setting['path']['upload'] . date("/Y/m/d/"); MakeDir($the_path); if (GetRemoteFile($img_list[$i], $the_path . $new_name)) { $img_info = GetImageSize($the_path . $new_name); $the_width = $img_info[0]; $the_height = $img_info[1]; if (!is_numeric($zoom)) { $zoom = 700; } if ($the_width > $zoom) { $the_height *= $zoom / $the_width; $the_width = $zoom; } $data = array(0, 0, 0, $old_name, "image" . str_replace(".", "/", $ext), filesize($the_path . $new_name), '', $the_time, 0, '', $req->getSession('username'), $setting['watermark']['mode'] & 2 ? 1 : 0); $db->insert($setting['db']['pre'] . "attachment", $data); $new_id = $db->GetInsertId(); if ($new_id != 0) { $attach_list .= $new_id . ","; $content = str_replace($img_list[$i], $setting['web']['url'] . "/files?" . $new_id, $content); array_push($id_list, $new_id); } $name_new = $the_time . substr(md5(filesize($the_path . $new_name)), 0, 5) . $ext; rename($the_path . $new_name, $the_path . $name_new); MakeDir("{$the_path}/preview/"); img_thumb($the_path . $name_new, $the_width, $the_height, $the_path . "/preview/" . $name_new); } } return $attach_list; }
//===Documents folder, should exist in your host in there you're going to save the file just uploaded $moveResult = move_uploaded_file($temp, $file_to_saved); //echo $file_to_saved; if ($moveResult != true) { echo "<span style='color:red;font-size:24px;'>"; echo "ERROR: File not uploaded. Try again."; echo "</span>"; unlink($temp); // Remove the uploaded file from the PHP temp folder exit; } //======= Image part ends here //unlink($temp); // Remove the uploaded file from the PHP temp folder //========Include Image Resize function======= include 'imageResize.php'; $file_to_saved = "../../Assets/image/HomePage/" . $file_get; $resized_file = "../../Assets/image/HomePage/" . "resized_" . $file_get; $wmax = 400; $hmax = 750; img_resize($file_to_saved, $resized_file, $wmax, $hmax, $fileExt); unlink($file_to_saved); // Remove the Original file from the image folder and display only resized image //========End of Image Resize function=========== // ======== Start Image Thumbnail(Crop) Function//===== ------ $target_file = "../../Assets/image/HomePage/" . "resized_" . $file_get; $thumbnail = "../../Assets/image/HomePage/" . "thumb_" . $file_get; $wthumb = 400; $hthumb = 595; img_thumb($target_file, $thumbnail, $wthumb, $hthumb, $fileExt); unlink($resized_file); //====End of Image Thumbnail(Crop) Function ==============
$ext = str_replace(".", "", $ext); $upload->upload_result[0]['new_name'] = str_replace(".upload", "", $upload->upload_result[0]['new_name']); $db->insert($setting['db']['pre'] . "attachment", array(0, 0, 0, $upload->upload_result[0]['name'], $upload->upload_result[0]['type'], $upload->upload_result[0]['size'], '', substr($upload->upload_result[0]['new_name'], 0, 13), 0, '', $req->getSession('username'), $watermark)); $new_id = $db->GetInsertId(); if ($new_id != 0) { $upload->upload_result[0]['att_id'] = $new_id; if (strpos($upload->upload_result[0]['type'], "image") === 0) { $upload->MakeDir("{$path_upload}/preview/"); $img_info = GetImageSize("{$path_upload}/" . $upload->upload_result[0]['new_name']); $the_width = $img_info[0]; $the_height = $img_info[1]; $zoom = 400; if ($the_width > $zoom) { $the_height *= $zoom / $the_width; $the_width = (int) $zoom; img_thumb($path_upload . "/" . $upload->upload_result[0]['new_name'], $the_width, $the_height, $path_upload . "/preview/" . $upload->upload_result[0]['new_name']); } else { copy($path_upload . "/" . $upload->upload_result[0]['new_name'], $path_upload . "/preview/" . $upload->upload_result[0]['new_name']); } } $script .= "parent.document.forms[0].attach_list.value += '{$new_id}|';\n"; $err_msg[] = $upload->upload_result[0]['name'] . " - " . $setting['language']['admin_attachment_upload_done']; } else { unlink("{$path_upload}/" . $upload->upload_result[0]['new_name']); $upload->upload_result[0]['att_id'] = 0; $upload->upload_result[0]['error'] = 10; $upload->upload_result[0]['message'] = $setting['language']['admin_attachment_upload_dberr']; } } else { $upload->upload_result[0]['att_id'] = 0; }
} } $tci = imagecreatetruecolor($w, $h); if ($ext == "gif" or $ext == "png") { imagecolortransparent($tci, imagecolorallocatealpha($tci, 0, 0, 0, 127)); imagealphablending($tci, false); imagesavealpha($tci, true); } imagecopyresampled($tci, $img, 0, 0, $src_x, $src_y, $w, $h, $w_orig, $h_orig); // if($src_x<0) { // $bgd = imagecolorallocate($tci, 255, 255, 255); // imagefill($tci, 0, 0, $bgd); // } if ($ext == "gif") { imagegif($tci, $newcopy); } else { if ($ext == "png") { imagepng($tci, $newcopy); } else { if ($ext == "bmp") { imagebmp($tci, $newcopy); } else { imagejpeg($tci, $newcopy, 84); } } } } img_thumb($tempFile, $targetFile, $thumbWidth, $thumbHeight, $ext); img_thumb($tempFile, $targetThumb, 86, 86, $ext); } echo $filename;
} $tci = imagecreatetruecolor($w, $h); if ($ext == "gif" or $ext == "png") { imagecolortransparent($tci, imagecolorallocatealpha($tci, 0, 0, 0, 127)); imagealphablending($tci, false); imagesavealpha($tci, true); } imagecopyresampled($tci, $img, 0, 0, $src_x, $src_y, $w, $h, $w_orig, $h_orig); // if($src_x<0) { // $bgd = imagecolorallocate($tci, 255, 255, 255); // imagefill($tci, 0, 0, $bgd); // } if ($ext == "gif") { imagegif($tci, $newcopy); } else { if ($ext == "png") { imagepng($tci, $newcopy); } else { if ($ext == "bmp") { imagebmp($tci, $newcopy); } else { imagejpeg($tci, $newcopy, 84); } } } } img_thumb($tempFile, $targetFile, $thumbWidth, $thumbHeight, $ext); img_thumb($tempFile, $targetFree, 360, 260, $ext); img_thumb($tempFile, $targetPaid, 556, 322, $ext); } echo $filename;
?> , mis à jour le <em><?php echo $udate; ?> </em> <?php } ?> </p> <?php if ($c_image) { ?> <?php echo img_thumb($c_image); ?> <br /> <?php } ?> <?php echo str_replace('<pre', '<pre class="line-numbers"', $c_content); ?> <?php if (!empty($twitter)) { ?> <br /> <a href="https://twitter.com/share" class="twitter-share-button" data-via="<?php echo $twitter;
$width = $para[1]; $height = $para[2]; if (empty($parent_element)) { $parent_element = "image"; } set_time_limit(0); $script = ""; if (count($_POST) > 0) { $path_upload = $setting['path']['upload'] . "/pic/" . date("Ym") . "/"; $upload = new MyUploader(); $upload->init("../" . $path_upload, true); $upload->DoIt(); if ($upload->upload_result[0]['error'] == 0) { $the_file = $path_upload . "/" . $upload->upload_result[0]['new_name']; if (!empty($width) && !empty($height)) { img_thumb(ROOT_PATH . "/" . $the_file, $width, $height, ROOT_PATH . "/" . $the_file . ".thumb"); unlink(ROOT_PATH . "/" . $the_file); rename(ROOT_PATH . "/" . $the_file . ".thumb", ROOT_PATH . "/" . $the_file); } $script = "\r\n\t\t\tvar theOLE = null;\r\n\t\t\ttheOLE = parent.parent || parent.dialogArguments || parent.opener;\r\n\t\t\ttheOLE.document.forms[0].{$parent_element}.value = '" . $web_url . "/" . $the_file . "';\r\n\t\t\talert('" . $setting['language']['admin_upload_img_ok'] . "');\r\n\t\t\tif(parent.parent==null){parent.close();}else{parent.parent.\$.closePopupLayer();}\r\n\t\t\treturn;\r\n\t\t"; } else { $script = "\r\n\t\t\talert('" . $upload->upload_result[0]['message'] . "');\r\n\t\t\tif(parent.parent==null){parent.close();}else{parent.parent.\$.closePopupLayer();}\r\n\t\t"; } } $tpl_info['idx'] = "upload_img"; $tpl_tmp = $mystep->getInstance("MyTpl", $tpl_info); $tpl_tmp->Set_Variable('script', $script); $tpl_tmp->Set_Variable('para', implode("|", $para)); $tpl_tmp->Set_Variable('self', $setting['info']['self']); $Max_size = ini_get('upload_max_filesize'); $tpl_tmp->Set_Variable('Max_size', $Max_size);
$img = imagecreatefromjpeg($target); } } $tci = imagecreatetruecolor($w, $h); if ($ext == "gif" or $ext == "png") { imagecolortransparent($tci, imagecolorallocatealpha($tci, 0, 0, 0, 127)); imagealphablending($tci, false); imagesavealpha($tci, true); } imagecopyresampled($tci, $img, 0, 0, $src_x, $src_y, $w, $h, $w_orig, $h_orig); // if($src_x<0) { // $bgd = imagecolorallocate($tci, 255, 255, 255); // imagefill($tci, 0, 0, $bgd); // } if ($ext == "gif") { imagegif($tci, $newcopy); } else { if ($ext == "png") { imagepng($tci, $newcopy); } else { if ($ext == "bmp") { imagebmp($tci, $newcopy); } else { imagejpeg($tci, $newcopy, 84); } } } } img_thumb($tempFile, $targetFile, $thumbWidth, $thumbHeight, $ext); } echo $filename;