function editdata() { require '../include/config.php'; $id = $_POST['id']; $name = $_POST['txtname']; $code = $_POST['txtcode']; $posision = $_POST['txtposision']; $line = $_POST['txtline']; $link = $_POST['txtlink']; $datestart = $_POST['datestart']; $dateend = $_POST['dateend']; $status = $_POST['status']; $file = $_FILES['fle']['name']; $file_tmp = $_FILES['fle']['tmp_name']; $update = "UPDATE banner_ads SET baname = '{$name}',\r\n \t\t\t\t\t\t\t\t bacode = '{$code}',\r\n \t\t\t\t\t\t\t\t baposition = '{$posision}',\r\n \t\t\t\t\t\t\t\t baline = '{$line}',\r\n \t\t\t\t\t\t\t\t balink = '{$link}',\r\n \t\t\t\t\t\t\t\t datestart = '{$datestart}',\r\n \t\t\t\t\t\t\t\t dateend = '{$dateend}'"; if ($file != "") { //check_size($file_tmp); $imgname = md5($file); $dot = substr($file, -3, 3); $pic_name = md5($id) . '_' . $imgname . "-" . time() . "." . $dot; resize($file_tmp, $pic_name, 300, "../../images/banner/ads/tmp/"); copy($file_tmp, "../../images/banner/ads/{$pic_name}"); $update .= ",baimg = '{$pic_name}'"; } $update .= ",status = '{$status}' where baid = '{$id}' "; $dbCon->query($update) or die($dbCon->error); $dbCon->close(); //echo $update; header("Location: ../banner/bannerads"); exit; }
function validateAndSave($file) { $result = array(); if (!preg_match('/^image\\//', $file['type']) || !preg_match('/\\.(jpe?g|JPE?G|GIF|gif|PNG|png)$/', $file['name']) || getimagesize($file['tmp_name']) === FALSE) { //then there is an error $result['status'] = 'ERR'; $result['message'] = 'Неверный формат файла!'; } else { if ($file['size'] > 3145728) { //if size is larger than what we expect $result['status'] = 'ERR'; $result['message'] = 'Пожалуйста, выберите файл меньшего размера!'; } else { if ($file['error'] != 0 || !is_uploaded_file($file['tmp_name'])) { //if there is an unknown error or temporary uploaded file is not what we thought it was $result['status'] = 'ERR'; $result['message'] = 'Неизвестная ошибка!'; } else { //save file inside current directory using a safer version of its name $info = @getimagesize($file['tmp_name']); $new_mame = uniqid() . "." . basename($info['mime']); $save_path = 'upload/img_gallery/' . preg_replace('/[^\\w\\.\\- ]/', '', $new_mame); //thumbnail name is like filename-thumb.jpg $thumb_path = preg_replace('/\\.(.+)$/', '', $save_path) . '-thumb.jpg'; if (!move_uploaded_file($file['tmp_name'], $save_path) or !resize($save_path, $thumb_path, 150)) { $result['status'] = 'ERR'; $result['message'] = 'Невозможно сохранить файл!'; } else { require "templates/db_con.php"; // require("templates/sait_con.php"); //---------------------- пишем в базу //print_r($_POST); $thumb_name = preg_replace('/\\.(.+)$/', '', $new_mame) . '-thumb.jpg'; $STH = $dbh->prepare('INSERT INTO `gallery_detail` ( `full_name`, `short_name`, `gallery_id`, `user_id`, `active`) VALUES ( "' . $new_mame . '", "' . $thumb_name . '", "' . $_POST['form-fid'] . '", "' . $_SESSION['user_id'] . '", "Y");'); $STH->execute(); $id = $dbh->lastInsertId(); //------------------------ //everything seems OK $result['status'] = 'OK'; $result['message'] = 'Аватар успешно изменен!'; //include new thumbnails `url` in our result and send to browser $result['url'] = $thumb_path; $result['url_full'] = $save_path; $result['id'] = $id; } } } } return $result; }
function resize(&$new_width, &$new_height, $original_width, $original_height) { $xscale = $new_width / $original_width; $yscale = $new_height / $original_height; if ($new_width <= $original_width and $new_height <= $original_height and $xscale == $yscale) { return; } if ($new_width and !$new_height) { return $new_height = $new_width / $original_width * $original_height; } elseif (!$new_width and $new_height) { return $new_width = $new_height / $original_height * $original_width; } if ($xscale != $yscale) { if ($original_width * $yscale <= $new_width) { $new_width = $original_width * $yscale; } if ($original_height * $xscale <= $new_height) { $new_height = $original_height * $xscale; } } $xscale = $new_width / $original_width; $yscale = $new_height / $original_height; if (round($xscale, 3) == round($yscale, 3)) { return; } resize($new_width, $new_height, $original_width, $original_height); }
function doImage($source, $width, $height, $timestamp = true, $name) { $origImage = getImage($source, $width, $height); if (is_null($origImage)) { die("Rendering Error"); } $image = resize($origImage, $width, $height); $thumb = resize($origImage, 100, 75); if ($timestamp) { $image = addTimeStamp($image); } $compression = 75; $filepath = "screenshots/"; $filename = $filepath . $name . "_" . time() . ".jpg"; $filename_thumb = $filepath . $name . "_" . time() . "_thumb.jpg"; //main image imagejpeg($image, $filename, $compression); chmod($filename, 0600); imagedestroy($image); //thumb image imagejpeg($thumb, $filename_thumb, $compression); chmod($filename_thumb, 0600); imagedestroy($thumb); echo "OK"; }
public function create() { $imgs = []; $path = 'uploads/img/' . date('Y/m/d/'); if (!is_dir($path)) { mkdir($path, 0777, true); } foreach ($_POST['imgurls'] as $imgurl) { $file = parse_url($imgurl)['path']; $file = substr($file, 1); $md5 = md5_file($file); $ext = '.' . substr($file, -3); $small = $path . $md5 . '_s' . $ext; $big = $path . $md5 . $ext; if (!file_exists($big)) { copy($file, $big); } if (!file_exists($small)) { resize($file, 0, 170, $small); } $imgs[] = ['small' => $small, 'big' => $big]; } $photo = new Photo(); $photo->userid = $this->user['userid']; $photo->saying = $_POST['saying']; $photo->subject_id = $_POST['movie_id']; $photo->imgs = $imgs; $photo->save(); return []; }
/** * Сачати картинку за вказану дату * @param $timestamp * */ function getOneMap($timestamp) { ini_set("allow_url_fopen", 1); $dYear = date('Y', $timestamp); $dMonth = date('m', $timestamp); $dDay = date('d', $timestamp); // http://mediarnbo.org/wp-content/uploads/2014/08/13-08.jpg // http://mediarnbo.org/wp-content/uploads/2014/08/15-08.jpg $url = SOURCE_LINK . $dYear . '/' . $dMonth . '/'; $imgName = $dDay . '-' . $dMonth . '.jpg'; $handle = fopen(ERRORS_FILE, 'w'); // file to write errors $source = getFilenameOnDiskBig($timestamp); $target = getFilenameOnDiskSml($timestamp); try { copy($url . $imgName, PATH_SAVE . $source); } catch (Exception $e) { $s = "Not exist: " . $url . $imgName . "\n"; fwrite($handle, $s); } // wln($url.$imgName); sleep(1); if (file_exists(PATH_SAVE . $source)) { resize(SML_IMG_WIDTH, PATH_SAVE . $target, PATH_SAVE . $source); echo '<img src="' . HOST . 'img/photos/' . $target . '"/>'; } else { print_r("Not exist: " . $url . $imgName . "\n"); } fclose($handle); }
function editdata() { require '../include/config.php'; $id = $_POST['id']; $name = $_POST['txtname']; $detail = $_POST['txtdetail']; $userid = $_POST['userid']; $status = $_POST['status']; $file = $_FILES['fle']['name']; $file_tmp = $_FILES['fle']['tmp_name']; $update = "UPDATE post SET postname = '{$name}',\r\n \t\t\t\t\t\t\tpostdetail = '{$detail}',\r\n \t\t\t\t\t\t\tuser_id = '{$userid}',\r\n \t\t\t\t\t\t\tstatus = '{$status}'"; if ($file != "") { //check_size($file_tmp); $imgname = md5($file); $dot = substr($file, -3, 3); $pic_name = $imgname . "-" . time() . "." . $dot; resize($file_tmp, $pic_name, 250, "../../images/post/tmp/"); copy($file_tmp, "../../images/post/{$pic_name}"); $update .= ",postimg = '{$pic_name}'"; } $update .= " where postid = '{$id}' "; $dbCon->query($update) or die($dbCon->error); $dbCon->close(); //echo $update; header("Location: ../posts"); exit; }
function image_upload_file($target_path, $thumbnail_path, $name, $file_basename, $type, $size, $tmp_name, $isMakeThum) { //$file_basename = substr($name, 0, strripos($name, '.')); // get file extention $file_ext = strtolower(substr($name, strripos($name, '.'))); // get file name $allowed_file_types = array('.jpg', '.png', '.rtf', '.pdf'); write_log("Upload: " . $name, UPLOAD_LOG); write_log("Type: " . $type, UPLOAD_LOG); write_log("Size:" . $size / 1024 . " Kb", UPLOAD_LOG); write_log("Stored in: " . $tmp_name, UPLOAD_LOG); write_log("file_ext : " . $file_ext, UPLOAD_LOG); //if (in_array($file_ext,$allowed_file_types) && ($size < 20000000)) if (in_array($file_ext, $allowed_file_types) && $size < MAX_FILE_SIZE) { // Rename file //$target_path = "uploads/"; $newfilename = md5($file_basename) . $file_ext; write_log("newfilename : " . $newfilename); if (file_exists($target_path . $newfilename)) { // file already exists error $message = "You have already uploaded this file."; $ret = array('file' => $newfilename, 'status' => UploadMessage::ERR_EXIST_FILE, 'message' => $message); write_log($message, UPLOAD_LOG); } else { move_uploaded_file($tmp_name, $target_path . $newfilename); $ret = UploadMessage::UPLOAD_OK; $message = "File uploaded successfully."; $ret = array('file' => $newfilename, 'status' => UploadMessage::UPLOAD_OK, 'message' => $message); write_log($message, UPLOAD_LOG); write_log($ret, UPLOAD_LOG); //make thumbnail image if ($isMakeThum) { $ret2 = resize($target_path . $newfilename, $thumbnail_path . $newfilename, 100, 100); } } } elseif (empty($file_basename)) { // file selection error $message = "Please select a file to upload."; $ret = array('file' => $newfilename, 'status' => UploadMessage::ERR_EMPTY_FILE_NAME, 'message' => $message); write_log("newfilename : " . $newfilename, UPLOAD_LOG); } elseif ($size > MAX_FILE_SIZE) { // file size error $message = "The file you are trying to upload is too large."; $ret = array('file' => $newfilename, 'status' => UploadMessage::ERR_LARGE_FILE, 'message' => $message); write_log($message, UPLOAD_LOG); } else { // file type error $message = "Only these file typs are allowed for upload: " . implode(', ', $allowed_file_types); write_log($message, UPLOAD_LOG); $ret = array('file' => $newfilename, 'status' => UploadMessage::ERR_FILE_TYPE, 'message' => $message); unlink($tmp_name); } return $ret; }
function validateAndSave($file) { $result = array(); if (!preg_match('/^image\\//', $file['type']) || !preg_match('/\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$/', $file['name']) || getimagesize($file['tmp_name']) === FALSE) { //then there is an error $result['status'] = 'ERR'; $result['message'] = 'Неверный формат файла!'; } else { if ($file['size'] > 3145728) { //if size is larger than what we expect $result['status'] = 'ERR'; $result['message'] = 'Пожалуйста, выберите файл меньшего размера!'; } else { if ($file['error'] != 0 || !is_uploaded_file($file['tmp_name'])) { //if there is an unknown error or temporary uploaded file is not what we thought it was $result['status'] = 'ERR'; $result['message'] = 'Неизвестная ошибка!'; } else { //save file inside current directory using a safer version of its name $info = @getimagesize($file['tmp_name']); $new_mame = uniqid() . "." . basename($info['mime']); $save_path = 'upload/img_dish/' . preg_replace('/[^\\w\\.\\- ]/', '', $new_mame); //thumbnail name is like filename-thumb.jpg $thumb_path = preg_replace('/\\.(.+)$/', '', $save_path) . '-thumb.jpg'; if (!move_uploaded_file($file['tmp_name'], $save_path) or !resize($save_path, $thumb_path, 220)) { $result['status'] = 'ERR'; $result['message'] = 'Не удалось сохранить файл!'; } else { //everything seems OK $result['status'] = 'OK'; $result['message'] = 'Файл изменен!'; //require("templates/db_con.php"); //require("templates/sait_con.php"); //---------------------- пишем в базу //print_r($_POST['form-fid']); $thumb_name = preg_replace('/\\.(.+)$/', '', $new_mame) . '-thumb.jpg'; //$STH=$dbh->prepare('UPDATE `services_products` set `photo`="'.$new_mame.'", `photo_thumb`="'.$thumb_name.'" WHERE id="'.$_POST['form-fid'].'";'); //$STH->execute(); $result['url'] = $thumb_path; $result['photo'] = $new_mame; $result['photo_thumb'] = $thumb_name; } } } } return $result; }
function resize(&$crop_x, &$crop_y, &$new_width, &$new_height, $original_width, $original_height) { $xscale = $new_width / $original_width; $yscale = $new_height / $original_height; if ($new_width <= $original_width and $new_height <= $original_height and $xscale == $yscale) { return; } if (isset($_GET['square'])) { if ($new_width === 0) { $new_width = $new_height; } if ($new_height === 0) { $new_height = $new_width; } if ($original_width > $original_height) { # portrait $crop_x = ceil(($original_width - $original_height) / 2); } else { if ($original_height > $original_width) { # landscape $crop_y = ceil(($original_height - $original_width) / 2); } } return; } else { if ($new_width and !$new_height) { return $new_height = $new_width / $original_width * $original_height; } elseif (!$new_width and $new_height) { return $new_width = $new_height / $original_height * $original_width; } if ($xscale != $yscale) { if ($original_width * $yscale <= $new_width) { $new_width = $original_width * $yscale; } if ($original_height * $xscale <= $new_height) { $new_height = $original_height * $xscale; } } $xscale = $new_width / $original_width; $yscale = $new_height / $original_height; if (round($xscale, 3) == round($yscale, 3)) { return; } resize($crop_x, $crop_y, $new_width, $new_height, $original_width, $original_height); } }
function doImage($source, $width, $height, $timestamp = true) { $image = getImage($source, $width, $height); if (is_null($image)) { die("Rendering Error"); } //no cache header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past header('Content-Type: image/jpeg'); $image = resize($image, $width, $height); if ($timestamp) { $image = addTimeStamp($image); } imagejpeg($image); imagedestroy($image); }
function compare($file1, $file2) { global $config; $file1 = escapeshellcmd($config['destination'] . $file1); $file2 = escapeshellcmd($config['destination'] . $file2); $image1 = tempnam($config['tmp_dir'], "") . ".ppm"; $image2 = tempnam($config['tmp_dir'], "") . ".ppm"; $diff = tempnam($config['tmp_dir'], "") . ".ppm"; $cmd = "/home/xrosecky/projects/compare/compare -1 '{$image1}' -2 '{$image2}' '{$file1}' '{$file2}' '{$diff}'"; $result = exec_help("compare '{$file1}' '{$file2}'", $cmd); $xml = simplexml_load_string($result); $img1 = escapeshellcmd($config['destination'] . $xml->{"image1"}->{"checksum"} . ".png"); $img2 = escapeshellcmd($config['destination'] . $xml->{"image2"}->{"checksum"} . ".png"); $img_diff = escapeshellcmd($config['destination'] . $xml->{"image1"}->{"checksum"} . "_" . $xml->{"image2"}->{"checksum"} . ".png"); resize($image1, $img1); resize($image2, $img2); resize($diff, $img_diff); jhove($xml->{"image1"}, $file1); jhove($xml->{"image2"}, $file2); return $xml; }
function validateAndSave($file) { $result = array(); if (!preg_match('/^image\\//', $file['type']) || !preg_match('/\\.(jpe?g|gif|png)$/', $file['name']) || getimagesize($file['tmp_name']) === FALSE) { //then there is an error $result['status'] = 'ERR'; $result['message'] = 'Invalid file format!'; } else { if ($file['size'] > 110000) { //if size is larger than what we expect $result['status'] = 'ERR'; $result['message'] = 'Please choose a smaller file!'; } else { if ($file['error'] != 0 || !is_uploaded_file($file['tmp_name'])) { //if there is an unknown error or temporary uploaded file is not what we thought it was $result['status'] = 'ERR'; $result['message'] = 'Unspecified error!'; } else { //save file inside current directory using a safer version of its name $save_path = preg_replace('/[^\\w\\.\\- ]/', '', $file['name']); //thumbnail name is like filename-thumb.jpg $thumb_path = preg_replace('/\\.(.+)$/', '', $save_path) . '-thumb.jpg'; if (!move_uploaded_file($file['tmp_name'], $save_path) or !resize($save_path, $thumb_path, 150)) { $result['status'] = 'ERR'; $result['message'] = 'Unable to save file!'; } else { //everything seems OK $result['status'] = 'OK'; $result['message'] = 'Avatar changed successfully!'; //include new thumbnails `url` in our result and send to browser $result['url'] = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']) . '/' . $thumb_path; } } } } return $result; }
function uploadimageAction() { if (POST) { if (!empty($_FILES["logo"]["name"])) { $v = explode(".", $_FILES["logo"]["name"]); $base = "public/images/user/"; $logo = encode(rand(0, time())) . "." . $v[count($v) - 1]; if (is_file($base . $this->session->user["image"]) && $this->session->user["image"] != 'boy.gif' && $this->session->user["image"] != 'girl.gif') { unlink($base . $this->session->user["image"]); unlink($base . "icon/" . $this->session->user["image"]); unlink($base . "thumb/" . $this->session->user["image"]); } resize($_FILES['logo']['tmp_name'], $base . "thumb/" . $logo, 150, 150); resize($_FILES['logo']['tmp_name'], $base . "icon/" . $logo, 50, 50); move_uploaded_file($_FILES['logo']['tmp_name'], $base . $logo); $this->db->update("user", array("image" => $logo), "id=" . $this->session->user["id"]); $this->session->error = array("Your profile pic changed.", 10, "yeppe"); $this->view->user["image"] = $this->session->user["image"] = $logo; } else { $this->view->error = array("Invalid image format uploaded", 10); } goBack(); } }
function editdata() { require '../include/config.php'; $id = $_POST['id']; $name = $_POST['txtname']; $file = $_FILES['fle']['name']; $file_tmp = $_FILES['fle']['tmp_name']; $update = "UPDATE catalog SET catname = '{$name}'"; if ($file != "") { check_size($file_tmp); $imgname = md5($file); $dot = substr($file, -3, 3); $pic_name = $imgname . "-" . time() . "." . $dot; resize($file_tmp, $pic_name, 150, "../../images/catproduct/tmp/"); copy($file_tmp, "../../images/catproduct/{$pic_name}"); $update .= ",catimg = '{$pic_name}'"; } $update .= "where catid = '{$id}' "; $dbCon->query($update) or die($dbCon->error); $dbCon->close(); //echo $update; header("Location: ../products/cat"); exit; }
/* }}} --- */ ob_start(); if ($mime_type == "image/jpeg") { imagejpeg($image_p, null, 100); } else { if ($mime_type == "image/png") { imagepng($image_p); } else { if ($mime_type == "image/gif") { imagegif($image_p); } } } $contents = ob_get_contents(); /* cache --- {{{ */ if (CACHE_DIR && is_dir(CACHE_DIR) && is_writable(CACHE_DIR)) { $f = fopen($cache_file, 'w'); fwrite($f, $contents); fclose($f); } /* }}} --- */ imagedestroy($image_p); } $file = $_SERVER['REDIRECT_URL']; $file = substr($file, 0, strlen($file) - 6); $width = isset($_GET['width']) ? $_GET['width'] : null; $height = isset($_GET['height']) ? $_GET['height'] : null; $m = isset($_GET['m']) ? true : false; $wp = isset($_GET['wp']) ? true : false; resize($file, $width, $height, $m, $wp);
} $image = getExtension($newname); //имя файла оставляем прежним //осторожно! если файл с таким именем существует, то он будет перезаписан загружаемым if ($info[0] < $newwidth) { // если ширина загужаемого изображения //меньше заданной в переменной, просто сохраняем файл if (move_uploaded_file($_FILES['image']['tmp_name'], $newname)) { $messages[] = "Файл успешно загружен. "; } else { $messages[] = "Ошибка загрузки файла!"; } } else { // а если больше, то ресайзим // функцию ресайза мы напишем дальше if (resize($tmp, $newwidth, $newname)) { $messages[] = "Рисунок был успешно загружен и преобразован"; } else { $messages[] = "Произошла ошибка при загрузке файла"; } } } else { $messages[] = "Ошибка! Попытка загрузить файл недопустимого формата."; } } else { $messages[] = "Файл не был загружен."; } } if ($image == '') { $image = "no_image.png"; }
function compare($file1, $file2) { global $config; $file1 = escapeshellcmd($config['destination'] . $file1); if ($file2 != "null") { $file2 = escapeshellcmd($config['destination'] . $file2); } $image1 = tempnam($config['tmp_dir'], "") . ".ppm"; $image2 = tempnam($config['tmp_dir'], "") . ".ppm"; $diff = tempnam($config['tmp_dir'], "") . ".ppm"; $compare_bin = $config['compare_bin']; $cmd = "{$compare_bin} -1 '{$image1}' -2 '{$image2}' '{$file1}' '{$file2}' '{$diff}'"; $result = exec_help("compare '{$file1}' '{$file2}'", $cmd); if ($result == "") { return false; } $xml = simplexml_load_string($result); $img1 = escapeshellcmd($config['destination'] . $xml->{"image1"}->{"checksum"} . ".png"); $img2 = escapeshellcmd($config['destination'] . $xml->{"image2"}->{"checksum"} . ".png"); $img_diff = escapeshellcmd($config['destination'] . $xml->{"image1"}->{"checksum"} . "_" . $xml->{"image2"}->{"checksum"} . ".png"); $img1_big = escapeshellcmd($config['destination'] . $xml->{"image1"}->{"checksum"} . "_big.png"); $img2_big = escapeshellcmd($config['destination'] . $xml->{"image2"}->{"checksum"} . "_big.png"); $img_diff_big = escapeshellcmd($config['destination'] . $xml->{"image1"}->{"checksum"} . "_" . $xml->{"image2"}->{"checksum"} . "_big.png"); if (!file_exists($img1)) { resize($image1, $img1); resize_bigger($image1, $img1_big); unlink($image1); } if (!file_exists($img2)) { resize($image2, $img2); resize_bigger($image2, $img2_big); unlink($image2); } if (!file_exists($img_diff)) { resize($diff, $img_diff); resize_bigger($diff, $img_diff_big); unlink($diff); } //jhove($xml->{"image1"}, $file1); //jhove($xml->{"image2"}, $file2); return $xml; }
background-color:#fff; border-left: 1px solid #e1e1e1; border-top: 1px solid #F2F2F2; border-right: 1px solid #e1e1e1; border-bottom: 1px solid #D3D3D3; } div { display: inline; font-size: 10px } .label { text-transform: uppercase; color: #A9A9A9; } /*]]>*/ </style> <?php echo '<h2 align="center">' . JText::_('COM_DATSOGALLERY_ORDER_ID') . ': ' . $order_id . '</h2>'; if ($total != 0) { echo '<ul style="list-style:none">'; foreach ($images as $image) { $pic = resize($image->imgoriginalname, 170, 170, 1, '3:2', 0, $image->catid); echo '<li style="float:left;background-image:none;padding:10px;margin-right:0;margin-left:6px">'; echo '<p><img src="' . $pic . '" class="dgimg" title="' . $image->imgtitle . '" alt="' . $image->imgtitle . '" /></p>'; echo '<div><div class="label">' . JText::_('COM_DATSOGALLERY_CATEGORY') . ':</div> ' . $image->category . '</div><br />'; echo '<div><div class="label">' . JText::_('COM_DATSOGALLERY_TITLE') . ':</div> ' . $image->imgtitle . '</div><br />'; echo '<div><div class="label">' . JText::_('COM_DATSOGALLERY_PRICE') . ':</div> ' . $image->imgprice . ' ' . $ad_pp_currency . '</div>'; echo '</li>'; } echo '</ul>'; }
function check_and_move($filename) { global $config, $_POST; $info = getimagesize($config['working_dir'] . $filename); $final_filename = ''; switch ($info['mime']) { case 'image/gif': $ext = 'gif'; break; case 'image/pjpeg': $ext = 'jpg'; break; case 'image/jpeg': $ext = 'jpg'; break; case 'image/x-png': $ext = 'png'; break; case 'image/png': $ext = 'png'; break; case 'image/bmp': $ext = 'bmp'; break; case 'image/x-ms-bmp': $ext = 'bmp'; break; default: $ext = 'fail'; $info['mime'] = 'n/a'; break; } $stat = stat($config['working_dir'] . $filename); $partes = explode('.', $filename); $extension = strtolower($partes[count($partes) - 1]); if ($info['mime'] == 'n/a') { $local_error[] = "Ошибка: Неверный MIME-тип изображения, допускаются " . implode(', ', $config['mimes']) . ". Вы пытались залить " . $info['mime']; } elseif (!in_array($ext, $config['extensions'])) { $local_error[] = "Ошибка: Неверное расширение изображения, допускаются " . strtoupper(implode(', ', $config['extensions'])) . ". Вы пытались залить " . strtoupper($extension); } elseif ($stat['size'] > $config['max_size_byte']) { $local_error[] = "Ошибка: Превышен максимальный размер файла: {$config['max_size_mb']} МБ"; } elseif ($info['1'] > $config['max_height']) { $local_error[] = "Ошибка: Превышена максимальная высота изображения: {$config['max_height']} пикселей"; } elseif ($info['0'] > $config['max_width']) { $local_error[] = "Ошибка: Превышена максимальная ширина изображения: {$config['max_width']} пикселей"; } if (!isset($local_error)) { if ($ext == 'bmp') { include 'bmp.php'; $src = imagecreatefrombmp($config['working_dir'] . $filename); imagepng($src, $config['working_dir'] . $filename); imagedestroy($src); $ext = 'png'; $partes[count($partes) - 1] = $ext; $filenamepng = implode(".", $partes); if (!rename("{$config['working_dir']}{$filename}", "{$config['working_dir']}{$filenamepng}")) { $local_error[] = "Ошибка преобразования изображения"; } $filename = $filenamepng; unset($filenamepng); } $final_filename = random_string($config['random_str_quantity'], 'lower,numbers') . "." . $ext; $uploaded_file_path = strtolower($config['uploaddir'] . $config['current_path'] . '/' . $final_filename); if (isset($_POST['thumb']) and $_POST['thumb'] == "true") { //если пользователь не выставил значение(я) превьюшки if ($_POST['thumb_width'] or $_POST['thumb_height']) { preview($filename, $final_filename, $_POST['thumb_width'], $_POST['thumb_height'], $config['quality']); } else { $local_error[] = "Ошибка: Не указан размер превью"; unlink("{$config['working_dir']}{$filename}"); exit; } } //если установлено уменьшение if (isset($_POST['resize']) and $_POST['resize'] == 'true') { if ($_POST['width'] or $_POST['height']) { resize("{$config['working_dir']}{$filename}", $_POST['width'], $_POST['height']); } else { $local_error[] = "Ошибка: Не указан размер уменьшенного рисунка"; unlink("{$config['working_dir']}{$filename}"); exit; } } if (!rename("{$config['working_dir']}{$filename}", "{$config['uploaddir']}{$config['current_path']}/{$final_filename}")) { $local_error[] = "Ошибка перемещения изображения"; } } else { @unlink("{$config['working_dir']}{$filename}"); } if (isset($local_error)) { $local_error_string = implode(', ', $local_error); } else { $local_error_string = ''; } return array($final_filename, $local_error_string); }
function addeditcontestpicsAction() { $users = $this->db->query("SELECT username,id FROM users ORDER BY username"); $this->view->users = $users->fetchAll(); if (POST) { if (is_array($_POST['id'])) { foreach ($_POST['id'] as $id) { if ($_POST['delete'] == 'delete') { $this->db->delete('contests_album', "id='{$id}'"); } if ($_POST['block'] == 'block') { $this->db->update('contests_album', array("status" => "N"), "id='{$id}'"); } if ($_POST['unblock'] == 'unblock') { $this->db->update('contests_album', array("status" => "Y"), "id='{$id}'"); } } } if ($_POST["updateMain"] == "update" && $_FILES['logoMain']['tmp_name'] != "") { $logo = rand(0, time()) . ".jpg"; resize($_FILES['logoMain']['tmp_name'], "public/images/contest/{$logo}", 130, 130); $this->db->update("contests", array("logo" => $logo), "id = '" . $this->getRequest()->getParam('for') . "'"); } if ($_POST["deleteMain"] == "delete") { $this->db->update("contests", array("logo" => "no.jpg"), "id = '" . $this->getRequest()->getParam('for') . "'"); } if ($_POST["add"] == "add" && $_POST["uid"] != "") { $v = explode(".", $_FILES['logo']['name']); $format = $v[count($v) - 1]; $logo = rand(0, time()) . "." . $format; $Xs = getimagesize($_FILES['logo']['tmp_name']); if ($Xs[0] < 525) { move_uploaded_file($_FILES['logo']['tmp_name'], "public/images/contestAlbum/{$logo}"); } else { resize($_FILES['logo']['tmp_name'], "public/images/contestAlbum/{$logo}", 525, 525); } resize("public/images/contestAlbum/{$logo}", "public/images/contestAlbum/thumb/{$logo}", 78, 78); $array = array("logo" => $logo, "status" => "Y", "uid" => $_POST["uid"], "cid" => $this->getRequest()->getParam('for')); $this->db->insert("contests_album", $array); } } if ($this->getRequest()->getParam('for') != "") { $contests = $this->db->query("SELECT name,id,uid,logo FROM contests WHERE id = '" . $this->getRequest()->getParam('for') . "'"); $contests = $contests->fetchAll(); $this->view->contests = $contests[0]; $pic = $this->db->query("SELECT contests_album.logo,contests_album.status,contests_album.id,contests_album.timestamps,users.username \r\n\t\t\t\t\t\t\t\t\tFROM contests_album \r\n\t\t\t\t\t\t\t\t\tLEFT JOIN users ON users.id=contests_album.uid \r\n\t\t\t\t\t\t\t\t\tWHERE contests_album.cid = " . $this->getRequest()->getParam('for')); $this->view->pics = $pic->fetchAll(); } }
function arrange($id, $source, $file) { global $cfg, $pathvars; $extension = strtolower(substr(strrchr($file, "."), 1)); $type = $cfg["filetyp"][$extension]; if ($type == "img") { // quellbild in speicher einlesen switch ($extension) { case "gif": $img_src = @imagecreatefromgif($source); break; case "jpg": $img_src = @imagecreatefromjpeg($source); break; case "png": $img_src = @imagecreatefrompng($source); break; default: die("config error. can't handle " . $extension . " file"); } $art = array("s" => "img", "m" => "img", "b" => "img", "tn" => "tn"); foreach ($art as $key => $value) { resize($source, $id, $img_src, $cfg["size"][$key], $cfg["fileopt"][$type]["path"] . $pathvars["filebase"]["pic"][$key], $value); } // orginal bild nach max resizen oder loeschen #if ( $cfg["size"]["max"] == "" || imagesx($img_src) <= $cfg["size"]["max"] || imagesy($img_src) <= $cfg["size"]["max"] ) { #if ( $cfg["size"]["max"] == "" || (imagesx($img_src) <= $cfg["size"]["max"] && imagesy($img_src) <= $cfg["size"]["max"] )) { if ($cfg["size"]["max"] == "" || imagesx($img_src) <= $cfg["size"]["max"]) { rename($source, $cfg["fileopt"][$type]["path"] . $pathvars["filebase"]["pic"]["o"] . $cfg["fileopt"][$type]["name"] . "_" . $id . "." . $extension); } else { resize($source, $id, $img_src, $cfg["size"]["max"], $cfg["fileopt"][$type]["path"] . $pathvars["filebase"]["pic"]["o"], $cfg["fileopt"][$type]["name"]); unlink($source); } // speicher des quellbild freigeben imagedestroy($img_src); } else { rename($source, $cfg["fileopt"][$type]["path"] . $cfg["fileopt"][$type]["name"] . "_" . $id . "." . $extension); } }
"> <div class="featured_img"><?php if ($this->session->userdata('PRICE_MODE') != '') { ?> <a href="products/details/<?php echo $product['product_alias']; ?> "><img src="<?php echo resize($this->config->item('PRODUCT_PATH') . $product['product_image'], 83, 96, 'featuredproduct_images'); ?> "/></a> <?php } else { ?> <a href="mode" class="mode_popup"><img src="<?php echo resize($this->config->item('PRODUCT_PATH') . $product['product_image'], 83, 96, 'featuredproduct_images'); ?> "/></a> <?php } ?> </div> <div class="featured_text"> <h3><?php echo $product['product_name']; ?> </h3> <?php echo word_limiter($product['product_desc'], 5); ?> </div>
if ($_FILES['image']['size'][$i] > $maxsize) { continue; } $arr = explode(".", $_FILES['image']['name'][$i]); $length = count($arr) - 1; if (!in_array($arr[$length], $arrex)) { continue; } $name = ''; for ($j = 0; $j < $length; $j++) { $name .= $arr[$j]; } $name = formatToUrl($name); $filename = createFileName($name, $name, 1, $path, $arr[$length]); if (isset($maxwidth)) { if (resize($maxwidth, $maxheight, $path . '/' . $filename, $i)) { list($width, $height) = getimagesize($path . '/' . $filename); $arrupload[] = array('width' => $width, 'height' => $height, 'name' => $filename, 'time' => 'Vừa Xong', 'size' => $_FILES['image']['size'][$i]); $flag = true; $message++; } } else { if (move_uploaded_file($_FILES['image']['tmp_name'][$i], $path . '/' . $filename)) { list($width, $height) = getimagesize($path . '/' . $filename); $arrupload[] = array('width' => $width, 'height' => $height, 'name' => $filename, 'time' => 'Vừa Xong', 'size' => $_FILES['image']['size'][$i]); $message++; $flag = true; } } } }
if ($athlete["name"] == $_GET["name"]) { if (!empty($athlete[$_GET["type"]])) { $num = $athlete[$_GET["type"]]; } else { $num = 0; } } } $im = ImageCreateFromPNG("img/" . $_GET['type'] . ".png"); $bg = ImageColorAllocate($im, 255, 255, 255); $width = 300; $height = 300; $text = $num; $textcolor = ImageColorAllocate($im, 0, 0, 0); // Font stuff $font = 'arial.ttf'; $width = strlen($text); // String length management switch (strlen($text)) { case 1: $x = 110; break; case 2: $x = 80; } imagettftext($im, 150, 0, $x, 220, $textcolor, $font, $text); $im = resize($im, 30, 30); imagealphablending($im, false); imagesavealpha($im, true); header("Content-type: image/png"); ImagePNG($im);
$result->close(); $pageurl = new pagination($numrows, $setting['seo'], 'download', $setting['gperpage'], 3); $select_games = yasDB_select("SELECT * FROM downgames ORDER BY `id` DESC LIMIT " . $pageurl->start . ", " . $pageurl->limit); while ($games = $select_games->fetch_array(MYSQLI_ASSOC)) { $thumbpath = $setting['siteurl'] . urldecode(str_replace("../", "", $games['thumbnail'])); $filepath = str_replace("../", "", $games['file']); if (strlen($games['description']) > 180) { $games['description'] = substr($games['description'], 0, 180) . '...'; } $games['description'] = stripslashes($games['description']); $description = str_replace(array("\r\n", "\r", "\n", "'", '"'), ' ', $games['description']); $pic_settings = array('w' => 130, 'h' => 100); echo '<div class="download"> <ul> <li class="title"><div class="downloadheader">' . $games['title'] . '</div></li> <li class="even"><div class="container_box7"><div class="gameholderimg"><img align="absmiddle" src="' . resize($thumbpath, $pic_settings, "download") . '" alt="' . $thumbpath . '" width="130" height="100" /></div><div class="desc">' . $games['description'] . '</div>'; if ($games['mochi'] != '') { echo '<div class="clear"></div><div class="downloadgame"><center><a href="' . $setting['siteurl'] . $filepath . '" onclick="return download_link(' . $games['id'] . ')"><img align="absmiddle" src="' . $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/buttons/download.png" width="100" height="30" /></a></center></div>'; echo '<div class="downloadmochi"><center><a href="' . $games['mochi'] . '" rel="nofollow" onclick="return download_link_mochi(' . $games['id'] . ')"><img align="absmiddle" src="' . $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/buttons/downloadmochi.png" width="100" height="30" /></a></center></div>'; echo '</div><div class="clear"></div></li></ul></div>'; } else { echo '<div class="clear"></div><div class="downloadgame"><center><a href="' . $setting['siteurl'] . $filepath . '" onclick="return download_link(' . $games['id'] . ')"><img align="absmiddle" src="' . $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/buttons/download.png" width="100" height="30" /></a></center></div>'; echo '</div><div class="clear"></div></li></ul></div>'; } } $select_games->close(); } ?> <div id="page_box"> <?php
require JPATH_COMPONENT_ADMINISTRATOR . DS . 'config.datsogallery.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'images.datsogallery.php'; $db = JFactory::getDBO(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $id = JRequest::getVar('id', 0, 'get', 'int'); $catid = JRequest::getVar('catid', 0, 'get', 'int'); if ($id) { $db->setQuery('SELECT c.access' . ' FROM #__datsogallery_catg AS c' . ' LEFT JOIN #__datsogallery AS a' . ' ON a.catid = c.cid' . ' WHERE a.id = ' . $id . ' AND c.approved = 1' . ' AND c.access IN (' . $groups . ')'); $access = $db->loadObject(); if (!$access) { die(JText::_('COM_DATSOGALLERY_NOT_ACCESS_THIS_DIRECTORY')); } else { $db->setQuery('SELECT a.imgoriginalname' . ' FROM #__datsogallery AS a' . ' WHERE a.id = ' . $id . ' AND a.catid = ' . $catid); $image = $db->loadResult(); } resize($image, $ad_orgwidth, $ad_orgheight, 0, 0, $ad_showwatermark, $catid); $cacheimage = getCacheFile($image, $ad_orgwidth, $ad_orgheight, $catid); $imagesize = getimagesize($cacheimage); $expires = 60 * 60 * 24 * 14; header('Pragma: public'); header('Cache-Control: maxage=' . $expires); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); header('Last-Modified: ' . date('r')); header('Accept-Ranges: bytes'); header('Content-Length: ' . filesize($cacheimage)); header('Content-Type: ' . $imagesize['mime']); ob_clean(); readfile($cacheimage); exit; }
$thumbnail = urldecode($games['thumbnail']); } else { $thumbnail = $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/nopic.jpg'; } if ($setting['seo'] == 'yes') { $gurl = $setting['siteurl'] . 'game/' . $games['id'] . '/' . $gameurl . '.html'; } else { $gurl = $setting['siteurl'] . 'index.php?act=game&id=' . $games['id']; } ?> <div style="float:left;margin:0 0;"> <a href="<?php echo $gurl; ?> "><img src="<?php echo resize($thumbnail, $pic_settings); ?> " style="margin:4px;" alt="" width="35" height="35" border="0" align="left" class="hintanchor" onMouseover="showhint('<b><?php echo addslashes($games['title']); ?> </b>', this, event, 'auto')"></a> </div> <?php } } ?> </div> <div style="clear:both;"></div> <?php $cache->write('newest'); $cache->stop_caching(); echo $cache->read('newest');
include 'function.php'; // settings $max_file_size = 1024 * 200; // 200kb $valid_exts = array('jpeg', 'jpg', 'png', 'gif'); // thumbnail sizes $sizes = array(100 => 100, 150 => 150, 250 => 250); if ($_SERVER['REQUEST_METHOD'] == 'POST' and isset($_FILES['image'])) { if ($_FILES['image']['size'] < $max_file_size) { // get file extension $ext = strtolower(pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION)); if (in_array($ext, $valid_exts)) { /* resize image */ foreach ($sizes as $w => $h) { $files[] = resize($w, $h); } } else { $msg = 'Unsupported file'; } } else { $msg = 'Please upload image smaller than 200KB'; } } ?> <html> <head> <title>Image resize while uploadin</title> <head> <body> <!-- file uploading form -->
$select_games = yasDB_select("SELECT * FROM downgames ORDER BY `id` DESC LIMIT " . $pageurl->start . ", " . $pageurl->limit); while ($games = $select_games->fetch_array(MYSQLI_ASSOC)) { $thumbpath = $setting['siteurl'] . urldecode(str_replace("../", "", $games['thumbnail'])); $filepath = 'download/' . basename($games['file']); if (strlen($games['description']) > 180) { $games['description'] = substr($games['description'], 0, 180) . '...'; } $games['description'] = stripslashes($games['description']); $description = str_replace(array("\r\n", "\r", "\n", "'", '"'), ' ', $games['description']); $pic_settings = array('w' => 130, 'h' => 100); echo '<div class="container_box6">'; echo '<div class="header3">' . $games['title'] . '</div>'; echo '<div class="container_box7">'; echo '<div class="desc">' . $games['description'] . '</div>'; echo '<div class="gameholderimg"> <img align="absmiddle" src="' . resize($thumbpath, $pic_settings, "download") . '" alt="' . $thumbpath . '" width="130" height="100" /> </div>'; if ($games['mochi'] != '') { echo '<div class="downloadgame"><center><a href="' . $setting['siteurl'] . $filepath . '" onclick="return download_link(' . $games['id'] . ')"><img align="absmiddle" src="' . $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/buttons/download.png" width="100" height="30" /></a></center></div>'; echo '<div class="downloadmochi"><center><a href="' . $games['mochi'] . '" rel="nofollow" onclick="return download_link_mochi(' . $games['id'] . ')"><img align="absmiddle" src="' . $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/buttons/downloadmochi.png" width="100" height="30" /></a></center></div>'; echo '</div>'; echo '</div>'; } else { echo '<div class="downloadgame"><center><a href="' . $setting['siteurl'] . $filepath . '" onclick="return download_link(' . $games['id'] . ')"><img align="absmiddle" src="' . $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/buttons/download.png" width="100" height="30" /></a></center></div>'; //echo '<div class="downloadgame"><center><a href="'.$setting['siteurl'].'includes/link_download.php?id='.$games['id'].'" ><img align="absmiddle" src="'.$setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/buttons/download.png" width="100" height="30" /></a></center></div>'; echo '</div>'; echo '</div>'; } } $select_games->close(); }