-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathglobals.php
135 lines (133 loc) · 3.59 KB
/
globals.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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
declare(strict_types=1);
/**
* MCCodes v2 by Dabomstew & ColdBlooded
*
* Repository: https://github.com/davemacaulay/mccodesv2
* License: MIT License
*/
if (str_contains($_SERVER['PHP_SELF'], 'globals.php'))
{
exit;
}
session_name('MCCSID');
session_start();
if (!isset($_SESSION['started']))
{
session_regenerate_id();
$_SESSION['started'] = true;
}
ob_start();
require 'lib/basic_error_handler.php';
set_error_handler('error_php');
require 'global_func.php';
$domain = determine_game_urlbase();
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == 0)
{
$login_url = "https://{$domain}/login.php";
header("Location: {$login_url}");
exit;
}
$userid = (int)($_SESSION['userid'] ?? 0);
require 'header.php';
global $_CONFIG;
include 'config.php';
const MONO_ON = 1;
require "class/class_db_{$_CONFIG['driver']}.php";
$db = new database();
$db->configure($_CONFIG['hostname'], $_CONFIG['username'],
$_CONFIG['password'], $_CONFIG['database']);
$db->connect();
$c = $db->connection_id;
$set = get_site_settings();
if ($set['use_timestamps_over_crons']) {
define('SILENT_CRONS', true);
try {
require_once __DIR__ . '/crons/cronless_crons.php';
} catch (Exception $e) {
echo 'An error occurred' . (defined('DEBUG') && DEBUG ? ':<br>'.$e->getMessage() : '');
exit;
}
}
global $jobquery, $housequery;
if (isset($jobquery) && $jobquery)
{
$is =
$db->query(
"SELECT `u`.*, `us`.*, `j`.*, `jr`.*
FROM `users` AS `u`
INNER JOIN `userstats` AS `us`
ON `u`.`userid`=`us`.`userid`
LEFT JOIN `jobs` AS `j` ON `j`.`jID` = `u`.`job`
LEFT JOIN `jobranks` AS `jr`
ON `jr`.`jrID` = `u`.`jobrank`
WHERE `u`.`userid` = {$userid}
LIMIT 1");
}
elseif (isset($housequery) && $housequery)
{
$is =
$db->query(
"SELECT `u`.*, `us`.*, `h`.*
FROM `users` AS `u`
INNER JOIN `userstats` AS `us`
ON `u`.`userid`=`us`.`userid`
LEFT JOIN `houses` AS `h` ON `h`.`hWILL` = `u`.`maxwill`
WHERE `u`.`userid` = {$userid}
LIMIT 1");
}
else
{
$is =
$db->query(
"SELECT `u`.*, `us`.*
FROM `users` AS `u`
INNER JOIN `userstats` AS `us`
ON `u`.`userid`=`us`.`userid`
WHERE `u`.`userid` = {$userid}
LIMIT 1");
}
$ir = $db->fetch_row($is);
set_userdata_data_types($ir);
if ($ir['force_logout'] > 0)
{
$db->query(
"UPDATE `users`
SET `force_logout` = 0
WHERE `userid` = {$userid}");
session_unset();
session_destroy();
$login_url = "https://{$domain}/login.php";
header("Location: {$login_url}");
exit;
}
global $macropage;
if ($macropage && !$ir['verified'] && $set['validate_on'] == 1)
{
$macro_url = "https://{$domain}/macro1.php?refer=$macropage";
header("Location: {$macro_url}");
exit;
}
check_level();
$h = new headers();
if (!isset($nohdr) || !$nohdr)
{
$h->startheaders();
$fm = money_formatter($ir['money']);
$cm = money_formatter($ir['crystals'], '');
$lv = date('F j, Y, g:i a', $ir['laston']);
global $atkpage;
if ($atkpage)
{
$h->userdata($ir, $lv, $fm, $cm, 0);
}
else
{
$h->userdata($ir, $lv, $fm, $cm);
}
global $menuhide;
if (!$menuhide)
{
$h->menuarea();
}
}