Skip to content

Commit

Permalink
Fix Bug Email
Browse files Browse the repository at this point in the history
  • Loading branch information
amirulasri committed Apr 15, 2021
1 parent c4faf73 commit c1d7e67
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 22 deletions.
13 changes: 11 additions & 2 deletions PHPMailer/get_oauth_token.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ protected function createResourceOwner(array $response, AccessToken $token)
);

// Use this to get a new access token if the old one expires
echo 'Refresh Token: ' . $token->getRefreshToken();

$tokenbaru = $token->getRefreshToken();

include('../setup.php');

$queryupdatetoken = mysqli_query($conn, "UPDATE emeltoken SET token = '$tokenbaru'");
if($queryupdatetoken){
echo '<script>alert("KEMASKINI TOKEN EMEL BERJAYA"); window.location="../admin/administrator/index.php";</script>';
}else{
echo '<script>alert("GAGAL KEMASKINI TOKEN EMEL"); window.location="../admin/administrator/index.php";</script>';
}

}
53 changes: 37 additions & 16 deletions dvillahomestay.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- version 5.0.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Sep 17, 2020 at 05:59 PM
-- Server version: 10.4.13-MariaDB
-- PHP Version: 7.4.7
-- Generation Time: Apr 15, 2021 at 05:24 PM
-- Server version: 10.4.17-MariaDB
-- PHP Version: 8.0.2

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
Expand Down Expand Up @@ -39,8 +39,25 @@ CREATE TABLE `adminlogin` (
--

INSERT INTO `adminlogin` (`username`, `password`, `namaadmin`, `role`) VALUES
('admin', '12345678', 'Admin', 'root'),
('adminamirul', '12345678', 'Amirul Asri', 'standard');
('admin', '12345678', 'Admin', 'root');

-- --------------------------------------------------------

--
-- Table structure for table `emeltoken`
--

CREATE TABLE `emeltoken` (
`id` int(11) NOT NULL,
`token` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `emeltoken`
--

INSERT INTO `emeltoken` (`id`, `token`) VALUES
(1, '1//0g0KUuESXYzdWCgYIARAAGBASNwF-L9IrnzHXy7qiS60rZgGZEzL2eRuryoUeH-BEc-T0zmF5ZZMON59ECs9-C1gMKfTkS4wBUzo');

-- --------------------------------------------------------

Expand All @@ -59,7 +76,7 @@ CREATE TABLE `pelanggan` (
--

INSERT INTO `pelanggan` (`email`, `namapelanggan`, `notelpelanggan`) VALUES
('amirulasrix@gmail.com', 'Amirul Asri', '01135020493');
('amirulasrix@gmail.com', 'MOHAMAD AMIRUL ASRI BIN AZMI', '01135020493');

-- --------------------------------------------------------

Expand Down Expand Up @@ -121,14 +138,6 @@ CREATE TABLE `tempahan` (
`statusbayaran` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tempahan`
--

INSERT INTO `tempahan` (`idtempahan`, `idrumah`, `email`, `tarikhmasuk`, `tarikhkeluar`, `bildewasa`, `bilkanakkanak`, `jumlahharga`, `namapelanggan`, `notelpelanggan`, `statusbayaran`) VALUES
(22, 4, 'amirulasrix@gmail.com', '2020-09-16', '2020-10-01', 3, 2, '1650', 'Amirul Asri', '01135020493', 'Belum dibuat'),
(24, 4, 'amirulasrix@gmail.com', '2020-10-14', '2024-12-28', 4, 4, '168960', 'Amirul Asri', '01135020493', 'Belum dibuat');

--
-- Indexes for dumped tables
--
Expand All @@ -139,6 +148,12 @@ INSERT INTO `tempahan` (`idtempahan`, `idrumah`, `email`, `tarikhmasuk`, `tarikh
ALTER TABLE `adminlogin`
ADD PRIMARY KEY (`username`);

--
-- Indexes for table `emeltoken`
--
ALTER TABLE `emeltoken`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `pelanggan`
--
Expand Down Expand Up @@ -169,6 +184,12 @@ ALTER TABLE `tempahan`
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `emeltoken`
--
ALTER TABLE `emeltoken`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `rumah`
--
Expand All @@ -179,7 +200,7 @@ ALTER TABLE `rumah`
-- AUTO_INCREMENT for table `tempahan`
--
ALTER TABLE `tempahan`
MODIFY `idtempahan` int(150) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;
MODIFY `idtempahan` int(150) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=31;

--
-- Constraints for dumped tables
Expand Down
9 changes: 7 additions & 2 deletions user/prosestempah.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@
$bildewasa = 1;
}

//DAPATKAN DATA TOKEN WEB
$querytoken = mysqli_query($conn, "SELECT * FROM emeltoken");
$gettoken = mysqli_fetch_array($querytoken);
$token = $gettoken['token'];

//Proses mendaftar disini:
//Periksa sama ada rumah itu telah ditempah sebelum ini
$semakrumah = mysqli_query($conn, "SELECT * FROM tempahan WHERE idrumah='$idrumah'");
$kekosongan = mysqli_num_rows($semakrumah);
if ($tidaktersedia == 0) {
if ($kekosongan == 0) {
// Jika rumah yang dipilih masih lagi belum ditempah oleh orang lain, Teruskan dengan tempahan
//PROSES TEMPAHAN:
$insert1 = "INSERT INTO pelanggan (email, namapelanggan, notelpelanggan) VALUES ('$email', '$namapelanggan', '$notelpelanggan')";
Expand Down Expand Up @@ -90,7 +95,7 @@
$mail->oauthUserEmail = "dvillahomestays@gmail.com"; // SMTP username
$mail->oauthClientId = "207643860161-38pivgr6v8ohv1e3jg8fiju1hg3dj5r1.apps.googleusercontent.com";
$mail->oauthClientSecret = "xpI7wE0Bhhoym4BfEZ2p-Ip-";
$mail->oauthRefreshToken = "1//0guwD4HPM_ztBCgYIARAAGBASNwF-L9IrbCt2pS76ATTZjzWLU6swJQH95ww9f03i3okYMfe5hXsZHuxAr386HuLq48QwVoYkihc";
$mail->oauthRefreshToken = "$token";
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->AuthType = 'XOAUTH2';
Expand Down
9 changes: 7 additions & 2 deletions user/prosestempahakaun.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
$bildewasa = 1;
}

//DAPATKAN DATA TOKEN WEB
$querytoken = mysqli_query($conn, "SELECT * FROM emeltoken");
$gettoken = mysqli_fetch_assoc($querytoken);
$token = $gettoken['token'];

//Periksa sama ada rumah itu ditempah pada tarikh yang tersedia
$semaktarikh = mysqli_query($conn, "SELECT * FROM tempahan WHERE idrumah = '$idrumah'");
$tidaktersedia = mysqli_num_rows($semaktarikh);
Expand Down Expand Up @@ -80,7 +85,7 @@
$mail->oauthUserEmail = "dvillahomestays@gmail.com"; // SMTP username
$mail->oauthClientId = "207643860161-38pivgr6v8ohv1e3jg8fiju1hg3dj5r1.apps.googleusercontent.com";
$mail->oauthClientSecret = "xpI7wE0Bhhoym4BfEZ2p-Ip-";
$mail->oauthRefreshToken = "1//0guwD4HPM_ztBCgYIARAAGBASNwF-L9IrbCt2pS76ATTZjzWLU6swJQH95ww9f03i3okYMfe5hXsZHuxAr386HuLq48QwVoYkihc";
$mail->oauthRefreshToken = "$token";
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->AuthType = 'XOAUTH2';
Expand Down Expand Up @@ -178,7 +183,7 @@
$mail->oauthUserEmail = "dvillahomestays@gmail.com"; // SMTP username
$mail->oauthClientId = "207643860161-38pivgr6v8ohv1e3jg8fiju1hg3dj5r1.apps.googleusercontent.com";
$mail->oauthClientSecret = "xpI7wE0Bhhoym4BfEZ2p-Ip-";
$mail->oauthRefreshToken = "1//0gDjnwBPJZWtQCgYIARAAGBASNwF-L9IrwHbz4sAAbLZgKTuDehdZHfZpMAwn3o-YPmgozkxkEKR7arc7XWwVE3nbK29RIyWXnfE";
$mail->oauthRefreshToken = "$token";
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->AuthType = 'XOAUTH2';
Expand Down

0 comments on commit c1d7e67

Please sign in to comment.