Skip to content

Commit

Permalink
Merge pull request #15 from Smaragda2/CreateLogs
Browse files Browse the repository at this point in the history
Create logs, Fix up, Performance issues, add Manifest
  • Loading branch information
Smaragda2 authored Apr 6, 2022
2 parents 024d309 + 463d1de commit ee8eac0
Show file tree
Hide file tree
Showing 22 changed files with 367 additions and 220 deletions.
24 changes: 12 additions & 12 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@
<!doctype html>
<html lang="en">
<?php
include_once "../database/dbconnect.php";

include_once "../database/dbconnect.php";
$database = new Database();
$db = $database->getConnection();
$_SESSION['dbconnect'] = $db;

if(!isset($_SESSION['admin'])){
$_SESSION['admin'] = '?';
}
}
?>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="../assets/css/main.css" />
<link rel="stylesheet" href="../assets/css/_custom-forms.scss" />
<script src="https://kit.fontawesome.com/ec3f31a4cb.js" crossorigin="anonymous"></script>

<link rel="canonical" href="https://getbootstrap.com/docs/4.0/examples/checkout/">

<!-- Bootstrap core CSS -->
<link href="https://getbootstrap.com/docs/4.0/dist/css/bootstrap.min.css" rel="stylesheet">

<!-- Custom styles for this template -->
<link href="https://getbootstrap.com/docs/4.0/examples/checkout/form-validation.css" rel="stylesheet">
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<style type="text/css">
tr:nth-child(even) {background: #CCC}
tr:nth-child(odd) {background: #FFF}
Expand Down Expand Up @@ -66,7 +66,7 @@
</ul>
</li>
<li>
<?php
<?php
if($_SESSION['admin'] == 'ok'){
print '<a href="?p=logout">Logout</a>';
}else{
Expand All @@ -77,11 +77,11 @@
</ul>
</nav>
</div>

<!-- Internal Pages -->
<main role="main" style="padding-top:5%;margin-right:10%;margin-left:10%" class="col-md-9 col-lg-10 px-4" id="main">
<section class="row text-center placeholders">
<?php
<?php
if( !isset($_REQUEST['p']) && $_SESSION['admin'] == 'ok' ){
$_REQUEST['p']='start';
}else if(!isset($_REQUEST['p']) && $_SESSION['admin'] != 'ok' ){
Expand Down Expand Up @@ -137,14 +137,14 @@
break;
case "UpdateSettings" : require "settings/UpdateSettings.php";
break;

}
}
?>
</section>
</main>
</div>

<!-- Scripts -->
<!--<script src="../assets/js/jquery.min.js"></script>-->
<script src="../assets/js/jquery.dropotron.min.js"></script>
Expand Down
63 changes: 32 additions & 31 deletions admin/services/request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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();

Expand All @@ -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>';
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 -----
Expand All @@ -151,10 +152,10 @@ function getUrl($price,$name,$token){
}

$return = "";

$price = $price*100;
$productName = $name;

$data = array(
"tags"=> array( $token ),
"PaymentTimeOut"=> 65535,
Expand All @@ -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;

}


?>
?>
Loading

0 comments on commit ee8eac0

Please sign in to comment.