-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Smaragda2/CreateLogs
Create logs, Fix up, Performance issues, add Manifest
- Loading branch information
Showing
22 changed files
with
367 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,41 +2,38 @@ | |
|
||
if(isset($_POST['RequestAppointment'])){ | ||
$mysqli = $_SESSION['dbconnect']; | ||
|
||
date_default_timezone_set('Europe/Athens'); | ||
$datum = new DateTime(); | ||
$startTime = $datum->format('Y-m-d H:i:s'); | ||
|
||
$onDate = $_POST['onDate']; | ||
$atTime = $_POST['atTime']; | ||
$email = $_POST['email']; | ||
|
||
$hour = $onDate.' '.$atTime; | ||
$createdAt = $startTime; | ||
|
||
$insertFullRequest = "INSERT INTO `Request`(`name`, `email`, createdAt, `tel`, `whereTo`, `skypeName`, `notes`, isCompleted, isCancelled, isConfirmed, isPaid, `selectedProductID`,paymentToken, onDate, atTime) VALUES (?,?,?,?,?,?,?,false,false,false,false,?,?,?,?)"; | ||
$insertTelRequest = "INSERT INTO `Request`(`name`, `email`, createdAt, `tel`, `whereTo`, `notes`, isCompleted, isCancelled, isConfirmed, isPaid, `selectedProductID`,paymentToken, onDate, atTime) VALUES (?,?,?,?,?,?,false,false,false,false,?,?,?,?)"; | ||
|
||
$formattedOnDate = date('Y-m-d',strtotime($onDate)); | ||
$insertBooked = "INSERT INTO `Booked`(`createdAt`,`onDate`, `atTime`) VALUES ('".$createdAt."','".$formattedOnDate."','".$atTime."')"; | ||
|
||
$send = false; | ||
|
||
|
||
$send = false; | ||
$createdAt = $startTime; | ||
|
||
$tokenStr = $email.','.$hour.','.$createdAt; | ||
$token = sha1($tokenStr); | ||
|
||
$bookedStmt = $mysqli->prepare($insertBooked); | ||
$bookedStmt = $mysqli->prepare($insertBooked); | ||
if(!$bookedStmt->execute()) | ||
print $bookedStmt->error; | ||
|
||
if($_POST['whereTo'] == "Skype"){ | ||
|
||
if($_POST['whereTo'] == "Skype"){ | ||
$stmt = $mysqli->prepare($insertFullRequest); | ||
$stmt->bind_param("sssssssisss", $_POST['fullName'], $_POST['email'], $startTime, $_POST['tel'], $_POST['whereTo'], $_POST['SkypeName'], $_POST['notes'], $_POST['id'],$token, $formattedOnDate, $atTime); | ||
|
||
if($stmt->execute()) | ||
$send = true; | ||
else{ | ||
|
@@ -53,7 +50,7 @@ | |
$send = false; | ||
} | ||
|
||
$getPaymentInfoByPaymentToken = 'SELECT COUNT(*) as exist FROM `paymentInfo` WHERE paymentToken = "'.$token.'"'; | ||
$getPaymentInfoByPaymentToken = 'SELECT COUNT(*) as exist FROM `paymentInfo` WHERE paymentToken = "'.$token.'"'; | ||
$results = $mysqli->query($getPaymentInfoByPaymentToken); | ||
$row = $results->fetch_assoc(); | ||
|
||
|
@@ -65,11 +62,15 @@ | |
|
||
|
||
if($send){ | ||
Logger::info('Appointment Info {Date and Time: '.$hour.', Customer Name: '.$_POST['fullName'].', | ||
Customer Email: '.$_POST['email'].', Customer Phone: '.$_POST['tel'].', Selected Product: '.$_POST['name'].', | ||
Price: '.$_POST['price'].', Appointment Notes: '.$notes.', Appoint through: '.$_POST['whereTo'].'}'); | ||
Logger::info('Appointment Token: '.$token.', Created At: '.$createdAt); | ||
|
||
$url = getUrl($_POST['price'],$_POST['name'],$token); | ||
|
||
$subject = "Niose Kala - Ένα νέο Ραντεβού δημιουργήθηκε!"; | ||
|
||
$message = '<head> <meta charset="utf-8" /> </head>'; | ||
$message .= '<body><divstyle="text-align:left"><h2>Στοιχεία Νέου Ραντεβού:</h2><br><hr><br>'; | ||
$message .= '<div class="row" style="text-align:left">Η ημερομηνία και ώρα του ραντεβού σας είναι '.$hour.'.<br>'; | ||
|
@@ -81,7 +82,7 @@ | |
if(!$mail = smtpmailer($email,$subject,$message)) { | ||
print "<br>".'<span style="color:red">'."Fail to send email.<br> Please try again!<hr> </p><br>"; | ||
//echo "<script>setTimeout();</script>"; | ||
|
||
}else{ | ||
print "<br>".'<span style="color:green">'."Το Ραντεβού Δημιουργήθηκε με επιτυχία. </p><br>"; | ||
print<<<END | ||
|
@@ -95,9 +96,9 @@ | |
}else{ | ||
print "<br>".'<span style="color:red">'."Something went wrong.<br> Please try again!<hr> </p><br>"; | ||
} | ||
} | ||
} | ||
|
||
function smtpmailer($email,$subject,$message) { | ||
function smtpmailer($email,$subject,$message) { | ||
$slittedURI = explode('/',$_SERVER['REQUEST_URI']); | ||
if($slittedURI[1]=="_aDemo"){ | ||
define('GUSER', '[email protected]'); // GMail username | ||
|
@@ -108,33 +109,33 @@ function smtpmailer($email,$subject,$message) { | |
} | ||
|
||
require_once('../appointments/mailer/class.phpmailer.php'); | ||
|
||
global $error; | ||
$mail = new PHPMailer(); // create a new object | ||
$mail->CharSet="UTF-8"; | ||
$mail->CharSet="UTF-8"; | ||
$mail->IsSMTP(); // enable SMTP | ||
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only | ||
$mail->SMTPAuth = true; // authentication enabled | ||
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail | ||
$mail->Host = 'smtp.gmail.com'; | ||
$mail->Port = 465; | ||
$mail->Username = GUSER; | ||
$mail->Password = GPWD; | ||
$mail->Port = 465; | ||
$mail->Username = GUSER; | ||
$mail->Password = GPWD; | ||
$mail->SetFrom(GUSER, 'Niose Kala'); | ||
$mail->Subject = $subject; | ||
$mail->MsgHTML($message); | ||
$mail->AddAddress($email); | ||
$mail->AddBCC(GUSER); | ||
if(!$mail->Send()) { | ||
$error = 'Mail error: '.$mail->ErrorInfo; | ||
$error = 'Mail error: '.$mail->ErrorInfo; | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
function getUrl($price,$name,$token){ | ||
|
||
$slittedURI = explode('/',$_SERVER['REQUEST_URI']); | ||
if($slittedURI[1]=="_aDemo"){ | ||
//----- DEMO ----- | ||
|
@@ -151,10 +152,10 @@ function getUrl($price,$name,$token){ | |
} | ||
|
||
$return = ""; | ||
|
||
$price = $price*100; | ||
$productName = $name; | ||
|
||
$data = array( | ||
"tags"=> array( $token ), | ||
"PaymentTimeOut"=> 65535, | ||
|
@@ -169,26 +170,26 @@ function getUrl($price,$name,$token){ | |
"sourceCode"=>$sourceCode, | ||
"CustomerTrns"=> $productName, | ||
"disableIVR"=> true | ||
); | ||
); | ||
$headers = array( | ||
'Content-Type:application/json', | ||
'Authorization: Basic '.$encAuth // <--- | ||
); | ||
|
||
$ch = curl_init($host); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | ||
curl_setopt($ch, CURLOPT_TIMEOUT, 30); | ||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | ||
$return = curl_exec($ch); | ||
curl_close($ch); | ||
|
||
$result =json_decode($return); | ||
$orderCode = $result->OrderCode; | ||
|
||
return $refURL.$orderCode; | ||
|
||
} | ||
|
||
|
||
?> | ||
?> |
Oops, something went wrong.