-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
219 lines (185 loc) · 5.78 KB
/
admin.php
File metadata and controls
219 lines (185 loc) · 5.78 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?php
include_once 'header.php';
if(!isset($_GET['page']) || !isset($_SESSION['uid'])) {
echo "<script>window.top.location='index.php'</script>";
//header("Location: index.php");
exit();
}
if($_GET['page'] == 'add') {
?>
<div class="container text-center" style="width:auto;" ng-app="myApp" ng-controller="customersCtrl">
<p><b style="font-size:25px;">Admin Adding Page</b> <br><br></p>
<form>
<input class="form-control" type="text" ng-model="name" name="name" placeholder="AdminName" autofocus required>
<br>
<input class="form-control" type="text" ng-model="uid" name="uid" placeholder="UserName" autofocus required>
<span ng-show="disp1">User Exists</span>
<br>
<input class="form-control" type="password" ng-model="pwd" name="pwd" placeholder="Password" autofocus required>
<span ng-show="disp2">Password Weak</span>
<br>
<button class="btn btn-primary" ng-click="add()">Add</button>
</form>
<br>
<button class="btn btn-primary" ng-click="reset()">Reset</button>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$scope.reset = function() {
$scope.name = '';
$scope.uid = '';
$scope.pwd = '';
$scope.disp1 = false;
$scope.disp2 = false;
}
$scope.add = function() {
$http({
method: "post",
url: "includes/admin.inc.php?page=add",
data: {
'name': $scope.name,
'uid' : $scope.uid,
'pwd' : $scope.pwd
}
}).then(function (data) {
console.log(data);
if (data.data == 'Admin Id already exists!')
$scope.disp1 = true;
else
$scope.disp1 = false;
if (data.data == 'Your password is weak!')
$scope.disp2 = true;
else
$scope.disp2 = false;
if (data.data == 1)
{
$scope.reset();
window.alert('Admin added successfully!');
}
}, function myError(response) {
console.log('Error');
});
}
$scope.reset();
});
</script>
<?php
}
elseif ($_GET['page'] == 'mod') {
?>
<div class="container text-center" style="width:auto;" ng-app="myApp" ng-controller="customersCtrl">
<p><b style="font-size:25px;">Change Password</b><br><br></p>
<form>
<input class="form-control" type="password" ng-model="opwd" name="opwd" placeholder="OldPassword" autofocus required>
<span ng-show="disp1">Wrong Password</span>
<br>
<input class="form-control" type="password" ng-model="npwd" name="npwd" placeholder="NewPassword" autofocus required>
<span ng-show="disp2">Password Weak</span>
<br>
<input class="form-control" type="password" ng-model="cnpwd" name="cnpwd" placeholder="ConfirmNewPassword" autofocus required>
<span ng-show="disp3">Confirm Password</span>
<br>
<button class="btn btn-primary" ng-click="mod()">Save</button>
</form>
<br>
<button class="btn btn-primary" ng-click="reset()">Reset</button>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$scope.reset = function() {
$scope.opwd = '';
$scope.npwd = '';
$scope.cnpwd = '';
$scope.disp1 = false;
$scope.disp2 = false;
$scope.disp3 = false;
}
$scope.mod = function() {
$http({
method: "post",
url: "includes/admin.inc.php?page=mod",
data: {
'opwd': $scope.opwd,
'npwd' : $scope.npwd,
'cnpwd' : $scope.cnpwd
}
}).then(function (data) {
console.log(data);
if (data.data == 'wrng') $scope.disp1 = true;
else $scope.disp1 = false;
if (data.data == 'weak')$scope.disp2 = true;
else $scope.disp2 = false;
if (data.data == 'cnfrm')$scope.disp3 = true;
else $scope.disp3 = false;
if (data.data == 'success')
{
$scope.reset();
window.alert('Admin modified successfully!');
}
}, function myError(response) {
console.log('Error');
});
}
$scope.reset();
});
</script>
<?php
}
elseif($_GET['page'] == 'del') {
?>
<div class="container text-center" style="width:auto;" ng-app="myApp" ng-controller="customersCtrl">
<p><b style="font-size:25px;">Admin Deleting Page</b> <br><br></p>
<form>
<input class="form-control" type="text" ng-model="uid" name="uid" placeholder="UserName" autofocus>
<span ng-show="disp1">User Not found!</span>
<br>
<button class="btn btn-primary" ng-click="del()">Delete</button>
</form>
<br>
<button class="btn btn-primary" ng-click="reset()">Reset</button>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$scope.reset = function() {
$scope.uid = '';
$scope.pwd = '';
$scope.disp1 = false;
}
$scope.mod = function() {
$http({
method: "post",
url: "includes/admin.inc.php?page=mod",
data: {
'uid': $scope.uid,
'pwd' : $scope.pwd,
}
}).then(function (data) {
console.log(data);
if (data.data == 'Admin Id Not Found')
$scope.disp1 = true;
else
$scope.disp1 = false;
if (data.data == 1)
{
$scope.reset();
window.alert('Admin deleted successfully!');
}
}, function myError(response) {
console.log('Error');
});
}
$scope.reset();
});
</script>
<?php
}
else {
echo "<script>window.top.location='index.php'</script>";
//header("Location: index.php");
exit();
}
include_once 'footer.php';
?>