Plugin Directory

Changeset 458263


Ignore:
Timestamp:
11/01/2011 01:45:14 PM (14 years ago)
Author:
moshthepitt
Message:

Committing changes as follows:

  1. Inquiry bugfix

Line 1243 dp-cart.php => $array1 = array('%from%', '%from_email%', '%details%', '%enq_subject%', '%custom_message%');

  1. Add "Out of Stock" Button Line 183 dp-products.php
  1. Add variations to shopping cart dp-widgets Line 201
  1. Remove price from variations drop-down dp-products.php line 74
  1. Adding DukaPress affiliate mode
  1. Added timthumb version 2.8.2
Location:
dukapress/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • dukapress/trunk/dukapress.php

    r433681 r458263  
    785785        $dp_checkout_url = $_POST['dp_checkout_url'];
    786786        $dp_thank_you_url = $_POST['dp_thank_you_url'];
     787        $dp_affiliate_url = $_POST['dp_affiliate_url'];
    787788        $dp_tax = $_POST['dp_tax'];
    788789        $dp_shop_paypal_id = $_POST['dp_shop_paypal_id'];
     
    888889        $dp_shopping_cart_settings['checkout'] = $dp_checkout_url;
    889890        $dp_shopping_cart_settings['thank_you'] = $dp_thank_you_url;
     891        $dp_shopping_cart_settings['affiliate_url'] = $dp_affiliate_url;
    890892        $dp_shopping_cart_settings['tax'] = $dp_tax;
    891893        $dp_shopping_cart_settings['dp_shop_country'] = $dp_shop_country;
     
    11061108                        <td>
    11071109                            <input size="50" type="text" value="<?php if(isset($dp_shopping_cart_settings['thank_you'])) {echo $dp_shopping_cart_settings['thank_you'];}?>" name="dp_thank_you_url">
     1110                        </td>
     1111                    </tr>
     1112                    <tr>
     1113                        <th scope="row"><?php _e("Affiliate URL","dp-lang");?></th>
     1114                        <td>
     1115                            <input size="50" type="text" value="<?php if(isset($dp_shopping_cart_settings['affiliate_url'])) {echo $dp_shopping_cart_settings['affiliate_url'];}?>" name="dp_affiliate_url">
    11081116                        </td>
    11091117                    </tr>
  • dukapress/trunk/lib/timthumb.php

    r433681 r458263  
    2121
    2222*/
    23 define ('VERSION', '2.8');                                      // Version of this script
    24 //Load a config file if it exists. Otherwise, use the values below.
    25 if( file_exists('timthumb-config.php'))     require_once('timthumb-config.php');
    26 if(! defined( 'DEBUG_ON' ) )            define ('DEBUG_ON', false);             // Enable debug logging to web server error log (STDERR)
     23define ('VERSION', '2.8.2');                                        // Version of this script
     24//Load a config file if it exists. Otherwise, use the values below
     25if( file_exists(dirname(__FILE__) . '/timthumb-config.php'))    require_once('timthumb-config.php');
     26if(! defined('DEBUG_ON') )          define ('DEBUG_ON', false);             // Enable debug logging to web server error log (STDERR)
    2727if(! defined('DEBUG_LEVEL') )           define ('DEBUG_LEVEL', 1);              // Debug level 1 is less noisy and 3 is the most noisy
    2828if(! defined('MEMORY_LIMIT') )          define ('MEMORY_LIMIT', '30M');             // Set PHP memory limit
     
    115115if(! isset($ALLOWED_SITES)){
    116116    $ALLOWED_SITES = array (
    117             'flickr.com',
    118             'picasa.com',
    119             'img.youtube.com',
    120             'upload.wikimedia.org',
    121             'photobucket.com',
    122             'imgur.com',
    123             'imageshack.us',
    124             'tinypic.com'
     117        'flickr.com',
     118        'picasa.com',
     119        'img.youtube.com',
     120        'upload.wikimedia.org',
     121        'photobucket.com',
     122        'imgur.com',
     123        'imageshack.us',
     124        'tinypic.com',
    125125    );
    126126}
     
    187187            }
    188188            $this->cacheDirectory = FILE_CACHE_DIRECTORY;
    189             touch($this->cacheDirectory . '/index.html');
     189            if (!touch($this->cacheDirectory . '/index.html')) {
     190                $this->error("Could note create the index.html file.");
     191            }
    190192        } else {
    191193            $this->cacheDirectory = sys_get_temp_dir();
     
    234236                $allowed = false;
    235237                foreach($ALLOWED_SITES as $site){
    236                     if (preg_match ('/(?:^|\.)' . $site . '$/i', $this->url['host'])) {
     238                    if ((strtolower(substr($this->url['host'],-strlen($site)-1)) === strtolower(".$site")) || (strtolower($this->url['host'])===strtolower($site))) {
    237239                        $this->debug(3, "URL hostname {$this->url['host']} matches $site so allowing.");
    238240                        $allowed = true;
     
    349351            } else { //Otherwise serve a 304
    350352                $this->debug(3, "File has not been modified since last get, so serving a 304.");
    351                 header ('HTTP/1.1 304 Not Modified');
     353                header ($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
    352354                $this->debug(1, "Returning 304 not modified");
    353355                return true;
     
    408410        }
    409411        $html .= '</ul>';
    410         header ('HTTP/1.1 400 Bad Request');
     412        header ($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
    411413        echo '<h1>A TimThumb error has occured</h1>The following error(s) occured:<br />' . $html . '<br />';
    412414        echo '<br />Query String : ' . htmlentities ($_SERVER['QUERY_STRING']);
     
    443445        if(! is_file($lastCleanFile)){
    444446            $this->debug(1, "File tracking last clean doesn't exist. Creating $lastCleanFile");
    445             touch($lastCleanFile);
     447            if (!touch($lastCleanFile)) {
     448                $this->error("Could note create cache clean timestamp file.");
     449            }
    446450            return;
    447451        }
     
    449453            $this->debug(1, "Cache was last cleaned more than " . FILE_CACHE_TIME_BETWEEN_CLEANS . " seconds ago. Cleaning now.");
    450454            // Very slight race condition here, but worst case we'll have 2 or 3 servers cleaning the cache simultaneously once a day.
    451             touch($lastCleanFile);
     455            if (!touch($lastCleanFile)) {
     456                $this->error("Could note create cache clean timestamp file.");
     457            }
    452458            $files = glob($this->cacheDirectory . '/*' . FILE_CACHE_SUFFIX);
    453459            $timeAgo = time() - FILE_CACHE_MAX_FILE_AGE;
     
    813819    protected function getLocalImagePath($src){
    814820        $src = preg_replace('/^\//', '', $src); //strip off the leading '/'
    815         $realDocRoot = realpath($this->docRoot);  //See issue 224. Using realpath as a windows fix.
    816821        if(! $this->docRoot){
    817822            $this->debug(3, "We have no document root set, so as a last resort, lets check if the image is in the current dir and serve that.");
     
    828833            $this->debug(3, "Found file as " . $this->docRoot . '/' . $src);
    829834            $real = realpath($this->docRoot . '/' . $src);
    830             if(strpos($real, $realDocRoot) === 0){
     835            if(stripos($real, $this->docRoot) === 0){
    831836                return $real;
    832837            } else {
     
    840845            $this->debug(3, "Found absolute path: $absolute");
    841846            if(! $this->docRoot){ $this->sanityFail("docRoot not set when checking absolute path."); }
    842             if(strpos($absolute, $realDocRoot) === 0){
     847            if(stripos($absolute, $this->docRoot) === 0){
    843848                return $absolute;
    844849            } else {
     
    847852            }
    848853        }
     854       
    849855        $base = $this->docRoot;
    850         foreach (explode('/', str_replace($this->docRoot, '', $_SERVER['SCRIPT_FILENAME'])) as $sub){
     856       
     857        // account for Windows directory structure
     858        if (strstr($_SERVER['SCRIPT_FILENAME'],':')) {
     859            $sub_directories = explode('\\', str_replace($this->docRoot, '', $_SERVER['SCRIPT_FILENAME']));
     860        } else {
     861            $sub_directories = explode('/', str_replace($this->docRoot, '', $_SERVER['SCRIPT_FILENAME']));
     862        }
     863       
     864        foreach ($sub_directories as $sub){
    851865            $base .= $sub . '/';
    852866            $this->debug(3, "Trying file as: " . $base . $src);
     
    854868                $this->debug(3, "Found file as: " . $base . $src);
    855869                $real = realpath($base . $src);
    856                 if(strpos($real, $realDocRoot) === 0){
     870                if(stripos($real, $this->docRoot) === 0){
    857871                    return $real;
    858872                } else {
  • dukapress/trunk/php/dp-products.php

    r456741 r458263  
    88 *
    99 */
    10 function dpsc_get_product_details($product_id, $buy_now = false, $direct = false) {
     10function dpsc_get_product_details($product_id, $buy_now = false, $direct = false, $affiliate = false) {
    1111    global $wpdb;
    1212
     
    2020//          $form_id = 'dpsc_product_direct_form_' . $product_id;
    2121//        }
     22       
     23       
    2224        $custom_fields_output['start'] = '<form id="' . $form_id . '" name="dpsc_product_form_' . $product_id . '" class="product_form" action="" method="post" enctype="multipart/form-data">';
    2325        if ($dp_shopping_cart_settings['dp_shop_mode'] != 'inquiry') {
     
    2729            } else {
    2830                $product_price = $all_custom_fields['price'][0];
    29                 $custom_fields_output['price'] = '<p class="dpsc_price">' . __('Price:', "dp-lang") . ' ' . $dp_shopping_cart_settings['dp_currency_symbol'] . '<span class="is">' . $all_custom_fields['price'][0] . '</span></p>';
     31                $custom_fields_output['price'] = '<p class="dpsc_price">' . __('Price:', "dp-lang") . ' ' . $dp_shopping_cart_settings['dp_currency_symbol'] . '<span class="is">' . $all_custom_fields['price'][0]. '</span></p>';
    3032            }
    3133        }
     
    3941            $action = 'dpsc_paypal_button';
    4042        }
    41         //Dukapress affiliate mode
    4243        if ($affiliate) {
    4344            $action = 'dpsc_affiliate';
    4445        }
     46       
    4547//        if ($direct) {
    4648//            $action = 'dpsc_direct_checkout_button';
     
    6971                        $var_price = floatval($get_var[1]);
    7072                        $var_price_display = number_format(floatval($get_var[1]), 2);
    71                         if ($var_price != 0.00 && ($dp_shopping_cart_settings['dp_shop_mode'] != 'inquiry')) {
    72                             $var_price_text = ' ( ' . $dp_shopping_cart_settings['dp_currency_symbol'] . $var_price_display . ' ) ';
     73                        if ($var_price != 0.00 && ($dp_shopping_cart_settings['dp_shop_mode'] != 'inquiry' && !$affiliate)) {
     74                            //$var_price_text = ' ( ' . $dp_shopping_cart_settings['dp_currency_symbol'] . $var_price_display . ' ) ';
    7375                        }
    7476                    }
     
    326328    extract(shortcode_atts(array(
    327329                'buy_now' => '',
    328                 'direct' => ''
     330                'direct' => '',
     331                'affiliate' => ''
    329332                    ), $atts));
    330333    $p_b_n = false;
     
    336339        $direct_checkout = true;
    337340    }
     341    $affiliate_checkout = false;
     342    if (!empty($affiliate)) {
     343        $affiliate_checkout = true;
     344    }
    338345    $product_id = get_the_ID();
    339     $output = dpsc_get_product_details($product_id, $p_b_n, $direct_checkout);
     346    $output = dpsc_get_product_details($product_id, $p_b_n, $direct_checkout, $affiliate_checkout);
    340347    $content .= '<div class="dpsc_product_main_container">';
    341348    $content .= '<div class="dpsc_image_container">';
     
    367374    if (!empty($buy_now)) {
    368375        $p_b_n = true;
     376    }
     377    $affiliate_checkout = false;
     378    if (!empty($affiliate)) {
     379        $affiliate_checkout = true;
    369380    }
    370381    $product_id = get_the_ID();
     
    408419                'order' => 'DESC',
    409420                'direct' => '',
     421                'affiliate' => '',
    410422                'buy_now' => ''
    411423                    ), $atts));
     
    418430    if (!empty($direct)) {
    419431        $direct_checkout = true;
     432    }
     433    $affiliate_checkout = false;
     434    if (!empty($affiliate)) {
     435        $affiliate_checkout = true;
    420436    }
    421437    if (!empty($per_page)) {
     
    449465        $all_count = 0;
    450466        foreach ($products as $product) {
    451             $output = dpsc_get_product_details($product->ID, $p_b_n, $direct_checkout);
     467            $output = dpsc_get_product_details($product->ID, $p_b_n, $direct_checkout, $affiliate_checkout);
    452468            if ($output) {
    453469                $attachment_images = &get_children('post_type=attachment&post_status=inherit&post_mime_type=image&post_parent=' . $product->ID);
     
    557573    $content_weight = get_post_meta($post_id, 'item_weight', true);
    558574    $content_file = get_post_meta($post_id, 'digital_file', true);
     575    $affiliate_url = get_post_meta($post_id, 'affiliate_url', true);
    559576?>
    560577    <table>
     
    564581        <tr><td><label for="item_weight"><b><?php _e('Item Weight:', "dp-lang"); ?></b></label></td><td><input id="item_weight" type="text" name="item_weight" value="<?php echo $content_weight; ?>" /> (<?php _e('in grams', "dp-lang"); ?>)</td></tr>
    565582        <tr><td><label for="digital_file"><b><?php _e('Digital File:', "dp-lang"); ?></b></label></td><td><input id="digital_file" type="text" name="digital_file" value="<?php echo $content_file; ?>" /></td></tr>
     583        <tr><td><label for="affiliate_url"><b><?php _e('Affiliate URL:', "dp-lang"); ?></b></label></td><td><input id="affiliate_url" type="text" name="affiliate_url" value="<?php echo $affiliate_url; ?>" /></td></tr>
    566584    </table>
    567585
     
    704722        update_post_meta($post_id, '_Content_Counter', $content_counter);
    705723    }
     724   
     725   
     726    // for option name
     727    if (NULL == $_POST['affiliate_url']) {
     728        //do nothing
     729    } else {
     730        $affiliate_url = $_POST['affiliate_url'];
     731        update_post_meta($post_id, 'affiliate_url', $affiliate_url);
     732    }
     733   
     734   
    706735}
    707736
  • dukapress/trunk/php/dp-widgets.php

    r456734 r458263  
    199199                    $dpsc_at_checkout_to_be_displayed_price = '';
    200200                }
    201                 $dpsc_var = '';
     201                $dpsc_var = '';
    202202                if (!empty($dpsc_product_in_cart['var'])) {
    203203                    $dpsc_var = ' (' . $dpsc_product_in_cart['var'] . ')';
Note: See TracChangeset for help on using the changeset viewer.