function printHeader($filename, $type) { $mime = getImageType($filename); if ($type == "view") { header("Content-type: {$mime}"); header("Content-Transfer-Encoding: binary\n"); header("Expires: 0"); //header('Content-length: '.sizeOf($imgcode)); } elseif ($type == "download") { if (strpos($GLOBALS['LOGIKS']["_SERVER"]['HTTP_USER_AGENT'], "MSIE") !== FALSE) { header("Content-type: {$mime}"); header("Content-Disposition: attachment; filename={$filename}"); header("Expires: 0"); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header("Content-Transfer-Encoding: binary"); header('Pragma: public'); //header("Content-Length: ".strlen($data)); } else { header("Content-type: {$mime}"); header("Content-Disposition: attachment; filename={$filename}"); header("Content-Transfer-Encoding: binary"); header("Expires: 0"); header('Pragma: no-cache'); //header("Content-Length: ".strlen($data)); } } }
function createImage($elem, $image64, $isUser) { $path = "http://www.services.emprestae.com"; $localPath = "services/images/"; $localPath .= $isUser ? "users/" : "objects/"; if ($image64) { $image_binary = base64_decode($image64); $type = getImageType($image_binary); $im = imagecreatefromstring($image_binary); $localPath .= "{$elem}.{$type}"; } else { if ($isUser) { $localPath .= "defaultUserImage.png"; } else { $localPath .= "defaultObjectImage.jpg"; } } if (!file_exists($localPath)) { $f = fopen($localPath, "wb"); fwrite($f, $image_binary); fclose($f); } return $path . $localPath; }
public function setImageHeaders($path, $type) { if (!$type) { $type = getImageType($path); } header("Content-type: image/" . $type); header("Expires: Mon, 1 Jan 2099 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); // get the size for content length $size = filesize($path); header("Content-Length: {$size} bytes"); ob_clean(); flush(); }
// // Multiple files have been passed from HTML // $cnt = 0; trace("HTML multiple POST:"); trace($postdata, true); $_post = $postdata; $postdata = array(); while (isset($_FILES['uploadedfile' . $cnt])) { trace("izzaa file"); $moved = move_uploaded_file($_FILES['uploadedfile' . $cnt]['tmp_name'], $upload_path . $_FILES['uploadedfile' . $cnt]['name']); trace("moved:" . $moved . " " . $_FILES['uploadedfile' . $cnt]['name']); if ($moved) { $name = $_FILES['uploadedfile' . $cnt]['name']; $file = $upload_path . $name; $type = getImageType($file); try { list($width, $height) = getimagesize($file); } catch (Exception $e) { $width = 0; $height = 0; } trace("file: " . $file); $_post['file'] = $file; $_post['name'] = $name; $_post['width'] = $width; $_post['height'] = $height; $_post['type'] = $type; $_post['size'] = filesize($file); trace($_post, true); $postdata[$cnt] = $_post;
if ($artistCount > $PREVIEW_COUNT) { $random = mt_rand(0, $artistCount - $PREVIEW_COUNT); } else { $random = 0; } $artistQuery = "SELECT * FROM " . getJoinTable("artist_list", "artist_artwork_list") . " \n WHERE " . getJoinMatch("artist_list", "artist_artwork_list", "artist_id") . " AND " . getImageType($IMAGE_SIZE1) . " LIMIT " . $random . ", " . $PREVIEW_COUNT; $artistResult = $dbHandle->query($artistQuery); // $albumCountResult = $dbHandle->query("SELECT * FROM album_list"); $albumCount = $albumCountResult->num_rows; if ($albumCount > $PREVIEW_COUNT) { $random = mt_rand(0, $albumCount - $PREVIEW_COUNT); } else { $random = 0; } $albumQuery = "SELECT * FROM " . getJoinTable("album_list", "album_artwork_list") . " \n WHERE " . getJoinMatch("album_list", "album_artwork_list", "album_id") . " AND " . getImageType($IMAGE_SIZE1) . " LIMIT " . $random . ", " . $PREVIEW_COUNT; $albumResult = $dbHandle->query($albumQuery); // $trackCountResult = $dbHandle->query("SELECT * FROM track_list"); $trackCount = $trackCountResult->num_rows; if ($trackCount > $PREVIEW_COUNT) { $random = mt_rand(0, $trackCount - $PREVIEW_COUNT); } else { $random = 0; } $trackQuery = "SELECT * FROM track_list LIMIT " . $random . ", " . $PREVIEW_COUNT; $trackResult = $dbHandle->query($trackQuery); // ?> <a id="topofpage"></a>
/** * Prints the images and/or albums as thumbnails of the selected album * * @param $number int The number of images per page * * @return string */ function printImageslist($number) { global $_zp_gallery, $host; $args = array(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); if (isset($_GET['album']) && !empty($_GET['album'])) { $album = urldecode(sanitize($_GET['album'])); $albumobj = newAlbum($album); echo "<h3>" . gettext("Album:") . " <em>" . html_encode($albumobj->getTitle()) . unpublishedZenphotoItemCheck($albumobj, false) . "</em> / " . gettext("Album folder:") . " <em>" . html_encode($albumobj->name) . "</em><br /><small>" . gettext("(Click on image to include)") . "</small></h3>"; $images_per_page = $number; if (isset($_GET['page'])) { $currentpage = sanitize_numeric($_GET['page']); } else { $currentpage = 1; } $imagecount = $albumobj->getNumImages(); $pagestotal = ceil($imagecount / $images_per_page); printTinyPageNav($pagestotal, $currentpage, 'images'); // album thumb display; $albumthumb = $albumobj->getAlbumThumbImage(); $albumthumbalbum = $albumthumb->getAlbum(); $albumdesc = $albumobj->getDesc(); $imagedesc = $albumthumb->getDesc(); $imgurl = getImageProcessorURI($args, $albumthumbalbum->name, $albumthumb->filename); $fullimage = pathurlencode(addslashes($albumthumb->getFullImage())); $imageType = getImageType($albumthumb); if ($imageType) { // Not a pure image $backgroundcss = 'albumthumb-image'; $imgurl = $albumthumb->getThumb(); $itemid = $albumthumb->getID(); } else { $backgroundcss = 'albumthumb-other'; $imgurl = getImageProcessorURI($args, $albumthumbalbum->name, $albumthumb->filename); $itemid = $albumthumb->getID(); } $imgsizeurl = $albumthumb->getCustomImage(85, NULL, NULL, 85, 85, NULL, NULL, TRUE); echo "<div class='thumb'>"; echo "<a href=\"javascript: ZenpageDialog.insert('" . $itemid . "','" . $imgurl . "','" . $albumobj->getThumb() . "','" . "','" . urlencode($albumthumb->filename) . "','" . js_encode($albumthumb->getTitle()) . "','" . js_encode($albumobj->getTitle()) . "','" . $fullimage . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'zenphoto','" . js_encode(getWatermarkParam($albumthumb, WATERMARK_THUMB)) . "','" . js_encode(getWatermarkParam($albumthumb, WATERMARK_IMAGE)) . "','" . $imageType . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . html_encode(addslashes($imagedesc)) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . html_encode(addslashes($albumdesc)) . "');\"" . " title='" . html_encode($albumthumb->getTitle()) . " (" . html_encode($albumthumb->filename) . ")'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img src='" . $imgsizeurl . "' class='" . $backgroundcss . "' /></a>\n"; echo "<a href='../../../../../.." . html_encode($albumthumb->getLink()) . "' title='Zoom' rel='colorbox' style='outline: none;'><img src='img/magnify.png' alt='' style='border: 0' /></a> " . gettext('<em>Albumthumb</em>') . unpublishedZenphotoItemCheck($albumthumb, false); echo "</div>"; $images = $albumobj->getImages(); if ($albumobj->getNumImages() != 0) { for ($nr = 1; $nr <= $pagestotal; $nr++) { $startimage[$nr] = $nr * $images_per_page - $images_per_page; // get start image number $endimage[$nr] = $nr * $images_per_page - 1; // get end image number } $number = $startimage[$currentpage]; for ($nr = $number; $nr <= $images_per_page * $currentpage; $nr++) { if ($nr === $imagecount) { break; } if (is_array($images[$nr])) { $linkalbumobj = newAlbum($images[$nr]['folder']); $imageobj = newImage($linkalbumobj, $images[$nr]['filename']); } else { $linkalbumobj = $albumobj; $imageobj = newImage($albumobj, $images[$nr]); } $imagedesc = $imageobj->getDesc(); $albumdesc = $linkalbumobj->getDesc(); $fullimage = pathurlencode(addslashes($imageobj->getFullImage())); $imageType = getImageType($imageobj); $thumburl = $imageobj->getThumb(); $imgurl = $imageobj->getLink(false); //$sizedimage = $imageobj->getSizedImage(getOption('image_size')); switch ($imageType) { case '': // image photo $backgroundcss = 'thumb-image'; $imgurl = getImageProcessorURI($args, $linkalbumobj->name, $imageobj->filename); $sizedimage = $imageobj->getSizedImage(getOption('image_size')); $sizedimage = '<img src="' . $sizedimage . '" alt="' . $imageobj->getTitle() . '" class="zenpage_sizedimage" />'; $itemid = ''; break; case 'textobject': $sizedimage = $imageobj->getSizedImage(getOption('image_size')); $sizedimage = str_replace('class="textobject"', 'class="textobject zenpage_sizedimage"', $sizedimage); $imgurl = getImageProcessorURI($args, $linkalbumobj->name, $imageobj->filename); $backgroundcss = 'thumb-textobject'; $itemid = ''; break; case 'video': case 'audio': $sizedimage = $imageobj->getThumb(); $sizedimage = str_replace('class="flowplayer"', 'class="mediaplayer zenpage_sizedimage"', $sizedimage); $imgurl = getImageProcessorURI($args, $linkalbumobj->name, $imageobj->filename); $backgroundcss = 'thumb-multimedia'; $itemid = $imageobj->getID(); break; default: $sizedimage = $imageobj->getSizedImage(getOption('image_size')); $backgroundcss = 'thumb-default'; $itemid = ''; break; } $imgsizeurl = $imageobj->getCustomImage(85, NULL, NULL, 85, 85, NULL, NULL, TRUE); echo "<div class='thumb'>\n"; echo "<a href=\"javascript:ZenpageDialog.insert('" . $itemid . "','" . $imgurl . "','" . $thumburl . "','" . html_encode($sizedimage) . "','" . urlencode($imageobj->filename) . "','" . js_encode($imageobj->getTitle()) . "','" . js_encode($linkalbumobj->getTitle()) . "','" . $fullimage . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'zenphoto','" . js_encode(getWatermarkParam($imageobj, WATERMARK_THUMB)) . "','" . js_encode(getWatermarkParam($imageobj, WATERMARK_IMAGE)) . "','" . $imageType . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . html_encode(addslashes($imagedesc)) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . html_encode(addslashes($albumdesc)) . "');\"" . " title='" . html_encode($imageobj->getTitle()) . " (" . html_encode($imageobj->filename) . ")'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img src='" . $imgsizeurl . "' class='" . $backgroundcss . "' /></a>\n"; echo "<a href='../../../../../.." . html_encode($imageobj->getLink()) . "' title='Zoom' rel='colorbox' style='outline: none;'><img src='img/magnify.png' alt='' style='border: 0' /></a> " . html_encode(shortentitle($imageobj->getTitle(), 8)) . unpublishedZenphotoItemCheck($imageobj, false); echo "</div>\n"; if ($nr === $endimage[$currentpage]) { break; } } // for end } else { echo "<p class='noimages'>" . gettext("<strong>Note:</strong> This album does not contain any images.") . "</p>"; } // if/else no image end } // if GET album end }
/** * * @param $origin_path 原始物理图片地址 * @param array $sizes 缩略图大小信息 为空则取后台设置 可生成多个缩略图 数组 参数1 为宽度, 参数2为高度, 参数3为处理方式:0(缩放,默认),1(剪裁), 参数4为是否水印 默认为 0(不生成水印) array( array(300,300,0,0), array(100,100,0,0), ... ), * @param $path 存储的路径 * @param $file_name 保存的文件名 * @param $del_temp 是否删除临时文件 * @param $id 关联编号,将根据编号生成目录 * * 返回 复制成功的信息,如为false则复制失败 * array( * 'path' => xxx //物理路径 * 'url' => xxx //相对路径 * ); * * by fzmatthew */ function copyImage($origin_path, $sizes = array(), $path = 'share', $del_temp = true, $id = 0) { global $_FANWE; static $size_setting = NULL, $image = NULL; if ($image === NULL) { include_once fimport('class/image'); $image = new Image(); } if ($path == 'temp') { $dir = './public/upload/temp/' . fToDate(NULL, 'Y/m/d/H'); } else { if ($id > 0) { $dir = './public/upload/' . $path . '/' . getDirsById($id); } else { $dir = './public/upload/' . $path . '/' . fToDate(NULL, 'Y/m/d'); } } makeDir(FANWE_ROOT . $dir); $file_name = md5(microtime(true)) . random('6') . '.jpg'; $file_path = FANWE_ROOT . $dir . "/" . $file_name; $bln = false; if (file_exists($origin_path) && @copy($origin_path, $file_path)) { $bln = true; } else { /* $data = getUrlContent($origin_path); if(!empty($data) && @file_put_contents($file_path,$data) > 0) $bln = true; */ $type = getImageType($origin_path); //获取图片类型 // if($type==null){ // return false; // } $file_name = md5(microtime(true)) . random('6') . '.' . $type; $file_path = FANWE_ROOT . $dir . "/" . $file_name; if ($type == 'png') { $data = @file_get_contents($origin_path); } else { $data = getUrlContent($origin_path); //获取远程图片 } if (!empty($data) && @file_put_contents($file_path, $data) > 0) { $bln = true; } } $is_animate = 0; //是否为动态GIF图片 if ($bln) { $info = $image->getImageInfo($file_path); if ($info['type'] != 'jpg' && $info['type'] != 'jpeg') { /* if(!$image->convertType($file_path,$file_path)) return false; */ //如果不是jpg,就无法打水印 if ($del_temp) { @unlink($origin_path); } $is_animate = IsAnimatedGif($file_path); return array('path' => $file_path, 'url' => $dir . "/" . $file_name, 'width' => $info[0], 'height' => $info[1], 'is_animate' => $is_animate); } $water_image = $_FANWE['setting']['water_image']; if (!empty($water_image)) { $water_image = FANWE_ROOT . $water_image; } $water_mark = intval($_FANWE['setting']['water_mark']); $alpha = intval($_FANWE['setting']['water_alpha']); $place = intval($_FANWE['setting']['water_position']); if ($sizes !== false && empty($sizes)) { if ($size_setting === NULL) { if (!isset($_FANWE['cache']['image_sizes'])) { FanweService::instance()->cache->loadCache('image_sizes'); } $size_setting = $_FANWE['cache']['image_sizes']; } $sizes = $size_setting; } foreach ($sizes as $size) { if ($size[0] > 0 || $size[1] > 0) { $thumb_bln = false; $thumb_type = isset($size[2]) ? intval($size[2]) : 0; if ($thumb = $image->thumb($file_path, $size[0], $size[1], $thumb_type)) { if (isset($size[3]) && intval($size[3]) > 0) { $image->water($thumb['path'], $water_image, $alpha, $place); } } } } if ($del_temp) { @unlink($origin_path); } return array('path' => $file_path, 'url' => $dir . "/" . $file_name, 'width' => $info[0], 'height' => $info[1], 'is_animate' => $is_animate); } else { return false; } }
function upload_image($max_width) { $path = ''; $upload_directory = ROOT_PATH . IMAGE_LOCATION; $uploaded_url = SERVER . BASE; $image_path = $path; $upload_directory .= $image_path; if (!file_exists($upload_directory)) { mkdir($upload_directory, 0777, true); } $image_name = get_free_image_name($upload_directory, getImageType($_FILES['imageFile']['name'])); $upload_file = $upload_directory . $image_name; $image_path .= IMAGE_LOCATION . $image_name; $uploaded_url .= $image_path; $file_type = trim(getImageType($_FILES['imageFile']['name'])); if ($file_type == "jpg" || $file_type == "jpeg" || $file_type == "JPG" || $file_type == "png" || $file_type == "PNG" || $file_type == "gif" || $file_type == "GIF") { } else { return FALSE; } if (move_uploaded_file($_FILES['imageFile']['tmp_name'], $upload_file)) { if (substr(strrchr($upload_file, "."), 1) == 'jpg' or substr(strrchr($upload_file, "."), 1) == 'jpeg' or substr(strrchr($upload_file, "."), 1) == 'JPG') { $image = imagecreatefromjpeg($upload_file); } elseif (substr(strrchr($upload_file, "."), 1) == 'png' or substr(strrchr($upload_file, "."), 1) == 'PNG') { $image = imagecreatefrompng($upload_file); } elseif (substr(strrchr($upload_file, "."), 1) == 'gif' or substr(strrchr($upload_file, "."), 1) == 'GIF') { $image = imagecreatefromgif($upload_file); } else { return FALSE; } //Check for image resizing list($width, $height) = getimagesize($upload_file); if ($width > $max_width) { $new_width = $max_width; $new_height = $height / $width * $new_width; $tmp = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($tmp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); if (substr(strrchr($upload_file, "."), 1) == 'jpg' or substr(strrchr($upload_file, "."), 1) == 'jpeg' or substr(strrchr($upload_file, "."), 1) == 'JPG') { $exif = exif_read_data($upload_file); if (!empty($exif['Orientation'])) { switch ($exif['Orientation']) { case 8: $tmp = imagerotate($tmp, 90, 0); break; case 3: $tmp = imagerotate($tmp, 180, 0); break; case 6: $tmp = imagerotate($tmp, -90, 0); break; } } } if (substr(strrchr($upload_file, "."), 1) == 'jpg' or substr(strrchr($upload_file, "."), 1) == 'jpeg' or substr(strrchr($upload_file, "."), 1) == 'JPG') { imagejpeg($tmp, $upload_file, 100); } elseif (substr(strrchr($upload_file, "."), 1) == 'png' or substr(strrchr($upload_file, "."), 1) == 'PNG') { imagepng($tmp, $upload_file, 0); } elseif (substr(strrchr($upload_file, "."), 1) == 'gif' or substr(strrchr($upload_file, "."), 1) == 'GIF') { imagegif($tmp, $upload_file, 100); } imagedestroy($tmp); } else { $tmp = imagecreatetruecolor($width, $height); imagecopyresampled($tmp, $image, 0, 0, 0, 0, $width, $height, $width, $height); if (substr(strrchr($upload_file, "."), 1) == 'jpg' or substr(strrchr($upload_file, "."), 1) == 'jpeg' or substr(strrchr($upload_file, "."), 1) == 'JPG') { $exif = exif_read_data($upload_file); if (!empty($exif['Orientation'])) { switch ($exif['Orientation']) { case 8: $tmp = imagerotate($tmp, 90, 0); break; case 3: $tmp = imagerotate($tmp, 180, 0); break; case 6: $tmp = imagerotate($tmp, -90, 0); break; } } } if (substr(strrchr($upload_file, "."), 1) == 'jpg' or substr(strrchr($upload_file, "."), 1) == 'jpeg' or substr(strrchr($upload_file, "."), 1) == 'JPG') { imagejpeg($tmp, $upload_file, 100); } elseif (substr(strrchr($upload_file, "."), 1) == 'png' or substr(strrchr($upload_file, "."), 1) == 'PNG') { imagepng($tmp, $upload_file, 0); } elseif (substr(strrchr($upload_file, "."), 1) == 'gif' or substr(strrchr($upload_file, "."), 1) == 'GIF') { imagegif($tmp, $upload_file, 100); } imagedestroy($tmp); } imagedestroy($image); return $uploaded_url; } return false; }
include 'header.php'; // Checks if the artist name has been submitted if (!($artistName = getReqArtist())) { $noInput = true; } else { $noInput = false; } // Gets the artist info // if (!$noInput) { $artistInfo = getSingleRow($dbHandle, "artist_list", "artist_name", $artistName); $artResult = $dbHandle->query("SELECT * FROM artist_artwork_list WHERE artist_id='" . $artistInfo['artist_id'] . "' AND image_size='" . $IMAGE_SIZE5 . "'"); $artReturn = $artResult->fetch_array(MYSQLI_BOTH); } // Constructs the query to get both album info and artwork // $albumQuery = "SELECT * FROM " . getJoinTable("album_list", "album_artwork_list") . " \n WHERE " . getJoinMatch("album_list", "album_artwork_list", "album_id") . " \n AND " . getImageType($IMAGE_SIZE3) . " \n AND " . getSectionCriteria("album_title"); if (!$noInput) { $albumQuery .= " AND album_list.artist_id='" . $artistInfo['artist_id'] . "'"; } $albumQuery .= " " . getSortCriteria("album_title"); // Gets the number of albums // $totalResult = $dbHandle->query($albumQuery); $totalCount = $totalResult->num_rows; mysqli_free_result($totalResult); $albumQuery .= " " . getPageCriteria($totalCount, $MAX_ITEMS_PER_PAGE, true); $albumResult = $dbHandle->query($albumQuery); ?> <a id="topofpage"></a> <div id="content">