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;
17 $user = new User("profile/$found");
18 if (empty($user)) return FALSE;
20 $token = substr(sha1('$Random'.rand()), 0, 10);
21 if (!file_put_contents("profile/$found/.token", $token))
22 throw new Exception("could not store token for $found");
24 $sitename = preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
25 $sitelink = 'https://'.$sitename;
27 '[[user]]' => $user->name ?: $found,
28 '[[link]]' => "$sitelink/login/pass?token=$found:$token",
29 '[[site]]' => $sitename,
32 $mailbody = file_get_contents('login/mailpass.inc.txt');
33 $mailbody = str_replace(array_keys($rep), array_values($rep), $mailbody);
34 if (!$mailbody) throw new Exception('empty mail body');
35 $mailsub = "Wachtwoord-reset voor $sitename";
36 $mailhead = "From: $sitename <info@$sitename>";
37 $rcpt = "$found <$email>";
39 return mail($rcpt, $mailsub, $mailbody, $mailhead);