-
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
8296530
commit b5d0593
Showing
8 changed files
with
490 additions
and
486 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; | ||
Oops, something went wrong.