-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
119 lines (78 loc) · 2.46 KB
/
admin.php
File metadata and controls
119 lines (78 loc) · 2.46 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
//Declare variable
$display = '';
// Connect DB
include 'dbconnect.php';
// Insert users in DB
include 'insertdb.php';
// File uploads
include 'uploadimage.php';
// Register User
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_REQUEST['signup'])) {
// Record inserted into database
if(insert_db() == 'Yes'){
$GLOBALS['display'] = "Account verification pending ";
}
else{$GLOBALS['display'] = "Error ";}
}
// User Login
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_REQUEST['signin'])) {
// Check for login
$row = login();
if($row != 'No'){
//REDIRECT TO DASHBOARD
if(($row["status"] == 'Denied') || ($row["status"] =='Pending')){
// Redirect to homepage
?>
<script>window.location.replace('index.php?status=<?php echo $row["status"]; ?>');</script>
<?php
}
if($row["status"] == 'Approved'){ $GLOBALS['display'] = "Your account has been verified";
// Start Session
session_start();
// Instantiate user data from DB
$_SESSION['user'] = $row;
}
}
// Redirect to homepage if user login is invalid
else{ ?>
<script>window.location.replace('index.php?status=Invalid');</script>
<?php
}
}
// confirmation email
function admin_confirmation_mail( $email, $firstName, $lastName ){
// Site URL
$site_url = $GLOBALS['site_url'];
// Set content-type
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
//header for email
$headers .= 'From: <admin@appleimages.com>' . "\r\n";
/// $email, $admin_decision
$msg = "Admin,<br>A user with the name $firstName $lastName with email address ($email)
needs an account confirmation,
\nClick the link to confirm your mail\n
<a href=\"$site_url/admin.php?email=$email&admin_decision=Approved\"> Confirm </a> or
<a href=\"$site_url/admin.php?email=$email&admin_decision=Denied\"> Deny</a>";
// send email
mail('aakaeze3261@conestogac.on.ca',"User Account Pending Confirmation",$msg,$headers);
}
if (isset($_GET['status'])){
$status = $_GET['status'];
switch ($status) {
case "Denied":
$GLOBALS['display'] = "Access denied";
break;
case "Pending":
$GLOBALS['display'] = "Approval pending";
break;
case "Invalid":
$GLOBALS['display'] = "Invalid username or password";
break;
default:
$GLOBALS['display'] = "Session Expired";
break;
}
}
?>