Skip to content

Commit

Permalink
Added backup services
Browse files Browse the repository at this point in the history
  • Loading branch information
Suvink committed Mar 29, 2021
1 parent 8ad98ba commit cc36d08
Show file tree
Hide file tree
Showing 14 changed files with 1,856 additions and 6 deletions.
Binary file modified .DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion api/v1/DineinPaymentListner.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
$DBConnection = new DBConnection();
$con = $DBConnection->getConnection();


$merchant_id = $_POST['merchant_id'];
$order_id = $_POST['order_id'];
$payhere_amount = $_POST['payhere_amount'];
Expand Down
555 changes: 555 additions & 0 deletions backups/Backup-2021-03-30_04-42-06.sql

Large diffs are not rendered by default.

555 changes: 555 additions & 0 deletions backups/Backup-2021-03-30_04-42-59.sql

Large diffs are not rendered by default.

555 changes: 555 additions & 0 deletions backups/Backup-2021-03-30_04-43-32.sql

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion config/dbcredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
'username' => 'eatme',
'password' => 'weM2KxUZriR9',
'dbname' => 'eat_me'

);
?>
4 changes: 4 additions & 0 deletions router.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
$notify= 'api/v1/PushNotifications.php';
$mStaffRatesCus= 'api/v1/MSRatesCustomer.php';
$payhereListner = 'api/v1/DineinPaymentListner.php';
$backups = 'services/backup.php';

