⚡ NEW: Changeset/ - Full Gallery 2025

Changeset 1804149


Ignore:
Timestamp:
01/17/2018 01:26:43 AM (8 years ago)
Author:
davejesch
Message:
  • fix: allow for custom post status values (Thanks Alex V.)
  • fix: removed deprecated warnings for function calls (Thanks Peter M.)
  • fix: resolve undefined index warnings on empty configs (Thanks Peter M.)
  • fix: fix to usage of fallback encryption method (Thanks Mika A.)
  • fix: fix spelling error and array index error
  • fix: runtime error that can occasionally occur while processing taxonomies
  • fix: runtime error that can occur on first edit of settings
  • fix: minor security update- remove bad password message that could imply valid account name
  • fix: remove deprecation messages for mcrypt functions
  • enhancement: add checks for SSL specific error conditions
  • enhancement: add "more info" links to all error messages shown in UI
  • enhancement: updates to licensing code
  • enhancement: check serverpress.com domain for licensing data
  • enhancement: add get_param method to javascript code
  • enhancement: make SyncApiResponse instance available from Controller; needed by Divi add-on
  • enhancement: check data object used in API calls and return early if contains error
Location:
wpsitesynccontent
Files:
48 added
14 edited

Legend:

Unmodified
Added
Removed
  • wpsitesynccontent/trunk/assets/js/sync.js

    r1745585 r1804149  
    4343    this.original_value = this.$content.val();
    4444    this.$content.on('keypress change', function() { _self.on_content_change(); });
     45};
     46
     47/**
     48 * Return the value of a GET parameter from the URL
     49 * @param {string} name Name of parameter to get
     50 * @returns {String} The value of the parameter if found, otherwise null.
     51 */
     52WPSiteSyncContent.prototype.get_param = function(name)
     53{
     54    var url = window.location.href;
     55    name = name.replace(/[\[\]]/g, "\\$&");
     56    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
     57        results = regex.exec(url);
     58    if (!results)
     59        return null;
     60    if (!results[2])
     61        return '';
     62    return decodeURIComponent(results[2].replace(/\+/g, ' '));
    4563};
    4664
     
    194212    }
    195213
     214//console.log('api() performing ajax request');
    196215    this.push_xhr = {
    197216        type: 'post',
     
    200219        url: ajaxurl,
    201220        success: function(response) {
    202 //console.log('push() success response:');
     221//console.log('api() success response:');
    203222//console.log(response);
    204223            wpsitesynccontent.clear_message();
     
    212231                }
    213232            } else {
    214                 if ('undefined' !== typeof(response.data.message))
    215 //                  jQuery('#sync-message').text(response.data.message);
    216                     wpsitesynccontent.set_message(response.data.message, false, true);
     233                var more = ' <a href="https://wpsitesync.com/knowledgebase/wpsitesync-error-messages/#error' + response.error_code + '" target="_blank" style="text-decoration:none"><span class="dashicons dashicons-info"></span></a>';
     234//console.log(response.data);
     235                if ('undefined' !== typeof(response.error_message) && null !== response.error_message) {
     236//console.log('found error message in response');
     237//                  jQuery('#sync-message').text(response.error_message);
     238                    wpsitesynccontent.set_message(response.error_message + more, false, true);
     239                } else {
     240//console.log('no error message in response, use default');
     241                    wpsitesynccontent.set_message(jQuery('#sync-error-msg').text() + more, false, true);
     242                }
    217243            }
    218244        },
    219245        error: function(response) {
    220 //console.log('push() failure response:');
     246//console.log('api() failure response:');
    221247//console.log(response);
    222248            var msg = '';
    223             if ('undefined' !== typeof(response.error_message))
    224                 wpsitesynccontent.set_message('<span class="error">' + response.error_message + '</span>', false, true);
    225             else
     249            if ('undefined' !== typeof(response.error_message)) {
     250                var more = ' <a href="https://wpsitesync.com/knowledgebase/wpsitesync-error-messages/#error' + response.error_code + '" target="_blank" style="text-decoration:none"><span class="dashicons dashicons-info"></span></a>';
     251                wpsitesynccontent.set_message('<span class="error">' + response.error_message + more + '</span>', false, true);
     252            } else
    226253                wpsitesynccontent.set_message('<span class="error">' + jQuery('#sync-runtime-err-msg').html() + '</span>', false, true)
    227254//          jQuery('#sync-content-anim').hide();
     
    231258    // Allow other plugins to alter the ajax request
    232259    jQuery(document).trigger('sync_api_call', [op, this.push_xhr]);
    233 //console.log('push() calling jQuery.ajax');
     260//console.log('api() calling jQuery.ajax');
    234261    jQuery.ajax(this.push_xhr);
    235 //console.log('push() returned from ajax call');
     262//console.log('api() returned from ajax call');
    236263};
    237264
     
    242269WPSiteSyncContent.prototype.push = function(post_id)
    243270{
     271    // TODO: refactor to use api() method
    244272//console.log('push()');
    245273    // Do nothing when in a disabled state
     
    281309            } else {
    282310//console.log('push() !response.success');
    283                 if ('undefined' !== typeof(response.data.message))
     311                var more = ' <a href="https://wpsitesync.com/knowledgebase/wpsitesync-error-messages/#error' + response.error_code + '" target="_blank" style="text-decoration:none"><span class="dashicons dashicons-info"></span></a>';
     312                if ('undefined' !== typeof(response.data.message)) {
    284313//                  jQuery('#sync-message').text(response.data.message);
    285                     wpsitesynccontent.set_message(response.data.message, false, true, 'sync-error');
     314                    wpsitesynccontent.set_message(response.data.message + more, false, true, 'sync-error');
     315                } else {
     316                    wpsitesynccontent.set_message(jQuery('#sync-error-msg').text() + more, false, true);
     317                }
    286318            }
    287319        },
  • wpsitesynccontent/trunk/classes/admin.php

    r1745585 r1804149  
    189189                echo '<div id="sync-pull-msg"><div style="color: #0085ba;">', __('Please activate the Pull extension.', 'wpsitesynccontent'), '</div></div>';
    190190        echo '<div id="sync-runtime-err-msg">', __('A PHP runtime error occured while processing your request. Examine Target log files for more information.', 'wpsitesynccontent'), '</div>';
     191        echo '<div id="sync-error-msg">', __('Error: error encountered during request.', 'wpsitesynccontent'), '</div>';
    191192        echo '</div>';
    192193
     
    207208    public function plugin_action_links($actions)
    208209    {
    209         $actions[] = sprintf('<a href="%1$s">%2$s</a>', admin_url('options-general.php?page=sync' ), __('Settings', 'wpsitesynccontent'));
     210        $actions[] = sprintf('<a href="%1$s">%2$s</a>', admin_url('options-general.php?page=sync'), __('Settings', 'wpsitesynccontent'));
    210211        return $actions;
    211212    }
  • wpsitesynccontent/trunk/classes/apicontroller.php

    r1745585 r1804149  
    1919    private $_user = NULL;                          // authenticated user making request
    2020    private $_auth = 1;                             // perform authentication checks
     21    private $_response = NULL;                      // reference to SyncApiResponse instance that Controller uses for API responses
    2122
    2223    public $source = NULL;                          // the URL of the Source site for the request
     
    4950        else
    5051            $response = new SyncApiResponse(TRUE);
     52        $this->_response = $response;
    5153
    5254        if (isset($args['site_key']))
     
    173175
    174176    /**
     177     * Get the SyncApiResponse object being used by the Controller
     178     * @return SyncApiResponse The response object used for the current API call.
     179     */
     180    public function get_api_response()
     181    {
     182        return $this->_response;
     183    }
     184
     185    /**
    175186     * Returns the specified Apache request header
    176187     * @param string $name The name of the request header to retrieve
     
    250261
    251262        $post_data = $this->post_raw('post_data', array());
    252 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' - post_data=' . var_export($post_data, TRUE));
     263SyncDebug::log(__METHOD__.'():' . __LINE__ . ' - post_data=' . var_export($post_data, TRUE));
    253264
    254265        $this->source_post_id = abs($post_data['ID']);
    255266//      if (0 === $this->source_post_id && isset($post_data['post_id']))
    256267//          $this->source_post_id = abs($post_data['post_id']);
    257 SyncDebug::log('- syncing post data Source ID#'. $this->source_post_id . ' - "' . $post_data['post_title'] . '"');
     268SyncDebug::log(__METHOD__.'():' . __LINE__ . ' syncing post data Source ID#'. $this->source_post_id . ' - "' . $post_data['post_title'] . '"');
    258269
    259270        // Check if a post_id was specified, indicating an update to a previously synced post
     
    307318        // do not allow the push if it's not a recognized post type
    308319        if (!in_array($post_data['post_type']/*$post->post_type*/, apply_filters('spectrom_sync_allowed_post_types', array('post', 'page')))) {
    309 SyncDebug::log(' - checking post type: ' . $post_data['post_type']/*$post->post_type*/);
     320SyncDebug::log(__METHOD__.'():' . __LINE__ . ' checking post type: ' . $post_data['post_type']/*$post->post_type*/);
    310321            $response->error_code(SyncApiRequest::ERROR_INVALID_POST_TYPE);
    311322            return;
     
    943954                if (!is_wp_error($child_terms)) {
    944955                    // loop through the children until we find one that matches
    945                     foreach ($child_terms as $term_id) {
    946                         $term_child = get_term_by('id', $term_id, $tax_type);
     956                    foreach ($child_terms as $child_term_id) {
     957                        $term_child = get_term_by('id', $child_term_id, $tax_type);
    947958SyncDebug::log(__METHOD__ . '() term child: ' . $term_child->slug);
    948959                        if ($term_child->slug === $tax_term['slug']) {
     
    977988SyncDebug::log(__METHOD__ . '() found term: ' . var_export($term, TRUE));
    978989                if (isset($term->term_id)) {
    979                     $term_id = $term->term_id;
     990                    $term_id = abs($term->term_id);
    980991                    $parent = $term_id;                            // indicate parent for next loop iteration
    981992                } else {
  • wpsitesynccontent/trunk/classes/apirequest.php

    r1745585 r1804149  
    3535    const ERROR_UPLOAD_NO_CONTENT = 28;
    3636    const ERROR_PHP_ERROR_ON_TARGET = 29;
     37    const ERROR_SSL_PROTOCOL_ERROR = 30;
    3738
    3839    const NOTICE_FILE_EXISTS = 1;
     
    9596                return $response;
    9697            }
     98//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' current auth data: ' . var_export($data, TRUE));
    9799        }
    98100
     
    106108SyncDebug::log(__METHOD__.'():' . __LINE__ . ' calling _push()');
    107109            $data = $this->_push($data);
     110            // check return value to ensure Content was found #146
     111            if (NULL === $data)
     112                $response->error_code(self::ERROR_POST_CONTENT_NOT_FOUND);
    108113            break;
    109114        case 'upload_media':
     
    123128
    124129        // check value returned from API call
    125         if (is_wp_error($data) || $response->has_errors()) {
     130###     if (is_wp_error($data) || $response->has_errors()) {
     131###         // an error occured somewhere along the way. report it and return
     132###//           $response->error_code(abs($res->get_message()));
     133###         return $response;
     134###     }
     135        // check for filter returning a WP_Error instance
     136        if (is_wp_error($data)) {
     137            $response->error_code(abs($data->get_error_code()));
     138        }
     139        // check for any errors
     140        if ($response->has_errors()) {
    126141            // an error occured somewhere along the way. report it and return
    127 //          $response->error_code(abs($res->get_message()));
    128142            return $response;
    129143        }
     
    161175SyncDebug::log(__METHOD__.'():' . __LINE__ . ' error in wp_remote_post(): ' . var_export($request, TRUE));
    162176            // handle error
    163             $response->error_code(self::ERROR_REMOTE_REQUEST_FAILED, $request->get_error_message());
     177            if (isset($request->errors['http_request_failed']) && FALSE !== stripos($request->errors['http_request_failed'], 'Unknown SSL protocol error in connection'))
     178                $response->error_code(self::ERROR_SSL_PROTOCOL_ERROR, $request->get_error_message());
     179            else
     180                $response->error_code(self::ERROR_REMOTE_REQUEST_FAILED, $request->get_error_message());
    164181        } else {
    165182            $response->result = $request;
     
    370387    private function _get_auth_cookie()
    371388    {
    372 SyncDebug::log(__METHOD__.'() user id=' . $this->_user_id);
     389//SyncDebug::log(__METHOD__.'() user id=' . $this->_user_id);
    373390        $this->_auth_cookie = get_user_meta($this->_user_id, 'spectrom_site_cookies', TRUE);
    374391
     
    494511    private function _auth(&$data)
    495512    {
    496 //SyncDebug::log(__METHOD__.'() data: ' . var_export($data, TRUE));
     513//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' data: ' . var_export($data, TRUE));
    497514        // TODO: indicate error if target system not set up
    498515
    499516        // if no Target credentials provided, get them from the config
    500517        if (!isset($data['username']) /*|| !isset($data['password'])*/ || !isset($data['host'])) {
    501 //SyncDebug::log(__METHOD__.'() using credentials from config');
     518//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' using credentials from config');
    502519            $source_model = new SyncSourcesModel();
    503520            $opts = new SyncOptions();
     
    540557//          return new WP_Error(self::ERROR_MISSING_SITE_KEY);
    541558        }
    542 //SyncDebug::log(__METHOD__.'() target username: ' . $this->_target_data['username']);
    543 //SyncDebug::log(__METHOD__.'() target token: ' . (isset($this->_target_data['token']) ? $this->_target_data['token'] : ''));
    544 //SyncDebug::log(__METHOD__.'() data token: ' . (isset($data['token']) ? $data['token'] : ''));
    545 //SyncDebug::log(__METHOD__.'() data password: ' . $data['password']);
     559//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' target username: ' . $this->_target_data['username']);
     560//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' target token: ' . (isset($this->_target_data['token']) ? $this->_target_data['token'] : ''));
     561//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' data token: ' . (isset($data['token']) ? $data['token'] : ''));
     562//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' data password: ' . $data['password']);
    546563        if (empty($this->_target_data['username']) ||
    547564            (empty($this->_target_data['token']) && empty($data['token']) && empty($data['password']))) {
    548 //SyncDebug::log(__METHOD__.'() return ERROR_BAD_CREDENTIALS');
     565//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' return ERROR_BAD_CREDENTIALS');
    549566            return new WP_Error(self::ERROR_BAD_CREDENTIALS);
    550567        }
    551568
    552 //SyncDebug::log(' ' . __LINE__ . ' - adding authentication data to array');
     569//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' - adding authentication data to array');
    553570        // add authentication to the data array
    554571        $data['auth'] = array(
     
    559576        // if password provided (first time authentication) then encrypt it
    560577        if (!empty($data['password'])) {
    561 //SyncDebug::log(__METHOD__.'() encrypting password');
     578//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' encrypting password');
    562579            $auth = new SyncAuth();
    563580            $data['password'] = $auth->encode_password($data['password'], $data['host']);
    564581
     582//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' encoded: ' . $data['password']);
    565583            $parts = explode(':', $data['password']);
    566584            $this->_target_data['password'] = $data['password'] = $parts[0];
    567585            $this->_target_data['encode'] = $data['encode'] = $parts[1];
    568586        }
    569 //SyncDebug::log(__METHOD__.'() data: ' . var_export($data, TRUE));
     587//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' data: ' . var_export($data, TRUE));
    570588
    571589        return NULL;
     
    576594     * @param int $post_id The post ID for the Content to be Pushed
    577595     * @param array $data The data array to add Post Content information to
    578      * @return array The updated data array
     596     * @return array The updated data array or NULL if Content cannot be found
    579597     */
    580598    public function get_push_data($post_id, $data)
     
    585603        $post_data = $model->build_sync_data($post_id);
    586604//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' post data: ' . var_export($post_data, TRUE));
     605        if (0 === count($post_data))
     606            return NULL;
    587607
    588608        // Check if this is an update of a previously sync'd post
     
    597617        // TODO: swap this around. move the data from $post_data[] into $data[] instead of copy- then set $data['post_data']. This should reduce memory usage
    598618        // TODO: copy all entries in $post_data array- allows for better API feature/data expansion
    599         $data['post_data'] = $post_data['post_data'];
     619        if (isset($post_data['post_data']))
     620            $data['post_data'] = $post_data['post_data'];
    600621        if (isset($post_data['post_meta']))
    601622            $data['post_meta'] = $post_data['post_meta'];
     
    725746        $this->_sent_images = array();          // list of images already sent. Used by _send_image() to not send the same image twice
    726747
     748        // TODO: use PHP_URL_HOST parameter
    727749        $url = parse_url(get_bloginfo('url'));
    728750        $this->_source_domain = $url['host'];
     
    9801002        case self::ERROR_UPLOAD_NO_CONTENT:     $error = __('Attachment upload failed. No content found; is there a broken link?', 'wpsitesynccontent'); break;
    9811003        case self::ERROR_PHP_ERROR_ON_TARGET:   $error = __('A PHP error occurred on Target while processing your request. Examine log files for more information.', 'wpsitesynccontent'); break;
     1004        case self::ERROR_SSL_PROTOCOL_ERROR:    $error = __('Unknown SSL protocol error on Target. Check DNS settings on Target domain.', 'wpsitesynccontent'); break;
    9821005
    9831006        default:
  • wpsitesynccontent/trunk/classes/apiresponse.php

    r1745585 r1804149  
    7171    public function copy(SyncApiResponse $response)
    7272    {
     73        $this->success = $response->success;
    7374        $this->error_code = $response->error_code;
    7475        $this->error_data = $response->error_data;
     
    268269    {
    269270        $aOutput = array('error_code' => $this->error_code);
    270         if (0 !== $this->error_code)
    271             $aOutput['error_message'] = SyncApiRequest::error_code_to_string($this->error_code);
     271        if (0 !== $this->error_code) {
     272            $msg = SyncApiRequest::error_code_to_string($this->error_code);
     273            if (NULL === $msg)
     274                $msg = sprintf(__('Unrecognized error: %d', 'wpsitesynccontent'),
     275                    $this->error_code);
     276            $aOutput['error_message'] = $msg;
     277        }
    272278
    273279        if (NULL !== $this->error_data)
  • wpsitesynccontent/trunk/classes/auth.php

    r1745585 r1804149  
    88class SyncAuth extends SyncInput
    99{
    10     const HASHING_PASSWORD = TRUE;
     10    const HASHING_PASSWORD = TRUE;      // TODO: remove
    1111
    1212    // TODO: make this configurable between Source and Target sites so it's harder to break
    1313    private $salt = 'Cx}@d7M#Q:C;k0GHigDFh&w^ jwIsm@Vc$:oEL+q:(%.iKp?Q*5Axfc[d_f(2#>ZZ^??4g-B|Wd>Q4NyM^;G+R`}S`fnFG?~+cM9<?V9s}UzVzW-t:x]?5)f|~EJ-NLb';
     14
     15    // TODO: https://github.com/defuse/php-encryption
    1416
    1517    /**
     
    2426        $password = $this->post('password', NULL);
    2527        $token = $this->post('token', NULL);
    26 //SyncDebug::log(__METHOD__.'() user=' . $username . ' pass=' . $password . ' token=' . $token);
    27 //SyncDebug::log(__METHOD__.'() post= ' . var_export($_POST, TRUE));
     28//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' user=' . $username . ' pass=' . $password . ' token=' . $token);
     29//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' post= ' . var_export($_POST, TRUE));
    2830        $source_model = new SyncSourcesModel();
    2931        $api_controller = SyncApiController::get_instance();
     
    3436            $site_key = $api_controller->source_site_key;
    3537
    36 //SyncDebug::log(__METHOD__.'() authenticating via token');
     38//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' authenticating via token');
    3739//SyncDebug::log(' - source: ' . $source . ' site_key: ' . $site_key . ' user: ' . $username . ' token: ' . $token);
    3840            $user_signon = $source_model->check_auth($source, $site_key, $username, $token);
    39 //SyncDebug::log(__METHOD__.'() source->check_auth() returned ' . var_export($user_signon, TRUE));
     41//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' source->check_auth() returned ' . var_export($user_signon, TRUE));
    4042        } else {
    4143            $info['user_login'] = $username;
    42 //SyncDebug::log(' - target: ' . get_bloginfo('wpurl'));
     44//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' - target: ' . get_bloginfo('wpurl'));
    4345            if (self::HASHING_PASSWORD) {
    4446                $info['user_password'] = $this->decode_password($password, get_bloginfo('wpurl'));
     
    5153            $_SERVER['HTTP_REFERER'] = get_bloginfo('wpurl');
    5254
    53 //SyncDebug::log(__METHOD__.'() checking credentials: ' . var_export($info, TRUE));
     55//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' checking credentials: ' . var_export($info, TRUE));
    5456            // if no credentials provided, don't bother authenticating
    5557            if (empty($info['user_login']) || empty($info['user_password'])) {
    56 //SyncDebug::log(__METHOD__.'() missing credentials');
     58//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' missing credentials');
    5759                $resp->success(FALSE);
    5860                $resp->error_code(SyncApiRequest::ERROR_BAD_CREDENTIALS);
     
    6365        }
    6466
    65 //SyncDebug::log(__METHOD__.'() checking login status ' . var_export($user_signon, TRUE));
     67//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' checking login status ' . var_export($user_signon, TRUE));
    6668        if (is_wp_error($user_signon)) {
    67             $resp->success(FALSE);
    68 //SyncDebug::log(__METHOD__.'() failed login ' . var_export($user_signon, TRUE));
     69//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' failed login ' . var_export($user_signon, TRUE));
    6970            // return error message
    70             $resp->error_code(SyncApiRequest::ERROR_BAD_CREDENTIALS, $user_signon->get_error_message());
     71            $resp->error_code(SyncApiRequest::ERROR_BAD_CREDENTIALS, NULL);
    7172        } else {
    7273            // we have a valid user - check additional requirements
     
    7475            // check capabilities
    7576            if (!$user_signon->has_cap('edit_posts')) {
    76 SyncDebug::log(__METHOD__.'() does not have capability: edit_posts');
     77//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' does not have capability: edit_posts');
    7778                $resp->error_code(SyncApiRequest::ERROR_NO_PERMISSION);
    7879                return;
     
    144145        $left = $right = '';
    145146        if (function_exists('mcrypt_get_iv_size')) {
    146             $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
    147             $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
    148             $encrypted = mcrypt_encrypt(MCRYPT_BLOWFISH, $key, utf8_encode($password), MCRYPT_MODE_ECB, $iv);
     147            $iv_size = @mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
     148            $iv = @mcrypt_create_iv($iv_size, MCRYPT_RAND);
     149            $encrypted = @mcrypt_encrypt(MCRYPT_BLOWFISH, $key, utf8_encode($password), MCRYPT_MODE_ECB, $iv);
    149150            $left = base64_encode($encrypted);
    150151        }
     
    153154
    154155        $encoded = $left . ':' . $right;
     156//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' encoded=[' . $encoded . ']');
    155157        return $encoded;
    156158    }
     
    172174            $right = $_POST['encode'];
    173175
     176//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' left=[' . $left . '] right=[' . $right . '] pass=[' . $password . ']');
    174177        $cleartext = NULL;
    175         if (function_exists('mcrypt_get_iv_size')) {
     178        if (!empty($left) && function_exists('mcrypt_get_iv_size')) {
    176179            $decoded = base64_decode($left);
    177180//SyncDebug::log('  decoded: ' . $decoded);
    178181
    179             $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
    180             $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
    181             $cleartext = mcrypt_decrypt(MCRYPT_BLOWFISH, $key, $decoded, MCRYPT_MODE_ECB, $iv);
     182            $iv_size = @mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
     183            $iv = @mcrypt_create_iv($iv_size, MCRYPT_RAND);
     184            $cleartext = @mcrypt_decrypt(MCRYPT_BLOWFISH, $key, $decoded, MCRYPT_MODE_ECB, $iv);
    182185//SyncDebug::log('  cleartext: ' . var_export($cleartext, TRUE));
    183186            $cleartext = trim($cleartext, "\0");
    184 //SyncDebug::log(__METHOD__.'() decoded left "' . $left . '" into "' . $cleartext . '"');
     187//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' decoded left "' . $left . '" into "' . $cleartext . '"');
    185188        }
    186189        if (empty($cleartext) && !empty($right)) {
  • wpsitesynccontent/trunk/classes/licensesettings.php

    r1560226 r1804149  
    110110            echo '<button id="sync-license-deact-', $args['name'], '" type="button" class="button sync-license sync-license-deactivate" data="', $args['name'], '" ';
    111111            echo ' onclick="sync_settings.deactivate(this, \'', $args['name'] , '\'); return false;" >';
    112             _e('Dectivate', 'wpsitesynccontent');
     112            _e('Deactivate', 'wpsitesynccontent');
    113113            echo '</button>';
    114114
  • wpsitesynccontent/trunk/classes/licensing.php

    r1745585 r1804149  
    99    const OPTION_NAME = 'spectrom_sync_licensing';
    1010
    11     const LICENSE_API_URL = 'https://wpsitesync.com';
     11    const LICENSE_API_URL_PRIMARY = 'https://wpsitesync.com';
     12    const LICENSE_API_URL_SECONDARY = 'https://serverpress.com';
    1213    const LICENSE_TTL = 10800;                      # 28800 = 8hrs | 10800 = 3hrs
    1314
     
    1819    const STATE_ERROR = '9';
    1920
     21    const MODE_GET = 1;                                 // for wp_remote_get() calls
     22    const MODE_POST = 2;                                // for wp_remote_post() calls
     23
    2024    private static $_licenses = NULL;
    2125    private static $_status = array();
     
    2327    private static $_instance = NULL;
    2428
     29    private $_license_data = NULL;                      // results of license API calls
     30    private $_license_req = NULL;                       // results of wp_remote_() call
     31
     32    private static $_api_urls = array(                  // list of URLs to contact for licensing
     33        self::LICENSE_API_URL_PRIMARY,
     34        self::LICENSE_API_URL_SECONDARY,
     35    );
     36
    2537    public function __construct()
    2638    {
     
    3143
    3244    /**
     45     * Call the Licensing API using the two domains
     46     * @param string $endpoint The path data to attach to the domain
     47     * @param array|NULL $params Parameters to be used for API call
     48     * @param int $mode One of MODE_GET or MODE_POST
     49     * @return boolean TRUE on successful call; otherwise FALSE
     50     */
     51    public function _call_api($endpoint, $params = NULL, $mode = self::MODE_GET)
     52    {
     53        if (NULL === $params)
     54            $params = array(
     55                'timeout' => 15,
     56                'sslverify' => FALSE
     57            );
     58        $lic = file_exists(dirname(dirname(__FILE__)) . '/license.tmp');
     59
     60        foreach (self::$_api_urls as $api) {
     61SyncDebug::log(__METHOD__.'():' . __LINE__ . ' api=' . $api . ' endpoint=' . var_export($endpoint, TRUE));
     62            $this->_license_data = NULL;
     63            if (NULL !== $endpoint)
     64                $api = add_query_arg($endpoint, $api);
     65            if (FALSE && $lic)
     66                $api = str_replace('//', '//staging.', $api);
     67
     68SyncDebug::log(__METHOD__.'():' . __LINE__ . ' calling wp_remote_' . (self::MODE_GET == $mode ? 'get' : 'post') . '() on ' . $api . ' with ' . var_export($params, TRUE));
     69
     70            if (self::MODE_GET === $mode)
     71                $res = $this->_license_req = wp_remote_get($api, $params);
     72            else
     73                $res = $this->_license_req = wp_remote_post($api, $params);
     74
     75            if (is_wp_error($res)) {
     76SyncDebug::log(__METHOD__.'():' . __LINE__ . ' error: ' . var_export($res, TRUE));
     77                continue;
     78            }
     79
     80            $this->_license_data = json_decode(wp_remote_retrieve_body($res));
     81SyncDebug::log(__METHOD__.'():' . __LINE__ . ' decoded: ' . var_export($this->_license_data, TRUE));
     82            // check results for get_version
     83            if (isset($params['body']['edd_action']) && 'get_version' === $params['body']['edd_action']) {
     84SyncDebug::log(__METHOD__.'():' . __LINE__ . ' edd get_version request');
     85                return TRUE;
     86            }
     87            // check results for licensing
     88            if (isset($this->_license_data->success) && $this->_license_data->success) {
     89SyncDebug::log(__METHOD__.'():' . __LINE__ . ' found success marker');
     90                return TRUE;
     91            }
     92            // TODO: is this necessary since it'll continue processing anyway?
     93            if (isset($this->_license_data->error) && 'missing' === $this->_license_data->error) {
     94SyncDebug::log(__METHOD__.'():' . __LINE__ . ' found failure marker');
     95                continue;
     96            }
     97        }
     98
     99SyncDebug::log(__METHOD__.'():' . __LINE__ . ' processed all licensing servers; returning error');
     100        return FALSE;
     101    }
     102
     103    public function get_api_result()
     104    {
     105        return $this->_license_data;
     106    }
     107    public function get_api_request()
     108    {
     109        return $this->_license_req;
     110    }
     111
     112    /**
    33113     * Returns the URL to use for Licensing API calls
    34114     * @return string The License API url
     115     * @deprecated
    35116     */
    36117    private function _get_api_url()
    37118    {
    38         $url = self::LICENSE_API_URL;
     119        $url = self::LICENSE_API_URL_PRIMARY;
     120SyncDebug::log(__METHOD__.'():' . __LINE__, TRUE);
    39121        if (file_exists(dirname(dirname(__FILE__)) . '/license.tmp'))
    40122            $url = str_replace('//', '//staging.', $url);
     
    90172            return FALSE;
    91173        }
    92 
    93 //      $extensions = SyncExtensionModel::get_extensions();
    94 //      if (!isset($extensions[$slug]))
    95 //          return FALSE;
    96174
    97175        $call = FALSE;
     
    125203            );
    126204//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' sending ' . var_export($api_params, TRUE) . ' to ' . $this->_get_api_url());
    127             $response = wp_remote_get($remote_url = add_query_arg($api_params, $this->_get_api_url()), array('timeout' => 15, 'sslverify' => FALSE));
    128             if (is_wp_error($response)) {
     205#           $response = wp_remote_get($remote_url = add_query_arg($api_params, $this->_get_api_url()), array('timeout' => 15, 'sslverify' => FALSE));
     206#           if (is_wp_error($response)) {
     207#               self::$_status[$slug] = FALSE;
     208#//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' FALSE');
     209#               return FALSE;
     210#           }
     211            $res = $this->_call_api($api_params);
     212            if (FALSE === $res) {
    129213                self::$_status[$slug] = FALSE;
    130 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' FALSE');
     214SyncDebug::log(__METHOD__.'():' . __LINE__ . ' FALSE');
    131215                return FALSE;
    132216            }
    133217
    134218            // check response
    135             $response_body = wp_remote_retrieve_body($response);
    136             if (!empty($response_body)) {
    137                 $license_data = json_decode($response_body);
     219#           $response_body = wp_remote_retrieve_body($response);
     220#           if (!empty($response_body)) {
     221#               $license_data = json_decode($response_body);
     222                $license_data = $this->_license_data;
    138223//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' license data=' . var_export($license_data, TRUE));
    139224                if ('valid' === $license_data->license) {
     
    150235                self::$_dirty = TRUE;
    151236                $this->save_licenses();
    152             } else {
    153 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' slug=' . $slug . ' url=' . $remote_url . ' with params: ' . var_export($api_params, TRUE) . ' returned: ' . $response_body);
    154             }
     237#           } else {
     238#SyncDebug::log(__METHOD__.'():' . __LINE__ . ' slug=' . $slug . ' url=' . $remote_url . ' with params: ' . var_export($api_params, TRUE) . ' returned: ' . $response_body);
     239#           }
    155240//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' setting dirty flag');
    156241        }
     
    192277    public function activate($name)
    193278    {
    194 //SyncDebug::log(__METHOD__."('{$name}')");
     279SyncDebug::log(__METHOD__."('{$name}')");
    195280        $this->_load_licenses();
    196281        if (empty(self::$_licenses[$name])) {
    197 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' license empty');
     282SyncDebug::log(__METHOD__.'():' . __LINE__ . ' license empty');
    198283            return FALSE;
    199284        }
     
    201286        $extensions = SyncExtensionModel::get_extensions(TRUE);
    202287        if (empty($extensions[$name])) {
    203 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' extension empty');
     288SyncDebug::log(__METHOD__.'():' . __LINE__ . ' extension empty');
    204289            return FALSE;
    205290        }
     
    207292        $license = self::$_licenses[$name];
    208293        // data to send in our API request
    209         $api_params = array( 
    210             'edd_action'=> 'activate_license', 
    211             'license'   => $license, 
     294        $api_params = array(
     295            'edd_action'=> 'activate_license',
     296            'license'   => $license,
    212297            'item_name' => urlencode($extensions[$name]['name']),   // the name of our product in EDD,
    213298            'url'       => home_url()
     
    215300
    216301        // Call the licensing API
    217 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' sending ' . var_export($api_params, TRUE) . ' to ' . $this->_get_api_url());
    218         $response = wp_remote_post($this->_get_api_url(), array(
     302SyncDebug::log(__METHOD__.'():' . __LINE__ . ' sending ' . var_export($api_params, TRUE) . ' to ' . $this->_get_api_url());
     303#       $response = wp_remote_post($this->_get_api_url(), array(
     304#           'timeout'   => 15,
     305#           'sslverify' => FALSE,
     306#           'body'      => $api_params
     307#       ));
     308        $res = $this->_call_api(NULL, array(
    219309            'timeout'   => 15,
    220310            'sslverify' => FALSE,
    221311            'body'      => $api_params
    222         ));
    223 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' results=' . var_export($response, TRUE));
     312        ), self::MODE_POST);
     313SyncDebug::log(__METHOD__.'():' . __LINE__ . ' results=' . var_export($response, TRUE));
    224314
    225315        // check for errors
    226         if (is_wp_error($response)) {
    227 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' FALSE');
     316        if (FALSE === $res) {       // if (is_wp_error($response)) {
     317SyncDebug::log(__METHOD__.'():' . __LINE__ . ' FALSE');
    228318            return FALSE;
    229319        }
    230320
    231321        // decode the license data
    232         $license_data = json_decode(wp_remote_retrieve_body($response));
    233 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' data=' . var_export($license_data, TRUE));
     322#       $license_data = json_decode(wp_remote_retrieve_body($response));
     323        $license_data = $this->_license_data;
     324SyncDebug::log(__METHOD__.'():' . __LINE__ . ' data=' . var_export($license_data, TRUE));
    234325
    235326/*
     
    264355
    265356        if ($license_data->success) {
    266 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' success');
     357SyncDebug::log(__METHOD__.'():' . __LINE__ . ' success');
    267358            switch ($license_data->license) {
    268359            case 'valid':
     
    295386        if ($update) {
    296387            self::$_dirty = TRUE;
    297 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' setting dirty');
     388SyncDebug::log(__METHOD__.'():' . __LINE__ . ' setting dirty');
    298389            $this->save_licenses();
    299390        }
     
    308399
    309400    /**
    310      * Retrieves the add-on's version from the EDD API 
     401     * Retrieves the add-on's version from the EDD API
    311402     * @param string $slug The slug for the add-on to retrieve version information for
    312403     * @param string $name The name of the add-on for version retrieval
     
    336427        );
    337428//SyncDebug::log(__METHOD__.'() sending ' . var_export($api_params, TRUE) . ' to ' . $this->_get_api_url());
    338         $response = wp_remote_get($this->_get_api_url(), array(
    339             'timeout' => 15,
    340             'sslverify' => FALSE
    341         ));
     429#       $response = wp_remote_get($this->_get_api_url(), array(
     430#           'timeout' => 15,
     431#           'sslverify' => FALSE
     432#       ));
     433        $res = $this->_call_api(NULL, $api_params);
    342434//SyncDebug::log(__METHOD__.'() results=' . var_export($response, TRUE));
    343435/**
     
    358450 */
    359451        // check for errors
    360         if (is_wp_error($response))
     452        if (FALSE === $res) // is_wp_error($response))
    361453            return FALSE;
    362454
    363455        // decode the response
    364         $license_data = json_decode(wp_remote_retrieve_body($response));
     456#       $license_data = json_decode(wp_remote_retrieve_body($response));
     457        $license_data = $this->_license_data;
    365458//SyncDebug::log(__METHOD__.'() data=' . var_export($license_data, TRUE));
    366459    }
     
    373466    public function deactivate($name)
    374467    {
    375 //SyncDebug::log(__METHOD__."('{$name}')");
    376         $this->_load_licenses();
    377         if (empty(self::$_licenses[$name]))
    378             return FALSE;
    379 
    380         $extensions = SyncExtensionModel::get_extensions();
    381         if (empty($extensions[$name]))
    382             return FALSE;
     468SyncDebug::log(__METHOD__."('{$name}')");
     469        $this->_load_licenses();
     470        if (empty(self::$_licenses[$name])) {
     471SyncDebug::log(__METHOD__.'():' . __LINE__ . ' license not found ' . var_export(self::$_licenses, TRUE));
     472            return FALSE;
     473        }
     474
     475        $extensions = SyncExtensionModel::get_extensions(TRUE);
     476        if (empty($extensions[$name])) {
     477SyncDebug::log(__METHOD__.'():' . __LINE__ . ' extension not found ' . var_export($extensions, TRUE));
     478            return FALSE;
     479        }
    383480
    384481        $license = self::$_licenses[$name];
    385482        // data to send in our API request
    386         $api_params = array( 
    387             'edd_action'=> 'deactivate_license', 
    388             'license'   => $license, 
     483        $api_params = array(
     484            'edd_action'=> 'deactivate_license',
     485            'license'   => $license,
    389486            'item_name' => urlencode($extensions[$name]['name']),   // the name of our product in EDD,
    390487        );
    391488
    392489        // Call the licensing API
    393 //SyncDebug::log(__METHOD__.'() sending ' . var_export($api_params, TRUE) . ' to ' . $this->_get_api_url());
    394         $response = wp_remote_post($this->_get_api_url(), array(
     490SyncDebug::log(__METHOD__.'() sending ' . var_export($api_params, TRUE));
     491#       $response = wp_remote_post($this->_get_api_url(), array(
     492#           'timeout'   => 15,
     493#           'sslverify' => FALSE,
     494#           'body'      => $api_params
     495#       ));
     496        $res = $this->_call_api(NULL, array(
    395497            'timeout'   => 15,
    396498            'sslverify' => FALSE,
    397499            'body'      => $api_params
    398         ));
     500        ), self::MODE_POST);
    399501//SyncDebug::log(__METHOD__.'() results=' . var_export($response, TRUE));
    400502
    401503        // check for errors
    402         if (is_wp_error($response))
     504        if (FALSE === $res) // is_wp_error($response))
    403505            return FALSE;
    404506
    405507        // decode the license data
    406         $license_data = json_decode(wp_remote_retrieve_body($response));
    407 //SyncDebug::log(__METHOD__.'() data=' . var_export($license_data, TRUE));
     508#       $license_data = json_decode(wp_remote_retrieve_body($response));
     509        $license_data = $this->_license_data;
     510SyncDebug::log(__METHOD__.'() data=' . var_export($license_data, TRUE));
    408511
    409512/*
     
    468571//SyncDebug::log(__METHOD__.'() trace=' . $ex->getTraceAsString());
    469572            $modified = FALSE;
    470             $extensions = SyncExtensionModel::get_extensions();
     573            $extensions = SyncExtensionModel::get_extensions(TRUE);
    471574            foreach ($extensions as $key => $extension) {
    472575                if (!isset(self::$_licenses[$key])) {
  • wpsitesynccontent/trunk/classes/model.php

    r1745585 r1804149  
    212212        $push_data = array();
    213213
     214        // build a list of all the post status values we need to look for #146
     215        $stati = get_post_stati();
     216//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' stati: ' . var_export($stati, TRUE));
     217        // not looking for auto-draft (won't be edited) and inherit (we want only content not images)
     218        $post_stati = array_diff(array_keys($stati), array('auto-draft', 'inherit'));
     219//SyncDebug::log(__METHOD__.'():' . __LINE__ . ' stati: ' . var_export($post_stati, TRUE));
     220
    214221        // This will include content from the wp_post table, the wp_postmeta table, as well as information on any registered Favorite Image, or
    215222        $args = array(
    216223            'p' => $post_id,
    217224            'post_type' => apply_filters('spectrom_sync_allowed_post_types', array('post', 'page')),
    218             'post_status' => array('publish', 'pending', 'draft', 'future', 'private', 'trash'),
     225            'post_status' => $post_stati, // array('publish', 'pending', 'draft', 'future', 'private', 'trash'),
    219226            'posts_per_page' => 1,
    220227        );
     
    358365        $taxonomies = $this->get_all_taxonomies(); // get_taxonomies(array(), 'objects');
    359366        foreach ($taxonomies as $tax_name => $tax) {
    360             if (NULL === $post_type || in_array($post_type, $tax->object_type))
     367            if (NULL === $post_type ||
     368                (is_object($tax) && (NULL !== $tax->object_type && in_array($post_type, $tax->object_type))))
    361369                $tax_names[] = $tax_name;
    362370        }
  • wpsitesynccontent/trunk/classes/options.php

    r1745585 r1804149  
    3939
    4040        // perform fixup / cleanup on option values...migrating from previous configuration settings
    41         if (!isset(self::$_options['remove']))
    42             self::$_options['remove'] = '0';
     41//      if (!isset(self::$_options['remove']))
     42//          self::$_options['remove'] = '0';
     43        $defaults = array(
     44            'host' => '',
     45            'username' => '',
     46            'password' => '',
     47            'site_key' => '',
     48            'target_site_key' => '',
     49            'auth' => 0,
     50            'strict' => '1',
     51            'salt' => '',
     52            'min_role' => '',
     53            'remove' => '0',
     54            'match_mode' => 'title',
     55        );
     56//die('options: ' . var_export(self::$_options, TRUE));
     57        self::$_options = array_merge($defaults, self::$_options);
    4358    }
    4459
  • wpsitesynccontent/trunk/classes/settings.php

    r1745585 r1804149  
    197197    {
    198198//SyncDebug::log(__METHOD__.'() tab=' . $this->_tab);
    199         $option_values = SyncOptions::get_all(); // $this->_options;
    200 
    201         $default_values = apply_filters('spectrom_sync_default_settings',
     199        $data = $option_values = SyncOptions::get_all(); // $this->_options;
     200
     201/*      $default_values = apply_filters('spectrom_sync_default_settings',
    202202            // TODO: get this list from the SyncOptions class
    203203            array(
     
    215215
    216216        // Parse option values into predefined keys, throw the rest away.
    217         $data = shortcode_atts($default_values, $option_values);
     217        $data = shortcode_atts($default_values, $option_values); */
    218218
    219219        $section_id = 'sync_section';
     
    309309        );
    310310
    311         switch ($data['match_mode']) {
     311        $match_mode = isset($data['match_mode']) ? $data['match_mode'] : 'slug';
     312        switch ($match_mode) {
    312313        case 'slug':        $desc = __('Slug - Search for matching Content on Target by Post Slug.', 'wpsitesynccontent');
    313314            break;
     
    327328            array(                                          // args
    328329                'name' => 'match_mode',
    329                 'value' => $data['match_mode'],
     330                'value' => $match_mode,
    330331                'options' => array(
    331332                    'title' => __('Post Title', 'wpsitesynccontent'),
     
    569570            }
    570571        }
    571 //SyncDebug::log(__METHOD__.'()  output array: ' . var_export($out, TRUE));
     572//SyncDebug::log(__METHOD__.'():' . __LINE__ . '  output array: ' . var_export($out, TRUE));
    572573
    573574        // authenticate if there was a password provided or the host/username are different
     
    579580            $out['auth'] = 0;
    580581
    581 //SyncDebug::log(__METHOD__.'() authenticating with data ' . var_export($out, TRUE));
     582SyncDebug::log(__METHOD__.'():' . __LINE__ . ' authenticating with data ' . var_export($out, TRUE));
    582583            $api = new SyncApiRequest();
    583584            $res = $api->api('auth', $out);
    584585            if (!is_wp_error($res)) {
    585 //SyncDebug::log(__METHOD__.'()  response from auth request: ' . var_export($res, TRUE));
     586SyncDebug::log(__METHOD__.'():' . __LINE__ . '  response from auth request: ' . var_export($res, TRUE));
    586587                if (isset($res->response->success) && $res->response->success) {
    587588                    $out['auth'] = 1;
     
    590591                } else {
    591592                    // authentication failure response from Target- report this to user
    592 //SyncDebug::log(__METHOD__.'() authentication response from Target');
     593SyncDebug::log(__METHOD__.'():' . __LINE__ . ' authentication response from Target');
    593594                    $msg = SyncApiRequest::error_code_to_string($res->error_code);
     595                    $msg .= ' <a href="https://wpsitesync.com/knowledgebase/wpsitesync-error-messages/#error' . $res->error_code . '" target="_blank" style="text-decoration:none"><span class="dashicons dashicons-info"></span></a>';
    594596                    add_settings_error('sync_options_group', 'auth-error',
    595597                        sprintf(__('Error authenticating user on Target: %s', 'wpsitesynccontent'),
  • wpsitesynccontent/trunk/install/pluginupdater.php

    r1560226 r1804149  
    1010 * @version 1.6.3
    1111 */
    12 class EDD_SL_Plugin_Updater {
     12class EDD_SL_Plugin_Updater_Sync {
    1313    private $api_url   = '';
    1414    private $api_data  = array();
     
    7272            return $_transient_data;
    7373        }
     74SyncDebug::log(__METHOD__.'():' . __LINE__ . ' trans data=' . var_export($_transient_data, TRUE));
    7475        if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
    7576            $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
     77SyncDebug::log(__METHOD__.'():' . __LINE__ . ' version info=' . var_export($version_info, TRUE));
    7678            if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
     79SyncDebug::log(__METHOD__.'():' . __LINE__ . ' left=' . $this->version . ' right=' . $version_info->new_version);
    7780                if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
    7881                    $_transient_data->response[ $this->name ] = $version_info;
     
    8083                $_transient_data->last_checked = time();
    8184                $_transient_data->checked[ $this->name ] = $this->version;
     85SyncDebug::log(__METHOD__.'():' . __LINE__ . ' checked:[' . $this->name . ']=' . var_export($_transient_data->checked[$this->name], TRUE));
    8286            }
    8387        }
     
    211215     */
    212216    private function api_request( $_action, $_data ) {
     217SyncDebug::log(__METHOD__.'():' . __LINE__ . ' action=' . $_action, TRUE);
    213218        global $wp_version;
    214219        $data = array_merge( $this->api_data, $_data );
     
    228233            'url'        => home_url()
    229234        );
    230         $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
    231         if ( ! is_wp_error( $request ) ) {
    232             $request = json_decode( wp_remote_retrieve_body( $request ) );
    233         }
     235
     236#       $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
     237        $license_api = WPSiteSyncContent::get_instance()->get_license();
     238SyncDebug::log(__METHOD__.'():' . __LINE__ . ' calling _call_api()');
     239        $res = $license_api->_call_api(NULL, array(
     240            'timeout' => 15,
     241            'sslverify' => FALSE,
     242            'body' => $api_params,
     243        ), SyncLicensing::MODE_POST);
     244#       if ( ! is_wp_error( $request ) ) {
     245#           $request = json_decode( wp_remote_retrieve_body( $request ) );
     246#       }
     247SyncDebug::log(__METHOD__.'():' . __LINE__ . ' res=' . ($res ? 'TRUE' : 'FALSE'));
     248        if ($res) {
     249            $request = $license_api->get_api_result();
     250        } else {
     251            $request = $license_api->get_api_request();
     252        }
     253SyncDebug::log(__METHOD__.'():' . __LINE__ . ' request=' . var_export($request, TRUE));
    234254        if ( $request && isset( $request->sections ) ) {
    235255            $request->sections = maybe_unserialize( $request->sections );
     
    265285                'url'        => home_url()
    266286            );
    267             $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
    268             if ( ! is_wp_error( $request ) ) {
    269                 $version_info = json_decode( wp_remote_retrieve_body( $request ) );
     287#           $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
     288            $license_api = WPSiteSyncContent::get_instance()->get_license();
     289            $res = $license_api->_call_api(NULL, array(
     290                'timeout' => 15,
     291                'sslverify' => FALSE,
     292                'body' => $api_parms,
     293            ), SyncLicensing::MODE_POST);
     294#           if ( ! is_wp_error( $request ) ) {
     295#               $version_info = json_decode( wp_remote_retrieve_body( $request ) );
     296#           }
     297            if ($res) {
     298                $version_info = $license_api->get_api_result();
     299            } else {
     300                $version_info = $license_api->get_api_request();
    270301            }
    271302            if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
  • wpsitesynccontent/trunk/readme.txt

    r1745585 r1804149  
    55Requires at least: 3.5
    66Requires PHP: 5.3.1
    7 Tested up to: 4.8.2
     7Tested up to: 4.9
    88Stable tag: trunk
    99License: GPLv2 or later
     
    112112
    113113== Changelog ==
     114= 1.3.3 - Jan 16, 2018 =
     115* fix: allow for custom post status values (Thanks Alex V.)
     116* fix: removed deprecated warnings for function calls (Thanks Peter M.)
     117* fix: resolve undefined index warnings on empty configs (Thanks Peter M.)
     118* fix: fix to usage of fallback encryption method (Thanks Mika A.)
     119* fix: fix spelling error and array index error
     120* fix: runtime error that can occasionally occur while processing taxonomies
     121* fix: runtime error that can occur on first edit of settings
     122* fix: minor security update- remove bad password message that could imply valid account name
     123* fix: remove deprecation messages for mcrypt functions
     124* enhancement: add checks for SSL specific error conditions
     125* enhancement: add "more info" links to all error messages shown in UI
     126* enhancement: updates to licensing code
     127* enhancement: check serverpress.com domain for licensing data
     128* enhancement: add get_param method to javascript code
     129* enhancement: make SyncApiResponse instance available from Controller; needed by Divi add-on
     130* enhancement: check data object used in API calls and return early if contains error
     131
    114132= 1.3.2 - Oct 12, 2017 =
    115133* fix: improve checking for sync-specific meta data to be ignored
  • wpsitesynccontent/trunk/wpsitesynccontent.php

    r1745585 r1804149  
    66Author: WPSiteSync
    77Author URI: http://wpsitesync.com
    8 Version: 1.3.2
     8Version: 1.3.3
    99Text Domain: wpsitesynccontent
    1010Domain path: /language
     
    2525    class WPSiteSyncContent
    2626    {
    27         const PLUGIN_VERSION = '1.3.2';
     27        const PLUGIN_VERSION = '1.3.3';
    2828        const PLUGIN_NAME = 'WPSiteSyncContent';
    2929
     
    204204        {
    205205            // load updater class
    206             if (!class_exists('EDD_SL_Plugin_Updater', FALSE)) {
     206            if (!class_exists('EDD_SL_Plugin_Updater_Sync', FALSE)) {
    207207                $file = dirname(__FILE__) . '/install/pluginupdater.php';
    208208                require_once($file);
     
    214214            foreach ($update_data['extensions'] as $extension) {
    215215//SyncDebug::log(__METHOD__.'() creating updater instance for ' . $extension['name']);
    216                 $edd_updater = new EDD_SL_Plugin_Updater($update_data['store_url'], $extension['file'], array(
     216                $edd_updater = new EDD_SL_Plugin_Updater_Sync($update_data['store_url'], $extension['file'], array(
    217217                    'version'   => $extension['version'],                       // current version number
    218218                    'license'   => $extension['license'],                       // license key
Note: See TracChangeset for help on using the changeset viewer.