/** загрузка(сохранение/обновление) аватара * @param integer ID записи * @param boolean удалять предыдущий аватар * @return имя файла успешно загруженной аватары | false */ function update($nRecordID, $bDeletePrevious = false, $bDoUpdateQuery = false) { global $oDb; if ($nRecordID && !empty($_FILES) && $_FILES[$this->input]['error'] == UPLOAD_ERR_OK) { $oUpload = new Upload($this->input, false); $aImageSize = getimagesize($_FILES[$this->input]['tmp_name']); if ($oUpload->isSuccessfull() && $aImageSize !== FALSE && in_array($aImageSize[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) { if ($bDeletePrevious) { $this->delete($nRecordID, false); } $sExtension = func::image_type_to_extension($aImageSize[2], false); $sFilename = Func::generateRandomName($this->filenameLetters, true, true) . '.' . $sExtension; //проверяем размер файла if (!$oUpload->checkSize($this->maxsize)) { return false; } //создаем thumbnail $oThumb = new thumbnail($_FILES[$this->input]['tmp_name']); $oThumb->jpeg_quality(85); $oThumb->crop_proportionaly(1, 1, 'middle', 'center'); $oThumb->createTumbnail_if_more_then($this->path . $nRecordID . '_' . $sFilename, $this->width, $this->height, true); @unlink($_FILES[$this->input]['tmp_name']); if ($bDoUpdateQuery) { $oDb->execute("UPDATE {$this->table} \n SET {$this->fieldAvatar} =" . $oDb->str2sql($sFilename) . "\n WHERE {$this->fieldID} = {$nRecordID} "); } return $sFilename; } } return false; }
function save() { //---Crear la galería con los nombres de todos los archivos $total = count($this->files); $cont = 0; //---Situar los thumbnails for ($i = 0; $i < $total; $i++) { $lame = $this->path . '/' . $this->files[$i]; $saver = $this->path . '/thumb/' . $this->files[$i]; //echo $saver."<br>"; //echo $lame."<br>"; $thumb = new thumbnail($lame); $thumb->size_height(250); $thumb->jpeg_quality(80); $thumb->save($saver); } }
/** загрузка(сохранение/обновление) скриншота * @param integer ID записи * @param boolean удалять предыдущий скриншот * @return имя файла успешно загруженного скриншота | false */ function update($nRecordID, $bDeletePrevious = false, $bDoUpdateQuery = false) { global $oDb; if ($nRecordID && !empty($_FILES) && $_FILES[$this->input]['error'] == UPLOAD_ERR_OK) { $oUpload = new Upload($this->input, false); $aImageSize = getimagesize($_FILES[$this->input]['tmp_name']); if ($oUpload->isSuccessfull() && $aImageSize !== FALSE && in_array($aImageSize[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) { if ($bDeletePrevious) { $this->delete($nRecordID, false); } $sExtension = func::image_type_to_extension($aImageSize[2], false); $sFilename = Func::generateRandomName($this->filenameLetters, true, true) . '.' . $sExtension; //проверяем размер файла if (!$oUpload->checkSize($this->maxsize)) { return false; } //создаем thumbnail $oThumb = new thumbnail($_FILES[$this->input]['tmp_name']); $oThumb->jpeg_quality(85); $bFileMoved = false; foreach ($this->sizes as $s) { if (!empty($s['original'])) { $oUpload->save($this->path, $nRecordID . '_' . $s['p'] . $sFilename, false, false); $bFileMoved = true; break; } $oThumb->createTumbnail_if_more_then($this->path . $nRecordID . '_' . $s['p'] . $sFilename, $s['w'], $s['h'], isset($s['autofit']) ? $s['autofit'] : true); } if (!$bFileMoved) { @unlink($_FILES[$this->input]['tmp_name']); } if ($bDoUpdateQuery) { $oDb->execute("UPDATE {$this->table} \n SET {$this->fieldPreview} =" . $oDb->str2sql($sFilename) . "\n WHERE {$this->fieldID} = {$nRecordID}"); } return $sFilename; } } return false; }
/** * Branded ein Bild mit einem Wasserzeichen * * Der Filter sucht im Verzeichnis addons/image_resize/media/ * nach einem Bild mit dem Dateinamen "brand.*" und verwendet den 1. Treffer */ function image_resize_brand(&$src_im) { global $REX; $files = glob($REX['INCLUDE_PATH'] . '/addons/image_resize/media/brand.*'); $brandImage = $files[0]; $brand = new thumbnail($brandImage); $paddX = 10; $paddY = 10; imagealphablending($src_im, true); imagecopy($src_im, $brand->getImage(), imagesx($src_im) - $brand->getImageWidth() - $paddX, imagesy($src_im) - $brand->getImageHeight() - $paddY, 0, 0, $brand->getImageWidth(), $brand->getImageHeight()); $brand->destroyImage(); }
/** * Make sure newly uploaded images are within the site's max-size setting * */ function MaxSize($added) { global $config; foreach ($added as $file) { thumbnail::CheckArea($file['realpath'], $config['maximgarea']); } }
function rex_image_ep_mediaupdated($params) { thumbnail::deleteCache($params["filename"]); }
/** * Save the GD image ($src_img) to the desired location ($dest_path) with the sizing arguments * */ function createImg($src_img, $dest_path, $dst_x, $dst_y, $off_w, $off_h, $dst_w, $dst_h, $old_x, $old_y, $new_w = false, $new_h = false) { if (!$new_w) { $new_w = $dst_w; } if (!$new_h) { $new_h = $dst_h; } $dst_img = imagecreatetruecolor($new_w, $new_h); if (!$dst_img) { trigger_error('dst_img not created'); return false; } $img_type = thumbnail::getType($dest_path); // allow gif & png to have transparent background if (function_exists('imagesavealpha')) { if ($img_type == 'gif' || $img_type == 'png') { imagealphablending($dst_img, false); imagesavealpha($dst_img, true); //php 4.3.2+ $transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127); imagefilledrectangle($dst_img, 0, 0, $dst_x, $dst_y, $transparent); } } if (!imagecopyresampled($dst_img, $src_img, $dst_x, $dst_y, $off_w, $off_h, $dst_w, $dst_h, $old_x, $old_y)) { trigger_error('copyresample failed'); imagedestroy($dst_img); imagedestroy($src_img); return false; } imagedestroy($src_img); return thumbnail::SrcToImage($dst_img, $dest_path, $img_type); }
<?php require_once '../classes/image.class.php'; $size = 600; $image = new thumbnail($_GET['src']); //$image->size_width($size); //Фіксована ширина //$image->size_height($size); //Фіксована висота $image->size_auto($size); //Фіксована ширина або висота //$image->size_crop($size); //Одинакові ширина та висота //$image->size_width_height($size,$size_h); //Довільна ширина та висота $image->add_logo("watermark.png"); //Додати лого до картинки $image->show();
function FileUpload() { global $config, $db, $lang, $member_id, $user_group; $_IP = get_ip(); $added_time = time() + $config['date_adjust'] * 60; if (!is_dir(ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX)) { @mkdir(ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX, 0777); @chmod(ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX, 0777); @mkdir(ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX . "thumbs", 0777); @chmod(ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX . "thumbs", 0777); } if (!is_dir(ROOT_DIR . "/uploads/files/" . FOLDER_PREFIX)) { @mkdir(ROOT_DIR . "/uploads/files/" . FOLDER_PREFIX, 0777); @chmod(ROOT_DIR . "/uploads/files/" . FOLDER_PREFIX, 0777); } if (!is_dir(ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX)) { return $this->msg_error($lang['upload_error_0'] . " /uploads/posts/" . FOLDER_PREFIX, 403); } if (!is_dir(ROOT_DIR . "/uploads/files/" . FOLDER_PREFIX)) { return $this->msg_error($lang['upload_error_0'] . " /uploads/files/" . FOLDER_PREFIX, 403); } if (!is_writable(ROOT_DIR . "/uploads/" . $this->upload_path . FOLDER_PREFIX)) { return $this->msg_error($lang['upload_error_1'] . " /uploads/" . $this->upload_path . FOLDER_PREFIX . " " . $lang['upload_error_2'], 403); } if (!is_writable(ROOT_DIR . "/uploads/files/" . FOLDER_PREFIX)) { return $this->msg_error($lang['upload_error_1'] . " /uploads/files/" . FOLDER_PREFIX . " " . $lang['upload_error_2'], 403); } if (!is_writable(ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX . "thumbs")) { return $this->msg_error($lang['upload_error_1'] . " /uploads/posts/" . FOLDER_PREFIX . "thumbs/ " . $lang['upload_error_2'], 403); } if (!$this->file) { return $this->msg_error($lang['upload_error_3'], 405); } $filename = $this->check_filename($this->file->getFileName()); $size = $this->file->getFileSize(); if (!$filename) { return $this->msg_error($lang['upload_error_4'], 405); } $filename_arr = explode(".", $filename); $type = end($filename_arr); if (!$type) { return $this->msg_error($lang['upload_error_4'], 405); } $error_code = $this->file->getErrorCode(); if ($error_code) { return $this->msg_error($error_code, 405); } if ($size == 0) { return $this->msg_error($lang['upload_error_5'], 403); } if ($config['files_allow'] == "yes" and $user_group[$member_id['user_group']]['allow_file_upload'] and in_array($type, $this->allowed_files)) { if (intval($user_group[$member_id['user_group']]['max_file_size']) and $size > $user_group[$member_id['user_group']]['max_file_size'] * 1024) { return $this->msg_error($lang['files_too_big'], 500); } if ($this->area != "template" and $user_group[$member_id['user_group']]['max_files']) { $row = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_files WHERE author = '{$this->author}' AND news_id = '{$this->news_id}'"); $count_files = $row['count']; if ($count_files and $count_files >= $user_group[$member_id['user_group']]['max_files']) { return $this->msg_error($lang['error_max_files'], 403); } } $uploaded_filename = $this->file->saveFile(ROOT_DIR . "/uploads/files/" . FOLDER_PREFIX, $filename, $this->use_prefix); if ($uploaded_filename) { @chmod(ROOT_DIR . "/uploads/files/" . FOLDER_PREFIX . $uploaded_filename, 0666); $added_time = time() + $config['date_adjust'] * 60; if ($user_group[$member_id['user_group']]['allow_admin']) { $db->query("INSERT INTO " . USERPREFIX . "_admin_logs (name, date, ip, action, extras) values ('" . $db->safesql($member_id['name']) . "', '{$added_time}', '{$_IP}', '36', '{$uploaded_filename}')"); } if ($this->area == "template") { $db->query("INSERT INTO " . PREFIX . "_static_files (static_id, author, date, name, onserver) values ('{$this->news_id}', '{$this->author}', '{$added_time}', '{$filename}', '" . FOLDER_PREFIX . "{$uploaded_filename}')"); $id = $db->insert_id(); if (in_array($type, $this->allowed_video)) { if ($type == "mp3") { $file_link = $config['http_home_url'] . "engine/skins/images/mp3_file.png"; $data_url = $config['http_home_url'] . "uploads/files/" . FOLDER_PREFIX . $uploaded_filename; $file_play = "audio"; } elseif ($type == "swf") { $file_link = $config['http_home_url'] . "engine/skins/images/file_flash.png"; $data_url = $config['http_home_url'] . "uploads/files/" . FOLDER_PREFIX . $uploaded_filename; $file_play = "flash"; } else { $file_link = $config['http_home_url'] . "engine/skins/images/video_file.png"; $data_url = $config['http_home_url'] . "uploads/files/" . FOLDER_PREFIX . $uploaded_filename; $file_play = "video"; } } else { $file_link = $config['http_home_url'] . "engine/skins/images/all_file.png"; $data_url = "#"; $file_play = ""; } $return_box = "<div class=\"uploadedfile\"><div class=\"info\">{$filename}</div><div class=\"uploadimage\"><a class=\"uploadfile\" href=\"{$data_url}\" data-src=\"{$id}:{$filename}\" data-type=\"file\" data-play=\"{$file_play}\"><img style=\"width:auto;height:auto;max-width:100px;max-height:90px;\" src=\"" . $file_link . "\" /></a></div><div class=\"info\"><input type=\"checkbox\" id=\"file\" name=\"static_files[]\" value=\"{$id}\" data-type=\"file\"> " . formatsize($size) . "</div></div>"; } else { $db->query("INSERT INTO " . PREFIX . "_files (news_id, name, onserver, author, date) values ('{$this->news_id}', '{$filename}', '" . FOLDER_PREFIX . "{$uploaded_filename}', '{$this->author}', '{$added_time}')"); $id = $db->insert_id(); if (in_array($type, $this->allowed_video)) { if ($type == "mp3") { $file_link = $config['http_home_url'] . "engine/skins/images/mp3_file.png"; $data_url = $config['http_home_url'] . "uploads/files/" . FOLDER_PREFIX . $uploaded_filename; $file_play = "audio"; } elseif ($type == "swf") { $file_link = $config['http_home_url'] . "engine/skins/images/file_flash.png"; $data_url = $config['http_home_url'] . "uploads/files/" . FOLDER_PREFIX . $uploaded_filename; $file_play = "flash"; } else { $file_link = $config['http_home_url'] . "engine/skins/images/video_file.png"; $data_url = $config['http_home_url'] . "uploads/files/" . FOLDER_PREFIX . $uploaded_filename; $file_play = "video"; } } else { $file_link = $config['http_home_url'] . "engine/skins/images/all_file.png"; $data_url = "#"; $file_play = ""; } $return_box = "<div class=\"uploadedfile\"><div class=\"info\">{$filename}</div><div class=\"uploadimage\"><a class=\"uploadfile\" href=\"{$data_url}\" data-src=\"{$id}:{$filename}\" data-type=\"file\" data-play=\"{$file_play}\"><img style=\"width:auto;height:auto;max-width:100px;max-height:90px;\" src=\"" . $file_link . "\" /></a></div><div class=\"info\"><input type=\"checkbox\" id=\"file\" name=\"files[]\" value=\"{$id}\" data-type=\"file\"> " . formatsize($size) . "</div></div>"; } } else { return $this->msg_error($lang['images_uperr_3'], 403); } } elseif (in_array($type, $this->allowed_extensions) and $user_group[$member_id['user_group']]['allow_image_upload']) { if (intval($config['max_up_size']) and $size > $config['max_up_size'] * 1024 and !$config['max_up_side']) { return $this->msg_error($lang['images_big'], 500); } if ($this->area != "template" and $this->area != "adminupload" and $user_group[$member_id['user_group']]['max_images']) { $row = $db->super_query("SELECT images FROM " . PREFIX . "_images WHERE author = '{$this->author}' AND news_id = '{$this->news_id}'"); if ($row['images']) { $count_images = count(explode("|||", $row['images'])); } else { $count_images = false; } if ($count_images and $count_images >= $user_group[$member_id['user_group']]['max_images']) { return $this->msg_error($lang['error_max_images'], 403); } } $uploaded_filename = $this->file->saveFile(ROOT_DIR . "/uploads/" . $this->upload_path . FOLDER_PREFIX, $filename, $this->use_prefix); if ($uploaded_filename) { $added_time = time() + $config['date_adjust'] * 60; @chmod(ROOT_DIR . "/uploads/" . $this->upload_path . FOLDER_PREFIX . $uploaded_filename, 0666); $i_info = @getimagesize(ROOT_DIR . "/uploads/" . $this->upload_path . FOLDER_PREFIX . $uploaded_filename); if (!in_array($i_info[2], array(1, 2, 3))) { @unlink(ROOT_DIR . "/uploads/" . $this->upload_path . FOLDER_PREFIX . $uploaded_filename); return $this->msg_error($lang['upload_error_6'], 500); } $thumb = new thumbnail(ROOT_DIR . "/uploads/" . $this->upload_path . FOLDER_PREFIX . $uploaded_filename); if ($this->area != "template" and $this->area != "adminupload") { $row = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_images WHERE news_id = '{$this->news_id}' AND author = '{$this->author}'"); if (!$row['count']) { $inserts = FOLDER_PREFIX . $uploaded_filename; $db->query("INSERT INTO " . PREFIX . "_images (images, author, news_id, date) values ('{$inserts}', '{$this->author}', '{$this->news_id}', '{$added_time}')"); } else { $row = $db->super_query("SELECT images FROM " . PREFIX . "_images WHERE news_id = '{$this->news_id}' AND author = '{$this->author}'"); if ($row['images'] == "") { $listimages = array(); } else { $listimages = explode("|||", $row['images']); } foreach ($listimages as $dataimages) { if ($dataimages == FOLDER_PREFIX . $uploaded_filename) { $error_image = "stop"; } } if ($error_image != "stop") { $listimages[] = FOLDER_PREFIX . $uploaded_filename; $row['images'] = implode("|||", $listimages); $db->query("UPDATE " . PREFIX . "_images SET images='{$row['images']}' WHERE news_id = '{$this->news_id}' AND author = '{$this->author}'"); } } } if ($this->area == "template") { $inserts = FOLDER_PREFIX . $uploaded_filename; $db->query("INSERT INTO " . PREFIX . "_static_files (static_id, author, date, name) values ('{$this->news_id}', '{$this->author}', '{$added_time}', '{$inserts}')"); $id = $db->insert_id(); } if ($user_group[$member_id['user_group']]['allow_admin']) { $db->query("INSERT INTO " . USERPREFIX . "_admin_logs (name, date, ip, action, extras) values ('" . $db->safesql($member_id['name']) . "', '{$added_time}', '{$_IP}', '36', '{$uploaded_filename}')"); } if ($this->make_thumb) { if ($thumb->size_auto($this->t_size, $this->t_seite)) { $thumb->jpeg_quality($config['jpeg_quality']); if ($this->make_watermark) { $thumb->insert_watermark($config['max_watermark']); } $thumb->save(ROOT_DIR . "/uploads/" . $this->upload_path . FOLDER_PREFIX . "thumbs/" . $uploaded_filename); @chmod(ROOT_DIR . "/uploads/" . $this->upload_path . FOLDER_PREFIX . "thumbs/" . $uploaded_filename, 0666); } } if ($member_id['user_group'] == 1) { if ($this->make_watermark or $config['max_up_side']) { $thumb = new thumbnail(ROOT_DIR . "/uploads/" . $this->upload_path . FOLDER_PREFIX . $uploaded_filename); $thumb->jpeg_quality($config['jpeg_quality']); $re_save = false; if (intval($config['max_up_side']) > 1 and $thumb->size_auto($config['max_up_side'], $config['o_seite'])) { $re_save = true; } if ($this->make_watermark) { $thumb->insert_watermark($config['max_watermark']); $re_save = true; } if ($re_save) { $thumb->save(ROOT_DIR . "/uploads/" . $this->upload_path . FOLDER_PREFIX . $uploaded_filename); } } } else { $thumb = new thumbnail(ROOT_DIR . "/uploads/" . $this->upload_path . FOLDER_PREFIX . $uploaded_filename); $thumb->jpeg_quality($config['jpeg_quality']); if ($config['max_up_side']) { $thumb->size_auto($config['max_up_side'], $config['o_seite']); } if ($this->make_watermark) { $thumb->insert_watermark($config['max_watermark']); } $thumb->save(ROOT_DIR . "/uploads/" . $this->upload_path . FOLDER_PREFIX . $uploaded_filename); } if ($config['max_up_side']) { $i_info = @getimagesize(ROOT_DIR . "/uploads/" . $this->upload_path . FOLDER_PREFIX . $uploaded_filename); } if (file_exists(ROOT_DIR . "/uploads/" . $this->upload_path . FOLDER_PREFIX . "thumbs/" . $uploaded_filename)) { $img_url = $config['http_home_url'] . "uploads/" . $this->upload_path . FOLDER_PREFIX . "thumbs/" . $uploaded_filename; $thumb_data = "yes"; } else { $img_url = $config['http_home_url'] . "uploads/" . $this->upload_path . FOLDER_PREFIX . $uploaded_filename; $thumb_data = "no"; } $data_url = $config['http_home_url'] . "uploads/" . $this->upload_path . FOLDER_PREFIX . $uploaded_filename; if ($this->area != "template") { $return_box = "<div class=\"uploadedfile\"><div class=\"info\">{$filename}</div><div class=\"uploadimage\"><a class=\"uploadfile\" href=\"{$data_url}\" data-src=\"{$data_url}\" data-thumb=\"{$thumb_data}\" data-type=\"image\"><img style=\"width:auto;height:auto;max-width:100px;max-height:90px;\" src=\"" . $img_url . "\" /></a></div><div class=\"info\"><input type=\"checkbox\" name=\"images[" . FOLDER_PREFIX . $uploaded_filename . "]\" value=\"" . FOLDER_PREFIX . $uploaded_filename . "\" data-thumb=\"{$thumb_data}\" data-type=\"image\" data-src=\"{$data_url}\"> {$i_info[0]}x{$i_info[1]}</div></div>"; } else { $return_box = "<div class=\"uploadedfile\"><div class=\"info\">{$filename}</div><div class=\"uploadimage\"><a class=\"uploadfile\" href=\"{$data_url}\" data-src=\"{$data_url}\" data-thumb=\"{$thumb_data}\" data-type=\"image\"><img style=\"width:auto;height:auto;max-width:100px;max-height:90px;\" src=\"" . $img_url . "\" /></a></div><div class=\"info\"><input type=\"checkbox\" name=\"static_files[]\" value=\"{$id}\" data-thumb=\"{$thumb_data}\" data-type=\"image\" data-src=\"{$data_url}\"> {$i_info[0]}x{$i_info[1]}</div></div>"; } } else { return $this->msg_error($lang['images_uperr_3'], 403); } } else { return $this->msg_error($lang['images_uperr_2'], 403); } $return_box = addcslashes($return_box, "\t\n\r\"\\/"); return htmlspecialchars("{\"success\":true, \"returnbox\":\"{$return_box}\"}", ENT_NOQUOTES, $config['charset']); }
foreach ($data as $url) { // во первых, проверка, чтобы картинка была только в папке uploads, ибо нефик!. //Покачто закомментировал т.к. на локалке работает всё нормально, нужно проверять на хостинге. /*$url = explode('/uploads/', $url); if(count($url) != 2) continue; // да ну нафиг, если в нескольких папках uploads $url = ROOT_DIR . '/uploads/' . $url[1]; if(!is_file($url)) continue;*/ $info = pathinfo($url); if (isset($info['extension'])) { $info['extension'] = strtolower($info['extension']); if (in_array($info['extension'], array('jpg', 'jpeg', 'gif', 'png'))) { $original_img = str_replace(ROOT_DIR, '', $url); $file_name = strtolower(basename($url)); $file_name = $img_size . "_" . $file_name; if (!file_exists($dir . $file_name)) { $thumb = new thumbnail($url); $thumb->size_auto($img_size); $thumb->save($dir . $file_name); } if ($img_size == 0) { $image[] = $original_img; } else { $image[] = $config['http_home_url'] . "uploads/blockpro/" . $file_name; } } } } if (count($image)) { $i = 0; foreach ($image as $url) { $i++;
// оригинальное название для оприделения формата $image_rename = substr(md5($server_time + rand(1, 100000)), 0, 20); // имя фотографии $image_size = $_FILES['uploadfile']['size']; // размер файла $type = end(explode(".", $image_name)); // формат файла //Проверям если, формат верный то пропускаем if (in_array(strtolower($type), $allowed_files)) { if ($image_size < 5000000) { $res_type = strtolower('.' . $type); if (move_uploaded_file($image_tmp, $album_dir . $image_rename . $res_type)) { //Подключаем класс для фотографий include ENGINE_DIR . '/classes/images.php'; //Создание оригинала $tmb = new thumbnail($album_dir . $image_rename . $res_type); $tmb->size_auto('570', 1); $tmb->jpeg_quality('100'); $tmb->save($album_dir . $image_rename . $res_type); $img_url = $config['home_url'] . 'uploads/blog/' . $image_rename . $res_type; //Результат для ответа echo $img_url; } else { echo 'big_size'; } } else { echo 'big_size'; } } else { echo 'bad_format'; }
<?php include "dbcon.php"; require_once 'clasess/thumbnail.class.php'; $order_id = $_REQUEST['order_id']; $name = $_REQUEST['name']; $email = $_REQUEST['email']; $event_name = $_REQUEST['event']; $signup_deadline = $_REQUEST['signup_deadline']; $product_description = $_REQUEST['product_description']; $cost_per_item = $_REQUEST['cost_per_item']; // base64_encode($order_id); ######## START IMAGE THUMBNAILS CREATION ######## $thumbnail = new thumbnail(); if (!empty($_REQUEST['submit'])) { $tmp = $_FILES['upload_pic']['tmp_name']; $org = $_FILES['upload_pic']['name']; $org_size = $_FILES['upload_pic']['size']; list($imageWidth, $imageHeight, $imageType, $imageAttr) = getimagesize($tmp); if ($tmp) { $directory = 'images/products'; // Upload files to here. $prefix = time(); // Filename prefixes $smlImage = $thumbnail->generate($tmp, $org, $directory, 'thumb_' . $prefix . '_' . $org, 40); if ($org_size > 400) { $org_size = 400; } $bigImage = $thumbnail->generate($tmp, $org, $directory, 'big_' . $prefix . '_' . $org, $imageWidth); $upload_pic = $prefix . '_' . $org; }
public function addCover($field, $dir = false) { global $settings; if (!$dir) { global $coverpath; $dir = $coverpath; } $bestand = $dir . $this->id . ".jpg"; // Is it jpg or png? $extentie = strtolower(findExtention($_FILES[$field]["name"])); if ($extentie != "jpg") { return false; } // Remove old file if (file_exists($bestand)) { unlink($bestand); } // Copy copy($_FILES[$field]["tmp_name"], $bestand); // Thumbnail $thumb = new thumbnail($bestand); $thumb->size_width($settings["photo"]["tn_maxwidth"]); $thumb->jpeg_quality(100); $thumb->save($dir . "tn_" . $this->id . ".jpg"); }
* die(); * } */ if (!file_exists("FOTOS/EINHEIT/{$e->einheit_kurzname}/ANZEIGE")) { // echo "NEMA ANZ ORDNERA"; mkdir("FOTOS/EINHEIT/{$e->einheit_kurzname}/ANZEIGE", 0777); } else { // echo "OK ANZ ORDNERA"; } /* Bisher alles ok */ if (file_exists("FOTOS/EINHEIT/{$e->einheit_kurzname}/ANZEIGE")) { // $kopiert = copy($orig_file, $newname); if (file_exists($orig_file)) { // echo "tempfile da"; // die(); $thumbnail = new thumbnail(); $thumbnail->create($orig_file); $thumbnail->setQuality(80); $thumbnail->resize("1024"); // $thumbnail->output(); $thumbnail->save($orig_file, true); // die(); if (!move_uploaded_file($orig_file, $newname)) { fehlermeldung_ausgeben("Datei {$orig_file} {$newname} konnte nicht kopiert werden"); } else { echo "{$orig_filename} hochgeladen"; // echo "OK Datei $orig_filename $newname aus temp verschoben!"; } } } else { // echo "ORDNER EXISTIERT NICHT und konnte nicht angelegt werden $orig_file";
$fileTypes = array('jpg', 'jpeg', 'gif', 'png'); // File extensions $fileParts = pathinfo($_FILES['Filedata']['name']); $image_ext = $fileParts['extension']; // Getting the image extention $image_name = basename($_FILES['Filedata']['name']); // Getting the image name // Generating a unique image path $image_path = md5(rand() * time()) . md5($image_name) . "." . $image_ext; // Generating a unique thumb image path $thumb_image_path = "thumb_" . $image_path; // Complete image path $targetFile = rtrim($targetPath, '/') . '/' . $image_path; // Complete thumb image path $thumbTargetFile = rtrim($targetPath, '/') . '/' . $thumb_image_path; $complete_image_path = $targetFolder . $image_path; $complete_thumb_path = $targetFolder . $thumb_image_path; if (in_array($image_ext, $fileTypes)) { copy($tempFile, $targetFile); //move_uploaded_file($tempFile,$targetFile); $thumb = new thumbnail($targetFile); $thumb->size_width(400); $thumb->size_height(300); $thumb->jpeg_quality(100); $thumb->save($thumbTargetFile); $query_obj->add_image($complete_thumb_path, $complete_image_path, "", 1, $dateTime, 1, $dateTime); echo '1'; } else { echo 'Invalid file type.'; } }
} if ($mode != 'w' and $mode != 'h' and $mode != 'a') { print "Error wrong mode - only h,w,a"; exit; } if ($size == '') { print "Error size is no INTEGER"; exit; } if ($size > $REX['ADDON']['max_size'][$mypage]) { print "Error size to big: max " . $REX['ADDON']['max_size'][$mypage] . " px"; exit; } include $REX['HTDOCS_PATH'] . "redaxo/include/addons/image_resize/class.thumbnail.inc.php"; // start thumb class $thumb = new thumbnail($imagepath); // check method if ($mode == "w") { $thumb->size_width($size); } if ($mode == "h") { $thumb->size_height($size); } if ($hmode != '') { $thumb->size_height($hmode); } if ($mode == "a") { $thumb->size_auto($size); } // jpeg quality $thumb->jpeg_quality($REX['ADDON']['jpeg_quality'][$mypage]);
<?php require_once '../classes/image.class.php'; $size = 150; $image = new thumbnail($_GET['src']); //$image->size_width($size); //Фіксована ширина //$image->size_height($size); //Фіксована висота //$image->size_auto($size); //Фіксована ширина або висота $image->size_crop($size); //Одинакові ширина та висота //$image->size_width_height($size,$size_h); //Довільна ширина та висота //$image->add_logo("watermark.png"); //Додати лого до картинки $image->show();
$row = $db->super_query("SELECT user_photo FROM `" . PREFIX . "_users` WHERE user_id = '{$user_info['user_id']}'"); $i_left = intval($_POST['i_left']); $i_top = intval($_POST['i_top']); $i_width = intval($_POST['i_width']); $i_height = intval($_POST['i_height']); if ($row['user_photo'] and $i_width >= 100 and $i_height >= 100 and $i_left >= 0 and $i_height >= 0) { include_once ENGINE_DIR . '/classes/images.php'; $tmb = new thumbnail(ROOT_DIR . "/uploads/users/{$user_info['user_id']}/{$row['user_photo']}"); $tmb->size_auto($i_width . "x" . $i_height, 0, "{$i_left}|{$i_top}"); $tmb->jpeg_quality(100); $tmb->save(ROOT_DIR . "/uploads/users/{$user_info['user_id']}/100_{$row['user_photo']}"); $tmb = new thumbnail(ROOT_DIR . "/uploads/users/{$user_info['user_id']}/100_{$row['user_photo']}"); $tmb->size_auto("100x100", 1); $tmb->jpeg_quality(100); $tmb->save(ROOT_DIR . "/uploads/users/{$user_info['user_id']}/100_{$row['user_photo']}"); $tmb = new thumbnail(ROOT_DIR . "/uploads/users/{$user_info['user_id']}/100_{$row['user_photo']}"); $tmb->size_auto("50x50"); $tmb->jpeg_quality(100); $tmb->save(ROOT_DIR . "/uploads/users/{$user_info['user_id']}/50_{$row['user_photo']}"); echo $user_info['user_id']; } else { echo 'err'; } exit; break; default: //Страница Редактирование основное $user_speedbar = $lang['editmyprofile'] . ' » ' . $lang['editmyprofile_genereal']; $tpl->load_template('editprofile.tpl'); $row = $db->super_query("SELECT user_name, user_lastname, user_sex, user_day, user_month, user_year, user_country, user_city, user_sp FROM `" . PREFIX . "_users` WHERE user_id = '{$user_info['user_id']}'"); $tpl->set('{name}', $row['user_name']);
echo "<SCRIPT language=\"javascript\">"; echo "alert('Erreur lors de la connexion א la base de donnיes. Vous serez ramenי א la page d'acceuil.');"; echo "top.location.href=\"/interPool/index.php\";"; echo "</SCRIPT>"; exit; } $id_saison = $sess->getSessVar('id_saison', '0'); $journalDir = "/export/home/www/interPool/images/journal/{$poolName}"; $thumbnailDir = $journalDir . "/thumbnails"; // tout d'un coup que le bouton send a יtי appuyי sans uploader de fichier... if ($_FILES['file2upload']['tmp_name'] == "") { echo "<SCRIPT language=\"javascript\">"; echo "window.location.href=\"/interPool/src/admin.php\";"; echo "</SCRIPT>"; exit; } // dיplacer le fichier uploadי dans le bon rיpertoire $uploadfile = $journalDir . "/" . basename($_FILES['file2upload']['name']); if (move_uploaded_file($_FILES['file2upload']['tmp_name'], $uploadfile)) { // crיation du thumbnail $thumbFile = $thumbnailDir . "/" . basename($_FILES['file2upload']['name']); $thumb = new thumbnail($uploadfile); $thumb->size_width(150); $thumb->size_height(200); $thumb->save($thumbFile); $query = "update accounts_detail set journal_vu='N'\n\t where id_pool = {$id_pool}\n\t and saison_id = {$id_saison}"; mysql_query($query, $pool->handle); } echo "<SCRIPT language=\"javascript\">"; echo "window.location.href=\"/interPool/src/admin.php\";"; echo "</SCRIPT>";
/** * Create a resized image of the file at $src_relative * */ static function CreateImage($src_relative, $width, $height) { global $dataDir; $src_path = $dataDir . '/data/_uploaded' . $src_relative; if (!file_exists($src_path)) { return false; } //compare to actual size includeFile('tool/Images.php'); $src_img = thumbnail::getSrcImg($src_path); if (!$src_img) { return false; } //Original Size $actual_w = imagesx($src_img); $actual_h = imagesy($src_img); if ($actual_w <= $width && $actual_h <= $height) { return false; } $info = gp_resized::ImageInfo($src_relative, $width, $height); if (!$info) { return false; } $dest_index = $info['index']; if (!$dest_index) { $dest_index = gp_resized::NewIndex(); } $dest_path = $dataDir . '/data/_resized/' . $dest_index . '/' . $info['name']; $exists_before = file_exists($dest_path); //make sure the folder exists if (!gpFiles::CheckDir(common::DirName($dest_path))) { return false; } //create new resized image if (!thumbnail::createImg($src_img, $dest_path, 0, 0, 0, 0, $width, $height, $actual_w, $actual_h)) { return false; } //not needed if the resized image is larger than the original if (filesize($dest_path) > filesize($src_path)) { if (!$exists_before) { unlink($dest_path); } return false; } $data['index'] = $dest_index; $data['w'] = $width; $data['h'] = $height; $data['img'] = $src_relative; return $data; }
if ($image_name != "") { $image_name = totranslit(stripslashes($img_name_arr[0])) . "." . $type; } if (strpos($image_name, "php") !== false) { die("Hacking attempt!"); } if (is_uploaded_file($image) and !$stop) { if (intval($user_group[$member_id['user_group']]['max_foto']) > 0) { if ($image_size < 100000) { $allowed_extensions = array("jpg", "png", "jpe", "jpeg", "gif"); if (in_array($type, $allowed_extensions) and $image_name) { include_once ENGINE_DIR . '/classes/thumb.class.php'; $res = @move_uploaded_file($image, ROOT_DIR . "/uploads/fotos/" . $row['user_id'] . "." . $type); if ($res) { @chmod(ROOT_DIR . "/uploads/fotos/" . $row['user_id'] . "." . $type, 0666); $thumb = new thumbnail(ROOT_DIR . "/uploads/fotos/" . $row['user_id'] . "." . $type); if ($thumb->size_auto($user_group[$member_id['user_group']]['max_foto'])) { $thumb->jpeg_quality($config['jpeg_quality']); $thumb->save(ROOT_DIR . "/uploads/fotos/foto_" . $row['user_id'] . "." . $type); } else { if ($type == "gif") { @rename(ROOT_DIR . "/uploads/fotos/" . $row['user_id'] . "." . $type, ROOT_DIR . "/uploads/fotos/foto_" . $row['user_id'] . "." . $type); } else { $thumb->jpeg_quality($config['jpeg_quality']); $thumb->save(ROOT_DIR . "/uploads/fotos/foto_" . $row['user_id'] . "." . $type); } } @chmod(ROOT_DIR . "/uploads/fotos/foto_" . $row['user_id'] . "." . $type, 0666); $foto_name = "foto_" . $row['user_id'] . "." . $type; $db->query("UPDATE " . USERPREFIX . "_users set foto='{$foto_name}' WHERE user_id = '{$id}'"); } else {
$row = $db->super_query("SELECT photo_name, album_id, user_id FROM `" . PREFIX . "_photos` WHERE id = '" . $id . "'"); if ($row['photo_name'] and $_POST['pos'] == 'left' or $_POST['pos'] == 'right' and $user_id == $row['user_id']) { $filename = ROOT_DIR . '/uploads/users/' . $user_id . '/albums/' . $row['album_id'] . '/' . $row['photo_name']; if ($_POST['pos'] == 'right') { $degrees = -90; } if ($_POST['pos'] == 'left') { $degrees = 90; } $source = imagecreatefromjpeg($filename); $rotate = imagerotate($source, $degrees, 0); imagejpeg($rotate, ROOT_DIR . '/uploads/users/' . $user_id . '/albums/' . $row['album_id'] . '/' . $row['photo_name'], 93); //Подключаем класс для фотографий include ENGINE_DIR . '/classes/images.php'; //Создание маленькой копии $tmb = new thumbnail(ROOT_DIR . '/uploads/users/' . $user_id . '/albums/' . $row['album_id'] . '/' . $row['photo_name']); $tmb->size_auto('140x100'); $tmb->jpeg_quality('100'); $tmb->save(ROOT_DIR . '/uploads/users/' . $user_id . '/albums/' . $row['album_id'] . '/c_' . $row['photo_name']); echo '/uploads/users/' . $user_id . '/albums/' . $row['album_id'] . '/' . $row['photo_name']; } break; default: //################### Просмотр фотографии ###################// NoAjaxQuery(); $user_id = intval($_POST['uid']); $photo_id = intval($_POST['pid']); $fuser = intval($_POST['fuser']); $section = $_POST['section']; //ЧС $CheckBlackList = CheckBlackList($user_id);
$image_name = substr(md5($server_time . md5($rImgUrl)), 0, 15); //Разришенные форматы $allowed_files = array('jpg', 'jpeg', 'jpe', 'png', 'gif'); //Загружаем картинку на сайт if (in_array(strtolower($img_format), $allowed_files) and preg_match("/http:\\/\\/(.*?)(.jpg|.png|.gif|.jpeg|.jpe)/i", $rImgUrl)) { //Директория загрузки фото $upload_dir = ROOT_DIR . '/uploads/attach/' . $user_id; //Если нет папки юзера, то создаём её if (!is_dir($upload_dir)) { @mkdir($upload_dir, 0777); @chmod($upload_dir, 0777); } //Подключаем класс для фотографий include ENGINE_DIR . '/classes/images.php'; if (@copy($rImgUrl, $upload_dir . '/' . $image_name . '.' . $img_format)) { $tmb = new thumbnail($upload_dir . '/' . $image_name . '.' . $img_format); $tmb->size_auto('100x80'); $tmb->jpeg_quality(100); $tmb->save($upload_dir . '/' . $image_name . '.' . $img_format); $attach_files = str_replace($attach_type[4], '/uploads/attach/' . $user_id . '/' . $image_name . '.' . $img_format, $attach_files); } } $cnt_attach_link++; } } } $attach_files = str_replace('vote|', 'hack|', $attach_files); $attach_files = str_replace(array('&#124;', '&raquo;', '&quot;'), array('|', '»', '"'), $attach_files); //Голосование $vote_title = ajax_utf8(textFilter($_POST['vote_title'], false, true)); $vote_answer_1 = ajax_utf8(textFilter($_POST['vote_answer_1'], false, true));
function register_user($social_user) { global $db, $config, $user_group, $popup, $js_popup, $lang; $add_time = time(); $_IP = get_ip(); if (intval($config['reg_group']) < 3) { $config['reg_group'] = 4; } if (function_exists('openssl_random_pseudo_bytes') && (version_compare(PHP_VERSION, '5.3.4') >= 0 || strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) { $stronghash = openssl_random_pseudo_bytes(15); } else { $stronghash = md5(uniqid(mt_rand(), TRUE)); } $salt = str_shuffle("abchefghjkmnpqrstuvwxyz0123456789" . sha1($stronghash . microtime())); $password = ''; $hash = ''; for ($i = 0; $i < 11; $i++) { $password .= $salt[GetRandInt(72)]; } $password = md5($password); if ($config['log_hash']) { for ($i = 0; $i < 9; $i++) { $hash .= $salt[GetRandInt(72)]; } } $social_user['nickname'] = $db->safesql($social_user['nickname']); $social_user['email'] = $db->safesql($social_user['email']); $social_user['name'] = $db->safesql($social_user['name']); $db->query("INSERT INTO " . USERPREFIX . "_users (name, password, email, reg_date, lastdate, user_group, info, signature, fullname, favorites, xfields, hash, logged_ip) VALUES ('{$social_user['nickname']}', '" . md5($password) . "', '{$social_user['email']}', '{$add_time}', '{$add_time}', '{$config['reg_group']}', '', '', '{$social_user['name']}', '', '', '{$hash}', '{$_IP}')"); $id = $db->insert_id(); $db->query("INSERT INTO " . USERPREFIX . "_social_login (sid, uid, password, provider, wait) VALUES ('{$social_user['sid']}', '{$id}', '{$password}', '{$social_user['provider']}', '0')"); set_cookie("dle_user_id", $id, 365); set_cookie("dle_password", $password, 365); if ($config['log_hash']) { set_cookie("dle_hash", $hash, 365); } $_SESSION['dle_user_id'] = $id; $_SESSION['dle_password'] = $password; $_SESSION['state'] = 0; if (intval($user_group[$config['reg_group']]['max_foto']) > 0 and $social_user['avatar']) { $n_array = explode(".", $social_user['avatar']); $type = end($n_array); $type = totranslit($type); $allowed_extensions = array("jpg", "png", "gif"); if (in_array($type, $allowed_extensions)) { include_once ENGINE_DIR . '/classes/thumb.class.php'; if (@copy($social_user['avatar'], ROOT_DIR . "/uploads/fotos/" . $id . "." . $type)) { @chmod(ROOT_DIR . "/uploads/fotos/" . $id . "." . $type, 0666); $thumb = new thumbnail(ROOT_DIR . "/uploads/fotos/" . $id . "." . $type); $thumb->size_auto($user_group[$config['reg_group']]['max_foto']); $thumb->jpeg_quality($config['jpeg_quality']); $thumb->save(ROOT_DIR . "/uploads/fotos/foto_" . $id . "." . $type); @unlink(ROOT_DIR . "/uploads/fotos/" . $id . "." . $type); $foto_name = "foto_" . $id . "." . $type; $db->query("UPDATE " . USERPREFIX . "_users SET foto='{$foto_name}' WHERE user_id='{$id}'"); } } } echo str_replace("{text}", $lang['social_login_ok'] . $js_popup, $popup); die; }
/** * Image-Resize Addon * * @author office[at]vscope[dot]at Wolfgang Hutteger * @author <a href="http://www.vscope.at">www.vscope.at</a> * * @author staab[at]public-4u[dot]de Markus Staab * @author <a href="http://www.public-4u.de">www.public-4u.de</a> * * @package redaxo4 * @version $Id: index.inc.php,v 1.21 2007/10/13 13:52:01 kills Exp $ */ include $REX['INCLUDE_PATH'] . '/layout/top.php'; if (isset($subpage) and $subpage == 'clear_cache') { $c = thumbnail::deleteCache(); $msg = 'Cache cleared - ' . $c . ' cachefiles removed'; } // Build Subnavigation $subpages = array(array('clear_cache', 'Resize Cache löschen')); rex_title('Image Resize', $subpages); if (isset($msg) and $msg != '') { echo '<p class="rex-warning"><span>' . $msg . '</span></p>'; } ?> <div class="rex-addon-output"> <h2>Instructions</h2> <div class="rex-addon-content"> <?php include dirname(__FILE__) . '/../help.inc.php'; ?>
$image_name = totranslit($_FILES['uploadfile']['name']); // оригинальное название для оприделения формата $image_rename = substr(md5($server_time + rand(1, 100000)), 0, 15); // имя фотографии $image_size = $_FILES['uploadfile']['size']; // размер файла $type = end(explode(".", $image_name)); // формат файла if (in_array($type, $allowed_files)) { if ($image_size < 5000000) { $res_type = '.' . $type; $uploaddir = ROOT_DIR . '/uploads/apps/' . $id . '/'; // Директория куда загружать if (move_uploaded_file($image_tmp, $uploaddir . $image_rename . $res_type)) { //Создание уменьшеной копии 100х100 $tmb = new thumbnail($uploaddir . $image_rename . $res_type); $tmb->size_auto('100x100'); $tmb->jpeg_quality(97); $tmb->save($uploaddir . '100_' . $image_rename . $res_type); $image_rename = $db->safesql($image_rename); $res_type = $db->safesql($res_type); $db->query("UPDATE `" . PREFIX . "_apps` SET `img`='{$image_rename}{$res_type}' WHERE `id`='{$id}'"); echo $config['home_url'] . 'uploads/apps/' . $id . '/100_' . $image_rename . $res_type; } else { echo 'bad'; } } else { echo 'big_size'; } } else { echo 'bad_format';
function SaveHeaderImage() { global $page, $dataDir, $dirPrefix, $langmessage; includeFile('tool/Images.php'); $page->ajaxReplace = array(); //source file $source_file_rel = $_REQUEST['file']; if (!empty($_REQUEST['src'])) { $source_file_rel = rawurldecode($_REQUEST['src']); if (!empty($dirPrefix)) { $len = strlen($dirPrefix); $source_file_rel = substr($source_file_rel, $len); } } $source_file_rel = '/' . ltrim($source_file_rel, '/'); $source_file_full = $dataDir . $source_file_rel; if (!file_exists($source_file_full)) { message($langmessage['OOPS'] . ' (Source file not found)'); return; } $src_img = thumbnail::getSrcImg($source_file_full); if (!$src_img) { message($langmessage['OOPS'] . ' (Couldn\'t create image [1])'); return; } //size and position variables $orig_w = $width = imagesx($src_img); $orig_h = $height = imagesy($src_img); $posx = $posy = 0; if (isset($_REQUEST['posx']) && is_numeric($_REQUEST['posx'])) { $posx = $_REQUEST['posx']; } if (isset($_REQUEST['posy']) && is_numeric($_REQUEST['posy'])) { $posy = $_REQUEST['posy']; } if (isset($_REQUEST['width']) && is_numeric($_REQUEST['width'])) { $width = $_REQUEST['width']; } if (isset($_REQUEST['height']) && is_numeric($_REQUEST['height'])) { $height = $_REQUEST['height']; } //check to see if the image needs to be resized if ($posx == 0 && $posy == 0 && $width == $orig_w && $height == $orig_h) { $this->SetImage($source_file_rel, $width, $height); return; } //destination file $name = basename($source_file_rel); $parts = explode('.', $name); $type = array_pop($parts); if (count($parts) > 1) { $time_part = array_pop($parts); if (!ctype_digit($time_part)) { $parts[] = $time_part; } } $name = implode('.', $parts); $time = time(); if (isset($_REQUEST['time']) && ctype_digit($_REQUEST['time'])) { $time = $_REQUEST['time']; } //$dest_img_rel = '/data/_uploaded/headers/'.$name.'.'.$time.'.'.$type; $dest_img_rel = '/data/_uploaded/headers/' . $name . '.' . $time . '.png'; $dest_img_full = $dataDir . $dest_img_rel; //make sure the folder exists if (!gpFiles::CheckDir(dirname($dest_img_full))) { message($langmessage['OOPS'] . ' (Couldn\'t create directory)'); return false; } if (!thumbnail::createImg($src_img, $dest_img_full, $posx, $posy, 0, 0, $orig_w, $orig_h, $orig_w, $orig_h, $width, $height)) { message($langmessage['OOPS'] . ' (Couldn\'t create image [2])'); return; } if ($this->SetImage($dest_img_rel, $width, $height)) { includeFile('admin/admin_uploaded.php'); admin_uploaded::CreateThumbnail($dest_img_full); } }
// формат файла //Проверям если, формат верный то пропускаем if (in_array(strtolower($type), $allowed_files)) { $config['max_photo_size'] = $config['max_photo_size'] * 1000; if ($image_size < $config['max_photo_size']) { $res_type = strtolower('.' . $type); if (move_uploaded_file($image_tmp, $album_dir . $image_rename . $res_type)) { //Подключаем класс для фотографий include ENGINE_DIR . '/classes/images.php'; //Создание оригинала $tmb = new thumbnail($album_dir . $image_rename . $res_type); $tmb->size_auto('770'); $tmb->jpeg_quality('85'); $tmb->save($album_dir . $image_rename . $res_type); //Создание маленькой копии $tmb = new thumbnail($album_dir . $image_rename . $res_type); $tmb->size_auto('140x100'); $tmb->jpeg_quality('90'); $tmb->save($album_dir . 'c_' . $image_rename . $res_type); $date = date('Y-m-d H:i:s', $server_time); //Генерируем position фотки для "обзо фотографий" $position_all = $_SESSION['position_all']; if ($position_all) { $position_all = $position_all + 1; $_SESSION['position_all'] = $position_all; } else { $position_all = 100000; $_SESSION['position_all'] = $position_all; } //Вставляем фотографию $db->query("INSERT INTO `" . PREFIX . "_photos` (album_id, photo_name, user_id, date, position) VALUES ('{$aid}', '{$image_rename}{$res_type}', '{$user_id}', '{$date}', '{$position_all}')");
include "classes/function.viscacha_frontend.php"; $zeitmessung1 = t1(); $slog = new slog(); $my = $slog->logged(); $lang->init($my->language); $tpl = new tpl(); if ($config['tpcallow'] == 0 && $_GET['action'] == "thumbnail") { include 'classes/graphic/class.thumbnail.php'; $thumb = new thumbnail(); $thumb->create_error('#0 ' . $lang->phrase('thumb_error')); } elseif ($config['tpcallow'] == 0) { error($lang->phrase('upload_switched_off')); } if ($_GET['action'] == "thumbnail") { include 'classes/graphic/class.thumbnail.php'; $thumb = new thumbnail(); if (!$_GET['id']) { $thumb->create_error('#1 ' . $lang->phrase('thumb_error')); } else { $result = $db->query(' SELECT u.id, u.file, t.board FROM ' . $db->pre . 'uploads AS u LEFT JOIN ' . $db->pre . 'topics AS t ON t.id = u.tid WHERE u.id = ' . $_GET['id'], __LINE__, __FILE__); $row = $db->fetch_assoc($result); $my->p = $slog->Permissions($row['board']); $uppath = 'uploads/topics/' . $row['file']; if ($db->num_rows($result) != 1) { $thumb->create_error('#2 ' . $lang->phrase('thumb_error')); } if ($my->p['forum'] == 0 || $my->p['downloadfiles'] == 0) { $thumb->create_error('#3 ' . $lang->phrase('thumb_error'));
function image_upload_process_handler() { global $db, $smarty, $main_smarty, $linkres; include_once 'image_upload_settings.php'; $module_error = false; // Debug Info image_upload_printdebug("START: image_upload_process_handler."); // Get the image real name, temp name, submission ID $imageFilename = $_FILES[module_imageupload_filename_field]['name']; $sourceFile = $_FILES[module_imageupload_filename_field]['tmp_name']; if ($sourceFile != "") { if (isset($_POST['id'])) { $linkID = strip_tags($_POST['id']); } else { $module_error = true; $module_errors[] = "- Submission entry id not found."; } // Get new names $destFile = module_imageupload_fullsize_prefix . $linkID; $destPath = module_imageupload_basedir . module_imageupload_imagedir; // Get image dimensions $thisImage = getimagesize($sourceFile); $thisImageFileSize = filesize($sourceFile); $thisImageWidth = $thisImage[0]; $thisImageHeight = $thisImage[1]; $thisImageMimeType = $thisImage['mime']; // Debug Info image_upload_printdebug("Original image filename = " . $imageFilename); image_upload_printdebug("Temp image filename = " . $sourceFile); image_upload_printdebug("Link ID = " . $linkID); image_upload_printdebug("Raw File size = " . $thisImageFileSize); image_upload_printdebug("Formatted File size = " . formatbytes($thisImageFileSize)); image_upload_printdebug("Max allowed file size = " . module_imageupload_upload_maxsize * 1000 * 1000); image_upload_printdebug("Max allowed image x height = " . module_imageupload_upload_maxwidth . "x" . module_imageupload_upload_maxheight); image_upload_printdebug("Destination file = " . $destFile); image_upload_printdebug("Destination path = " . $destPath); image_upload_printdebug("Image data = " . $thisImageWidth . "x" . $thisImageHeight . " (" . $thisImageMimeType . ")"); // Test image against max width / height constraints if ($thisImageWidth > module_imageupload_upload_maxwidth || $thisImageHeight > module_imageupload_upload_maxheight) { $module_error = true; $module_errors[] = "- This image exceeds the " . module_imageupload_upload_maxwidth . "x" . module_imageupload_upload_maxheight . " (width x height) maximum."; } // Test image against max file size constraints if ($thisImageFileSize > module_imageupload_upload_maxsize * 1000 * 1000) { $module_error = true; $module_errors[] = "- This image exceeds the allowed file size of " . module_imageupload_upload_maxsize . "MB"; } // Determine Mime Type if (!$module_error) { switch ($thisImageMimeType) { case "image/jpeg": $module_error = false; $tempExt = ".jpg"; break; case "image/gif": $module_error = false; $tempExt = ".gif"; break; case "image/png": $module_error = false; $tempExt = ".png"; break; case "image/wbmp": $module_error = false; $tempExt = ".wbmp"; break; default: if ($imageAttached) { $module_error = true; $module_errors[] = "- Unknown image type. Only JPG, PNG, GIF and WMBP allowed."; } } } // Process file, remove re-posts, and convert if necessary if (!$module_error) { if (file_exists($destPath . $destFile . $tempExt)) { @unlink($destPath . $destFile . $tempExt); } // Convert image if not JPG switch ($thisImageMimeType) { case "image/jpeg": // No conversion needed // Debug Info image_upload_printdebug("No image conversion necessary."); if (!move_uploaded_file($sourceFile, $destPath . $destFile . $tempExt)) { $module_error = true; $module_errors[] = "- Error processing image."; // Delete original @unlink($destPath . $destFile . $tempExt); } break; case "image/gif": case "image/png": case "image/wbmp": // Include image converter class @(include_once 'plugins/class.imageconverter.inc.php'); // Debug Info image_upload_printdebug("Conversion of image file beginning..."); if (move_uploaded_file($sourceFile, $destPath . $destFile . $tempExt)) { $tempDest = $destPath . $destFile . $tempExt; // Convert image to JPG $img = new ImageConverter($tempDest, "jpg", $destPath); @unlink($tempDest); // Get converted image dimensions $destImage = getimagesize($destPath . $destFile . ".jpg"); $destImageWidth = $destImage[0]; $destImageHeight = $destImage[1]; $destImageMimeType = $destImage['mime']; @unlink($tempDest); // Debug Info image_upload_printdebug("Dest Filename = " . $destPath . $destFile . ".jpg"); image_upload_printdebug("Dest image width = " . $destImageWidth); image_upload_printdebug("Dest image height = " . $destImageHeight); image_upload_printdebug("Dest image mime type = " . $destImageMimeType); } else { // Debug Info image_upload_printdebug("Unable to move source file to dest for conversion. Deleting source file."); $module_error = true; $module_error_message = module_imageupload_errorcode_2; // Delete original @unlink($sourceFile); } break; } } // Check if we need to resize image to meet fullsize width or height setting if (!$module_error) { // Debug Info image_upload_printdebug("Checking image dimensions for possible resizing."); $destFile .= ".jpg"; # Check to see if the image needs to be rescaled. switch (module_imageupload_fullsize_maxtoggle) { case "w": if ($thisImageWidth > module_imageupload_fullsize_width) { // Include image resize functions include_once 'plugins/class.thumbnail.inc.php'; // Debug Info image_upload_printdebug("Image is wider than setting, attempting to reduce."); image_upload_printdebug("Dest Path = " . $destPath); image_upload_printdebug("Dest File = " . $destFile); $convertImage = new thumbnail($destPath . $destFile); $convertImage->size_auto(module_imageupload_fullsize_width); $convertImage->jpeg_quality(module_imageupload_jpg_quality); $convertImage->save($destPath . $destFile, module_imageupload_gdversion); $destImage = getimagesize($destPath . $destFile); $destImageWidth = $destImage[0]; $destImageHeight = $destImage[1]; // Debug Info image_upload_printdebug("Converted image is " . $destImageWidth . "x" . $destImageHeight); } break; case "h": if ($thisImageHeight > module_imageupload_fullsize_height) { // Include image resize functions include_once 'plugins/class.thumbnail.inc.php'; // Debug Info image_upload_printdebug("Image is taller than setting, attempting to reduce."); image_upload_printdebug("Dest Path = " . $destPath); image_upload_printdebug("Dest File = " . $destFile); $convertImage = new thumbnail($destPath . $destFile); $convertImage->size_auto(module_imageupload_fullsize_height); $convertImage->jpeg_quality(module_imageupload_jpg_quality); $convertImage->save($destPath . $destFile, module_imageupload_gdversion); getimagesize($destPath . $destFile); $destImageWidth = $destImage[0]; $destImageHeight = $destImage[1]; // Debug Info image_upload_printdebug("Converted image is " . $destImageWidth . "x" . $destImageHeight); } break; } } if (!$module_error) { // Debug Info image_upload_printdebug("Updating database with image filename."); // Update database $db->query("UPDATE " . table_links . " set " . module_imageupload_filename_field . "='{$destFile}' WHERE link_id='{$linkID}'"); if (module_imageupload_customcaptions) { // Debug Info image_upload_printdebug("Using custom image caption."); $imageCaption = $_POST[module_imageupload_caption_field]; if ($imageCaption != "") { // Debug Info image_upload_printdebug("Custom image caption: " . $imageCaption); $imageCaption = strip_tags($imageCaption); $imageCaption = addslashes($imageCaption); // Debug Info image_upload_printdebug('Updating database with custom image caption'); // Update database $db->query("UPDATE " . table_links . " set " . module_imageupload_caption_field . "='" . $imageCaption . "' WHERE link_id='{$linkID}'"); } } // Debug Info image_upload_printdebug("Database updated."); } else { @unlink($sourceFile); @unlink($destPath . $destFile . ".jpg"); // Output error messages image_upload_printerrors($module_errors); } } // Debug Info image_upload_printdebug("END: image_upload_process_handler."); }