Changeset 458263
- Timestamp:
- 11/01/2011 01:45:14 PM (14 years ago)
- Location:
- dukapress/trunk
- Files:
-
- 4 edited
-
dukapress.php (modified) (3 diffs)
-
lib/timthumb.php (modified) (13 diffs)
-
php/dp-products.php (modified) (14 diffs)
-
php/dp-widgets.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
dukapress/trunk/dukapress.php
r433681 r458263 785 785 $dp_checkout_url = $_POST['dp_checkout_url']; 786 786 $dp_thank_you_url = $_POST['dp_thank_you_url']; 787 $dp_affiliate_url = $_POST['dp_affiliate_url']; 787 788 $dp_tax = $_POST['dp_tax']; 788 789 $dp_shop_paypal_id = $_POST['dp_shop_paypal_id']; … … 888 889 $dp_shopping_cart_settings['checkout'] = $dp_checkout_url; 889 890 $dp_shopping_cart_settings['thank_you'] = $dp_thank_you_url; 891 $dp_shopping_cart_settings['affiliate_url'] = $dp_affiliate_url; 890 892 $dp_shopping_cart_settings['tax'] = $dp_tax; 891 893 $dp_shopping_cart_settings['dp_shop_country'] = $dp_shop_country; … … 1106 1108 <td> 1107 1109 <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"> 1108 1116 </td> 1109 1117 </tr> -
dukapress/trunk/lib/timthumb.php
r433681 r458263 21 21 22 22 */ 23 define ('VERSION', '2.8 '); // Version of this script24 //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)23 define ('VERSION', '2.8.2'); // Version of this script 24 //Load a config file if it exists. Otherwise, use the values below 25 if( file_exists(dirname(__FILE__) . '/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) 27 27 if(! defined('DEBUG_LEVEL') ) define ('DEBUG_LEVEL', 1); // Debug level 1 is less noisy and 3 is the most noisy 28 28 if(! defined('MEMORY_LIMIT') ) define ('MEMORY_LIMIT', '30M'); // Set PHP memory limit … … 115 115 if(! isset($ALLOWED_SITES)){ 116 116 $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', 125 125 ); 126 126 } … … 187 187 } 188 188 $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 } 190 192 } else { 191 193 $this->cacheDirectory = sys_get_temp_dir(); … … 234 236 $allowed = false; 235 237 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))) { 237 239 $this->debug(3, "URL hostname {$this->url['host']} matches $site so allowing."); 238 240 $allowed = true; … … 349 351 } else { //Otherwise serve a 304 350 352 $this->debug(3, "File has not been modified since last get, so serving a 304."); 351 header ( 'HTTP/1.1304 Not Modified');353 header ($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified'); 352 354 $this->debug(1, "Returning 304 not modified"); 353 355 return true; … … 408 410 } 409 411 $html .= '</ul>'; 410 header ( 'HTTP/1.1400 Bad Request');412 header ($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request'); 411 413 echo '<h1>A TimThumb error has occured</h1>The following error(s) occured:<br />' . $html . '<br />'; 412 414 echo '<br />Query String : ' . htmlentities ($_SERVER['QUERY_STRING']); … … 443 445 if(! is_file($lastCleanFile)){ 444 446 $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 } 446 450 return; 447 451 } … … 449 453 $this->debug(1, "Cache was last cleaned more than " . FILE_CACHE_TIME_BETWEEN_CLEANS . " seconds ago. Cleaning now."); 450 454 // 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 } 452 458 $files = glob($this->cacheDirectory . '/*' . FILE_CACHE_SUFFIX); 453 459 $timeAgo = time() - FILE_CACHE_MAX_FILE_AGE; … … 813 819 protected function getLocalImagePath($src){ 814 820 $src = preg_replace('/^\//', '', $src); //strip off the leading '/' 815 $realDocRoot = realpath($this->docRoot); //See issue 224. Using realpath as a windows fix.816 821 if(! $this->docRoot){ 817 822 $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."); … … 828 833 $this->debug(3, "Found file as " . $this->docRoot . '/' . $src); 829 834 $real = realpath($this->docRoot . '/' . $src); 830 if(str pos($real, $realDocRoot) === 0){835 if(stripos($real, $this->docRoot) === 0){ 831 836 return $real; 832 837 } else { … … 840 845 $this->debug(3, "Found absolute path: $absolute"); 841 846 if(! $this->docRoot){ $this->sanityFail("docRoot not set when checking absolute path."); } 842 if(str pos($absolute, $realDocRoot) === 0){847 if(stripos($absolute, $this->docRoot) === 0){ 843 848 return $absolute; 844 849 } else { … … 847 852 } 848 853 } 854 849 855 $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){ 851 865 $base .= $sub . '/'; 852 866 $this->debug(3, "Trying file as: " . $base . $src); … … 854 868 $this->debug(3, "Found file as: " . $base . $src); 855 869 $real = realpath($base . $src); 856 if(str pos($real, $realDocRoot) === 0){870 if(stripos($real, $this->docRoot) === 0){ 857 871 return $real; 858 872 } else { -
dukapress/trunk/php/dp-products.php
r456741 r458263 8 8 * 9 9 */ 10 function dpsc_get_product_details($product_id, $buy_now = false, $direct = false ) {10 function dpsc_get_product_details($product_id, $buy_now = false, $direct = false, $affiliate = false) { 11 11 global $wpdb; 12 12 … … 20 20 // $form_id = 'dpsc_product_direct_form_' . $product_id; 21 21 // } 22 23 22 24 $custom_fields_output['start'] = '<form id="' . $form_id . '" name="dpsc_product_form_' . $product_id . '" class="product_form" action="" method="post" enctype="multipart/form-data">'; 23 25 if ($dp_shopping_cart_settings['dp_shop_mode'] != 'inquiry') { … … 27 29 } else { 28 30 $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>'; 30 32 } 31 33 } … … 39 41 $action = 'dpsc_paypal_button'; 40 42 } 41 //Dukapress affiliate mode42 43 if ($affiliate) { 43 44 $action = 'dpsc_affiliate'; 44 45 } 46 45 47 // if ($direct) { 46 48 // $action = 'dpsc_direct_checkout_button'; … … 69 71 $var_price = floatval($get_var[1]); 70 72 $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 . ' ) '; 73 75 } 74 76 } … … 326 328 extract(shortcode_atts(array( 327 329 'buy_now' => '', 328 'direct' => '' 330 'direct' => '', 331 'affiliate' => '' 329 332 ), $atts)); 330 333 $p_b_n = false; … … 336 339 $direct_checkout = true; 337 340 } 341 $affiliate_checkout = false; 342 if (!empty($affiliate)) { 343 $affiliate_checkout = true; 344 } 338 345 $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); 340 347 $content .= '<div class="dpsc_product_main_container">'; 341 348 $content .= '<div class="dpsc_image_container">'; … … 367 374 if (!empty($buy_now)) { 368 375 $p_b_n = true; 376 } 377 $affiliate_checkout = false; 378 if (!empty($affiliate)) { 379 $affiliate_checkout = true; 369 380 } 370 381 $product_id = get_the_ID(); … … 408 419 'order' => 'DESC', 409 420 'direct' => '', 421 'affiliate' => '', 410 422 'buy_now' => '' 411 423 ), $atts)); … … 418 430 if (!empty($direct)) { 419 431 $direct_checkout = true; 432 } 433 $affiliate_checkout = false; 434 if (!empty($affiliate)) { 435 $affiliate_checkout = true; 420 436 } 421 437 if (!empty($per_page)) { … … 449 465 $all_count = 0; 450 466 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); 452 468 if ($output) { 453 469 $attachment_images = &get_children('post_type=attachment&post_status=inherit&post_mime_type=image&post_parent=' . $product->ID); … … 557 573 $content_weight = get_post_meta($post_id, 'item_weight', true); 558 574 $content_file = get_post_meta($post_id, 'digital_file', true); 575 $affiliate_url = get_post_meta($post_id, 'affiliate_url', true); 559 576 ?> 560 577 <table> … … 564 581 <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> 565 582 <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> 566 584 </table> 567 585 … … 704 722 update_post_meta($post_id, '_Content_Counter', $content_counter); 705 723 } 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 706 735 } 707 736 -
dukapress/trunk/php/dp-widgets.php
r456734 r458263 199 199 $dpsc_at_checkout_to_be_displayed_price = ''; 200 200 } 201 $dpsc_var = '';201 $dpsc_var = ''; 202 202 if (!empty($dpsc_product_in_cart['var'])) { 203 203 $dpsc_var = ' (' . $dpsc_product_in_cart['var'] . ')';
Note: See TracChangeset
for help on using the changeset viewer.