/** * Verifies the email against WangGuard service * * @global type $wpdb * @global type $wangguard_api_key * @global type $wangguard_user_check_status * @param type $email * @param type $clientIP * @param type $callingFromRegularWPHook regular WP hook sends true on this param * @return boolean */ function wangguard_is_email_reported_as_sp($email, $clientIP, $ProxyIP, $callingFromRegularWPHook = false) { global $wpdb; global $wangguard_api_key; global $wangguard_user_check_status; if (empty($wangguard_api_key)) { return false; } $wangguard_user_check_status = "not-checked"; if (get_site_option("wangguard-do-not-check-client-ip") == '1') { $clientIP = ''; $ProxyIP = ''; } $response = wangguard_http_post("wg=<in><apikey>{$wangguard_api_key}</apikey><email>" . $email . "</email><ip>" . $clientIP . "</ip><proxyip>" . $ProxyIP . "</proxyip></in>", 'query-email.php'); $responseArr = XML_unserialize($response); wangguard_stats_update("check"); if (is_array($responseArr)) { if ($responseArr['out']['cod'] == '10' || $responseArr['out']['cod'] == '11') { wangguard_stats_update("detected"); return true; } else { if ($responseArr['out']['cod'] == '20') { $wangguard_user_check_status = 'checked'; } elseif ($responseArr['out']['cod'] == '100') { $wangguard_user_check_status = 'error:' . __('Your WangGuard API KEY is invalid.', 'wangguard'); } else { $wangguard_user_check_status = 'error:' . $responseArr['out']['cod']; } } } return false; }
/** * wangguard_verify_email: takes a WP_User object and checks its status against WangGuard service, possible responses are: * * @param string $email: e-mail address to check * @param string $clientIP: client IP * @param string $proxyIP: client proxy ip if available - use the wangguard_getRemoteProxyIP() function to get the client proxy ip * @return string: * not-checked : user was not checked, admins aren't checked, also replied when a WangGuard server error occurs * reported : user is reported on WangGuard * checked : user isn't reported on WangGuard * error:XXX : WangGuard server replied with an error code (mostly protocol issues) */ function wangguard_verify_email($email, $clientIP, $proxyIP = '') { global $wangguard_api_key; $user_check_status = "not-checked"; wangguard_stats_update("check"); if (get_site_option("wangguard-do-not-check-client-ip") == '1') { $clientIP = ''; $proxyIP = ''; } //Rechecks the user agains WangGuard service $response = wangguard_http_post("wg=<in><apikey>{$wangguard_api_key}</apikey><email>" . $email . "</email><ip>" . $clientIP . "</ip><proxyip>" . $proxyIP . "</proxyip></in>", 'query-email.php'); $responseArr = XML_unserialize($response); if (is_array($responseArr)) { if ($responseArr['out']['cod'] == '10' || $responseArr['out']['cod'] == '11') { $user_check_status = 'reported'; wangguard_stats_update("detected"); } else { if ($responseArr['out']['cod'] == '20') { $user_check_status = 'checked'; } else { $user_check_status = 'error:' . $responseArr['out']['cod']; } } } return $user_check_status; }