Changeset 1052064 for cart66-lite
- Timestamp:
- 12/22/2014 11:14:44 PM (10 years ago)
- Location:
- cart66-lite/trunk
- Files:
-
- 5 edited
-
cart66.php (modified) (1 diff)
-
models/Cart66.php (modified) (77 diffs)
-
models/Cart66Ajax.php (modified) (25 diffs)
-
models/Cart66Common.php (modified) (83 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cart66-lite/trunk/cart66.php
r1042917 r1052064 4 4 Plugin URI: http://www.cart66.com 5 5 Description: Wordpress Shopping Cart 6 Version: 1.5. 36 Version: 1.5.4 7 7 Author: Reality 66 8 8 Author URI: http://www.Reality66.com -
cart66-lite/trunk/models/Cart66.php
r763354 r1052064 1 1 <?php 2 2 class Cart66 { 3 3 4 4 public function install() { 5 5 global $wpdb; … … 20 20 require_once(CART66_PATH . "/models/Cart66Setting.php"); 21 21 Cart66Setting::setValue('version', CART66_VERSION_NUMBER); 22 22 23 23 // Look for hard coded order number 24 24 if(CART66_PRO && CART66_ORDER_NUMBER !== false) { … … 29 29 set_transient('_cart66_version_request', $versionInfo, 43200); 30 30 } 31 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Trying to register order number: " . 31 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Trying to register order number: " . 32 32 CART66_ORDER_NUMBER . print_r($versionInfo, true)); 33 33 if(!$versionInfo) { … … 35 35 } 36 36 } 37 37 38 38 $this->upgradeDatabase(); 39 39 } 40 40 41 41 public function scheduledEvents() { 42 42 $offset = get_option( 'gmt_offset' ) * 3600; … … 56 56 } 57 57 } 58 58 59 59 public function init() { 60 60 global $cart66Settings, $cart66Objects; … … 62 62 $this->initCurrencySymbols(); 63 63 $this->setDefaultPageRoles(); 64 64 65 65 // Allow override for sending email receipts 66 66 define("CART66_EMAILS", apply_filters('cart66_send_default_emails', true)); 67 67 68 68 // Verify that upgrade has been run 69 69 if(IS_ADMIN) { … … 73 73 } 74 74 } 75 75 76 76 // Define debugging and testing info 77 77 $cart66Logging = Cart66Setting::getValue('enable_logging') ? true : false; … … 79 79 define("CART66_DEBUG", $cart66Logging); 80 80 define("SANDBOX", $sandbox); 81 81 82 82 // Handle dynamic JS requests 83 83 // See: http://ottopress.com/2010/dont-include-wp-load-please/ for why 84 84 add_filter('query_vars', array($this, 'addAjaxTrigger')); 85 85 add_action('template_redirect', array($this, 'ajaxTriggerCheck')); 86 86 87 87 // Scheduled events 88 88 if(CART66_PRO) { … … 93 93 add_action('daily_prune_pending_orders', array($order, 'dailyPrunePendingPayPalOrders')); 94 94 } 95 95 96 96 // Notification shortcodes 97 97 $sc = new Cart66ShortcodeManager(); 98 98 add_shortcode('email_shortcodes', array($sc, 'emailShortcodes')); 99 99 100 100 // add Cart66 to the admin bar 101 101 if(Cart66Common::cart66UserCan('orders')) { 102 102 add_action('admin_bar_menu', array($this, 'cart66_admin_bar_menu'), 35); 103 103 } 104 104 105 105 if(IS_ADMIN) { 106 106 if(Cart66Setting::getValue('capost_merchant_id')) { … … 110 110 111 111 add_action('admin_head', array( $this, 'registerBasicScripts')); 112 add_action('admin_ init', array($this, 'registerAdminScripts'));112 add_action('admin_enqueue_scripts', array($this, 'registerAdminScripts')); 113 113 add_action('admin_init', array($this, 'registerCustomScripts')); 114 114 add_action('admin_print_styles', array($this, 'registerAdminStyles')); 115 115 116 116 add_action('admin_menu', array($this, 'buildAdminMenu')); 117 117 // we dont use this button anymore … … 134 134 add_action('wp_ajax_dismiss_mijireh_notice', array('Cart66Ajax', 'dismissMijirehNotice')); 135 135 add_action('wp_ajax_cart66_page_check', array('Cart66Ajax','checkPages')); 136 136 137 137 138 138 if(CART66_PRO) { … … 142 142 add_action('wp_ajax_inventory_table', array('Cart66DataTables', 'inventoryTable')); 143 143 } 144 144 145 145 // Load Dialog Box in editor 146 146 add_action('media_buttons', array('Cart66Dialog', 'cart66_dialog_box'), 11); 147 147 add_action('admin_footer', array('Cart66Dialog', 'add_shortcode_popup')); 148 148 149 149 // Load Page Slurp Button on checkout page 150 add_action('add_meta_boxes', array($this, 'addPageSlurpButtonMeta')); 150 add_action('add_meta_boxes', array($this, 'addPageSlurpButtonMeta')); 151 151 add_action('media_buttons', array($this, 'addPageSlurpButton'), 12); 152 152 153 153 // Load Dashboard Widget 154 154 add_action('wp_dashboard_setup', array('Cart66Dashboard', 'cart66_add_dashboard_widgets' )); 155 155 156 156 if(CART66_PRO) { 157 157 add_action('wp_ajax_update_gravity_product_quantity_field', array('Cart66Ajax', 'updateGravityProductQuantityField')); 158 158 } 159 159 160 160 if(class_exists('SpreedlySubscription') || true) { 161 161 add_action('save_post', array($this, 'saveFeatureLevelMetaBoxData')); 162 162 add_action('add_meta_boxes', array($this, 'addFeatureLevelMetaBox')); 163 163 } 164 164 165 165 //Plugin update actions 166 166 if(CART66_PRO) { … … 169 169 add_action('install_plugins_pre_plugin-information', array('Cart66ProCommon', 'showChangelog')); 170 170 } 171 171 172 172 add_action('save_post', array($this,'check_cart66_pages_on_inline_edit')); 173 173 add_action('admin_notices',array($this,'cart66_page_check')); … … 192 192 add_filter('wp_nav_menu_objects', array($this, 'filter_private_menu_items'), 10, 2); 193 193 } 194 194 195 195 add_action('wp_head', array('Cart66Common', 'displayVersionInfo')); 196 196 add_action('template_redirect', array($this, 'dontCacheMeBro')); … … 201 201 } 202 202 } 203 203 204 204 // ================================================================ 205 205 // = Intercept query string cart66 tasks = 206 206 // ================================================================ 207 207 208 208 // Logout the logged in user 209 209 $isLoggedIn = Cart66Common::isLoggedIn(); … … 213 213 Cart66Account::logout($url); 214 214 } 215 215 216 216 if($_SERVER['REQUEST_METHOD'] == 'GET' && Cart66Common::getVal('task') == 'member_download') { 217 217 if(Cart66Common::isLoggedIn()) { 218 $path = $_GET['path'];218 $path = str_replace(array('../','./'),'',$_GET['path']); // don't allow folder traversing 219 219 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Attempting a member download file request: $path"); 220 220 Cart66Common::downloadFile($path); … … 256 256 } 257 257 } 258 259 } 260 258 259 } 260 261 261 public function checkIPN() { 262 262 if(isset($_GET['listener']) && $_GET['listener'] == '2CO') { … … 277 277 } 278 278 } 279 279 280 280 public function cart66_page_check($return = false){ 281 281 282 282 if(Cart66Common::verifyCartPages('error')){ 283 283 284 284 $alert_output = "<div class='alert-message alert-danger' id='cart66_page_errors'> 285 285 <div class='left'> … … 289 289 <p>" . __( 'Please refer to' , 'cart66' ) . " <a href='http://cart66.com/2011/dont-rename-the-store-pages/' target='_blank'>" . __( 'this article</a> for the proper configuration of pages for Cart66.' , 'cart66' ) . " <em> " . __( 'Cart66 will not work properly until this issue is resolved.' , 'cart66' ) . "</em></p> 290 290 </div> 291 </div>"; 292 291 </div>"; 292 293 293 } 294 294 else{ 295 295 $alert_output = '<div id="cart66_page_errors"></div>'; 296 296 } 297 297 298 298 if($return){ 299 299 return $alert_output; … … 303 303 } 304 304 } 305 305 306 306 public function check_cart66_pages_on_inline_edit(){ 307 307 if(!empty($_POST) && isset($_POST['action']) && $_POST['action'] == 'inline-save' && isset($_POST['post_type']) && $_POST['post_type'] == 'page'){ … … 312 312 inline_save_callback(); 313 313 </script> 314 </tr><?php 314 </tr><?php 315 315 $inline_save_flag = 1; 316 316 } 317 317 318 318 $inline_safe_flag = 1; 319 320 } 321 322 } 323 319 320 } 321 322 } 323 324 324 public function cart66_admin_bar_menu() { 325 325 global $wp_admin_bar; … … 327 327 return; 328 328 } 329 329 330 330 $wp_admin_bar->add_menu( 331 331 array( 'id' => 'cart66', … … 335 335 ) 336 336 ); 337 337 338 338 $cart66Pages = array( 339 339 "Orders" => array("role" => 'orders', "slug" => '_admin'), … … 350 350 'title' => __($page), 351 351 'href' => get_bloginfo('wpurl') . '/wp-admin/admin.php?page=cart66' . strtolower($meta['slug']), 352 'meta' => false) 352 'meta' => false) 353 353 ); 354 354 } 355 355 } 356 356 357 357 $wp_admin_bar->add_menu( array( 358 358 'id' => 'cart66-pages', … … 360 360 'title' => __("Store Pages"), 361 361 'href' => false, 362 'meta' => false) 362 'meta' => false) 363 363 ); 364 364 365 365 $storePages = array( 366 366 "Store" => get_page_by_path('store'), … … 369 369 "Receipt" => get_page_by_path('store/receipt') 370 370 ); 371 371 372 372 foreach($storePages as $pageName=>$cartPage){ 373 373 if($cartPage){ … … 377 377 'title' => __($pageName), 378 378 'href' => get_bloginfo('wpurl') . '/wp-admin/post.php?post=' . $cartPage->ID . '&action=edit', 379 'meta' => false) 379 'meta' => false) 380 380 ); 381 } 381 } 382 382 } 383 383 } 384 384 385 385 public function cart66_canada_post_upgrade(){ 386 386 global $current_screen; 387 387 388 388 echo '<div class="error">'; 389 389 echo '<H3>Canada Post Live Rates Update</h3>'; … … 393 393 echo '</div>'; 394 394 } 395 395 396 396 public function cart66_data_collection(){ 397 397 global $current_screen; 398 398 399 399 echo '<div class="updated">'; 400 400 echo '<script type="text/javascript"> … … 416 416 echo '</div>'; 417 417 } 418 419 418 419 420 420 public function filter_private_menu_items($items) { 421 421 if(Cart66Common::isLoggedIn()) { … … 432 432 } 433 433 } 434 434 435 435 return $items; 436 436 } 437 437 438 438 public static function enqueueScripts() { 439 439 $url = CART66_URL . '/cart66.css'; … … 443 443 wp_enqueue_style('cart66-custom-css', $css, null, CART66_VERSION_NUMBER, 'all'); 444 444 } 445 445 446 446 // Include the cart66 javascript library 447 447 $path = CART66_URL . '/js/cart66-library.js'; 448 448 wp_enqueue_script('cart66-library', $path, array('jquery'), CART66_VERSION_NUMBER, true); 449 449 } 450 450 451 451 public function loadCoreModels() { 452 452 require_once(CART66_PATH . "/models/Cart66BaseModelAbstract.php"); … … 482 482 require_once(CART66_PATH . "/models/Cart66Updater.php"); 483 483 require_once(CART66_PATH . "/models/Cart66Notifications.php"); 484 484 485 485 if(CART66_PRO) { 486 486 require_once(CART66_PATH . "/pro/models/Cart66AccessManager.php"); … … 503 503 require_once(CART66_PATH . "/pro/models/Cart66EmailLog.php"); 504 504 require_once(CART66_PATH . "/pro/models/Cart66MembershipReminders.php"); 505 505 506 506 // Load Constant Contact classes 507 507 if(Cart66Setting::getValue('constantcontact_username')) { … … 512 512 513 513 require_once(CART66_PATH . "/gateways/Cart66GatewayAbstract.php"); 514 514 515 515 self::loadSpreedlyModels(); 516 516 517 517 if(CART66_PRO && Cart66Setting::getValue('zendesk_token')) { 518 518 require_once(CART66_PATH . "/pro/models/ZendeskRemoteAuth.php"); 519 519 } 520 520 } 521 521 522 522 public function loadSpreedlyModels() { 523 523 $shortName = Cart66Setting::getValue('spreedly_shortname'); … … 534 534 } 535 535 } 536 536 537 537 public function initCurrencySymbols() { 538 538 $cs = Cart66Setting::getValue('CART66_CURRENCY_SYMBOL'); … … 546 546 define("CURRENCY_CODE", $ccd); 547 547 } 548 548 549 549 public function setDefaultPageRoles() { 550 550 $defaultPageRoles = array( … … 576 576 if($updateRoles) { 577 577 Cart66Setting::setValue('admin_page_roles',serialize($pageRoles)); 578 } 578 } 579 579 } 580 580 return unserialize(Cart66Setting::getValue('admin_page_roles')); 581 581 } 582 582 583 583 public function registerBasicScripts() { 584 584 ?><script type="text/javascript">var wpurl = '<?php echo esc_js( home_url('/') ); ?>';</script><?php … … 586 586 wp_enqueue_style('dashboard-css', $dashboardCss, null, CART66_VERSION_NUMBER, 'all'); 587 587 } 588 588 589 589 public function registerAdminScripts() { 590 590 $path = CART66_URL . '/js/jquery.dataTables.min.js'; 591 wp_enqueue_script('jquery-dataTables', $path, null, CART66_VERSION_NUMBER, true); 591 $currentScreen = get_current_screen(); 592 if(strpos($currentScreen->base,'cart66')>-1 || $currentScreen->base == "dashboard"){ 593 // dequeue new datatables on cart66 pages 594 wp_dequeue_script( 'datatables_js' ); 595 wp_enqueue_script('jquery-datatables', $path, null, CART66_VERSION_NUMBER, true); 596 } 592 597 $path = CART66_URL . '/js/page-slurp.js'; 593 598 wp_enqueue_script('page-slurp', $path, null, CART66_VERSION_NUMBER, true); 594 599 wp_enqueue_script('pusher', 'https://d3dy5gmtp8yhk7.cloudfront.net/1.11/pusher.min.js', null, CART66_VERSION_NUMBER, true); 595 600 } 596 601 597 602 public function registerCustomScripts() { 598 603 if(strpos($_SERVER['QUERY_STRING'], 'page=cart66') !== false) { … … 609 614 $path = CART66_URL . '/js/ui.multiselect.js'; 610 615 wp_enqueue_script('jquery-multiselect', $path, array('jquery-ui-sortable'), CART66_VERSION_NUMBER, true); 611 616 612 617 $path = CART66_URL . '/js/ui.timepicker.addon.js'; 613 618 wp_enqueue_script('jquery-timepicker-addon', $path, array('jquery-ui-datepicker', 'jquery-ui-slider'), CART66_VERSION_NUMBER, true); … … 619 624 wp_enqueue_script('notifications-js', $path, null, CART66_VERSION_NUMBER, false); 620 625 621 626 622 627 // Include the jquery table quicksearch library 623 628 $path = CART66_URL . '/js/jquery.quicksearch.js'; 624 629 wp_enqueue_script('quicksearch', $path, array('jquery')); 625 626 } 627 } 628 630 631 } 632 } 633 629 634 public function registerAdminStyles() { 630 635 $screen = get_current_screen(); … … 634 639 wp_enqueue_style('widget-css', $widgetCss, null, CART66_VERSION_NUMBER, 'all'); 635 640 } 636 641 637 642 $adminCss = CART66_URL . '/admin/admin-styles.css'; 638 643 wp_enqueue_style('admin-css', $adminCss, null, CART66_VERSION_NUMBER, 'all'); … … 640 645 $uiCss = CART66_URL . '/admin/jquery-ui-1.7.1.custom.css'; 641 646 wp_enqueue_style('ui-css', $uiCss, null, CART66_VERSION_NUMBER, 'all'); 642 647 643 648 $codemirror = CART66_URL . '/admin/codemirror.css'; 644 649 wp_enqueue_style('codemirror-css', $codemirror, null, CART66_VERSION_NUMBER, 'all'); … … 646 651 } 647 652 } 648 653 649 654 public function dontCacheMeBro() { 650 655 if(!IS_ADMIN) { … … 671 676 } 672 677 } 673 678 674 679 // Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Disable caching is: $disableCaching"); 675 680 676 681 if($sendHeaders) { 677 682 // Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Sending no cache headers"); … … 681 686 header('Pragma: no-cache'); 682 687 } 683 688 684 689 } 685 690 } … … 690 695 public function buildAdminMenu() { 691 696 $icon = CART66_URL . '/images/cart66_logo_16.gif'; 692 697 693 698 add_menu_page('Cart66', 'Cart66', Cart66Common::getPageRoles('orders'), 'cart66_admin', null, $icon); 694 699 add_submenu_page('cart66_admin', __('Orders', 'cart66'), __('Orders', 'cart66'), Cart66Common::getPageRoles('orders'), 'cart66_admin', array('Cart66Admin', 'ordersPage')); … … 702 707 add_submenu_page('cart66_admin', __('Accounts', 'cart66'), __('Accounts', 'cart66'), Cart66Common::getPageRoles('accounts'), 'cart66-accounts', array('Cart66Admin', 'accountsPage')); 703 708 } 704 709 705 710 706 711 /** … … 718 723 } 719 724 } 720 725 721 726 public function checkShippingMethodOnCheckout() { 722 727 if($_SERVER['REQUEST_METHOD'] == 'GET') { 723 728 global $post; 724 729 $checkoutPage = get_page_by_path('store/checkout'); 725 730 726 731 if(!Cart66Setting::getValue('use_live_rates')) { 727 732 Cart66Session::drop('Cart66LiveRates'); 728 733 } 729 734 730 735 if(is_object($checkoutPage) && isset( $post->ID ) && $post->ID == $checkoutPage->ID) { 731 736 if(Cart66Session::get('Cart66LiveRates') && get_class(Cart66Session::get('Cart66LiveRates')) == 'Cart66LiveRates') { … … 770 775 } 771 776 } 772 777 773 778 public function checkTermsOnCheckout() { 774 779 global $post; 775 780 $checkoutPage = get_page_by_path('store/checkout'); 776 781 $cartPage = get_page_by_path('store/cart'); 777 782 778 783 // Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] What is the post? " . print_r($post, 1)); 779 784 $sendBack = false; 780 785 if(isset($post) && is_object($post) && is_object($cartPage) && is_object($checkoutPage)) { 781 786 782 787 if($post->ID == $checkoutPage->ID || $post->ID == $cartPage->ID) { 783 788 if(Cart66Setting::getValue('require_terms') == 1) { … … 799 804 } 800 805 } 801 802 } 803 } 804 806 807 } 808 } 809 805 810 public function checkCustomFieldsOnCheckout() { 806 811 global $post; 807 812 $checkoutPage = get_page_by_path('store/checkout'); 808 813 $cartPage = get_page_by_path('store/cart'); 809 814 810 815 $sendBack = false; 811 816 if(isset($post) && is_object($post) && is_object($cartPage) && is_object($checkoutPage)) { 812 817 813 818 if($post->ID == $checkoutPage->ID || $post->ID == $cartPage->ID) { 814 819 $items = Cart66Session::get('Cart66Cart')->getItems(); … … 832 837 } 833 838 } 834 835 } 836 837 } 838 839 840 } 841 842 } 843 839 844 public function checkMinAmountOnCheckout() { 840 845 global $post; … … 865 870 } 866 871 } 867 872 868 873 public function checkZipOnCheckout() { 869 874 if(CART66_PRO && $_SERVER['REQUEST_METHOD'] == 'GET') { … … 875 880 $link = get_permalink($cartPage->ID); 876 881 $sendBack = false; 877 882 878 883 if(!Cart66Session::get('cart66_shipping_zip')) { 879 884 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Live rate warning: No shipping zip in session"); … … 886 891 $sendBack = true; 887 892 } 888 893 889 894 if($sendBack) { 890 895 wp_redirect($link); 891 896 exit; 892 897 } 893 898 894 899 } // End if checkout page 895 900 } // End if using live rates 896 901 } // End if GET 897 902 } 898 903 899 904 /** 900 905 * Add Cart66 to the TinyMCE editor … … 921 926 return $plugin_array; 922 927 } 923 928 924 929 /** 925 930 * Load the cart from the session or put a new cart in the session … … 953 958 } 954 959 } 955 956 } 957 960 961 } 962 958 963 public function initShortcodes() { 959 964 $sc = new Cart66ShortcodeManager(); … … 988 993 add_shortcode('terms_of_service', array($sc, 'termsOfService')); 989 994 add_shortcode('account_expiration', array($sc, 'accountExpiration')); 990 995 991 996 if(CART66_PRO) { 992 997 add_shortcode('email_opt_out', array($sc, 'emailOptOut')); 993 998 } 994 999 995 1000 // System shortcodes 996 1001 add_shortcode('cart66_tests', array($sc, 'cart66Tests')); … … 1003 1008 add_shortcode('checkout_mwarrior', array($sc, 'mwarriorCheckout')); 1004 1009 1005 1010 1006 1011 // Enable Gravity Forms hooks if Gravity Forms is available 1007 1012 if(CART66_PRO && class_exists('RGForms')) { 1008 1013 add_action("gform_post_submission", array($sc, 'gravityFormToCart'), 100, 1); 1009 1014 } 1010 1011 } 1012 1015 1016 } 1017 1013 1018 /** 1014 1019 * Adds a query var trigger for the dynamic JS dialog … … 1038 1043 exit; 1039 1044 } 1040 1045 1041 1046 if ( intval( get_query_var( 'cart66AjaxCartRequests' ) ) == 4 ) { 1042 1047 //Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] CONFIRM ORDER VERIFICATION"); … … 1044 1049 exit; 1045 1050 } 1046 1051 1047 1052 if ( intval( get_query_var( 'cart66AjaxCartRequests' ) ) == 5 ) { 1048 1053 //Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] CONFIRM ORDER VERIFICATION"); … … 1058 1063 register_widget('Cart66CartWidget'); 1059 1064 } 1060 1061 public function addPageSlurpButtonMeta() { 1065 1066 public function addPageSlurpButtonMeta() { 1062 1067 global $post; 1063 1068 if(Cart66Common::isSlurpPage()) { 1064 add_meta_box( 1065 'slurp_meta_box', // $id 1066 'Mijireh Page Slurp', // $title 1067 array($this, 'drawPageSlurpMetaBox'), // $callback 1068 'page', // $page 1069 'normal', // $context 1070 'high'); // $priority 1069 add_meta_box( 1070 'slurp_meta_box', // $id 1071 'Mijireh Page Slurp', // $title 1072 array($this, 'drawPageSlurpMetaBox'), // $callback 1073 'page', // $page 1074 'normal', // $context 1075 'high'); // $priority 1071 1076 } 1072 1077 } 1073 1078 1074 1079 public function drawPageSlurpMetaBox($post) { 1075 1080 echo "<div id='mijireh_notice' class='mijireh-info alert-message info' data-alert='alert'>"; … … 1084 1089 echo "</div>"; 1085 1090 } 1086 1091 1087 1092 public function addFeatureLevelMetaBox() { 1088 1093 if(CART66_PRO) { … … 1090 1095 //add_meta_box('cart66_feature_level_meta', __('Feature Levels', 'cart66'), array($this, 'drawFeatureLevelMetaBox'), 'page', 'side', 'low'); 1091 1096 } 1092 } 1093 1097 } 1098 1094 1099 public function drawFeatureLevelMetaBox($post) { 1095 1100 if(CART66_PRO) { … … 1097 1102 $featureLevels = array(); 1098 1103 $data = array(); 1099 1104 1100 1105 // Load feature levels defined in Spreedly if available 1101 1106 if(class_exists('SpreedlySubscription')) { … … 1116 1121 $featureLevels[] = $s->featureLevel; 1117 1122 } 1118 1123 1119 1124 // Load feature levels defined in Membership products 1120 1125 foreach(Cart66Product::getMembershipProducts() as $membership) { … … 1126 1131 if(count($featureLevels)) { 1127 1132 $featureLevels = array_unique($featureLevels); 1128 sort($featureLevels); 1133 sort($featureLevels); 1129 1134 1130 1135 $savedPlanCsv = get_post_meta($post->ID, '_cart66_subscription', true); … … 1137 1142 } 1138 1143 } 1139 1144 1140 1145 /** 1141 1146 * Convert selected plan ids into a CSV string. … … 1149 1154 $featureLevels = implode(',', $_REQUEST['feature_levels']); 1150 1155 } 1151 1156 1152 1157 if(!empty($featureLevels)) { 1153 1158 add_post_meta($postId, '_cart66_subscription', $featureLevels, true) or update_post_meta($postId, '_cart66_subscription', $featureLevels); … … 1158 1163 } 1159 1164 } 1160 1165 1161 1166 public function hideStorePages($excludes) { 1162 1167 1163 1168 if(Cart66Setting::getValue('hide_system_pages') == 1) { 1164 1169 $store = get_page_by_path('store'); … … 1180 1185 $receipt = get_page_by_path('store/receipt'); 1181 1186 $excludes[] = $receipt->ID; 1182 1187 1183 1188 $spreedly = get_page_by_path('store/spreedly'); 1184 1189 if ( isset( $spreedly->ID ) ) 1185 1190 $excludes[] = $spreedly->ID; 1186 1191 1187 1192 if(is_array(get_option('exclude_pages'))){ 1188 1193 $excludes = array_merge(get_option('exclude_pages'), $excludes ); 1189 1194 } 1190 1195 sort($excludes); 1191 1196 1192 1197 return $excludes; 1193 1198 } 1194 1199 1195 1200 public function protectSubscriptionPages() { 1196 1201 global $wp_query; 1197 1202 1198 1203 // Keep visitors who are not logged in from seeing private pages 1199 1204 if(!isset($wp_query->tax_query)) { 1200 1205 $pid = isset( $wp_query->post->ID ) ? $wp_query->post->ID : NULL; 1201 1206 Cart66AccessManager::verifyPageAccessRights($pid); 1202 1207 1203 1208 // block subscription pages from non-subscribers 1204 1209 $accountId = Cart66Common::isLoggedIn() ? Cart66Session::get('Cart66AccountId') : 0; … … 1270 1275 1271 1276 } 1272 1277 1273 1278 /** 1274 1279 * Hide private pages and pages that require a subscription feature level the subscriber does not have … … 1284 1289 $hidePrivate = false; 1285 1290 $account = new Cart66Account(Cart66Session::get('Cart66AccountId')); 1286 1291 1287 1292 if($account->isActive()) { 1288 1293 $activeAccount = true; 1289 1294 $featureLevel = $account->getFeatureLevel(); 1290 1295 } 1291 1296 1292 1297 // Optionally add the logout link to the end of the navigation 1293 1298 if(Cart66Setting::getValue('auto_logout_link')) { … … 1320 1325 return $excludes; 1321 1326 } 1322 1327 1323 1328 public function appendLogoutLink($output) { 1324 1329 $output .= "<li><a href='" . Cart66Common::appendQueryString('cart66-task=logout') . "'>Log out</a></li>"; 1325 1330 return $output; 1326 1331 } 1327 1332 1328 1333 /** 1329 1334 * Force downloads for … … 1343 1348 $report = Cart66Exporter::exportOrders($start, $end); 1344 1349 1345 header('Content-Type: application/csv'); 1350 header('Content-Type: application/csv'); 1346 1351 header('Content-Disposition: inline; filename="Cart66Report.csv"'); 1347 1352 echo $report; … … 1369 1374 Cart66Common::clearLog(); 1370 1375 } 1371 1372 } 1373 1376 1377 } 1378 1374 1379 public function addPageSlurpButton() { 1375 1380 global $post; … … 1378 1383 } 1379 1384 } 1380 1385 1381 1386 public function upgradeDatabase() { 1382 1387 if(Cart66Setting::getValue('auth_force_ssl') == 'no') { … … 1387 1392 } 1388 1393 } 1389 1394 1390 1395 } -
cart66-lite/trunk/models/Cart66Ajax.php
r1023350 r1052064 1 1 <?php 2 2 class Cart66Ajax { 3 3 4 4 public static function resendEmailFromLog() { 5 5 $log_id = $_POST['id']; … … 16 16 die(); 17 17 } 18 18 19 19 public function forcePluginUpdate(){ 20 20 $output = false; … … 26 26 die(); 27 27 } 28 28 29 29 public static function sendTestEmail() { 30 30 $to = $_POST['email']; … … 53 53 die(); 54 54 } 55 55 56 56 public static function ajaxReceipt() { 57 57 if(isset($_GET['order_id'])) { … … 64 64 } 65 65 } 66 66 67 67 public static function ajaxOrderLookUp() { 68 68 $redirect = true; … … 78 78 die(); 79 79 } 80 80 81 81 public static function viewLoggedEmail() { 82 82 if(isset($_POST['log_id'])) { … … 86 86 } 87 87 } 88 88 89 89 public static function checkPages(){ 90 90 $Cart66 = new Cart66(); … … 92 92 die(); 93 93 } 94 94 95 95 public static function shortcodeProductsTable() { 96 96 global $wpdb; 97 97 $prices = array(); 98 $types = array(); 98 $types = array(); 99 99 //$options=''; 100 100 $postId = intval(Cart66Common::postVal('id')); … … 129 129 die(); 130 130 } 131 131 132 132 public static function ajaxTaxUpdate() { 133 133 if(isset($_POST['state']) && isset($_POST['state_text']) && isset($_POST['zip']) && isset($_POST['gateway'])) { … … 168 168 die(); 169 169 } 170 170 171 171 public static function loadAjaxGateway($gateway) { 172 172 switch($gateway) { … … 212 212 return $gateway; 213 213 } 214 214 215 215 public static function ajaxCartElements($args="") { 216 216 … … 227 227 ); 228 228 } 229 229 230 230 $summary = array( 231 'items' => ' ' . _n('item', 'items', Cart66CartWidget::countItems(), 'cart66'), 232 'amount' => Cart66Common::currency(Cart66CartWidget::getSubTotal()), 231 'items' => ' ' . _n('item', 'items', Cart66CartWidget::countItems(), 'cart66'), 232 'amount' => Cart66Common::currency(Cart66CartWidget::getSubTotal()), 233 233 'count' => Cart66CartWidget::countItems() 234 234 ); 235 235 236 236 $array = array( 237 237 'summary' => $summary, … … 244 244 die(); 245 245 } 246 246 247 247 public static function ajaxAddToCart() { 248 248 $message = Cart66Session::get('Cart66Cart')->addToCart(true); … … 257 257 die(); 258 258 } 259 259 260 260 public static function promotionProductSearch() { 261 261 global $wpdb; … … 263 263 $product = new Cart66Product(); 264 264 $tableName = Cart66Common::getTableName('products'); 265 $products = $wpdb->get_results("SELECT id, name from $tableName WHERE name LIKE '%%%$search%%' ORDER BY id ASC LIMIT 10"); 265 $search_sql = $wpdb->prepare( "SELECT id, name from $tableName WHERE name LIKE %s ORDER BY id ASC LIMIT 10", '%' . $wpdb->esc_like($search) . '%'); 266 $products = $wpdb->get_results($search_sql); 266 267 $data = array(); 267 268 foreach($products as $p) { … … 271 272 die(); 272 273 } 273 274 274 275 public static function loadPromotionProducts() { 275 276 $productId = Cart66Common::postVal('productId'); … … 284 285 die(); 285 286 } 286 287 287 288 public static function saveSettings() { 289 if(!Cart66Common::cart66UserCan('settings')){ 290 die(); 291 } 288 292 $error = ''; 289 293 foreach($_REQUEST as $key => $value) { … … 327 331 } 328 332 elseif($key == 'constantcontact_list_ids') { 329 333 330 334 } 331 335 elseif($key == 'admin_page_roles') { … … 359 363 else { 360 364 $result[0] = 'Cart66Modal alert-message success'; 361 $result[1] = '<strong>Success</strong><br/>' . $_REQUEST['_success'] . '<br>'; 365 $result[1] = '<strong>Success</strong><br/>' . $_REQUEST['_success'] . '<br>'; 362 366 } 363 367 … … 366 370 die(); 367 371 } 368 372 369 373 public static function updateGravityProductQuantityField() { 370 374 $formId = Cart66Common::getVal('formId'); … … 375 379 die(); 376 380 } 377 381 378 382 public static function checkInventoryOnAddToCart() { 379 383 $result = array(true); … … 415 419 $result[1] = $p->name . " " . $optionsMsg . " is $soldOutLabel $out"; 416 420 } 417 421 418 422 $result = json_encode($result); 419 423 echo $result; 420 424 die(); 421 425 } 422 426 423 427 public static function pageSlurp() { 424 428 require_once(CART66_PATH . "/models/Pest.php"); 425 429 require_once(CART66_PATH . "/models/PestJSON.php"); 426 430 427 431 $page_id = Cart66Common::postVal('page_id'); 428 432 $page = get_page($page_id); … … 430 434 $html = false; 431 435 $job_id = $slurp_url; 432 436 433 437 if(wp_update_post(array('ID' => $page->ID, 'post_status' => 'publish'))) { 434 438 $access_key = Cart66Setting::getValue('mijireh_access_key'); … … 440 444 'return_url' => add_query_arg('task', 'mijireh_page_slurp', $slurp_url) 441 445 ); 442 446 443 447 try { 444 448 $response = $rest->post('/api/1/slurps', $data); … … 453 457 $job_id = 'did not update post successfully'; 454 458 } 455 459 456 460 echo $job_id; 457 461 die; 458 462 } 459 463 460 464 public static function dismissMijirehNotice() { 461 465 Cart66Setting::setValue('mijireh_notice', 1); 462 466 } 463 467 464 468 } -
cart66-lite/trunk/models/Cart66Common.php
r1023350 r1052064 3 3 4 4 /** 5 * Return the string to use as the input id while keeping track of 6 * how many times a product is rendered to make sure there are no 5 * Return the string to use as the input id while keeping track of 6 * how many times a product is rendered to make sure there are no 7 7 * conflicting input ids. 8 8 * … … 34 34 return $id; 35 35 } 36 36 37 37 /** 38 38 * Strip all non numeric characters, then format the phone number. 39 * 39 * 40 40 * Phone numbers are formatted as follows: 41 41 * 7 digit phone numbers: 266-1789 42 42 * 10 digit phone numbers: (804) 266-1789 43 * 43 * 44 44 * @return string 45 45 */ … … 60 60 return $isRegistered; 61 61 } 62 62 63 63 public static function activePromotions() { 64 64 $active = false; … … 69 69 return $active; 70 70 } 71 71 72 72 public static function showValue($value) { 73 73 echo isset($value)? $value : ''; 74 74 } 75 75 76 76 public static function displayCustomFormField($field, $post_data) { 77 77 $output = ''; … … 87 87 return $output; 88 88 } 89 89 90 90 public static function getView($filename, $data=null, $notices=true, $minify=false) { 91 91 $notice = ''; … … 110 110 } 111 111 } 112 112 113 113 if(CART66_PRO && !self::isRegistered()) { 114 114 $hardCoded = ''; … … 128 128 } 129 129 } 130 130 131 131 } 132 132 … … 154 154 $overrideDirectory = $themeDirectory."/cart66-templates"; 155 155 $userViewFile = $overrideDirectory."/$filename"; 156 156 157 157 //Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Override: $overrideDirectory\nUser view file: $userViewFile"); 158 158 159 159 if(file_exists($userViewFile) && in_array($filename,$approvedOverrideFiles)) { 160 160 // File exists, make sure it's not empty … … 172 172 // Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Approved Override: ".var_export(in_array($filename,$approvedOverrideFiles),true)); 173 173 } 174 174 175 175 // Check for override and confirm we have a registered plugin 176 176 if($customView && CART66_PRO && self::isRegistered()) { … … 182 182 $filename = CART66_PATH . "/$filename"; 183 183 } 184 184 185 185 ob_start(); 186 186 include $filename; 187 187 $contents = ob_get_contents(); 188 188 ob_end_clean(); 189 189 190 190 return ($minify) ? Cart66Common::minifyMarkup($notice . $contents) : $notice . $contents; 191 191 } 192 192 193 193 public static function minifyMarkup($markup){ 194 194 $search = array( … … 205 205 return $output; 206 206 } 207 207 208 208 public static function getTableName($name, $prefix='cart66_'){ 209 209 global $wpdb; 210 210 return $wpdb->prefix . $prefix . $name; 211 211 } 212 212 213 213 public static function getTablePrefix(){ 214 214 global $wpdb; 215 215 return $wpdb->prefix . "cart66_"; 216 216 } 217 217 218 218 /** 219 219 * If CART66_DEBUG is defined as true and a log file exists in the root of the Cart66 plugin directory, log the $data 220 220 */ 221 221 public static function log($data) { 222 222 223 223 if(defined('CART66_DEBUG') && CART66_DEBUG) { 224 224 $tz = '- Server time zone ' . date('T'); 225 225 $date = date('m/d/Y g:i:s a', self::localTs()); 226 226 $header = strpos($_SERVER['REQUEST_URI'], 'wp-admin') ? "\n\n======= ADMIN REQUEST =======\n[LOG DATE: $date $tz]\n" : "\n\n[LOG DATE: $date $tz]\n"; 227 $filename = CART66_PATH . "/log.txt"; 227 $filename = CART66_PATH . "/log.txt"; 228 228 if(file_exists($filename) && is_writable($filename)) { 229 229 file_put_contents($filename, $header . $data, FILE_APPEND); 230 230 } 231 231 } 232 233 } 234 232 233 } 234 235 235 public static function clearLog(){ 236 $filename = CART66_PATH . "/log.txt"; 236 $filename = CART66_PATH . "/log.txt"; 237 237 if(file_exists($filename) && is_writable($filename)) { 238 238 file_put_contents($filename, ''); … … 243 243 $id = ''; 244 244 mt_srand((double)microtime()*1000000); 245 for ($i = 0; $i < $numChars; $i++) { 245 for ($i = 0; $i < $numChars; $i++) { 246 246 $id .= chr(mt_rand(ord(0), ord(9))); 247 247 } 248 248 return $id; 249 249 } 250 250 251 251 public static function getRandString($length = 14) { 252 252 $string = ''; … … 257 257 } 258 258 return $string; 259 } 260 259 } 260 261 261 public static function camel2human($val) { 262 262 $val = strtolower(preg_replace('/([A-Z])/', ' $1', $val)); 263 263 return $val; 264 264 } 265 265 266 266 /** 267 267 * Return the account id if the visitor is logged in, otherwise false. 268 268 * This function has nothing to do with feature levels or subscription status 269 * 269 * 270 270 * @return int or false 271 271 */ … … 278 278 } 279 279 280 280 281 281 public static function awardCommission($orderId, $referrer) { 282 282 global $wpdb; … … 288 288 $order_items = array(); 289 289 foreach($order->getItems() as $item) { 290 $order_items[] = $item->item_number; 290 $order_items[] = $item->item_number; 291 291 $price = $item->product_price * $item->quantity; 292 292 … … 303 303 $price = $price - $subtractAmount; 304 304 } 305 305 306 306 // Transaction if for commission is the id in th order items table 307 307 $txn_id = $order->trans_id; … … 309 309 $item_id = $item->item_number; 310 310 $buyer_email = $order->email; 311 311 312 312 if(function_exists('wp_aff_award_commission')) { 313 313 // Make sure commission has not already been granted for this transaction … … 318 318 } 319 319 } 320 321 } 322 320 321 } 322 323 323 // valid order id 324 324 // Transaction if for commission is the id in th order items table … … 327 327 $item_id = implode(',',$order_items); 328 328 $buyer_email = $order->email; 329 329 330 330 // Affiliate Royale 331 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] 331 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] 332 332 Running wafp_award_commission\n 333 333 referrer $referrer\n … … 337 337 buyer_email $buyer_email"); 338 338 do_action('wafp_award_commission', $referrer, $sale_amount, $txn_id, $item_id, $buyer_email); 339 340 } 341 } 342 } 343 339 340 } 341 } 342 } 343 344 344 /** 345 345 * Return true if the email address is not empty and has a valid format 346 * 346 * 347 347 * @param string $email The email address to validate 348 348 * @return boolean Empty or invalid email addresses return false, otherwise true … … 365 365 return $isValid; 366 366 } 367 367 368 368 public static function isEmailUnique($email, $exceptId=0) { 369 369 global $wpdb; … … 375 375 return $isUnique; 376 376 } 377 377 378 378 public static function randomString($numChars = 7) { 379 379 $letters = ""; 380 380 mt_srand((double)microtime()*1000000); 381 for ($i = 0; $i < $numChars; $i++) { 381 for ($i = 0; $i < $numChars; $i++) { 382 382 $randval = chr(mt_rand(ord("a"), ord("z"))); 383 383 $letters .= $randval; … … 385 385 return $letters; 386 386 } 387 387 388 388 public static function isValidDate($val) { 389 389 $isValid = false; … … 407 407 return $isValid; 408 408 } 409 409 410 410 /** 411 411 * Strip slashes and escape sequences from POST values and returened the scrubbed value. … … 419 419 return $value; 420 420 } 421 421 422 422 public static function deepTagClean(&$data) { 423 423 if(is_array($data)) { … … 438 438 return $data; 439 439 } 440 440 441 441 442 442 /** … … 452 452 return $value; 453 453 } 454 454 455 455 /** 456 456 * Get home country code from cart settings or return US if no setting exists 457 * 457 * 458 458 * @return string 459 459 */ 460 460 public static function getHomeCountryCode() { 461 461 if($homeCountry = Cart66Setting::getValue('home_country')) { 462 list($homeCountryCode, $dummy) = explode('~', $homeCountry); 462 list($homeCountryCode, $dummy) = explode('~', $homeCountry); 463 463 } 464 464 else { … … 467 467 return $homeCountryCode; 468 468 } 469 469 470 470 public static function getCountryName($code) { 471 471 $countries = self::getCountries(true); … … 481 481 return $localeCode; 482 482 } 483 483 484 484 public static function getShippingCountries() { 485 485 $countries = self::getCountries(); … … 505 505 return $countries; 506 506 } 507 507 508 508 public static function getCountries($all=false) { 509 509 $countries = array( … … 749 749 'ZW'=>'Zimbabwe' 750 750 ); 751 751 752 752 // Put home country at the top of the list 753 753 $setting = new Cart66Setting(); … … 762 762 763 763 $customCountries = self::getCustomCountries(); 764 764 765 765 if($all) { 766 766 if(is_array($customCountries)) { … … 783 783 } 784 784 else { 785 $countries = array_slice($countries, 0, 1, true); 786 } 787 } 788 789 790 785 $countries = array_slice($countries, 0, 1, true); 786 } 787 } 788 789 790 791 791 return $countries; 792 792 } … … 805 805 return $list; 806 806 } 807 807 808 808 public static function getPayPalCurrencyCodes() { 809 809 $currencies = array( … … 834 834 } 835 835 836 836 837 837 public static function getZones($code='all') { 838 838 $setting = new Cart66Setting(); 839 839 $zones = array(); 840 840 841 841 $au = array(); 842 842 $au['0'] = ''; … … 850 850 $au['WA'] = 'Western Australia'; 851 851 $zones['AU'] = $au; 852 852 853 853 $br = array(); 854 854 $br['0'] = ''; … … 881 881 $br['Tocantins'] = 'Tocantins'; 882 882 $zones['BR'] = $br; 883 883 884 884 $ca = array(); 885 885 $ca['0'] = ''; … … 898 898 $ca['YT'] = 'Yukon Territory'; 899 899 $zones['CA'] = $ca; 900 900 901 901 $my['0'] = ''; 902 902 $my['KUL'] = 'Kuala Lumpur (Federal Territory)'; … … 917 917 $my['TRG'] = 'Terengganu'; 918 918 $zones['MY'] = $my; 919 919 920 920 $us = array(); 921 921 $us['0'] = ''; … … 974 974 $us['AE'] = 'Armed Forces (AE)'; 975 975 $us['AP'] = 'Armed Forces (AP)'; 976 976 977 977 if($setting->getValue('include_us_territories') == 1){ 978 978 $us['AS'] = 'American Samoa'; … … 985 985 $us['PW'] = 'Palua'; 986 986 } 987 987 988 988 $zones['US'] = $us; 989 989 990 990 switch ($code) { 991 991 case 'AU': … … 1005 1005 break; 1006 1006 } 1007 1007 1008 1008 return $zones; 1009 1009 } 1010 1010 1011 1011 1012 1012 … … 1032 1032 return $path; 1033 1033 } 1034 1034 1035 1035 public static function localTs($timestamp=null) { 1036 1036 $timestamp = isset($timestamp) ? $timestamp : time(); … … 1069 1069 return $promoMsg; 1070 1070 } 1071 1071 1072 1072 //increment the number of redemptions 1073 1073 public function updatePromoRedemptions() { … … 1075 1075 $promotion->updateRedemptions(); 1076 1076 } 1077 1077 1078 1078 public function showErrors($errors, $message=null) { 1079 1079 $out = "<div id='cart66Errors' class='Cart66Error'>"; … … 1097 1097 return $out; 1098 1098 } 1099 1099 1100 1100 public function getJqErrorScript(array $jqErrors) { 1101 1101 $script = ' … … 1122 1122 /** 1123 1123 * Return the WP_CONTENT_URL taking into account HTTPS and the possibility that WP_CONTENT_URL may not be defined 1124 * 1124 * 1125 1125 * @return string 1126 1126 */ … … 1135 1135 return $wpurl; 1136 1136 } 1137 1137 1138 1138 /** 1139 1139 * Return the WordPress URL taking into account HTTPS … … 1146 1146 return $wpurl; 1147 1147 } 1148 1148 1149 1149 /** 1150 1150 * Detect if request occurred over HTTPS and, if so, return TRUE. Otherwise return FALSE. 1151 * 1151 * 1152 1152 * @return boolean 1153 1153 */ 1154 1154 public static function isHttps() { 1155 1155 $isHttps = false; 1156 if((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || 1156 if((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || 1157 1157 (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) { 1158 1158 $isHttps = true; … … 1160 1160 return $isHttps; 1161 1161 } 1162 1163 1162 1163 1164 1164 public static function getCurrentPageUrl() { 1165 1165 $protocol = 'http://'; … … 1170 1170 return $url; 1171 1171 } 1172 1172 1173 1173 /** 1174 1174 * Attach a string of name/value pairs to a URL for the current page 1175 1175 * This function looks for the presence of a ? and appropriately appends the new parameters. 1176 1176 * Return a URL for the current page with the appended params. 1177 * 1177 * 1178 1178 * @return string 1179 1179 */ … … 1184 1184 return $url; 1185 1185 } 1186 1186 1187 1187 public static function appendWurlQueryString($nvPairs) { 1188 1188 $url = home_url(); … … 1191 1191 return $url; 1192 1192 } 1193 1193 1194 1194 /** 1195 1195 * Replace the query string for the current page url 1196 * 1196 * 1197 1197 * @param string Name value pairs formatted as name1=value1&name2=value2 1198 1198 * @return string The URL to the current page with the given query string … … 1206 1206 return $url; 1207 1207 } 1208 1209 1210 1208 1209 1210 1211 1211 public static function serializeSimpleXML(SimpleXMLElement $xmlObj) { 1212 1212 return serialize($xmlObj->asXML()); 1213 1213 } 1214 1214 1215 1215 public static function unserializeSimpleXML($str) { 1216 1216 return simplexml_load_string(unserialize($str)); 1217 1217 } 1218 1218 1219 1219 /** 1220 1220 * Return either the live or the sandbox PayPal URL based on whether or not paypal_sandbox is set. … … 1227 1227 return $paypalUrl; 1228 1228 } 1229 1229 1230 1230 public static function curl($url, $method='GET') { 1231 1231 $method = strtoupper($method); 1232 1232 1233 1233 // Make sure curl is installed? 1234 if (!function_exists('curl_init')){ 1234 if (!function_exists('curl_init')){ 1235 1235 throw new Cart66Exception('cURL is not installed!'); 1236 1236 } … … 1243 1243 curl_setopt($ch, CURLOPT_VERBOSE, true); 1244 1244 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 1245 1245 1246 1246 if($method == 'POST') { 1247 1247 curl_setopt($ch, CURLOPT_POST, true); 1248 1248 } 1249 1249 1250 1250 $output = curl_exec($ch); 1251 1251 1252 1252 // close the curl resource, and free system resources 1253 1253 curl_close($ch); 1254 1254 1255 1255 // wp remote fallback 1256 1256 if(empty($output)){ … … 1258 1258 $output = $output['body']; 1259 1259 } 1260 1260 1261 1261 return $output; 1262 1262 } 1263 1263 1264 1264 public static function downloadFile($path) { 1265 1265 1266 1266 // Validate the $path 1267 1267 if(!strpos($path, '://')) { … … 1289 1289 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Download file size: $bytes"); 1290 1290 1291 ob_start();1292 header("Pragma: public");1293 header("Expires: 0");1294 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");1295 header("Cache-Control: private",false);1296 header("Content-Type: application/octet-stream;");1297 header('Content-Disposition: attachment; filename="' . $fileName . '"');1298 header("Content-Transfer-Encoding: binary");1299 header("Content-Length: $bytes");1300 1301 1291 //open the file and stream download 1302 1292 if($fp = fopen($path, 'rb')) { 1293 1294 ob_start(); 1295 header("Pragma: public"); 1296 header("Expires: 0"); 1297 header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 1298 header("Cache-Control: private",false); 1299 header("Content-Type: application/octet-stream;"); 1300 header('Content-Disposition: attachment; filename="' . $fileName . '"'); 1301 header("Content-Transfer-Encoding: binary"); 1302 header("Content-Length: $bytes"); 1303 1303 1304 while(!feof($fp)) { 1304 1305 //reset time limit for big files … … 1322 1323 } 1323 1324 } 1324 1325 } 1326 1325 1326 } 1327 1327 1328 public static function remoteFileSize($remoteFile) { 1328 1329 $ch = curl_init($remoteFile); … … 1330 1331 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 1331 1332 curl_setopt($ch, CURLOPT_HEADER, true); 1332 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 1333 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 1333 1334 $data = curl_exec($ch); 1334 1335 curl_close($ch); … … 1341 1342 return $contentLength; 1342 1343 } 1343 1344 1344 1345 public static function onlyUsingPayPalStandard() { 1345 1346 $onlyPayPalStandard = false; … … 1347 1348 $onlyPayPalStandard = true; 1348 1349 } 1349 1350 1350 1351 if(Cart66Setting::getValue('auth_username') || Cart66Setting::getValue('paypalpro_api_username')) { 1351 1352 $onlyPayPalStandard = false; 1352 1353 } 1353 1354 1354 1355 return $onlyPayPalStandard; 1355 1356 } 1356 1357 1357 1358 /** 1358 1359 * Convert an array into XML 1359 * 1360 * 1360 1361 * Example use: echo arrayToXml($products,'products'); 1361 * 1362 * 1362 1363 * @param array $array - The array you wish to convert into a XML structure. 1363 1364 * @param string $name - The name you wish to enclose the array in, the 'parent' tag for XML. … … 1411 1412 return $output; 1412 1413 } 1413 1414 1414 1415 public static function testResult($passed, $msg='') { 1415 1416 $trace = debug_backtrace(); … … 1421 1422 echo $out . "\n"; 1422 1423 } 1423 1424 1424 1425 public static function showReportData(){ 1425 1426 global $wpdb; 1426 1427 $orders = Cart66Common::getTableName('orders'); 1427 1428 $reportData = array(); 1428 1429 1429 1430 $sql = "SELECT sum(`total`) from $orders"; 1430 1431 $lifetimeTotal = $wpdb->get_var($sql); 1431 1432 $reportData[] = array("Total Sales","total_sales",$lifetimeTotal); 1432 1433 1433 1434 $sql = "SELECT count('id') from $orders"; 1434 1435 $totalOrders = $wpdb->get_var($sql); 1435 1436 $reportData[] = array("Total Orders","total_orders",$totalOrders); 1436 1437 1437 1438 $sql = "SELECT ordered_on from $orders order by id asc LIMIT 1"; 1438 1439 $firstSaleDate = $wpdb->get_var($sql); 1439 1440 $reportData[] = array("First Sale","first_sale",$firstSaleDate); 1440 1441 1441 1442 $sql = "SELECT ordered_on from $orders order by id desc LIMIT 1"; 1442 1443 $lastSaleDate = $wpdb->get_var($sql); 1443 1444 $reportData[] = array("Last Sale","last_sale",$lastSaleDate); 1444 1445 1445 1446 $postTypes = get_post_types('','names'); 1446 1447 foreach($postTypes as $postType){ … … 1451 1452 $customPostTypes = (empty($customPostTypes)) ? "none" : implode(',',$customPostTypes); 1452 1453 $reportData[] = array("Custom Post Types","custom_post_types",$customPostTypes); 1453 1454 1454 1455 $output = "First Sale: " . $firstSaleDate . "<br>"; 1455 1456 $output .= "Last Sale: " . $lastSaleDate . "<br>"; … … 1460 1461 $output .= (CART66_PRO) ? "Cart66 Version: Pro " . Cart66Setting::getValue('version') . "<br>" : "Cart66 Version: " .Cart66Setting::getValue('version') . "<br>"; 1461 1462 $output .= "PHP Version: " . phpversion() . "<br>"; 1462 1463 1463 1464 1464 1465 //$output .= ": " . "" . "<br>"; 1465 1466 1466 1467 return $output; 1467 1468 } … … 1492 1493 return $output; 1493 1494 } 1494 1495 1495 1496 public static function getTimeLeft($datestamp) { 1496 1497 $output = false; … … 1519 1520 return $output; 1520 1521 } 1521 1522 1522 1523 public static function cart66UserCan($role) { 1523 1524 $access = false; … … 1535 1536 return $pageRoles[$role]; 1536 1537 } 1537 1538 1538 1539 public static function urlIsLive($url) { 1539 1540 $ch = curl_init($url); 1540 1541 curl_setopt($ch, CURLOPT_NOBODY, true); 1541 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 1542 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 1542 1543 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); 1543 1544 curl_exec($ch); … … 1546 1547 return ($response_code == '200') ? true : false; 1547 1548 } 1548 1549 1549 1550 public static function displayVersionInfo() { 1550 1551 if(CART66_PRO) { … … 1555 1556 } 1556 1557 } 1557 1558 1558 1559 public static function removeCart66Meta() { 1559 1560 remove_action('wp_head', array('Cart66Common','displayVersionInfo')); 1560 1561 } 1561 1562 1562 1563 /** 1563 1564 * Return true if the current page is the mijireh checkout page, otherwise return false. 1564 * 1565 * 1565 1566 * @return boolean 1566 1567 */ … … 1579 1580 return $isSlurp; 1580 1581 } 1581 1582 1582 1583 /** 1583 1584 * Return an array just like explode, but trim the values of the array. 1584 * 1585 * 1585 1586 * This allows for spaces in CSV strings. The following two strings would return the same array 1586 1587 * option1, option2, option3 1587 1588 * option1,option2,option3 1588 * 1589 * 1589 1590 * @return array 1590 1591 */ … … 1597 1598 return $values; 1598 1599 } 1599 1600 1600 1601 public static function sessionType() { 1601 1602 $type = Cart66Setting::getValue('session_type'); … … 1605 1606 return $type; 1606 1607 } 1607 1608 1608 1609 // Remove all non-numeric characters except for the decimal 1609 1610 public static function cleanNumber($string) { … … 1613 1614 return $number; 1614 1615 } 1615 1616 1616 1617 public static function verifyCartPages($outputType = 'full'){ 1617 1618 $requiredPages = array( … … 1635 1636 } 1636 1637 } 1637 1638 1638 1639 switch($outputType){ 1639 1640 case "success": … … 1646 1647 $output = array_merge($error, $success); 1647 1648 } 1648 1649 1649 1650 return implode(" ", $output); 1650 1651 } 1652 1651 1652 } 1653 1653 1654 public static function convert_currency_to_number($amount) { 1654 1655 if(is_numeric($amount)) { … … 1663 1664 return $amount; 1664 1665 } 1665 1666 1666 1667 public static function currency($amount, $html=true, $markup=false, $symbol=true) { 1667 1668 if(!is_numeric($amount)) { … … 1671 1672 $dec_point = Cart66Setting::getValue('currency_dec_point') ? Cart66Setting::getValue('currency_dec_point') : '.'; 1672 1673 $thousands_sep = Cart66Setting::getValue('currency_thousands_sep') ? Cart66Setting::getValue('currency_thousands_sep') : ','; 1673 1674 1674 1675 if($markup) { 1675 1676 $amount = self::currencyMarkup($amount); … … 1698 1699 } 1699 1700 } 1700 1701 1701 1702 return $amount; 1702 1703 } 1703 1704 1704 1705 public static function tax($rate) { 1705 1706 if($rate == 0) { … … 1714 1715 return $rate . '%'; 1715 1716 } 1716 1717 1717 1718 public static function currencyFormat($amount, $decimal, $dec_point, $thousands_sep) { 1718 1719 return number_format($amount, $decimal, $dec_point, $thousands_sep); 1719 1720 } 1720 1721 1721 1722 public static function currencyMarkup($amount) { 1722 1723 $amount = str_replace(CART66_CURRENCY_SYMBOL, '', $amount); … … 1738 1739 $html = $amount; 1739 1740 } 1740 1741 1741 1742 return $html; 1742 1743 } 1743 1744 1744 1745 public static function currencySymbol($position, $html=true) { 1745 1746 $symbol = ''; … … 1762 1763 return $symbol; 1763 1764 } 1764 1765 1765 1766 } -
cart66-lite/trunk/readme.txt
r1042917 r1052064 4 4 Tags: ecommerce, e-commerce, shopping, cart, store, paypal, sell, cart66, products, sales, shopping cart 5 5 Requires at least: 2.8.2 6 Tested up to: 4. 07 Stable tag: 1.5. 36 Tested up to: 4.1 7 Stable tag: 1.5.4 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 98 98 == Changelog == 99 99 100 = 1.5.4 = 101 102 * FIXED: Security vulnerabilities 103 * FIXED: Conflict with DataTables library (causing links to stop working with Yoast Plugins) 104 100 105 = 1.5.3 = 106 101 107 * NEW: [Hurricane affiliate software](http://hurricane.io) integration 102 108 * NEW: Toggle settings for email MIME type
Note: See TracChangeset
for help on using the changeset viewer.