cari
Rumahpembangunan bahagian belakangtutorial phpPHP:404错误陷阱并email给管理员的程序_PHP教程
PHP:404错误陷阱并email给管理员的程序_PHP教程Jul 13, 2016 pm 05:19 PM
404emailphpdaripadaprogrampentadbirkesilapanperangkap


# 404.php, 8/10/2000.
# Traps 404 errors and mails a notice to the webmaster.
# Requires PHP 3.0 or newer, and mail capability on your system.
#
# Copyright 2000 shaun@shat.net under the GNU Public License.
# Disclaimer: I wrote this script for me, and it works for me.
# If it doesnt work for you, or makes your server explode,
# thats life. Please email with questions or bug reports.

# Set these variables to configure the script:

# Set $domain to your domain name (no www)

$domain = "your.domain.com";

# Set $docroot to the URL of the directory which contains your
# .htaccess file. Dont include trailing slash.

$docroot = "http://your.domain.com";

# Font face youd like to use on the 404 page

$fontface = "Verdana";

# Font size youd like to use on the 404 page

$fontsize = "2";

# Background color of the 404 page (default is white)

$bgcolor = "#ffffff";

# Text color youd like to use on the 404 page (default is black)

$textcolor = "#000000";

# This script is capable of mailing the details of each 404 error
# to the webmaster. Use the $reportlevel variable to control when
# you receive these reports.
#
# 0 = dont use the email capabilities at all
# 1 = send email only if the errors referer contains your domain name
# (i.e. the 404 was generated by a broken link on your site)
# 2 = send email any time a 404 error is generated (useful for tracking
# broken links at other sites which link to you)

$reportlevel = 2;

# Set $emailaddress to the email address of whoever should be
# notified of 404 errors. Dont escape the @ symbol. This will also
# be used as the "from" address on any emails the script generates.
# You can leave this unassigned if youre not using email features.

$emailaddress = "you@your.domain.com";

 

################################################################
# DONT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOURE DOING #
################################################################
# If you want to edit the script, Ive commented profusely :) #
################################################################

 

# The print_details function is what prints the 404 error to
# the visitor. As far as I know, PHP3 doesnt incorporate Perls
# print # but the script was written for PHP3. So, you have to use
# a lot of echo statements if you want to retain PHP3 compat.

function print_details()
{
# Request access to the global variables we need
global $fontface, $fontsize, $docroot, $REQUEST_URI, $reportlevel;
global $bgcolor, $textcolor

# Print the 404 error in web format
echo "

404 Not Found";
echo "";
echo "

404 Not Found

";
echo "

";
echo "Were sorry. The page you requested, $docroot$REQUEST_URI, doesnt exist";
echo " on this server.

";

# If an email report is being generated, let the visitor know:
if ($reportlevel != 0)
{
echo "

";
echo "The details of this error have automatically been mailed to the webmaster.";
}

# Close up the HTML tags
# echo "";

return;
}


# The send_email function sends the details of the 404 error to the
# webmaster.

function send_email()
{
# Request access to the global variables we need
global $REQUEST_URI, $HTTP_REFERER, $emailaddress, $REMOTE_ADDR, $docroot;

# Build the $errortime variable to contain the date/time of the error.
# Using date() likely would have been better, but I already had this code
# elsewhere, and Im lazy.
$today = getdate();
$month = $today[mon];
$mday = $today[mday];
$year = $today[year];
$hours = $today[hours];
$minutes = $today[minutes];
$errortime = "$month/$mday/$year at $hours:$minutes";

# Create the body of the email message
$message .= "404 Error Report A 404 error was encountered by $REMOTE_ADDR";
$message .= " on $errortime. ";
$message .= "The URI which generated the error is: $docroot$REQUEST_URI ";
$message .= "The referring page was: $HTTP_REFERER ";

# Send the mail message. This assumes mail() will work on your system!
mail("$emailaddress", "404 Error Report", $message, "From: $emailaddress");

return;
}


# Done with function declarations. Main function begins here.

# Send a 404 error to the users browser
print_details();

