该脚本是由其他人编写的,当涉及到php时,我最多也是新手。我知道它之前有用,但现在切换到新服务器并升级到php7后,我没有从滚轮输出。没有电子邮件,没有任何东西。请告诉我,有人可以告诉我有什么问题,可能还有如何解决它!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Dice Handler</title>
</head>
<body>
<?php // Functions ------------------------------------------
function rollDice($dice)
{
$faceArray = array();
for($i = 0; $i < $dice; $i++) {
$face = rand(1, 10);
$faceArray[$i] = $face;
}
return $faceArray;
}
;
function is_valid_email($email)
{
return preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s]+\.+[a-z]{2,6}))$#si', $email);
}
function contains_bad_str($str_to_test)
{
$bad_strings = array(
"content-type:",
"mime-version:",
"multipart/mixed",
"Content-Transfer-Encoding:",
"bcc:",
"cc:",
"to:"
);
foreach($bad_strings as $bad_string) {
if(eregi($bad_string, strtolower($str_to_test))) {
echo "$bad_string found. Suspected injection attempt - mail not being sent.";
exit;
}
}
}
function contains_newlines($str_to_test)
{
if(preg_match("/(%0A|%0D|\\n+|\\r+)/i", $str_to_test) != 0) {
echo "newline found in $str_to_test. Suspected injection attempt - mail not being sent.";
exit;
}
}
// Code -------------------------------------------
$name = $_POST['requiredname'];
$dice = $_POST['requireddice'];
$description = $_POST['requireddescription'];
$email = $_POST['requiredemail'];
if(!is_valid_email($email)) {
echo 'Invalid email submitted - mail not being sent.';
exit;
}
contains_bad_str($email);
contains_bad_str($description);
contains_newlines($email);
contains_newlines($description);
$faces = rollDice($dice);
for($i = 0; $i < (count($faces) - 1); $i++) {
$results = $results . $faces[$i] . ", ";
}
$results = $results . $faces[$i] . ", ";
echo ($results);
function redirect($url)
{
header('Location: http://www.nybn.org/diceform.php ' . $url, true);
die();
}
// email results //
$to = 'dicerolls@nybn.org' . ',';
$to .= $email;
$subject = "Dice roll for $name";
$message = "$name rolled a $results for $description";
$headers = "From: " . $from . "\r\n" . "Reply-To: " . $from . "\r\n" . "X-Mailer: PHP/" . phpversion();
$headers .= 'From: NYbN Dice Roller <dicerolls@nybn.org>' . "\r\n";
mail($to, $subject, $message, $headers);
?>
</body>
</html>