function sendEmailWithPDF($userId, $email, $name, $subject, $body) { require_once 'PHPMailer/class.phpmailer.php'; $account = selectAccountByUserId($userId); $doc = generateUserPDF($account->ID); $password = randomPassword(); $mail = new PHPMailer(); $body = "Requested Tan Numbers are attached to the e-mail..\n\n<br /><br />Password:{$password}"; $mail->CharSet = 'UTF-8'; $mail->SetFrom('*****@*****.**', 'SecureCodingTeam6'); //Set the name as you like $mail->SMTPAuth = true; $mail->Host = "smtp.gmail.com"; // SMTP server $mail->SMTPSecure = "ssl"; $mail->Username = "******"; //account which you want to send mail from $mail->Password = "******"; //this is account's password $mail->Port = "465"; $mail->isSMTP(); $user = getSingleUser($userId); $mail->AddAddress($email, $name); $mail->Subject = $subject; $mail->MsgHTML($body); $doc->SetProtection(array('print', 'copy'), $password); $doc = $doc->Output('', 'S'); //Save the pdf file $mail->AddStringAttachment($doc, 'doc.pdf', 'base64', 'application/pdf'); if (!$mail->send()) { return false; } return true; }
if ((isset($_POST['approve']) || isset($_POST['reject'])) && isset($_SESSION['usertoken']) && $_POST['usertoken'] == $_SESSION['usertoken']) { $id = $_POST['userid']; $decision = isset($_POST['approve']) ? true : false; $approver = getAuthUser()->userid; $balance = $_POST['balance']; unset($_SESSION['usertoken']); $approval = approveRegistration($id, $approver, $decision, $balance); if (!empty($approval->msg)) { $showMsg = $approval->msg; } } // get single user - Sanitize input 4.8.1 $id = isset($_GET['id']) && getAuthUser()->usertype === 'E' ? (int) $_GET['id'] : getAuthUser()->userid; //4.8.1 if (is_numeric($id)) { $user = getSingleUser($id); } // if this user is invalid, redirect to view users page if (!$user) { header("Location: " . "view_users.php"); exit; } function getSCS() { $program = realpath("../app/SCSimulator/tan_generator"); $program_directory = substr($program, 0, strrpos($program, "/")); chdir($program_directory); $acctNum = selectAccountByUserId(getAuthUser()->userid)->ACCOUNT_NUMBER; $dbUser = "******"; $dbPass = "******"; $dbName = "bank_db";