[ Indice ]

Riferimento incrociato di Joomla! 1.5.14 - VM 1.1.4

Servizio fornito da VMItalia
Classe:   Funzione:   Variabile:   Costante:  
Storico Ricerche +

titolo

Corpo

[chiudi]

/components/com_virtuemart/ -> show_image_in_imgtag.php (sorgente)

   1  <?php
   2  /**

   3  * Image Resizer & img Tag "Filler"

   4  *

   5  * @author Andreas Martens <heyn@plautdietsch.de>

   6  * @author Patrick Teague <webdude@veslach.com>

   7  *

   8  * @version $Id: show_image_in_imgtag.php 1646 2009-02-16 19:40:16Z tkahl $

   9  * @package VirtueMart

  10  * @subpackage core

  11  * @copyright Copyright (C) 2004-2008 soeren - All rights reserved.

  12  * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php

  13  * VirtueMart is free software. This version may have been modified pursuant

  14  * to the GNU General Public License, and as distributed it includes or

  15  * is derivative of works licensed under the GNU General Public License or

  16  * other free or open source software licenses.

  17  * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.

  18  *

  19  * http://virtuemart.net

  20  */
  21  define('_VALID_MOS', 1);
  22  
  23  // Get the Joomla! configuration file

  24  $config_file = '../../configuration.php';
  25  include_once( $config_file );
  26  
  27  if( isset($_REQUEST['mosConfig_absolute_path'])) die();
  28  
  29  if( !isset( $mosConfig_absolute_path ) ) {
  30  // We are in J! 1.5

  31      define( '_JEXEC', 1 );
  32      $mosConfig_absolute_path = dirname( $config_file );
  33  }
  34  
  35  include_once ("../../administrator/components/com_virtuemart/virtuemart.cfg.php");
  36  
  37  $resize_image = true;
  38  // check if dynamic thumbnails are disabled or the GD Library is not available

  39  if( PSHOP_IMG_RESIZE_ENABLE == '') {
  40      $resize_image = false;
  41  }
  42  elseif (!extension_loaded('gd') && !dl('gd.so')) {
  43      $resize_image = false;
  44  }
  45   
  46  include ( CLASSPATH . "ps_main.php");
  47      
  48  if( $resize_image ) {
  49      //    Image2Thumbnail will resize your images

  50      include ( CLASSPATH . "class.img2thumb.php");
  51  }
  52  
  53  $basefilename = @basename(urldecode($_REQUEST['filename']));
  54  $filenames[] = IMAGEPATH."product/".$basefilename;
  55  $resized_filenames[] = IMAGEPATH."product/resized/".$basefilename;
  56  $filenames[] = IMAGEPATH."category/".$basefilename;
  57  $resized_filenames[] = IMAGEPATH."category/resized/".$basefilename;
  58  $newxsize = (int)@$_REQUEST['newxsize'] == 0 ? PSHOP_IMG_WIDTH : (int)@$_REQUEST['newxsize'];
  59  $newysize = (int)@$_REQUEST['newysize'] == 0 ? PSHOP_IMG_WIDTH : (int)@$_REQUEST['newysize'];
  60  
  61  // Don't allow sizes beyond 600 pixels

  62  $newxsize = min( $newxsize, 600 );
  63  $newysize = min( $newysize, 600 );
  64  
  65  //Don't allow sizes under 40 pixels

  66  $newxsize = max( $newxsize, 40 );
  67  $newysize = max( $newysize, 40 );
  68  
  69  if( $newxsize < $newysize ) {
  70      // Don't let $newxsize be smaller than 55% of $newysize

  71      $newxsize = max( $newxsize, 0.55 * $newysize );
  72  }
  73  elseif( $newysize < $newxsize ) {
  74      // Don't let $newysize be smaller than 55% of $newxsize

  75      $newysize = max( $newysize, 0.55 * $newxsize );
  76  }
  77  $maxsize = false;
  78  $bgred = 255;
  79  $bggreen = 255;
  80  $bgblue = 255;
  81  
  82  /*

  83  if( !isset($fileout) )

  84      $fileout="";

  85  if( !isset($maxsize) )

  86      $maxsize=0;

  87  */
  88  
  89  /* Minimum security */

  90  $file_exists = false;
  91  $i = 0;
  92  foreach ( $filenames as $file ) {
  93      if( file_exists( $file ) ) {
  94          $file_exists = true;
  95          $filename = $file;
  96          break;
  97      } elseif( file_exists($resized_filenames[$i])) {
  98          $file_exists = true;
  99          $filename = $resized_filenames[$i];
 100          break;        
 101      }
 102      ++$i;
 103  }
 104  $file_exists or die('File does not exist');
 105  
 106  $filename2 = $resized_filenames[$i];
 107  
 108  $fileinfo = pathinfo( $filename );
 109  $file = str_replace(".".$fileinfo['extension'], "", $fileinfo['basename']);
 110  // In class.img2thumb in the function NewImgShow() the extension .jpg will be added to .gif if imagegif does not exist.

 111  
 112  // If the image is a gif, and imagegif() returns false then make the extension ".gif.jpg"

 113  
 114  if( $fileinfo['extension'] == "gif") {
 115    if( function_exists("imagegif") ) {
 116      $ext = ".".$fileinfo['extension'];
 117      $noimgif="";
 118    }
 119    else {
 120      $ext = ".jpg";
 121      $noimgif = ".".$fileinfo['extension'];
 122    }
 123  } 
 124  else {
 125    $ext =  ".".$fileinfo['extension'];
 126    $noimgif="";
 127  }
 128  
 129  if( $resize_image ) {
 130      if( file_exists($filename2)) { 
 131          $fileout = $filename2;
 132      } else {
 133          $fileout = dirname( $filename2 ) .'/'.$file."_".$newxsize."x".$newysize.$noimgif.$ext;
 134      }
 135  } else {
 136      $fileout = $filename;
 137  }
 138  // Tell the user agent to cache this script/stylesheet for an hour

 139  $age = 3600;
 140  header( 'Expires: '.gmdate( 'D, d M Y H:i:s', time()+ $age ) . ' GMT' );
 141  header( 'Cache-Control: max-age='.$age.', must-revalidate' );
 142  
 143  if( file_exists( $fileout ) ) {
 144      // Try to delete the resized image if the original file is newer

 145      if (filemtime($fileout) < filemtime($filename)) @unlink($fileout);
 146  }
 147  
 148  if( file_exists( $fileout ) ) {
 149    /* We already have a resized image

 150    * So send the file to the browser */
 151        switch(strtolower($ext))
 152          {
 153              case ".gif":
 154                  header ("Content-type: image/gif");
 155                  readfile($fileout);
 156                  break;
 157              case ".jpg":
 158                  header ("Content-type: image/jpeg");
 159                  readfile($fileout);
 160                  break;
 161              case ".png":
 162                  header ("Content-type: image/png");
 163                  readfile($fileout);
 164                  break;
 165          }
 166  }
 167  else {
 168       /* We need to resize the image and Save the new one (all done in the constructor) */

 169        $neu = new Img2Thumb($filename,$newxsize,$newysize,$fileout,$maxsize,$bgred,$bggreen,$bgblue);
 170        
 171        /* Send the file to the browser */

 172        switch($ext)
 173          {
 174              case ".gif":
 175                  header ("Content-type: image/gif");
 176                  readfile($fileout);
 177                  break;
 178              case ".jpg":
 179                  header ("Content-type: image/jpeg");
 180                  readfile($fileout);
 181                  break;
 182              case ".png":
 183                  header ("Content-type: image/png");
 184                  readfile($fileout);
 185                  break;
 186          }
 187  }
 188  ?>


Generato il: Mon Oct 19 20:29:27 2009 Generato con PHPXref 0.7