我的注册表单导致 500 内部服务器错误。该页面在脚本执行之前超时(来自服务器人员)。“脚本在返回标头之前超时:index.php,”我不是 php 开发人员,但使用它并自定义它,所以我不知道会导致什么这个。是表格和感谢页面中的内容吗?希望这里的人可能有一些想法。我打开了php错误报告,没有显示错误。该错误提到了“标题”,所以想知道它是否是以下行: header("Location: $thanksPage"); - 感谢您的帮助...
// OPTIONS - PLEASE CONFIGURE THESE BEFORE USE!
error_reporting(E_ALL);
ini_set('display_errors', '1');
$yourEmail = "my@email.com"; // the email address you wish to receive these mails through
$yourWebsite = "Maine Firearm Instruction"; // the name of your website
$thanksPage = 'thanks.php'; // URL to 'thanks for sending mail' page; leave empty to keep message on the same page
$maxPoints = 4; // max points a person can hit before it refuses to submit - recommend 4
// DO NOT EDIT BELOW HERE
$error_msg = null;
$result = null;
function isBot() {
$bots = array("Indy", "Blaiz", "Java", "libwww-perl", "Python", "OutfoxBot", "User- Agent", "PycURL", "AlphaServer", "T8Abot", "Syntryx", "WinHttp", "WebBandit", "nicebot");
$isBot = false;
foreach ($bots as $bot)
if (strpos($_SERVER['HTTP_USER_AGENT'], $bot) !== false)
$isBot = true;
if (empty($_SERVER['HTTP_USER_AGENT']) || $_SERVER['HTTP_USER_AGENT'] == " ")
$isBot = true;
exit("Bots not allowed.</p>");
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
function clean($data) {
$data = trim(stripslashes(strip_tags($data)));
return $data;
}
// lets check a few things - not enough to trigger an error on their own, but worth assigning a spam score..
// score quickly adds up therefore allowing genuine users with 'accidental' score through but cutting out real spam :)
$points = (int)0;
$badwords = array("adult", "beastial", "bestial", "blowjob", "clit", "cum", "cunilingus", "cunillingus", "cunnilingus", "cunt", "ejaculate", "fag", "felatio", "fellatio", "fuck", "fuk", "fuks", "gangbang", "gangbanged", "gangbangs", "hotsex", "hardcode", "jism", "jiz", "orgasim", "orgasims", "orgasm", "orgasms", "phonesex", "phuk", "phuq", "porn", "pussies", "pussy", "spunk", "xxx", "viagra", "phentermine", "tramadol", "adipex", "advai", "alprazolam", "ambien", "ambian", "amoxicillin", "antivert", "blackjack", "backgammon", "texas", "holdem", "poker", "carisoprodol", "ciara", "ciprofloxacin", "debt", "dating", "porn", "link=", "voyeur");
$exploits = array("content-type", "bcc:", "cc:", "document.cookie", "onclick", "onload", "javascript");
foreach ($badwords as $word)
if (strpos($_POST['comments'], $word) !== false)
$points += 2;
foreach ($exploits as $exploit)
if (strpos($_POST['comments'], $exploit) !== false)
$points += 2;
if (strpos($_POST['comments'], "http://") !== false || strpos($_POST['comments'], "www.") !== false)
$points += 2;
if (isset($_POST['nojs']))
$points += 1;
if (preg_match("/(<.*>)/i", $_POST['comments']))
$points += 2;
if (strlen($_POST['name']) < 3)
$points += 1;
if (strlen($_POST['comments']) < 15 || strlen($_POST['comments'] > 1500))
$points += 2;
// end score assignments
foreach ($_POST as $key => $value)
$_POST[$key] = trim($value);
if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['ename']) || empty($_POST['ephone']) || empty($_POST['age']) || empty($_POST['class']) || empty($_POST['pay'])) {
$error_msg .= "Required fields are noted with an asterisk '*'. \n";
} elseif (strlen($_POST['name']) > 20) {
$error_msg .= "The name field is limited at 20 characters. \n";
} elseif (!preg_match("/^[a-zA-Z-'\s]*$/", stripslashes($_POST['name']))) {
$error_msg .= "The name field must not contain special characters. \n";
} elseif (!preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i', strtolower($_POST['email']))) {
$error_msg .= "Invalid email address - please enter a valid e-mail address. \n";
}
if ($error_msg == NULL && $points <= $maxPoints) {
$subject = "MFAI online registration";
$subject2 = "MFAI Online Registration";
$message = "The following MFAI class registration was submitted from the MFAI website: \n\n";
$message2 = "Thank you for registering for a MFAI class. We've received the following information: \n\n";
foreach ($_POST as $key => $val) {
$message .= ucwords($key) . ": " . clean($val) . "\r\n";
$message2 .= ucwords($key) . ": " . clean($val) . "\r\n";
}
$message .= 'IP: '.$_SERVER['REMOTE_ADDR']."\r\n";
$message .= 'Browser: '.$_SERVER['HTTP_USER_AGENT']."\r\n";
$message .= 'Points: '.$points;
$message2 .= "Please let us know if you have any questions prior to class. We look forward to seeing you at class! \r\n Maine Firearm Instruction, LLC \r\n 207.754.8014 \r\n chris@mainefirearminstruction.com";
if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) {
$headers = "From: $yourEmail \r\n";
$headers .= "Reply-To: $yourEmail";
} else {
$headers = "From: $yourWebsite <$yourEmail> \r\n";
$headers .= "Reply-To: $yourEmail";
}
if (mail($yourEmail,$subject,$message,$headers)) {
if (!empty($thanksPage)) {
if( (!empty( $_POST['pay'])) && ($_POST['pay'] != "please select") && (!empty( $_POST['acfga-member'] )) )
{
//redirect here
session_start();
unset($_SESSION['name']);
unset($_SESSION['phone']);
unset($_SESSION['cphone']);
unset($_SESSION['email']);
unset($_SESSION['address']);
unset($_SESSION['city']);
unset($_SESSION['state']);
unset($_SESSION['zip']);
unset($_SESSION['age']);
unset($_SESSION['ename']);
unset($_SESSION['ephone']);
unset($_SESSION['class']);
unset($_SESSION['pay']);
unset($_SESSION['comments']);
unset($_SESSION['howfind']);
unset($_SESSION['other']);
unset($_SESSION['acfga-member']);
$_SESSION['name'] = $_POST['name'];
$_SESSION['phone'] = $_POST['phone'];
$_SESSION['cphone'] = $_POST['cphone'];
$_SESSION['email'] = $_POST['email'];
$_SESSION['address'] = $_POST['address'];
$_SESSION['city'] = $_POST['city'];
$_SESSION['state'] = $_POST['state'] ;
$_SESSION['zip'] = $_POST['zip'];
$_SESSION['age'] = $_POST['age'];
$_SESSION['ename'] = $_POST['ename'];
$_SESSION['ephone'] = $_POST['ephone'];
$_SESSION['class'] = $_POST['class'];
$_SESSION['pay'] = $_POST['pay'];
$_SESSION['comments'] = $_POST['comments'];
$_SESSION['howfind'] = $_POST['howfind'];
$_SESSION['other'] = $_POST['other'];
$_SESSION['acfga-member'] = $_POST['acfga-member'];
//print_r($_SESSION['plan']);
//print_r($_SESSION['pay']);
//header("Refresh: 0; url=".$thanksPage."");
header("Location: $thanksPage");
//exit;
}
} else {
$result = 'Your registraiton was successfully sent.';
}
} else {
$error_msg = 'Your registration could not be sent this time.';
}
} else {
if (empty($error_msg))
$error_msg = 'Your message looks too much like spam, and could not be sent this time. ['.$points.']';
}
}
function get_data($var) {
if (isset($_POST[$var]))
echo htmlspecialchars($_POST[$var]);
}