2 function userbymail($email)
4 foreach (glob("profile/*") as $useropt) {
5 if ($mailopt = @file_get_contents("$useropt/email.txt")
6 and rtrim($mailopt) == $email) {
7 return substr($useropt, strlen('profile/'));
13 function mailtoken($email)
15 $found = userbymail($email);
16 if (!$found) return FALSE;
18 $token = substr(sha1('$Random'.rand()), 0, 10);
19 if (!file_put_contents("profile/$found/.token", $token))
20 throw new Exception("could not store token for $found");
22 $sitename = $_SERVER['HTTP_HOST'];
23 $sitelink = 'https://'.$sitename;
26 '[[link]]' => "$sitelink/login/pass?token=$found:$token",
27 '[[site]]' => $sitename,
30 $mailbody = file_get_contents('login/mailpass.inc.txt');
31 $mailbody = str_replace(array_keys($rep), array_values($rep), $mailbody);
32 if (!$mailbody) throw new Exception('empty mail body');
33 $mailsub = "Wachtwoord-reset voor $sitename";
35 return mail($email, $mailsub, $mailbody);