# See whether or not we should send an email report. If so, do it.
if ($reportlevel != 0)
if ($reportlevel == 1) {
if (eregi($domain,$HTTP_REFERER))
send_email(); }
else
send_email();

# All done!
exit;

?>


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/532620.htmlTechArticle? # 404.php, 8/10/2000. # Traps 404 errors and mails a notice to the webmaster. # Requires PHP 3.0 or newer, and mail capability on your system. # # Copyright 2000 shaun@shat.net u...
Kenyataan
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
php怎么把负数转为正整数php怎么把负数转为正整数Apr 19, 2022 pm 08:59 PM

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

php怎么实现几秒后执行一个函数php怎么实现几秒后执行一个函数Apr 24, 2022 pm 01:12 PM

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php怎么除以100保留两位小数php怎么除以100保留两位小数Apr 22, 2022 pm 06:23 PM

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

php怎么根据年月日判断是一年的第几天php怎么根据年月日判断是一年的第几天Apr 22, 2022 pm 05:02 PM

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php怎么判断有没有小数点php怎么判断有没有小数点Apr 20, 2022 pm 08:12 PM

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

php怎么替换nbsp空格符php怎么替换nbsp空格符Apr 24, 2022 pm 02:55 PM

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\&nbsp\;||\xc2\xa0)/","其他字符",$str)”语句。

php怎么设置implode没有分隔符php怎么设置implode没有分隔符Apr 18, 2022 pm 05:39 PM

在PHP中,可以利用implode()函数的第一个参数来设置没有分隔符,该函数的第一个参数用于规定数组元素之间放置的内容,默认是空字符串,也可将第一个参数设置为空,语法为“implode(数组)”或者“implode("",数组)”。

php字符串有没有下标php字符串有没有下标Apr 24, 2022 am 11:49 AM

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

See all articles

Alat AI Hot

Undresser.AI Undress

Undresser.AI Undress

Apl berkuasa AI untuk mencipta foto bogel yang realistik

AI Clothes Remover

AI Clothes Remover

Alat AI dalam talian untuk mengeluarkan pakaian daripada foto.

Undress AI Tool

Undress AI Tool

Gambar buka pakaian secara percuma

Clothoff.io

Clothoff.io

Penyingkiran pakaian AI

AI Hentai Generator

AI Hentai Generator

Menjana ai hentai secara percuma.

Alat panas

DVWA

DVWA

Damn Vulnerable Web App (DVWA) ialah aplikasi web PHP/MySQL yang sangat terdedah. Matlamat utamanya adalah untuk menjadi bantuan bagi profesional keselamatan untuk menguji kemahiran dan alatan mereka dalam persekitaran undang-undang, untuk membantu pembangun web lebih memahami proses mengamankan aplikasi web, dan untuk membantu guru/pelajar mengajar/belajar dalam persekitaran bilik darjah Aplikasi web keselamatan. Matlamat DVWA adalah untuk mempraktikkan beberapa kelemahan web yang paling biasa melalui antara muka yang mudah dan mudah, dengan pelbagai tahap kesukaran. Sila ambil perhatian bahawa perisian ini

Muat turun versi mac editor Atom

Muat turun versi mac editor Atom

Editor sumber terbuka yang paling popular

Dreamweaver Mac版

Dreamweaver Mac版

Alat pembangunan web visual

PhpStorm versi Mac

PhpStorm versi Mac

Alat pembangunan bersepadu PHP profesional terkini (2018.2.1).

SecLists

SecLists

SecLists ialah rakan penguji keselamatan muktamad. Ia ialah koleksi pelbagai jenis senarai yang kerap digunakan semasa penilaian keselamatan, semuanya di satu tempat. SecLists membantu menjadikan ujian keselamatan lebih cekap dan produktif dengan menyediakan semua senarai yang mungkin diperlukan oleh penguji keselamatan dengan mudah. Jenis senarai termasuk nama pengguna, kata laluan, URL, muatan kabur, corak data sensitif, cangkerang web dan banyak lagi. Penguji hanya boleh menarik repositori ini ke mesin ujian baharu dan dia akan mempunyai akses kepada setiap jenis senarai yang dia perlukan.