Changeset 1804149
- Timestamp:
- 01/17/2018 01:26:43 AM (8 years ago)
- Location:
- wpsitesynccontent
- Files:
-
- 48 added
- 14 edited
-
tags/1.3.2 (added)
-
tags/1.3.2/.htaccess (added)
-
tags/1.3.2/assets (added)
-
tags/1.3.2/assets/css (added)
-
tags/1.3.2/assets/css/sync-admin.css (added)
-
tags/1.3.2/assets/imgs (added)
-
tags/1.3.2/assets/imgs/ajax-loader.gif (added)
-
tags/1.3.2/assets/imgs/wpsitesync-logo-blue.png (added)
-
tags/1.3.2/assets/imgs/wpsitesync-logo.svg (added)
-
tags/1.3.2/assets/js (added)
-
tags/1.3.2/assets/js/settings.js (added)
-
tags/1.3.2/assets/js/sync.js (added)
-
tags/1.3.2/classes (added)
-
tags/1.3.2/classes/admin.php (added)
-
tags/1.3.2/classes/ajax.php (added)
-
tags/1.3.2/classes/apicontroller.php (added)
-
tags/1.3.2/classes/apiheaders.php (added)
-
tags/1.3.2/classes/apimodel.php (added)
-
tags/1.3.2/classes/apirequest.php (added)
-
tags/1.3.2/classes/apiresponse.php (added)
-
tags/1.3.2/classes/attachmodel.php (added)
-
tags/1.3.2/classes/auth.php (added)
-
tags/1.3.2/classes/debug.php (added)
-
tags/1.3.2/classes/extensionmodel.php (added)
-
tags/1.3.2/classes/extensionsettings.php (added)
-
tags/1.3.2/classes/input.php (added)
-
tags/1.3.2/classes/licensesettings.php (added)
-
tags/1.3.2/classes/licensing.php (added)
-
tags/1.3.2/classes/logmodel.php (added)
-
tags/1.3.2/classes/mediamodel.php (added)
-
tags/1.3.2/classes/model.php (added)
-
tags/1.3.2/classes/options.php (added)
-
tags/1.3.2/classes/postmodel.php (added)
-
tags/1.3.2/classes/serialize.php (added)
-
tags/1.3.2/classes/settings.php (added)
-
tags/1.3.2/classes/sourcesmodel.php (added)
-
tags/1.3.2/classes/view.php (added)
-
tags/1.3.2/index.php (added)
-
tags/1.3.2/install (added)
-
tags/1.3.2/install/activate.php (added)
-
tags/1.3.2/install/deactivate.php (added)
-
tags/1.3.2/install/pluginupdater.php (added)
-
tags/1.3.2/languages (added)
-
tags/1.3.2/languages/placeholder.txt (added)
-
tags/1.3.2/readme.txt (added)
-
tags/1.3.2/views (added)
-
tags/1.3.2/views/content_details.php (added)
-
tags/1.3.2/wpsitesynccontent.php (added)
-
trunk/assets/js/sync.js (modified) (7 diffs)
-
trunk/classes/admin.php (modified) (2 diffs)
-
trunk/classes/apicontroller.php (modified) (7 diffs)
-
trunk/classes/apirequest.php (modified) (14 diffs)
-
trunk/classes/apiresponse.php (modified) (2 diffs)
-
trunk/classes/auth.php (modified) (9 diffs)
-
trunk/classes/licensesettings.php (modified) (1 diff)
-
trunk/classes/licensing.php (modified) (18 diffs)
-
trunk/classes/model.php (modified) (2 diffs)
-
trunk/classes/options.php (modified) (1 diff)
-
trunk/classes/settings.php (modified) (7 diffs)
-
trunk/install/pluginupdater.php (modified) (6 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wpsitesynccontent.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpsitesynccontent/trunk/assets/js/sync.js
r1745585 r1804149 43 43 this.original_value = this.$content.val(); 44 44 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 */ 52 WPSiteSyncContent.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, ' ')); 45 63 }; 46 64 … … 194 212 } 195 213 214 //console.log('api() performing ajax request'); 196 215 this.push_xhr = { 197 216 type: 'post', … … 200 219 url: ajaxurl, 201 220 success: function(response) { 202 //console.log(' push() success response:');221 //console.log('api() success response:'); 203 222 //console.log(response); 204 223 wpsitesynccontent.clear_message(); … … 212 231 } 213 232 } 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 } 217 243 } 218 244 }, 219 245 error: function(response) { 220 //console.log(' push() failure response:');246 //console.log('api() failure response:'); 221 247 //console.log(response); 222 248 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 226 253 wpsitesynccontent.set_message('<span class="error">' + jQuery('#sync-runtime-err-msg').html() + '</span>', false, true) 227 254 // jQuery('#sync-content-anim').hide(); … … 231 258 // Allow other plugins to alter the ajax request 232 259 jQuery(document).trigger('sync_api_call', [op, this.push_xhr]); 233 //console.log(' push() calling jQuery.ajax');260 //console.log('api() calling jQuery.ajax'); 234 261 jQuery.ajax(this.push_xhr); 235 //console.log(' push() returned from ajax call');262 //console.log('api() returned from ajax call'); 236 263 }; 237 264 … … 242 269 WPSiteSyncContent.prototype.push = function(post_id) 243 270 { 271 // TODO: refactor to use api() method 244 272 //console.log('push()'); 245 273 // Do nothing when in a disabled state … … 281 309 } else { 282 310 //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)) { 284 313 // 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 } 286 318 } 287 319 }, -
wpsitesynccontent/trunk/classes/admin.php
r1745585 r1804149 189 189 echo '<div id="sync-pull-msg"><div style="color: #0085ba;">', __('Please activate the Pull extension.', 'wpsitesynccontent'), '</div></div>'; 190 190 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>'; 191 192 echo '</div>'; 192 193 … … 207 208 public function plugin_action_links($actions) 208 209 { 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')); 210 211 return $actions; 211 212 } -
wpsitesynccontent/trunk/classes/apicontroller.php
r1745585 r1804149 19 19 private $_user = NULL; // authenticated user making request 20 20 private $_auth = 1; // perform authentication checks 21 private $_response = NULL; // reference to SyncApiResponse instance that Controller uses for API responses 21 22 22 23 public $source = NULL; // the URL of the Source site for the request … … 49 50 else 50 51 $response = new SyncApiResponse(TRUE); 52 $this->_response = $response; 51 53 52 54 if (isset($args['site_key'])) … … 173 175 174 176 /** 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 /** 175 186 * Returns the specified Apache request header 176 187 * @param string $name The name of the request header to retrieve … … 250 261 251 262 $post_data = $this->post_raw('post_data', array()); 252 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' - post_data=' . var_export($post_data, TRUE));263 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' - post_data=' . var_export($post_data, TRUE)); 253 264 254 265 $this->source_post_id = abs($post_data['ID']); 255 266 // if (0 === $this->source_post_id && isset($post_data['post_id'])) 256 267 // $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'] . '"');268 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' syncing post data Source ID#'. $this->source_post_id . ' - "' . $post_data['post_title'] . '"'); 258 269 259 270 // Check if a post_id was specified, indicating an update to a previously synced post … … 307 318 // do not allow the push if it's not a recognized post type 308 319 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*/);320 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' checking post type: ' . $post_data['post_type']/*$post->post_type*/); 310 321 $response->error_code(SyncApiRequest::ERROR_INVALID_POST_TYPE); 311 322 return; … … 943 954 if (!is_wp_error($child_terms)) { 944 955 // 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); 947 958 SyncDebug::log(__METHOD__ . '() term child: ' . $term_child->slug); 948 959 if ($term_child->slug === $tax_term['slug']) { … … 977 988 SyncDebug::log(__METHOD__ . '() found term: ' . var_export($term, TRUE)); 978 989 if (isset($term->term_id)) { 979 $term_id = $term->term_id;990 $term_id = abs($term->term_id); 980 991 $parent = $term_id; // indicate parent for next loop iteration 981 992 } else { -
wpsitesynccontent/trunk/classes/apirequest.php
r1745585 r1804149 35 35 const ERROR_UPLOAD_NO_CONTENT = 28; 36 36 const ERROR_PHP_ERROR_ON_TARGET = 29; 37 const ERROR_SSL_PROTOCOL_ERROR = 30; 37 38 38 39 const NOTICE_FILE_EXISTS = 1; … … 95 96 return $response; 96 97 } 98 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' current auth data: ' . var_export($data, TRUE)); 97 99 } 98 100 … … 106 108 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' calling _push()'); 107 109 $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); 108 113 break; 109 114 case 'upload_media': … … 123 128 124 129 // 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()) { 126 141 // an error occured somewhere along the way. report it and return 127 // $response->error_code(abs($res->get_message()));128 142 return $response; 129 143 } … … 161 175 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' error in wp_remote_post(): ' . var_export($request, TRUE)); 162 176 // 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()); 164 181 } else { 165 182 $response->result = $request; … … 370 387 private function _get_auth_cookie() 371 388 { 372 SyncDebug::log(__METHOD__.'() user id=' . $this->_user_id);389 //SyncDebug::log(__METHOD__.'() user id=' . $this->_user_id); 373 390 $this->_auth_cookie = get_user_meta($this->_user_id, 'spectrom_site_cookies', TRUE); 374 391 … … 494 511 private function _auth(&$data) 495 512 { 496 //SyncDebug::log(__METHOD__.'() data: ' . var_export($data, TRUE));513 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' data: ' . var_export($data, TRUE)); 497 514 // TODO: indicate error if target system not set up 498 515 499 516 // if no Target credentials provided, get them from the config 500 517 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'); 502 519 $source_model = new SyncSourcesModel(); 503 520 $opts = new SyncOptions(); … … 540 557 // return new WP_Error(self::ERROR_MISSING_SITE_KEY); 541 558 } 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']); 546 563 if (empty($this->_target_data['username']) || 547 564 (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'); 549 566 return new WP_Error(self::ERROR_BAD_CREDENTIALS); 550 567 } 551 568 552 //SyncDebug::log( '' . __LINE__ . ' - adding authentication data to array');569 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' - adding authentication data to array'); 553 570 // add authentication to the data array 554 571 $data['auth'] = array( … … 559 576 // if password provided (first time authentication) then encrypt it 560 577 if (!empty($data['password'])) { 561 //SyncDebug::log(__METHOD__.'() encrypting password');578 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' encrypting password'); 562 579 $auth = new SyncAuth(); 563 580 $data['password'] = $auth->encode_password($data['password'], $data['host']); 564 581 582 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' encoded: ' . $data['password']); 565 583 $parts = explode(':', $data['password']); 566 584 $this->_target_data['password'] = $data['password'] = $parts[0]; 567 585 $this->_target_data['encode'] = $data['encode'] = $parts[1]; 568 586 } 569 //SyncDebug::log(__METHOD__.'() data: ' . var_export($data, TRUE));587 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' data: ' . var_export($data, TRUE)); 570 588 571 589 return NULL; … … 576 594 * @param int $post_id The post ID for the Content to be Pushed 577 595 * @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 579 597 */ 580 598 public function get_push_data($post_id, $data) … … 585 603 $post_data = $model->build_sync_data($post_id); 586 604 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' post data: ' . var_export($post_data, TRUE)); 605 if (0 === count($post_data)) 606 return NULL; 587 607 588 608 // Check if this is an update of a previously sync'd post … … 597 617 // 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 598 618 // 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']; 600 621 if (isset($post_data['post_meta'])) 601 622 $data['post_meta'] = $post_data['post_meta']; … … 725 746 $this->_sent_images = array(); // list of images already sent. Used by _send_image() to not send the same image twice 726 747 748 // TODO: use PHP_URL_HOST parameter 727 749 $url = parse_url(get_bloginfo('url')); 728 750 $this->_source_domain = $url['host']; … … 980 1002 case self::ERROR_UPLOAD_NO_CONTENT: $error = __('Attachment upload failed. No content found; is there a broken link?', 'wpsitesynccontent'); break; 981 1003 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; 982 1005 983 1006 default: -
wpsitesynccontent/trunk/classes/apiresponse.php
r1745585 r1804149 71 71 public function copy(SyncApiResponse $response) 72 72 { 73 $this->success = $response->success; 73 74 $this->error_code = $response->error_code; 74 75 $this->error_data = $response->error_data; … … 268 269 { 269 270 $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 } 272 278 273 279 if (NULL !== $this->error_data) -
wpsitesynccontent/trunk/classes/auth.php
r1745585 r1804149 8 8 class SyncAuth extends SyncInput 9 9 { 10 const HASHING_PASSWORD = TRUE; 10 const HASHING_PASSWORD = TRUE; // TODO: remove 11 11 12 12 // TODO: make this configurable between Source and Target sites so it's harder to break 13 13 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 14 16 15 17 /** … … 24 26 $password = $this->post('password', NULL); 25 27 $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)); 28 30 $source_model = new SyncSourcesModel(); 29 31 $api_controller = SyncApiController::get_instance(); … … 34 36 $site_key = $api_controller->source_site_key; 35 37 36 //SyncDebug::log(__METHOD__.'() authenticating via token');38 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' authenticating via token'); 37 39 //SyncDebug::log(' - source: ' . $source . ' site_key: ' . $site_key . ' user: ' . $username . ' token: ' . $token); 38 40 $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)); 40 42 } else { 41 43 $info['user_login'] = $username; 42 //SyncDebug::log( ' - target: ' . get_bloginfo('wpurl'));44 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' - target: ' . get_bloginfo('wpurl')); 43 45 if (self::HASHING_PASSWORD) { 44 46 $info['user_password'] = $this->decode_password($password, get_bloginfo('wpurl')); … … 51 53 $_SERVER['HTTP_REFERER'] = get_bloginfo('wpurl'); 52 54 53 //SyncDebug::log(__METHOD__.'() checking credentials: ' . var_export($info, TRUE));55 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' checking credentials: ' . var_export($info, TRUE)); 54 56 // if no credentials provided, don't bother authenticating 55 57 if (empty($info['user_login']) || empty($info['user_password'])) { 56 //SyncDebug::log(__METHOD__.'() missing credentials');58 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' missing credentials'); 57 59 $resp->success(FALSE); 58 60 $resp->error_code(SyncApiRequest::ERROR_BAD_CREDENTIALS); … … 63 65 } 64 66 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)); 66 68 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)); 69 70 // 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); 71 72 } else { 72 73 // we have a valid user - check additional requirements … … 74 75 // check capabilities 75 76 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'); 77 78 $resp->error_code(SyncApiRequest::ERROR_NO_PERMISSION); 78 79 return; … … 144 145 $left = $right = ''; 145 146 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); 149 150 $left = base64_encode($encrypted); 150 151 } … … 153 154 154 155 $encoded = $left . ':' . $right; 156 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' encoded=[' . $encoded . ']'); 155 157 return $encoded; 156 158 } … … 172 174 $right = $_POST['encode']; 173 175 176 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' left=[' . $left . '] right=[' . $right . '] pass=[' . $password . ']'); 174 177 $cleartext = NULL; 175 if ( function_exists('mcrypt_get_iv_size')) {178 if (!empty($left) && function_exists('mcrypt_get_iv_size')) { 176 179 $decoded = base64_decode($left); 177 180 //SyncDebug::log(' decoded: ' . $decoded); 178 181 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); 182 185 //SyncDebug::log(' cleartext: ' . var_export($cleartext, TRUE)); 183 186 $cleartext = trim($cleartext, "\0"); 184 //SyncDebug::log(__METHOD__.'() decoded left "' . $left . '" into "' . $cleartext . '"');187 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' decoded left "' . $left . '" into "' . $cleartext . '"'); 185 188 } 186 189 if (empty($cleartext) && !empty($right)) { -
wpsitesynccontent/trunk/classes/licensesettings.php
r1560226 r1804149 110 110 echo '<button id="sync-license-deact-', $args['name'], '" type="button" class="button sync-license sync-license-deactivate" data="', $args['name'], '" '; 111 111 echo ' onclick="sync_settings.deactivate(this, \'', $args['name'] , '\'); return false;" >'; 112 _e('De ctivate', 'wpsitesynccontent');112 _e('Deactivate', 'wpsitesynccontent'); 113 113 echo '</button>'; 114 114 -
wpsitesynccontent/trunk/classes/licensing.php
r1745585 r1804149 9 9 const OPTION_NAME = 'spectrom_sync_licensing'; 10 10 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'; 12 13 const LICENSE_TTL = 10800; # 28800 = 8hrs | 10800 = 3hrs 13 14 … … 18 19 const STATE_ERROR = '9'; 19 20 21 const MODE_GET = 1; // for wp_remote_get() calls 22 const MODE_POST = 2; // for wp_remote_post() calls 23 20 24 private static $_licenses = NULL; 21 25 private static $_status = array(); … … 23 27 private static $_instance = NULL; 24 28 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 25 37 public function __construct() 26 38 { … … 31 43 32 44 /** 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) { 61 SyncDebug::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 68 SyncDebug::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)) { 76 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' error: ' . var_export($res, TRUE)); 77 continue; 78 } 79 80 $this->_license_data = json_decode(wp_remote_retrieve_body($res)); 81 SyncDebug::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']) { 84 SyncDebug::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) { 89 SyncDebug::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) { 94 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' found failure marker'); 95 continue; 96 } 97 } 98 99 SyncDebug::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 /** 33 113 * Returns the URL to use for Licensing API calls 34 114 * @return string The License API url 115 * @deprecated 35 116 */ 36 117 private function _get_api_url() 37 118 { 38 $url = self::LICENSE_API_URL; 119 $url = self::LICENSE_API_URL_PRIMARY; 120 SyncDebug::log(__METHOD__.'():' . __LINE__, TRUE); 39 121 if (file_exists(dirname(dirname(__FILE__)) . '/license.tmp')) 40 122 $url = str_replace('//', '//staging.', $url); … … 90 172 return FALSE; 91 173 } 92 93 // $extensions = SyncExtensionModel::get_extensions();94 // if (!isset($extensions[$slug]))95 // return FALSE;96 174 97 175 $call = FALSE; … … 125 203 ); 126 204 //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) { 129 213 self::$_status[$slug] = FALSE; 130 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' FALSE');214 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' FALSE'); 131 215 return FALSE; 132 216 } 133 217 134 218 // 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; 138 223 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' license data=' . var_export($license_data, TRUE)); 139 224 if ('valid' === $license_data->license) { … … 150 235 self::$_dirty = TRUE; 151 236 $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 # } 155 240 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' setting dirty flag'); 156 241 } … … 192 277 public function activate($name) 193 278 { 194 //SyncDebug::log(__METHOD__."('{$name}')");279 SyncDebug::log(__METHOD__."('{$name}')"); 195 280 $this->_load_licenses(); 196 281 if (empty(self::$_licenses[$name])) { 197 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' license empty');282 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' license empty'); 198 283 return FALSE; 199 284 } … … 201 286 $extensions = SyncExtensionModel::get_extensions(TRUE); 202 287 if (empty($extensions[$name])) { 203 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' extension empty');288 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' extension empty'); 204 289 return FALSE; 205 290 } … … 207 292 $license = self::$_licenses[$name]; 208 293 // 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, 212 297 'item_name' => urlencode($extensions[$name]['name']), // the name of our product in EDD, 213 298 'url' => home_url() … … 215 300 216 301 // 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( 302 SyncDebug::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( 219 309 'timeout' => 15, 220 310 'sslverify' => FALSE, 221 311 'body' => $api_params 222 ) );223 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' results=' . var_export($response, TRUE));312 ), self::MODE_POST); 313 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' results=' . var_export($response, TRUE)); 224 314 225 315 // check for errors 226 if ( is_wp_error($response)) {227 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' FALSE');316 if (FALSE === $res) { // if (is_wp_error($response)) { 317 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' FALSE'); 228 318 return FALSE; 229 319 } 230 320 231 321 // 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; 324 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' data=' . var_export($license_data, TRUE)); 234 325 235 326 /* … … 264 355 265 356 if ($license_data->success) { 266 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' success');357 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' success'); 267 358 switch ($license_data->license) { 268 359 case 'valid': … … 295 386 if ($update) { 296 387 self::$_dirty = TRUE; 297 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' setting dirty');388 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' setting dirty'); 298 389 $this->save_licenses(); 299 390 } … … 308 399 309 400 /** 310 * Retrieves the add-on's version from the EDD API 401 * Retrieves the add-on's version from the EDD API 311 402 * @param string $slug The slug for the add-on to retrieve version information for 312 403 * @param string $name The name of the add-on for version retrieval … … 336 427 ); 337 428 //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); 342 434 //SyncDebug::log(__METHOD__.'() results=' . var_export($response, TRUE)); 343 435 /** … … 358 450 */ 359 451 // check for errors 360 if ( is_wp_error($response))452 if (FALSE === $res) // is_wp_error($response)) 361 453 return FALSE; 362 454 363 455 // 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; 365 458 //SyncDebug::log(__METHOD__.'() data=' . var_export($license_data, TRUE)); 366 459 } … … 373 466 public function deactivate($name) 374 467 { 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; 468 SyncDebug::log(__METHOD__."('{$name}')"); 469 $this->_load_licenses(); 470 if (empty(self::$_licenses[$name])) { 471 SyncDebug::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])) { 477 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' extension not found ' . var_export($extensions, TRUE)); 478 return FALSE; 479 } 383 480 384 481 $license = self::$_licenses[$name]; 385 482 // 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, 389 486 'item_name' => urlencode($extensions[$name]['name']), // the name of our product in EDD, 390 487 ); 391 488 392 489 // 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( 490 SyncDebug::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( 395 497 'timeout' => 15, 396 498 'sslverify' => FALSE, 397 499 'body' => $api_params 398 ) );500 ), self::MODE_POST); 399 501 //SyncDebug::log(__METHOD__.'() results=' . var_export($response, TRUE)); 400 502 401 503 // check for errors 402 if ( is_wp_error($response))504 if (FALSE === $res) // is_wp_error($response)) 403 505 return FALSE; 404 506 405 507 // 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; 510 SyncDebug::log(__METHOD__.'() data=' . var_export($license_data, TRUE)); 408 511 409 512 /* … … 468 571 //SyncDebug::log(__METHOD__.'() trace=' . $ex->getTraceAsString()); 469 572 $modified = FALSE; 470 $extensions = SyncExtensionModel::get_extensions( );573 $extensions = SyncExtensionModel::get_extensions(TRUE); 471 574 foreach ($extensions as $key => $extension) { 472 575 if (!isset(self::$_licenses[$key])) { -
wpsitesynccontent/trunk/classes/model.php
r1745585 r1804149 212 212 $push_data = array(); 213 213 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 214 221 // This will include content from the wp_post table, the wp_postmeta table, as well as information on any registered Favorite Image, or 215 222 $args = array( 216 223 'p' => $post_id, 217 224 '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'), 219 226 'posts_per_page' => 1, 220 227 ); … … 358 365 $taxonomies = $this->get_all_taxonomies(); // get_taxonomies(array(), 'objects'); 359 366 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)))) 361 369 $tax_names[] = $tax_name; 362 370 } -
wpsitesynccontent/trunk/classes/options.php
r1745585 r1804149 39 39 40 40 // 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); 43 58 } 44 59 -
wpsitesynccontent/trunk/classes/settings.php
r1745585 r1804149 197 197 { 198 198 //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', 202 202 // TODO: get this list from the SyncOptions class 203 203 array( … … 215 215 216 216 // 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); */ 218 218 219 219 $section_id = 'sync_section'; … … 309 309 ); 310 310 311 switch ($data['match_mode']) { 311 $match_mode = isset($data['match_mode']) ? $data['match_mode'] : 'slug'; 312 switch ($match_mode) { 312 313 case 'slug': $desc = __('Slug - Search for matching Content on Target by Post Slug.', 'wpsitesynccontent'); 313 314 break; … … 327 328 array( // args 328 329 'name' => 'match_mode', 329 'value' => $ data['match_mode'],330 'value' => $match_mode, 330 331 'options' => array( 331 332 'title' => __('Post Title', 'wpsitesynccontent'), … … 569 570 } 570 571 } 571 //SyncDebug::log(__METHOD__.'() output array: ' . var_export($out, TRUE));572 //SyncDebug::log(__METHOD__.'():' . __LINE__ . ' output array: ' . var_export($out, TRUE)); 572 573 573 574 // authenticate if there was a password provided or the host/username are different … … 579 580 $out['auth'] = 0; 580 581 581 //SyncDebug::log(__METHOD__.'()authenticating with data ' . var_export($out, TRUE));582 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' authenticating with data ' . var_export($out, TRUE)); 582 583 $api = new SyncApiRequest(); 583 584 $res = $api->api('auth', $out); 584 585 if (!is_wp_error($res)) { 585 //SyncDebug::log(__METHOD__.'()response from auth request: ' . var_export($res, TRUE));586 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' response from auth request: ' . var_export($res, TRUE)); 586 587 if (isset($res->response->success) && $res->response->success) { 587 588 $out['auth'] = 1; … … 590 591 } else { 591 592 // authentication failure response from Target- report this to user 592 //SyncDebug::log(__METHOD__.'()authentication response from Target');593 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' authentication response from Target'); 593 594 $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>'; 594 596 add_settings_error('sync_options_group', 'auth-error', 595 597 sprintf(__('Error authenticating user on Target: %s', 'wpsitesynccontent'), -
wpsitesynccontent/trunk/install/pluginupdater.php
r1560226 r1804149 10 10 * @version 1.6.3 11 11 */ 12 class EDD_SL_Plugin_Updater {12 class EDD_SL_Plugin_Updater_Sync { 13 13 private $api_url = ''; 14 14 private $api_data = array(); … … 72 72 return $_transient_data; 73 73 } 74 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' trans data=' . var_export($_transient_data, TRUE)); 74 75 if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { 75 76 $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); 77 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' version info=' . var_export($version_info, TRUE)); 76 78 if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { 79 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' left=' . $this->version . ' right=' . $version_info->new_version); 77 80 if( version_compare( $this->version, $version_info->new_version, '<' ) ) { 78 81 $_transient_data->response[ $this->name ] = $version_info; … … 80 83 $_transient_data->last_checked = time(); 81 84 $_transient_data->checked[ $this->name ] = $this->version; 85 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' checked:[' . $this->name . ']=' . var_export($_transient_data->checked[$this->name], TRUE)); 82 86 } 83 87 } … … 211 215 */ 212 216 private function api_request( $_action, $_data ) { 217 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' action=' . $_action, TRUE); 213 218 global $wp_version; 214 219 $data = array_merge( $this->api_data, $_data ); … … 228 233 'url' => home_url() 229 234 ); 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(); 238 SyncDebug::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 # } 247 SyncDebug::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 } 253 SyncDebug::log(__METHOD__.'():' . __LINE__ . ' request=' . var_export($request, TRUE)); 234 254 if ( $request && isset( $request->sections ) ) { 235 255 $request->sections = maybe_unserialize( $request->sections ); … … 265 285 'url' => home_url() 266 286 ); 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(); 270 301 } 271 302 if ( ! empty( $version_info ) && isset( $version_info->sections ) ) { -
wpsitesynccontent/trunk/readme.txt
r1745585 r1804149 5 5 Requires at least: 3.5 6 6 Requires PHP: 5.3.1 7 Tested up to: 4. 8.27 Tested up to: 4.9 8 8 Stable tag: trunk 9 9 License: GPLv2 or later … … 112 112 113 113 == 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 114 132 = 1.3.2 - Oct 12, 2017 = 115 133 * fix: improve checking for sync-specific meta data to be ignored -
wpsitesynccontent/trunk/wpsitesynccontent.php
r1745585 r1804149 6 6 Author: WPSiteSync 7 7 Author URI: http://wpsitesync.com 8 Version: 1.3. 28 Version: 1.3.3 9 9 Text Domain: wpsitesynccontent 10 10 Domain path: /language … … 25 25 class WPSiteSyncContent 26 26 { 27 const PLUGIN_VERSION = '1.3. 2';27 const PLUGIN_VERSION = '1.3.3'; 28 28 const PLUGIN_NAME = 'WPSiteSyncContent'; 29 29 … … 204 204 { 205 205 // load updater class 206 if (!class_exists('EDD_SL_Plugin_Updater ', FALSE)) {206 if (!class_exists('EDD_SL_Plugin_Updater_Sync', FALSE)) { 207 207 $file = dirname(__FILE__) . '/install/pluginupdater.php'; 208 208 require_once($file); … … 214 214 foreach ($update_data['extensions'] as $extension) { 215 215 //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( 217 217 'version' => $extension['version'], // current version number 218 218 'license' => $extension['license'], // license key
Note: See TracChangeset
for help on using the changeset viewer.