//controllers
$dineinlogincontroller = 'PHP/customer/dineinlogincontroller.php';
Expand Down Expand Up @@ -191,6 +192,9 @@
case '/api/v1/dinein/payment':
require($payhereListner);
break;
case '/backup':
require($backups);
break;
default:
http_response_code(404);
require($errorPage);
Expand Down
5 changes: 5 additions & 0 deletions services/backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S`
echo "SQL DUMP STARTED AT ${TIMESTAMP}"
touch "../backups/Backup-${TIMESTAMP}.sql"
/Applications/XAMPP/bin/mysqldump --user=eatme --password=weM2KxUZriR9 --host=localhost eat_me > ../backups/Backup-${TIMESTAMP}.sql
echo "BACKUP FINISHED"
105 changes: 105 additions & 0 deletions tests/tests/_output/LoginCest.tryToTest.fail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="../../img/favicon.png" />
<!-- Global Styles -->
<link rel="stylesheet" href="../../css/style.css" />
<link rel="stylesheet" href="../../plugins/ArtemisAlert/ArtemisAlert.css">
<title>Login - EatME</title>
</head>

<body>
<div class="navbar">
<div class="columns group">
<div class="column is-2">
<img src="../../img/logo.png" height="56" width="224" />
</div>
<div class="column is-10"></div>
</div>
</div>

<div class="container has-text-centered">
<h1 class="title mb-1 mt-0">Login</h1>
<img id="banner-image" class="mt-0 mb-0" src="../../img/login.jpg" height="150" />
<center>
<div id="error-block"></div>


<div id="loginInfoDiv" style="display: block">
<label class="field artemis-input-field">
<label for="phone_number_input">Phone</label>
<input class="artemis-input" type="text" placeholder="Your Phone Number here" id="phone_number_input" required>
<span class="label-wrap">
<span class="label-text">Phone Number</span>
</span>
</label>
<button class="button is-primary" name="is-send" onclick="sendOTP();">Send OTP</button>
</div>

<form action="/online/login" id="otpDiv" style="display: none" method="POST">
<label class="field artemis-input-field">
<input class="artemis-input" type="text" placeholder="Your OTP here" name="otp" autocomplete="one-time-code" required>
<span class="label-wrap">
<span class="label-text">OTP</span>
</span>
</label>
<input id="ref_token" style="display: none" name="token">
<button class="button is-primary" name="submit">Login</button>
</form>


</form>
</center>
</div>
<script src="../../plugins/ArtemisAlert/ArtemisAlert.js"></script>
<script>
async function sendOTP() {

let phone_no = document.getElementById('phone_number_input').value;
if (!/^(?:0|94|\+94|0094)?(?:(11|21|23|24|25|26|27|31|32|33|34|35|36|37|38|41|45|47|51|52|54|55|57|63|65|66|67|81|91)(0|2|3|4|5|7|9)|7(0|1|2|5|6|7|8)\d)\d{6}$/.test(phone_no)) {
artemisAlert.alert('error', 'Enter a valid phone number!')
return;
} else {

//Call the Loader
document.getElementById('banner-image').src = '../../img/loading.gif';

let data = {
"phone": phone_no,
}

try {
const response = await fetch('/api/v1/verify', {
method: 'POST',
body: JSON.stringify(data)
});

let dataJson = JSON.parse(await response.text());
console.log(dataJson);
if (!dataJson.token) {
document.getElementById('error-block').innerHTML = '<div class="row artemis-notification notification-danger bounceIn"><p>Error: ' + dataJson.message + '!</p></div>';
document.getElementById('banner-image').src = '../../img/login.jpg';
} else {
document.getElementById('ref_token').value = dataJson.token;
document.getElementById('banner-image').src = '../../img/login.jpg';
document.getElementById('loginInfoDiv').style.display = "none";
document.getElementById('otpDiv').style.display = "block";
}

} catch (err) {
console.log(err.text);
document.getElementById('banner-image').src = '../../img/login.jpg';
document.getElementById('error-block').innerHTML = '<div class="row artemis-notification notification-danger bounceIn"><p>Error: Unknown Error Occured! Please try again later!</p></div>';
}

}

}
</script>
</body>

</html>
3 changes: 2 additions & 1 deletion tests/tests/_output/failed
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
tests/acceptance/FirstCest.php:secondpageWorks
tests/acceptance/LoginCest.php:tryToTest
tests/unit/UnitFirstTest.php:testLogin
27 changes: 25 additions & 2 deletions tests/tests/acceptance/FirstCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,37 @@

class FirstCest
{
public function frontpageWorks(AcceptanceTester $I)
public function HomePageWords(AcceptanceTester $I)
{
$I->amOnPage('/');
$I->see('Eat Me');
}
public function secondpageWorks(AcceptanceTester $I)
public function OnlineLoginWorks(AcceptanceTester $I)
{
$I->amOnPage('/online/login');
$I->see('login');
}
public function DineinLoginWorks(AcceptanceTester $I)
{
$I->amOnPage('/dinein/login');
$I->see('login');
}
public function OnlineOrderWorks(AcceptanceTester $I)
{
//Only works for logged in customers
$I->amOnPage('/online');
$I->see('login');
}
public function DineinOrderWorks(AcceptanceTester $I)
{
//Only works for logged in customers
$I->amOnPage('/online/login');
$I->see('login');
}
public function StaffLoginWorks(AcceptanceTester $I)
{
$I->amOnPage('/staff/login');
$I->see('login');
}

}
18 changes: 18 additions & 0 deletions tests/tests/acceptance/LoginCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

class LoginCest
{
public function _before(AcceptanceTester $I)
{

}

// tests
public function tryToTestLogin(AcceptanceTester $I)
{
$I->amOnPage('online/login');
$I->fillField('#phone_number_input', "0771655198");
$I->click('is-sent');
$I->see('Your OTP here');
}
}
30 changes: 30 additions & 0 deletions tests/tests/unit/UnitFirstTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

class UnitFirstTest extends \Codeception\Test\Unit
{
/**
* @var \UnitTester
*/
protected $tester;

protected function _before()
{
}

protected function _after()
{
}

// tests
public function testLogin()
{
$login = new OnlineOrderLoginController();

$login->submitLogin(null, null);
$this->assertFalse("False Data Rejected");

$login->submitLogin('2dcDe2E', '234196');
$this->assertTrue('True Data Accpted');

}
}
3 changes: 2 additions & 1 deletion views/customer/OnlineOrderLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@

<div id="loginInfoDiv" style="display: block">
<label class="field artemis-input-field">
<label for="phone_number_input">Phone</label>
<input class="artemis-input" type="text" placeholder="Your Phone Number here" id="phone_number_input" required>
<span class="label-wrap">
<span class="label-text">Phone Number</span>
</span>
</label>
<button class="button is-primary" onclick="sendOTP();">Send OTP</button>
<button class="button is-primary" name="is-send" onclick="sendOTP();">Send OTP</button>
</div>

<form action="/online/login" id="otpDiv" style="display: none" method="POST">
Expand Down

0 comments on commit cc36d08

Please sign in to comment.