2012-03-18 11:41:06 -04:00
|
|
|
<?php
|
|
|
|
|
2012-04-11 12:49:22 -04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2010-2012 Tinyboard Development Group
|
|
|
|
*/
|
|
|
|
|
|
|
|
if(realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) {
|
|
|
|
// You cannot request this file directly.
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2012-03-18 11:41:06 -04:00
|
|
|
function event() {
|
|
|
|
global $events;
|
|
|
|
|
|
|
|
$args = func_get_args();
|
|
|
|
|
|
|
|
$event = $args[0];
|
2012-03-24 00:31:35 -04:00
|
|
|
|
2012-03-18 11:41:06 -04:00
|
|
|
$args = array_splice($args, 1);
|
|
|
|
|
|
|
|
if(!isset($events[$event]))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
foreach($events[$event] as $callback) {
|
|
|
|
if(!is_callable($callback))
|
|
|
|
error('Event handler for ' . $event . ' is not callable!');
|
|
|
|
if($error = call_user_func_array($callback, $args))
|
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function event_handler($event, $callback) {
|
|
|
|
global $events;
|
|
|
|
|
|
|
|
if(!isset($events[$event]))
|
|
|
|
$events[$event] = Array();
|
|
|
|
|
|
|
|
$events[$event][] = $callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
function reset_events() {
|
|
|
|
global $events;
|
|
|
|
|
|
|
|
$events = Array();
|
|
|
|
}
|
|
|
|
|