} else { $quality = 50; } /* Double width and height for retina displays (you should only set this to 'true' for debuggine purposes) */ if ($retina == 'auto' && $supportsRetina == 'true' || $retina == 'true') { $width = $width * 2; $height = $height * 2; } /* Set MIME header */ header('Content-type: image/jpeg'); /* Generate image */ if ($loading && $noscriptFallback == 'false' || $loading && $noscriptFallback == 'true' && @$_COOKIE['js'] == 'true') { /* Output smallest possible transparent png as a placeholder (http://garethrees.org/2007/11/14/pngcrush/) */ print base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQIHWNgYAAAAAMAAU9ICq8AAAAASUVORK5CYII='); } elseif ($loading) { /* Read the original file */ readfile(PATH . $file); } else { /* Output optimized image */ $resizedFile = str_ireplace('.jpg', '', PATH . $file) . '_' . $width . 'x' . $height . '_' . $quality . '.jpg'; if (file_exists($resizedFile)) { /* If in cache, read it. */ readfile($resizedFile); } else { /* If not in cache, create it first. Then read it. */ $resizeObj = new resize(PATH . $file); $resizeObj->resizeImage($width, $height, 'crop'); $resizeObj->saveImage($resizedFile, $quality); readfile($resizedFile); } }
public function upload($maxSize = 20000, $uploadPath = 'upload/', $thumbPath = false, $filename = false, $enableThumbnail = array('maxwidth' => 100, 'maxheight' => 100, 'method' => 'auto'), $resize = false) { $tmp = explode('.', $_FILES[$this->prefix]['name']); $extension = strtolower(end($tmp)); $file = array(); if (($_FILES[$this->prefix]['type'] == 'image/gif' || $_FILES[$this->prefix]['type'] == 'image/jpeg' || $_FILES[$this->prefix]['type'] == 'image/jpg' || $_FILES[$this->prefix]['type'] == 'image/pjpeg' || $_FILES[$this->prefix]['type'] == 'image/x-png' || $_FILES[$this->prefix]['type'] == 'image/png') && $_FILES[$this->prefix]['size'] < $maxSize && in_array($extension, $this->extensions)) { if ($_FILES[$this->prefix]['error'] > 0) { $file['status'] = false; $file['error'] = $_FILES[$this->prefix]['error']; } else { $file['status'] = true; $file['upload'] = $_FILES[$this->prefix]['name']; $file['type'] = $_FILES[$this->prefix]['type']; $file['size'] = $_FILES[$this->prefix]['size'] / 1024; $file['temp'] = $_FILES[$this->prefix]['tmp_name']; if (!$filename) { $tmp = explode('.', $_FILES[$this->prefix]['name']); $filename = reset($tmp); } // move the file to the desired directory if (!file_exists($uploadPath)) { mkdir($uploadPath); } move_uploaded_file($_FILES[$this->prefix]['tmp_name'], $uploadPath . $filename . '.' . $extension); // creates a thumbnail if ($enableThumbnail) { $path = $uploadPath . $filename . '.' . $extension; if ($thumbPath) { if (!file_exists($thumbPath)) { mkdir($thumbPath); } $thumbPath = $thumbPath . $filename . '.' . $extension; } else { $thumbPath = $uploadPath . $filename . '_thumb.' . $extension; } $resizeObj = new resize($uploadPath . $filename . '.' . $extension); $resizeObj->resizeImage($enableThumbnail['maxwidth'], $enableThumbnail['maxheight'], $enableThumbnail['method']); $resizeObj->saveImage($thumbPath, 70); $file['thumb'] = $thumbPath; } $file['stored'] = $uploadPath . $filename . '.' . $extension; $file['file'] = $filename . '.' . $extension; // resize $dimensions = getimagesize($uploadPath . $filename . '.' . $extension); if ($resize && ($dimensions[0] > $resize['width'] || $dimensions[1] > $resize['width'])) { $path = $uploadPath . $filename . '.' . $extension; $resizeObj = new resize($path); $resizeObj->resizeImage($resize['width'], $resize['height'], 'auto'); $resizeObj->saveImage($path, 70); } } } else { $file['status'] = false; $file['error'] = 'invalid file'; } return $file; }
function resizeSingleOther($imgUrl, $jsonObject, $resizedDir, $id, &$resizedUrl) { /* *similar to resizeSingleMain() */ $width = $jsonObject['other']['size']['width']; $height = $jsonObject['other']['size']['height']; $resizeObject = new resize($imgUrl); $resizeObject->resizeImage($width, $height, 'exact', $id . "-resized"); $resizeObject->saveImage($resizedDir . $id . "-resized.jpg", 100); $resizedUrl = $resizedDir . $id . "-resized.jpg"; }
function try_handle_image_submit() { global $user_message, $upload_folder; $user_message = ""; if (isset($_FILES) && array_key_exists('file', $_FILES)) { if ($_FILES["file"]["error"] === UPLOAD_ERR_OK) { //check the filetype switch ($_FILES["file"]["type"]) { case 'image/jpeg': $file_suffix = "jpg"; break; case 'image/png': $file_suffix = "png"; break; case 'image/gif': $file_suffix = "gif"; break; default: $user_message = "Ukendt filtype."; return; } //mode the file to the upload folder $filename = md5_file($_FILES["file"]["tmp_name"]) . "." . $file_suffix; $filepath = $upload_folder . $filename; move_uploaded_file($_FILES["file"]["tmp_name"], $filepath); //resize the image include "code_dep/imgresize-class.php"; $resizedimg = new resize($filepath); //options: exact, portrait, landscape, auto, crop $resizedimg->resizeImage(200, 200, 'crop'); $resizedimg->saveImage($upload_folder . "resized-" . $filename, 100); //store the reference to the file in the user profile query("UPDATE users SET profile_image = '" . db()->escape_string($filename) . "' WHERE id = " . module()->getUserid()); } else { if ($_FILES["file"]["error"] === UPLOAD_ERR_NO_FILE) { $user_message = "Der blev ikke sendt en fil."; return; } else { $user_message = "Der skete en ukendt fejl under upload af billedet."; return; } } } }
private function create_thumb($key, $size) { $thumb_key = self::IMAGE_CACHE_FOLDER . $this->option_thumbnail["width"] . "x" . $this->option_thumbnail["height"] . "-" . $this->option_thumbnail["resize"] . "/" . $key; if (!$this->s3_client->doesObjectExist($this->bucket, $thumb_key)) { $temp_original_image = self::create_unique_temp_filename($key); $temp_converted_image = self::create_unique_temp_filename($key); // echo "Creating ... "; $download = $this->s3_client->getObject(array("Bucket" => $this->bucket, "Key" => $key, "SaveAs" => $temp_original_image)); // echo "Size is " . $this->option_thumbnail["width"]; $this->total_converted_size += $size; $resizeObj = new resize($temp_original_image); if ($resizeObj->validImage()) { $resizeObj->resizeImage($this->option_thumbnail["width"], $this->option_thumbnail["height"], $this->option_thumbnail["resize"]); $resizeObj->saveImage($temp_converted_image, 100); $upload = $this->s3_client->putObject(array("Bucket" => $this->bucket, "Key" => $thumb_key, "SourceFile" => $temp_converted_image, "ContentType" => $download["ContentType"], "ACL" => "public-read", "StorageClass" => "REDUCED_REDUNDANCY")); unlink($temp_converted_image); } else { $thumb_key = $key; //TODO } unlink($temp_original_image); } return $thumb_key; }
} else { $image = addslashes($_FILES["image"]["tmp_name"]); $image_name = $_FILES["image"]["name"]; $type = $_FILES["image"]["type"]; $size = $_FILES["image"]["size"]; $temp = $_FILES["image"]["tmp_name"]; $error = $_FILES["image"]["error"]; if ($size == FALSE) { echo "this is not an image"; } else { move_uploaded_file($temp, '../-registration/large/' . $image_name); // *** Include the class include_once "resize-class.php"; // *** 1) Initialise / load image $resizeObj = new resize('../-registration/large/' . $image_name); // *** 2) Resize image (options: exact, portrait, landscape, auto, crop) $resizeObj->resizeImage(50, 50, 'crop'); // *** 3) Save image $resizeObj->saveImage('../-registration/include/dpic/' . $image_name, 100); //query img to db $update = mysql_query("UPDATE student_t SET photo='{$image_name}' WHERE student_id='{$id}'") or die(mysql_error()); } echo $image_name; echo "<img src='../-registration/include/dpic/{$image_name}' />"; } header("Location: reg_listofenrolledstudents.php"); ?>
function print_my_responsive_photo_gallery_func() { $settings = get_option('my_responsive_photo_gallery_slider_settings'); $rand_Numb = uniqid('gallery_slider'); $wpcurrentdir = dirname(__FILE__); $wpcurrentdir = str_replace("\\", "/", $wpcurrentdir); $url = plugin_dir_url(__FILE__); $uploads = wp_upload_dir(); $baseDir = $uploads['basedir']; $baseDir = str_replace("\\", "/", $baseDir); $pathToImagesFolder = $baseDir . '/wp-responsive-photo-gallery'; $baseurl = $uploads['baseurl']; $baseurl .= '/wp-responsive-photo-gallery/'; ob_start(); ?> <div id="divSliderMain_admin_<?php echo $rand_Numb; ?> " style="max-width:<?php echo $settings['panel_width']; ?> px;"> <ul id="<?php echo $rand_Numb; ?> "> <?php global $wpdb; $imageheight = $settings['panel_height']; $imagewidth = $settings['panel_width']; $query = "SELECT * FROM " . $wpdb->prefix . "gv_responsive_slider order by createdon desc"; $rows = $wpdb->get_results($query, 'ARRAY_A'); if (count($rows) > 0) { foreach ($rows as $row) { $imagename = $row['image_name']; $imageUploadTo = $pathToImagesFolder . '/' . $imagename; $imageUploadTo = str_replace("\\", "/", $imageUploadTo); $pathinfo = pathinfo($imageUploadTo); $filenamewithoutextension = $pathinfo['filename']; $outputimg = ""; if ($settings['panel_scale'] == 'fit') { $outputimg = $baseurl . $imagename; } else { list($width, $height) = getimagesize($pathToImagesFolder . "/" . $row['image_name']); if ($width < $imagewidth) { $imagewidth = $width; } if ($height < $imageheight) { $imageheight = $height; } $imagetoCheck = $pathToImagesFolder . '/' . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo['extension']; $imagetoCheckSmall = $pathToImagesFolder . '/' . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . strtolower($pathinfo['extension']); if (file_exists($imagetoCheck)) { $outputimg = $baseurl . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo['extension']; } else { if (file_exists($imagetoCheckSmall)) { $outputimg = $baseurl . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . strtolower($pathinfo['extension']); } else { if (file_exists($pathToImagesFolder . "/" . $row['image_name'])) { $resizeObj = new resize($pathToImagesFolder . "/" . $row['image_name']); $resizeObj->resizeImage($imagewidth, $imageheight, "exact"); $resizeObj->saveImage($pathToImagesFolder . "/" . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo['extension'], 100); $outputimg = $baseurl . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo['extension']; } else { $outputimg = $baseurl . $imagename; } } } } ?> <li><img data-target="1" data-href="<?php echo $row['custom_link']; ?> " src="<?php echo $outputimg; ?> " /></li> <?php } ?> <?php } ?> </ul> </div> <script type="text/javascript"> $j= jQuery.noConflict(); $j(document).ready(function() { <?php $galRandNo = rand(0, 13313); ?> var galleryItems<?php echo $galRandNo; ?> ; $j(function(){ galleryItems<?php echo $galRandNo; ?> = $j("#<?php echo $rand_Numb; ?> "); var galleryItemDivs = $j('#divSliderMain_admin_<?php echo $rand_Numb; ?> '); galleryItems<?php echo $galRandNo; ?> .each(function (index, item){ item.parent_data = $j(item).parent("#divSliderMain_admin_<?php echo $rand_Numb; ?> "); }); galleryItemDivs.each(function(index, item){ $j("ul",this).galleryView({ transition_speed:<?php echo $settings['transition_speed']; ?> , //INT - duration of panel/frame transition (in milliseconds) transition_interval:<?php echo $settings['transition_interval']; ?> , //INT - delay between panel/frame transitions (in milliseconds) easing:'<?php echo $settings['easing']; ?> ', //STRING - easing method to use for animations (jQuery provides 'swing' or 'linear', more available with jQuery UI or Easing plugin) show_panels:<?php echo $settings['show_panels'] == 1 ? 'true' : 'false'; ?> , //BOOLEAN - flag to show or hide panel portion of gallery show_panel_nav:<?php echo $settings['show_panel_nav'] == 1 ? 'true' : 'false'; ?> , //BOOLEAN - flag to show or hide panel navigation buttons enable_overlays:<?php echo $settings['enable_overlays'] == 1 ? 'true' : 'false'; ?> , //BOOLEAN - flag to show or hide panel overlays panel_width:<?php echo $settings['panel_width']; ?> , //INT - width of gallery panel (in pixels) panel_height:<?php echo $settings['panel_height']; ?> , //INT - height of gallery panel (in pixels) panel_animation:'<?php echo $settings['panel_animation']; ?> ', //STRING - animation method for panel transitions (crossfade,fade,slide,none) panel_scale: '<?php echo $settings['panel_scale']; ?> ', //STRING - cropping option for panel images (crop = scale image and fit to aspect ratio determined by panel_width and panel_height, fit = scale image and preserve original aspect ratio) overlay_position:'<?php echo $settings['overlay_position']; ?> ', //STRING - position of panel overlay (bottom, top) pan_images:<?php echo $settings['pan_images'] == 1 ? 'true' : 'false'; ?> , //BOOLEAN - flag to allow user to grab/drag oversized images within gallery pan_style:'<?php echo $settings['pan_style']; ?> ', //STRING - panning method (drag = user clicks and drags image to pan, track = image automatically pans based on mouse position start_frame:'<?php echo $settings['start_frame']; ?> ', //INT - index of panel/frame to show first when gallery loads show_filmstrip:<?php echo $settings['show_filmstrip'] == 1 ? 'true' : 'false'; ?> , //BOOLEAN - flag to show or hide filmstrip portion of gallery show_filmstrip_nav:<?php echo $settings['show_filmstrip_nav'] == 1 ? 'true' : 'false'; ?> , //BOOLEAN - flag indicating whether to display navigation buttons enable_slideshow:<?php echo $settings['enable_slideshow'] == 1 ? 'true' : 'false'; ?> , //BOOLEAN - flag indicating whether to display slideshow play/pause button autoplay:<?php echo $settings['autoplay'] == 1 ? 'true' : 'false'; ?> , //BOOLEAN - flag to start slideshow on gallery load show_captions:<?php echo $settings['show_captions'] == 1 ? 'true' : 'false'; ?> , //BOOLEAN - flag to show or hide frame captions filmstrip_style: '<?php echo $settings['filmstrip_style']; ?> ', //STRING - type of filmstrip to use (scroll = display one line of frames, scroll filmstrip if necessary, showall = display multiple rows of frames if necessary) filmstrip_position:'<?php echo $settings['filmstrip_position']; ?> ', //STRING - position of filmstrip within gallery (bottom, top, left, right) frame_width:<?php echo $settings['frame_width']; ?> , //INT - width of filmstrip frames (in pixels) frame_height:<?php echo $settings['frame_width']; ?> , //INT - width of filmstrip frames (in pixels) frame_opacity:<?php echo $settings['frame_opacity']; ?> , //FLOAT - transparency of non-active frames (1.0 = opaque, 0.0 = transparent) frame_scale: '<?php echo $settings['frame_scale']; ?> ', //STRING - cropping option for filmstrip images (same as above) frame_gap:<?php echo $settings['frame_gap']; ?> , //INT - spacing between frames within filmstrip (in pixels) show_infobar:<?php echo $settings['show_infobar'] == 1 ? 'true' : 'false'; ?> , //BOOLEAN - flag to show or hide infobar infobar_opacity:<?php echo $settings['infobar_opacity']; ?> , //FLOAT - transparency for info bar clickable: 'all' }); }); var oldsize_w<?php echo $galRandNo; ?> =<?php echo $settings['panel_width']; ?> ; var oldsize_h<?php echo $galRandNo; ?> =<?php echo $settings['panel_height']; ?> ; function resizegallery<?php echo $galRandNo; ?> (){ if(galleryItems<?php echo $galRandNo; ?> ==undefined){return;} galleryItems<?php echo $galRandNo; ?> .each(function (index, item){ var $parent = item.parent_data; // width based on parent? var width = ($parent.innerWidth()-10);//2 times 5 pixels margin var height = ($parent.innerHeight()-10);//2 times 5 pixels margin if(oldsize_w<?php echo $galRandNo; ?> ==width){ return; } oldsize_w<?php echo $galRandNo; ?> =width; var resizeToHeight=width/3*2; if(resizeToHeight><?php echo $settings['panel_height']; ?> ){ resizeToHeight=<?php echo $settings['panel_height']; ?> ; } thumbfactor = width/(<?php echo $settings['panel_width']; ?> -10); $j(item).resizeGalleryView( width, resizeToHeight, <?php echo $settings['frame_width']; ?> *thumbfactor, <?php echo $settings['frame_height']; ?> *thumbfactor); }); } var inited<?php echo $galRandNo; ?> =false; function onresize<?php echo $galRandNo; ?> (){ resizegallery<?php echo $galRandNo; ?> (); inited<?php echo $galRandNo; ?> =true; } $j(window).resize(onresize<?php echo $galRandNo; ?> ); $j( document ).ready(function() { onresize<?php echo $galRandNo; ?> (); }); }); }); </script> <?php $output = ob_get_clean(); return $output; }
} else { $image = addslashes($_FILES["image"]["tmp_name"]); $image_name = $_FILES["image"]["name"]; $type = $_FILES["image"]["type"]; $size = $_FILES["image"]["size"]; $temp = $_FILES["image"]["tmp_name"]; $error = $_FILES["image"]["error"]; if ($size == FALSE) { echo "this is not an image"; } else { move_uploaded_file($temp, '../library/book/' . $image_name); // *** Include the class include_once "resize-class.php"; // *** 1) Initialise / load image $resizeObj = new resize('../library/book/' . $image_name); // *** 2) Resize image (options: exact, portrait, landscape, auto, crop) $resizeObj->resizeImage(90, 90, 'crop'); // *** 3) Save image $resizeObj->saveImage('../library/book/dpic/' . $image_name, 100); //query img to db $update = mysql_query("UPDATE cat_reading_material_t SET image='{$image_name}' WHERE call_no = '{$id}';") or die(mysql_error()); } //echo $image_name; //echo "<img src='../-registration/include/dpic/$image_name' />"; } header("Location: report_book_daily.php?"); ?>
if (count($imgSize) == '1') { $imgSize[1] = $imgSize[0]; } // Определяем имя файла $fileName = $size . '_' . $method . '_' . strtolower(basename($imgResized)); // Если картинки нет в папке обработанных картинок — создадим её if (!file_exists($dir . $fileName)) { // Подключаем класс ресайза if (!class_exists('resize')) { require_once PLUGINS_PATH . '/thumb/classes/resize.php'; } // Изменяем размер $resizeImg = new resize($imgResized); $resizeImg->resizeImage($imgSize[0], $imgSize[1], $method); // Сохраняем картинку в заданную папку $resizeImg->saveImage($dir . $fileName, $quality); } $imgResized = Url::getBase() . $imageDir . $fileName; } $title = isset($title) ? $title : ''; $alt = isset($alt) ? $alt : ''; $class = isset($class) ? $class . ' popup-image' : 'popup-image'; $gallery = isset($gallery) ? '-gallery' : ''; $imageLink = '<a class="' . $class . $gallery . '" href="' . $content . '" title="' . $title . '"><img src="' . $imgResized . '" alt="' . $alt . '"></a>'; return $imageLink; } return ''; }); Action::add('theme_header', function () { if (Config::get('plugins.thumb.loadcss')) { echo '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css">';
$thumbs_height = $o_height * ($thumbs_width / $o_width); $small_width = 60; $small_height = $o_height * ($small_width / $o_width); if (move_uploaded_file($_FILES[$filename]['tmp_name'], $uploaddir . $uploadfile)) { $resizeObj = new resize($uploaddir . $uploadfile); $resizeObj->resizeImage($thumbs_width, $thumbs_height, 'crop'); $resizeObj->saveImage($uploaddir_thumb . $uploadfile, 100); $resizeObj = new resize($uploaddir_thumb . $uploadfile); $resizeObj->resizeImage($small_width, $small_height, 'crop'); $resizeObj->saveImage($uploaddir_small_thumb . $uploadfile, 100); if ($o_width > 360) { $large_width = 360; $large_height = $o_height * ($large_width / $o_width); $resizeObj = new resize($uploaddir . $uploadfile); $resizeObj->resizeImage($large_width, $large_height, 'crop'); $resizeObj->saveImage($uploaddir . $uploadfile, 100); } echo basename($uploadfile); } } else { echo "error"; } } } /* $file = $uploaddir . basename($_FILES[$filename]['name']); if (move_uploaded_file($_FILES[$filename]['tmp_name'], $file)) { //echo "success"; echo basename($_FILES[$filename]['name']);
private function get_img_name() { //получаем картинку,которая еще не загружалась $dir = new DirectoryIterator('./img/'); foreach ($dir as $file) { if ($file->isFile()) { $filename = $file->getBasename(); if (!in_array($filename, $this->last_img_id)) { //еще не брали картинку $resizeObj = new resize('./img/' . $filename); //обработка $resizeObj->resizeImage(700, 500, 'crop'); $resizeObj->saveImage("./img/" . $filename, 100); return $filename; } } } }
function editbanner($content, $image) { $var = explode("_", $this->args[2]); $id = $var[1]; $uploaddir = BANNER_IMAGE_ORIGINAL; $uploaddir1 = BANNER_IMAGE_THUMB; $uploaddir2 = BANNER_IMAGE_LARGE; //move_uploaded_file($image["file"]["tmp_name"],'http://projects.sibzsolutions.net/tsavostore/bannerimage/'.$filenametest) or die(); $image_type = strstr($image["file"]["name"], '.'); $file_type = $image["file"]["type"] == "image/gif" || $image["file"]["type"] == "image/jpeg" || $image["file"]["type"] == "image/jpg" || $image["file"]["type"] == "image/png" || $image["file"]["type"] == "image/swf"; if ($image["file"]["name"] != "" && $image_type != $file_type) { $lastmsg = "The Picture format is not supported, upload a supported format."; $this->dbobject->redirect($this->link, $lastmsg); } $filename = ''; if ($image["file"]["name"] != '') { $filename = time() . $image["file"]["name"]; $filename = str_replace(' ', '_', $filename); //echo $uploaddir.$filename; if (move_uploaded_file($image['file']['tmp_name'], $uploaddir . $filename)) { $resizeObj = new resize($uploaddir . $filename); $resizeObj->resizeImage(958, 311, 'exact'); $resizeObj->saveImage($uploaddir1 . $filename, 100); $resizeObj->resizeImage(200, 80, 'exact'); $resizeObj->saveImage($uploaddir2 . $filename, 100); } else { $filename = ''; $photoError = "<br />Photo Not Uploaded."; } } // Insert banner Details in banner Table $AddArray = array("bantitle" => trim($content['title']), "bantype" => $content['imgtype'], "banlink" => $content['link'], "created" => date("Y-m-d H:i:s"), "del_status" => '1'); if ($filename != '') { $AddArray['banfile'] = $filename; } $where = "id=" . $id; $this->dbobject->update_record(BANNER_TABLE, $AddArray, $where, '', $query_echo = ''); }
if (in_array($fileParts['extension'], $fileTypes)) { if (!file_exists($uploadDir)) { mkdir($uploadDir, 0777, true); mkdir($uploadDir . 'small' . DIRECTORY_SEPARATOR, 0777, true); mkdir($uploadDir . 'large' . DIRECTORY_SEPARATOR, 0777, true); } $newName = file_exists($uploadDir . $_FILES['Filedata']['name']) ? $verifyToken . '_' . $_FILES['Filedata']['name'] : $_FILES['Filedata']['name']; move_uploaded_file($tempFile, $uploadDir . $newName); /*** * Create thumbnail image ***/ // *** 1) Initialise / load image $resizeObj = new resize($uploadDir . $newName); // *** 2) Resize image (options: exact, portrait, landscape, auto, crop) $resizeObj->resizeImage($thumb_width, $thumb_height, $thumb_type); // *** 3) Save small image $resizeObj->saveImage($uploadDir . 'small' . DIRECTORY_SEPARATOR . $newName, 100); // *** 4) Resize image (options: exact, portrait, landscape, auto, crop) $resizeObj = new resize($uploadDir . $newName); $resizeObj->resizeImage($resize_width, $resize_height, $resize_type); // *** 3) Save large image $resizeObj->saveImage($uploadDir . 'large' . DIRECTORY_SEPARATOR . $newName, 100); $_photoData['project_photos'][] = $newName; //insert new photo $projectModel = new ProjectModel(); $projectModel->insert_project_images($_photoData['project_photos']); echo '1'; } else { echo 'Invalid file type.'; } }
$sql = "INSERT INTO tbl_products SET Title = '" . $Title . "',Description = '" . $Description . "',Brand = '" . $Brand . "',Color = '" . $Color . "',Price = '" . $Price . "'"; $result3 = mysql_query($sql); $last_ID = mysql_insert_id(); for ($i = 0; $i < count($_POST['sizes']); $i++) { mysql_query("INSERT INTO tbl_productsizes SET ProductID = '" . $last_ID . "' , sizeID = '" . $_POST['sizes'][$i] . "'"); } for ($i = 1; $i <= count($_FILES['photos']['name']); $i++) { $sepext = explode('.', $_FILES['photos']['name'][$i - 1]); $type = end($sepext); //$uniqueID = md5(uniqid()); $newFileName = $sepext[0] . '.' . $type; $RnewFileName = $sepext[0] . '_R.' . $type; if (move_uploaded_file($_FILES['photos']['tmp_name'][$i - 1], "images/products/big/" . $newFileName)) { $resizeObj = new resize("images/products/big/" . $newFileName); $resizeObj->resizeImage(66, 91, 'crop'); $resizeObj->saveImage("images/products/thumbs/" . $RnewFileName, 100); $resizeObj->resizeImage(202, 186, 'crop'); $resizeObj->saveImage("images/products/medium/" . $newFileName, 100); mysql_query("INSERT INTO tbl_productphotos SET ProductID = '" . $last_ID . "' , photo = '" . $RnewFileName . "'"); } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body>
} return array($sResourcePath, $sDestPath); } // File name & location $sExt = ''; list($sImage, $sOutputFile) = getFilePath($sImage); $sOutputFile .= PHPFOX_DS . $sDesFile; if (!file_exists($sImage)) { header('HTTP/1.0 404 Not Found'); exit; } // Check file existance if (!file_exists($sOutputFile)) { $oResize = new resize($sImage); $oResize->resizeImage($iWidth, $iHeight, $sOption); $oResize->saveImage($sOutputFile, 100); } // return image ob_clean(); header('Content-Type: image/' . $sExt); echo file_get_contents($sOutputFile); ob_flush(); exit; function grabImage($url, $saveto) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); $raw = curl_exec($ch); curl_close($ch);
echo 'Sorry, your file is too large.'; $uploadOk = 0; } // Allow certain file formats if ($uploadedPhotoFiletype != 'jpg' && $uploadedPhotoFiletype != 'png' && $uploadedPhotoFiletype != 'jpeg' && $uploadedPhotoFiletype != 'gif') { echo 'Sorry, only JPG, JPEG, PNG & GIF files are allowed.'; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo 'Sorry, your file was not uploaded.'; } else { if (move_uploaded_file($_FILES['player-photo']['tmp_name'], $newFilePath)) { // Include the class include $functions . 'photoResize.php'; // 1) Initialise / load image $resizeObj = new resize($newFilePath); // 2) Resize image (options: exact, portrait, landscape, auto, crop) $resizeObj->resizeImage(170, 170, 'crop'); // 3) Save image $resizeObj->saveImage($thumbFilePath, 100); // Update Player Photo Path $database->update('players', ['photo' => $thumbFileName], ['id' => $you['id']]); // Delete the fullsize image unlink($newFilePath); } else { echo 'Sorry, there was an error uploading your file.'; } } } header('Location: /');
$user = unserialize($_SESSION['user']); $results = upload($_FILES, $CONF, $db); if (isset($results)) { $filename = $results['results']['file']['name']; $file_path = $CONF['upload_dir'] . $filename; $thumbnail_path = $CONF['upload_dir'] . 'thumbnails/150_150_' . $filename; $date_added = date("Y-m-d H:i:s", time()); $file_db = $db->select('uploads', "filename=? LIMIT 1", array($filename)); if (file_exists($file_path) && $file_db) { $file_type = $file_db['type']; $pattern = "/^(image)\\/(.*)\$/"; if (preg_match($pattern, $file_type)) { $resizeObj = new resize($file_path); // *** 2) Resize image (options: exact, portrait, landscape, auto, crop) $resizeObj->resizeImage(150, 150, 'auto'); $resizeObj->saveImage($thumbnail_path, 70); $data = array("url" => $filename, "user_id" => $user->id, "date_added" => $date_added); $row_id = $db->insert($data, 'ricehalla'); $data = array("table_name" => 'ricehalla', "row_id" => $row_id, "user_id" => $user->id, "points" => 1); $db->insert($data, 'votes'); array_push($jsonArray, array('image' => array('id' => $row_id, 'url' => get_page_url("ricehalla", $CONF) . '/' . $row_id, 'image_src' => get_page_url("u", $CONF) . '/' . $filename, 'votes' => 1, 'owner' => $user->username, 'date_posted' => $date_added, 'tags' => array()))); } else { array_push($jsonArray, array('error' => $CONF['errors']['InvFile'])); } } else { array_push($jsonArray, array('error' => $CONF['errors']['NoFile'])); } } else { array_push($jsonArray, array('error' => $CONF['errors']['InvRequest'])); } } else {
$pos = strpos($_FILES['photo']['type'], "image"); if ($pos === FALSE) { $valid_file = false; $message = 'Oops! El archivo no es una imagen.'; } //if the file has passed the test if ($valid_file) { //move it to where we want it to be $ruta = '../images/grilla/' . $new_file_name; //ruta de los thumbs $ruta_thumb = '../images/grilla/thumb/' . $new_file_name; move_uploaded_file($_FILES['photo']['tmp_name'], $ruta); //creo el thumb $newThumb = new resize($ruta); $newThumb->resizeImage(150, 632, "landscape"); $exito = $newThumb->saveImage($ruta_thumb); $ruta = substr($ruta, 3); $ruta_thumb = substr($ruta_thumb, 3); $query = "UPDATE grilla SET rows = {$_POST['rows']}, cols = {$_POST['cols']}, img_url = '{$ruta}', thumb_url = '{$ruta_thumb}', prioridad = {$_POST['prioridad']}, id_curso = '{$_POST['id_curso']}', habilitado = {$_POST['habilitado']}, idioma = '{$_POST['idioma']}' WHERE grilla.id = {$id_img_grilla}"; } } } else { $query = "UPDATE grilla SET rows = {$_POST['rows']}, cols = {$_POST['cols']}, prioridad = {$_POST['prioridad']}, id_curso = '{$_POST['id_curso']}', habilitado = {$_POST['habilitado']}, idioma = '{$_POST['idioma']}' WHERE grilla.id = {$id_img_grilla}"; } $mysqli->query($query); header('Location: grilla_edit.php?accion=filtrar'); exit; } } if (isset($_POST['edicion_noticia'])) { $id_pais = json_encode($_POST['pais']);
<?php include "../db/db.php"; if (isset($_POST['Change'])) { $emp_id = $_POST['emp_id']; echo $emp_id; $pic = $_POST['dpic_usr']; // UPDATE IMAGE ---- Working $img_name = $_FILES["dpic_usr"]["name"]; $type = $_FILES["dpic_usr"]["type"]; $size = $_FILES["dpic_usr"]["size"]; $temp = $_FILES["dpic_usr"]["tmp_name"]; $error = $_FILES["dpic_usr"]["error"]; move_uploaded_file($temp, "include/dpic/" . $img_name . $emp_id); // *** Include the class include "resize-class.php"; // *** 1) Initialise / load image $resizeObj = new resize('include/dpic/' . $img_name . $emp_id); // *** 2) Resize image (options: exact, portrait, landscape, auto, crop) $resizeObj->resizeImage(137, 175, 'crop'); // *** 3) Save image $resizeObj->saveImage('include/dpic/' . $img_name . $emp_id, 100); //query img to db $usr_img = "UPDATE `eis_pic_t` SET `pic_name`='{$img_name}{$emp_id}' WHERE `emp_id`='{$emp_id}'"; mysql_query($usr_img) or die(mysql_error()); header("location: eis_admin_view_emp.php?emp_id={$emp_id}"); }
function editlogo($content, $image) { $var = explode("_", $this->args[2]); $id = $var[1]; $uploaddir = PLOGO_IMAGE_ORIGINAL; //$uploaddir2 = PLOGO_IMAGE_THUMB ; $uploaddir1 = PLOGO_IMAGE_LARGE; //$uploaddir ='/home/sibzsolu/public_html/projects/tsavostore/bannerimage/original/'; // $uploaddir1 ='/home/sibzsolu/public_html/projects/tsavostore/bannerimage/thumb/' ; // $uploaddir2 ='/home/sibzsolu/public_html/projects/tsavostore/bannerimage/large/'; //print_r($_FILES); //move_uploaded_file($image["file"]["tmp_name"],'http://projects.sibzsolutions.net/tsavostore/bannerimage/'.$filenametest) or die(); $image_type = strstr($image["file"]["name"], '.'); $file_type = $image["file"]["type"] == "image/gif" || $image["file"]["type"] == "image/jpeg" || $image["file"]["type"] == "image/jpg" || $image["file"]["type"] == "image/png" || $image["file"]["type"] == "image/swf"; if ($image["file"]["name"] != "" && $image_type != $file_type) { $lastmsg = "The Picture format is not supported, upload a supported format."; $this->dbobject->redirect($this->link, $lastmsg); } $filename = time() . $image["file"]["name"]; if (move_uploaded_file($image['file']['tmp_name'], $uploaddir . $filename)) { list($width, $height) = getimagesize($uploaddir . $filename); //echo $uploaddir.$filename; $resizeObj = new resize($uploaddir . $filename); $resizeObj->resizeImage(160, 95, 'auto'); $resizeObj->saveImage($uploaddir1 . $filename, 100); //$resizeObj -> resizeImage(110, 107,'exact'); //$resizeObj -> saveImage($uploaddir2.$filename, 100); } else { $photoError = "<br />Photo Not Uploaded."; } // Insert banner Details in banner Table $AddArray = array("logo_title" => trim($content['title']), "logo_file" => $filename, "logo_link" => $content['link'], "created_on" => date("Y-m-d H:i:s"), "logo_status" => '1'); $where = "logo_id=" . $id; $this->dbobject->update_record(LOGO_TABLE, $AddArray, $where, '', $query_echo = ''); }
function account_update() { $update_result = 1; $username = isset($_POST["username"]) ? $_POST["username"] : ""; $password = isset($_POST["password"]) ? $_POST["password"] : ""; $email = isset($_POST["email"]) ? $_POST["email"] : ""; $avatar = isset($_POST["avatar"]) ? $_POST["avatar"] : ""; $bio = isset($_POST["bio"]) ? $_POST["bio"] : ""; // social networks $twitter = isset($_POST["twitter"]) ? $_POST["twitter"] : ""; $facebook = isset($_POST["facebook"]) ? $_POST["facebook"] : ""; $tumblr = isset($_POST["tumblr"]) ? $_POST["tumblr"] : ""; $livejournal = isset($_POST["livejournal"]) ? $_POST["livejournal"] : ""; $googleplus = isset($_POST["googleplus"]) ? $_POST["googleplus"] : ""; $wordpress = isset($_POST["wordpress"]) ? $_POST["wordpress"] : ""; $blogger = isset($_POST["blogger"]) ? $_POST["blogger"] : ""; // instant messaging $im_friends_only = isset($_POST["im_friends_only"]) ? $_POST["im_friends_only"] : ""; $kik = isset($_POST["kik"]) ? $_POST["kik"] : ""; $google_talk = isset($_POST["google_talk"]) ? $_POST["google_talk"] : ""; $yahoo_messenger = isset($_POST["yahoo_messenger"]) ? $_POST["yahoo_messenger"] : ""; $msn_messenger = isset($_POST["msn_messenger"]) ? $_POST["msn_messenger"] : ""; $aol_instant_messenger = isset($_POST["aol_instant_messenger"]) ? $_POST["aol_instant_messenger"] : ""; $icq = isset($_POST["icq"]) ? $_POST["icq"] : ""; // notifications $notify_messages = isset($_POST["notify_messages"]) ? $_POST["notify_messages"] : ""; $notify_comments = isset($_POST["notify_comments"]) ? $_POST["notify_comments"] : ""; $notify_other_comments = isset($_POST["notify_other_comments"]) ? $_POST["notify_other_comments"] : ""; $notify_new_friends = isset($_POST["notify_new_friends"]) ? $_POST["notify_new_friends"] : ""; $notify_friends_posts = isset($_POST["notify_friends_posts"]) ? $_POST["notify_friends_posts"] : ""; $notify_likes = isset($_POST["notify_likes"]) ? $_POST["notify_likes"] : ""; $default_post_privacy = isset($_POST["default_post_privacy"]) ? $_POST["default_post_privacy"] : ""; $default_post_status = isset($_POST["default_post_status"]) ? $_POST["default_post_status"] : ""; $show_friends = isset($_POST["show_friends"]) ? $_POST["show_friends"] : ""; $show_friend_of = isset($_POST["show_friend_of"]) ? $_POST["show_friend_of"] : ""; $messages_friends_only = isset($_POST["messages_friends_only"]) ? $_POST["messages_friends_only"] : ""; $user_tags = isset($_POST["tags"]) ? $_POST["tags"] : ""; $clauses = array(); if ($username != "" && $email != "") { if (check_username($username)) { // first fetch the existing user record $mysqli = db_connect(); $sql = "SELECT * FROM Users WHERE Id='" . $mysqli->real_escape_string($_SESSION["user_id"]) . "'"; $result = $mysqli->query($sql); if ($result->num_rows > 0) { // check the new username is not already used // but ONLY do this if they have changed from the logged in session username $user_check = true; if ($username != $_SESSION["user_name"]) { $result = $mysqli->query("SELECT Id FROM Users WHERE UPPER(Username)=UPPER('" . $mysqli->real_escape_string($username) . "')"); if ($result->num_rows > 0) { $user_check = false; } } if ($user_check) { // if password has been reset we can change the username if (strlen($password) > 0 && $username != $_SESSION["user_name"]) { $cancel_validation = false; $clauses[] = "Username='******'"; } else { if ($username != $_SESSION["user_name"]) { $update_result = -7; } } // only do any of this if we are still ok if ($update_result >= 0) { // if password has been entered, change it if ($password != "") { $enc_password = crypt($password, $username); $clauses[] = "Password='******'"; } $clauses[] = "Email='" . $mysqli->real_escape_string($email) . "'"; if ($_FILES["avatar"]["size"] > 0) { $allowedExts = array("jpg", "jpeg", "gif", "png"); $extension = strtolower(end(explode(".", $_FILES["avatar"]["name"]))); if ($_FILES["avatar"]["size"] < 4096 * 1024) { if (in_array($extension, $allowedExts)) { $destination_filename = realpath("avatars") . "/" . $_SESSION["user_id"] . "." . $extension; $destination_filename_64 = realpath("avatars") . "/" . $_SESSION["user_id"] . "_64." . $extension; if (file_exists($destination_filename)) { unlink($destination_filename); } if (file_exists($destination_filename_64)) { unlink($destination_filename_64); } move_uploaded_file($_FILES["avatar"]["tmp_name"], $destination_filename); // make a 64 pixel version include "resize_class.php"; $resizeObj = new resize($destination_filename); $resizeObj->resizeImage(64, 64, "crop"); $resizeObj->saveImage(realpath("avatars") . "/" . $_SESSION["user_id"] . "_64." . $extension, 100); // remove the original if (file_exists(realpath($destination_filename))) { unlink(realpath($destination_filename)); } $_SESSION["user_avatar"] = realpath("avatars") . "/" . $_SESSION["user_id"] . "_64." . $extension; $clauses[] = "Avatar='avatars/" . $_SESSION["user_id"] . "_64." . $extension . "'"; } else { // wrong file extensin / format $update_result = -6; } } else { // file too big $update_result = -5; } } // Bio Text $clauses[] = "Bio=\"" . $mysqli->real_escape_string($bio) . "\""; // Social Network URLs $clauses[] = "Twitter='" . $mysqli->real_escape_string($twitter) . "'"; $clauses[] = "Facebook='" . $mysqli->real_escape_string($facebook) . "'"; $clauses[] = "Tumblr='" . $mysqli->real_escape_string($tumblr) . "'"; $clauses[] = "GooglePlus='" . $mysqli->real_escape_string($googleplus) . "'"; $clauses[] = "Wordpress='" . $mysqli->real_escape_string($wordpress) . "'"; $clauses[] = "Blogger='" . $mysqli->real_escape_string($blogger) . "'"; $clauses[] = "LiveJournal='" . $mysqli->real_escape_string($livejournal) . "'"; // IM $clauses[] = $im_friends_only != "" ? "IMFriendsOnly=" . $mysqli->real_escape_string($im_friends_only) : "IMFriendsOnly=0"; $clauses[] = "KIK='" . $mysqli->real_escape_string($kik) . "'"; $clauses[] = "YahooMessenger='" . $mysqli->real_escape_string($yahoo_messenger) . "'"; $clauses[] = "GoogleTalk='" . $mysqli->real_escape_string($google_talk) . "'"; $clauses[] = "AOLInstantMessenger='" . $mysqli->real_escape_string($aol_instant_messenger) . "'"; $clauses[] = "MSNMessenger='" . $mysqli->real_escape_string($msn_messenger) . "'"; $clauses[] = "ICQ='" . $mysqli->real_escape_string($icq) . "'"; $clauses[] = $notify_messages != "" ? "NotifyMessages=" . $mysqli->real_escape_string($notify_messages) : "NotifyMessages=0"; $clauses[] = $notify_comments != "" ? "NotifyComments=" . $mysqli->real_escape_string($notify_comments) : "NotifyComments=0"; $clauses[] = $notify_other_comments != "" ? "NotifyOtherComments=" . $mysqli->real_escape_string($notify_other_comments) : "NotifyOtherComments=0"; $clauses[] = $notify_new_friends != "" ? "NotifyNewFriends=" . $mysqli->real_escape_string($notify_new_friends) : "NotifyNewFriends=0"; $clauses[] = $notify_friends_posts != "" ? "NotifyFriendsPosts=" . $mysqli->real_escape_string($notify_friends_posts) : "NotifyFriendsPosts=0"; $clauses[] = $notify_likes != "" ? "NotifyLikes=" . $mysqli->real_escape_string($notify_likes) : "NotifyLikes=0"; $clauses[] = $default_post_privacy != "" ? "DefaultPostPrivacy=" . $mysqli->real_escape_string($default_post_privacy) : "DefaultPostPrivacy=0"; $clauses[] = $default_post_status != "" ? "DefaultPostStatus=" . $mysqli->real_escape_string($default_post_status) : "DefaultPostStatus=0"; $clauses[] = $show_friends != "" ? "ShowFriends=" . $mysqli->real_escape_string($show_friends) : "ShowFriends=0"; $clauses[] = $show_friend_of != "" ? "ShowFriendOf=" . $mysqli->real_escape_string($show_friend_of) : "ShowFriendOf=0"; $clauses[] = $messages_friends_only != "" ? "MessagesFriendsOnly=" . $mysqli->real_escape_string($messages_friends_only) : "MessagesFriendsOnly=1"; $clauses[] = "Edited=Now()"; $clauses[] = "IPEdited='" . $mysqli->real_escape_string($_SERVER["REMOTE_ADDR"]) . "'"; // join the clauses together to make the SQL update $sql_clauses = implode(",", $clauses); $sql = "UPDATE Users SET " . $sql_clauses . " WHERE Id=" . $mysqli->real_escape_string($_SESSION["user_id"]); $mysqli->query($sql); // reset session variables $_SESSION["user_name"] = $username; $_SESSION["user_email"] = $email; // remove the existing user tags $mysqli->query("DELETE FROM UserTags WHERE UserId=" . $mysqli->real_escape_string($_SESSION["user_id"])); // break the tags up into individual terms $tags = explode(",", $user_tags); if (count($tags) > 0) { // trim all tags $tags = array_map("trim", $tags); foreach ($tags as $tag) { if ($tag != "") { $tag = strtolower($tag); $tag_id = 0; // find out if the tag exists $sql = "SELECT * FROM Tags WHERE Name='" . $mysqli->real_escape_string($tag) . "'"; $result = $mysqli->query($sql); if ($result->num_rows > 0) { // if it does exist, get it's ID $row = @$result->fetch_assoc(); $tag_id = $row["Id"]; } else { // if it does not exist, add it, and get the ID $sql = "INSERT INTO Tags (Name) VALUES ('" . $mysqli->real_escape_string($tag) . "')"; $mysqli->query($sql); $tag_id = $mysqli->insert_id; } // add the tag to the UserTags list $mysqli->query("INSERT INTO UserTags (UserId,TagId,Created) VALUES (" . $mysqli->real_escape_string($_SESSION["user_id"]) . "," . $mysqli->real_escape_string($tag_id) . ",Now())"); } } } // end tags section } } else { // username is already used $update_result = -4; } } else { // cannot find record $update_result = -3; } } else { // username does not pass checks $update_result = -2; } } else { // missing form info $update_result = -1; } return $update_result; }
function edit_product() { if ($this->input->post('action') == '') { $data['product'] = $this->adminpanelbk_model->getProductDetails($this->uri->segment(3)); $this->load->view('adminpanelbk/edit_product', $data); } else { $this->form_validation->set_rules('title', 'product name', 'trim|required|min_length[3]|max_length[60]'); $this->form_validation->set_rules('price', 'price', 'trim|required|numeric'); $this->form_validation->set_rules('stock', 'stock', 'trim|required|numeric'); $this->form_validation->set_rules('cat_id', 'category', 'trim|required'); $this->form_validation->set_rules('desc', 'description', 'trim|required'); if ($this->form_validation->run() == FALSE) { $this->load->view("adminpanelbk/edit_product"); } else { $this->adminpanelbk_model->update_product($this->input->post()); if ($_FILES['file']['name'] != '') { include "lib/imageManipulation.php"; include "lib/resize-class.php"; $id = $this->input->post('item_id'); $type = substr(strtolower($_FILES['file']['name']), -4); $img_name = substr($this->input->post('title'), 0, 20); $img_name = str_replace(" ", "_", $img_name) . "_" . $id; $big_image = "images/uploads/" . $img_name . "." . $type; $med_image = "images/uploads/" . $img_name . "_med." . $type; $thumbnail = "images/uploads/" . $img_name . "_small." . $type; copy($_FILES['file']['tmp_name'], $big_image); $resizeObj = new resize($big_image); $resizeObj->resizeImage(75, 75, 'auto'); $resizeObj->saveImage($thumbnail, 100); $resizeObj = new resize($big_image); $resizeObj->resizeImage(270, 240, 'auto'); $resizeObj->saveImage($med_image, 100); $resizeObj = new resize($big_image); $resizeObj->resizeImage(300, 300, 'auto'); $resizeObj->saveImage($big_image, 100); $this->adminpanelbk_model->update_image_links($big_image, $med_image, $thumbnail, $id); } $url = base_url() . "index.php/adminpanelbk/products"; header("Location:{$url}"); exit; } } }
public function postAction() { $params = $this->request->getParams(); $content = $params['pro_detail']; $content = html_entity_decode($content, ENT_NOQUOTES, 'UTF-8'); $match = array(); $split = preg_match('/<h1.*class="pTitle".*<\\/h1>/siU', $content, $match); if ($split) { $title = preg_replace('/<h1.*class="pTitle".*>/siU', '', $match[0]); $params['pro_name'] = substr($title, 0, -5); } $split = preg_match('/<h2.*class="pHead".*<\\/h2>/siU', $content, $match); if ($split) { $pro_des = preg_replace('/<h2.*class="pHead".*>/siU', '', $match[0]); $params['pro_des'] = substr($pro_des, 0, -5); } /* upload image */ $avatarUrl = ""; $newName = ""; //var_dump($_FILES);exit; if ($_FILES["file"]["name"] != "") { $file_exts = array("jpg", "bmp", "jpeg", "gif", "png"); $upload_exts = end(explode(".", $_FILES["file"]["name"])); if (($_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/png" || $_FILES["file"]["type"] == "image/pjpeg") && $_FILES["file"]["size"] < 2000000 && in_array($upload_exts, $file_exts)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br>"; die; } else { // Enter your path to upload file here $avatarUrl = ROOT . AVATAR_PATH; if (file_exists($avatarUrl . $_FILES["file"]["name"])) { $newName = time() . $_FILES["file"]["name"]; $avatarUrl .= $newName; move_uploaded_file($_FILES["file"]["tmp_name"], $avatarUrl); } else { $newName = $_FILES["file"]["name"]; $avatarUrl .= $newName; move_uploaded_file($_FILES["file"]["tmp_name"], $avatarUrl); } } } else { echo "<div class='error'>Invalid file</div>"; die; } $params['pro_image'] = $newName; // *** 1) Initialise / load image $resizeObj = new resize($avatarUrl); // *** 2) Resize image (options: exact, portrait, landscape, auto, crop) $resizeObj->resizeImage(180, 110, 'crop'); $savePath = ROOT . AVATAR_RESIZE_PATH; // *** 3) Save image $resizeObj->saveImage($savePath . "180x110/" . $newName, 100); // *** 2) Resize image (options: exact, portrait, landscape, auto, crop) $resizeObj->resizeImage(280, 200, 'crop'); // *** 3) Save image $resizeObj->saveImage($savePath . "280x200/" . $newName, 100); } /* end upload image */ $params["url_key"] = $params['pro_name']; $id = $this->request->queryString("id"); $productModel = $this->model->get('product'); $rewriteModel = $this->model->get('rewrite'); $params["url_key"] = Helper::getInstance()->urlKey($params["url_key"], $id, $productModel->getTableName()); $i = 1; $duplicate = Helper::getInstance()->rewriteDuplicate("/" . $params["url_key"], $id, $rewriteModel->getTableName(), "request_path"); while ($duplicate) { $params["url_key"] .= "-" . $i++; $duplicate = Helper::getInstance()->rewriteDuplicate("/" . $params["url_key"], $id, $rewriteModel->getTableName(), "request_path"); } $rewriteParams = array(); $rewriteParams['request_path'] = "/" . $params['url_key']; $rewriteParams['target_path'] = '/default/product/viewdetail/id/'; //$publicTime = $params['public_time']; //$publicTime = Helper::getInstance()->convertDate($params['public_time']); //$params['public_time'] = $publicTime. " ".$params['sltH'].":".$params['sltM'].":00"; //unset($params['sltH']); //unset($params['sltM']); unset($params['file']); if ($id == "") { $productModel->addNew($params); //var_dump($params);exit; $productInfo = $productModel->getInfoByKey($params["url_key"]); $rewriteParams['target_path'] .= $productInfo['pro_id']; $rewriteModel->addNewRewrite($rewriteParams); } else { $productInfo = $productModel->getProductInfo($id); if ($productInfo['url_key'] != $params['url_key']) { $rewriteInfo = $rewriteModel->getRewriteInfo("/" . $productInfo['url_key']); $rewriteParams['target_path'] .= $id; $rewriteModel->updateRewrite($rewriteInfo['id'], $rewriteParams); } $productModel->update($id, $params); } $this->redirect("/admin/product/list"); }
function addreview($content, $image) { // Insert Review Details in Review Table //print_r($content); //exit; $imagenm = ""; $uploaddir = "../review/original/"; $uploaddir1 = "../review/thumb/"; $uploaddir2 = "../review/large/"; $imagenm = time() . $image['packimg']['name']; $photoError = ""; if ($image['packimg']['name'] != '') { if (move_uploaded_file($image['packimg']['tmp_name'], $uploadDir . $imagenm)) { list($width, $height) = getimagesize($uploadDir . $imagenm); $resizeObj = new resize($uploadDir . $imagenm); $resizeObj->resizeImage(671, 400, 'exact'); $resizeObj->saveImage($uploaddir1 . $imagenm, 100); $resizeObj->resizeImage(110, 107, 'exact'); $resizeObj->saveImage($uploaddir2 . $imagenm, 100); } else { $photoError = "<br />Photo Not Uploaded."; $this->dbobject->redirect($this->link . "addreview/", "Photo not Uploaded!"); } } else { $photoError = "<br />Photo Not Uploaded."; $this->dbobject->redirect($this->link . "addreview/", "Photo not Uploaded!"); } /*$filename=''; if($this->dbobject->validImage($image['packimg']['name'])){ $photoError = ""; if($this->functionsobject->LoadImage($image['packimg'],75,500)) { $filename = $this->functionsobject->saveLarge($uploaddir); $filename = $this->functionsobject->saveThumb($uploaddir1 , 110); $filename = $this->functionsobject->saveLargeThumb($uploaddir2, 75, 303,183); $this->functionsobject->deleteTempImage(); // delete Temp Images } else { $photoError = "<br />Photo Not Uploaded."; $this->dbobject->redirect($this->link."addreview/","Photo not Uploaded!"); } }*/ $AddArray = array("addedby" => $content['addedby'], "rating" => $content['rating'], "comments" => $content['description'], "profileimage" => $filename, "created" => date('Y-m-d'), "del_status" => '1'); //print_r($AddArray); exit; $this->dbobject->insert_record(REVIEW_TABLE, $AddArray, '', $query_echo = ''); $lastmsg = "Review Inserted Successfully"; //----------------- End of upload review Images------ $this->dbobject->redirect($this->link, $lastmsg); }
</head> <body> <a href="index.php"><img src="img/cylinder2.jpg" alt=""></a> <div> <a href="index1.php"><img src="img/cylinder1.jpg" alt="" id="a1"></a> <a href="index2.php"><img src="img/cylinder2.jpg" alt="" id="a2"></a> <a href="index3.php"><img src="img/cylinder3.jpg" alt="" id="a3"></a> </div> <form action=""> <p><b>input picture for print</b></p> <p><input type="text" name="width" value="111">enter width<Br> <input type="text" name="height" value="111">enter height<Br> <input type="text" name="formats" value="jpeg">enter formats</p> <p><input type="submit"></p> <?php $width = $_GET['width']; $height = $_GET['height']; $formats = $_GET['formats']; if ($GLOBALS['width'] > 0 && $GLOBALS['height'] > 0) { include "resize.class.php"; $resizeObj = new resize('img/cylinder2.jpg'); $resizeObj->resizeImage($GLOBALS['width'], $GLOBALS['height'], 'crop'); $resizeObj->saveImage('cylinder2.' . $formats, 100); } ?> </form> </body> </html>
} // INSERT IMAGE $img_name = $_FILES["dpic_usr"]["name"]; $type = $_FILES["dpic_usr"]["type"]; $size = $_FILES["dpic_usr"]["size"]; $temp = $_FILES["dpic_usr"]["tmp_name"]; $error = $_FILES["dpic_usr"]["error"]; move_uploaded_file($temp, "../include/dpic/" . $img_name); // *** Include the class include "resize-class.php"; // *** 1) Initialise / load image $resizeObj = new resize('../include/dpic/' . $img_name); // *** 2) Resize image (options: exact, portrait, landscape, auto, crop) $resizeObj->resizeImage(137, 175, 'crop'); // *** 3) Save image $resizeObj->saveImage('../include/dpic/' . $img_name, 100); //query img to db $usr_img = "INSERT INTO eis_pic_t(emp_id,pic_name) VALUES(LAST_INSERT_ID(),'{$img_name}')"; mysql_query($usr_img) or die(mysql_error()); /* START */ $count1 = 1; $count2 = 2; $count3 = 3; $count4 = 4; $count5 = 5; $count6 = 6; $count7 = 7; $count8 = 8; $count9 = 9; $count10 = 10; $count11 = 11;
/** * @param $data * @param string $noimage * @param $size * @param string $quality * @param string $number * @param string $resizeType * @param bool|true $grabRemote * * @return array|string */ public function getImage($data, $noimage = '', $size, $quality = '90', $number = '1', $resizeType = 'crop', $grabRemote = true) { $resizeType = $resizeType == '' || !$resizeType ? 'auto' : $resizeType; $quality = $quality == '' || !$quality ? '100' : $quality; $noimage = Url::getBase() . $noimage; // Задаём папку для загрзки картинок по умолчанию. $uploadDir = '/storage/social/'; // Задаём папку для картинок $imageDir = $uploadDir . $size . '/'; $dir = ROOT_DIR . $imageDir; // $data = stripslashes($data); $arImages = array(); if (preg_match_all('/<img(?:\\s[^<>]*?)?\\bsrc\\s*=\\s*(?|"([^"]*)"|\'([^\']*)\'|([^<>\'"\\s]*))[^<>]*>/i', $data, $m)) { $i = 1; // Счётчик // Если регулярка нашла картинку — работаем. if (isset($m[1])) { foreach ($m[1] as $key => $url) { // Если номер картинки меньше, чем требуется — проходим мимо. if ($number != 'all' && $i < (int) $number) { // Не забываем прибавить счётчик. $i++; continue; } $imageItem = $url; // Удаляем текущий домен из строки. $urlShort = str_ireplace(Url::getBase(), '', $imageItem); // Проверяем наша картинка или чужая. $isRemote = preg_match('~^http(s)?://~', $urlShort) ? true : false; // Проверяем разрешено ли тянуть сторонние картинки. $grabRemoteOn = $grabRemote ? true : false; // Отдаём заглушку, если ничего нет. if (!$urlShort) { $imageItem = $noimage; continue; } // Если внешняя картинка и запрещего грабить картинки к себе — возвращаем её. if ($isRemote && !$grabRemoteOn) { $imgResized = $urlShort; continue; } // Работаем с картинкой // Если есть параметр size — включаем ресайз картинок if ($size) { // Создаём и назначаем права, если нет таковых if (!is_dir($dir)) { @mkdir($dir, 0755, true); @chmod($dir, 0755); } if (!chmod($dir, 0755)) { @chmod($dir, 0755); } // Присваиваем переменной значение картинки (в т.ч. если это внешняя картинка) $imgResized = $urlShort; // Если не внешняя картинка — подставляем корневю дирректорию, чтоб ресайзер понял что ему дают. if (!$isRemote) { $imgResized = ROOT_DIR . $urlShort; } // Определяем новое имя файла $fileName = $size . '_' . $resizeType . '_' . strtolower(basename($imgResized)); // Если картинки нет в папке обработанных картинок if (!file_exists($dir . $fileName)) { // Если картинка локальная, или картинка внешняя и разрешено тянуть внешние — обработаем её. if (!$isRemote || $grabRemoteOn && $isRemote) { // Разделяем высоту и ширину $imgSize = explode('x', $size); // Если указана только одна величина - присваиваем второй первую, будет квадрат для exact, auto и crop, иначе класс ресайза жестоко тупит, ожидая вторую переменную. if (count($imgSize) == '1') { $imgSize[1] = $imgSize[0]; } // @TODO: по хорошему надо бы вынести ресайз в отдельный метод на случай, если понадобится другой класс для ресайза. // Подрубаем класс для картинок $resizeImg = new resize($imgResized); $resizeImg->resizeImage($imgSize[0], $imgSize[1], $resizeType); $resizeImg->saveImage($dir . $fileName, $quality); // Сохраняем картинку в заданную папку } } $imgResized = Url::getBase() . '/storage' . $imageDir . $fileName; } else { // Если параметра imgSize нет - отдаём исходную картинку $imgResized = $urlShort; } // Отдаём дальше результат обработки. $imageItem = $imgResized; $arImages[$i] = $imageItem; if ($number == $i) { break; } $i++; } } } else { // Если регулярка не нашла картинку - отдадим заглушку $arImages[$number] = $noimage; } // Если хотим все картинки — не вопрос, получим массив. if ($number == 'all') { return $arImages; } // По умолчанию возвращаем отдну картинку (понимаю, что метод должен возвращать всегда один тип данных, но это сделано из-за совместимости версий) return $arImages[$number]; }
// echo "Upload: " . $_FILES["vendorLogo"]["name"] . "<br />"; // echo "Type: " . $_FILES["vendorLogo"]["type"] . "<br />"; // echo "Size: " . ($_FILES["vendorLogo"]["size"] / 1024) . " Kb<br />"; // echo "Temp file: " . $_FILES["vendorLogo"]["tmp_name"] . "<br />"; $filename = $config_basedir . "images/vendor/" . $_FILES["vendorLogo"]["name"]; $location = $config_web_basedir . "images/vendor/" . $_FILES["vendorLogo"]["name"]; if (file_exists($location)) { $log->Warn("Failure: " . $_FILES["vendorLogo"]["name"] . " already exists (File: " . $_SERVER['PHP_SELF'] . ")"); } else { move_uploaded_file($_FILES['vendorLogo']['tmp_name'], $location); // *** 1) Initialize / load image $resizeObj = new resize($location); // *** 2) Resize image (options: exact, portrait, landscape, auto, crop) $resizeObj->resizeImage(16, 16, 'auto'); // *** 3) Save image $resizeObj->saveImage($location, 100); } } } else { $errors['fileInvalid'] = "Invalid File"; $log->Warn("Failure: Invalid File(File: " . $_SERVER['PHP_SELF'] . ")"); $_SESSION['errors'] = $errors; session_write_close(); header("Location: " . $config_basedir . "vendors.php?error"); exit; } } else { /* set location variable as defaultImg for later use in SQL statement, reason is user is not obliged to upload a file*/ $filename = "images/logos/rconfig16.png"; } /* end validate */
function updatepage($content, $id) { global $databaseobject; $this->dbobject = $databaseobject; $photo_data = $_FILES['photo']; //echo '<pre>'; print_r($photo_data); die; $photo = $photo_data['name']; if ($photo = $photo_data['name'] !== "") { $Imgfilename = trim($photo_data['name']); } else { $Imgfilename = trim($content['imgname']); } $tmp_name = $photo_data['tmp_name']; $test = getcwd(); $uploads_dir = $test . "/uploads"; $update = array("page_name" => $content['page_name'], "page_content" => $content['editor1'], "image_name" => $Imgfilename, "del_status" => 1); $imgtw = 900; $imgth = 300; $imglw = 900; //This is for landing(index) page images $imglh = 300; //This is for landing(index) page images // Upload original images $fileName = $photo_data['name']; $fileTmpLoc = $photo_data["tmp_name"]; $size = getimagesize($photo_data['tmp_name']); //echo '<pre>';print_r($size);die; $imgtw = 900; $imgth = 300; $imglw = 900; $imglh = 300; // Upload original images $orgimgPath = getcwd() . '/uploads'; move_uploaded_file($photo_data["tmp_name"], $orgimgPath . $Imgfilename); //$dsa =getcwd().'/resize-class.php'; //include($dsa); $largePath = getcwd() . '/uploads/small_images/'; //Resize image for large file $resizeObj = new resize($orgimgPath . $Imgfilename); $resizeObj->resizeImage($imglw, $imglh, 'auto'); // exact,portrait , landscape,crop,auto $resizeObj->saveImage($largePath . $Imgfilename, 100); $where = "pageid =" . $id; $msg = "Page Updated Successfully"; if ($this->dbobject->count_row("SELECT * FROM " . BUSINESS_TABLE . " WHERE page_name='" . $content['page_name'] . "' AND pageid!=" . $id) > 0) { $this->dbobject->redirect($this->link . "editbusiness/" . $id . "/", "Page Name is already in user"); } else { $databaseobject->update_record(BUSINESS_TABLE, $update, $where, $msg, ''); $this->dbobject->redirect($this->link, "Page Data Updated Successfully"); } }
public function updateanduploadimg($nproduct_id, $newname, $tmpname, $oper = '') { $newname = preg_replace('/\\s+/', '', $newname); /*remove whitespaces from filename*/ $ret = ''; $this->db->query("BEGIN"); $sql = "UPDATE accessories SET aimgname='" . $newname . "' WHERE aid=" . $nproduct_id . ""; //echo $sql;die(); $res = $this->db->query($sql); /*if($categry == 1) { $imgpath=$_SERVER['DOCUMENT_ROOT']."/compare/car/".$newname; } else if($categry == 2) {*/ $imgpath = $_SERVER['DOCUMENT_ROOT'] . "/server/" . $newname; //echo $imgpath;die(); //} //echo $sql; //echo $imgpath;die(); if ($res) { if ($newname != '') { if (move_uploaded_file($tmpname, $imgpath)) { $ret = "OK"; $resize = new resize($imgpath); $resize->resizeImage(270, 320, 'auto'); $resize->saveImage($imgpath, 80); } else { $ret = "ERR"; } } } //if($oper == 'Update') $ret = "OK"; if ($ret == "OK") { $this->db->query("COMMIT"); } else { $this->db->query("ROLLBACK"); } return $ret; }