-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path_xtense.php
More file actions
88 lines (77 loc) · 2.53 KB
/
_xtense.php
File metadata and controls
88 lines (77 loc) · 2.53 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
<?php
/**
* _xtense.php
* @package Mod Cdr
* @author Machine
* @co-author Capi
* @version 1.60
* @license https://opensource.org/licenses/gpl-license.php GNU Public License
* @description Fichier de liaison xtense avec le mod Cdr
*/
if (!defined('IN_SPYOGAME'))
die("Hacking attempt");
global $db, $table_prefix, $user, $xtense_version;
$xtense_version = "2.2";
///define("TABLE_XTENSE_CALLBACKS", $table_prefix."xtense_callbacks");
define("TABLE_CDR", $table_prefix . "cdr");
// TEST XTENSE2
if (class_exists("Callback")) {
/**
* Class cdr_Callback
*/
class cdr_Callback extends Callback
{
public $version = '2.3.9';
/**
* @param $system
* @return int
*/
public function cdr($system)
{
global $io;
if (cdr($system))
return Io::SUCCESS;
else
return Io::ERROR;
}
/**
* @return array
*/
public function getCallbacks()
{
return array(array('function' => 'cdr', 'type' => 'system'));
}
}
}
/**
* @param $system
* @return bool
*/
function cdr($system)
{
global $db;
// dump($system);
// données a traiter
// timestamp actuel
$date = time();
$gal = (int)$system['galaxy'];
// On boucle dans la liste des résultats et on insert dans la DB
// Iterate all 15 positions so the preventive DELETE covers empty slots too
for ($i = 1; $i <= 15; $i++) {
$sys = ':' . (int)$system['system'] . ':' . $i;
$metal = isset($system['data'][$i]['debris']['metal']) ? (int)$system['data'][$i]['debris']['metal'] : 0;
$crystal = isset($system['data'][$i]['debris']['cristal']) ? (int)$system['data'][$i]['debris']['cristal'] : 0;
$deuterium = isset($system['data'][$i]['debris']['deuterium']) ? (int)$system['data'][$i]['debris']['deuterium'] : 0;
$total = $metal + $crystal + $deuterium;
// suppression preventive (pas de doublons et effacement des cdr qui n'existent plus)
// on supprime du param config
$query = "DELETE FROM " . TABLE_CDR . " WHERE `gal`='$gal' AND `coord`='$sys'";
$db->sql_query($query);
// si un cdr est present
if ($total > 5000) {
$query = "INSERT INTO " . TABLE_CDR . " (`date`, `total`, `metal`, `cristal`, `deuterium`, `gal`, `coord`) VALUES ('$date', '$total', '$metal', '$crystal', '$deuterium', '$gal', '$sys')";
$db->sql_query($query);
}
}
return true;
}