コード例 #1
0
ファイル: share-and-follow.php プロジェクト: kivivuori/jotain
 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();
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: admin-page.php プロジェクト: kivivuori/jotain
     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();
         }