示例#1
0
 public function display()
 {
     $template = new Template();
     $template->load("message");
     if (ImageServer::insert($_POST['path'], $_POST['name'], $_POST['description'])) {
         $template->assign_var("MESSAGE", Language::DirectTranslateHtml("IMAGE_ADDED"));
         $redirect = UrlRewriting::GetUrlByAlias("admin/home", "dir=" . urlencode($_SESSION['dir']));
         if (isset($_POST['referrer'])) {
             $redirect = $_POST['referrer'];
         }
         echo "<script type='text/javascript'>setTimeout('window.location.href= \\'" . $redirect . "\\'', 1000)</script>";
     } else {
         $template->assign_var("MESSAGE", Language::DirectTranslateHtml("IMAGE_NOT_ADDED"));
     }
     $template->output();
 }
示例#2
0
 function isValidForThumb()
 {
     if ($this->isImage() || $this->isPdf() && ImageServer::isEnabledPdf()) {
         return true;
     }
     return false;
 }
示例#3
0
include '../system/classes/language.php';
include '../system/classes/settings.php';
include '../system/classes/cache.php';
include '../system/classes/filecache.php';
include '../system/classes/mysql.php';
include '../system/classes/user.php';
include '../system/classes/role.php';
include '../system/classes/page.php';
include '../system/classes/sys.php';
include '../const.php';
$db = new MySQL('../system/dbsettings.php');
$db->Connect();
DataBase::SetCurrent($db);
$language = new Language();
Settings::$allowFileCache = false;
$images = ImageServer::getImages();
if ($images) {
    $i = 1;
    foreach ($images as $image) {
        ?>
		  ["<?php 
        echo $image->name;
        ?>
", "<?php 
        echo $image->path;
        ?>
"]
		  <?php 
        if ($i < count($images)) {
            echo ",";
        }
示例#4
0
$_IMAGES["wmv"] = $_IMAGES["video"];
$_IMAGES["xcf"] = $_IMAGES["graphics"];
$_IMAGES["xls"] = $_IMAGES["spreadsheet"];
$_IMAGES["xlsx"] = $_IMAGES["spreadsheet"];
$_IMAGES["xml"] = $_IMAGES["code"];
$_IMAGES["zip"] = $_IMAGES["archive"];
require "inc/EncodeExplorer.php";
require "inc/Dir.php";
require "inc/FileManager.php";
require "inc/File.php";
require "inc/GateKeeper.php";
require "inc/ImageServer.php";
require "inc/Location.php";
require "inc/Logger.php";
//
// This is where the system is activated.
// We check if the user wants an image and show it. If not, we show the explorer.
//
$encodeExplorer = new EncodeExplorer();
$encodeExplorer->init();
GateKeeper::init();
if (!ImageServer::showImage() && !Logger::logQuery()) {
    $location = new Location();
    $location->init();
    if (GateKeeper::isAccessAllowed()) {
        Logger::logAccess($location->getDir(true, false, false, 0), true);
        $fileManager = new FileManager();
        $fileManager->run($location);
    }
    $encodeExplorer->run($location);
}
示例#5
0
<?php

require_once 'vfm-admin/config.php';
require_once 'vfm-admin/class.php';
$imageServer = new ImageServer();
$imageServer->showImage();
示例#6
0
 /**
  * Output a default image when the requested image is not found
  *
  * @author Jonathan Davis
  * @since 1.1
  * @return void
  **/
 public function error()
 {
     header("HTTP/1.1 404 Not Found");
     $notfound = ImageServer::path() . '/core/ui/icons/notfound.png';
     if (defined('SHOPP_NOTFOUND_IMAGE') && file_exists(SHOPP_NOTFOUND_IMAGE)) {
         $notfound = SHOPP_NOTFOUND_IMAGE;
     }
     if (!file_exists($notfound)) {
         die('<h1>404 Image Not Found</h1>');
     } else {
         header('HTTP/1.1 404 Image Not Found');
         $this->headers(basename($notfound), @filesize($notfound));
         @readfile($notfound);
     }
     die;
 }
示例#7
0
 private function rename($dir, $uploadpath)
 {
     if (isset($_POST['plugin_filelistwidget_action_rename'])) {
         $oldpath = $uploadpath . $dir . "/" . $_POST['plugin_filelistwidget_rename_oldname'];
         $newpath = $uploadpath . $dir . "/" . $_POST['plugin_filelistwidget_rename_newname'];
         if (file_exists($oldpath) && !file_exists($newpath)) {
             $imagePathOld = $this->getImagePath($dir, $_POST['plugin_filelistwidget_rename_oldname']);
             $imagePathNew = $this->getImagePath($dir, $_POST['plugin_filelistwidget_rename_newname']);
             if (ImageServer::contains($imagePathOld)) {
                 ImageServer::move($imagePathOld, $imagePathNew);
             }
             rename($oldpath, $newpath);
         }
     }
 }
 public static function showThumbnail($file)
 {
     if (filemtime($file) < filemtime($_SERVER['SCRIPT_FILENAME'])) {
         $mtime = gmdate('r', filemtime($_SERVER['SCRIPT_FILENAME']));
     } else {
         $mtime = gmdate('r', filemtime($file));
     }
     $etag = md5($mtime . $file);
     if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $mtime || isset($_SERVER['HTTP_IF_NONE_MATCH']) && str_replace('"', '', stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])) == $etag) {
         header('HTTP/1.1 304 Not Modified');
         return;
     } else {
         header('ETag: "' . $etag . '"');
         header('Last-Modified: ' . $mtime);
         header('Content-Type: image/png');
         $image = ImageServer::createThumbnail($file);
         imagepng($image);
     }
 }
 function thumb()
 {
     Configure::write('Security.level', 'medium');
     Configure::write('debug', 0);
     $this->layout = null;
     $this->autoRender = false;
     if (empty($this->params['named']['src'])) {
         die("No source image");
     }
     $this->params['named']['src'] = rawurldecode($this->params['named']['src']);
     // internet explorer was submitting the "|" characters encoded. note that the "|" is intact with other browsers / email clients
     $src = str_replace('|', DS, $this->params['named']['src']);
     if ($this->params['named']['size'] == 'original') {
         $this->redirect('/' . $src);
         return;
     }
     // sanitize the src name a little
     $src = str_replace('..', '', $src);
     // remove any double dots,
     // this should probably do enough seeing as we're tagging it onto the end of the WWW_ROOT constant
     // but just in case also filter out other mischievous characters...
     $src = preg_replace('/(^\\/)|(^\\.\\/)|(~)/', '', $src);
     // remove any starting / or ./
     // width and height disabled in favour of a more secure size matrix
     // width
     // $width = (!isset($this->params['named']['w'])) ? null : $this->params['named']['w'];
     // height
     // $height = (!isset($this->params['named']['h'])) ? null : $this->params['named']['h'];
     $sizecode = isset($this->params['named']['size']) ? $this->params['named']['size'] : null;
     // width
     $width = array_key_exists($sizecode, $this->sizes) ? $this->sizes[$sizecode][0] : 100;
     // height
     $height = array_key_exists($sizecode, $this->sizes) ? $this->sizes[$sizecode][1] : 100;
     $scaleMode = array_key_exists($sizecode, $this->sizes) ? $this->sizes[$sizecode][2] : 1;
     $anchor = array_key_exists($sizecode, $this->sizes) ? $this->sizes[$sizecode][3] : 'C';
     $sourceFilename = WWW_ROOT . $src;
     $maxSrcPixels = 10000000;
     // images over around 3megapixels seem to exhaust a memory limit of ??MB
     if (!file_exists($sourceFilename) || !is_file($sourceFilename)) {
         $sourceFilename = APP . 'plugins' . DS . 'file_library' . DS . 'webroot' . DS . 'img' . DS . 'admin' . DS . 'no-image.png';
     }
     $ext = strtolower(substr(strrchr($sourceFilename, '.'), 1));
     // get the file extension
     if (!in_array($ext, array('jpg', 'jpeg', 'png', 'gif'))) {
         $sourceFilename = APP . 'plugins' . DS . 'file_library' . DS . 'webroot' . DS . 'img' . DS . 'admin' . DS . 'image-unknown-format.png';
     }
     // this image size check is probably slowing the script down. better to check for ready-made thumbnail first
     $imgsize = getimagesize($sourceFilename);
     if (empty($imgsize)) {
         die("Could not check size of source image with getimagesize()");
     }
     if ($imgsize[0] * $imgsize[1] > $maxSrcPixels) {
         $sourceFilename = APP . 'plugins' . DS . 'file_library' . DS . 'webroot' . DS . 'img' . DS . 'admin' . DS . 'image-too-large.png';
     }
     if (is_readable($sourceFilename)) {
         //vendor("imageserver/imageserver.class");
         $result = App::import('Vendor', 'FileLibrary.ImageServer', array('file' => 'imageserver' . DS . 'imageserver.1.3.php'));
         $i = new ImageServer();
         $i->src = $sourceFilename;
         $i->cache_path = CACHE . 'thumbs' . DS;
         //$i->cache_required = false;
         $i->h = $height;
         $i->w = $width;
         $i->anchor = $anchor;
         $i->cache_required = true;
         $i->max_source_pixelcount = $maxSrcPixels;
         $i->scaleMode = $scaleMode;
         $i->attempt_memory_increase = 50000000;
         // false or integer in bytes
         $i->backgroundColour = array(0xff, 0xff, 0xff);
         //FFFFFF
         // only uncomment if debugging
         /*
         			if (function_exists('memory_get_peak_usage')) {
         				$mem_peak = memory_get_peak_usage();
         				$this->log('Displayed (and maybe created) a thumbnail, memory use was '.$mem_peak.' bytes',LOG_DEBUG);
         			}
         			else {
         				$this->log('Displayed a thumbnail but unable to log max memory use. Current is '.memory_get_usage().' bytes',LOG_DEBUG);
         			}*/
         if (!$i->output()) {
             echo $i->error;
         }
     } else {
         // Can't read source
         die("Couldn't read source image " . $sourceFilename);
     }
 }