public function listProducts($limit = 9999, $category = false)
 {
     try {
         $output = array();
         $stream = new Pos_RemoteConnector(self::request('/products.js'));
         if (!$stream->getErrorMessage()) {
             $products = json_decode($stream);
             if ($category) {
                 foreach ($products as $product) {
                     foreach ($product->categories as $product_category) {
                         if ($product_category->permalink == $category) {
                             $output[] = $product;
                         }
                     }
                 }
             } else {
                 $output = $products;
             }
             return $output;
         }
     } catch (Exception $e) {
         // log $e
     }
 }
Example #2
0
 function getCDNsets()
 {
     if ($this->_options['cdn-key'] == '') {
     } else {
         if (strlen($this->_options['cdn-key']) != 40) {
             echo "<div class='errors'>It looks like you have put in an incorrect CDN API key.</div>";
         } else {
             $result = get_transient('cdnsets');
             if ($this->_options['cdn']['status_txt'] == 'FAIL' || $result === false) {
                 require_once 'RemoteConnector.php';
                 $url = "http://api.share-and-follow.com/v1/getSets2.php?url=" . trailingslashit(get_bloginfo('url')) . "&challange=" . md5(trailingslashit(get_bloginfo('url')) . $this->_options['cdn-key']);
                 $control = new Pos_RemoteConnector($url);
                 $result = $control->__toString();
                 if ($result != false) {
                     set_transient('cdnsets', $result, 60 * 60);
                 }
             }
             if ($result === false) {
                 echo $control->getErrorMessage();
             } else {
                 $replies = json_decode($result, true);
                 if ($replies['status_txt'] == 'FAIL') {
                     $this->_options['cdn']['status_txt'] = 'FAIL';
                     $this->update_plugin_options();
                     return "<div class='errors'>The following error has happened : " . $replies['data'] . "</div>";
                 } else {
                     $this->_options['cdn'] = json_decode($result, true);
                     // jason format
                     $this->update_plugin_options();
                 }
             }
         }
     }
 }
Example #3
0
 if (!empty($_POST['cdn-key']) && $_POST['cdn-key'] != $c->_options['cdn-key']) {
     delete_transient('cdnsets');
     $c->_options['cdn-key'] = $_POST['cdn-key'];
 }
 if ($c->_options['cdn-key'] == '') {
     delete_transient('cdnsets');
 } else {
     if (strlen($c->_options['cdn-key']) != 40) {
         echo "<div class='error'><p>It looks like you have put in an incorrect CDN API key. Check if you have put extra spaces in it</p></div>";
         delete_transient('cdnsets');
     } else {
         $result = get_transient('cdnsets');
         if ($this->_options['cdn']['status_txt'] == 'FAIL' || $result === false) {
             require_once 'RemoteConnector.php';
             $url = "http://api.share-and-follow.com/v1/getSets2.php?url=" . trailingslashit(get_bloginfo('url')) . "&challange=" . md5(trailingslashit(get_bloginfo('url')) . $this->_options['cdn-key']);
             $control = new Pos_RemoteConnector($url);
             $result = $control->__toString();
             if ($result != false) {
                 set_transient('cdnsets', $result, 60 * 60 * 24);
             }
         }
         $replies = json_decode($result, true);
         if ($replies['status_txt'] == 'FAIL') {
             $c->_options['cdn']['status_txt'] = 'FAIL';
             $c->update_plugin_options();
             echo "<div class='error'>The following error has happened : " . $replies['data'] . "</div>";
         } else {
             $c->_options['cdn'] = json_decode($result, true);
             // jason format
             $c->_options['cdn']['status_txt'] = 'OK';
             $c->update_plugin_options();