Cloudflare経由または不使用の場合に正しく利用者のIPアドレスを取得出来るように分岐を設定

This commit is contained in:
konkon-fox 2023-10-21 23:22:36 +09:00
parent 171bc1e921
commit f7f09ad5ce
3 changed files with 6 additions and 2 deletions

0
test/.use_cloudflare Normal file
View File

View File

@ -10,7 +10,9 @@ if (getenv('SKIP_VERIFICATION')) {
$FORCESSL = false;
}
$NOWTIME = time();
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
if (file_exists(__DIR__ . '/.use_cloudflare') && isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}
$HOST = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$area = [];
$area["district"] = $area['proxy'] = $area['hosting'] = $area['regionName'] = $area['city'] = $area['countryCode'] = $area['mobile'] = $area["asname"] = '';

View File

@ -23,7 +23,9 @@ if(isset($SETTING['date_comma_digit']) && $SETTING['date_comma_digit'] !== '0'){
}else{
$DATE = date("Y/m/d H:i:s", $NOWTIME);
}
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
if (file_exists(__DIR__ . '/.use_cloudflare') && isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}
$HOST = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$subjectfile = $PATH."subject.json"; //スレッド一覧
$LTLFILE = $PATH."index.json"; //ローカルタイムライン