public function section_main_settings()
 {
     $successMessage = '';
     $versionInfo = false;
     $orderNumberFailed = '';
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         if ($_POST['cart66-action'] == 'saveOrderNumber' && CART66_PRO) {
             $orderNumber = trim(Cart66Common::postVal('order_number'));
             Cart66Setting::setValue('order_number', $orderNumber);
             $versionInfo = get_transient('_cart66_version_request');
             if (!$versionInfo) {
                 $versionInfo = Cart66ProCommon::getVersionInfo();
                 set_transient('_cart66_version_request', $versionInfo, 43200);
             }
             if ($versionInfo) {
                 $successMessage = __("Thank you! Cart66 has been activated", "cart66");
             } else {
                 Cart66Setting::setValue('order_number', '');
                 $orderNumberFailed = true;
             }
         }
     }
     $data = array('success_message' => $successMessage, 'version_info' => $versionInfo, 'order_number_failed' => $orderNumberFailed);
     echo Cart66Common::getView('admin/settings/main.php', $data, false);
 }
 public function emailOptOut()
 {
     if (isset($_GET['cart66-task']) && $_GET['cart66-task'] == 'opt_out') {
         if (isset($_GET['e']) && isset($_GET['t'])) {
             $email = base64_decode(urldecode($_GET['e']));
             $verify = Cart66ProCommon::verifyEmailToken($_GET['t'], $email);
             if ($verify == 1) {
                 $data = array('form' => 'form', 'email' => $email, 'token' => $_GET['t']);
                 echo Cart66Common::getView('pro/views/unsubscribe.php', $data);
             } else {
                 if ($verify == -1) {
                     $message = __('This email has already been unsubscribed', 'cart66');
                 }
                 if ($verify == -2) {
                     $message = __('This email does not exist in our system', 'cart66');
                 }
                 $data = array('form' => 'error', 'message' => $message);
                 echo Cart66Common::getView('pro/views/unsubscribe.php', $data);
             }
         }
     } elseif (isset($_GET['cart66-action']) && $_GET['cart66-action'] == 'opt_out') {
         Cart66ProCommon::unsubscribeEmailToken($_POST['token'], $_POST['email']);
         $data = array('form' => 'opt_out', 'email' => $_POST['email']);
         echo Cart66Common::getView('pro/views/unsubscribe.php', $data);
     } elseif (isset($_GET['cart66-action']) && $_GET['cart66-action'] == 'cancel_opt_out') {
         $data = array('form' => 'cancel');
         echo Cart66Common::getView('pro/views/unsubscribe.php', $data);
     }
 }
