* bug fix: if the no_verify field was blank, e-mail verifications would not go out.

* added option to turn on PHPMailer debug mode
This commit is contained in:
tomo 2023-07-01 18:43:00 -06:00 committed by Retro_Guy
parent 532d22a495
commit 2646e652a7
1 changed files with 74 additions and 59 deletions

View File

@ -1,3 +1,4 @@
<?php
include "config.inc.php";
@ -108,6 +109,7 @@ if(isset($_POST['command']) && $_POST['command'] == 'CreateNew') {
$CONFIG['verify_email'] = false;
}
}
if($CONFIG['verify_email'] == true) {
$saved_code = file_get_contents(sys_get_temp_dir()."/".$username);
if((strcmp(trim($code), trim($saved_code))) !== 0) {
@ -323,15 +325,17 @@ if ($ok || ($command == "Create") )
{
echo 'Create account: '.$_POST['username'].'<br/><br />';
/* Generate email */
# only check for no verification is the field has been populated
if (!empty($CONFIG['no_verify']))
{
$no_verify=explode(' ', $CONFIG['no_verify']);
foreach($no_verify as $no) {
if (strlen($_SERVER['HTTP_HOST']) - strlen($no) === strrpos($_SERVER['HTTP_HOST'],$no)) {
$CONFIG['verify_email'] = false;
}
}
}
if($CONFIG['verify_email']) {
# Log email address attempts to avoid abuse
if(file_exists($email_registry)) {
$tried_email = unserialize(file_get_contents($email_registry));
@ -348,6 +352,9 @@ $mail->SMTPOptions = array(
);
$mail->IsSMTP();
#uncomment below to enable debugging
#$mail->SMTPDebug = 3;
$mail->CharSet = 'UTF-8';
$mail->Host = $mailer['host'];
$mail->SMTPAuth = true;
@ -374,11 +381,18 @@ $msg.="This is your account creation code: ".$mycode."\n\n";
$msg.="Note: replies to this email address are checked daily.";
$mail->Body = wordwrap($msg,70);
$mail->send();
if (!$mail->send())
{
echo 'The message could not be sent.';
echo '<p>Error: ' . $mail->ErrorInfo;
}
else
{
echo 'An email has been sent to '.$user_email.'<br />';
echo 'Please enter the code from the email below:<br />';
}
}
echo '<form name="create1" method="post" action="register.php">';
if($CONFIG['verify_email'] == true) {
echo '<input name="code" type="text" id="code">&nbsp;';
@ -390,7 +404,8 @@ $mail->send();
echo '<input name="key" type="hidden" value="'.password_hash($keys[0], PASSWORD_DEFAULT).'">';
echo '<input type="submit" name="Submit" value="Click Here to Create"></td>';
echo '<br/><br/><a href="'.$CONFIG['default_content'].'">Cancel and return to home page</a>';
} else {
}
else {
echo "Authentication Failed\r\n";
exit(1);
}