/** * (アクセスユーザの)リモートホストを取得する * * @param string $empty gethostbyaddr() がIPを返した時の時の代替文字。 * @return string */ function getRemoteHost($empty = '') { // gethostbyaddr() は、同じ実行スクリプト内でもキャッシュしないようなのでキャッシュする static $gethostbyaddr_ = null; if (isset($_SERVER['REMOTE_HOST'])) { return $_SERVER['REMOTE_HOST']; } if (php_sapi_name() == 'cli') { return 'cli'; } if (is_null($gethostbyaddr_)) { require_once P2_LIB_DIR . '/HostCheck.php'; $gethostbyaddr_ = HostCheck::cachedGetHostByAddr($_SERVER['REMOTE_ADDR']); } return $gethostbyaddr_ == $_SERVER['REMOTE_ADDR'] ? $empty : $gethostbyaddr_; }