-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_cron.php
127 lines (106 loc) · 3.28 KB
/
index_cron.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
<?php
/**
* Dispatcher général du site
*
*
*/
session_start();
ini_set('display_errors', 1);
error_reporting(E_ALL);
/**
* Détermination des PATH et URL absolus pour être utilisés dans tout le site
*
* Note : tous les PATH et URL se finissent par '/'
*/
$URL_ROOT_RELATIVE = dirname($_SERVER['PHP_SELF']);
if($URL_ROOT_RELATIVE[strlen($URL_ROOT_RELATIVE) - 1] == '/') {
$URL_ROOT_RELATIVE = substr($URL_ROOT_RELATIVE, 0, -1);
}
define('URL_ROOT_RELATIVE', $URL_ROOT_RELATIVE);
// Constante principale, c'est l'URL absolue de la base du site
define("URL_ROOT", 'http://scramblednations.com/');
// PATH absolu de la base du site
define('DIR_ROOT', dirname($_SERVER['SCRIPT_FILENAME']) .'/');
// PATH du répertoire d'inclusions
define('DATA', DIR_ROOT.'data/');
// PATH du répertoire d'inclusions
define('INC', DIR_ROOT.'inc/');
// PATH du répertoire des templates
define('TPL', DIR_ROOT.'template/');
// Constante de debug SQL général
define('DEBUG_SQL', false);
// Suppression des antislashes
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}
$flag_prod = true;
// Fichier de paramétrage
require_once(INC.'constantes.inc.php');
// Fonctions MySQL
require_once(INC.'db.inc.php');
// Fonctions générales
require_once(INC.'fonctions.inc.php');
// i18n functions
require_once(INC.'i18n.inc.php');
// Extending GD functions
require_once(INC.'gd.inc.php');
// Fonctions liées aux pages
require_once(INC.'page.inc.php');
// Fonctions système de fichier
require_once(INC.'files.inc.php');
// Fonctions envoi de mail
require_once(INC.'PHPMailer/class.phpmailer.php');
//Includes classes
require_once('data/db_object.class.php');
require_once( DATA.'order_type/iorder.php');
require_once( INC.'borderlines.inc.php');
if( isset( $_SERVER['REMOTE_ADDR'] ) ) redirect('/');
$flag_action = false;
if(! mysql_uconnect(DB_HOST, DB_USER, DB_PASS, DB_BASE)) {
echo "DB connection error";
die();
}else {
mysql_uquery("SET NAMES 'utf8'");
}
$options = getopt('cgw:');
if( isset($options['c'])) {
$game_list = Game::db_get_nonended_game_list();
foreach( $game_list as $game ) {
if( $game->started ) {
echo date('[Y-m-d H:i:s]').' Game "'.$game->name .'" => ';
if( $game->compute_auto() ) {
echo "turn computed\n";
}else {
echo "turn failed\n";
}
}else {
if( $game->min_players && count( $game->get_game_player_list() ) >= $game->min_players ) {
$game->start();
}
}
/*if( $game->has_ended( ) ) {
$new_game = clone $game;
$new_game->id = null;
$new_game->reset();
}*/
}
}
if( isset($options['g'])) {
echo "Generating worlds\n";
var_dump($options);
if( isset($options['w'])) {
$world = World::instance( $options['w'] );
echo $world->name."\n";
$world->initialize_territories();
}
}
?>