示例#1
0
 function akismet($values)
 {
     $content = FrmEntriesHelper::entry_array_to_string($values);
     if (empty($content)) {
         return false;
     }
     $datas = array();
     $datas['blog'] = FrmAppHelper::site_url();
     $datas['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
     $datas['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
     $datas['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : false;
     $datas['comment_type'] = 'formidable';
     if ($permalink = get_permalink()) {
         $datas['permalink'] = $permalink;
     }
     $datas['comment_content'] = $content;
     foreach ($_SERVER as $key => $value) {
         if (!in_array($key, array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW')) && is_string($value)) {
             $datas["{$key}"] = $value;
         } else {
             $datas["{$key}"] = '';
         }
         unset($key, $value);
     }
     $query_string = '';
     foreach ($datas as $key => $data) {
         $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
         unset($key, $data);
     }
     if (is_callable('Akismet::http_post')) {
         $response = Akismet::http_post($query_string, 'comment-check');
     } else {
         global $akismet_api_host, $akismet_api_port;
         $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
     }
     return (is_array($response) and $response[1] == 'true') ? true : false;
 }
 /**
  * Check entries for spam
  *
  * @return boolean true if is spam
  */
 public static function akismet($values)
 {
     $content = FrmEntriesHelper::entry_array_to_string($values);
     if (empty($content)) {
         return false;
     }
     $datas = array();
     self::parse_akismet_array($datas, $content);
     $query_string = '';
     foreach ($datas as $key => $data) {
         $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
         unset($key, $data);
     }
     $response = Akismet::http_post($query_string, 'comment-check');
     return is_array($response) && $response[1] == 'true';
 }