-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidatorPage.inc
More file actions
85 lines (71 loc) · 2.05 KB
/
ValidatorPage.inc
File metadata and controls
85 lines (71 loc) · 2.05 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
require 'Page.inc';
require 'sql_utils.inc';
require 'common_utils.inc';
require 'Constants.php';
class ValidatorPage extends Page
{
const DOWNLOAD_PAGE = "http://www.metropolitanparc.com/download.php";
public $passCode = "";
function __construct($title, $passCode)
{
parent::__construct($title);
$this->passCode = @trim($passCode); // Trim the passcode
}
public function Display()
{
// Redirect if coming straight to this page
if($this->passCode == '')
{
header("location: HomePage.php");
}
echo "<html>\n<head>\n";
$this->displayJS();
$this->displayStyle();
$this->displayTitle();
echo "</head>\n<body>";
echo "<p id=\"response\">";
$authenticattionResult = SqlUtils::authenticate($this->passCode);
if($authenticattionResult->resultCode == AuthenticationResult::INVALID_PASSCODE)
{
$this->displayBodyOnError();
}
elseif($authenticattionResult->resultCode == AuthenticationResult::DOWNLOAD_LIMIT_REACHED)
{
$this->displayBodyOnDownloadLimitReached($authenticattionResult->name);
}
else
{
$this->setSession($authenticattionResult->name,$this->passCode);
$this->displayBodyOnSuccess($authenticattionResult->name);
}
echo "</p>";
echo "</body>\n</html>\n";
}
protected function displayJS()
{
}
private function displayBodyOnSuccess($name)
{
echo $name."<br> Thank you for downloading Metropolitan Parc's Album One";
header('Refresh: 2; url='.ValidatorPage::DOWNLOAD_PAGE);
}
private function displayBodyOnError()
{
echo "Passphrase not recognised. Please try again";
}
private function displayBodyOnDownloadLimitReached($name)
{
echo $name."<br>You have reached your maximum number of downloads. To request a new ".
"passcode, please contact us: metropolitanparc@gmail.com";
}
private function setSession($name, $passCode)
{
session_start();
$_SESSION[Constants::SESSION_USERNAME] = $name;
$_SESSION[Constants::SESSION_PASSCODE] = $passCode;
}
protected function displayFooter()
{
}
}