function process_query() { $upload_dir = '../img/'; $upload_url_dir = '/img/'; $upload_file = false; try { $new_name = rand(0, PHP_INT_MAX) . '.jpg'; $upload_file = $upload_dir . basename($_FILES['image']['name']); move_uploaded_file($_FILES['image']['tmp_name'], $upload_file); if (!resize_img($upload_file, $upload_dir . $new_name)) { throw new Exception(); } else { $data = $upload_url_dir . $new_name; $label = 'url'; $status = RESPONSE_STATUS_OK; } } catch (Exception $e) { $data = 'file is not image of .jpg .gif .png formats'; $label = 'error'; $status = RESPONSE_STATUS_FAIL; } finally { if ($upload_file) { unlink($upload_file); } } api_echo_as_json($data, $label, $status); }
function createImage($imgSrc, $imgDest, $width, $height, $crop = true, $quality = 100) { if (JFile::exists($imgDest)) { $info = getimagesize($imgDest, $imageinfo); if ($info[0] == $width && $info[1] == $height) { return; } } if (JFile::exists($imgSrc)) { $info = getimagesize($imgSrc, $imageinfo); $sWidth = $info[0]; $sHeight = $info[1]; resize_img($imgSrc, $imgDest, $width, $height, $crop, $quality); } }
if (!file_exists($dir . '/slideshow') || !is_dir($dir)) { mkdir($dir . '/slideshow'); } if (!file_exists($dir . '/thumbnail') || !is_dir($dir)) { mkdir($dir . '/thumbnail'); } if (!file_exists($dir . '/manager') || !is_dir($dir)) { mkdir($dir . '/manager'); } // for not replace files $i = ''; while (file_exists($dir . "/original/{$filename}{$i}.{$ext}")) { $i++; } $filename = "{$filename}{$i}.{$ext}"; if (!$file->save("{$dir}/original/{$filename}")) { $response['message'] = "Can't save file here: {$dir}/original/{$filename}"; } else { $imagesize = getimagesize("{$dir}/original/{$filename}", $imageinfo); $mime = $imagesize['mime']; resize_img($dir . "/original/{$filename}", $dir . "/manager/{$filename}", 128, 96); $response['success'] = true; $response['file'] = strtolower($filename); } } } } } } } echo json_encode($response);
/** * Function wc_slideshow. * Produces a slider from list of image URLs * Uses Nivo-Slider Scripts / Library * http://nivo.dev7studios.com/ * @slider_height (string) - height of the slider in px * @slider_width (string) - width of the slider in px * @effect (string) - use different effects * Returns timthumb URL. */ function wc_slideshow($atts, $content = null) { global $sa_general; extract(shortcode_atts(array('slider_height' => '0', 'slider_width' => '668', 'effect' => 'boxRandom', 'showtitle' => true), $atts)); $title = ''; $preStyle = ''; $IMG_TAGS = ''; $general_options = get_option('sa_general', $sa_general); $use_timthumb = $general_options['use_timthumb']; $slider_height_att = ''; if ($slider_height > 0) { $slider_height_att = "height:'" . $slider_height . "'"; } wp_print_scripts('jquery.nivo.slider'); $effect = strtolower($effect); /* Allows User to select their own slider effect. They pass this in with the effect=boxRain attribute. */ switch ($effect) { case 'slicedown': $effect = "sliceDown"; break; case 'sliceup': $effect = "sliceUp"; break; case 'sliceupdown': $effect = "sliceUpDown"; break; case 'fold': $effect = "fold"; break; case 'fade': $effect = "fade"; break; case 'boxrain': $effect = "boxRain"; break; default: $effect = "boxRandom"; } // Trim all space off $content. $content = trim($content); if ($content > "") { $doc = new DOMDocument(); $doc->loadHTML($content); $imageTags = $doc->getElementsByTagName('img'); //$imageHref = $doc->getElementsByTagName('a'); foreach ($imageTags as $tag) { // $content .= $tag->getAttribute('src') ."\n"; $IMG_TAGS .= $tag->getAttribute('src') . "\n"; } } // Remove all IMG TAGS $content = preg_replace("/<img[^>]+\\>/i", "", $content); // Remove all HREF TAGS $content = preg_replace("/<\\/?a(\\s+.*?>|>)/", "", $content); // ADD Everything together. $content = $content . "\n" . $IMG_TAGS; // Organize each line of content into an array. $images = !empty($content) ? preg_split("/(\r?\n)/", $content) : ''; //print_r($images); // Check if something exists and that it is an array. if (!empty($images) && is_array($images)) { // Clear the $content string. $content = ''; // For each image in the array, check for URL's and create the Nivo Slider Content. foreach ($images as $image) { // Strip any HTML Tags $image = trim(strip_tags($image)); // Separate the image path and link url (looks for comma to distinguish). $pos = strpos($image, ','); // Look for , and if it exists then we have to split URL and Image path. if ($pos === false) { $imagePath = $image; $imageLink = ''; } else { list($imagePath, $imageLink) = split(',', $image); } // Clean up any leading or trailing spaces. Make sure to remove http:// and https:// $imageLink = trim($imageLink); $imageLink = remove_http($imageLink); // If image path is no empty and it's great than nothing, continue... if (!empty($imagePath) && $imagePath > '') { // We now use get_attachment_id_from_src() to find the postID of the image attachement (custom function under /functions/common.php). $postid = get_attachment_id_from_src($imagePath); // Get the image size. $image_attributes = wp_get_attachment_image_src($postid, 'full'); // returns an array // Return the post object and title $postid = get_post($postid); if ($showtitle) { $title = $postid->post_title; } // Clear tmp vars. $imageLinkOpen = ""; $imageLinkClose = ""; // Build the tmp vars for the image link (if one was supplied) if ($imageLink > "") { $imageLinkOpen = "<a href='http://" . $imageLink . "'>"; $imageLinkClose = "</a>"; } // TIMTHUMB OPTION if ($use_timthumb) { // Build and add on to the $content string. $content .= $imageLinkOpen . "<img src='" . resize_img($image_attributes[0], $slider_width, $slider_height) . "' width='" . $slider_width . "' " . $slider_height_att . " alt='" . $title . "' title='" . $title . "' data-transition='" . $effect . "' />" . $imageLinkClose; } else { // DEFAULT RESIZING OPTION $content .= $imageLinkOpen . "<img src='" . $imagePath . "' width='" . $slider_width . "' " . $slider_height_att . " alt='" . $title . "' title='" . $title . "' data-transition='" . $effect . "' />" . $imageLinkClose; } } //end IF } // END FOR EACH $preHTML = "<div class=\"slider-wrapper theme-default\">\r\n\t\t\t\t\t<div class=\"ribbon\"></div>\r\n\t\t\t\t\t<div id=\"slider\" class=\"nivoSlider\" style=\"max-width:" . $slider_width . "px\">"; $postHTML = "</div>\n</div>"; return $preStyle . $preHTML . $content . $postHTML; } // END IF }
"> <!-- BEGIN .post-content --> <div class="post-content clearfix"> <div class="post-thumb"> <?php if (has_post_thumbnail()) { ?> <div class="post-thumb"> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "><?php resize_img("width=280&height=140"); ?> </a> </div> <?php } ?> </div> <h4 class="entry-title"><a href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title(); ?> "><?php the_title();
<?php session_start(); include_once 'includes/connect.php'; include_once 'includes/functions.php'; $title = 'Danny\'s site'; ?> <html> <head> <title><?php echo $title; ?> </title> <link rel="stylesheet" href="includes/style.css" type="text/css"> </head> <body> <div id="wrapper"> <center><a href="http://danny.com"><?php echo resize_img('includes/header.png'); ?> </a></center> <div id="content"> <a href="signin.php">signin</a> | <a href="signup.php">signup</a><br />
$target_file = './' . $dir['images'] . $clean_file; if (file_exists($target_file)) { $i = 2; while (file_exists($target_file) && $i < 100) { $clean_file_name = friendly_url($source_file['filename']) . '-' . $i; $clean_file = $clean_file_name . '.' . $clean_file_ext; $target_file = './' . $dir['images'] . $clean_file; $i++; } } move_uploaded_file($_FILES['file']['tmp_name'], $target_file); list($img_width, $img_height) = getimagesize($target_file); if (isset($img_width) && !empty($img_width) && isset($img_height) && !empty($img_height)) { $thumb_size = isset($conf['admin_thumb_size']) && is_numeric($conf['admin_thumb_size']) ? $conf['admin_thumb_size'] : $default['thumb_size']; #if ($img_width > $thumb_size || $img_height > $thumb_size) { resize_img($target_file, $thumb_size, './' . $dir['thumbs'] . '_' . $clean_file); #} $files_file = file($file['files']); $files_file_lines = ''; foreach ($files_file as $single_line) { $file_data = explode(DELIMITER, $single_line); if (substr($file_data[0], 0, 2) == '<?') { $auto_increment_id = trim($file_data[1]); } else { $files_file_lines .= $single_line; } } $file_size = filesize($target_file); $files_file_content = SAFETY_LINE . DELIMITER . ($auto_increment_id + 1) . "\n" . $files_file_lines; $files_file_content .= $auto_increment_id . DELIMITER . $clean_file_name . DELIMITER . $clean_file_ext . DELIMITER . $file_size . DELIMITER . mn_time() . DELIMITER . 'images' . DELIMITER . $img_width . DELIMITER . $img_height . DELIMITER . $_SESSION['mn_user_id'] . DELIMITER . $file_gallery . DELIMITER . $file_folder . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . "\n"; mn_put_contents($file['files'], $files_file_content);
<?php } ?> </div> <?php } elseif (has_post_thumbnail()) { ?> <div class="post-thumb"> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> " ><?php resize_img("width=205&height=140"); ?> </a> </div> <?php } ?> <h2 class="entry-title"><a href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title(); ?> "><?php the_title(); ?>
$custom_error['jquery-upload-file-error']="File already exists"; echo json_encode($custom_error); die(); */ $error = $_FILES["file"]["error"]; //You need to handle both cases //If Any browser does not support serializing of multiple files using FormData() if (!is_array($_FILES["file"]["name"])) { $fileName = $_FILES["file"]["name"]; move_uploaded_file($_FILES["file"]["tmp_name"], $output_dir . $fileName); $imgSize = getimagesize($output_dir . $fileName); if ($imgSize[0] > 600) { resize_img($output_dir, $fileName, $output_dir, 600, ''); } resize_img($output_dir, $fileName, $thumbs_dir, 100, 'thumb'); $ret[] = $fileName; } else { $fileCount = count($_FILES["file"]["name"]); for ($i = 0; $i < $fileCount; $i++) { $fileName = $_FILES["file"]["name"][$i]; move_uploaded_file($_FILES["file"]["tmp_name"][$i], $output_dir . $fileName); $imgSize = getimagesize($output_dir . $fileName); if ($imgSize[0] > 600) { resize_img($output_dir, $fileName, $output_dir, 600, ''); } resize_img($output_dir, $fileName, $thumbs_dir, 100, 'thumb'); $ret[] = $fileName; } } echo json_encode($ret); }
/** * @param $file (string) - путь к большой картинке * @param $watermark (string) - путь к водяному знаку * @param $coords (array) - массив координат * @param $opacity (double) - значение прозрачности * @param $dist (string) - путь к сгенерированной картинке * @param $flag (string) - флаг - одна картинка накладывается или растрируется * * */ function merge_watermark($file, $watermark, $coords, $opacity, $dist, $flag) { $data = array(); if (!file_exists($file) || !file_exists($watermark)) { $data['status'] = "NO"; $data['message'] = "Большая картинка или водяной знак не загружены"; $data['url'] = ''; } else { // Проверяем, есть ли такая папка if (!file_exists($dist)) { mkdir($dist, 777); } // считываем сигнатуру изображения $file_sign = exif_imagetype($file); $watermark_sing = exif_imagetype($watermark); // Если были переданы не верные картинки if (!$file_sign || !$watermark_sing) { $data['status'] = "NO"; $data['message'] = "Были загружены некорректные изображения"; $data['url'] = ''; } else { // Объекты $file_img_object = create_image_object($file_sign, $file); $watermark_img_object = create_image_object($watermark_sing, $watermark); // если не удалось создать один из объектов if (!$file_img_object['object'] || !$watermark_img_object['object']) { $data['status'] = "NO"; $data['message'] = "Возникла ошибка при генерации изображения"; $data['url'] = ''; } else { // уменьшаем изображение $file_img_object['object'] = resize_img($file, $file_img_object, 648, 536); // упрощаем массив координат $simple_coords = simpled_coords($coords, $flag); // не верно переданны координаты if (!$simple_coords) { $data['status'] = "NO"; $data['message'] = "Не верное переданны координаты"; $data['url'] = ''; } else { // накладываем изображения по координатам foreach ($simple_coords as $item_coord) { imagecopymerge($file_img_object['object'], $watermark_img_object['object'], $item_coord['left'], $item_coord['top'], 0, 0, $watermark_img_object['size']['width'], $watermark_img_object['size']['height'], $opacity); } // получаем результат $result = save_image($file_img_object, $dist); // Если не получилось сгенерировать изображение if (!$result['flag']) { $data['status'] = "NO"; $data['message'] = "Ошибка сохранения изображения"; $data['url'] = ''; } else { $data['status'] = "OK"; $data['message'] = "Изображение успешно сгенерированно"; $data['url'] = $result['src']; } } } } } echo json_encode($data); exit; }
$tmp_thumb = explode('.', $filename); $thumb = ''; $cnt = count($tmp_thumb) - 1; for ($i = 0; $i < $cnt; $i++) { $thumb .= $tmp_thumb[$i]; } $tmp_thumb = $thumb; $i = 0; while (file_exists("{$path}{$thumb}.{$format}")) { $i++; $thumb = "{$tmp_thumb}_copy{$i}"; } $filename = "{$thumb}.{$format}"; $targetFile = "{$path}{$filename}"; if ($_FILES['Filedata']['size'] > $config['size']) { die(ERROR_SAVE_FILE_3); } if (!move_uploaded_file($tempFile, $targetFile)) { die(ERROR_SAVE_FILE_2); } if (format($filename, 1, '.jpg.jpeg.gif.png')) { resize_img($path, $filename, $thumb, $config); die('1'); } die('1'); } else { die(ERROR_SAVE_FILE_1); } } else { die('PERMISSION DENIED'); }
imagedestroy($dst); return FALSE; } $res = FALSE; switch($type) { case IMAGETYPE_GIF: $res = imagegif($dst, $destination); break; case IMAGETYPE_JPEG: $res = imagejpeg($dst, $destination, 100); break; case IMAGETYPE_PNG: $res = imagepng($dst, $destination); break; } imagedestroy($src_copy); imagedestroy($dst); if( ! $res ) { return FALSE; } if( ! file_exists($destination) ) { return FALSE; } chmod( $destination, 0777 ); return TRUE; */ } resize_img('aaa.jpg', '', 120, 80); //echo 'OK';
$save_path = "{$path}{$filename}.{$type}"; if (copy($image, $save_path)) { if (filesize($save_path) > $config['size']) { $die = ' <script type="text/javascript"> with(window.top){ popupMenu({title: lng.ERROR, main: \'<p class="center">\' + lng.SAVE_FILE_ERROR_3 + "</p>"}); } if(parent){ parent.pixlr.overlay.hide(); } </script> '; die($die); } resize_img("{$folder}{$path}", "{$filename}.{$type}", $filename, $config); echo ' <script type="text/javascript"> with(window.top){ getDir(realPath); setView(); } if(parent) parent.pixlr.overlay.hide(); </script> '; } else { echo ' <script type="text/javascript"> with(window.top){ popupMenu({title: lng.ERROR, main: \'<p class="center">\' + lng.SAVE_FILE_ERROR_2 + "</p>"}); }
} else { if ($imageinfo[0] < 100 && $_SESSION['epUser']['parent'] != 2) { $error = 'Image must be wider than 100 pixels.'; unlink($file_path . $temp_id); } else { $image_title = mysql_real_escape_string(preg_replace(array('/\\.([a-z0-9]+)$/i', '/[^a-z0-9]+/i'), array('', '-'), $_FILES[$element]['name'])); $image_position = dbq("SELECT MAX(`position`) AS `position` FROM `wp_image_gallery` WHERE `parent` = {$parentID}"); if (!is_array($image_position)) { $image_position = 1; } else { $image_position = $image_position[0]['position'] + 1; } $insert_id = dbq("INSERT INTO `wp_image_gallery` (`parent`, `title`, `position`) VALUES ('{$parentID}', '{$image_title}', '{$image_position}')"); dbq("UPDATE wp_structure SET modified = NOW() WHERE id = {$parentID}"); foreach ($cfg['img'] as $img_key => $img_val) { resize_img($file_path . $temp_id, $file_path . "{$insert_id}-{$img_key}.jpg", $cfg['img'][$img_key][0], $cfg['img'][$img_key][1], $cfg['img'][$img_key][2], $cfg['img'][$img_key][3], $cfg['img'][$img_key][4], $cfg['img'][$img_key][5], $cfg['img'][$img_key][6], $cfg['img'][$img_key][7]); } /* resize_img ($file_path . $temp_id, $file_path . "{$insert_id}-s.jpg", $cfg['img']['small'][0], $cfg['img']['small'][1], $cfg['img']['small'][2], $cfg['img']['small'][3], $cfg['img']['small'][4], $cfg['img']['small'][5], $cfg['img']['small'][6], $cfg['img']['small'][7]); resize_img ($file_path . $temp_id, $file_path . "{$insert_id}-m.jpg", $cfg['img']['medium'][0], $cfg['img']['medium'][1], $cfg['img']['medium'][2], $cfg['img']['medium'][3], $cfg['img']['medium'][4], $cfg['img']['medium'][5], $cfg['img']['medium'][6], $cfg['img']['medium'][7]); resize_img ($file_path . $temp_id, $file_path . "{$insert_id}-l.jpg", $cfg['img']['large'][0], $cfg['img']['large'][1], $cfg['img']['large'][2], $cfg['img']['large'][3], $cfg['img']['large'][4], $cfg['img']['large'][5], $cfg['img']['large'][6], $cfg['img']['large'][7]); */ unlink($file_path . $temp_id); $msg = 'SUCCESS'; } } } else { $error = 'File upload error!'; } } else { if ($element == 'jq-files' || $element == 'jq-files1' || $element == 'jq-files2' || $element == 'jq-files3') {
$thumb_path = "../../contents/thumbs/"; require "../../includes/functions.inc.php"; if (is_dir($path)) { $dir_handle = opendir($path); $img = array(); $i = 0; while (($dir = readdir()) !== false) { if (is_dir($dir)) { continue; } else { $extensions = array('jpg', 'jpeg', 'png', 'gif'); if (in_array(get_ext($dir), $extensions)) { $img[$i]['imgName'] = $dir; $imgSize = getimagesize($path . $dir); $img[$i]['imgWidth'] = $imgSize[0]; $img[$i]['imgHeight'] = $imgSize[1]; $img[$i]['imgPath'] = $path . $dir; $img[$i]['thumbPath'] = $thumb_path . $dir . '.thumb.' . get_ext($dir); $img[$i]['fileSize'] = filesize($path . $dir); if (!file_exists($img[$i]['thumbPath'])) { resize_img($path, $dir, $thumb_path, 100, 'thumb'); } $i++; } else { continue; } } } closedir(); echo json_encode($img); }
$rand = rand(0, 100); $tpl = '{"Dir": ['; while ($read = readdir($dir)) { if (is_dir($read) == 1 && $read != '.' && $read != '..') { $tpl .= '{"Name":"' . $read . '","Type":"Cat","Format":"1","Filesize":"0"},'; } else { if (strpos($read, '.') !== 0) { $name = explode('.', $read); $r_name = ''; $cnt = count($name) - 1; for ($i = 0; $i < $cnt; $i++) { $r_name .= $name[$i]; } if (format($read, 1, '.jpeg.jpg.png.gif')) { if (!file_exists("{$dir_str}.thumb_{$r_name}." . format($read))) { resize_img($dir_str, $read, $r_name, $config); } if (!file_exists("{$dir_str}.thumb_user_{$read}")) { $thumb = 'None'; } else { $thumb = 'Exists'; } $tpl .= '{"Name":"' . $r_name . '","Type":"Img","Thumb":"' . $thumb . '","Format":"' . format($read) . '","Filesize":"' . filesize($read) . '"},'; } else { $tpl .= '{"Name":"' . $r_name . '","Type": "File","Format":"' . format($read) . '","Filesize":"' . filesize($read) . '"},'; } } } } closedir($dir); $tpl .= '], "SortType": "' . $config['sortType'] . '", "View": "' . $config['view'] . '", "ResizeThumb": "' . $config['resizeThumb'] . '"}';
/** * 移动端图片处理 */ public function mbimagePrase() { // 配置文件 global $uploadConfig; // 图片上传全局配置 $imageUpload = $uploadConfig['IMAGE_UPLOAD']; //源图片地址 $ocimg = $_POST['picurl']; $tcimg = $_POST['tpicurl']; //目标图片保存路径使用绝对地址 $tpath = $imageUpload['FILE_PATH'] . $_POST['tpath']; // 创建图像流 $imageInfo = getimagesize($ocimg); switch ($imageInfo[2]) { case 1: $image2 = imagecreatefromgif($ocimg); break; case 2: $image2 = imagecreatefromjpeg($ocimg); break; case 3: $image2 = imagecreatefrompng($ocimg); break; default: break; } //图片宽高比 $width = $imageInfo[0]; $height = $imageInfo[1]; //计算截图坐标 //目标图片比源图片更宽更高 if ($_POST['twidth'] > $width || $_POST['theight'] > $height) { $t = round($_POST['twidth'] / $_POST['theight'], 2); //目标图片宽高比 $s = round($width / $height, 2); //原图宽高比 $cimg = $ocimg; //以图片高为标准,截取宽度 if ($t < $s) { $realw = ceil($height * round($_POST['twidth'] / $_POST['theight'], 2)); $realh = $height; $data['px'] = floor(($width - $realw) / 2); //截图X坐标为px $data['py'] = 0; //截图Y坐标为py $data['pw'] = $realw; //截图宽度为pw $data['ph'] = $realh; //截图高度为ph } else { $realw = $width; $realh = ceil($width * round($_POST['theight'] / $_POST['twidth'], 2)); $data['px'] = 0; $data['py'] = ceil(($height - $realh) / 2); $data['pw'] = $realw; $data['ph'] = $realh; } } else { //图片先压缩 //list($cx, $cy) = getallsize($width, $height, $_POST['twidth'], $_POST['theight']); $t = round($_POST['twidth'] / $_POST['theight'], 2); //目标图片宽高比 $s = round($width / $height, 2); //原图宽高比 if ($t < $s) { $cx = ceil($_POST['theight'] * round($width / $height, 2)); $cy = $_POST['theight']; $data['px'] = ceil(($cx - $_POST['twidth']) / 2); $data['pw'] = $_POST['twidth']; $data['py'] = 0; $data['ph'] = $cy; } else { $cx = $_POST['twidth']; $cy = ceil($_POST['twidth'] * round($height / $width, 2)); $data['px'] = 0; $data['pw'] = $cx; $data['py'] = ceil(($cy - $_POST['theight']) / 2); $data['ph'] = $_POST['theight']; } $cimage = imagecreatetruecolor($cx, $cy); $cred = imagecolorallocate($cimage, 255, 255, 255); imagefilledrectangle($cimage, 0, 0, $cx, $cy, $cred); // 填充背景色 imagecopyresampled($cimage, $image2, 0, 0, 0, 0, floor($cx), floor($cy), $width, $height); $compress = imagejpeg($cimage, $tpath, 100); $cimg = $tcimg; } //图片截取处理 if (resize_img($cimg, $tpath, $data['px'], $data['py'], $data['pw'], $data['ph'], $data['pw'], $data['ph'], 100)) { //echo file_get_contents($_POST['tpicurl'], 'r'); $ctx = stream_context_create(array('http' => array('timeout' => 20))); echo @file_get_contents($_POST['tpicurl'], false, $ctx); exit; } else { $ctx = stream_context_create(array('http' => array('timeout' => 20))); echo @file_get_contents($_POST['picurl'], false, $ctx); //echo file_get_contents($_POST['picurl'], 'r'); exit; } }
if (!in_array($imageinfo[2], array(1, 2, 3))) { $error = 'Image must be in JPG, GIF or PNG format.'; unlink($file_path . $temp_id); } else { $image_title = mysql_real_escape_string(preg_replace(array('/\\.([a-z0-9]+)$/i', '/[^a-z0-9]+/i'), array('', '-'), $_FILES[$element]['name'])); $image_position = dbq("SELECT MAX(`position`) AS `position` FROM `wp_image_gallery` WHERE `parent` = {$parentID}"); if (!is_array($image_position)) { $image_position = 1; } else { $image_position = $image_position[0]['position'] + 1; } $insert_id = dbq("INSERT INTO `wp_image_gallery` (`parent`, `title`, `position`) VALUES ('{$parentID}', '{$image_title}', '{$image_position}')"); resize_img($file_path . $temp_id, $file_path . "{$insert_id}-s.jpg", $cfg['img']['small'][0], $cfg['img']['small'][1], $cfg['img']['small'][2], $cfg['img']['small'][3], $cfg['img']['small'][4], $cfg['img']['small'][5], $cfg['img']['small'][6], $cfg['img']['small'][7]); resize_img($file_path . $temp_id, $file_path . "{$insert_id}-m.jpg", $cfg['img']['medium'][0], $cfg['img']['medium'][1], $cfg['img']['medium'][2], $cfg['img']['medium'][3], $cfg['img']['medium'][4], $cfg['img']['medium'][5], $cfg['img']['medium'][6], $cfg['img']['medium'][7]); resize_img($file_path . $temp_id, $file_path . "{$insert_id}-l.jpg", $cfg['img']['large'][0], $cfg['img']['large'][1], $cfg['img']['large'][2], $cfg['img']['large'][3], $cfg['img']['large'][4], $cfg['img']['large'][5], $cfg['img']['large'][6], $cfg['img']['large'][7]); resize_img($file_path . $temp_id, $file_path . "{$insert_id}-xl.jpg", $cfg['img']['xl'][0], $cfg['img']['xl'][1], $cfg['img']['xl'][2], $cfg['img']['xl'][3], $cfg['img']['xl'][4], $cfg['img']['xl'][5], $cfg['img']['xl'][6], $cfg['img']['xl'][7]); unlink($file_path . $temp_id); $msg = 'SUCCESS'; } } else { $error = 'File upload error!'; } } else { if ($element == 'jq-files') { $file_path = $cfg['data'] . "files/"; if (is_uploaded_file($_FILES[$element]['tmp_name'])) { $image_title = preg_replace(array('/\\.([a-z0-9]+)$/i', '/[^a-z0-9]+/i'), array('', '-'), $_FILES[$element]['name']); $file_ext = preg_replace('/.+\\.([a-z0-9]+)$/i', '$1', $_FILES[$element]['name']); $file_position = dbq("SELECT MAX(`position`) AS `position` FROM `wp_file_gallery` WHERE `parent` = {$parentID}"); if (!is_array($file_position)) { $file_position = 1;
$errorsChecked = true; } else { if (is_file($cfg['data'] . $id)) { $imglist = glob($cfg['data'] . "{$id}-*.jpg"); if (count($imglist)) { foreach ($imglist as $delimg) { unlink($delimg); } } /* if (is_file ($cfg['data'] . "$id-s.jpg")) { unlink ($cfg['data'] . "$id-s.jpg"); unlink ($cfg['data'] . "$id-m.jpg"); unlink ($cfg['data'] . "$id-l.jpg"); } */ foreach ($cfg['img'] as $img_key => $img_val) { resize_img($cfg['data'] . $id, $cfg['data'] . "{$id}-{$img_key}.jpg", $cfg['img'][$img_key][0], $cfg['img'][$img_key][1], $cfg['img'][$img_key][2], $cfg['img'][$img_key][3], $cfg['img'][$img_key][4], $cfg['img'][$img_key][5], $cfg['img'][$img_key][6], $cfg['img'][$img_key][7]); } /* resize_img ($cfg['data'] . $id, $cfg['data'] . "$id-s.jpg", $cfg['img']['small'][0], $cfg['img']['small'][1], $cfg['img']['small'][2], $cfg['img']['small'][3], $cfg['img']['small'][4], $cfg['img']['small'][5], $cfg['img']['small'][6], $cfg['img']['small'][7]); resize_img ($cfg['data'] . $id, $cfg['data'] . "$id-m.jpg", $cfg['img']['medium'][0], $cfg['img']['medium'][1], $cfg['img']['medium'][2], $cfg['img']['medium'][3], $cfg['img']['medium'][4], $cfg['img']['medium'][5], $cfg['img']['medium'][6], $cfg['img']['medium'][7]); resize_img ($cfg['data'] . $id, $cfg['data'] . "$id-l.jpg", $cfg['img']['large'][0], $cfg['img']['large'][1], $cfg['img']['large'][2], $cfg['img']['large'][3], $cfg['img']['large'][4], $cfg['img']['large'][5], $cfg['img']['large'][6], $cfg['img']['large'][7]); */ unlink($cfg['data'] . $id); } if ($record['position'] != $_POST['position']) { dbq("UPDATE {$cfg['db']['prefix']}_structure SET position = position + 1 WHERE position >= {$_POST['position']} ORDER BY position DESC"); } dbq("UPDATE\r\n {$cfg['db']['prefix']}_structure,\r\n {$cfg['db']['prefix']}_image\r\n SET\r\n title = '" . addslashes($_POST['title']) . "',\r\n uri = '{$uri}',\r\n online = {$online},\r\n sort = '{$_POST['sort']}',\r\n position = {$_POST['position']},\r\n modified = '{$time}',\r\n viewRights = '{$viewRights}',\r\n createRights = '{$createRights}',\r\n editRights = '{$editRights}',\r\n deleteRights = '{$deleteRights}'\r\n WHERE\r\n link = id AND\r\n id = {$id}"); }
<?php session_start(); include_once 'includes/connect.php'; include_once 'includes/config.php'; include_once 'includes/functions.php'; ?> <html> <head> <title> Seen.tv </title> <link rel="stylesheet" href="includes/style.css" type="text/css"> <script type="text/javascript" src="includes/js/jquery-1.7.2.min.js"></script> </head> <body> <div id="wrapper"> <center><?php echo '<a href="http://seen.tv">' . resize_img('includes/header.png') . '</a>'; ?> </center> <div id="content">
function widget($args, $instance) { extract($args); $show_popular = $instance['show_popular'] == 'yes' ? true : false; $show_popular_number = $instance['show_popular_number']; $show_recent = $instance['show_recent'] == 'yes' ? true : false; $show_recent_number = $instance['show_recent_number']; $show_comments = $instance['show_comments'] == 'yes' ? true : false; $show_comments_number = $instance['show_comments_number']; $show_tags = $instance['show_tags'] == 'yes' ? true : false; $show_tags_number = $instance['show_tags_number']; ?> <div class="widget-grey-bg"> <?php echo $before_widget; ?> <div class="widget-title"> <?php if ($show_popular) { ?> <span>Интересные записи</span> <?php } ?> <?php if ($show_recent) { ?> <span>Последние посты</span> <?php } ?> <?php if ($show_comments) { ?> <span>Комментарии</span> <?php } ?> <?php if ($show_tags) { ?> <span>Популярные теги</span> <?php } ?> </div> <div class="tab_container"> <?php //Tab 1 if ($show_popular) { echo '<div id="tab1" class="tab_content">'; echo '<ul class="clearfix">'; $the_query = new WP_Query("orderby=comment_count&order=DESC&showposts={$show_popular_number}"); while ($the_query->have_posts()) { $the_query->the_post(); ?> <li class="clearfix"> <?php if (function_exists('has_post_thumbnail') && has_post_thumbnail()) { ?> <div class="post-thumb"> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "><?php resize_img("width=55&height=55"); ?> </a> </div> <?php } ?> <div class="detail"> <h3 class="entry-title"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h3> <span class="entry-meta"><?php the_time(get_option('date_format')); ?> // <a href="<?php comments_link(); ?> "><?php comments_number(__('Без комментариев', 'theme_textdomain'), __('1 Комментарий', 'theme_textdomain'), __('% Комментариев', 'theme_textdomain')); ?> </a></span> </div> </li> <?php } ?> </ul> </div> <?php } //Tab 2 if ($show_recent) { echo '<div id="tab2" class="tab_content">'; echo '<ul class="clearfix">'; $the_query = new WP_Query("showposts={$show_recent_number}"); while ($the_query->have_posts()) { $the_query->the_post(); ?> <li class="clearfix"> <?php if (function_exists('has_post_thumbnail') && has_post_thumbnail()) { ?> <div class="post-thumb"> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "><?php resize_img("width=55&height=55"); ?> </a> </div> <?php } ?> <div class="detail"> <h3 class="entry-title"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h3> <span class="entry-meta"><?php the_time(get_option('date_format')); ?> // <a href="<?php comments_link(); ?> "><?php comments_number(__('No Comments', 'theme_textdomain'), __('1 Comment', 'theme_textdomain'), __('% Comments', 'theme_textdomain')); ?> </a></span> </div> </li> <?php } ?> </ul> </div> <?php } //Tab3 if ($show_comments) { echo '<div id="tab3" class="tab_content">'; $comments = get_comments(array('number' => $show_comments_number, 'status' => 'approve', 'type' => 'comment')); echo '<ul class="clearfix">'; foreach ($comments as $comment) { $comm_title = get_the_title($comment->comment_post_ID); $comm_link = get_comment_link($comment->comment_ID); ?> <li class="clearfix"> <div class="post-thumb"> <a href="<?php echo $comm_link; ?> "><?php echo get_avatar($comment, 55); ?> </a> </div> <div class="detail"> <span class="entry-meta"><a href="<?php echo $comm_link; ?> "><?php echo substr(get_comment_excerpt($comment->comment_ID), 0, 100); ?> </a></span> </div> </li> <?php } ?> </ul> </div> <?php } //Tab 4 if ($show_tags) { ?> <div id="tab4" class="tab_content clearfix"> <?php wp_tag_cloud('largest=12&smallest=12&unit=px&number=' . $show_tags_number); ?> </div> <?php } ?> </div> <?php echo $after_widget; ?> </div> <?php }
echo $image[height]; ?> " alt="slider image" /> <?php } ?> <?php } ?> </div> </div> <?php } elseif (has_post_thumbnail()) { ?> <div class="post-thumb"><?php resize_img("width=610&height=350"); ?> </div> <?php } ?> <?php if ($video['vimeo-youtube'] != '' || $video['embedded-code'] != '') { ?> <div class="post-video"> <?php embed_video(get_the_ID(), 610, 350, 'portfolio_video'); ?> </div>
<?php include_once 'includes/header.php'; $user_name = mysql_real_escape_string($_GET['user']); $user_id = name_to_id($user_name); $photo_result = mysql_query("SELECT * FROM photos WHERE user_id='{$user_id}' ORDER BY photo_views DESC LIMIT 0, 100"); $photo_count = mysql_num_rows($photo_result); if ($photo_count == 0) { echo 'No images have been uploaded by this user.'; } else { while ($photo_row = mysql_fetch_assoc($photo_result)) { $date = date("Y\\-m\\-d H:i:s"); echo '<b><h1>' . $photo_row['photo_title'] . '</h1></b>' . resize_img($photo_row['photo_name'], $photo_row['user_id']) . '<br />' . views($photo_row['photo_name'], $date) . '<br />'; } } include_once 'includes/footer.php';
<!-- BEGIN .post --> <div <?php post_class('full-width-template'); ?> id="post-<?php the_ID(); ?> "> <!-- BEGIN .post-content --> <div class="post-content clearfix"> <?php if (has_post_thumbnail()) { ?> <div class="post-thumb"><?php resize_img("width=988&height=300"); ?> </div> <?php } ?> <?php if (current_user_can('edit_post', $post->ID)) { ?> <div class="edit-message"> <?php edit_post_link(__('Edit this', 'theme_textdomain')); ?> </div> <?php }
$sql = 'SELECT COUNT(temp_id) as total_images FROM ' . CLASSIFIEDS_IMAGES_TABLE . ' WHERE temp_id = ' . $temp_id; } $db->sql_query($sql); $total_images = $db->sql_fetchfield('total_images'); } if ($config['max_images_per_ad'] == 0 || $total_images < $config['max_images_per_ad']) { move_uploaded_file($FiledataTmp_name, $targetFile); if ($ad_id != 0) { $sql = 'INSERT INTO ' . CLASSIFIEDS_IMAGES_TABLE . ' (image_name, ad_id) VALUES ("' . $filename_to_db . '", ' . $ad_id . ')'; } else { $sql = 'INSERT INTO ' . CLASSIFIEDS_IMAGES_TABLE . ' (image_name, temp_id) VALUES ("' . $filename_to_db . '", ' . $temp_id . ')'; } $db->sql_query($sql); echo $filename_to_db; resize_img($targetFile, $fileParts['extension'], $targetThumbFile, 100, 100); resize_img($targetFile, $fileParts['extension'], $targetResizedFile, 800, 600); @unlink($targetFile); } else { echo "10"; // Too many files } } else { echo "20"; // Invalid extension } } }
break; case 'image/png': $uploaded = imagecreatefrompng($imgsrc); break; default: $error['format'] = 'Image format not supported'; } } else { $error['size'] = 'That file is too big to handle.'; } if (empty($error)) { // Resize the image to a working width if (!empty($_POST['uploadSummary'])) { $working_up = resize_img($uploaded, $workingWidthSummary); } else { $working_up = resize_img($uploaded, $workingWidth); } imagedestroy($uploaded); // Save it always with different names (browser cache problems) $ruta = time() . 'jpg'; // Detroy previous uploaded if (file_exists($dirTmpUser . '/' . $ruta)) { unlink($dirTmpUser . '/' . $ruta); } // Save image for later cropping imagejpeg($working_up, $dirTmpUser . '/' . $imgs . '.jpg', 90); imagedestroy($working_up); } } elseif (!empty($_FILES) && $_FILES['file']['error'] == 1) { $error['upload'] = 'Problem on the uploading. Big file?'; // SUBMIT CROP
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $show_number = $instance['show_number']; $show_img = $instance['show_img'] == "yes" ? true : false; ?> <div class="widget-grey-bg"> <?php echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } ?> <div class="recent-posts-widget"> <ul class="clearfix"> <?php $the_query = new WP_Query("showposts={$show_number}"); while ($the_query->have_posts()) { $the_query->the_post(); ?> <li class="clearfix"> <?php if (function_exists('has_post_thumbnail') && has_post_thumbnail() && $show_img) { ?> <div class="post-thumb"> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "><?php resize_img("width=55&height=55"); ?> </a> </div> <?php } ?> <div class="detail"> <h3 class="entry-title"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h3> <span class="entry-meta"><?php the_time(get_option('date_format')); ?> // <a href="<?php comments_link(); ?> "><?php comments_number(__('No Comments', 'theme_textdomain'), __('1 Comment', 'theme_textdomain'), __('% Comments', 'theme_textdomain')); ?> </a></span> </div> </li> <?php } ?> </ul> </div> <?php echo $after_widget; ?> </div> <?php }
} else { // ok, file is small enough, so... // Check the upload and make a picture of that if you can you evil server switch ($ftype) { case 'image/jpeg': $source = imagecreatefromjpeg($imgsrc); break; case 'image/png': $source = imagecreatefrompng($imgsrc); break; default: $error['format'] = 'Image format not supported'; } if (empty($error)) { // Resize the image to a working width $img = resize_img($source, $sourceWidth); // Destroy the source imagedestroy($source); // Leave a copy on the user temp dir imagejpeg($img, $urlTmpImg); imagedestroy($img); // Reload header("Location: user-settings.php?uploaded=true"); die; } } } else { $error['uploading'] = 'Error uploading image.'; } } // SUMBIT CANCEL
$errorsChecked = true; } else { if (is_uploaded_file($_FILES['fileId']['tmp_name'])) { if ($record['extension'] != '') { unlink($cfg['data'] . "{$id}" . "." . $record['extension']); } $extension = strtolower(ereg_replace('.*\\.([A-Za-z0-9_-]+)$', '\\1', $_FILES['fileId']['name'])); move_uploaded_file($_FILES['fileId']['tmp_name'], $cfg['data'] . "{$id}.{$extension}"); $image_info = @getimagesize($cfg['data'] . "{$id}.{$extension}"); if (!is_file($cfg['data'] . $id) && is_array($image_info) && in_array($image_info[2], array(1, 2, 3))) { @copy($cfg['data'] . "{$id}.{$extension}", $cfg['data'] . $id); } } else { $extension = $record['extension']; } if (is_file($cfg['data'] . $id)) { if (is_file($cfg['data'] . "{$id}-s.jpg")) { unlink($cfg['data'] . "{$id}-s.jpg"); unlink($cfg['data'] . "{$id}-m.jpg"); unlink($cfg['data'] . "{$id}-l.jpg"); } resize_img($cfg['data'] . $id, $cfg['data'] . "{$id}-s.jpg", $cfg['img']['small'][0], $cfg['img']['small'][1], $cfg['img']['small'][2], $cfg['img']['small'][3], $cfg['img']['small'][4], $cfg['img']['small'][5], $cfg['img']['small'][6], $cfg['img']['small'][7]); resize_img($cfg['data'] . $id, $cfg['data'] . "{$id}-m.jpg", $cfg['img']['medium'][0], $cfg['img']['medium'][1], $cfg['img']['medium'][2], $cfg['img']['medium'][3], $cfg['img']['medium'][4], $cfg['img']['medium'][5], $cfg['img']['medium'][6], $cfg['img']['medium'][7]); resize_img($cfg['data'] . $id, $cfg['data'] . "{$id}-l.jpg", $cfg['img']['large'][0], $cfg['img']['large'][1], $cfg['img']['large'][2], $cfg['img']['large'][3], $cfg['img']['large'][4], $cfg['img']['large'][5], $cfg['img']['large'][6], $cfg['img']['large'][7]); unlink($cfg['data'] . $id); } if ($record['position'] != $_POST['position']) { dbq("UPDATE {$cfg['db']['prefix']}_structure SET position = position + 1 WHERE position >= {$_POST['position']} ORDER BY position DESC"); } dbq("UPDATE\r\n {$cfg['db']['prefix']}_structure,\r\n {$cfg['db']['prefix']}_hi_res\r\n SET\r\n title = '" . addslashes($_POST['title']) . "',\r\n uri = '{$uri}',\r\n online = {$online},\r\n sort = '{$_POST['sort']}',\r\n position = {$_POST['position']},\r\n modified = '{$time}',\r\n viewRights = '{$viewRights}',\r\n createRights = '{$createRights}',\r\n editRights = '{$editRights}',\r\n deleteRights = '{$deleteRights}',\r\n extension = '{$extension}'\r\n WHERE\r\n link = id AND\r\n id = {$id}"); }
break; case "media": $dir = "{$config['base_dir']}media/{$dir}"; break; case "files": $dir = "{$config['base_dir']}files/{$dir}"; break; } if (file_exists("{$path}user_config_manager.php")) { require "{$path}user_config_manager.php"; } else { require '../user_config_manager.php'; } $dir_str = $dir; $dir = opendir($dir); chdir($dir_str); while ($read = readdir($dir)) { if (is_file($read) && strpos($read, '.') !== 0 && format($read, 1, '.jpg.jpeg.png.gif')) { $tmp_thumb = explode('.', $read); $thumb = ''; $cnt = count($tmp_thumb) - 1; for ($i = 0; $i < $cnt; $i++) { $thumb .= $tmp_thumb[$i]; } if (!resize_img($dir_str, $read, $thumb, $config)) { die(ERROR_REFRESH); } } } closedir($dir); die('1');