����JFIF��H�H����Exif��MM�*���� ��3����V�����3������3�(��������������������3�����
Server IP : 162.0.232.25 / Your IP : 18.118.139.119 Web Server : LiteSpeed System : Linux premium276.web-hosting.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : kwacuqig ( 988) PHP Version : 8.2.26 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/kwacuqig/voltify.malawisounds.com/ |
Upload File : |
<?php //Define name spaces use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; //Include required phpMailer files require './PHPMailer/PHPMailer.php'; require './PHPMailer/SMTP.php'; require './PHPMailer/Exception.php'; include './head.php'; include './header.php'; include './navbar.php'; if (isset($_POST['submit'])) { $token = $_POST['token']; $kwh = $_POST['kwh']; $price = $_POST['price']; $meterNumber = $_POST['meterNumber']; $query = "SELECT * FROM `customers` WHERE `meter_number`='$meterNumber'"; if ($query_run = mysqli_query($conn, $query)) { $row = mysqli_fetch_array($query_run); $email = $row['email']; $subject = "Your Receipt for Recent Purchase"; $firstname = $row['firstname']; $surname = $row['surname']; $pm = " <!DOCTYPE html> <html lang=\"en\"> <head> <meta charset=\"UTF-8\"> <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"> <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"> </head> <body> <div style=\"background-color:rgba(0,255,0,0.1);padding:1rem;\"> <div style=\"background-color:#fff;border-radius:10px;padding:10px;\"> <div style=\"background-color:#009900;color:#fff;border-radius:15px 15px 0 0;text-align:center;font-size:18px;padding:40px 10px ;font-weight:bold;font-family:arial;\"> <div class=\"text-center bg-dark text-white\">VOLTIFY</div> </div> <h2>Dear $firstname $surname,</h2> <p>Here are the particulars of the token you have acquired.</p> <b>Meter Number</b>: $meterNumber <br><br> <b>Price</b>: K$price <br><br> <b>Amount</b>: $kwh kWh<br><br> <b>Token</b>: $token <br><br> <center> <div class=\"padding:5px;text-align:center;background-color:#c9c8c8;\"> Voltify © " . date('Y') . " </div> </center> </div> </div> </body> </html> "; //Create instance of phpMailer $mail = new PHPMailer(); //Enable verbose debug output // $mail->SMTPDebug = SMTP::DEBUG_SERVER; //set mailer to use smtp $mail->isSMTP(); //define smtp host $mail->Host = "smtp.gmail.com"; //enable smtp authentification $mail->SMTPAuth = "true"; //set type of encryption (ssl/tls) //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; //set port to connect smtp $mail->Port = "587"; //465 for ssl //set gmail username $mail->Username = "beatonndaba@gmail.com"; //set gmail password $mail->Password = "tsxngatucbssjwbm"; //Set email format to HTML $mail->isHTML(true); //set email subject $mail->Subject = $subject; //set sender email $mail->setFrom($email, "VOLTIFY"); //Email body $mail->Body = $pm; //Add recipient $mail->addAddress($email); //Finally send email if ($mail->Send()) { ?> <script type="text/javascript"> document.addEventListener("DOMContentLoaded", function(event) { swal("SUCCESS", "Invoice email was sent successfully", "success"); }) </script> <?php } else { ?> <script type="text/javascript"> document.addEventListener("DOMContentLoaded", function(event) { swal("ERROR", "<?php echo 'Message could not be sent. Mailer Error: {' . $mail->ErrorInfo . '}'; ?>", "error"); }) </script> <?php } //Closing smtp connection $mail->smtpClose(); } else { die(mysqli_error($conn)); } } function generateToken($amountOfEnergy, $meterNumber) { $tokenLength = 20; $shift = 3; // Number of positions to shift each digit $delimiter = '|'; // Delimiter character to separate meter number and token amount $token = ''; // Convert the amount of energy and meter number to strings $energyString = strval($amountOfEnergy); $meterNumberString = strval($meterNumber); // Calculate the remaining length for random digits $remainingLength = $tokenLength - strlen($energyString) - strlen($meterNumberString); // Generate random digits for the remaining length for ($i = 0; $i < $remainingLength; $i++) { $token .= strval(random_int(0, 9)); } // Concatenate the strings to form the token $token = $energyString . $delimiter . $meterNumberString . $token; // Encrypt the token using a Caesar cipher $encryptedToken = encryptToken($token, $shift); return $encryptedToken; // return $token; } // Encrypt the token using a simple Caesar cipher function encryptToken($token, $shift) { $encryptedToken = ''; for ($i = 0; $i < strlen($token); $i++) { $c = $token[$i]; if (ctype_digit($c)) { // Shift the digit value by the specified number of positions $shiftedDigit = ($c + $shift) % 10; $encryptedToken .= strval($shiftedDigit); } } return $encryptedToken; } if (isset($_POST['meterNumber'], $_POST['kwh'])) { $meterNumber = $_POST['meterNumber']; $kwh = $_POST['kwh']; $price = $_POST['price']; $run = mysqli_query($conn, "SELECT * FROM `customers` WHERE `meter_number`='$meterNumber' ") or die(mysqli_error($conn)); $row = mysqli_fetch_array($run); } $token = generateToken($kwh, $meterNumber); ?> <!-- Breadcomb area End--> <!-- Invoice area Start--> <div class="invoice-area"> <div class="container-fluid"> <div class="row"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <div class="invoice-wrap"> <div class="invoice-img"> <img src="img/logo/logo.png" alt="" /> </div> <div class="invoice-hds-pro"> <div class="row"> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12"> <div class="invoice-cmp-ds ivc-frm"> <div class="invoice-frm"> <span>Invoice from</span> </div> <div class="comp-tl"> <h2>Voltify</h2> </div> <div class="cmp-ph-em"> <span>0998412421</span> <span>info@voltify.com</span> </div> </div> </div> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12"> <div class="invoice-cmp-ds ivc-to"> <div class="invoice-frm"> <span>Invoice to</span> </div> <div class="comp-tl"> <h2><?php echo $row['firstname'] . ' ' . $row['surname']; ?></h2> </div> <div class="cmp-ph-em"> <span><?php echo $row['mobile']; ?></span> <span><?php echo $row['email']; ?></span> </div> </div> </div> </div> <div class="row"> <center> <div class="col-sm-12 col-xs-12"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="price" value="<?php echo $price; ?>"> <input type="hidden" name="kwh" value="<?php echo $kwh; ?>"> <input type="hidden" name="meterNumber" value="<?php echo $meterNumber; ?>"> <button class="btn btn-primary" style="border-radius:20px;margin-top:8px" type="submit" name="submit"><i class="fa fa-envelope"></i> Email</button> </form> </div> </center> </div> </div> <div class="row"> <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12"> <div class="invoice-hs"> <span>Date</span> <h2><?php echo date('d/m/Y'); ?></h2> </div> </div> <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12"> <div class="invoice-hs date-inv sm-res-mg-t-30 tb-res-mg-t-30 tb-res-mg-t-0"> <span>Token</span> <h2><?php echo $token; ?></h2> </div> </div> <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12"> <div class="invoice-hs wt-inv sm-res-mg-t-30 tb-res-mg-t-30 tb-res-mg-t-0"> <span>Units</span> <h2><?php echo $kwh; ?>kWh</h2> </div> </div> <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12"> <div class="invoice-hs gdt-inv sm-res-mg-t-30 tb-res-mg-t-30 tb-res-mg-t-0"> <span>Total Price</span> <h2>K<?php echo $price; ?></h2> </div> </div> </div> </div> </div> </div> </div> </div> <!-- Invoice area End--> <?php include './footer.php'; include './scripts.php'; ?> <script> document.querySelectorAll(".main-menu-area .nav li")[0].classList.add('active') document.querySelector(".main-menu-area .tab-content #Home").classList.add('in') document.querySelector(".main-menu-area .tab-content #Home").classList.add('active') document.querySelector("title").innerHTML = "Voltify ~ Invoice"; </script>