-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5d0593
commit b8f9a00
Showing
18 changed files
with
1,379 additions
and
1,379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,67 @@ | ||
<?php | ||
/** | ||
* @package Xtense 2 | ||
* @author Unibozu | ||
* @licence GNU | ||
*/ | ||
|
||
if (!defined('IN_SPYOGAME')) exit; | ||
|
||
/** | ||
* Gestion des fonctions de callback des plugins OGSpyw | ||
* | ||
*/ | ||
class CallbackHandler { | ||
private $list = array(); | ||
private $calls = array(); | ||
private $types = array(); | ||
private $included = array(); | ||
public $currentCallback = false; | ||
|
||
/** | ||
* @param $type | ||
* @param $params | ||
*/ | ||
public function add($type, $params) { | ||
if (empty($params)) return; | ||
$this->calls[$type][] = $params; | ||
if (!in_array($type, $this->types)) { | ||
$this->types[] = $type; | ||
} | ||
} | ||
|
||
/** | ||
* Appels des fonctions des mods | ||
* | ||
*/ | ||
public function apply() { | ||
global $io, $db, $get_dev, $server_config; | ||
if (empty($this->calls)) return; | ||
$success = array(); | ||
$errors = array(); | ||
|
||
$query = $db->sql_query('SELECT c.`id`, c.`function`, c.`type`, c.`mod_id`, m.`root`, m.`title` FROM '.TABLE_XTENSE_CALLBACKS.' c LEFT JOIN '.TABLE_MOD.' m ON c.`mod_id` = m.`id` WHERE c.`active` = 1 AND m.`active` = 1 AND c.`type` IN ("'.implode('", "', $this->types).'")'); | ||
while ($call = $db->sql_fetch_assoc($query)) { | ||
foreach ($this->calls[$call['type']] as $params) { | ||
$this->currentCallback = $call; | ||
|
||
try { | ||
$instance = Callback::load($call['root']); | ||
|
||
if (!method_exists($instance, $call['function']) || !is_callable(array($instance, $call['function']))) throw new Exception('Invalid method "'.$call['function'].'"'); | ||
|
||
$execReturn = $instance->{$call['function']}($params); | ||
|
||
$io->append_call($call, $execReturn); | ||
} catch (mysqli_sql_exception $e) { | ||
$io->append_call_error($call, 'Erreur MySQL lors de l\'execution'."\n".$e->getFile().' @ '.$e->getLine()."\n".$e->getMessage()); | ||
} catch (Exception $e) { | ||
$io->append_call_error($call, $e->getMessage(), $e); | ||
} | ||
|
||
$this->currentCallback = false; | ||
} // Foreach | ||
} // while | ||
|
||
} // Method "apply" | ||
} | ||
<?php | ||
/** | ||
* @package Xtense 2 | ||
* @author Unibozu | ||
* @licence GNU | ||
*/ | ||
|
||
if (!defined('IN_SPYOGAME')) exit; | ||
|
||
/** | ||
* Gestion des fonctions de callback des plugins OGSpyw | ||
* | ||
*/ | ||
class CallbackHandler { | ||
private $list = array(); | ||
private $calls = array(); | ||
private $types = array(); | ||
private $included = array(); | ||
public $currentCallback = false; | ||
|
||
/** | ||
* @param $type | ||
* @param $params | ||
*/ | ||
public function add($type, $params) { | ||
if (empty($params)) return; | ||
$this->calls[$type][] = $params; | ||
if (!in_array($type, $this->types)) { | ||
$this->types[] = $type; | ||
} | ||
} | ||
|
||
/** | ||
* Appels des fonctions des mods | ||
* | ||
*/ | ||
public function apply() { | ||
global $io, $db, $get_dev, $server_config; | ||
if (empty($this->calls)) return; | ||
$success = array(); | ||
$errors = array(); | ||
|
||
$query = $db->sql_query('SELECT c.`id`, c.`function`, c.`type`, c.`mod_id`, m.`root`, m.`title` FROM '.TABLE_XTENSE_CALLBACKS.' c LEFT JOIN '.TABLE_MOD.' m ON c.`mod_id` = m.`id` WHERE c.`active` = 1 AND m.`active` = 1 AND c.`type` IN ("'.implode('", "', $this->types).'")'); | ||
while ($call = $db->sql_fetch_assoc($query)) { | ||
foreach ($this->calls[$call['type']] as $params) { | ||
$this->currentCallback = $call; | ||
|
||
try { | ||
$instance = Callback::load($call['root']); | ||
|
||
if (!method_exists($instance, $call['function']) || !is_callable(array($instance, $call['function']))) throw new Exception('Invalid method "'.$call['function'].'"'); | ||
|
||
$execReturn = $instance->{$call['function']}($params); | ||
|
||
$io->append_call($call, $execReturn); | ||
} catch (mysqli_sql_exception $e) { | ||
$io->append_call_error($call, 'Erreur MySQL lors de l\'execution'."\n".$e->getFile().' @ '.$e->getLine()."\n".$e->getMessage()); | ||
} catch (Exception $e) { | ||
$io->append_call_error($call, $e->getMessage(), $e); | ||
} | ||
|
||
$this->currentCallback = false; | ||
} // Foreach | ||
} // while | ||
|
||
} // Method "apply" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
<?php | ||
|
||
/** | ||
* @package Xtense 2 | ||
* @author Unibozu | ||
* @licence GNU | ||
*/ | ||
if (!defined('IN_SPYOGAME')) die("Hacking Attempt!"); | ||
|
||
require_once("mod/{$root}/includes/Callback.php"); | ||
|
||
// Vidange de la table | ||
$db->sql_query('TRUNCATE TABLE `'.TABLE_XTENSE_CALLBACKS.'`'); | ||
|
||
|
||
$insert = array(); | ||
$callInstall = array('errors' => array(), 'success' => array()); | ||
|
||
$query = $db->sql_query('SELECT `action`, `root`, `id`, `title` FROM '.TABLE_MOD.' WHERE `active` = 1'); | ||
while ($data = $db->sql_fetch_assoc($query)) { | ||
if (!file_exists('mod/'.$data['root'].'/_xtense.php')) continue; | ||
try { | ||
$call = Callback::load($data['root']); | ||
$error = false; | ||
} catch (Exception $e) { | ||
$callInstall['errors'][] = $data['title'].' (erreur lors du chargement du lien) : '.$e->getMessage(); | ||
$error = true; | ||
} | ||
if(!$error) | ||
foreach ($call->getCallbacks() as $k => $c) { | ||
try { | ||
if (empty($c)) continue; | ||
if (!isset($c['function'], $c['type'])) throw new Exception('Données sur le lien invalides : '.$k); | ||
if (!in_array($c['type'], $callbackTypesNames)) throw new Exception('Type de lien ('.$c['type'].') invalide'); | ||
if (!isset($c['active'])) $c['active'] = 1; | ||
if (!method_exists($call, $c['function'])) throw new Exception('La méthode "'.$c['function'].'" n'existe pas'); | ||
$insert[] = '('.$data['id'].', "'.$c['function'].'", "'.$c['type'].'", '.$c['active'].')'; | ||
$callInstall['success'][] = $data['title'].' (#'.$k.') : '.$c['type']; | ||
} catch (Exception $e) { | ||
$callInstall['errors'][] = $data['title'].' : '.$e->getMessage(); | ||
} | ||
} | ||
} | ||
|
||
if (!empty($insert)) { | ||
$db->sql_query('REPLACE INTO '.TABLE_XTENSE_CALLBACKS.' (`mod_id`, `function`, `type`, `active`) VALUES '.implode(', ', $insert)); | ||
} | ||
return $callInstall; | ||
<?php | ||
|
||
/** | ||
* @package Xtense 2 | ||
* @author Unibozu | ||
* @licence GNU | ||
*/ | ||
if (!defined('IN_SPYOGAME')) die("Hacking Attempt!"); | ||
|
||
require_once("mod/{$root}/includes/Callback.php"); | ||
|
||
// Vidange de la table | ||
$db->sql_query('TRUNCATE TABLE `'.TABLE_XTENSE_CALLBACKS.'`'); | ||
|
||
|
||
$insert = array(); | ||
$callInstall = array('errors' => array(), 'success' => array()); | ||
|
||
$query = $db->sql_query('SELECT `action`, `root`, `id`, `title` FROM '.TABLE_MOD.' WHERE `active` = 1'); | ||
while ($data = $db->sql_fetch_assoc($query)) { | ||
if (!file_exists('mod/'.$data['root'].'/_xtense.php')) continue; | ||
try { | ||
$call = Callback::load($data['root']); | ||
$error = false; | ||
} catch (Exception $e) { | ||
$callInstall['errors'][] = $data['title'].' (erreur lors du chargement du lien) : '.$e->getMessage(); | ||
$error = true; | ||
} | ||
if(!$error) | ||
foreach ($call->getCallbacks() as $k => $c) { | ||
try { | ||
if (empty($c)) continue; | ||
if (!isset($c['function'], $c['type'])) throw new Exception('Données sur le lien invalides : '.$k); | ||
if (!in_array($c['type'], $callbackTypesNames)) throw new Exception('Type de lien ('.$c['type'].') invalide'); | ||
if (!isset($c['active'])) $c['active'] = 1; | ||
if (!method_exists($call, $c['function'])) throw new Exception('La méthode "'.$c['function'].'" n'existe pas'); | ||
$insert[] = '('.$data['id'].', "'.$c['function'].'", "'.$c['type'].'", '.$c['active'].')'; | ||
$callInstall['success'][] = $data['title'].' (#'.$k.') : '.$c['type']; | ||
} catch (Exception $e) { | ||
$callInstall['errors'][] = $data['title'].' : '.$e->getMessage(); | ||
} | ||
} | ||
} | ||
|
||
if (!empty($insert)) { | ||
$db->sql_query('REPLACE INTO '.TABLE_XTENSE_CALLBACKS.' (`mod_id`, `function`, `type`, `active`) VALUES '.implode(', ', $insert)); | ||
} | ||
return $callInstall; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
<?php | ||
/** | ||
* @package Xtense 2 | ||
* @author Unibozu | ||
* @licence GNU | ||
*/ | ||
|
||
if (!defined('IN_SPYOGAME')) die("Hacking Attempt!"); | ||
|
||
global $table_prefix; | ||
|
||
define('TABLE_XTENSE_GROUPS', $table_prefix.'xtense_groups'); | ||
define('TABLE_XTENSE_CALLBACKS', $table_prefix.'xtense_callbacks'); | ||
define('TABLE_PARSEDREC', $table_prefix.'parsedRec'); | ||
define('TABLE_PARSEDSPYEN', $table_prefix.'parsedSpyEn'); | ||
|
||
define('TYPE_PLANET', 0); | ||
define('TYPE_MOON', 1); | ||
|
||
if (file_exists ("../mod/{$root}/version.txt")) | ||
list($mod_name, $mod_version, $mod_install, $ogspy_min_version, $toolbar_min_version) = file("../mod/{$root}/version.txt"); | ||
else | ||
list($mod_name, $mod_version, $mod_install, $ogspy_min_version, $toolbar_min_version) = file("mod/{$root}/version.txt"); | ||
|
||
define('PLUGIN_VERSION', trim($mod_version)); | ||
define('TOOLBAR_MIN_VERSION', trim($toolbar_min_version)); | ||
|
||
$database = array( | ||
'ressources' => array('metal','cristal','deuterium','energie','activite'), | ||
'ressources_p' => array('M_percentage','C_Percentage','D_percentage','CES_percentage','CEF_percentage','SAT_percentage','FOR_percentage'), | ||
'buildings' => array('M', 'C', 'D', 'CES', 'CEF', 'UdR', 'UdN', 'CSp', 'SAT', 'HM', 'HC', 'HD', 'FOR', 'Lab', 'Ter','Dock', 'Silo', 'DdR', 'BaLu', 'Pha', 'PoSa'), | ||
'labo' => array('Esp', 'Ordi', 'Armes', 'Bouclier', 'Protection', 'NRJ', 'Hyp', 'RC', 'RI', 'PH', 'Laser', 'Ions', 'Plasma', 'RRI', 'Graviton', 'Astrophysique'), | ||
'defense' => array('LM', 'LLE', 'LLO', 'CG', 'LP', 'AI', 'PB', 'GB', 'MIC', 'MIP'), | ||
'fleet' => array('PT', 'GT', 'CLE', 'CLO', 'CR', 'VB', 'VC', 'REC', 'SE', 'BMD', 'SAT', 'DST', 'EDLM', 'FOR','TRA','FAU', 'ECL') | ||
); | ||
|
||
$databaseSpyId = array( | ||
'ressources' => array( 601 => 'metal',602 => 'cristal',603 => 'deuterium',604 => 'energie'), | ||
//'debris' => array(701 =>'metal',702 =>'cristal',703 =>'deuterium'), Not Supported by OGSpy yet | ||
'buildings' => array( 1 =>'M', 2 =>'C', 3 =>'D', 4 =>'CES', 12 =>'CEF', 14 =>'UdR', 15 =>'UdN', 21 =>'CSp', 22 =>'HM', 23 =>'HC', 24 =>'HD', 31 =>'Lab', 33 =>'Ter',34 =>'DdR', 44 =>'Silo', 36 =>'Dock', 41 =>'BaLu', 42 =>'Pha', 43 =>'PoSa'), | ||
'labo' => array(106 =>'Esp', 108 =>'Ordi', 109 =>'Armes', 110 =>'Bouclier', 111 =>'Protection', 113 =>'NRJ', 114 =>'Hyp', 115 =>'RC', 117 =>'RI', 118 =>'PH', 120 =>'Laser', 121 =>'Ions', 122 =>'Plasma', 123 =>'RRI', 124 =>'Astrophysique', 199 =>'Graviton' ), | ||
'defense' => array(401 =>'LM', 402 =>'LLE', 403 =>'LLO', 404 =>'CG', 405 =>'AI', 406 =>'LP', 407 =>'PB', 408 =>'GB', 502 =>'MIC', 503 =>'MIP'), | ||
'fleet' => array(202 =>'PT', 203 =>'GT', 204 =>'CLE', 205 =>'CLO', 206 =>'CR', 207 =>'VB', 208 =>'VC', 209 =>'REC', 210 =>'SE', 211 => 'BMD', 212 =>'SAT', 213 =>'DST', 214 =>'EDLM', 215 => 'TRA', 217 =>'FOR', 218 => 'FAU', 219 => 'ECL') | ||
); | ||
|
||
$callbackTypesNames = array( | ||
'overview','system','ally_list','buildings','research','fleet','fleetSending','defense','spy','ennemy_spy','rc', | ||
'rc_cdr', 'msg', 'ally_msg', 'expedition','ranking' | ||
); | ||
|
||
<?php | ||
/** | ||
* @package Xtense 2 | ||
* @author Unibozu | ||
* @licence GNU | ||
*/ | ||
|
||
if (!defined('IN_SPYOGAME')) die("Hacking Attempt!"); | ||
|
||
global $table_prefix; | ||
|
||
define('TABLE_XTENSE_GROUPS', $table_prefix.'xtense_groups'); | ||
define('TABLE_XTENSE_CALLBACKS', $table_prefix.'xtense_callbacks'); | ||
define('TABLE_PARSEDREC', $table_prefix.'parsedRec'); | ||
define('TABLE_PARSEDSPYEN', $table_prefix.'parsedSpyEn'); | ||
|
||
define('TYPE_PLANET', 0); | ||
define('TYPE_MOON', 1); | ||
|
||
if (file_exists ("../mod/{$root}/version.txt")) | ||
list($mod_name, $mod_version, $mod_install, $ogspy_min_version, $toolbar_min_version) = file("../mod/{$root}/version.txt"); | ||
else | ||
list($mod_name, $mod_version, $mod_install, $ogspy_min_version, $toolbar_min_version) = file("mod/{$root}/version.txt"); | ||
|
||
define('PLUGIN_VERSION', trim($mod_version)); | ||
define('TOOLBAR_MIN_VERSION', trim($toolbar_min_version)); | ||
|
||
$database = array( | ||
'ressources' => array('metal','cristal','deuterium','energie','activite'), | ||
'ressources_p' => array('M_percentage','C_Percentage','D_percentage','CES_percentage','CEF_percentage','SAT_percentage','FOR_percentage'), | ||
'buildings' => array('M', 'C', 'D', 'CES', 'CEF', 'UdR', 'UdN', 'CSp', 'SAT', 'HM', 'HC', 'HD', 'FOR', 'Lab', 'Ter','Dock', 'Silo', 'DdR', 'BaLu', 'Pha', 'PoSa'), | ||
'labo' => array('Esp', 'Ordi', 'Armes', 'Bouclier', 'Protection', 'NRJ', 'Hyp', 'RC', 'RI', 'PH', 'Laser', 'Ions', 'Plasma', 'RRI', 'Graviton', 'Astrophysique'), | ||
'defense' => array('LM', 'LLE', 'LLO', 'CG', 'LP', 'AI', 'PB', 'GB', 'MIC', 'MIP'), | ||
'fleet' => array('PT', 'GT', 'CLE', 'CLO', 'CR', 'VB', 'VC', 'REC', 'SE', 'BMD', 'SAT', 'DST', 'EDLM', 'FOR','TRA','FAU', 'ECL') | ||
); | ||
|
||
$databaseSpyId = array( | ||
'ressources' => array( 601 => 'metal',602 => 'cristal',603 => 'deuterium',604 => 'energie'), | ||
//'debris' => array(701 =>'metal',702 =>'cristal',703 =>'deuterium'), Not Supported by OGSpy yet | ||
'buildings' => array( 1 =>'M', 2 =>'C', 3 =>'D', 4 =>'CES', 12 =>'CEF', 14 =>'UdR', 15 =>'UdN', 21 =>'CSp', 22 =>'HM', 23 =>'HC', 24 =>'HD', 31 =>'Lab', 33 =>'Ter',34 =>'DdR', 44 =>'Silo', 36 =>'Dock', 41 =>'BaLu', 42 =>'Pha', 43 =>'PoSa'), | ||
'labo' => array(106 =>'Esp', 108 =>'Ordi', 109 =>'Armes', 110 =>'Bouclier', 111 =>'Protection', 113 =>'NRJ', 114 =>'Hyp', 115 =>'RC', 117 =>'RI', 118 =>'PH', 120 =>'Laser', 121 =>'Ions', 122 =>'Plasma', 123 =>'RRI', 124 =>'Astrophysique', 199 =>'Graviton' ), | ||
'defense' => array(401 =>'LM', 402 =>'LLE', 403 =>'LLO', 404 =>'CG', 405 =>'AI', 406 =>'LP', 407 =>'PB', 408 =>'GB', 502 =>'MIC', 503 =>'MIP'), | ||
'fleet' => array(202 =>'PT', 203 =>'GT', 204 =>'CLE', 205 =>'CLO', 206 =>'CR', 207 =>'VB', 208 =>'VC', 209 =>'REC', 210 =>'SE', 211 => 'BMD', 212 =>'SAT', 213 =>'DST', 214 =>'EDLM', 215 => 'TRA', 217 =>'FOR', 218 => 'FAU', 219 => 'ECL') | ||
); | ||
|
||
$callbackTypesNames = array( | ||
'overview','system','ally_list','buildings','research','fleet','fleetSending','defense','spy','ennemy_spy','rc', | ||
'rc_cdr', 'msg', 'ally_msg', 'expedition','ranking' | ||
); | ||
|
||
|
Oops, something went wrong.