Skip to content

Commit

Permalink
Merge pull request #39 from paintballrefjosh/bug-fixes
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
Josh authored Mar 29, 2017
2 parents 6800cca + 7aeb022 commit b2a81ed
Show file tree
Hide file tree
Showing 34 changed files with 6,340 additions and 2,846 deletions.
24 changes: 10 additions & 14 deletions core/SDL/class.account.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,13 @@ function register($params, $account_extend = NULL)
}

// Send the activation email
$act_link = (string)$mwe_config['site_base_href'].'?p=account&sub=activate&id='.$u_id.'&key='.$tmp_act_key;
$email_text = '== Account activation =='."\n\n";
$email_text .= 'Username: '.$params['username']."\n";
$email_text .= 'Password: '.$password."\n";
$email_text .= 'This is your activation key: '.$tmp_act_key."\n";
$email_text .= 'CLICK HERE : '.$act_link."\n";
send_email($params['email'], $params['username'], '== '.(string)$mwe_config['site_title'].' account activation ==', $email_text, false);
$act_link = (string)$mwe_config['site_base_href'] . $mwe_config['site_href'] . "?p=account&sub=activate&id=$u_id&key=$tmp_act_key";
$email_text = $mwe_config['site_title'] . " Account activation<br /><br />";
$email_text .= 'Username: '.$params['username']."<br />";
$email_text .= 'Password: '.$password."<br />";
$email_text .= 'This is your activation key: '.$tmp_act_key."<br />";
$email_text .= 'CLICK HERE : '.$act_link."<br />";
send_email($params['email'], $mwe_config['site_title'].' - Account Activation', $email_text, false);
return 1;
}

Expand Down Expand Up @@ -1045,14 +1045,10 @@ function addOrUpdateAccountKeys($id, $key)

