/** * This function is beign used to login a user. * It will first check if the sent POST data returns a match with the DB, if it does, some session variables will be appointed to the user and he will be redirected to the index page again. * If it didn't match, the template will be reloaded and a matching error message will be shown. * @author Daan Janssens, mentored by Matthew Lagoe */ function login() { global $INGAME_WEBPATH; global $WEBPATH; try { $login_value = filter_var($_POST['LoginValue'], FILTER_SANITIZE_STRING); $password = filter_var($_POST['Password'], FILTER_SANITIZE_STRING); //check if the filtered sent POST data returns a match with the DB $result = WebUsers::checkLoginMatch($login_value, $password); if ($result != "fail") { //handle successful login $_SESSION['user'] = $result['Login']; $_SESSION['id'] = $result['UId']; $_SESSION['ticket_user'] = serialize(Ticket_User::constr_ExternId($_SESSION['id'])); $user = new WebUsers($_SESSION['id']); $_SESSION['Language'] = $user->getLanguage(); $GETString = ""; foreach ($_GET as $key => $value) { $GETString = $GETString . $key . '=' . $value . "&"; } if ($GETString != "") { $GETString = '?' . $GETString; } //go back to the index page. header("Cache-Control: max-age=1"); if (Helpers::check_if_game_client()) { header('Location: ' . $INGAME_WEBPATH . $GETString); } else { header('Location: ' . $WEBPATH . $GETString); } throw new SystemExit(); } else { //handle login failure $result = array(); $result['login_error'] = 'TRUE'; $result['no_visible_elements'] = 'TRUE'; helpers::loadtemplate('login', $result); throw new SystemExit(); } } catch (PDOException $e) { //go to error page or something, because can't access website db print_r($e); throw new SystemExit(); } }
/** * Wrapper for sending emails, creates the content of the email * Based on the type of the ticketing mail it will create a specific email, it will use the language.ini files to load the correct language of the email for the receiver. * Also if the $TICKET_MAILING_SUPPORT is set to false or if the user's personal 'ReceiveMail' entry is set to false then no mail will be sent. * @param $receiver if integer, then it refers to the id of the user to whom we want to mail, if it's a string(email-address) then we will use that. * @param $ticketObj the ticket object itself, this is being used for including ticket related information into the email. * @param $content the content of a reply or new ticket * @param $type REPLY, NEW, WARNAUTHOR, WARNSENDER, WARNUNKNOWNSENDER * @param $sender (default = 0 (if it is not forwarded)) else use the id of the support group to which the ticket is currently forwarded, the support groups email address will be used to send the ticket. */ public static function send_ticketing_mail($receiver, $ticketObj, $content, $type, $sender = 0) { global $TICKET_MAILING_SUPPORT; if ($TICKET_MAILING_SUPPORT) { global $MAIL_LOG_PATH; //error_log("Receiver: {$receiver}, content: {$content}, type: {$type}, SendingId: {$sender} \n", 3, $MAIL_LOG_PATH); if ($sender == 0) { //if it is not forwarded (==public == which returns 0) then make it NULL which is needed to be placed in the DB. $sender = NULL; } global $AMS_TRANS; if (is_numeric($receiver)) { $webUser = new WebUsers($receiver); $lang = $webUser->getLanguage(); } else { global $DEFAULT_LANGUAGE; $lang = $DEFAULT_LANGUAGE; } $variables = parse_ini_file($AMS_TRANS . '/' . $lang . '.ini', true); $mailText = array(); foreach ($variables['email'] as $key => $value) { $mailText[$key] = $value; } switch ($type) { case "REPLY": $webUser = new WebUsers($receiver); if ($webUser->getReceiveMail()) { $subject = $mailText['email_subject_new_reply'] . $ticketObj->getTId() . "]"; $txt = $mailText['email_body_new_reply_1'] . $ticketObj->getTId() . $mailText['email_body_new_reply_2'] . $ticketObj->getTitle() . $mailText['email_body_new_reply_3'] . $content . $mailText['email_body_new_reply_4']; self::send_mail($receiver, $subject, $txt, $ticketObj->getTId(), $sender); } break; case "NEW": $webUser = new WebUsers($receiver); if ($webUser->getReceiveMail()) { $subject = $mailText['email_subject_new_ticket'] . $ticketObj->getTId() . "]"; $txt = $mailText['email_body_new_ticket_1'] . $ticketObj->getTId() . $mailText['email_body_new_ticket_2'] . $ticketObj->getTitle() . $mailText['email_body_new_ticket_3'] . $content . $mailText['email_body_new_ticket_4']; self::send_mail($receiver, $subject, $txt, $ticketObj->getTId(), $sender); } break; case "WARNAUTHOR": if (is_numeric($sender)) { $sender = Ticket_User::get_email_by_user_id($sender); } $subject = $mailText['email_subject_warn_author'] . $ticketObj->getTId() . "]"; $txt = $mailText['email_body_warn_author_1'] . $ticketObj->getTitle() . $mailText['email_body_warn_author_2'] . $sender . $mailText['email_body_warn_author_3'] . $sender . $mailText['email_body_warn_author_4']; self::send_mail($receiver, $subject, $txt, $ticketObj->getTId(), NULL); break; case "WARNSENDER": $subject = $mailText['email_subject_warn_sender']; $txt = $mailText['email_body_warn_sender']; self::send_mail($receiver, $subject, $txt, $ticketObj->getTId(), NULL); break; case "WARNUNKNOWNSENDER": $subject = $mailText['email_subject_warn_unknown_sender']; $txt = $mailText['email_body_warn_unknown_sender']; self::send_mail($receiver, $subject, $txt, $ticketObj->getTId(), NULL); break; } } }