Plugin Directory

Changeset 433681


Ignore:
Timestamp:
09/05/2011 07:39:38 PM (15 years ago)
Author:
moshthepitt
Message:

Committing DukaPress 2.3.4

Location:
dukapress/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • dukapress/trunk/dukapress.php

    r421103 r433681  
    33Plugin Name: DukaPress Shopping Cart
    44Description: DukaPress Shopping Cart
    5 Version: 2.3.3
     5Version: 2.3.4
    66Author: NetMadeEz and Nickel Pro
    77Author URI: http://dukapress.org/
     
    99*/
    1010
    11 $dp_version = 2.33;
     11$dp_version = 2.34;
    1212
    1313require_once('php/dp-products.php');
  • dukapress/trunk/lib/timthumb.php

    r421093 r433681  
    2121
    2222*/
    23 define ('VERSION', '2.5');                                      // Version of this script
     23define ('VERSION', '2.8');                                      // Version of this script
    2424//Load a config file if it exists. Otherwise, use the values below.
    2525if( file_exists('timthumb-config.php'))     require_once('timthumb-config.php');
     
    4444if(! defined('BROWSER_CACHE_DISABLE') )     define ('BROWSER_CACHE_DISABLE', false);        // Use for testing if you want to disable all browser caching
    4545
    46 //Image size
     46//Image size and defaults
    4747if(! defined('MAX_WIDTH') )             define ('MAX_WIDTH', 1500);             // Maximum image width
    4848if(! defined('MAX_HEIGHT') )            define ('MAX_HEIGHT', 1500);                // Maximum image height
     49if(! defined('NOT_FOUND_IMAGE') )       define ('NOT_FOUND_IMAGE', '');             //Image to serve if any 404 occurs
     50if(! defined('ERROR_IMAGE') )           define ('ERROR_IMAGE', '');             //Image to serve if an error occurs instead of showing error message
    4951
    5052//Image compression is enabled if either of these point to valid paths
     53
     54//These are now disabled by default because the file sizes of PNGs (and GIFs) are much smaller than we used to generate.
     55//They only work for PNGs. GIFs and JPEGs are not affected.
     56if(! defined('OPTIPNG_ENABLED') )       define ('OPTIPNG_ENABLED', false); 
    5157if(! defined('OPTIPNG_PATH') )          define ('OPTIPNG_PATH', '/usr/bin/optipng'); //This will run first because it gives better compression than pngcrush.
     58if(! defined('PNGCRUSH_ENABLED') )      define ('PNGCRUSH_ENABLED', false);
    5259if(! defined('PNGCRUSH_PATH') )         define ('PNGCRUSH_PATH', '/usr/bin/pngcrush'); //This will only run if OPTIPNG_PATH is not set or is not valid
    5360
     
    96103if(! defined('WEBSHOT_COLOR_DEPTH') )   define ('WEBSHOT_COLOR_DEPTH', '24');           //I haven't tested anything besides 24
    97104if(! defined('WEBSHOT_IMAGE_FORMAT') )  define ('WEBSHOT_IMAGE_FORMAT', 'png');         //png is about 2.5 times the size of jpg but is a LOT better quality
    98 if(! defined('WEBSHOT_TIMEOUT') )   define ('WEBSHOT_TIMEOUT', '300');          //Seconds to wait for a webshot
     105if(! defined('WEBSHOT_TIMEOUT') )   define ('WEBSHOT_TIMEOUT', '20');           //Seconds to wait for a webshot
    99106if(! defined('WEBSHOT_USER_AGENT') )    define ('WEBSHOT_USER_AGENT', "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.18) Gecko/20110614 Firefox/3.6.18"); //I hate to do this, but a non-browser robot user agent might not show what humans see. So we pretend to be Firefox
    100107if(! defined('WEBSHOT_JAVASCRIPT_ON') ) define ('WEBSHOT_JAVASCRIPT_ON', true);         //Setting to false might give you a slight speedup and block ads. But it could cause other issues.
     
    126133class timthumb {
    127134    protected $src = "";
     135    protected $is404 = false;
    128136    protected $docRoot = "";
    129137    protected $lastURLError = false;
     
    164172        global $ALLOWED_SITES;
    165173        $this->startTime = microtime(true);
     174        date_default_timezone_set('UTC');
    166175        $this->debug(1, "Starting new request from " . $this->getIP() . " to " . $_SERVER['REQUEST_URI']);
    167176        $this->calcDocRoot();
     
    178187            }
    179188            $this->cacheDirectory = FILE_CACHE_DIRECTORY;
    180             touch($this->cacheDirectory . '/index.php');
    181189            touch($this->cacheDirectory . '/index.html');
    182190        } else {
     
    194202        }
    195203        if(BLOCK_EXTERNAL_LEECHERS && array_key_exists('HTTP_REFERER', $_SERVER) && (! preg_match('/^https?:\/\/(?:www\.)?' . $this->myHost . '(?:$|\/)/i', $_SERVER['HTTP_REFERER']))){
     204            // base64 encoded red image that says 'no hotlinkers'
     205            // nothing to worry about! :)
    196206            $imgData = base64_decode("R0lGODlhUAAMAIAAAP8AAP///yH5BAAHAP8ALAAAAABQAAwAAAJpjI+py+0Po5y0OgAMjjv01YUZ\nOGplhWXfNa6JCLnWkXplrcBmW+spbwvaVr/cDyg7IoFC2KbYVC2NQ5MQ4ZNao9Ynzjl9ScNYpneb\nDULB3RP6JuPuaGfuuV4fumf8PuvqFyhYtjdoeFgAADs=");
    197207            header('Content-Type: image/gif');
     
    241251            $this->localImage = $this->getLocalImagePath($this->src);
    242252            if(! $this->localImage){
     253                $this->debug(1, "Could not find the local image: {$this->localImage}");
    243254                $this->error("Could not find the internal image you specified.");
     255                $this->set404();
    244256                return false;
    245257            }
     
    277289                $this->debug(3, "webshot is NOT set so we're going to try to fetch a regular image.");
    278290                $this->serveExternalImage();
     291
    279292            }
    280293        } else {
     
    286299    protected function handleErrors(){
    287300        if($this->haveErrors()){
     301            if(NOT_FOUND_IMAGE && $this->is404()){
     302                if($this->serveImg(NOT_FOUND_IMAGE)){
     303                    exit(0);
     304                } else {
     305                    $this->error("Additionally, the 404 image that is configured could not be found or there was an error serving it.");
     306                }
     307            }
     308            if(ERROR_IMAGE){
     309                if($this->serveImg(ERROR_IMAGE)){
     310                    exit(0);
     311                } else {
     312                    $this->error("Additionally, the error image that is configured could not be found or there was an error serving it.");
     313                }
     314            }
     315               
    288316            $this->serveErrors();
    289317            exit(0);
     
    343371                    } else {
    344372                        $this->debug(3, "Empty cachefile is still fresh so returning message saying we had an error fetching this image from remote host.");
     373                        $this->set404();
    345374                        $this->error("An error occured fetching image.");
    346375                        return false;
     
    673702        }
    674703        //Straight from Wordpress core code. Reduces filesize by up to 70% for PNG's
    675         if ( IMAGETYPE_PNG == $origType && function_exists('imageistruecolor') && !imageistruecolor( $image ) ){
     704        if ( (IMAGETYPE_PNG == $origType || IMAGETYPE_GIF == $origType) && function_exists('imageistruecolor') && !imageistruecolor( $image ) && imagecolortransparent( $image ) > 0 ){
    676705            imagetruecolortopalette( $canvas, false, imagecolorstotal( $image ) );
    677706        }
     
    687716        } else if(preg_match('/^image\/gif$/i', $mimeType)){
    688717            $imgType = 'gif';
    689             imagepng($canvas, $tempfile, floor($quality * 0.09));
     718            imagegif($canvas, $tempfile);
    690719        } else {
    691720            return $this->sanityFail("Could not match mime type after verifying it previously.");
    692721        }
    693722
    694         if( OPTIPNG_PATH && @is_file(OPTIPNG_PATH)){
     723        if($imgType == 'png' && OPTIPNG_ENABLED && OPTIPNG_PATH && @is_file(OPTIPNG_PATH)){
    695724            $exec = OPTIPNG_PATH;
    696725            $this->debug(3, "optipng'ing $tempfile");
     
    707736                $this->debug(1, "optipng did not change image size.");
    708737            }
    709         } else if(PNGCRUSH_PATH && @is_file(PNGCRUSH_PATH)){
     738        } else if($imgType == 'png' && PNGCRUSH_ENABLED && PNGCRUSH_PATH && @is_file(PNGCRUSH_PATH)){
    710739            $exec = PNGCRUSH_PATH;
    711740            $tempfile2 = tempnam($this->cacheDirectory, 'timthumb_tmpimg_');
     
    758787        $this->debug(3, "Done image replace with security header. Cleaning up and running cleanCache()");
    759788        imagedestroy($canvas);
     789        imagedestroy($image);
    760790        return true;
    761791    }
     
    776806            }
    777807        }
    778         if($docRoot){ $docRoot = preg_replace('/\/$/', '', $docRoot); }
     808        if($docRoot && $_SERVER['DOCUMENT_ROOT'] != '/'){ $docRoot = preg_replace('/\/$/', '', $docRoot); }
    779809        $this->debug(3, "Doc root is: " . $docRoot);
    780810        $this->docRoot = $docRoot;
     
    877907        $this->debug(3, "Received output: $out");
    878908        if(! is_file($tempfile)){
     909            $this->set404();
    879910            return $this->error("The command to create a thumbnail failed.");
    880911        }
     
    962993    }
    963994    protected function sendImageHeaders($mimeType, $dataSize){
     995        if(! preg_match('/^image\//i', $mimeType)){
     996            $mimeType = 'image/' . $mimeType;
     997        }
     998        if(strtolower($mimeType) == 'image/jpg'){
     999            $mimeType = 'image/jpeg';
     1000        }
    9641001        $gmdate_expires = gmdate ('D, d M Y H:i:s', strtotime ('now +10 days')) . ' GMT';
    9651002        $gmdate_modified = gmdate ('D, d M Y H:i:s') . ' GMT';
     
    9921029    protected function openImage($mimeType, $src){
    9931030        switch ($mimeType) {
    994             case 'image/jpg':
    995                 $image = imagecreatefromjpeg ($src);
    996                 break;
     1031            case 'image/jpg': //This isn't a valid mime type so we should probably remove it
    9971032            case 'image/jpeg':
    9981033                $image = imagecreatefromjpeg ($src);
     
    10901125            $curlResult = curl_exec($curl);
    10911126            fclose(self::$curlFH);
    1092 
     1127            $httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     1128            if($httpStatus == 404){
     1129                $this->set404();
     1130            }
    10931131            if($curlResult){
    10941132                curl_close($curl);
     
    11021140            $img = @file_get_contents ($url);
    11031141            if($img === false){
    1104                 $this->lastURLError = error_get_last();
     1142                $err = error_get_last();
     1143                if(is_array($err) && $err['message']){
     1144                    $this->lastURLError = $err['message'];
     1145                } else {
     1146                    $this->lastURLError = $err;
     1147                }
     1148                if(preg_match('/404/', $this->lastURLError)){
     1149                    $this->set404();
     1150                }
     1151
    11051152                return false;
    11061153            }
     
    11131160
    11141161    }
     1162    protected function serveImg($file){
     1163        $s = getimagesize($file);
     1164        if(! ($s && $s['mime'])){
     1165            return false;
     1166        }
     1167        header ('Content-Type: ' . $s['mime']);
     1168        header ('Content-Length: ' . filesize($file) );
     1169        header ('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
     1170        header ("Pragma: no-cache");
     1171        $bytes = @readfile($file);
     1172        if($bytes > 0){
     1173            return true;
     1174        }
     1175        $content = @file_get_contents ($file);
     1176        if ($content != FALSE){
     1177            echo $content;
     1178            return true;
     1179        }
     1180        return false;
     1181
     1182    }
     1183    protected function set404(){
     1184        $this->is404 = true;
     1185    }
     1186    protected function is404(){
     1187        return $this->is404;
     1188    }
    11151189}
    1116 ?>
  • dukapress/trunk/php/dp-cart.php

    r398928 r433681  
    126126 */
    127127add_action('wp_ajax_dpsc_empty_your_cart', 'dpsc_empty_cart');
    128 add_action('wp_ajax_no_priv_dpsc_empty_your_cart', 'dpsc_empty_cart');
     128add_action('wp_ajax_nopriv_dpsc_empty_your_cart', 'dpsc_empty_cart');
    129129
    130130function dpsc_empty_cart() {
  • dukapress/trunk/php/dp-payment.php

    r398899 r433681  
    275275                        <input type="hidden" name="cartId" value="101KT0098" />
    276276                        <input type="hidden" name="amount" value="' . $dpsc_total . '" />
    277                         <input type="hidden" name="testMode" value="' . $dp_shopping_cart_settings['worldpay_testmode'] . '" />
     277                        <input type="hidden" name="testMode" value="' . $testModeVal . '" />
    278278                        <input type="hidden" name="name" value="' . $name . '" />
    279279                        <input type="hidden" name="address" value="' . $baddress . ' ' . $bcity . ' ' . $bstate . '" />
  • dukapress/trunk/readme.txt

    r421103 r433681  
    66Requires at least: 3.0
    77Tested up to: 3.2.1
    8 Stable tag: 2.3.3
     8Stable tag: 2.3.4
    99
    1010DukaPress is an open source e-commerce solution built for Wordpress.
     
    41411. [DukaPress Styles](http://dukapress.com/products/styles/ "DukaPress Styles - make DukaPress look good without getting a new theme")
    42421. [Shipping Pro](http://dukapress.com/products/shipping-pro/ "Shipping Pro - location-based shipping")
     431. [List View](http://dukapress.com/products/list-view/ "DukaPress List View - display your products in a handy list")
    4344
    4445Premium Themes:
     
    105106
    106107== Changelog ==
     108
     109= 2.3.4 =
     110Some small, but annoying, bugs have been fixed.  Timthumb updated for continued security.
    107111
    108112= 2.3.3 =
     
    188192== Upgrade Notice ==
    189193
     194= 2.3.4 =
     195Bugfix release.
     196
    190197= 2.3.3 =
    191198Security update.
Note: See TracChangeset for help on using the changeset viewer.