-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmockController.php
54 lines (42 loc) · 1.38 KB
/
mockController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
class mockController extends Controller {
protected $returnArray = [];
public function verify (){
if ($_POST) {
$AUTH_USER = 'srkndnsn';
$AUTH_PASS = 'bSadFd7c*';
$hasSuppliedCredentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));
$receipt = mHelper::postCharVariableControl("receipt");
$isNotAuthenticated = (!$hasSuppliedCredentials || $_SERVER['PHP_AUTH_USER'] != $AUTH_USER ||
$_SERVER['PHP_AUTH_PW'] != $AUTH_PASS);
if ($isNotAuthenticated) {
$returnArray['status'] = false;
$returnArray['message'] = "Authorization Required";
}
else{
if ($receipt != ""){
$receiptControlChar = substr($receipt, -1);
if (intval($receiptControlChar)%2 == 0){
$returnArray['status'] = true;
$returnArray['message'] = "Successful";
date_default_timezone_set('America/Denver');
$returnArray['expireDate'] = date('Y-m-d H:i:s');
}
else{
$returnArray['status'] = false;
$returnArray['message'] = "The receipt is invalid ";
}
}
else{
$returnArray['status'] = false;
$returnArray['message'] = "The variable/variables are invalid or empty";
}
}
}
else{
$returnArray['status'] = false;
$returnArray['message'] = "The method should be POST";
}
echo json_encode($returnArray);
}
}