aboutsummaryrefslogtreecommitdiff
path: root/reset.php
blob: 793f0005b50d92ea42c7bd1b9d999528535c5d94 (plain)
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
<?php session_start() ?>
<!doctype html>

<html>
 <head>
  <title>Junge Gemeinde Adlershof.</title>
  <meta http-equiv='Content-type' content='text/html; charset=utf-8' />
  <link rel='stylesheet' type='text/css' href='hyperstyle.css' />
  <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'>
 </head>

 <body link="#000000" vlink="#000000" alink="#FF0000">

<?php

if($_SESSION["login"]){

include("header.php");

} else {
	echo "
	<div id='header' class='kleineschrift'>
	<br><br>
	<hr>
	</div>
	";

$startseite="<div class='kleineschrift'><a style='text-decoration:underline;' href='login.php'>Zurück zur Startseite.</a></div>";
}
?>
        <div id='content_container' align="center"><br>

        <div align='center'>
        <p5>JUNGE GEMEINDE ADLERSHOF</p5>
<br><br><div id='behaelter' align='center'>

<?php

$email_post = $_POST["email"];
$try = $_POST["try"];

if (empty($email_post)){
echo "
<a5>Gib deine E-Mail Adresse ein, um dir ein neues Passwort zuzuschicken.</a5><br><br>
<form action='reset.php' method='post'>
<input type='text' name='email' size='30'/>
</form>
";
} else {

	/*___Datenbank___*/
	$db_check = new SQLite3("../database/share.db");
	$safe_email = SQLite3::escapeString("$email_post");

        $email_db = $db_check->query("SELECT email FROM user WHERE email='$safe_email';");
        while($email_array = $email_db->fetchArray(SQLITE3_NUM)){
                foreach($email_array as $thirdelement){
                        $email=$thirdelement;
                }
        }

	if (empty($email)){
		$try = $try +1;

		if ($try > 0){
			header("HTTP/1.0 401 Unauthorized");
		}
		$maxtry = 3 - $try;

			if ($maxtry == 0) {
				echo "<a4><b>YOU ARE BANNED! ;_;</b></a4><br>	";
				header("Refresh: 3; /401");

			} else {
				echo "<a5>Die E-Mail ist nicht in der Datenbank gespeichert. Achte auf Tippfehler und probiere noch einmal.<br>
				Du hast noch $maxtry Versuche, bevor du gesperrt wirst.</a5>
				<br><br>
				<form action='reset.php' method='post'>
				<input type='text' name='email' size='30'/>
				<input type='hidden' name='try' value='$try'/>
				</form>
				";
			}
	} else {

		$secret = explode(" ", "a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9");
		shuffle($secret);
		$secret = substr(implode($secret), 0, 10);

	        $salt = uniqid(mt_rand(), true);
        	$password = "$salt"."$secret";
	        $hash_password = md5($password);
        	for($i=0;$i<15000;$i++)
                	$hash_password = md5($hash_password);

		$result = $db_check->exec("UPDATE user SET password='$hash_password', salt='$salt' where email='$email';");

		echo "Wir haben deine E-Mail in der Datenbank. Eine E-Mail mit deinem neuen Passwort wurde soeben verschickt.<br>";

//		exec('curl -vv --user max:sommer13 -F sender="mailer-daemon@jg-adlershof.de" -F recipient="'.$email.'" -F subject="Angefordertes neues Passwort - BITTE NICHT ANTWORTEN"  -F message="Dein neues Passwort lautet: '.$secret.'." http://playground.oweissbarth.de/mail/send.php'); 


	}


}

?>
<br>
<?php echo $startseite; ?>
</div>
</div>
</div>
</body>
</html>
<?php 
?>