2022/05/22 15:55 JST
Geeklog Japan Forums
Google botによる404エラーログ
ページナビゲーション
状態: オフライン
kuro
Forum User
Active Member
登録日: 2010/03/10
投稿数: 445
Ivyさん、ごめんなさい。嘘ついてました。
自分では何もしてないつもりでしたが、
lib-custom.phpからCUSTOM_handle404.phpを呼び出してたようです。
lib-custom.phpにて
// 404
if (file_exists($_CONF['path'] . 'system/custom/custom_handle404.php')) {
require_once $_CONF['path'] . 'system/custom/custom_handle404.php';
}
となってて、
custom_handle404.phpを見ると、
<?php
function CUSTOM_handle404($alternate_url = '')
{
global $_CONF, $_USER, $LANG_404;
// send 404 in any case
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
if (isset($_SERVER['SCRIPT_URI'])) {
$url = $_SERVER['SCRIPT_URI'];
} else {
if (empty($_SERVER['HTTPS']) || ($_SERVER['HTTPS'] === 'off')) {
$url = 'http';
} else {
$url = 'https';
}
if (isset($_SERVER['SCRIPT_URI'])) {
$url .= '://' . @$_SERVER['HTTP_HOST'] . strip_tags($_SERVER['SCRIPT_URI']);
}
}
// Add log stuff
if (empty($_USER['uid'])) {
$byUser = 'anon@' . $_SERVER['REMOTE_ADDR'];
} else {
$byUser = $_USER['uid'] . '@' . $_SERVER['REMOTE_ADDR'];
}
$logEntry = "404 Error generated by {$byUser} for URL: {$url}";
// Add referer
if (!empty($_SERVER['HTTP_REFERER'])) {
$logEntry .= " - Referring URL: {$_SERVER['HTTP_REFERER']}";
}
// Add user agent
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$logEntry .= ' - User agent: ' . $_SERVER['HTTP_USER_AGENT'];
}
// Write into log file
$logEntry = str_replace(array('<?', '?>'), array('(@', '@)'), $logEntry);
$logEntry = @strftime('%c') . ' - ' . $logEntry . PHP_EOL;
@file_put_contents($_CONF['path_log'] . '404.log', $logEntry, FILE_APPEND | LOCK_EX);
$display = SP_returnStaticpage('_404');
COM_output($display);
exit; // Do not want to go any further
}
となっており、、、たぶんこのせいですよね?
404ログを「いいえ」にしてても書き込まれる原因は。
Ivy-we版を使ってるのですが、Ivy-we版だとこのような仕様になってのかも、、、です。
CUSTOM_handle404(l);を別に作成していてlib-custom.phpからそっちを呼んでいたりもしませんよね・・・
自分では何もしてないつもりでしたが、
lib-custom.phpからCUSTOM_handle404.phpを呼び出してたようです。
lib-custom.phpにて
PHP Formatted Code
// 404
if (file_exists($_CONF['path'] . 'system/custom/custom_handle404.php')) {
require_once $_CONF['path'] . 'system/custom/custom_handle404.php';
}
となってて、
custom_handle404.phpを見ると、
PHP Formatted Code
<?php
function CUSTOM_handle404($alternate_url = '')
{
global $_CONF, $_USER, $LANG_404;
// send 404 in any case
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
if (isset($_SERVER['SCRIPT_URI'])) {
$url = $_SERVER['SCRIPT_URI'];
} else {
if (empty($_SERVER['HTTPS']) || ($_SERVER['HTTPS'] === 'off')) {
$url = 'http';
} else {
$url = 'https';
}
if (isset($_SERVER['SCRIPT_URI'])) {
$url .= '://' . @$_SERVER['HTTP_HOST'] . strip_tags($_SERVER['SCRIPT_URI']);
}
}
// Add log stuff
if (empty($_USER['uid'])) {
$byUser = 'anon@' . $_SERVER['REMOTE_ADDR'];
} else {
$byUser = $_USER['uid'] . '@' . $_SERVER['REMOTE_ADDR'];
}
$logEntry = "404 Error generated by {$byUser} for URL: {$url}";
// Add referer
if (!empty($_SERVER['HTTP_REFERER'])) {
$logEntry .= " - Referring URL: {$_SERVER['HTTP_REFERER']}";
}
// Add user agent
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$logEntry .= ' - User agent: ' . $_SERVER['HTTP_USER_AGENT'];
}
// Write into log file
$logEntry = str_replace(array('<?', '?>'), array('(@', '@)'), $logEntry);
$logEntry = @strftime('%c') . ' - ' . $logEntry . PHP_EOL;
@file_put_contents($_CONF['path_log'] . '404.log', $logEntry, FILE_APPEND | LOCK_EX);
$display = SP_returnStaticpage('_404');
COM_output($display);
exit; // Do not want to go any further
}
となっており、、、たぶんこのせいですよね?
404ログを「いいえ」にしてても書き込まれる原因は。
Ivy-we版を使ってるのですが、Ivy-we版だとこのような仕様になってのかも、、、です。
状態: オフライン
sasabo-
Forum User
Chatty
登録日: 2008/03/31
投稿数: 57
横からスミマセン。
/system/custom/custom_handle404.php
上記ファイル内の次の行をコメントアウトすることで404.logの生成は止まりました。
@file_put_contents($_CONF['path_log'] . '404.log', $logEntry, FILE_APPEND | LOCK_EX);
ログの生成は止まるんですが、
存在しない記事、静的ページへのアクセスで、404ページではなく、
メモリエラーを出す症状は変わらないんですよね。。
Fatal error: Allowed memory size of 209715200 bytes exhausted (tried to allocate 20480 bytes) in /home/(省略)/system/databases/mysqli.class.php on line 829
存在しないページにアクセスしてるのはbotだけだと思われるので、とりあえず定期的にログを削除する作業は不要になりそうです。
/system/custom/custom_handle404.php
上記ファイル内の次の行をコメントアウトすることで404.logの生成は止まりました。
@file_put_contents($_CONF['path_log'] . '404.log', $logEntry, FILE_APPEND | LOCK_EX);
ログの生成は止まるんですが、
存在しない記事、静的ページへのアクセスで、404ページではなく、
メモリエラーを出す症状は変わらないんですよね。。
Fatal error: Allowed memory size of 209715200 bytes exhausted (tried to allocate 20480 bytes) in /home/(省略)/system/databases/mysqli.class.php on line 829
存在しないページにアクセスしてるのはbotだけだと思われるので、とりあえず定期的にログを削除する作業は不要になりそうです。
状態: オフライン
terayama
Forum User
Active Member
登録日: 2007/02/16
投稿数: 265
Ivy-we版をお使いでしたら
custom_handle404.phpを使わないように
lib-custom.phpの途中にある
// 404
if (file_exists($_CONF['path'] . 'system/custom/custom_handle404.php'
) {
require_once $_CONF['path'] . 'system/custom/custom_handle404.php';
}
を
末尾と同じ
/* 404 */
//if (file_exists($_CONF['path'] . 'system/custom/custom_handle404.php'Wink) {
// require_once $_CONF['path'] . 'system/custom/custom_handle404.php';
//}
にするほうがいいのではないでしょうか
custom_handle404.phpを使わないように
lib-custom.phpの途中にある
// 404
if (file_exists($_CONF['path'] . 'system/custom/custom_handle404.php'

require_once $_CONF['path'] . 'system/custom/custom_handle404.php';
}
を
末尾と同じ
/* 404 */
//if (file_exists($_CONF['path'] . 'system/custom/custom_handle404.php'Wink) {
// require_once $_CONF['path'] . 'system/custom/custom_handle404.php';
//}
にするほうがいいのではないでしょうか
状態: オフライン
kuro
Forum User
Active Member
登録日: 2010/03/10
投稿数: 445
terayamaさま、
コメントありがとうございます。
はい。その通りでした。
lib-common.phpは元に戻して、
lib-custom.phpをterayamaさんのご指摘どおりにしたところ、
普通にコンフィグで「いいえ」にすると機能するようになり、
ログは記録されなくなりました。
コメントありがとうございます。
末尾と同じ
/* 404 */
//if (file_exists($_CONF['path'] . 'system/custom/custom_handle404.php'Wink) {
// require_once $_CONF['path'] . 'system/custom/custom_handle404.php';
//}
にするほうがいいのではないでしょうか
/* 404 */
//if (file_exists($_CONF['path'] . 'system/custom/custom_handle404.php'Wink) {
// require_once $_CONF['path'] . 'system/custom/custom_handle404.php';
//}
にするほうがいいのではないでしょうか
はい。その通りでした。
lib-common.phpは元に戻して、
lib-custom.phpをterayamaさんのご指摘どおりにしたところ、
普通にコンフィグで「いいえ」にすると機能するようになり、
ログは記録されなくなりました。
ページナビゲーション
時刻はすべて JST , 現在の時刻は 03:55 PM
- 通常
- 注目トピック
- ロック済
- 新着
- 注目トピック 新着
- ロック済トピック 新着
- ゲストユーザの投稿を見る
- 投稿可能
- 一部のHTMLを許可
- バッドワードをチェック
検索
ユーザー機能
リモートログイン
イベント
-