Changeset 1116671
- Timestamp:
- 03/20/2015 07:59:58 AM (11 years ago)
- Location:
- cleantalk-spam-protect/trunk
- Files:
-
- 3 edited
-
cleantalk-admin.php (modified) (14 diffs)
-
cleantalk-common.php (modified) (13 diffs)
-
cleantalk-public.php (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cleantalk-spam-protect/trunk/cleantalk-admin.php
r1116000 r1116671 26 26 */ 27 27 function ct_admin_init() { 28 global $ct_server_timeout, $show_ct_notice_autokey, $ct_notice_autokey_label, $ct_notice_autokey_value, $show_ct_notice_renew, $ct_notice_renew_label, $show_ct_notice_trial, $ct_notice_trial_label, $show_ct_notice_online, $ct_notice_online_label, $renew_notice_showtime, $trial_notice_showtime, $ct_plugin_name, $ct_options, $ trial_notice_check_timeout, $account_notice_check_timeout, $ct_user_token_label, $ct_account_status_check;28 global $ct_server_timeout, $show_ct_notice_autokey, $ct_notice_autokey_label, $ct_notice_autokey_value, $show_ct_notice_renew, $ct_notice_renew_label, $show_ct_notice_trial, $ct_notice_trial_label, $show_ct_notice_online, $ct_notice_online_label, $renew_notice_showtime, $trial_notice_showtime, $ct_plugin_name, $ct_options, $ct_data, $trial_notice_check_timeout, $account_notice_check_timeout, $ct_user_token_label; 29 29 30 30 $ct_options = ct_get_options(); 31 $ct_data = ct_get_data(); 31 32 32 33 $show_ct_notice_trial = false; … … 91 92 } 92 93 93 if (time() > $ct_ options['next_account_status_check']) {94 if (time() > $ct_data['next_account_status_check']) { 94 95 $result = false; 95 96 if (function_exists('curl_init') && function_exists('json_decode') && ct_valid_key($ct_options['apikey'])) { … … 138 139 139 140 if (isset($result['user_token'])) { 140 $ct_ options['user_token'] = $result['user_token'];141 $ct_data['user_token'] = $result['user_token']; 141 142 } 142 143 } 143 144 144 145 // Save next status request time 145 $ct_options['next_account_status_check'] = strtotime("+$notice_check_timeout hours", time()); 146 $ct_account_status_check = time(); 147 update_option('cleantalk_settings', $ct_options); 146 $ct_data['next_account_status_check'] = strtotime("+$notice_check_timeout hours", time()); 147 update_option('cleantalk_data', $ct_data); 148 148 } 149 149 … … 199 199 */ 200 200 function ct_input_apikey() { 201 global $ct_options, $ct_ notice_online_label;201 global $ct_options, $ct_data, $ct_notice_online_label; 202 202 203 203 $value = $ct_options['apikey']; … … 222 222 */ 223 223 function ct_input_comments_test() { 224 global $ct_options ;224 global $ct_options, $ct_data; 225 225 226 226 $value = $ct_options['comments_test']; … … 235 235 */ 236 236 function ct_input_registrations_test() { 237 global $ct_options ;237 global $ct_options, $ct_data; 238 238 239 239 $value = $ct_options['registrations_test']; … … 248 248 */ 249 249 function ct_input_contact_forms_test() { 250 global $ct_options ;250 global $ct_options, $ct_data; 251 251 252 252 $value = $ct_options['contact_forms_test']; … … 261 261 */ 262 262 function ct_input_general_contact_forms_test() { 263 global $ct_options ;263 global $ct_options, $ct_data; 264 264 265 265 $value = $ct_options['general_contact_forms_test']; … … 277 277 */ 278 278 function ct_input_remove_old_spam() { 279 global $ct_options ;279 global $ct_options, $ct_data; 280 280 281 281 $value = $ct_options['remove_old_spam']; … … 335 335 */ 336 336 function admin_notice_message(){ 337 global $show_ct_notice_trial, $show_ct_notice_renew, $show_ct_notice_online, $show_ct_notice_autokey, $ct_notice_autokey_value, $ct_plugin_name, $ct_options ;337 global $show_ct_notice_trial, $show_ct_notice_renew, $show_ct_notice_online, $show_ct_notice_autokey, $ct_notice_autokey_value, $ct_plugin_name, $ct_options, $ct_data; 338 338 339 339 $user_token = ''; 340 if (isset($ct_ options['user_token']) && $ct_options['user_token'] != '') {341 $user_token = '&user_token=' . $ct_ options['user_token'];340 if (isset($ct_data['user_token']) && $ct_data['user_token'] != '') { 341 $user_token = '&user_token=' . $ct_data['user_token']; 342 342 } 343 343 … … 397 397 */ 398 398 function ct_valid_key($apikey = null) { 399 global $ct_options ;399 global $ct_options, $ct_data; 400 400 if ($apikey === null) { 401 401 $apikey = $ct_options['apikey']; … … 533 533 */ 534 534 function ct_update_option($option_name) { 535 global $show_ct_notice_online, $ct_notice_online_label, $ct_notice_trial_label, $trial_notice_showtime, $ct_ account_status_check, $ct_options, $ct_server_timeout;535 global $show_ct_notice_online, $ct_notice_online_label, $ct_notice_trial_label, $trial_notice_showtime, $ct_options, $ct_data, $ct_server_timeout; 536 536 537 537 if($option_name !== 'cleantalk_settings') { … … 539 539 } 540 540 541 // Skip test call if the function executet during account status check 542 if ($ct_account_status_check > 0 && time() - $ct_account_status_check < 5) { 541 $api_key = $ct_options['apikey']; 542 if (isset($_POST['cleantalk_settings']['apikey'])) { 543 $api_key = trim($_POST['cleantalk_settings']['apikey']); 544 } 545 if (!ct_valid_key($api_key)) { 543 546 return; 544 547 } … … 556 559 $app_server_error = false; 557 560 if (function_exists('curl_init') && function_exists('json_decode')) { 558 $api_key = $ct_options['apikey'];559 if (isset($_POST['cleantalk_settings']['apikey'])) {560 $api_key = trim($_POST['cleantalk_settings']['apikey']);561 }562 563 if (!ct_valid_key($api_key)) {564 return null;565 }566 567 561 $url = 'https://cleantalk.org/app_notice'; 568 562 $data['auth_key'] = $api_key; -
cleantalk-spam-protect/trunk/cleantalk-common.php
r1116005 r1116671 76 76 77 77 // Plugin's options 78 $ct_options = null; 79 80 // Account status check last time81 $ct_ account_status_check = 0;78 $ct_options = null; 79 80 // Plugin's data 81 $ct_data = null; 82 82 83 83 // Post without page load … … 132 132 */ 133 133 function ct_base_call($params = array()) { 134 global $wpdb, $ct_agent_version, $ct_formtime_label, $ct_options ;134 global $wpdb, $ct_agent_version, $ct_formtime_label, $ct_options, $ct_data; 135 135 136 136 require_once('cleantalk.class.php'); … … 208 208 */ 209 209 function get_sender_info() { 210 global $ct_direct_post, $ct_options ;210 global $ct_direct_post, $ct_options, $ct_data; 211 211 212 212 $php_session = session_id() != '' ? 1 : 0; … … 284 284 */ 285 285 function ct_get_checkjs_value($random_key = false) { 286 global $ct_options ;286 global $ct_options, $ct_data; 287 287 288 288 if ($random_key) { 289 $keys = $ct_ options['js_keys'];289 $keys = $ct_data['js_keys']; 290 290 $keys_checksum = md5(json_encode($keys)); 291 291 … … 295 295 296 296 // Removing key if it's to old 297 if (time() - $t > $ct_ options['js_keys_store_days'] * 86400) {297 if (time() - $t > $ct_data['js_keys_store_days'] * 86400) { 298 298 unset($keys[$k]); 299 299 continue; … … 307 307 308 308 // Get new key if the latest key is too old 309 if (time() - $latest_key_time > $ct_ options['js_key_lifetime']) {309 if (time() - $latest_key_time > $ct_data['js_key_lifetime']) { 310 310 $key = rand(); 311 311 $keys[$key] = time(); … … 313 313 314 314 if (md5(json_encode($keys)) != $keys_checksum) { 315 $ct_ options['js_keys'] = $keys;316 update_option('cleantalk_ settings', $ct_options);315 $ct_data['js_keys'] = $keys; 316 update_option('cleantalk_data', $ct_data); 317 317 } 318 318 } else { … … 354 354 'spam_store_days' => '15', // Days before delete comments from folder Spam 355 355 'ssl_on' => 0, // Secure connection to servers 356 'relevance_test' => 0, // Test comment for relevance 357 'notice_api_errors' => 0, // Send API error notices to WP admin 358 ); 359 } 360 361 /** 362 * Inner function - Current Cleantalk data 363 * @return mixed[] Array of options 364 */ 365 function ct_get_data() { 366 $data = get_option('cleantalk_data'); 367 if (!is_array($data)){ 368 $data = array(); 369 } 370 return array_merge(ct_def_data(), (array) $data); 371 } 372 373 /** 374 * Inner function - Default Cleantalk data 375 * @return mixed[] Array of default options 376 */ 377 function ct_def_data() { 378 return array( 356 379 'next_account_status_check' => 0, // Time label when the plugin should check account status 357 380 'user_token' => '', // User token 358 'relevance_test' => 0, // Test comment for relevance359 'notice_api_errors' => 0, // Send API error notices to WP admin360 381 'js_keys' => array(), // Keys to do JavaScript antispam test 361 382 'js_keys_store_days' => 8, // JavaScript keys store days - 8 days now … … 389 410 */ 390 411 function ct_feedback($hash, $message = null, $allow) { 391 global $ct_options ;412 global $ct_options, $ct_data; 392 413 393 414 require_once('cleantalk.class.php'); … … 426 447 */ 427 448 function ct_send_feedback($feedback_request = null) { 428 global $ct_options ;449 global $ct_options, $ct_data; 429 450 430 451 if (empty($feedback_request) && isset($_SESSION['feedback_request']) && preg_match("/^[a-z0-9\;\:]+$/", $_SESSION['feedback_request'])) { … … 468 489 */ 469 490 function ct_do_this_hourly() { 470 global $ct_options ;491 global $ct_options, $ct_data; 471 492 // do something every hour 472 493 … … 474 495 $ct_options = ct_get_options(); 475 496 497 if (!isset($ct_data)) 498 $ct_data = ct_get_data(); 499 476 500 delete_spam_comments(); 477 501 ct_send_feedback(); … … 483 507 */ 484 508 function delete_spam_comments() { 485 global $pagenow, $ct_options ;509 global $pagenow, $ct_options, $ct_data; 486 510 487 511 if ($ct_options['remove_old_spam'] == 1) { -
cleantalk-spam-protect/trunk/cleantalk-public.php
r1116000 r1116671 6 6 */ 7 7 function ct_init() { 8 global $ct_wplp_result_label, $ct_jp_comments, $ct_post_data_label, $ct_post_data_authnet_label, $ct_formtime_label, $ct_direct_post, $ct_options ;8 global $ct_wplp_result_label, $ct_jp_comments, $ct_post_data_label, $ct_post_data_authnet_label, $ct_formtime_label, $ct_direct_post, $ct_options, $ct_data; 9 9 10 10 $ct_options = ct_get_options(); 11 $ct_data = ct_get_data(); 11 12 12 13 ct_init_session(); … … 117 118 */ 118 119 function ct_comment_form($post_id) { 119 global $ct_options ;120 global $ct_options, $ct_data; 120 121 121 122 if (ct_is_user_enable() === false) { … … 214 215 */ 215 216 function ct_frm_entries_footer_scripts($fields, $form) { 216 global $current_user, $ct_checkjs_frm, $ct_options ;217 global $current_user, $ct_checkjs_frm, $ct_options, $ct_data; 217 218 218 219 if ($ct_options['contact_forms_test'] == 0) { … … 239 240 */ 240 241 function ct_frm_validate_entry ($errors, $values) { 241 global $wpdb, $current_user, $ct_agent_version, $ct_checkjs_frm, $ct_options ;242 global $wpdb, $current_user, $ct_agent_version, $ct_checkjs_frm, $ct_options, $ct_data; 242 243 243 244 if ($ct_options['contact_forms_test'] == 0) { … … 286 287 */ 287 288 function ct_bbp_new_pre_content ($comment) { 288 global $ct_options ;289 global $ct_options, $ct_data; 289 290 290 291 if (ct_is_user_enable() === false || $ct_options['comments_test'] == 0 || is_user_logged_in()) { … … 339 340 // this action is called by wp-comments-post.php 340 341 // after processing WP makes redirect to post page with comment's form by GET request (see above) 341 global $wpdb, $current_user, $comment_post_id, $ct_agent_version, $ct_comment_done, $ct_approved_request_id_label, $ct_jp_comments, $ct_options ;342 global $wpdb, $current_user, $comment_post_id, $ct_agent_version, $ct_comment_done, $ct_approved_request_id_label, $ct_jp_comments, $ct_options, $ct_data; 342 343 343 344 if (ct_is_user_enable() === false || $ct_options['comments_test'] == 0 || $ct_comment_done) { … … 498 499 */ 499 500 function js_test($field_name = 'ct_checkjs', $data = null, $random_key = false) { 500 global $ct_options ;501 global $ct_options, $ct_data; 501 502 502 503 $checkjs = null; … … 514 515 if ($random_key) { 515 516 516 $keys = $ct_ options['js_keys'];517 $keys = $ct_data['js_keys']; 517 518 if (isset($keys[$js_post_value])) { 518 519 $checkjs = 1; … … 649 650 */ 650 651 function ct_register_form() { 651 global $ct_checkjs_register_form, $ct_options ;652 global $ct_checkjs_register_form, $ct_options, $ct_data; 652 653 653 654 if ($ct_options['registrations_test'] == 0) { … … 665 666 */ 666 667 function ct_login_message($message) { 667 global $errors, $ct_session_register_ok_label, $ct_options ;668 global $errors, $ct_session_register_ok_label, $ct_options, $ct_data; 668 669 669 670 if ($ct_options['registrations_test'] != 0) { … … 728 729 */ 729 730 function ct_registration_errors($errors, $sanitized_user_login = null, $user_email = null) { 730 global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label, $ct_session_register_ok_label, $bp, $ct_signup_done, $ct_formtime_label, $ct_negative_comment, $ct_options ;731 global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label, $ct_session_register_ok_label, $bp, $ct_signup_done, $ct_formtime_label, $ct_negative_comment, $ct_options, $ct_data; 731 732 732 733 // Go out if a registrered user action … … 873 874 */ 874 875 function ct_grunion_contact_form_field_html($r, $field_label) { 875 global $ct_checkjs_jpcf, $ct_jpcf_patched, $ct_jpcf_fields, $ct_options ;876 global $ct_checkjs_jpcf, $ct_jpcf_patched, $ct_jpcf_fields, $ct_options, $ct_data; 876 877 877 878 if ($ct_options['contact_forms_test'] == 1 && $ct_jpcf_patched === false && preg_match("/[text|email]/i", $r)) { … … 896 897 */ 897 898 function ct_contact_form_is_spam($form) { 898 global $ct_checkjs_jpcf, $ct_options ;899 global $ct_checkjs_jpcf, $ct_options, $ct_data; 899 900 900 901 if ($ct_options['contact_forms_test'] == 0) { … … 958 959 */ 959 960 function ct_wpcf7_form_elements($html) { 960 global $wpdb, $current_user, $ct_checkjs_cf7, $ct_options ;961 global $wpdb, $current_user, $ct_checkjs_cf7, $ct_options, $ct_data; 961 962 962 963 if ($ct_options['contact_forms_test'] == 0) { … … 973 974 */ 974 975 function ct_wpcf7_spam($param) { 975 global $wpdb, $current_user, $ct_agent_version, $ct_checkjs_cf7, $ct_cf7_comment, $ct_options ;976 global $wpdb, $current_user, $ct_agent_version, $ct_checkjs_cf7, $ct_cf7_comment, $ct_options, $ct_data; 976 977 977 978 if (WPCF7_VERSION >= '3.0.0') { … … 1075 1076 */ 1076 1077 function ct_si_contact_form_validate($form_errors = array(), $form_id_num = 0) { 1077 global $ct_options ;1078 global $ct_options, $ct_data; 1078 1079 1079 1080 if (!empty($form_errors)) … … 1151 1152 */ 1152 1153 function ct_check_wplp(){ 1153 global $ct_wplp_result_label, $ct_options ;1154 global $ct_wplp_result_label, $ct_options, $ct_data; 1154 1155 if (!isset($_COOKIE[$ct_wplp_result_label])) { 1155 1156 // First AJAX submit of WPLP form … … 1212 1213 */ 1213 1214 function ct_s2member_registration_test() { 1214 global $ct_agent_version, $ct_post_data_label, $ct_post_data_authnet_label, $ct_formtime_label, $ct_options ;1215 global $ct_agent_version, $ct_post_data_label, $ct_post_data_authnet_label, $ct_formtime_label, $ct_options, $ct_data; 1215 1216 1216 1217 if ($ct_options['registrations_test'] == 0) {
Note: See TracChangeset
for help on using the changeset viewer.