2025-06-02 10:01:12 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* (c) 2025 BeCast
|
|
|
|
* -------------------------------------
|
|
|
|
* Filename: plugin.class.php
|
|
|
|
* Purpose: Plugin Handling
|
|
|
|
* CVS Header: $Header$
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
$module["module"]["name"]="Plugin Class";
|
|
|
|
$module["module"]["ver"]="0.1.1";
|
|
|
|
class plugins{
|
|
|
|
|
2025-06-23 20:45:15 +02:00
|
|
|
var array $hooks;
|
|
|
|
var string $current_hook;
|
|
|
|
var array $plugin_=array();
|
2025-06-02 10:01:12 +02:00
|
|
|
|
|
|
|
function load_plugins($region='G'){
|
|
|
|
global $config, $db;
|
|
|
|
$result = $db->query("SELECT * FROM " . $config["prefix"] . "module");
|
|
|
|
while ($row = $db->fetch_array($result)){
|
|
|
|
$this->plugin_[$row["file"]] = $row;
|
|
|
|
if($row["module"]=""){
|
|
|
|
//$plugin="$
|
|
|
|
}else{
|
|
|
|
|
|
|
|
}
|
|
|
|
//include_once();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function use_hook($name,$function,$order=20,$file="") {
|
|
|
|
if(is_array($function)){
|
|
|
|
$fname=serialize($function);
|
|
|
|
}else{
|
|
|
|
$fname=$function;
|
|
|
|
}
|
|
|
|
if(!empty($this->hooks[$name][$order][$fname]) && is_array($this->hooks[$name][$order][$fname])){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->hooks[$name][$order][$fname] = array(
|
|
|
|
"function" => $function,
|
|
|
|
"file" => $file
|
|
|
|
);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function run_hook($name,$variables=array()) {
|
2025-06-23 20:45:15 +02:00
|
|
|
if(empty($this->hooks)){
|
|
|
|
return false;
|
|
|
|
}
|
2025-06-02 10:01:12 +02:00
|
|
|
if(array_key_exists($name,$this->hooks)){
|
|
|
|
if(!is_array($this->hooks[$name]))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$this->current_hook = $name;
|
|
|
|
ksort($this->hooks[$name]);
|
|
|
|
foreach($this->hooks[$name] as $priority => $hooks)
|
|
|
|
{
|
|
|
|
if(is_array($hooks))
|
|
|
|
{
|
|
|
|
foreach($hooks as $hook)
|
|
|
|
{
|
|
|
|
if($hook['file'])
|
|
|
|
{
|
|
|
|
require_once $hook['file'];
|
|
|
|
}
|
2025-06-02 22:38:25 +02:00
|
|
|
if(!is_array($variables))
|
2025-06-02 10:01:12 +02:00
|
|
|
$variables=array();
|
2025-06-02 22:38:25 +02:00
|
|
|
|
|
|
|
$return = call_user_func_array($hook['function'], $variables);
|
|
|
|
|
|
|
|
|
2025-06-02 10:01:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->current_hook = '';
|
|
|
|
return $return;
|
|
|
|
}
|
2025-06-23 20:45:15 +02:00
|
|
|
return false;
|
2025-06-02 10:01:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|