wordpress使用郵件追蹤404頁面
來源:易賢網(wǎng) 閱讀:713 次 日期:2014-08-19 14:07:17
溫馨提示:易賢網(wǎng)小編為您整理了“wordpress使用郵件追蹤404頁面”,方便廣大網(wǎng)友查閱!

作為一個有意識的Web開發(fā)者/網(wǎng)站的所有者,你可能想跟蹤您的網(wǎng)站或博客的404頁。當然你可以分析你站點的訪問日志文件,但我們今天要講的是一個更好的追蹤方式,那就是通過發(fā)送郵件報告。這樣我么就能更加及時的獲取404頁面的情況。

如果你的主題沒有404.php文件,你必須創(chuàng)建他,然后將一下代碼添加到你的404頁面中:

注意:使用該方法前提是你的wordpress支持郵件發(fā)送。

// 設(shè)置頁面狀態(tài)

header("HTTP/1.1 404 Not Found");

header("Status: 404 Not Found");

// 站點信息

$blog = get_bloginfo('name');

$site = get_bloginfo('url') . '/';

$email = get_bloginfo('admin_email');

// 主題信息

if (!empty($_COOKIE["nkthemeswitch" . COOKIEHASH])) {

$theme = clean($_COOKIE["nkthemeswitch" . COOKIEHASH]);

} else {

$theme_data = wp_get_theme();

$theme = clean($theme_data->Name);

}

// 獲取來源地址

if (isset($_SERVER['HTTP_REFERER'])) {

$referer = clean($_SERVER['HTTP_REFERER']);

} else {

$referer = "undefined";

}

// 來源 URI

if (isset($_SERVER['REQUEST_URI']) && isset($_SERVER["HTTP_HOST"])) {

$request = clean('http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);

} else {

$request = "undefined";

}

// 查詢字符串

if (isset($_SERVER['QUERY_STRING'])) {

$string = clean($_SERVER['QUERY_STRING']);

} else {

$string = "undefined";

}

// IP 地址

if (isset($_SERVER['REMOTE_ADDR'])) {

$address = clean($_SERVER['REMOTE_ADDR']);

} else {

$address = "undefined";

}

// 用戶客戶端信息 agent

if (isset($_SERVER['HTTP_USER_AGENT'])) {

$agent = clean($_SERVER['HTTP_USER_AGENT']);

} else {

$agent = "undefined";

}

// 用戶連接協(xié)議

if (isset($_SERVER['REMOTE_IDENT'])) {

$remote = clean($_SERVER['REMOTE_IDENT']);

} else {

$remote = "undefined";

}

// 記錄時間

$time = clean(date("Y-m-d H:i:s", time()));

// 組合信息

function clean($string) {

$string = rtrim($string);

$string = ltrim($string);

$string = htmlentities($string, ENT_QUOTES);

$string = str_replace("n", "

", $string);

if (get_magic_quotes_gpc()) {

$string = stripslashes($string);

}

return $string;

}

$message =

"TIME: " . $time . "n" .

"*404: " . $request . "n" .

"SITE: " . $site . "n" .

"THEME: " . $theme . "n" .

"REFERRER: " . $referer . "n" .

"QUERY STRING: " . $string . "n" .

"REMOTE ADDRESS: " . $address . "n" .

"REMOTE IDENTITY: " . $remote . "n" .

"USER AGENT: " . $agent . "nnn";

// 發(fā)送郵件

mail($email, "404 Alert: " . $blog . " [" . $theme . "]", $message, "From: $email");

?>

更多信息請查看IT技術(shù)專欄

更多信息請查看CMS教程
易賢網(wǎng)手機網(wǎng)站地址:wordpress使用郵件追蹤404頁面
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇剩?/div>
相關(guān)閱讀CMS教程
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 加入群交流 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
聯(lián)系電話:0871-65317125(9:00—18:00) 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)