Exemplo n.º 3
0
 public function generateUnsubscribeLink($accountId)
 {
     $url = false;
     if ($unsubscribeLink = get_page_by_path('store/unsubscribe')) {
         $account = new Cart66Account();
         $account->load($accountId);
         $url = get_permalink($unsubscribeLink->ID) . '?cart66-task=opt_out&e=' . urlencode(base64_encode($account->email)) . '&t=' . Cart66ProCommon::generateEmailToken($account->id);
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] {$url}");
     }
     return $url;
 }
 public static function saveSettings()
 {
     $error = '';
     foreach ($_REQUEST as $key => $value) {
         if ($key[0] != '_' && $key != 'action' && $key != 'submit' && $key) {
             if (is_array($value) && $key != 'admin_page_roles') {
                 $value = array_filter($value, 'strlen');
                 if (empty($value)) {
                     $value = '';
                 } else {
                     $value = implode('~', $value);
                 }
             }
             if ($key == 'status_options') {
                 $value = str_replace('&', '', Cart66Common::deepTagClean($value));
             }
             if ($key == 'home_country') {
                 $hc = Cart66Setting::getValue('home_country');
                 if ($hc != $value) {
                     $method = new Cart66ShippingMethod();
                     $method->clearAllLiveRates();
                 }
             } elseif ($key == 'countries') {
                 if (strpos($value, '~') === false) {
                     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] country list value: {$value}");
                     $value = '';
                 }
                 if (empty($value) && !empty($_REQUEST['international_sales'])) {
                     $error = "Please select at least one country to ship to.";
                 }
             } elseif ($key == 'enable_logging' && $value == '1') {
                 try {
                     Cart66Log::createLogFile();
                 } catch (Cart66Exception $e) {
                     $error = '<span>' . $e->getMessage() . '</span>';
                     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Caught Cart66 exception: " . $e->getMessage());
                 }
             } elseif ($key == 'constantcontact_list_ids') {
             } elseif ($key == 'admin_page_roles') {
                 $value = serialize($value);
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Saving Admin Page Roles: " . print_r($value, true));
             } elseif ($key == 'currency_decimals' && $value == 0) {
                 $value = 'no_decimal';
             }
             Cart66Setting::setValue($key, trim(stripslashes($value)));
             if (CART66_PRO && $key == 'order_number') {
                 $versionInfo = get_transient('_cart66_version_request');
                 if (!$versionInfo) {
                     $versionInfo = Cart66ProCommon::getVersionInfo();
                     set_transient('_cart66_version_request', $versionInfo, 43200);
                 }
                 if (!$versionInfo) {
                     Cart66Setting::setValue('order_number', '');
                     $error = '<span>' . __('Invalid Order Number', 'cart66') . '</span>';
                 }
             }
         }
     }
     if ($error) {
         $result[0] = 'Cart66Modal alert-message alert-error';
         $result[1] = "<strong>" . __("Warning", "cart66") . "</strong><br/>{$error}";
     } else {
         $result[0] = 'Cart66Modal alert-message success';
         $result[1] = '<strong>Success</strong><br/>' . $_REQUEST['_success'] . '<br>';
     }
     $out = json_encode($result);
     echo $out;
     die;
 }
Exemplo n.º 5
0
 $setting = new Cart66Setting();
 $home = Cart66Setting::getValue('home_country');
 if ($home) {
     list($homeCountryCode, $name) = explode('~', $home);
 }
 $services = Cart66ProCommon::getCaPostServices();
 $methods = $method->getServicesForCarrier('capost');
 foreach ($services as $name => $code) {
     $checked = '';
     if (in_array($code, $methods)) {
         $checked = 'checked="checked"';
     }
     echo '<label class="med">&nbsp;</label>';
     echo "<input type='checkbox' class='capost_shipping_options' name='capost_methods[]' value='{$code}~{$name}' {$checked}> {$name}<br/>";
 }
 $services = Cart66ProCommon::getCaPostIntlServices();
 $methods = $method->getServicesForCarrier('capost_intl');
 foreach ($services as $name => $code) {
     $checked = '';
     if (in_array($code, $methods)) {
         $checked = 'checked="checked"';
     }
     echo '<label class="med">&nbsp;</label>';
     echo "<input type='checkbox' class='capost_shipping_options' name='capost_methods_intl[]' value='{$code}~{$name}' {$checked}> {$name}<br/>";
 }
 ?>
         </li>
         <li>
           <label class="med">&nbsp;</label>
           <input type='submit' name='submit' class="button-primary" style='width: 60px; margin-top: 10px;' value='<?php 
 _e('Save', 'cart66');
