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);
 }
Пример #2
0
 public static function getUpdatePluginsOption($option)
 {
     $pluginName = "cart66/cart66.php";
     $versionInfo = get_transient('_cart66_version_request');
     if (!$versionInfo) {
         $versionInfo = Cart66ProCommon::getVersionInfo();
         set_transient('_cart66_version_request', $versionInfo, 43200);
     }
     if (is_array($versionInfo)) {
         $cart66Option = isset($option->response[$pluginName]) ? $option->response[$pluginName] : '';
         if (empty($cart66Option)) {
             $option->response[$pluginName] = new stdClass();
         }
         $setting = new Cart66Setting();
         $orderNumber = Cart66Setting::getValue('order_number');
         $currentVersion = Cart66Setting::getValue('version');
         if (version_compare($currentVersion, $versionInfo['version'], '<')) {
             $newVersion = $versionInfo['version'];
             Cart66Common::log("New Version Available: {$currentVersion} < {$newVersion}");
             $option->response[$pluginName]->url = "http://www.cart66.com";
             $option->response[$pluginName]->slug = "cart66";
             $option->response[$pluginName]->package = str_replace("{KEY}", $orderNumber, $versionInfo["url"]);
             $option->response[$pluginName]->new_version = $versionInfo["version"];
             $option->response[$pluginName]->id = "0";
         } else {
             unset($option->response[$pluginName]);
         }
     }
     return $option;
 }
Пример #3
0
 public function install()
 {
     global $wpdb;
     $prefix = Cart66Common::getTablePrefix();
     $sqlFile = CART66_PATH . '/sql/database.sql';
     $sql = str_replace('[prefix]', $prefix, file_get_contents($sqlFile));
     $queries = explode(";\n", $sql);
     $wpdb->hide_errors();
     foreach ($queries as $sql) {
         if (strlen($sql) > 5) {
             $wpdb->query($sql);
             Cart66Common::log("Running: {$sql}");
         }
     }
     require_once CART66_PATH . "/create-pages.php";
     // Set the version number for this version of Cart66
     require_once CART66_PATH . "/models/Cart66Setting.php";
     Cart66Setting::setValue('version', CART66_VERSION_NUMBER);
     // Look for hard coded order number
     if (CART66_PRO && CART66_ORDER_NUMBER !== false) {
         Cart66Setting::setValue('order_number', CART66_ORDER_NUMBER);
         $versionInfo = get_transient('_cart66_version_request');
         if (!$versionInfo) {
             $versionInfo = Cart66ProCommon::getVersionInfo();
             set_transient('_cart66_version_request', $versionInfo, 43200);
         }
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Trying to register order number: " . CART66_ORDER_NUMBER . print_r($versionInfo, true));
         if (!$versionInfo) {
             Cart66Setting::setValue('order_number', '');
         }
     }
     $this->upgradeDatabase();
 }
 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;
 }
Пример #5
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 
    }