Plugin Directory

Changeset 1052064 for cart66-lite


Ignore:
Timestamp:
12/22/2014 11:14:44 PM (10 years ago)
Author:
reality66
Message:

Update to version 1.5.4

Location:
cart66-lite/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cart66-lite/trunk/cart66.php

    r1042917 r1052064  
    44Plugin URI: http://www.cart66.com
    55Description: Wordpress Shopping Cart
    6 Version: 1.5.3
     6Version: 1.5.4
    77Author: Reality 66
    88Author URI: http://www.Reality66.com
  • cart66-lite/trunk/models/Cart66.php

    r763354 r1052064  
    11<?php
    22class Cart66 {
    3  
     3
    44  public function install() {
    55    global $wpdb;
     
    2020    require_once(CART66_PATH . "/models/Cart66Setting.php");
    2121    Cart66Setting::setValue('version', CART66_VERSION_NUMBER);
    22    
     22
    2323    // Look for hard coded order number
    2424    if(CART66_PRO && CART66_ORDER_NUMBER !== false) {
     
    2929        set_transient('_cart66_version_request', $versionInfo, 43200);
    3030      }
    31       Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Trying to register order number: " . 
     31      Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Trying to register order number: " .
    3232        CART66_ORDER_NUMBER . print_r($versionInfo, true));
    3333      if(!$versionInfo) {
     
    3535      }
    3636    }
    37    
     37
    3838    $this->upgradeDatabase();
    3939  }
    40  
     40
    4141  public function scheduledEvents() {
    4242    $offset = get_option( 'gmt_offset' ) * 3600;
     
    5656    }
    5757  }
    58  
     58
    5959  public function init() {
    6060    global $cart66Settings, $cart66Objects;
     
    6262    $this->initCurrencySymbols();
    6363    $this->setDefaultPageRoles();
    64    
     64
    6565    // Allow override for sending email receipts
    6666    define("CART66_EMAILS", apply_filters('cart66_send_default_emails', true));
    67    
     67
    6868    // Verify that upgrade has been run
    6969    if(IS_ADMIN) {
     
    7373      }
    7474    }
    75    
     75
    7676    // Define debugging and testing info
    7777    $cart66Logging = Cart66Setting::getValue('enable_logging') ? true : false;
     
    7979    define("CART66_DEBUG", $cart66Logging);
    8080    define("SANDBOX", $sandbox);
    81    
     81
    8282    // Handle dynamic JS requests
    8383    // See: http://ottopress.com/2010/dont-include-wp-load-please/ for why
    8484    add_filter('query_vars', array($this, 'addAjaxTrigger'));
    8585    add_action('template_redirect', array($this, 'ajaxTriggerCheck'));
    86    
     86
    8787    // Scheduled events
    8888    if(CART66_PRO) {
     
    9393      add_action('daily_prune_pending_orders', array($order, 'dailyPrunePendingPayPalOrders'));
    9494    }
    95    
     95
    9696    // Notification shortcodes
    9797    $sc = new Cart66ShortcodeManager();
    9898    add_shortcode('email_shortcodes', array($sc, 'emailShortcodes'));
    99        
     99
    100100    // add Cart66 to the admin bar
    101101    if(Cart66Common::cart66UserCan('orders')) {
    102102      add_action('admin_bar_menu', array($this, 'cart66_admin_bar_menu'), 35);
    103103    }
    104    
     104
    105105    if(IS_ADMIN) {
    106106      if(Cart66Setting::getValue('capost_merchant_id')) {
     
    110110
    111111      add_action('admin_head', array( $this, 'registerBasicScripts'));
    112       add_action('admin_init', array($this, 'registerAdminScripts'));
     112      add_action('admin_enqueue_scripts', array($this, 'registerAdminScripts'));
    113113      add_action('admin_init', array($this, 'registerCustomScripts'));
    114114      add_action('admin_print_styles', array($this, 'registerAdminStyles'));
    115      
     115
    116116      add_action('admin_menu', array($this, 'buildAdminMenu'));
    117117      // we dont use this button anymore
     
    134134      add_action('wp_ajax_dismiss_mijireh_notice', array('Cart66Ajax', 'dismissMijirehNotice'));
    135135      add_action('wp_ajax_cart66_page_check', array('Cart66Ajax','checkPages'));
    136            
     136
    137137
    138138      if(CART66_PRO) {
     
    142142        add_action('wp_ajax_inventory_table', array('Cart66DataTables', 'inventoryTable'));
    143143      }
    144      
     144
    145145      // Load Dialog Box in editor
    146146      add_action('media_buttons', array('Cart66Dialog', 'cart66_dialog_box'), 11);
    147147      add_action('admin_footer', array('Cart66Dialog', 'add_shortcode_popup'));
    148      
     148
    149149      // 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'));
    151151      add_action('media_buttons', array($this, 'addPageSlurpButton'), 12);
    152      
     152
    153153      // Load Dashboard Widget
    154154      add_action('wp_dashboard_setup', array('Cart66Dashboard', 'cart66_add_dashboard_widgets' ));
    155      
     155
    156156      if(CART66_PRO) {
    157157        add_action('wp_ajax_update_gravity_product_quantity_field', array('Cart66Ajax', 'updateGravityProductQuantityField'));
    158158      }
    159      
     159
    160160      if(class_exists('SpreedlySubscription') || true) {
    161161        add_action('save_post', array($this, 'saveFeatureLevelMetaBoxData'));
    162162        add_action('add_meta_boxes', array($this, 'addFeatureLevelMetaBox'));
    163163      }
    164      
     164
    165165      //Plugin update actions
    166166      if(CART66_PRO) {
     
    169169        add_action('install_plugins_pre_plugin-information', array('Cart66ProCommon', 'showChangelog'));
    170170      }
    171      
     171
    172172      add_action('save_post', array($this,'check_cart66_pages_on_inline_edit'));
    173173      add_action('admin_notices',array($this,'cart66_page_check'));
     
    192192        add_filter('wp_nav_menu_objects', array($this, 'filter_private_menu_items'), 10, 2);
    193193      }
    194      
     194
    195195      add_action('wp_head', array('Cart66Common', 'displayVersionInfo'));
    196196      add_action('template_redirect', array($this, 'dontCacheMeBro'));
     
    201201      }
    202202    }
    203    
     203
    204204    // ================================================================
    205205    // = Intercept query string cart66 tasks                          =
    206206    // ================================================================
    207      
     207
    208208    // Logout the logged in user
    209209    $isLoggedIn = Cart66Common::isLoggedIn();
     
    213213      Cart66Account::logout($url);
    214214    }
    215    
     215
    216216    if($_SERVER['REQUEST_METHOD'] == 'GET' &&  Cart66Common::getVal('task') == 'member_download') {
    217217      if(Cart66Common::isLoggedIn()) {
    218         $path = $_GET['path'];
     218        $path = str_replace(array('../','./'),'',$_GET['path']); // don't allow folder traversing
    219219        Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Attempting a member download file request: $path");
    220220        Cart66Common::downloadFile($path);
     
    256256      }
    257257    }
    258    
    259   }
    260  
     258
     259  }
     260
    261261  public function checkIPN() {
    262262    if(isset($_GET['listener']) && $_GET['listener'] == '2CO') {
     
    277277    }
    278278  }
    279  
     279
    280280  public function cart66_page_check($return = false){
    281    
     281
    282282    if(Cart66Common::verifyCartPages('error')){
    283      
     283
    284284      $alert_output = "<div class='alert-message alert-danger' id='cart66_page_errors'>
    285285        <div class='left'>
     
    289289          <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>
    290290        </div>
    291       </div>"; 
    292      
     291      </div>";
     292
    293293    }
    294294    else{
    295295      $alert_output = '<div id="cart66_page_errors"></div>';
    296296    }
    297    
     297
    298298    if($return){
    299299      return $alert_output;
     
    303303    }
    304304  }
    305  
     305
    306306  public function check_cart66_pages_on_inline_edit(){
    307307    if(!empty($_POST) && isset($_POST['action']) && $_POST['action'] == 'inline-save' && isset($_POST['post_type']) && $_POST['post_type'] == 'page'){
     
    312312            inline_save_callback();
    313313          </script>
    314         </tr><?php 
     314        </tr><?php
    315315        $inline_save_flag = 1;
    316316      }
    317      
     317
    318318      $inline_safe_flag = 1;
    319      
    320     }
    321    
    322   }
    323  
     319
     320    }
     321
     322  }
     323
    324324  public function cart66_admin_bar_menu() {
    325325      global $wp_admin_bar;
     
    327327        return;
    328328        }
    329      
     329
    330330      $wp_admin_bar->add_menu(
    331331      array( 'id' => 'cart66',
     
    335335      )
    336336    );
    337        
     337
    338338        $cart66Pages = array(
    339339            "Orders" => array("role" => 'orders', "slug" => '_admin'),
     
    350350                'title' => __($page),
    351351                'href' => get_bloginfo('wpurl') . '/wp-admin/admin.php?page=cart66' . strtolower($meta['slug']),
    352                 'meta' => false) 
     352                'meta' => false)
    353353                );
    354354            }
    355355        }
    356        
     356
    357357        $wp_admin_bar->add_menu( array(
    358358            'id' => 'cart66-pages',
     
    360360        'title' => __("Store Pages"),
    361361        'href' => false,
    362         'meta' => false) 
     362        'meta' => false)
    363363        );
    364        
     364
    365365        $storePages = array(
    366366            "Store" => get_page_by_path('store'),
     
    369369            "Receipt" => get_page_by_path('store/receipt')
    370370        );
    371        
     371
    372372        foreach($storePages as $pageName=>$cartPage){
    373373          if($cartPage){
     
    377377            'title' => __($pageName),
    378378            'href' => get_bloginfo('wpurl') . '/wp-admin/post.php?post=' . $cartPage->ID . '&action=edit',
    379             'meta' => false) 
     379            'meta' => false)
    380380            );
    381           }         
     381          }
    382382        }
    383383    }
    384  
     384
    385385  public function cart66_canada_post_upgrade(){
    386386    global $current_screen;
    387      
     387
    388388    echo '<div class="error">';
    389389    echo '<H3>Canada Post Live Rates Update</h3>';
     
    393393    echo '</div>';
    394394  }
    395  
     395
    396396  public function cart66_data_collection(){
    397397       global $current_screen;
    398        
     398
    399399       echo '<div class="updated">';
    400400       echo '<script type="text/javascript">
     
    416416       echo '</div>';
    417417  }
    418    
    419  
     418
     419
    420420  public function filter_private_menu_items($items) {
    421421    if(Cart66Common::isLoggedIn()) {
     
    432432      }
    433433    }
    434    
     434
    435435    return $items;
    436436  }
    437  
     437
    438438  public static function enqueueScripts() {
    439439    $url = CART66_URL . '/cart66.css';
     
    443443      wp_enqueue_style('cart66-custom-css', $css, null, CART66_VERSION_NUMBER, 'all');
    444444    }
    445    
     445
    446446    // Include the cart66 javascript library
    447447    $path = CART66_URL . '/js/cart66-library.js';
    448448    wp_enqueue_script('cart66-library', $path, array('jquery'), CART66_VERSION_NUMBER, true);
    449449  }
    450  
     450
    451451  public function loadCoreModels() {
    452452    require_once(CART66_PATH . "/models/Cart66BaseModelAbstract.php");
     
    482482    require_once(CART66_PATH . "/models/Cart66Updater.php");
    483483    require_once(CART66_PATH . "/models/Cart66Notifications.php");
    484    
     484
    485485    if(CART66_PRO) {
    486486      require_once(CART66_PATH . "/pro/models/Cart66AccessManager.php");
     
    503503      require_once(CART66_PATH . "/pro/models/Cart66EmailLog.php");
    504504      require_once(CART66_PATH . "/pro/models/Cart66MembershipReminders.php");
    505      
     505
    506506      // Load Constant Contact classes
    507507      if(Cart66Setting::getValue('constantcontact_username')) {
     
    512512
    513513    require_once(CART66_PATH . "/gateways/Cart66GatewayAbstract.php");
    514    
     514
    515515    self::loadSpreedlyModels();
    516    
     516
    517517    if(CART66_PRO && Cart66Setting::getValue('zendesk_token')) {
    518518      require_once(CART66_PATH . "/pro/models/ZendeskRemoteAuth.php");
    519519    }
    520520  }
    521  
     521
    522522  public function loadSpreedlyModels() {
    523523    $shortName = Cart66Setting::getValue('spreedly_shortname');
     
    534534    }
    535535  }
    536  
     536
    537537  public function initCurrencySymbols() {
    538538    $cs = Cart66Setting::getValue('CART66_CURRENCY_SYMBOL');
     
    546546    define("CURRENCY_CODE", $ccd);
    547547  }
    548  
     548
    549549  public function setDefaultPageRoles() {
    550550    $defaultPageRoles = array(
     
    576576      if($updateRoles) {
    577577        Cart66Setting::setValue('admin_page_roles',serialize($pageRoles));
    578       }     
     578      }
    579579    }
    580580    return unserialize(Cart66Setting::getValue('admin_page_roles'));
    581581  }
    582  
     582
    583583  public function registerBasicScripts() {
    584584    ?><script type="text/javascript">var wpurl = '<?php echo esc_js( home_url('/') ); ?>';</script><?php
     
    586586    wp_enqueue_style('dashboard-css', $dashboardCss, null, CART66_VERSION_NUMBER, 'all');
    587587  }
    588  
     588
    589589  public function registerAdminScripts() {
    590590    $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    }
    592597    $path = CART66_URL . '/js/page-slurp.js';
    593598    wp_enqueue_script('page-slurp', $path, null, CART66_VERSION_NUMBER, true);
    594599    wp_enqueue_script('pusher', 'https://d3dy5gmtp8yhk7.cloudfront.net/1.11/pusher.min.js', null, CART66_VERSION_NUMBER, true);
    595600  }
    596  
     601
    597602  public function registerCustomScripts() {
    598603    if(strpos($_SERVER['QUERY_STRING'], 'page=cart66') !== false) {
     
    609614      $path = CART66_URL . '/js/ui.multiselect.js';
    610615      wp_enqueue_script('jquery-multiselect', $path, array('jquery-ui-sortable'), CART66_VERSION_NUMBER, true);
    611      
     616
    612617      $path = CART66_URL . '/js/ui.timepicker.addon.js';
    613618      wp_enqueue_script('jquery-timepicker-addon', $path, array('jquery-ui-datepicker', 'jquery-ui-slider'), CART66_VERSION_NUMBER, true);
     
    619624      wp_enqueue_script('notifications-js', $path, null, CART66_VERSION_NUMBER, false);
    620625
    621  
     626
    622627      // Include the jquery table quicksearch library
    623628      $path = CART66_URL . '/js/jquery.quicksearch.js';
    624629      wp_enqueue_script('quicksearch', $path, array('jquery'));
    625      
    626     }
    627   }
    628  
     630
     631    }
     632  }
     633
    629634  public function registerAdminStyles() {
    630635    $screen = get_current_screen();
     
    634639        wp_enqueue_style('widget-css', $widgetCss, null, CART66_VERSION_NUMBER, 'all');
    635640      }
    636      
     641
    637642        $adminCss = CART66_URL . '/admin/admin-styles.css';
    638643        wp_enqueue_style('admin-css', $adminCss, null, CART66_VERSION_NUMBER, 'all');
     
    640645      $uiCss = CART66_URL . '/admin/jquery-ui-1.7.1.custom.css';
    641646      wp_enqueue_style('ui-css', $uiCss, null, CART66_VERSION_NUMBER, 'all');
    642      
     647
    643648      $codemirror = CART66_URL . '/admin/codemirror.css';
    644649      wp_enqueue_style('codemirror-css', $codemirror, null, CART66_VERSION_NUMBER, 'all');
     
    646651    }
    647652  }
    648  
     653
    649654  public function dontCacheMeBro() {
    650655    if(!IS_ADMIN) {
     
    671676        }
    672677      }
    673      
     678
    674679      // Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Disable caching is: $disableCaching");
    675      
     680
    676681      if($sendHeaders) {
    677682        // Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Sending no cache headers");
     
    681686        header('Pragma: no-cache');
    682687      }
    683      
     688
    684689    }
    685690  }
     
    690695  public function buildAdminMenu() {
    691696    $icon = CART66_URL . '/images/cart66_logo_16.gif';
    692    
     697
    693698    add_menu_page('Cart66', 'Cart66', Cart66Common::getPageRoles('orders'), 'cart66_admin', null, $icon);
    694699    add_submenu_page('cart66_admin', __('Orders', 'cart66'), __('Orders', 'cart66'), Cart66Common::getPageRoles('orders'), 'cart66_admin', array('Cart66Admin', 'ordersPage'));
     
    702707    add_submenu_page('cart66_admin', __('Accounts', 'cart66'), __('Accounts', 'cart66'), Cart66Common::getPageRoles('accounts'), 'cart66-accounts', array('Cart66Admin', 'accountsPage'));
    703708  }
    704  
     709
    705710
    706711  /**
     
    718723    }
    719724  }
    720  
     725
    721726  public function checkShippingMethodOnCheckout() {
    722727    if($_SERVER['REQUEST_METHOD'] == 'GET') {
    723728      global $post;
    724729      $checkoutPage = get_page_by_path('store/checkout');
    725      
     730
    726731      if(!Cart66Setting::getValue('use_live_rates')) {
    727732        Cart66Session::drop('Cart66LiveRates');
    728733      }
    729      
     734
    730735      if(is_object($checkoutPage) && isset( $post->ID ) && $post->ID == $checkoutPage->ID) {
    731736        if(Cart66Session::get('Cart66LiveRates') && get_class(Cart66Session::get('Cart66LiveRates')) == 'Cart66LiveRates') {
     
    770775    }
    771776  }
    772  
     777
    773778  public function checkTermsOnCheckout() {
    774779    global $post;
    775780    $checkoutPage = get_page_by_path('store/checkout');
    776781    $cartPage = get_page_by_path('store/cart');
    777    
     782
    778783    // Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] What is the post? " . print_r($post, 1));
    779784    $sendBack = false;
    780785    if(isset($post) && is_object($post) && is_object($cartPage) && is_object($checkoutPage)) {
    781      
     786
    782787      if($post->ID == $checkoutPage->ID || $post->ID == $cartPage->ID) {
    783788        if(Cart66Setting::getValue('require_terms') == 1) {
     
    799804        }
    800805      }
    801      
    802     }
    803   }
    804  
     806
     807    }
     808  }
     809
    805810  public function checkCustomFieldsOnCheckout() {
    806811    global $post;
    807812    $checkoutPage = get_page_by_path('store/checkout');
    808813    $cartPage = get_page_by_path('store/cart');
    809    
     814
    810815    $sendBack = false;
    811816    if(isset($post) && is_object($post) && is_object($cartPage) && is_object($checkoutPage)) {
    812      
     817
    813818      if($post->ID == $checkoutPage->ID || $post->ID == $cartPage->ID) {
    814819        $items = Cart66Session::get('Cart66Cart')->getItems();
     
    832837        }
    833838      }
    834      
    835     }
    836    
    837   }
    838  
     839
     840    }
     841
     842  }
     843
    839844  public function checkMinAmountOnCheckout() {
    840845    global $post;
     
    865870    }
    866871  }
    867  
     872
    868873  public function checkZipOnCheckout() {
    869874    if(CART66_PRO && $_SERVER['REQUEST_METHOD'] == 'GET') {
     
    875880          $link = get_permalink($cartPage->ID);
    876881          $sendBack = false;
    877          
     882
    878883          if(!Cart66Session::get('cart66_shipping_zip')) {
    879884            Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Live rate warning: No shipping zip in session");
     
    886891            $sendBack = true;
    887892          }
    888          
     893
    889894          if($sendBack) {
    890895            wp_redirect($link);
    891896            exit;
    892897          }
    893          
     898
    894899        } // End if checkout page
    895900      } // End if using live rates
    896901    } // End if GET
    897902  }
    898  
     903
    899904  /**
    900905   *  Add Cart66 to the TinyMCE editor
     
    921926    return $plugin_array;
    922927  }
    923  
     928
    924929  /**
    925930   * Load the cart from the session or put a new cart in the session
     
    953958      }
    954959    }
    955    
    956   }
    957  
     960
     961  }
     962
    958963  public function initShortcodes() {
    959964    $sc = new Cart66ShortcodeManager();
     
    988993    add_shortcode('terms_of_service',             array($sc, 'termsOfService'));
    989994    add_shortcode('account_expiration',           array($sc, 'accountExpiration'));
    990    
     995
    991996    if(CART66_PRO) {
    992997      add_shortcode('email_opt_out',              array($sc, 'emailOptOut'));
    993998    }
    994    
     999
    9951000    // System shortcodes
    9961001    add_shortcode('cart66_tests',                 array($sc, 'cart66Tests'));
     
    10031008    add_shortcode('checkout_mwarrior',            array($sc, 'mwarriorCheckout'));
    10041009
    1005    
     1010
    10061011    // Enable Gravity Forms hooks if Gravity Forms is available
    10071012    if(CART66_PRO && class_exists('RGForms')) {
    10081013      add_action("gform_post_submission", array($sc, 'gravityFormToCart'), 100, 1);
    10091014    }
    1010    
    1011   }
    1012  
     1015
     1016  }
     1017
    10131018  /**
    10141019   * Adds a query var trigger for the dynamic JS dialog
     
    10381043      exit;
    10391044    }
    1040    
     1045
    10411046    if ( intval( get_query_var( 'cart66AjaxCartRequests' ) ) == 4 ) {
    10421047      //Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] CONFIRM ORDER VERIFICATION");
     
    10441049      exit;
    10451050    }
    1046    
     1051
    10471052    if ( intval( get_query_var( 'cart66AjaxCartRequests' ) ) == 5 ) {
    10481053      //Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] CONFIRM ORDER VERIFICATION");
     
    10581063    register_widget('Cart66CartWidget');
    10591064  }
    1060  
    1061   public function addPageSlurpButtonMeta() { 
     1065
     1066  public function addPageSlurpButtonMeta() {
    10621067    global $post;
    10631068    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
    10711076        }
    10721077  }
    1073  
     1078
    10741079  public function drawPageSlurpMetaBox($post) {
    10751080    echo "<div id='mijireh_notice' class='mijireh-info alert-message info' data-alert='alert'>";
     
    10841089    echo  "</div>";
    10851090  }
    1086  
     1091
    10871092  public function addFeatureLevelMetaBox() {
    10881093    if(CART66_PRO) {
     
    10901095      //add_meta_box('cart66_feature_level_meta', __('Feature Levels', 'cart66'), array($this, 'drawFeatureLevelMetaBox'), 'page', 'side', 'low');
    10911096    }
    1092   } 
    1093  
     1097  }
     1098
    10941099  public function drawFeatureLevelMetaBox($post) {
    10951100    if(CART66_PRO) {
     
    10971102      $featureLevels = array();
    10981103      $data = array();
    1099      
     1104
    11001105      // Load feature levels defined in Spreedly if available
    11011106      if(class_exists('SpreedlySubscription')) {
     
    11161121        $featureLevels[] = $s->featureLevel;
    11171122      }
    1118      
     1123
    11191124      // Load feature levels defined in Membership products
    11201125      foreach(Cart66Product::getMembershipProducts() as $membership) {
     
    11261131      if(count($featureLevels)) {
    11271132        $featureLevels = array_unique($featureLevels);
    1128         sort($featureLevels); 
     1133        sort($featureLevels);
    11291134
    11301135        $savedPlanCsv = get_post_meta($post->ID, '_cart66_subscription', true);
     
    11371142    }
    11381143  }
    1139  
     1144
    11401145  /**
    11411146   * Convert selected plan ids into a CSV string.
     
    11491154        $featureLevels = implode(',', $_REQUEST['feature_levels']);
    11501155      }
    1151      
     1156
    11521157      if(!empty($featureLevels)) {
    11531158        add_post_meta($postId, '_cart66_subscription', $featureLevels, true) or update_post_meta($postId, '_cart66_subscription', $featureLevels);
     
    11581163    }
    11591164  }
    1160  
     1165
    11611166  public function hideStorePages($excludes) {
    1162    
     1167
    11631168    if(Cart66Setting::getValue('hide_system_pages') == 1) {
    11641169      $store = get_page_by_path('store');
     
    11801185    $receipt = get_page_by_path('store/receipt');
    11811186    $excludes[] = $receipt->ID;
    1182    
     1187
    11831188    $spreedly = get_page_by_path('store/spreedly');
    11841189    if ( isset( $spreedly->ID ) )
    11851190            $excludes[] = $spreedly->ID;
    1186    
     1191
    11871192    if(is_array(get_option('exclude_pages'))){
    11881193        $excludes = array_merge(get_option('exclude_pages'), $excludes );
    11891194    }
    11901195    sort($excludes);
    1191    
     1196
    11921197    return $excludes;
    11931198  }
    1194  
     1199
    11951200  public function protectSubscriptionPages() {
    11961201    global $wp_query;
    1197    
     1202
    11981203    // Keep visitors who are not logged in from seeing private pages
    11991204    if(!isset($wp_query->tax_query)) {
    12001205      $pid = isset( $wp_query->post->ID ) ? $wp_query->post->ID : NULL;
    12011206      Cart66AccessManager::verifyPageAccessRights($pid);
    1202      
     1207
    12031208      // block subscription pages from non-subscribers
    12041209      $accountId = Cart66Common::isLoggedIn() ? Cart66Session::get('Cart66AccountId') : 0;
     
    12701275
    12711276  }
    1272  
     1277
    12731278  /**
    12741279   * Hide private pages and pages that require a subscription feature level the subscriber does not have
     
    12841289      $hidePrivate = false;
    12851290      $account = new Cart66Account(Cart66Session::get('Cart66AccountId'));
    1286      
     1291
    12871292      if($account->isActive()) {
    12881293        $activeAccount = true;
    12891294        $featureLevel = $account->getFeatureLevel();
    12901295      }
    1291      
     1296
    12921297      // Optionally add the logout link to the end of the navigation
    12931298      if(Cart66Setting::getValue('auto_logout_link')) {
     
    13201325    return $excludes;
    13211326  }
    1322  
     1327
    13231328  public function appendLogoutLink($output) {
    13241329    $output .= "<li><a href='" . Cart66Common::appendQueryString('cart66-task=logout') . "'>Log out</a></li>";
    13251330    return $output;
    13261331  }
    1327  
     1332
    13281333  /**
    13291334   * Force downloads for
     
    13431348      $report = Cart66Exporter::exportOrders($start, $end);
    13441349
    1345       header('Content-Type: application/csv'); 
     1350      header('Content-Type: application/csv');
    13461351      header('Content-Disposition: inline; filename="Cart66Report.csv"');
    13471352      echo $report;
     
    13691374      Cart66Common::clearLog();
    13701375    }
    1371    
    1372   }
    1373  
     1376
     1377  }
     1378
    13741379  public function addPageSlurpButton() {
    13751380    global $post;
     
    13781383    }
    13791384  }
    1380  
     1385
    13811386  public function upgradeDatabase() {
    13821387    if(Cart66Setting::getValue('auth_force_ssl') == 'no') {
     
    13871392    }
    13881393  }
    1389  
     1394
    13901395}
  • cart66-lite/trunk/models/Cart66Ajax.php

    r1023350 r1052064  
    11<?php
    22class Cart66Ajax {
    3  
     3
    44  public static function resendEmailFromLog() {
    55    $log_id = $_POST['id'];
     
    1616    die();
    1717  }
    18  
     18
    1919  public function forcePluginUpdate(){
    2020    $output = false;
     
    2626    die();
    2727  }
    28  
     28
    2929  public static function sendTestEmail() {
    3030    $to = $_POST['email'];
     
    5353    die();
    5454  }
    55  
     55
    5656  public static function ajaxReceipt() {
    5757    if(isset($_GET['order_id'])) {
     
    6464    }
    6565  }
    66  
     66
    6767  public static function ajaxOrderLookUp() {
    6868    $redirect = true;
     
    7878    die();
    7979  }
    80  
     80
    8181  public static function viewLoggedEmail() {
    8282    if(isset($_POST['log_id'])) {
     
    8686    }
    8787  }
    88  
     88
    8989  public static function checkPages(){
    9090    $Cart66 = new Cart66();
     
    9292    die();
    9393  }
    94  
     94
    9595  public static function shortcodeProductsTable() {
    9696    global $wpdb;
    9797    $prices = array();
    98     $types = array(); 
     98    $types = array();
    9999    //$options='';
    100100    $postId = intval(Cart66Common::postVal('id'));
     
    129129    die();
    130130  }
    131  
     131
    132132  public static function ajaxTaxUpdate() {
    133133    if(isset($_POST['state']) && isset($_POST['state_text']) && isset($_POST['zip']) && isset($_POST['gateway'])) {
     
    168168    die();
    169169  }
    170  
     170
    171171  public static function loadAjaxGateway($gateway) {
    172172    switch($gateway) {
     
    212212    return $gateway;
    213213  }
    214  
     214
    215215  public static function ajaxCartElements($args="") {
    216216
     
    227227      );
    228228    }
    229    
     229
    230230    $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()),
    233233      'count' => Cart66CartWidget::countItems()
    234234    );
    235    
     235
    236236    $array = array(
    237237      'summary' => $summary,
     
    244244    die();
    245245  }
    246  
     246
    247247  public static function ajaxAddToCart() {
    248248    $message = Cart66Session::get('Cart66Cart')->addToCart(true);
     
    257257    die();
    258258  }
    259  
     259
    260260  public static function promotionProductSearch() {
    261261    global $wpdb;
     
    263263    $product = new Cart66Product();
    264264    $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);
    266267    $data = array();
    267268    foreach($products as $p) {
     
    271272    die();
    272273  }
    273  
     274
    274275  public static function loadPromotionProducts() {
    275276    $productId = Cart66Common::postVal('productId');
     
    284285    die();
    285286  }
    286  
     287
    287288  public static function saveSettings() {
     289    if(!Cart66Common::cart66UserCan('settings')){
     290      die();
     291    }
    288292    $error = '';
    289293    foreach($_REQUEST as $key => $value) {
     
    327331        }
    328332        elseif($key == 'constantcontact_list_ids') {
    329          
     333
    330334        }
    331335        elseif($key == 'admin_page_roles') {
     
    359363    else {
    360364      $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>';
    362366    }
    363367
     
    366370    die();
    367371  }
    368  
     372
    369373  public static function updateGravityProductQuantityField() {
    370374    $formId = Cart66Common::getVal('formId');
     
    375379    die();
    376380  }
    377  
     381
    378382  public static function checkInventoryOnAddToCart() {
    379383    $result = array(true);
     
    415419      $result[1] = $p->name . " " . $optionsMsg . " is $soldOutLabel $out";
    416420    }
    417    
     421
    418422    $result = json_encode($result);
    419423    echo $result;
    420424    die();
    421425  }
    422  
     426
    423427  public static function pageSlurp() {
    424428    require_once(CART66_PATH . "/models/Pest.php");
    425429    require_once(CART66_PATH . "/models/PestJSON.php");
    426    
     430
    427431    $page_id = Cart66Common::postVal('page_id');
    428432    $page = get_page($page_id);
     
    430434    $html = false;
    431435    $job_id = $slurp_url;
    432    
     436
    433437    if(wp_update_post(array('ID' => $page->ID, 'post_status' => 'publish'))) {
    434438      $access_key = Cart66Setting::getValue('mijireh_access_key');
     
    440444        'return_url' => add_query_arg('task', 'mijireh_page_slurp', $slurp_url)
    441445      );
    442      
     446
    443447      try {
    444448        $response = $rest->post('/api/1/slurps', $data);
     
    453457      $job_id = 'did not update post successfully';
    454458    }
    455    
     459
    456460    echo $job_id;
    457461    die;
    458462  }
    459  
     463
    460464  public static function dismissMijirehNotice() {
    461465    Cart66Setting::setValue('mijireh_notice', 1);
    462466  }
    463  
     467
    464468}
  • cart66-lite/trunk/models/Cart66Common.php

    r1023350 r1052064  
    33
    44  /**
    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
    77   * conflicting input ids.
    88   *
     
    3434    return $id;
    3535  }
    36  
     36
    3737  /**
    3838   * Strip all non numeric characters, then format the phone number.
    39    * 
     39   *
    4040   * Phone numbers are formatted as follows:
    4141   *  7 digit phone numbers: 266-1789
    4242   *  10 digit phone numbers: (804) 266-1789
    43    * 
     43   *
    4444   * @return string
    4545   */
     
    6060    return $isRegistered;
    6161  }
    62  
     62
    6363  public static function activePromotions() {
    6464    $active = false;
     
    6969    return $active;
    7070  }
    71  
     71
    7272  public static function showValue($value) {
    7373    echo isset($value)? $value : '';
    7474  }
    75  
     75
    7676  public static function displayCustomFormField($field, $post_data) {
    7777    $output = '';
     
    8787    return $output;
    8888  }
    89  
     89
    9090  public static function getView($filename, $data=null, $notices=true, $minify=false) {
    9191    $notice = '';
     
    110110        }
    111111      }
    112      
     112
    113113      if(CART66_PRO && !self::isRegistered()) {
    114114        $hardCoded = '';
     
    128128        }
    129129      }
    130      
     130
    131131    }
    132132
     
    154154    $overrideDirectory = $themeDirectory."/cart66-templates";
    155155    $userViewFile = $overrideDirectory."/$filename";
    156    
     156
    157157    //Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Override: $overrideDirectory\nUser view file: $userViewFile");
    158    
     158
    159159    if(file_exists($userViewFile) && in_array($filename,$approvedOverrideFiles)) {
    160160      // File exists, make sure it's not empty
     
    172172      // Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Approved Override: ".var_export(in_array($filename,$approvedOverrideFiles),true));
    173173    }
    174  
     174
    175175    // Check for override and confirm we have a registered plugin
    176176    if($customView && CART66_PRO && self::isRegistered()) {
     
    182182      $filename = CART66_PATH . "/$filename";
    183183    }
    184    
     184
    185185    ob_start();
    186186    include $filename;
    187187    $contents = ob_get_contents();
    188188    ob_end_clean();
    189    
     189
    190190    return ($minify) ? Cart66Common::minifyMarkup($notice . $contents) : $notice . $contents;
    191191  }
    192  
     192
    193193  public static function minifyMarkup($markup){
    194194    $search = array(
     
    205205    return $output;
    206206  }
    207  
     207
    208208  public static function getTableName($name, $prefix='cart66_'){
    209209      global $wpdb;
    210210      return $wpdb->prefix . $prefix . $name;
    211211  }
    212  
     212
    213213  public static function getTablePrefix(){
    214214      global $wpdb;
    215215      return $wpdb->prefix . "cart66_";
    216216  }
    217  
     217
    218218  /**
    219219   * If CART66_DEBUG is defined as true and a log file exists in the root of the Cart66 plugin directory, log the $data
    220220   */
    221221  public static function log($data) {
    222    
     222
    223223    if(defined('CART66_DEBUG') && CART66_DEBUG) {
    224224      $tz = '- Server time zone ' . date('T');
    225225      $date = date('m/d/Y g:i:s a', self::localTs());
    226226      $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";
    228228      if(file_exists($filename) && is_writable($filename)) {
    229229        file_put_contents($filename, $header . $data, FILE_APPEND);
    230230      }
    231231    }
    232    
    233   }
    234  
     232
     233  }
     234
    235235  public static function clearLog(){
    236     $filename = CART66_PATH . "/log.txt"; 
     236    $filename = CART66_PATH . "/log.txt";
    237237    if(file_exists($filename) && is_writable($filename)) {
    238238      file_put_contents($filename, '');
     
    243243    $id = '';
    244244        mt_srand((double)microtime()*1000000);
    245         for ($i = 0; $i < $numChars; $i++) { 
     245        for ($i = 0; $i < $numChars; $i++) {
    246246            $id .= chr(mt_rand(ord(0), ord(9)));
    247247        }
    248248        return $id;
    249249    }
    250    
     250
    251251    public static function getRandString($length = 14) {
    252252      $string = '';
     
    257257    }
    258258      return $string;
    259     } 
    260  
     259    }
     260
    261261  public static function camel2human($val) {
    262262    $val = strtolower(preg_replace('/([A-Z])/', ' $1', $val));
    263263    return $val;
    264264  }
    265  
     265
    266266  /**
    267267   * Return the account id if the visitor is logged in, otherwise false.
    268268   * This function has nothing to do with feature levels or subscription status
    269    * 
     269   *
    270270   * @return int or false
    271271   */
     
    278278  }
    279279
    280  
     280
    281281  public static function awardCommission($orderId, $referrer) {
    282282    global $wpdb;
     
    288288        $order_items = array();
    289289        foreach($order->getItems() as $item) {
    290           $order_items[] = $item->item_number;         
     290          $order_items[] = $item->item_number;
    291291          $price = $item->product_price * $item->quantity;
    292292
     
    303303            $price = $price - $subtractAmount;
    304304          }
    305          
     305
    306306          // Transaction if for commission is the id in th order items table
    307307          $txn_id = $order->trans_id;
     
    309309          $item_id = $item->item_number;
    310310          $buyer_email = $order->email;
    311          
     311
    312312          if(function_exists('wp_aff_award_commission')) {
    313313            // Make sure commission has not already been granted for this transaction
     
    318318            }
    319319          }
    320          
    321         }
    322        
     320
     321        }
     322
    323323        // valid order id
    324324        // Transaction if for commission is the id in th order items table
     
    327327        $item_id = implode(',',$order_items);
    328328        $buyer_email = $order->email;
    329        
     329
    330330        // Affiliate Royale
    331         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] 
     331        Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "]
    332332         Running wafp_award_commission\n
    333333         referrer $referrer\n
     
    337337         buyer_email $buyer_email");
    338338         do_action('wafp_award_commission', $referrer, $sale_amount, $txn_id, $item_id, $buyer_email);
    339        
    340       }
    341     }
    342   }
    343  
     339
     340      }
     341    }
     342  }
     343
    344344  /**
    345345   * Return true if the email address is not empty and has a valid format
    346    * 
     346   *
    347347   * @param string $email The email address to validate
    348348   * @return boolean Empty or invalid email addresses return false, otherwise true
     
    365365    return $isValid;
    366366  }
    367  
     367
    368368  public static function isEmailUnique($email, $exceptId=0) {
    369369    global $wpdb;
     
    375375    return $isUnique;
    376376  }
    377  
     377
    378378  public static function randomString($numChars = 7) {
    379379    $letters = "";
    380380    mt_srand((double)microtime()*1000000);
    381     for ($i = 0; $i < $numChars; $i++) { 
     381    for ($i = 0; $i < $numChars; $i++) {
    382382      $randval = chr(mt_rand(ord("a"), ord("z")));
    383383      $letters .= $randval;
     
    385385    return $letters;
    386386  }
    387  
     387
    388388  public static function isValidDate($val) {
    389389    $isValid = false;
     
    407407    return $isValid;
    408408  }
    409  
     409
    410410  /**
    411411   * Strip slashes and escape sequences from POST values and returened the scrubbed value.
     
    419419    return $value;
    420420  }
    421  
     421
    422422  public static function deepTagClean(&$data) {
    423423    if(is_array($data)) {
     
    438438    return $data;
    439439  }
    440  
     440
    441441
    442442  /**
     
    452452    return $value;
    453453  }
    454  
     454
    455455  /**
    456456   * Get home country code from cart settings or return US if no setting exists
    457    * 
     457   *
    458458   * @return string
    459459   */
    460460  public static function getHomeCountryCode() {
    461461    if($homeCountry = Cart66Setting::getValue('home_country')) {
    462       list($homeCountryCode, $dummy) = explode('~', $homeCountry); 
     462      list($homeCountryCode, $dummy) = explode('~', $homeCountry);
    463463    }
    464464    else {
     
    467467    return $homeCountryCode;
    468468  }
    469  
     469
    470470  public static function getCountryName($code) {
    471471    $countries = self::getCountries(true);
     
    481481    return $localeCode;
    482482  }
    483  
     483
    484484  public static function getShippingCountries() {
    485485    $countries = self::getCountries();
     
    505505    return $countries;
    506506  }
    507  
     507
    508508  public static function getCountries($all=false) {
    509509    $countries = array(
     
    749749      'ZW'=>'Zimbabwe'
    750750    );
    751    
     751
    752752    // Put home country at the top of the list
    753753    $setting = new Cart66Setting();
     
    762762
    763763    $customCountries = self::getCustomCountries();
    764    
     764
    765765    if($all) {
    766766      if(is_array($customCountries)) {
     
    783783      }
    784784      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
    791791    return $countries;
    792792  }
     
    805805    return $list;
    806806  }
    807  
     807
    808808  public static function getPayPalCurrencyCodes() {
    809809    $currencies = array(
     
    834834  }
    835835
    836  
     836
    837837  public static function getZones($code='all') {
    838838    $setting = new Cart66Setting();
    839839    $zones = array();
    840    
     840
    841841    $au = array();
    842842    $au['0'] = '';
     
    850850    $au['WA'] = 'Western Australia';
    851851    $zones['AU'] = $au;
    852    
     852
    853853    $br = array();
    854854    $br['0'] = '';
     
    881881    $br['Tocantins'] = 'Tocantins';
    882882    $zones['BR'] = $br;
    883    
     883
    884884    $ca = array();
    885885    $ca['0'] = '';
     
    898898    $ca['YT'] = 'Yukon Territory';
    899899    $zones['CA'] = $ca;
    900    
     900
    901901    $my['0'] = '';
    902902    $my['KUL'] = 'Kuala Lumpur (Federal Territory)';
     
    917917    $my['TRG'] = 'Terengganu';
    918918    $zones['MY'] = $my;
    919    
     919
    920920    $us = array();
    921921    $us['0'] = '';
     
    974974    $us['AE'] = 'Armed Forces (AE)';
    975975    $us['AP'] = 'Armed Forces (AP)';
    976    
     976
    977977    if($setting->getValue('include_us_territories') == 1){
    978978      $us['AS'] = 'American Samoa';
     
    985985      $us['PW'] = 'Palua';
    986986    }
    987    
     987
    988988    $zones['US'] = $us;
    989    
     989
    990990    switch ($code) {
    991991      case 'AU':
     
    10051005        break;
    10061006    }
    1007    
     1007
    10081008    return $zones;
    10091009  }
    1010  
     1010
    10111011
    10121012
     
    10321032    return $path;
    10331033  }
    1034  
     1034
    10351035  public static function localTs($timestamp=null) {
    10361036    $timestamp = isset($timestamp) ? $timestamp : time();
     
    10691069    return $promoMsg;
    10701070  }
    1071  
     1071
    10721072  //increment the number of redemptions
    10731073  public function updatePromoRedemptions() {
     
    10751075    $promotion->updateRedemptions();
    10761076  }
    1077  
     1077
    10781078  public function showErrors($errors, $message=null) {
    10791079    $out = "<div id='cart66Errors' class='Cart66Error'>";
     
    10971097    return $out;
    10981098  }
    1099  
     1099
    11001100  public function getJqErrorScript(array $jqErrors) {
    11011101    $script = '
     
    11221122  /**
    11231123   * Return the WP_CONTENT_URL taking into account HTTPS and the possibility that WP_CONTENT_URL may not be defined
    1124    * 
     1124   *
    11251125   * @return string
    11261126   */
     
    11351135    return $wpurl;
    11361136  }
    1137  
     1137
    11381138  /**
    11391139   * Return the WordPress URL taking into account HTTPS
     
    11461146    return $wpurl;
    11471147  }
    1148  
     1148
    11491149  /**
    11501150   * Detect if request occurred over HTTPS and, if so, return TRUE. Otherwise return FALSE.
    1151    * 
     1151   *
    11521152   * @return boolean
    11531153   */
    11541154  public static function isHttps() {
    11551155    $isHttps = false;
    1156     if((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || 
     1156    if((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ||
    11571157        (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) {
    11581158      $isHttps = true;
     
    11601160    return $isHttps;
    11611161  }
    1162  
    1163  
     1162
     1163
    11641164  public static function getCurrentPageUrl() {
    11651165    $protocol = 'http://';
     
    11701170    return $url;
    11711171  }
    1172  
     1172
    11731173  /**
    11741174   * Attach a string of name/value pairs to a URL for the current page
    11751175   * This function looks for the presence of a ? and appropriately appends the new parameters.
    11761176   * Return a URL for the current page with the appended params.
    1177    * 
     1177   *
    11781178   * @return string
    11791179   */
     
    11841184    return $url;
    11851185  }
    1186  
     1186
    11871187  public static function appendWurlQueryString($nvPairs) {
    11881188    $url = home_url();
     
    11911191    return $url;
    11921192  }
    1193  
     1193
    11941194  /**
    11951195   * Replace the query string for the current page url
    1196    * 
     1196   *
    11971197   * @param string Name value pairs formatted as name1=value1&name2=value2
    11981198   * @return string The URL to the current page with the given query string
     
    12061206    return $url;
    12071207  }
    1208  
    1209 
    1210  
     1208
     1209
     1210
    12111211  public static function serializeSimpleXML(SimpleXMLElement $xmlObj) {
    12121212    return serialize($xmlObj->asXML());
    12131213  }
    1214  
     1214
    12151215  public static function unserializeSimpleXML($str) {
    12161216    return simplexml_load_string(unserialize($str));
    12171217  }
    1218  
     1218
    12191219  /**
    12201220   * Return either the live or the sandbox PayPal URL based on whether or not paypal_sandbox is set.
     
    12271227    return $paypalUrl;
    12281228  }
    1229  
     1229
    12301230  public static function curl($url, $method='GET') {
    12311231    $method = strtoupper($method);
    1232    
     1232
    12331233    // Make sure curl is installed?
    1234     if (!function_exists('curl_init')){ 
     1234    if (!function_exists('curl_init')){
    12351235      throw new Cart66Exception('cURL is not installed!');
    12361236    }
     
    12431243    curl_setopt($ch, CURLOPT_VERBOSE, true);
    12441244    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    1245    
     1245
    12461246    if($method == 'POST') {
    12471247      curl_setopt($ch, CURLOPT_POST, true);
    12481248    }
    1249    
     1249
    12501250    $output = curl_exec($ch);
    12511251
    12521252    // close the curl resource, and free system resources
    12531253    curl_close($ch);
    1254    
     1254
    12551255    // wp remote fallback
    12561256    if(empty($output)){
     
    12581258      $output = $output['body'];
    12591259    }
    1260    
     1260
    12611261    return $output;
    12621262  }
    1263  
     1263
    12641264  public static function downloadFile($path) {
    1265    
     1265
    12661266    // Validate the $path
    12671267    if(!strpos($path, '://')) {
     
    12891289          Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Download file size: $bytes");
    12901290
    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 
    13011291          //open the file and stream download
    13021292          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
    13031304            while(!feof($fp)) {
    13041305              //reset time limit for big files
     
    13221323      }
    13231324    }
    1324    
    1325   }
    1326  
     1325
     1326  }
     1327
    13271328  public static function remoteFileSize($remoteFile) {
    13281329    $ch = curl_init($remoteFile);
     
    13301331    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    13311332    curl_setopt($ch, CURLOPT_HEADER, true);
    1332     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
     1333    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    13331334    $data = curl_exec($ch);
    13341335    curl_close($ch);
     
    13411342    return $contentLength;
    13421343  }
    1343  
     1344
    13441345  public static function onlyUsingPayPalStandard() {
    13451346    $onlyPayPalStandard = false;
     
    13471348      $onlyPayPalStandard = true;
    13481349    }
    1349    
     1350
    13501351    if(Cart66Setting::getValue('auth_username') || Cart66Setting::getValue('paypalpro_api_username')) {
    13511352      $onlyPayPalStandard = false;
    13521353    }
    1353    
     1354
    13541355    return $onlyPayPalStandard;
    13551356  }
    1356  
     1357
    13571358  /**
    13581359   * Convert an array into XML
    1359    * 
     1360   *
    13601361   * Example use: echo arrayToXml($products,'products');
    1361    * 
     1362   *
    13621363   * @param array $array       - The array you wish to convert into a XML structure.
    13631364   * @param string $name       - The name you wish to enclose the array in, the 'parent' tag for XML.
     
    14111412    return $output;
    14121413  }
    1413  
     1414
    14141415  public static function testResult($passed, $msg='') {
    14151416    $trace = debug_backtrace();
     
    14211422    echo $out . "\n";
    14221423  }
    1423  
     1424
    14241425  public static function showReportData(){
    14251426    global $wpdb;
    14261427    $orders = Cart66Common::getTableName('orders');
    14271428    $reportData = array();
    1428    
     1429
    14291430    $sql = "SELECT sum(`total`) from $orders";
    14301431    $lifetimeTotal = $wpdb->get_var($sql);
    14311432    $reportData[] = array("Total Sales","total_sales",$lifetimeTotal);
    1432    
     1433
    14331434    $sql = "SELECT count('id') from $orders";
    14341435    $totalOrders = $wpdb->get_var($sql);
    14351436    $reportData[] = array("Total Orders","total_orders",$totalOrders);
    1436    
     1437
    14371438    $sql = "SELECT ordered_on from $orders order by id asc LIMIT 1";
    14381439    $firstSaleDate = $wpdb->get_var($sql);
    14391440    $reportData[] = array("First Sale","first_sale",$firstSaleDate);
    1440    
     1441
    14411442    $sql = "SELECT ordered_on from $orders order by id desc LIMIT 1";
    14421443    $lastSaleDate = $wpdb->get_var($sql);
    14431444    $reportData[] = array("Last Sale","last_sale",$lastSaleDate);
    1444    
     1445
    14451446    $postTypes = get_post_types('','names');
    14461447    foreach($postTypes as $postType){
     
    14511452    $customPostTypes = (empty($customPostTypes)) ? "none" : implode(',',$customPostTypes);
    14521453    $reportData[] = array("Custom Post Types","custom_post_types",$customPostTypes);
    1453    
     1454
    14541455    $output = "First Sale: " . $firstSaleDate . "<br>";
    14551456    $output .= "Last Sale: " . $lastSaleDate . "<br>";
     
    14601461    $output .= (CART66_PRO) ? "Cart66 Version: Pro " . Cart66Setting::getValue('version') . "<br>" : "Cart66 Version: " .Cart66Setting::getValue('version') . "<br>";
    14611462    $output .= "PHP Version: " . phpversion() . "<br>";
    1462    
    1463    
     1463
     1464
    14641465    //$output .= ": " . "" . "<br>";
    1465    
     1466
    14661467    return $output;
    14671468  }
     
    14921493    return $output;
    14931494  }
    1494  
     1495
    14951496  public static function getTimeLeft($datestamp) {
    14961497    $output = false;
     
    15191520    return $output;
    15201521  }
    1521  
     1522
    15221523  public static function cart66UserCan($role) {
    15231524    $access = false;
     
    15351536    return $pageRoles[$role];
    15361537  }
    1537  
     1538
    15381539  public static function urlIsLive($url) {
    15391540    $ch = curl_init($url);
    15401541    curl_setopt($ch, CURLOPT_NOBODY, true);
    1541     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
     1542    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    15421543    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    15431544    curl_exec($ch);
     
    15461547    return ($response_code == '200') ? true : false;
    15471548  }
    1548  
     1549
    15491550  public static function displayVersionInfo() {
    15501551    if(CART66_PRO) {
     
    15551556    }
    15561557  }
    1557  
     1558
    15581559  public static function removeCart66Meta() {
    15591560    remove_action('wp_head', array('Cart66Common','displayVersionInfo'));
    15601561  }
    1561  
     1562
    15621563  /**
    15631564   * Return true if the current page is the mijireh checkout page, otherwise return false.
    1564    * 
     1565   *
    15651566   * @return boolean
    15661567   */
     
    15791580    return $isSlurp;
    15801581  }
    1581  
     1582
    15821583  /**
    15831584   * Return an array just like explode, but trim the values of the array.
    1584    * 
     1585   *
    15851586   * This allows for spaces in CSV strings. The following two strings would return the same array
    15861587   * option1, option2, option3
    15871588   * option1,option2,option3
    1588    * 
     1589   *
    15891590   * @return array
    15901591   */
     
    15971598    return $values;
    15981599  }
    1599  
     1600
    16001601  public static function sessionType() {
    16011602    $type = Cart66Setting::getValue('session_type');
     
    16051606    return $type;
    16061607  }
    1607  
     1608
    16081609  // Remove all non-numeric characters except for the decimal
    16091610  public static function cleanNumber($string) {
     
    16131614    return $number;
    16141615  }
    1615  
     1616
    16161617  public static function verifyCartPages($outputType = 'full'){
    16171618    $requiredPages = array(
     
    16351636       }
    16361637    }
    1637    
     1638
    16381639    switch($outputType){
    16391640      case "success":
     
    16461647        $output = array_merge($error, $success);
    16471648    }
    1648    
     1649
    16491650    return implode(" ", $output);
    1650    
    1651   }
    1652  
     1651
     1652  }
     1653
    16531654  public static function convert_currency_to_number($amount) {
    16541655    if(is_numeric($amount)) {
     
    16631664    return $amount;
    16641665  }
    1665  
     1666
    16661667  public static function currency($amount, $html=true, $markup=false, $symbol=true) {
    16671668    if(!is_numeric($amount)) {
     
    16711672    $dec_point = Cart66Setting::getValue('currency_dec_point') ? Cart66Setting::getValue('currency_dec_point') : '.';
    16721673    $thousands_sep = Cart66Setting::getValue('currency_thousands_sep') ? Cart66Setting::getValue('currency_thousands_sep') : ',';
    1673    
     1674
    16741675    if($markup) {
    16751676      $amount = self::currencyMarkup($amount);
     
    16981699      }
    16991700    }
    1700    
     1701
    17011702    return $amount;
    17021703  }
    1703  
     1704
    17041705  public static function tax($rate) {
    17051706    if($rate == 0) {
     
    17141715    return $rate . '%';
    17151716  }
    1716  
     1717
    17171718  public static function currencyFormat($amount, $decimal, $dec_point, $thousands_sep) {
    17181719    return number_format($amount, $decimal, $dec_point, $thousands_sep);
    17191720  }
    1720  
     1721
    17211722  public static function currencyMarkup($amount) {
    17221723    $amount = str_replace(CART66_CURRENCY_SYMBOL, '', $amount);
     
    17381739      $html = $amount;
    17391740    }
    1740    
     1741
    17411742    return $html;
    17421743  }
    1743  
     1744
    17441745  public static function currencySymbol($position, $html=true) {
    17451746    $symbol = '';
     
    17621763    return $symbol;
    17631764  }
    1764  
     1765
    17651766}
  • cart66-lite/trunk/readme.txt

    r1042917 r1052064  
    44Tags: ecommerce, e-commerce, shopping, cart, store, paypal, sell, cart66, products, sales, shopping cart
    55Requires at least: 2.8.2
    6 Tested up to: 4.0
    7 Stable tag: 1.5.3
     6Tested up to: 4.1
     7Stable tag: 1.5.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9898== Changelog ==
    9999
     100= 1.5.4 =
     101
     102* FIXED: Security vulnerabilities
     103* FIXED: Conflict with DataTables library (causing links to stop working with Yoast Plugins)
     104
    100105= 1.5.3 =
     106
    101107* NEW: [Hurricane affiliate software](http://hurricane.io) integration
    102108* NEW: Toggle settings for email MIME type
Note: See TracChangeset for help on using the changeset viewer.