function removeAccountKeyForUser($id)
{
$count = $this->DB->selectRow("SELECT * FROM mw_account_keys where id ='$id'");
if($count == FALSE)
{
//do nothing
}
else
$count = $this->DB->count("SELECT `id` FROM `mw_account_keys` where `id` ='$id'");
if($count == 1)
{
$this->DB->query("DELETE FROM mw_account_keys WHERE id ='$id'");
$this->DB->query("DELETE FROM `mw_account_keys` WHERE `id` ='$id'");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/class.update.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function check_for_updates()
// check if local list file exists, this is only used when the update/ directory exists
$this->update_list = file("update_list.txt");
}
elseif(file_exists("https://raw.githubusercontent.com/paintballrefjosh/MaNGOSWebV4/master/update/update_list.txt"))
else
{
// check if GitHub list file exists
$this->update_list = file("https://raw.githubusercontent.com/paintballrefjosh/MaNGOSWebV4/master/update/update_list.txt");
Expand Down
108 changes: 45 additions & 63 deletions core/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function getRealmlist()
{
global $DB;

$realms = $DB->select("SELECT * FROM `mw_realm` ORDER BY `realm_id` ASC");
$realms = $DB->select("SELECT * FROM `mw_realm` WHERE `site_enabled` = 1 ORDER BY `realm_id` ASC");

return $realms;
}
Expand Down Expand Up @@ -202,74 +202,56 @@ function print_gold($gvar)
//===== MAIL FUNCTIONS =====//

// Send Mail
function send_email($goingto, $toname, $sbj, $messg, $notice = true)
function send_email($email_to, $email_subject, $email_message, $notice = true)
{
global $mwe_config;
define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors
$core_em = $mwe_config['site_email'];

// If email type "0" (SMTP)
if($mwe_config['email_type'] == 0)
{
require_once 'core/mail/SMTP.php'; // path to 'SMTP.php' file from XPM4 package

$f = ''.$core_em.''; // from mail address
$t = ''.$goingto.''; // to mail address

// standard mail message RFC2822
$m = 'From: '.$f."\r\n".
'To: '.$t."\r\n".
'Subject: '.$sbj."\r\n".
'Content-Type: text/plain'."\r\n\r\n".
''.$messg.'';

$h = explode('@', $t); // get client hostname
$c = SMTP::MXconnect($h[1]); // connect to SMTP server (direct) from MX hosts list
$s = SMTP::Send($c, array($t), $m, $f); // send mail
// print result
if($notice)if ($s) output_message('success', 'Mail Sent!');
else output_message('error', print_r($_RESULT));
SMTP::Disconnect($c); // disconnect
}
elseif($mwe_config['email_type'] == 1) // If email type "1" (MIME)
{
require_once 'core/mail/MIME.php'; // path to 'MIME.php' file from XPM4 package

// compose message in MIME format
$mess = MIME::compose($messg);
// send mail
$send = mail($goingto, $sbj, $mess['content'], 'From: '.$core_em.''."\n".$mess['header']);
// print result
if($notice)echo $send ? output_message('success', 'Mail Sent!') : output_message('error', 'Error!');
}
elseif($mwe_config['email_type'] == 2) // If email type "2" (MTA Relay)
{
require_once 'core/mail/MAIL.php'; // path to 'MAIL.php' file from XPM4 package

$m = new MAIL; // initialize MAIL class
$m->From($core_em); // set from address
$m->AddTo($goingto); // add to address
$m->Subject($sbj); // set subject
$m->Html($messg); // set html message
if($mwe_config['email_use_secure'] == 1)
{
$smtp_encryption = $mwe_config['email_smtp_secure'];
}
else
{
$smtp_encryption = false;
}

// connect to MTA server 'smtp.hostname.net' port '25' with authentication: 'username'/'password'
if($mwe_config['email_use_secure'] == 1)
{
$c = $m->Connect($mwe_config['email_smtp_host'], $mwe_config['email_smtp_port'], $mwe_config['email_smtp_user'], $mwe_config['email_smtp_pass'], $mwe_config['email_smtp_secure'])
or die(print_r($m->Result));
}
else
{
$c = $m->Connect($mwe_config['email_smtp_host'], $mwe_config['email_smtp_port'], $mwe_config['email_smtp_user'], $mwe_config['email_smtp_pass'])
or die(print_r($m->Result));
}
require("core/mail/PHPMailerAutoload.php");

$mail = new PHPMailer;

$mail->SMTPDebug = 0;
$mail->Debugoutput = 'html';
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $mwe_config['email_smtp_host']; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $mwe_config['email_smtp_user']; // SMTP username
$mail->Password = $mwe_config['email_smtp_pass']; // SMTP password
$mail->SMTPSecure = $smtp_encryption; // 'tls', 'ssl' or false
$mail->Port = $mwe_config['email_smtp_port']; // TCP port to connect to
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);

$mail->setFrom($mwe_config['site_email'], $mwe_config['site_title']);
$mail->addAddress($email_to); // Add a recipient

// send mail relay using the '$c' resource connection
if($notice)echo $m->Send($c) ? output_message('success', 'Mail Sent!') : output_message('error', 'Error! Please check your config and make sure you inserted your MTA info correctly.');
$mail->isHTML(true); // Set email format to HTML

$m->Disconnect(); // disconnect from server
// print_r($m->History); // optional, for debugging
}
$mail->Subject = $email_subject;
$mail->Body = $email_message;

if(!$mail->send())
{
output_message("error", '<b>Error!</b> Message could not be sent.<br />Mailer Error: ' . $mail->ErrorInfo);
}
elseif($notice)
{
output_message("success", "Your message has been sent successfully.");
}
}

// ************************************************************
Expand Down
31 changes: 0 additions & 31 deletions core/mail/FUNC.php

This file was deleted.

33 changes: 0 additions & 33 deletions core/mail/MAIL.php

This file was deleted.

33 changes: 0 additions & 33 deletions core/mail/MIME.php

This file was deleted.

Loading

0 comments on commit b2a81ed

Please sign in to comment.