示例#1
0
 /**
  * コンストラクタ
  * @param $ip_host IPアドレスもしくはホスト
  */
 public function __construct($ip_host = null)
 {
     // 入力がIPか?
     $is_ip = preg_match(self::IP_MATCH_PATTERN, $ip_host);
     // IPアドレス(空欄時は、アクセスしてきたIPを指定)
     $this->ip = empty($ip) ? Utility::getRemoteIp() : (!$is_ip ? gethostbyname($ip_host) : $ip_host);
     // ホスト名で判断する
     $this->host = $is_ip ? gethostbyaddr($this->ip) : $this->ip;
 }
示例#2
0
 public static function check($postdata)
 {
     global $akismet_api_key;
     $akismet = new ZendService\Akismet($akismet_api_key, Router::get_script_absuri());
     if ($akismet->verifyKey($akismet_api_key)) {
         // 送信するデーターをセット
         $akismet_post = array('user_ip' => Utility::getRemoteIp(), 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null, 'comment_type' => 'comment', 'comment_author' => isset($vars['name']) ? $vars['name'] : self::DEFAULT_USER_NAME);
         if ($use_spam_check['akismet'] === 2) {
             $akismet_post['comment_content'] = $postdata;
         } else {
             // 差分のみをAkismetに渡す
             $akismet_post['comment_content'] = $addedata;
         }
         if ($akismet->isSpam($akismet_post)) {
             Utility::dieMessage('Writing was limited by Akismet (Blocking SPAM).', $_title['prohibit'], 400);
         }
     } else {
         Utility::dieMessage('Akismet API key does not valied.', 500);
     }
 }
示例#3
0
function get_remoteip()
{
    return Utility::getRemoteIp();
}
示例#4
0
 /**
  * 共通チェック
  */
 private function log_common_check()
 {
     // 認証中のユーザ名
     $username = Auth::check_auth();
     // 認証済の場合
     if ($this->config['auth_nolog'] && !empty($username)) {
         return null;
     }
     // タイムスタンプ
     $utime = UTIME;
     // リモートIPを取得
     $ip = Utility::getRemoteIp();
     if (isset($this->config[$this->kind]['nolog_ip'])) {
         // ロギング対象外IP
         foreach ($this->config[$this->kind]['nolog_ip'] as $nolog_ip) {
             if ($ip === $nolog_ip) {
                 return null;
             }
         }
     }
     $rc = array();
     $field = self::set_fieldname();
     foreach ($field as $key) {
         switch ($key) {
             case 'ts':
                 // タイムスタンプ (UTIME)
                 $rc[$key] = (int) $utime;
                 break;
             case 'ip':
                 // IPアドレス
                 $rc[$key] = $ip;
                 break;
             case 'host':
                 // ホスト名 (FQDN)
                 $rc[$key] = gethostbyaddr($ip);
                 break;
             case 'auth_api':
                 // 認証API名
                 //$obj = new auth_api();
                 //$msg = $obj->auth_session_get();
                 $rc[$key] = isset($msg['api']) && !empty($username) ? 'plus' : null;
                 break;
             case 'local_id':
                 $rc[$key] = isset($msg['local_id']) ? null : $msg['local_id'];
                 break;
             case 'user':
                 // ユーザ名(認証済)
                 $rc[$key] = $username;
                 break;
             case 'ntlm':
                 // ユーザ名(NTLM認証)
                 if (self::netbios_scope_check($ip, gethostbyaddr($ip))) {
                     $obj_nbt = new NetBios($ip);
                     $rc[$key] = $obj_nbt->username;
                     unset($obj_nbt);
                 } else {
                     $rc[$key] = null;
                 }
                 break;
             case 'proxy':
                 // Proxy情報
                 $obj_proxy = new ProxyChecker();
                 $rc[$key] = $obj_proxy->is_proxy() ? $obj_proxy->get_proxy_info() . '(' . $obj_proxy->get_realip() . ')' : null;
                 unset($obj_proxy);
                 break;
             case 'ua':
                 // ブラウザ情報
                 if (isset($_SERVER['HTTP_USER_AGENT'])) {
                     $rc[$key] = $_SERVER['HTTP_USER_AGENT'];
                 } else {
                     if (isset($_SERVER['ALL_HTTP'])) {
                         $rc[$key] = preg_match('/^HTTP_USER_AGENT:(.+)$/m', $_SERVER['ALL_HTTP'], $regs) ? $regs[1] : null;
                     }
                 }
                 break;
             case 'del':
                 // 削除フラグ
                 // 更新時は、削除されたか?
                 $rc[$key] = $this->kind === 'update' && Factory::Wiki($this->page)->has() ? null : 'DELETE';
                 break;
             case 'sig':
                 // 署名(曖昧)
                 $rc[$key] = self::log_set_signature($utime);
                 break;
             case 'file':
                 // ファイル名
                 $rc[$key] = $this->kind;
                 break;
             case 'page':
             case 'cmd':
                 $rc[$key] = $this->page;
                 break;
         }
     }
     return $rc;
 }