-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ajax.php
85 lines (74 loc) · 2.03 KB
/
main.ajax.php
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
<?php
define("REGISTER_HIT", false);
include('main.loader.php');
if(isset($_POST))
{
switch(@$_POST["action"]) //Voy a hacer que los cases esten mejor escritas, dos palabras la primera en miuscula y la segunda en mayuscula
{
case "login":
$expireTime = @$_POST['duration'];
$username = mysqli_escape_string(Database::conn(), @$_POST['username']);
$password = @$_POST['password'];
UserLogin::Login($expireTime, $username, $password);
break;
case "register":
$username = mysqli_escape_string(Database::conn(), @$_POST['username']);
$password = @$_POST['password'];
$email = mysqli_escape_string(Database::conn(), @$_POST['email']);
$cpass = @$_POST['pass_confirm'];
UserRegister::Register($username, $password, $cpass, $email);
break;
case "logout":
if(UserUtils::getStat() !== null)
UserLogout::Logout();
break;
case 'admin-enter':
$pass = $_POST["adminpass"];
if($pass == Settings::$adminpass)
{
$_SESSION["admin"] = true;
header("Refresh:0");
}
else
ContentManager::addMsg('wrongAdminPass');
if(!ContentManager::$msg_list)
{
ContentManager::$msg_type = 1;
ContentManager::addMsg("admin-login");
}
break;
case 'getOnlinePeople':
$data = $_POST['data'];
$t = 120;
if(isset($data) && is_numeric($data)) {$t = $data*60;}
echo count(UserUtils::getOnlinePeople($t));
break;
case 'getads':
$i = 0;
$rawdata = array();
$resultado = Announcement::getAnnouncementsByLang(Lang::$lang->lang_name,Announcement::getRandom());
echo json_encode($resultado);
break;
case 'getSetting':
$name = @$_POST['name'];
if(isset($name))
{
$sett = SettingsManager::get($name);
$data = @unserialize($sett);
echo json_encode($data !== false ? $data : $sett);
}
//else
// addMsg('undefinedSettName');
break;
default:
die("Action '".@$_POST["action"]."' not registered!");
break;
}
if(isset($_POST["showlist"]))
echo ContentManager::getList(Lang::$lang);
}
else
{
header("Location: /");
exit;
}