Exemplo n.º 6
0
 public function init()
 {
     global $cart66Settings, $cart66Objects;
     $this->loadCoreModels();
     $this->initCurrencySymbols();
     $this->setDefaultPageRoles();
     // Allow override for sending email receipts
     define("CART66_EMAILS", apply_filters('cart66_send_default_emails', true));
     // Verify that upgrade has been run
     if (IS_ADMIN) {
         $dbVersion = Cart66Setting::getValue('version');
         if (version_compare(CART66_VERSION_NUMBER, $dbVersion)) {
             $this->install();
         }
     }
     // Define debugging and testing info
     $cart66Logging = Cart66Setting::getValue('enable_logging') ? true : false;
     $sandbox = Cart66Setting::getValue('paypal_sandbox') ? true : false;
     define("CART66_DEBUG", $cart66Logging);
     define("SANDBOX", $sandbox);
     // Handle dynamic JS requests
     // See: http://ottopress.com/2010/dont-include-wp-load-please/ for why
     add_filter('query_vars', array($this, 'addAjaxTrigger'));
     add_action('template_redirect', array($this, 'ajaxTriggerCheck'));
     // Scheduled events
     if (CART66_PRO) {
         add_action('daily_subscription_reminder_emails', array('Cart66MembershipReminders', 'dailySubscriptionEmailReminderCheck'));
         add_action('daily_followup_emails', array('Cart66AdvancedNotifications', 'dailyFollowupEmailCheck'));
         add_action('daily_gravity_forms_entry_removal', array('Cart66GravityReader', 'dailyGravityFormsOrphanedEntryRemoval'));
         $order = new Cart66Order();
         add_action('daily_prune_pending_orders', array($order, 'dailyPrunePendingPayPalOrders'));
     }
     // Notification shortcodes
     $sc = new Cart66ShortcodeManager();
     add_shortcode('email_shortcodes', array($sc, 'emailShortcodes'));
     // add Cart66 to the admin bar
     if (Cart66Common::cart66UserCan('orders')) {
         add_action('admin_bar_menu', array($this, 'cart66_admin_bar_menu'), 35);
     }
     if (IS_ADMIN) {
         if (Cart66Setting::getValue('capost_merchant_id')) {
             add_action('admin_notices', array($this, 'cart66_canada_post_upgrade'));
         }
         //add_action( 'admin_notices', 'cart66_data_collection' );
         add_action('admin_head', array($this, 'registerBasicScripts'));
         add_action('admin_enqueue_scripts', array($this, 'registerAdminScripts'));
         add_action('admin_init', array($this, 'registerCustomScripts'));
         add_action('admin_print_styles', array($this, 'registerAdminStyles'));
         add_action('admin_menu', array($this, 'buildAdminMenu'));
         // we dont use this button anymore
         //add_action('admin_init', array($this, 'addEditorButtons'));
         add_action('admin_init', array($this, 'forceDownload'));
         add_action('wp_ajax_save_settings', array('Cart66Ajax', 'saveSettings'));
         add_action('wp_ajax_force_plugin_update', array('Cart66Ajax', 'forcePluginUpdate'));
         add_action('wp_ajax_promotionProductSearch', array('Cart66Ajax', 'promotionProductSearch'));
         add_action('wp_ajax_loadPromotionProducts', array('Cart66Ajax', 'loadPromotionProducts'));
         add_action('wp_ajax_send_test_email', array('Cart66Ajax', 'sendTestEmail'));
         add_action('wp_ajax_resend_email_from_log', array('Cart66Ajax', 'resendEmailFromLog'));
         add_action('wp_ajax_promotions_table', array('Cart66DataTables', 'promotionsTable'));
         add_action('wp_ajax_products_table', array('Cart66DataTables', 'productsTable'));
         add_action('wp_ajax_orders_table', array('Cart66DataTables', 'ordersTable'));
         add_action('wp_ajax_print_view', array('Cart66Ajax', 'ajaxReceipt'));
         add_action('wp_ajax_view_email', array('Cart66Ajax', 'viewLoggedEmail'));
         add_action('wp_ajax_dashboard_products_table', array('Cart66DataTables', 'dashboardProductsTable'));
         add_action('wp_ajax_shortcode_products_table', array('Cart66Ajax', 'shortcodeProductsTable'));
         add_action('wp_ajax_page_slurp', array('Cart66Ajax', 'pageSlurp'));
         add_action('wp_ajax_dismiss_mijireh_notice', array('Cart66Ajax', 'dismissMijirehNotice'));
         add_action('wp_ajax_cart66_page_check', array('Cart66Ajax', 'checkPages'));
         if (CART66_PRO) {
             add_action('wp_ajax_spreedly_table', array('Cart66DataTables', 'spreedlyTable'));
             add_action('wp_ajax_paypal_subscriptions_table', array('Cart66DataTables', 'paypalSubscriptionsTable'));
             add_action('wp_ajax_accounts_table', array('Cart66DataTables', 'accountsTable'));
             add_action('wp_ajax_inventory_table', array('Cart66DataTables', 'inventoryTable'));
         }
         // Load Dialog Box in editor
         add_action('media_buttons', array('Cart66Dialog', 'cart66_dialog_box'), 11);
         add_action('admin_footer', array('Cart66Dialog', 'add_shortcode_popup'));
         // Load Page Slurp Button on checkout page
         add_action('add_meta_boxes', array($this, 'addPageSlurpButtonMeta'));
         add_action('media_buttons', array($this, 'addPageSlurpButton'), 12);
         // Load Dashboard Widget
         add_action('wp_dashboard_setup', array('Cart66Dashboard', 'cart66_add_dashboard_widgets'));
         if (CART66_PRO) {
             add_action('wp_ajax_update_gravity_product_quantity_field', array('Cart66Ajax', 'updateGravityProductQuantityField'));
         }
         if (class_exists('SpreedlySubscription') || true) {
             add_action('save_post', array($this, 'saveFeatureLevelMetaBoxData'));
             add_action('add_meta_boxes', array($this, 'addFeatureLevelMetaBox'));
         }
         //Plugin update actions
         if (CART66_PRO) {
             add_action('update_option__transient_update_plugins', array('Cart66ProCommon', 'checkUpdate'));
             //used by WP 2.8
             add_filter('pre_set_site_transient_update_plugins', array('Cart66ProCommon', 'getUpdatePluginsOption'));
             //used by WP 3.0
             add_action('install_plugins_pre_plugin-information', array('Cart66ProCommon', 'showChangelog'));
         }
         add_action('save_post', array($this, 'check_cart66_pages_on_inline_edit'));
         add_action('admin_notices', array($this, 'cart66_page_check'));
     } else {
         $this->initShortcodes();
         $this->initCart();
         $this->checkIPN();
         $order = new Cart66Order();
         add_action('wp_enqueue_scripts', array('Cart66', 'enqueueScripts'));
         if (CART66_PRO) {
             add_action('template_redirect', array($this, 'checkInventoryOnCheckout'), 0);
             add_action('template_redirect', array($this, 'checkShippingMethodOnCheckout'), 0);
             add_action('template_redirect', array($this, 'checkZipOnCheckout'), 0);
             add_action('template_redirect', array($this, 'checkTermsOnCheckout'), 0);
             add_action('template_redirect', array($this, 'checkMinAmountOnCheckout'), 0);
             add_action('template_redirect', array($this, 'checkCustomFieldsOnCheckout'), 0);
             add_action('template_redirect', array($this, 'protectSubscriptionPages'), 0);
             add_filter('wp_list_pages_excludes', array($this, 'hideStorePages'));
             add_filter('wp_list_pages_excludes', array($this, 'hidePrivatePages'));
             add_filter('wp_nav_menu_objects', array($this, 'filter_private_menu_items'), 10, 2);
         }
         add_action('wp_head', array('Cart66Common', 'displayVersionInfo'));
         add_action('template_redirect', array($this, 'dontCacheMeBro'));
         add_action('shutdown', array('Cart66Session', 'touch'));
         add_action('wp_footer', array($order, 'updateViewed'));
         if (!Cart66Setting::getValue('use_other_analytics_plugin')) {
             add_action('wp_footer', array($order, 'addTrackingCode'));
         }
     }
     // ================================================================
     // = Intercept query string cart66 tasks                          =
     // ================================================================
     // Logout the logged in user
     $isLoggedIn = Cart66Common::isLoggedIn();
     if (isset($_REQUEST['cart66-task']) && $_REQUEST['cart66-task'] == 'logout' && $isLoggedIn) {
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Intercepting Cart66 Logout task");
         $url = Cart66ProCommon::getLogoutUrl();
         Cart66Account::logout($url);
     }
     if ($_SERVER['REQUEST_METHOD'] == 'GET' && Cart66Common::getVal('task') == 'member_download') {
         if (Cart66Common::isLoggedIn()) {
             $path = str_replace(array('../', './'), '', $_GET['path']);
             // don't allow folder traversing
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Attempting a member download file request: {$path}");
             Cart66Common::downloadFile($path);
         }
     } elseif ($_SERVER['REQUEST_METHOD'] == 'GET' && Cart66Common::getVal('task') == 'add-to-cart-anchor') {
         $options = null;
         if (isset($_GET['options'])) {
             $options = Cart66Common::getVal('options');
         }
         $productUrl = null;
         if (isset($_GET['product_url'])) {
             $productUrl = $_GET['product_url'];
         }
         Cart66Session::get('Cart66Cart')->addItem(Cart66Common::getVal('cart66ItemId'), 1, $options, null, $productUrl);
         $promotion_var_name = Cart66Setting::getValue('promotion_get_varname') ? Cart66Setting::getValue('promotion_get_varname') : 'promotion';
         if (isset($_GET[$promotion_var_name])) {
             Cart66Session::get('Cart66Cart')->applyPromotion(strtoupper($_GET[$promotion_var_name]), true);
         }
         wp_redirect(remove_query_arg(array('cart66ItemId', 'product_url', 'task', $promotion_var_name), Cart66Common::getCurrentPageUrl()));
         exit;
     } elseif ($_SERVER['REQUEST_METHOD'] == 'GET' && Cart66Common::getVal('task') == 'mijireh_notification') {
         require_once CART66_PATH . "/gateways/Cart66Mijireh.php";
         $order_number = Cart66Common::getVal('order_number');
         $mijireh = new Cart66Mijireh();
         $mijireh->saveMijirehOrder($order_number);
     } elseif (isset($_GET['task']) && Cart66Common::getVal('task') == 'mijireh_page_slurp') {
         $access_key = Cart66Setting::getValue('mijireh_access_key');
         if (isset($_POST['access_key']) && isset($_POST['page_id']) && $_POST['access_key'] == $access_key) {
             wp_update_post(array('ID' => $_POST['page_id'], 'post_status' => 'private'));
         }
     } else {
         $promotion_var_name = Cart66Setting::getValue('promotion_get_varname') ? Cart66Setting::getValue('promotion_get_varname') : 'promotion';
         if ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET[$promotion_var_name])) {
             Cart66Session::get('Cart66Cart')->applyPromotion(strtoupper($_GET[$promotion_var_name]), true);
         }
     }
 }
