Esempio n. 1
0
/**
 * Executes the current request.
 * 
 * This is the second of two essential functions.
 * It runs the actual execution. If fact it is the only place where you will
 * find an `echo` in the ScavixWDF code.
 * @return void
 */
function system_execute()
{
    session_sanitize();
    execute_hooks(HOOK_POST_INITSESSION);
    // respond to PING requests that are sended to keep the session alive
    if (Args::request('ping', false)) {
        session_keep_alive();
        execute_hooks(HOOK_PING_RECIEVED);
        die("PONG");
    }
    // respond to DEBUG requests
    if ($GLOBALS['CONFIG']['system']['ajax_debug_argument']) {
        $data = Args::request($GLOBALS['CONFIG']['system']['ajax_debug_argument'], false);
        if ($data) {
            logging_add_category("JS");
            $data = json_decode($data, true);
            if (is_array($data) && count($data) > 0) {
                log_write(Args::request('sev', ''), array_shift($data), $data);
            } else {
                log_write(Args::request('sev', ''), $data);
            }
            die('"OK"');
        }
    }
    Args::strip_tags();
    global $current_controller, $current_event;
    list($current_controller, $current_event) = system_parse_request_path();
    $current_controller = system_instanciate_controller($current_controller);
    if (!(system_method_exists($current_controller, $current_event) || system_method_exists($current_controller, '__method_exists') && $current_controller->__method_exists($current_event))) {
        $current_event = cfg_get('system', 'default_event');
    }
    if (!isset($GLOBALS['wdf_route'])) {
        $GLOBALS['wdf_route'] = array($current_controller, $current_event);
    }
    if (system_method_exists($current_controller, $current_event) || system_method_exists($current_controller, '__method_exists') && $current_controller->__method_exists($current_event)) {
        $content = system_invoke_request($current_controller, $current_event, HOOK_PRE_EXECUTE);
    } else {
        $content = '';
    }
    execute_hooks(HOOK_POST_EXECUTE);
    @set_time_limit(ini_get('max_execution_time'));
    system_exit($content, false);
}
Esempio n. 2
0
/**
 * Tries to set up a category for a logged in user.
 * 
 * Checks the object store for an object with id $object_storage_id 
 * that contains a field $fieldname. Then adds content of that field as category to all loggers.
 * 
 * Note: This will NOT extend the logger with information as logging_extend_logger does!
 * @param string $object_storage_id Storage ID of the object to check for
 * @param string $fieldname Name of field/property to use as category ('name' will use $obj->name as category)
 * @return void
 */
function logging_set_user($object_storage_id = 'user', $fieldname = 'username')
{
    if (in_object_storage('user')) {
        $lu = restore_object('user');
        if ($lu && isset($lu->username) && $lu->username) {
            logging_add_category($lu->username);
        }
    }
}