-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmailBox.php
More file actions
110 lines (96 loc) · 3.35 KB
/
mailBox.php
File metadata and controls
110 lines (96 loc) · 3.35 KB
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
<?php
foreach (glob("API/*.php") as $filename){include_once $filename;}
foreach (glob("API/managers/*.php") as $filename){include_once $filename;}
foreach (glob("API/template/*.php") as $filename){include_once $filename;}
require './LanguageManager.php';
$socketManager = new SocketManager();
$languageManager = new LanguageManager();
session_start();
if(!$socketManager->isDBConnected()){
$file = fopen("page/unavailable/unavailable.html","r");
$var = array(
array("UNAVAILABLE", "unavailable"),
array("SORRYUNAV", "unavailableMessage")
);
while(!feof($file)) {
$result = fgets($file);
foreach($var as $keyVal){
$result = str_replace($keyVal[0], $languageManager->getFromLang($keyVal[1]), $result);
}
echo $result;
}
fclose($file);
die(0);
}
while($socketManager->getUserManager() == null){$i = 0;}
$userManager = $socketManager->getUserManager();
if(isset($_SESSION["connected"]) && isset($_SESSION["uuid"]) && $_SESSION["connected"] === true && $userManager->getUserByID($_SESSION["uuid"]) != null){
$file = fopen("page/mailBox/mailBox.html","r");
$var = array(
array("OMAILBOX", "mailbox"),
array("OSEARCH", "search"),
array("ONEW_MAIL", "newMail"),
array("OSENDED_MAIL", "sendedMail"),
array("ORECEIVED_MAIL", "receivedMail"),
array("OLOGOUT", "logout"),
array("ODESTINATOR", "destinator"),
array("OOBJECT", "mailObject"),
array("OMAIL_MESSAGE_CONTENT", "mailContent"),
array("OSEND", "send")
);
while(!feof($file)) {
$result = fgets($file);
foreach($var as $keyVal){
$result = str_replace($keyVal[0], $languageManager->getFromLang($keyVal[1]), $result);
}
echo $result;
}
fclose($file);
}else{
$file = fopen("page/authentification/authentification.html", "r");
$var = array(
array("AUTHENTIFICATION", "authentification"),
array("MAIL", "mail"),
array("PASSWORD", "password"),
array("LOGIN", "login")
);
while(!feof($file)) {
$result = fgets($file);
foreach($var as $keyVal){
$result = str_replace($keyVal[0], $languageManager->getFromLang($keyVal[1]), $result);
}
echo $result;
}
fclose($file);
}
if($_SERVER["REQUEST_METHOD"] == "POST"){
if(isset($_POST["mail"]) && isset($_POST["password"])){
$mail = explode(".", $_POST["mail"]);
$firstname = $mail[0];
$name = explode("@", $mail[1])[0];
$group = explode("@", $mail[1])[1];
$password = $_POST["password"];
$user = $userManager->getUserByName($name, $firstname);
if($user === null){
$socketManager->disconnect();
header("location: mailbox.php");
return;
}
if($user->getPassword() === $password && $user->getGroup() === $group){
$_SESSION["connected"] = true;
$_SESSION["uuid"] = $user->getUUID();
$socketManager->disconnect();
header("location: mailbox.php");
}
}
}
if($_SERVER["REQUEST_METHOD"] == "GET"){
if(isset($_GET['disconnect'])){
$_SESSION["connected"] = false;
$_SESSION["uuid"] = "";
$socketManager->disconnect();
header("location: mailbox.php");
}
}
$socketManager->disconnect();
?>