-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
99 lines (87 loc) · 3.1 KB
/
admin.php
File metadata and controls
99 lines (87 loc) · 3.1 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
<?php
require './LanguageManager.php';
$languageManager = new LanguageManager();
session_start();
//$adminAcces = fopen("../config", "a+");
if(filesize("../config") == 0){die("Please use the installer to config the service");}
$file = file("../config");
if(count($file) < 5){die("Please use the installer to config the service");}
//$content = explode("AAA", fread($adminAcces, filesize("../config")));
//if(empty($content)){die("Please use the installer to config the service");}
$adminUser = null;
$adminPassword = null;
foreach($file as $line){
$line = (array_search($line, $file, true) == count($file)-1 ? $line : substr($line, 0, -2));
if(str_starts_with($line, "adminUsername=")){
$line = str_replace("adminUsername=", "", $line);
$adminUser = $line;
}
if(str_starts_with($line, "adminPassword=")){
$line = str_replace("adminPassword=", "", $line);
$adminPassword = $line;
}
}
if($adminUser == null || $adminUser == ""){die("Please use the installer to config the admin user");}
if(isset($_SESSION["adminConn"]) && $_SESSION["adminConn"] == ($adminUser . $adminPassword)){
$file = fopen("page/admin/panel.html","r");
$var = array(
array("ADMIN_PANEL", "adminPanel"),
array("CREATE_USER", "createUser"),
array("MODIFY_USER", "modifyUser"),
array("SAVE_CHANGES", "save"),
array("SHOW_INFOS", "showInfos"),
array("ONAME", "name"),
array("OFIRSTNAME", "firstname"),
array("OPASSWORD", "password"),
array("OGROUP", "group"),
array("SHOW", "show"),
array("CHANGE_DB_INFOS", "changeDBInfos"),
array("SEND", "send"),
array("USERNAME", "username"),
array("MAIL", "mail"),
array("ONAME", "name"),
array("NEW_NAME", "newName"),
array("NEW_FIRSTNAME", "newFirstname"),
array("NEW_PASSWORD", "newPassword"),
array("NEW_GROUP", "newGroup")
);
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/admin/connection.html","r");
$var = array(
array("ADMIN_PANEL_CONNECTION", "adminPanelConnection"),
array("USERNAME", "username"),
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"){
$username = $_POST["username"];
$password = $_POST["password"];
if($username == $adminUser && $password == $adminPassword){
$_SESSION["adminConn"] = $username . $password;
header("location: admin.php");
}
}
if($_SERVER["REQUEST_METHOD"] == "GET"){
if(isset($_GET["disconnect"])){
$_SESSION["adminConn"] = "";
header("location: admin.php");
}
}
?>