Update reset.php
[clinton/MarylandElectronicPetitionSignature.git] / admin / reset.php
CommitLineData
532de2f1 1<?PHP
60eab1aa 2include_once('../slack.php');
532de2f1 3include_once('/var/www/secure.php');
0dd4d9f7 4include_once('../email.php');
532de2f1
PM
5if(isset($_POST['email'])){
6 $email = $_POST['email'];
7 $r = $petition->query("SELECT * FROM users WHERE email = '$email'");
0dd4d9f7
PM
8 $row = mysqli_fetch_array($r,MYSQLI_ASSOC);
9 if ($row['email'] != ''){
532de2f1
PM
10 $pass = rand(1000,9999);
11 $salt = md5(rand(1000,9999));
12 $hash = md5($pass.$salt);
13 $encrypted = $hash.':'.$salt;
0dd4d9f7
PM
14 //off_world_mail(,,);
15 $subject = 'MD Petition Login';
bb171a21 16 $body = 'Login with '.$email.' and your new password '.$pass.' at https://www.md-petition.com/admin/login.php';
0dd4d9f7 17 meps_mail($email,$body,$subject);
532de2f1
PM
18 $petition->query("update users set pass = '$encrypted' WHERE email = '$email'");
19 echo "<h1>Your Password has been Sent.</h1>";
2d021f26 20 slack_general_admin('DEBUG: '.$body,'md-petition-signed');
532de2f1
PM
21 }else{
22 echo "<h1>E-Mail address not found.</h1>";
9503f62a 23 slack_general('ADMIN: Reset- E-Mail address not found','md-petition');
532de2f1 24 }
9503f62a
PM
25}else{
26 slack_general('ADMIN: reset.php','md-petition');
532de2f1
PM
27}
28?>
301ed955
PM
29<script async src="https://www.googletagmanager.com/gtag/js?id=G-TY6C66ZWMX"></script>
30<script>
31 window.dataLayer = window.dataLayer || [];
32 function gtag(){dataLayer.push(arguments);}
33 gtag('js', new Date());
532de2f1 34
301ed955
PM
35 gtag('config', 'G-TY6C66ZWMX');
36</script>
532de2f1
PM
37<form action="reset.php" method="post" accept-charset="utf-8"> <table>
38 <tbody><tr>
39 <td>E-Mail Address</td>
40 <td><input type="text" name="email" value=""></td>
41 </tr>
42 <tr>
43 <td>&nbsp;</td>
2f840576 44 <td><input type="submit" name="resetGo" value="Reset Password"> or <a href='login.php'>Login Here</a></td>
532de2f1
PM
45 </tr>
46 </tbody></table>
47</form>