-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResetallusers.php
More file actions
130 lines (87 loc) · 3.97 KB
/
Resetallusers.php
File metadata and controls
130 lines (87 loc) · 3.97 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
<?php
require_once('inc/startsession.php');
/////////////////////////////////////////////////////////////////////
//
// Written by Jim Garbe-- Dynamic Checksheet
//
/////////////////////////////////////////////////////////////////////
$Title="Reset All Users' Passwords";
require_once('inc/appvars.php');
require_once('inc/title.php');
/////////////////////////////////
//Bring in functions of "chkclass.php"
/////////////////////////////////
require_once("inc/functions.php.inc");
require_once('inc/connectvars.php');
// Generate the navigation menu
if (isset($_SESSION['username']) && ($_SESSION['status'] == 1)) {
}
else {
echo ' <a href="login.php">Log In As An Administrator(' . $_SESSION['username'] . ').</a><br />';
// echo ' <a href="signup.php">Sign Up</a>';
}
?>
</div>
<?php
// Generate the navigation menu
if (isset($_SESSION['username']) && ($_SESSION['status'] == 1)) {
if (isset($_POST['reset'])&& !empty($_POST['confirm']) && !empty($_POST['prepend'])) {
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
// Grab the data from the _user database.
echo"<table style=color:white;>";
// Retrieve the user data from MySQL
$chquery = "SELECT user_id,username FROM _user WHERE user_id != 1";
$chdata = mysqli_query($dbc, $chquery);
while($chuser=mysqli_fetch_array($chdata)){
$chuser_id=$chuser['user_id'];
$chusername=$chuser['username'];
$prepchusername=$_POST['prepend'].$chusername;
print("<tr><td>$chuser_id</td><td>$chusername</td><td>$prepchusername</td></tr>");
$query2 = "UPDATE _user SET password = SHA('$prepchusername')" .
" WHERE user_id = '" . $chuser['user_id'] . "'";
$chdata2= mysqli_query($dbc,$query2);
}
?>
</table>
<div align="center"><a href=Resetallusers.php>BACK</a></div>
<?php
} elseif (isset($_POST['reset2'])&& empty($_POST['confirm']) && !empty($_POST['prepend'])) {
?> <form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php
echo '<center><p class="error" style=font-size:1.4em>Warning:<br>';
echo 'Resetting all passwords will not allow anyone access until they are given the new password. </p>';
echo 'Please confirm that you want to reset all passwords. </p></center>'; ?>
<center> <label for="confirm">Confirm:</label>
<input type="checkbox" id="confirm" name="confirm" value="1" /><br /> <br>
<label for="prepend">Prepend:</label>
<input type="text" id="prepend" name="prepend" value="<?php if (!empty($_POST['prepend'])) echo $_POST['prepend']; ?>" /></center><br>
<div align="center"><input type="submit" value="OK" name="reset" /></div>
</form> <div align="center"><a href=Resetallusers.php>BACK</a></div>
<?php
}
elseif (isset($_POST['reset2']) && empty($_POST['prepend'])) {
echo '<center><p class="error">You should prepend your reset passwords.<br> (example-- 123 = 123password or XXX = XXXpassword ). </p></center>'; ?>
<form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label for="prepend">New Prepend:</label>
<input type="text" id="prepend" name="prepend" value="<?php if (!empty($_POST['prepend'])) echo $_POST['prepend']; ?>" />
<div align="center"><input type="submit" value="Try Again" name="reset2" /></div>
</form>
<div align="center"><a href=Resetallusers.php>BACK</a></div>
<?php
} else {
?>
<form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<h2>To Reset ALL Passwords</h2>
<p>The new passwords will reset to a "prepend" and the username. <br> (example-- 123 = 123username or XXX = XXXusername ). </p>
<label for="prepend">New Prepend:</label>
<input type="text" id="prepend" name="prepend" value="<?php if (!empty($_POST['prepend'])) echo $_POST['prepend']; ?>" />
<center><input type="submit" value="Reset" name="reset2" /></center>
</form>
<?php
}
}
?>
<div class="push"></div>
</div>
</body>
</html>