Exemplo n.º 7
0
    public static function cart66_upgrade_message()
    {
        $updater = new Cart66ProCommon();
        $newVersion = get_transient('_cart66_version_request');
        if (!$newVersion) {
            $newVersion = $updater->getVersionInfo();
            set_transient('_cart66_version_request', $newVersion, 43200);
        }
        $currentVersion = Cart66Setting::getValue('version');
        $cart66_plugin_url = "cart66/cart66.php";
        $cart66_upgrade_url = wp_nonce_url('update.php?action=upgrade-plugin&amp;plugin=' . urlencode($cart66_plugin_url), 'upgrade-plugin_' . $cart66_plugin_url);
        ?>
      <div class='alert-message mijireh-info' id='cart66_upgrade_message' style="display:none;">
        <a href="javascript:void(0);" class="close" onclick="dismissMessage();">&times;</a>
        <img src="<?php 
        echo CART66_URL;
        ?>
/images/cart66_upgrade.png" height="30" />
        <p>
          <strong><?php 
        _e('There is a new version of Cart66 available', 'cart66');
        ?>
!</strong> 
          <?php 
        _e('You are currently running Cart66', 'cart66');
        ?>
 
          <?php 
        echo $currentVersion;
        ?>
<br />
          <strong><?php 
        _e('The latest version of Cart66 is', 'cart66');
        ?>
 <?php 
        echo $newVersion['version'];
        ?>
.</strong>
          &nbsp;<a href="plugin-install.php?tab=plugin-information&plugin=cart66&TB_iframe=true&width=640&height=810" class="thickbox" title="Cart66"><?php 
        _e('View Details', 'cart66');
        ?>
</a> 
          <?php 
        _e('or', 'cart66');
        ?>
 
          <a href="<?php 
        echo $cart66_upgrade_url;
        ?>
"><?php 
        _e('Upgrade Automatically', 'cart66');
        ?>
</a>
        </p>
      </div>
    <?php 
    }