-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadmin_acc_settings2.php
More file actions
205 lines (181 loc) · 5.4 KB
/
admin_acc_settings2.php
File metadata and controls
205 lines (181 loc) · 5.4 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
<?php
//============================================================+
// File name : admin_acc_settings2.php
//
// Description : Admin Account Settings
//
// Author: Aditya Mathur
//
// (c) Copyright:
// Aditya Mathur
// eztasker.com
//
// License:
// Copyright (C) 2014 Aditya Mathur - eztasker.com
//============================================================+
session_start();
if(isset($_SESSION['li_uname111'])){
$e=$_SESSION['li_uname111'];
$type=1;
$permission=$_SESSION['li_permission111'];
if($permission==1){
// proceed.
}
else{
//deny
echo "<script> alert('Sorry! you do not have enough privileges to view this page!') </script>" ;
header('location:index.php');die;
}
}else{
header('location:index.php');die; //kill script & jump to login page
}
?>
<!-- Header -->
<?php include('./includes/header.php');?>
<div class="">
<!-- Menus -->
<?php include './includes/menu.php';?>
</div>
<div class="spacer"></div>
</div>
<?php
function checkEmail($email){
$pattern = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i";
if (preg_match($pattern, trim(strip_tags($email)))){
return true;
} else {
return false;
}
}
?>
<?php
function searchAccount($row){
$url=base64_encode($row[0]);
$url2=base64_encode($row[6]);
?>
<table class='main-table'>
<tr><td>
<table class=''>
<tr><td colspan=2><br/><h2><?php echo $row['fname']." ".$row['lname'];?> </h2></td></tr>
<tr>
<td colspan=2>
<a href="admin_acc_settings3.php?v=<?php echo $url?>">Edit Account</a>
<a href="admin_acc_settings2.php?v=<?php echo $url?>&v2=<?php echo $url2?>" onclick="return confirm('Are you sure?');">Delete</a>
</td>
</tr>
<tr><td colspan=2><br/><div class="hr"><hr /></div><br/></td></tr>
<tr>
<td><strong>Account Name</strong></td>
<td><?php echo $row['fname']." ".$row['lname'];?></td>
</tr>
<tr>
<td><strong>Email</strong></td>
<td><?php echo $row['email']?></td>
</tr>
<tr>
<td><strong>Permission</strong></td>
<td><?php if($row['permission']==1){echo "Is Owner";}else{echo "Is Admin";}?></td>
</tr>
<tr>
<td><strong>Account Created on</strong></td>
<td><?php echo $row['created']?></td>
</tr>
</table>
</td></tr>
</table>
<br><br>
<?php } ?>
<?php
function delAccount($id,$permission){
require_once './includes/db_config.php';
connect();
if($permission==1){
$query1 = "select * from admin where permission=1";
$result1=mysql_query($query1) or die(mysql_error());
if(mysql_num_rows($result1)<2){
//deny
echo "<script> alert('Can not delete owner\'s last account. Please create a new one before deleting this.')</script>";
echo "<script> window.location='admin_acc_settings.php'</script>";die;
}else{
$query = "DELETE from admin where id = '".$id."' ";
mysql_query($query) or die(mysql_error());
echo "<script> alert('Account Deleted!')</script>";
echo "<script> window.location='admin_acc_settings.php'</script>";
}
}
else{
$query = "DELETE from admin where id = '".$id."' ";
mysql_query($query) or die(mysql_error());
echo "<script> alert('Account Deleted!')</script>";
echo "<script> window.location='admin_acc_settings.php'</script>";
}
}
//get data via del link
if(isset($_REQUEST['v']) && isset($_REQUEST['v2'])){
$t1=trim($_REQUEST['v']);
$id=base64_decode($t1);
$t2=trim($_REQUEST['v2']);
$permission=base64_decode($t2);
delAccount($id, $permission);
}
?>
<table class='main-table' >
<form name='form1' method='GET' action="admin_acc_settings2.php">
<tr>
<td colspan="2"><center></br></br>
<input type='text' name='email' size='70' placeholder='Enter Email'>
<input type='submit' name='search' value='Search'>
<input type='submit' name='view' value='View All'></center>
</td>
</tr>
<tr><td colspan=2><br/><br/></td></tr>
</form><br>
</table><br><br>
<?php
/* ___code to Search Particular Record________*/
if(isset($_GET['search'])){
$email=$_GET['email'];
$email=preg_replace( '/\s+/','',$email);
if($email==""){
unset($email);
echo "<script>window.location='admin_acc_settings.php'</script>" ;die;
}
if(!checkEmail($email)){
echo "<script> alert('Please Enter valid email ID.') </script>" ;
echo "<script>window.location='admin_acc_settings.php'</script>" ;die;
}
require_once './includes/db_config.php';
connect();
$query1 = "select * from admin where email='".$email."'";
$result1=mysql_query($query1) or die(mysql_error());
if(mysql_num_rows($result1)>0){
while($row=mysql_fetch_array($result1)){
searchAccount($row);
}
}else{
echo "<script> alert('No record found for this email') </script>" ;
echo "<script>window.location='admin_acc_settings.php'</script>" ;die;
}
}
?>
<?php
//////////* ______code to display All Admin Record________*///////////
if(isset($_GET['view']))
{
require_once './includes/db_config.php';
connect();
echo"<table><tr><td colspan=2><br/><h2>All Admins</h2><br/></td></tr></table>";
$query1 = "select * from admin";
$result1=mysql_query($query1) or die(mysql_error());
if(mysql_num_rows($result1)>0){
while($row=mysql_fetch_array($result1)){
searchAccount($row);
}
}else{
echo "<script> alert('No record found for this email') </script>" ;
echo "<script>window.location='admin_acc_settings.php'</script>" ;die;
}
}
?>
<!-- footer -->
<?php include('./includes/footer.php');?>