summaryrefslogtreecommitdiff
path: root/intern.gospeladlershof.de/code/login.php
blob: 002ddd3f899e9081b3990d0e5f830659990f2cbc (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
<?php

define("LOGIN_SITE", true);
require_once __DIR__ . '/session.php';
require_once __DIR__ . '/../vendor/autoload.php';
use Pheanstalk\Pheanstalk;

$mail = strtolower($_REQUEST["email"]);
$passwd = hash("sha512", $_REQUEST["password"]);

$addresses= file(__DIR__ . "/../../intern/chor_list_members.txt", FILE_IGNORE_NEW_LINES);

foreach($addresses as $a) {

	if ( $mail === strtolower($a) ) {
		$hash = chr( mt_rand( 97 ,122 ) ) .substr( md5( time( ) ) ,1 );
		ob_start();
		require __DIR__ . '/template/html_mail.php';
		$htmlmessage = ob_get_clean();

		ob_start();
		require __DIR__ . 'template/text_mail.php';
		$textmessage = ob_get_clean();

		$redis = new Predis\Client([
			'scheme' => 'tcp',
			'host'   => '192.168.122.1',
			'port'   => 6379,
			'database' => 2,
		]);

		$redis->set($mail, $hash, "ex", 86400); // hält den Wert für 24h

		$pheanstalk = new Pheanstalk('192.168.122.1');

		$data = array(
			'To' => $mail,
			'Name' => 'Gospelchor Adlershof',
			'From' => 'noreply@gospeladlershof.de',
			'ReplyTo' => 'webmaster@gospeladlershof.de',
			'Subject' => 'Gospelchor Adlershof | Login',
			'HTMLMessage' => $htmlmessage,
			'TextMessage' => $textmessage,
		);

		$pheanstalk
			->useTube('contactme_mailer')
			->put(json_encode($data));

		$_SESSION["user"] = $mail;

		error_log(json_encode($data));
	}
}

header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
header("Location: /check_login.php");

	/*
		$_SESSION["login"] = true;
		$_SESSION["success"] = "Erfolgreich eingeloggt.";

		$_SESSION["dontdisplaydeploybutton"] = 1;
		$_SESSION["user"] = $mail;

		header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
		header("Location: /");

		exit;
	}
}

$_SESSION["login"] = false;
$_SESSION["error"] = "E-Mail oder Passwort stimmmen nicht überein.";

header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
header("Location: /login.php");
	 */