function spamshield_log_data($wpss_log_data_array, $wpss_log_data_errors, $wpss_log_comment_type = 'comment', $wpss_log_contact_form_data = NULL, $wpss_log_contact_form_id = NULL, $wpss_log_contact_form_mcid = NULL) { /*** * Example: * Comment: spamshield_log_data( $commentdata, $wpss_error_code ) * Contact Form: spamshield_log_data( $contact_form_author_data, $wpss_error_code, 'contact form', $wpss_contact_form_msg, $wpss_contact_form_mid, $wpss_contact_form_mcid ); * Registration: spamshield_log_data( $register_author_data, $wpss_error_code, 'register' ); * BP Reg: spamshield_log_data( $register_author_data, $wpss_error_code, 'bp-register' ); * WooCommerce Reg: spamshield_log_data( $register_author_data, $wpss_error_code, 'wc-register' ); * S2 Reg: spamshield_log_data( $register_author_data, $wpss_error_code, 's2-register' ); * WP-Members Reg: spamshield_log_data( $register_author_data, $wpss_error_code, 'wpm-register' ); * Contact Form 7: spamshield_log_data( $form_auth_dat, $wpss_error_code, 'contact form 7', $cf7_serial_post ); * Gravity Forms: spamshield_log_data( $form_auth_dat, $wpss_error_code, 'gravity forms', $gf_serial_post ); * Miscellaneous Form: spamshield_log_data( $form_auth_dat, $wpss_error_code, 'misc form', $msc_serial_post ); * JetPack Form: spamshield_log_data( $form_auth_dat, $wpss_error_code, 'jetpack form', $msc_serial_post ); * Ninja Forms: spamshield_log_data( $form_auth_dat, $wpss_error_code, 'ninja forms', $msc_serial_post ); ***/ spamshield_log_reset(NULL, FALSE, FALSE, TRUE); /* Create log file if it doesn't exist */ $wpss_log_key = spamshield_get_log_key(); $wpss_log_filename = strpos(RSMP_SERVER_NAME_REV, RSMP_MDBUG_SERVER_NAME_REV) === 0 ? 'temp-comments-log.txt' : 'temp-comments-log-' . $wpss_log_key . '.txt'; $wpss_log_empty_filename = 'temp-comments-log.init.txt'; $wpss_log_file = WPSS_PLUGIN_DATA_PATH . '/' . $wpss_log_filename; $wpss_log_max_filesize = 2 * 1048576; /* 2 MB */ if (empty($wpss_log_comment_type)) { $wpss_log_comment_type = 'comment'; } $wpss_log_comment_type_display = spamshield_casetrans('upper', $wpss_log_comment_type); $wpss_log_comment_type_ucwords = spamshield_casetrans('ucwords', $wpss_log_comment_type); $wpss_log_comment_type_ucwords_ref_disp = preg_replace("~\\sform~i", "", $wpss_log_comment_type_ucwords); $noda = '[No Data]'; $wpss_display_name = $wpss_user_firstname = $wpss_user_lastname = $wpss_user_email = $wpss_user_url = $wpss_user_login = $wpss_user_id = ''; $wpss_user_logged_in = FALSE; if (is_user_logged_in()) { global $current_user; get_currentuserinfo(); $wpss_display_name = $current_user->display_name; $wpss_user_firstname = $current_user->user_firstname; $wpss_user_lastname = $current_user->user_lastname; $wpss_user_email = $current_user->user_email; $wpss_user_url = $current_user->user_url; $wpss_user_login = $current_user->user_login; $wpss_user_id = $current_user->ID; $wpss_user_logged_in = TRUE; } $spamshield_options = get_option('spamshield_options'); spamshield_update_session_data($spamshield_options); $wpss_log_session_data = spamshield_get_log_session_data(); extract($wpss_log_session_data); global $wpss_active_plugins; if (empty($wpss_active_plugins)) { $wpss_active_plugins = get_option('active_plugins'); } $wpss_active_plugins_str = implode(', ', $wpss_active_plugins); global $wpss_cl_active; if (empty($wpss_cl_active)) { $wpss_cl_active = spamshield_is_plugin_active('commentluv/commentluv.php'); } $wpss_time_end = spamshield_microtime(); if (empty($wpss_time_init) && !empty($wpss_timestamp_init)) { $wpss_time_init = $wpss_timestamp_init; } if (!empty($wpss_time_init)) { $wpss_time_on_site = spamshield_timer($wpss_time_init, $wpss_time_end, TRUE, 2); } else { $wpss_time_on_site = $noda; } if (!empty($wpss_timestamp_init)) { $wpss_site_entry_time = get_date_from_gmt(date('Y-m-d H:i:s', $wpss_timestamp_init), 'Y-m-d (D) H:i:s e'); /* Added 1.7.3 */ } else { $wpss_site_entry_time = $noda; } $comment_logging = $spamshield_options['comment_logging']; $comment_logging_start_date = $spamshield_options['comment_logging_start_date']; $comment_logging_all = $spamshield_options['comment_logging_all']; if (!empty($wpss_log_data_array['javascript_page_referrer'])) { $wpss_javascript_page_referrer = $wpss_log_data_array['javascript_page_referrer']; } else { $wpss_javascript_page_referrer = ''; } if (!empty($wpss_log_data_array['jsonst'])) { $wpss_jsonst = $wpss_log_data_array['jsonst']; } else { $wpss_jsonst = ''; } $get_current_time = time(); /* Updated next line in Version 1.1.4.4 - Display local time in logs. Won't match other time logs, because those need to be UTC. */ $get_current_time_display = current_time('timestamp', 0); $reset_interval_hours = 24 * 7; /* Reset interval in hours */ $reset_interval_minutes = 60; /* Reset interval minutes default */ $reset_interval_minutes_override = $reset_interval_minutes; /* Use as override for testing; leave = $reset_interval_minutes when not testing */ if ($reset_interval_minutes_override != $reset_interval_minutes) { $reset_interval_hours = 1; $reset_interval_minutes = $reset_interval_minutes_override; } /* Default is one week */ $reset_interval = 60 * $reset_interval_minutes * $reset_interval_hours; /* seconds * minutes * hours */ if (strpos(RSMP_SERVER_NAME_REV, RSMP_DEBUG_SERVER_NAME_REV) === 0) { $reset_interval = $reset_interval * 4; } $time_threshold = $get_current_time - $reset_interval; /* This turns off if over x amount of time since starting, or filesize exceeds max */ if (!empty($comment_logging_start_date) && $time_threshold > $comment_logging_start_date || file_exists($wpss_log_file) && filesize($wpss_log_file) >= $wpss_log_max_filesize) { $comment_logging = $comment_logging_start_date = $comment_logging_all = 0; /* Turns logging off */ $spamshield_options['comment_logging'] = $comment_logging; $spamshield_options['comment_logging_start_date'] = $comment_logging_start_date; $spamshield_options['comment_logging_all'] = $comment_logging_all; update_option('spamshield_options', $spamshield_options); } else { /* LOG DATA */ $wpss_log_datum = date('Y-m-d (D) H:i:s', $get_current_time_display); $wpss_log_URL = spamshield_get_url(); $wpss_IS_AJAX = spamshield_is_ajax_request() ? 'TRUE' : 'FALSE'; $wpss_IS_COMMENT = spamshield_is_comment_request() ? 'TRUE' : 'FALSE'; $wpss_IS_404 = is_404() ? 'TRUE' : 'FALSE'; $wpss_log_data = "*************************************************************************************\n"; $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $wpss_log_data .= ":: " . $wpss_log_comment_type_display . " BEGIN ::" . "\n"; $submitter_ip_address = spamshield_get_ip_addr(); $submitter_ip_address_short_l = trim(substr($submitter_ip_address, 0, 6)); $submitter_ip_address_short_r = trim(substr($submitter_ip_address, -6, 2)); $submitter_ip_address_obfuscated = $submitter_ip_address_short_l . '****' . $submitter_ip_address_short_r . '.***'; /* IP / PROXY INFO - BEGIN */ global $wpss_ip_proxy_info; if (empty($wpss_ip_proxy_info)) { $wpss_ip_proxy_info = spamshield_ip_proxy_info(); } extract($wpss_ip_proxy_info); /* IP / PROXY INFO - END */ $wpss_spamshield_count = spamshield_number_format(spamshield_count()); if ($wpss_log_comment_type == 'comment' || $wpss_log_comment_type == 'contact form') { $body_content_length = spamshield_number_format($wpss_log_data_array['body_content_len']); } else { $body_content_length = ''; } if ($wpss_log_comment_type == 'comment') { $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; /* Comment Post Info */ $comment_author_email = $wpss_log_data_array['comment_author_email']; $comment_types_allowed = ''; if (!empty($wpss_log_data_array['comment_post_comments_open'])) { $comment_post_comments_open = 'Open'; $comment_types_allowed .= 'comments'; } else { $comment_post_comments_open = 'Closed'; } if (!empty($wpss_log_data_array['comment_post_pings_open'])) { $comment_post_pings_open = 'Open'; if (!empty($comment_types_allowed)) { $comment_types_allowed .= ','; } $comment_types_allowed .= 'pingbacks,trackbacks'; } else { $comment_post_pings_open = 'Closed'; } if (empty($comment_types_allowed)) { $comment_types_allowed = 'none, comments closed'; } $comment_post_type_ucw = spamshield_casetrans('ucwords', $wpss_log_data_array['comment_post_type']); $wpss_log_data .= "Date/Time: \t\t['" . $wpss_log_datum . "']\n"; $wpss_log_data .= "Comment Post ID: \t['" . $wpss_log_data_array['comment_post_ID'] . "']\n"; $wpss_log_data .= "Comment Post Title: \t['" . $wpss_log_data_array['comment_post_title'] . "']\n"; $wpss_log_data .= "Comment Post URL: \t['" . $wpss_log_data_array['comment_post_url'] . "']\n"; $wpss_log_data .= "Comment Post Type: \t['" . $wpss_log_data_array['comment_post_type'] . "']\n"; $wpss_log_data .= $comment_post_type_ucw . " Allows Types:\t['" . $comment_types_allowed . "']\n"; $wpss_log_data .= "Comment Type: \t\t['"; if (!empty($wpss_log_data_array['comment_type'])) { $wpss_log_data .= $wpss_log_data_array['comment_type']; } else { $wpss_log_data .= "comment"; } $wpss_log_data .= "']"; $wpss_log_data .= "\n"; $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $wpss_log_data .= "Comment Author: \t['" . $wpss_log_data_array['comment_author'] . "']\n"; $wpss_log_data .= "Comment Author Email: \t['" . $comment_author_email . "']\n"; $wpss_log_data .= "Comment Author URL: \t['" . $wpss_log_data_array['comment_author_url'] . "']\n"; $wpss_log_data .= "Comment Content: " . "\n['comment_content_begin']\n" . $wpss_log_data_array['comment_content'] . "\n['comment_content_end']\n"; $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $wpss_log_data .= "WPSSCID: \t\t['" . $wpss_log_data_array['comment_wpss_cid'] . "']\n"; /* Added 1.7.7 - WPSS Comment ID */ $wpss_log_data .= "WPSSCCID:\t\t['" . $wpss_log_data_array['comment_wpss_ccid'] . "']\n"; /* Added 1.7.7 - WPSS Comment Content ID */ } elseif (strpos($wpss_log_comment_type, 'register') !== FALSE) { $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $wpss_log_data .= "Date/Time: \t\t['" . $wpss_log_datum . "']\n"; if (empty($wpss_log_data_array['ID'])) { $wpss_log_data_array['ID'] = '[None]'; } $wpss_log_data .= "User ID: \t\t['" . $wpss_log_data_array['ID'] . "']\n"; $wpss_log_data .= "User Login: \t\t['" . $wpss_log_data_array['user_login'] . "']\n"; $wpss_log_data .= "Display Name: \t\t['" . $wpss_log_data_array['display_name'] . "']\n"; $wpss_log_data .= "First Name: \t\t['" . $wpss_log_data_array['user_firstname'] . "']\n"; $wpss_log_data .= "Last Name: \t\t['" . $wpss_log_data_array['user_lastname'] . "']\n"; $wpss_log_data .= "User Email: \t\t['" . $wpss_log_data_array['user_email'] . "']\n"; if (empty($wpss_log_data_array['user_url'])) { $wpss_log_data_array['user_url'] = '[None]'; } $wpss_log_data .= "User URL: \t\t['" . $wpss_log_data_array['user_url'] . "']\n"; } elseif ($wpss_log_comment_type == 'contact form') { $wpss_log_contact_form_subject = !empty($_POST['wpss_contact_subject']) ? sanitize_text_field($_POST['wpss_contact_subject']) : ''; $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $wpss_log_data .= "Date/Time: \t\t['" . $wpss_log_datum . "']\n"; $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $wpss_log_data .= "Subject: \t\t['" . $wpss_log_contact_form_subject . "']\n"; $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $wpss_log_data .= $wpss_log_contact_form_data; $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $wpss_log_data .= "WPSSMID: \t\t['" . $wpss_log_contact_form_id . "']\n"; /* Added 1.7.7 - WPSS Message ID */ $wpss_log_data .= "WPSSMCID:\t\t['" . $wpss_log_contact_form_mcid . "']\n"; /* Added 1.7.7 - WPSS Message Content ID */ } elseif (strpos($wpss_log_comment_type, 'form') !== FALSE) { $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $wpss_log_data .= "Date/Time: \t\t['" . $wpss_log_datum . "']\n"; $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $form_post_data_arr = unserialize($wpss_log_contact_form_data); $form_post_data_disp = ''; foreach ($form_post_data_arr as $k => $v) { if (is_array($v)) { $v = implode('|', $v); } $form_post_data_disp .= $k . ': ' . trim(stripslashes($v)) . "\n"; } $wpss_log_data .= $form_post_data_disp; } $wpss_sessions_enabled = isset($_SESSION) ? 'Enabled' : 'Disabled'; /* Sanitized versions for output */ $wpss_http_accept_language = spamshield_get_http_accept(FALSE, FALSE, TRUE); $wpss_http_accept = spamshield_get_http_accept(); $server_x_req_w = spamshield_get_server_x_req_w(); $wpss_http_user_agent = spamshield_get_user_agent(); $wpss_http_referer = spamshield_get_referrer(); /* Not original ref - Comment Processor Referrer */ $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; if ($wpss_user_logged_in != FALSE) { $wpss_log_data .= "User ID: \t\t['" . $wpss_user_id . "']\n"; } $wpss_log_data .= "IP Address: \t\t['" . $ip . "'] ['http://ipaddressdata.com/" . $ip . "']\n"; $wpss_log_data .= "Reverse DNS: \t\t['" . $reverse_dns . "']\n"; $wpss_log_data .= "Reverse DNS IP: \t['" . $reverse_dns_ip . "']\n"; $wpss_log_data .= "FCrDNS Verified: \t['" . $reverse_dns_verification . "']\n"; /* Forward-confirmed reverse DNS (FCrDNS) */ $wpss_log_data .= "Proxy Info: \t\t['" . $ip_proxy . "']\n"; $wpss_log_data .= "Proxy Data: \t\t['" . $ip_proxy_data . "']\n"; $wpss_log_data .= "Proxy Status: \t\t['" . $proxy_status . "']\n"; if (empty($ip_proxy_via)) { $ip_proxy_via = '[None]'; } $wpss_log_data .= "HTTP_VIA: \t\t['" . $ip_proxy_via . "']\n"; if (empty($masked_ip)) { $masked_ip = '[None]'; } $wpss_log_data .= "HTTP_X_FORWARDED_FOR: \t['" . $masked_ip . "']\n"; $wpss_log_data .= "HTTP_ACCEPT_LANGUAGE: \t['" . $wpss_http_accept_language . "']\n"; $wpss_log_data .= "HTTP_ACCEPT: \t\t['" . $wpss_http_accept . "']\n"; $wpss_log_data .= "HTTP_X_REQUESTED_WITH: \t['" . $server_x_req_w . "']\n"; $wpss_log_data .= "IS_AJAX: \t\t['" . $wpss_IS_AJAX . "']\n"; $wpss_log_data .= "IS_COMMENT: \t\t['" . $wpss_IS_COMMENT . "']\n"; $wpss_log_data .= "404: \t\t\t['" . $wpss_IS_404 . "']\n"; $wpss_log_data .= "User-Agent: \t\t['" . $wpss_http_user_agent . "']\n"; $wpss_log_data .= "URL: \t\t\t['" . $wpss_log_URL . "']\n"; $wpss_log_data .= "Form Processor Ref: \t['"; if (!empty($wpss_http_referer)) { $wpss_log_data .= $wpss_http_referer; } else { $wpss_log_data .= '[None]'; } $wpss_log_data .= "']"; $wpss_log_data .= "\n"; $wpss_log_data .= "JS Page Ref: \t\t['"; if (!empty($wpss_javascript_page_referrer)) { $wpss_log_data .= $wpss_javascript_page_referrer; } else { $wpss_log_data .= '[None]'; } $wpss_log_data .= "']"; $wpss_log_data .= "\n"; $wpss_log_data .= "JSONST: \t\t['"; if (!empty($wpss_jsonst)) { $wpss_log_data .= $wpss_jsonst; } else { $wpss_log_data .= '[None]'; } $wpss_log_data .= "']"; $wpss_log_data .= "\n"; /* New Data Section - Begin */ if (strpos(RSMP_SERVER_NAME_REV, RSMP_DEBUG_SERVER_NAME_REV) === 0) { if (!empty($_SESSION)) { $wpss_log_data_serial_session = serialize($_SESSION); } else { $wpss_log_data_serial_session = ''; } if (!empty($_COOKIE)) { $wpss_log_data_serial_cookie = serialize($_COOKIE); } else { $wpss_log_data_serial_cookie = ''; } if (!empty($_GET)) { $wpss_log_data_serial_get = serialize($_GET); } else { $wpss_log_data_serial_get = ''; } if (!empty($_POST)) { $wpss_log_data_post_raw = $_POST; switch ($wpss_log_comment_type) { case 'comment': unset($wpss_log_data_post_raw['comment']); break; case 'contact form': unset($wpss_log_data_post_raw['wpss_contact_message']); break; } $wpss_log_data_serial_post = serialize($wpss_log_data_post_raw); } else { $wpss_log_data_serial_post = ''; } if (!empty($_SERVER['REQUEST_METHOD'])) { $wpss_server_request_method = $_SERVER['REQUEST_METHOD']; } else { $wpss_server_request_method = ''; } $wpss_mem_used = spamshield_wp_memory_used(); if (!empty($_SESSION['user_spamshield_count_' . RSMP_HASH])) { $wpss_user_spamshield_count = $_SESSION['user_spamshield_count_' . RSMP_HASH]; } else { $wpss_user_spamshield_count = 0; } if (!empty($_SESSION['user_spamshield_count_jsck_' . RSMP_HASH])) { $wpss_jsck_spamshield_count = $_SESSION['user_spamshield_count_jsck_' . RSMP_HASH]; } else { $wpss_jsck_spamshield_count = 0; } if (!empty($_SESSION['user_spamshield_count_algo_' . RSMP_HASH])) { $wpss_algo_spamshield_count = $_SESSION['user_spamshield_count_algo_' . RSMP_HASH]; } else { $wpss_algo_spamshield_count = 0; } $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $wpss_log_data .= "PHP Session ID: \t['" . $wpss_session_id . "']\n"; $wpss_log_data .= "PHP Session Cookie: \t['" . $wpss_session_ck . "']\n"; $wpss_log_data .= "Sess ID/CK Match: \t['" . $wpss_session_verified . "']\n"; $wpss_log_data .= "Page Hits: \t\t['" . $wpss_page_hits . "']\n"; $wpss_log_data .= "Last Page Hit: \t\t['" . $wpss_last_page_hit . "']\n"; $wpss_log_data .= "Hits Per Page: " . "\n['hits_per_page_begin']" . $wpss_hits_per_page . "['hits_per_page_end']\n"; $wpss_log_data .= "Original IP: \t\t['" . $wpss_user_ip_init . "']\n"; $wpss_log_data .= "IP History: \t\t['" . $wpss_ip_history . "']\n"; $wpss_log_data .= "Time on Site: \t\t['" . $wpss_time_on_site . "']\n"; $wpss_log_data .= "Site Entry Time: \t['" . $wpss_site_entry_time . "']\n"; /* Added 1.7.3 */ $wpss_log_data .= "Landing Page: \t\t['" . $wpss_referer_init . "']\n"; /* PHP */ $wpss_log_data .= "Original Referrer: \t['" . $wpss_referer_init_js . "']\n"; /* JS */ $wpss_log_data .= "Author History:\t\t['" . $wpss_author_history . "']\n"; $wpss_log_data .= "Email History:\t\t['" . $wpss_author_email_history . "']\n"; $wpss_log_data .= "URL History: \t\t['" . $wpss_author_url_history . "']\n"; $wpss_log_data .= "Entries Accepted: \t['" . $wpss_comments_accepted . "']\n"; $wpss_log_data .= "Entries Denied: \t['" . $wpss_comments_denied . "']\n"; $wpss_log_data .= "Spam Count: \t\t['" . $wpss_spamshield_count . "']\n"; /* Added 1.8 */ $wpss_log_data .= "User Spam Count: \t['" . $wpss_user_spamshield_count . "']\n"; /* Added 1.8 */ $wpss_log_data .= "JSCK Spam Count: \t['" . $wpss_jsck_spamshield_count . "']\n"; /* Added 1.8.9.6 */ $wpss_log_data .= "ALGO Spam Count: \t['" . $wpss_algo_spamshield_count . "']\n"; /* Added 1.8.9.6 */ $wpss_log_data .= "Current Status: \t['" . $wpss_comments_status_current . "']\n"; /* Changed 1.8 */ $wpss_log_data .= "REQUEST_METHOD: \t['" . $wpss_server_request_method . "']\n"; if ($wpss_log_comment_type == 'comment' || $wpss_log_comment_type == 'contact form') { $wpss_log_data .= "Content Length: \t['" . $body_content_length . "']\n"; } $wpss_log_data .= '$_COOKIE' . " Data:\t\t['" . $wpss_log_data_serial_cookie . "']\n"; $wpss_log_data .= '$_GET' . " Data: \t\t['" . $wpss_log_data_serial_get . "']\n"; $wpss_log_data .= 'MOD $_POST' . " Data:\t['" . $wpss_log_data_serial_post . "']\n"; $wpss_log_data .= "CL Active: \t\t['" . $wpss_cl_active . "']\n"; $wpss_log_data .= "Mem Used: \t\t['" . $wpss_mem_used . "']\n"; $wpss_log_data .= "Extra Data: \t\t['" . $wpss_append_log_data . "']\n"; } /* New Data Section - End */ $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; if (strpos($wpss_log_data_errors, 'No Error') === 0) { /* Changed 1.8 */ $wpss_log_data_errors_count = 0; } else { $wpss_log_data_errors_count = spamshield_count_words($wpss_log_data_errors); } if (empty($wpss_log_data_errors)) { $wpss_log_data_errors = 'No Error'; } if ($wpss_log_comment_type == 'comment') { if (empty($wpss_log_data_array['total_time_jsck_filter'])) { $wpss_total_time_jsck_filter = 0; } else { $wpss_total_time_jsck_filter = $wpss_log_data_array['total_time_jsck_filter']; } $wpss_total_time_jsck_filter_disp = spamshield_number_format($wpss_total_time_jsck_filter, 6); if (empty($wpss_log_data_array['total_time_content_filter'])) { $wpss_total_time_content_filter = 0; } else { $wpss_total_time_content_filter = $wpss_log_data_array['total_time_content_filter']; } $wpss_total_time_content_filter_disp = spamshield_number_format($wpss_total_time_content_filter, 6); $wpss_start_time_comment_processing = $wpss_log_data_array['start_time_comment_processing']; /* Timer End - Comment Processing */ $wpss_end_time_comment_processing = spamshield_microtime(); $wpss_total_time_wpss_processing = $wpss_total_time_jsck_filter + $wpss_total_time_content_filter; $wpss_total_time_wpss_processing_disp = spamshield_number_format($wpss_total_time_wpss_processing, 6); $wpss_total_time_comment_processing = spamshield_timer($wpss_start_time_comment_processing, $wpss_end_time_comment_processing, FALSE, 6, TRUE); $wpss_total_time_comment_proc_disp = spamshield_number_format($wpss_total_time_comment_processing, 6); $wpss_total_time_wp_processing = $wpss_total_time_comment_processing - $wpss_total_time_wpss_processing; $wpss_total_time_wp_processing_disp = spamshield_number_format($wpss_total_time_wp_processing, 6); if (!empty($wpss_total_time_jsck_filter_disp) || !empty($wpss_total_time_content_filter_disp) || !empty($wpss_total_time_wpss_processing_disp)) { $wpss_log_data .= "JS/C Processing Time: \t['" . $wpss_total_time_jsck_filter_disp . " seconds'] Time for JS/Cookies Layer to test for spam\n"; $wpss_log_data .= "Algo Processing Time: \t['" . $wpss_total_time_content_filter_disp . " seconds'] Time for Algorithmic Layer to test for spam\n"; $wpss_log_data .= "WPSS Processing Time: \t['" . $wpss_total_time_wpss_processing_disp . " seconds'] Total time for WP-SpamShield to test for spam\n"; } if (strpos(RSMP_SERVER_NAME_REV, RSMP_DEBUG_SERVER_NAME_REV) === 0) { $wpss_total_time_part_1 = $wpss_log_data_array['total_time_part_1']; $wpss_total_time_part_1_disp = spamshield_number_format($wpss_total_time_part_1, 6); $wpss_proc_data = get_option('spamshield_procdat'); if (empty($wpss_proc_data) || !isset($wpss_proc_data['total_wpss_time']) || !isset($wpss_proc_data['total_comment_proc_time'])) { $wpss_proc_data = array('total_tracked' => 0, 'total_wpss_time' => 0, 'avg_wpss_proc_time' => 0, 'total_comment_proc_time' => 0, 'avg_comment_proc_time' => 0, 'total_wpss_avg_tracked' => 0, 'total_avg_wpss_proc_time' => 0, 'avg2_wpss_proc_time' => 0); } if (!isset($wpss_proc_data['total_wpss_avg_tracked'])) { $wpss_proc_data['total_wpss_avg_tracked'] = 0; } if (!isset($wpss_proc_data['total_avg_wpss_proc_time'])) { $wpss_proc_data['total_avg_wpss_proc_time'] = 0; } if (!isset($wpss_proc_data['avg2_wpss_proc_time'])) { $wpss_proc_data['avg2_wpss_proc_time'] = 0; } $wpss_proc_data_total_tracked = $wpss_proc_data['total_tracked'] + 1; $wpss_proc_data_total_wpss_time = $wpss_proc_data['total_wpss_time'] + $wpss_total_time_wpss_processing; $wpss_proc_data_avg_wpss_proc_time = $wpss_proc_data_total_wpss_time / $wpss_proc_data_total_tracked; $wpss_proc_data_total_comment_proc_time = $wpss_proc_data['total_comment_proc_time'] + $wpss_total_time_comment_processing; $wpss_proc_data_avg_comment_proc_time = $wpss_proc_data_total_comment_proc_time / $wpss_proc_data_total_tracked; $wpss_proc_data_total_wpss_avg_tracked = $wpss_proc_data['total_wpss_avg_tracked'] + 1; $wpss_proc_data_total_avg_wpss_proc_time = $wpss_proc_data['total_avg_wpss_proc_time'] + $wpss_proc_data_avg_wpss_proc_time; $wpss_proc_data_avg2_wpss_proc_time = $wpss_proc_data_total_avg_wpss_proc_time / $wpss_proc_data_total_wpss_avg_tracked; $wpss_proc_data = array('total_tracked' => $wpss_proc_data_total_tracked, 'total_wpss_time' => $wpss_proc_data_total_wpss_time, 'avg_wpss_proc_time' => $wpss_proc_data_avg_wpss_proc_time, 'total_comment_proc_time' => $wpss_proc_data_total_comment_proc_time, 'avg_comment_proc_time' => $wpss_proc_data_avg_comment_proc_time, 'total_wpss_avg_tracked' => $wpss_proc_data_total_wpss_avg_tracked, 'total_avg_wpss_proc_time' => $wpss_proc_data_total_avg_wpss_proc_time, 'avg2_wpss_proc_time' => $wpss_proc_data_avg2_wpss_proc_time); update_option('spamshield_procdat', $wpss_proc_data); $wpss_proc_data_avg_wpss_proc_time_disp = spamshield_number_format($wpss_proc_data_avg_wpss_proc_time, 6); $wpss_proc_data_avg2_wpss_proc_time_disp = spamshield_number_format($wpss_proc_data_avg2_wpss_proc_time, 6); $wpss_proc_data_avg_comment_proc_time_disp = spamshield_number_format($wpss_proc_data_avg_comment_proc_time, 6); $wpss_log_data .= "WP Processing Time:\t['" . $wpss_total_time_wp_processing_disp . " seconds'] Time for other WordPress processes\n"; $wpss_log_data .= "Total Processing Time: \t['" . $wpss_total_time_comment_proc_disp . " seconds'] Total time for WordPress to process comment\n"; $wpss_log_data .= "Avg WPSS Proc Time:\t['" . $wpss_proc_data_avg_wpss_proc_time_disp . " seconds'] Average total time for WP-SpamShield to test for spam\n"; $wpss_log_data .= "FAvg WPSS Proc Time:\t['" . $wpss_proc_data_avg2_wpss_proc_time_disp . " seconds'] Fuzzy Average total WPSS time\n"; $wpss_log_data .= "Avg Total Proc Time:\t['" . $wpss_proc_data_avg_comment_proc_time_disp . " seconds'] Average total time for WordPress to process comments\n"; } $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; } $wpss_log_data .= "Failed Tests: \t\t['" . $wpss_log_data_errors_count . "']\n"; $wpss_log_data .= "Failed Test Codes: \t['" . $wpss_log_data_errors . "']\n"; $wpss_log_data .= "Spam Count: \t\t['" . $wpss_spamshield_count . "']\n"; /* Added 1.8 */ $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $wpss_log_data .= "Debugging Data:\t\t['PHP MemLimit: " . RSMP_PHP_MEM_LIMIT . "; WP MemLimit: " . WP_MEMORY_LIMIT . "; Sessions: " . $wpss_sessions_enabled . "']\n"; $wpss_log_data .= "Site Server Name:\t['" . RSMP_SERVER_NAME . "']\n"; $wpss_log_data .= "Site Server IP:\t\t['" . RSMP_SERVER_ADDR . "']\n"; $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $wpss_log_data .= "Active Plugins:\t\t['" . $wpss_active_plugins_str . "']\n"; $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $wpss_log_data .= RSMP_USER_AGENT . "\n"; $wpss_log_data .= RSMP_PHP_UNAME . "\n"; $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $wpss_log_data .= ":: " . $wpss_log_comment_type_display . " END ::" . "\n"; $wpss_log_data .= "-------------------------------------------------------------------------------------\n"; $wpss_log_data .= "*************************************************************************************\n\n\n"; $wpss_log_fp = @fopen($wpss_log_file, 'a+'); @fwrite($wpss_log_fp, $wpss_log_data); @fclose($wpss_log_fp); } }
function spamshield_first_action() { spamshield_start_session(); /* Add all commands after this */ /* Add Vars Here */ $key_main_page_hits = 'wpss_page_hits_' . RSMP_HASH; $key_main_pages_hist = 'wpss_pages_hit_' . RSMP_HASH; $key_main_hits_per_page = 'wpss_pages_hit_count_' . RSMP_HASH; $key_first_ref = 'wpss_referer_init_' . RSMP_HASH; $current_ref = spamshield_get_referrer(); $key_auth_hist = 'wpss_author_history_' . RSMP_HASH; $key_comment_auth = 'comment_author_' . RSMP_HASH; $key_email_hist = 'wpss_author_email_history_' . RSMP_HASH; $key_auth_url_hist = 'wpss_author_url_history_' . RSMP_HASH; if (empty($_SESSION['wpss_user_ip_init_' . RSMP_HASH])) { $_SESSION['wpss_user_ip_init_' . RSMP_HASH] = $_SERVER['REMOTE_ADDR']; } if (empty($_SESSION['wpss_user_agent_init_' . RSMP_HASH])) { $_SESSION['wpss_user_agent_init_' . RSMP_HASH] = spamshield_get_user_agent(); } $_SESSION['wpss_version_' . RSMP_HASH] = WPSS_VERSION; $_SESSION['wpss_site_url_' . RSMP_HASH_ALT] = RSMP_SITE_URL; $_SESSION['wpss_plugin_url_' . RSMP_HASH_ALT] = WPSS_PLUGIN_URL; $_SESSION['wpss_user_ip_current_' . RSMP_HASH] = $_SERVER['REMOTE_ADDR']; $_SESSION['wpss_user_agent_current_' . RSMP_HASH] = spamshield_get_user_agent(); if (!is_admin() && !current_user_can('moderate_comments')) { /* Page hits */ if (empty($_SESSION[$key_main_page_hits])) { $_SESSION[$key_main_page_hits] = 0; } ++$_SESSION[$key_main_page_hits]; /* Pages visited history */ if (empty($_SESSION[$key_main_pages_hist])) { $_SESSION[$key_main_pages_hist] = array(); $_SESSION[$key_main_hits_per_page] = array(); } $_SESSION[$key_main_pages_hist][] = spamshield_get_url(); /* Initial referrer */ if (empty($_SESSION[$key_first_ref])) { if (!empty($current_ref)) { $_SESSION[$key_first_ref] = $current_ref; } else { $_SESSION[$key_first_ref] = '[No Data]'; } } if (!empty($_COOKIE[$key_comment_auth])) { $stored_author_data = spamshield_get_author_data(); $stored_author = $stored_author_data['comment_author']; $stored_author_email = $stored_author_data['comment_author_email']; $stored_author_url = $stored_author_data['comment_author_url']; if (empty($_SESSION[$key_auth_hist]) && !empty($stored_author)) { $_SESSION[$key_auth_hist] = array(); $_SESSION[$key_auth_hist][] = $stored_author; } if (empty($_SESSION[$key_email_hist]) && !empty($stored_author_email)) { $_SESSION[$key_email_hist] = array(); $_SESSION[$key_email_hist][] = $stored_author_email; } if (empty($_SESSION[$key_auth_url_hist]) && !empty($stored_author_url)) { $_SESSION[$key_auth_url_hist] = array(); $_SESSION[$key_auth_url_hist][] = $stored_author_url; } } } }