forked from OGSteam/ogspy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.php
executable file
·133 lines (115 loc) · 3.7 KB
/
common.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
<?php
/**
* Main file which do includes et set up all data for the application
* @package OGSpy
* @subpackage main
* @author Kyser
* @copyright Copyright © 2007, http://ogsteam.fr/
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 3.04
*/
if (!defined('IN_SPYOGAME')) {
die("Hacking attempt");
}
// PHP5 with register_long_arrays off?
if (!isset($HTTP_POST_VARS) && isset($_POST)) {
$HTTP_POST_VARS = $_POST;
$HTTP_GET_VARS = $_GET;
$HTTP_SERVER_VARS = $_SERVER;
$HTTP_COOKIE_VARS = $_COOKIE;
$HTTP_ENV_VARS = $_ENV;
$HTTP_POST_FILES = $_FILES;
// _SESSION is the only superglobal which is conditionally set
if (isset($_SESSION)) {
$HTTP_SESSION_VARS = $_SESSION;
}
}
//Récupération des paramètres de connexion à la base de données
if (file_exists("parameters/id.php")) {
require_once ("parameters/id.php");
} else {
if (!defined("OGSPY_INSTALLED") && !defined("INSTALL_IN_PROGRESS") && !defined("UPGRADE_IN_PROGRESS")) {
header("Location: install/index.php?lang=fr");
exit();
} elseif (file_exists('../parameters/id.php')) {
require_once ('../parameters/id.php');
}
}
//Appel des fonctions
require_once ("includes/config.php");
require_once ("includes/admin_functions.php");
require_once ("includes/functions.php");
require_once ("includes/mysql.php");
require_once ("includes/log.php");
require_once ("includes/galaxy.php");
require_once ("includes/user.php");
require_once ("includes/sessions.php");
require_once ("includes/help.php");
require_once ("includes/mod.php");
require_once ("includes/ogame.php");
require_once ("includes/cache.php");
require_once ("includes/chart_js.php");
if (defined("OGSPY_INSTALLED")){
require_once ("includes/mail.php");
require_once ("includes/token.php");
}
//Récupération des valeur GET, POST, COOKIE
extract($_GET, EXTR_PREFIX_ALL, "pub");
extract($_POST, EXTR_PREFIX_ALL, "pub");
extract($_COOKIE, EXTR_PREFIX_ALL, "pub");
foreach ($_GET as $secvalue) {
if (!check_getvalue($secvalue)) {
die("I don't like you...");
}
}
foreach ($_POST as $secvalue) {
if (!check_postvalue($secvalue)) {
header("Location: index.php");
die();
}
}
//Language File
if (!isset($ui_lang)) { // Checks the ui_lang value from parameters file
if (isset($pub_lang)) {
$ui_lang = $pub_lang; //This value is used during installation
} else {
$ui_lang = "fr";
}
//If no language is available in id.php file we take fr by default
}
require_once ("lang/lang_main.php");
// ajout fichier clef unique
if (!defined("INSTALL_IN_PROGRESS") && !defined("UPGRADE_IN_PROGRESS")) {
if (file_exists('parameters/key.php')) {
require_once ('parameters/key.php');
$dossierParent = (__FILE__);
$path = $_SERVER["SCRIPT_FILENAME"]; ;
if ($path != $serveur_path) {
generate_key();
} // regenere que si incoherence d url
} else // non bloquant
{
generate_key();
}
}
//Connexion à la base de donnnées
if (!defined("INSTALL_IN_PROGRESS")) {
// appel de l instance en cours
$db = sql_db::getInstance($db_host, $db_user, $db_password, $db_database);
if (!$db->db_connect_id) {
die("Impossible de se connecter à la base de données");
}
//Récupération et encodage de l'adresse ip
$user_ip = $_SERVER['REMOTE_ADDR'];
$user_ip = encode_ip($user_ip);
// initialisation des variables en cache
init_serverconfig();
init_mod_cache();
if (!defined("UPGRADE_IN_PROGRESS")) {
session();
maintenance_action();
}
}
if (isset($server_config["log_phperror"]) && $server_config["log_phperror"] == 1) {
set_error_handler('ogspy_error_handler');
}