Beispiel #1
0
function shn_main_front_controller()
{

    global $global;
    global $conf;

    $action = $global['action'];
    $module = $global['module'];


    // check if we should enable database logging....
    if (isset($conf['enable_monitor_sql']) && $conf['enable_monitor_sql'] == true) {
        $global['db']->LogSQL();
    }
    // are we streaming PLUS SOAP Services?
    if (isset($_REQUEST['wsdl'])) {
        shn_main_plus_server();
        exit();
    }

    // is the user confirming an account registration?
    if (isset($_REQUEST['register'])) {
        shn_main_plus_register();
        exit();
    }

    // are we straming anything else?
    if (isset($_REQUEST['stream'])) {
        $stream = "_" . $_REQUEST['stream'];
    } else {
        $stream = null;
    }

    // check if the appropriate stream library exists
    if (array_key_exists('stream', $_REQUEST) && file_exists($global['approot'] . '/inc/lib_stream' . $stream . '.inc')) {
        require_once($global['approot'] . '/inc/lib_stream' . $stream . '.inc');

        // else revert to the html stream
    } else {
        if (array_key_exists('stream', $_REQUEST)) {
            add_error(_t('The stream requested is not valid.'));
        }
        require_once($global['approot'] . "/inc/lib_stream_html.inc");
        $stream = null;
    }

    // Redirect the module based on the action performed
    // redirect admin functions through the admin module
    if (preg_match('/^adm/', $action)) {
        $global['effective_module'] = $module = 'admin';
        $global['effective_action'] = $action = 'modadmin';
    }


    // fixes the security vulnerability associated with null characters in the $module string
    $module = str_replace("\0", "", $module);


    // load stream file if exists...
    $module_stream_file = $global['approot'] . 'mod/' . $module . '/stream.inc';
    if (file_exists($module_stream_file)) {
        include_once($module_stream_file);
    }
    // identify the correct module file based on action and module
    $module_file = $global['approot'] . 'mod/' . $module . '/main.inc';

    // check if module exists (modules main.inc)
    if (file_exists($module_file)) {
        include_once($module_file);
    } else {
        // default to the home page if the module main does not exist
        add_error(_t('The requested module is not installed in Vesuvius'));
        $module = 'home';
        $action = 'default';
        include_once($global['approot'] . 'mod/home/main.inc');
    }

    // identify the name of the module function based on the action, stream and module
    $module_function = 'shn' . $stream . '_' . $module . '_' . $action;

    // if function does not exist re-direct
    if (!function_exists($module_function)) {

        // try to see if there is a generic Xstream function instead
        $module_function = 'shn_XST_' . $module . '_' . $action;

        if (!function_exists($module_function)) {

            // display the error on the relevant stream
            if ($stream == null) {
                add_error(_t('The action requested is not available'));
                $module_function = 'shn_' . $module . '_default';
            } else {
                // if this does not exist display the error in the html homepage
                add_error(_t('This action does not support the stream type.'));
                $module_function = "display_errors"; // just display the errors
            }
        }
    }

    // list of exceptions generated by calling the function.
    $global['exception_list'] = array();

    // initialize stream based on selected steam POST value this includes the inclusion of various sections in XHTML including the HTTP header,content header, menubar, login
    shn_stream_init();

    if ($stream == null) {

        if ((($global['action'] == 'signup2') || ($global['action'] == 'signup') || ($global['action'] == 'forgotPassword') || ($global['action'] == 'loginForm')) && ($global['module'] = 'pref')) {
            if (shn_acl_is_signup_enabled()) {
                $module_function();
            }
        } else {
            // if not a self-signup action
            $allowed_mods = shn_get_allowed_mods_current_user();

            // check if requested module is within users allowed modules
            $res = array_search($module, $allowed_mods, false);

            if (false !== $res) {
                if (shn_acl_check_perms($module, $module_function) == ALLOWED) {
                    // check if the user just logged in.... request_time = session expiry, if so, great them! :)
                    $q = "
						SELECT count(*)
						FROM sessions
						WHERE expiry = '" . mysql_real_escape_string($_SERVER['REQUEST_TIME']) . "';
					";
                    $result = $global['db']->Execute($q);
                    //if($result === false) { daoErrorLog(__FILE__, __LINE__, __METHOD__, __CLASS__, __FUNCTION__, $global['db']->ErrorMsg(), "getEventListUser 1"); }
                    if ($result->fields["count(*)"] == '1') {
                        add_confirmation("Login successful");
                    }
                    $module_function();
                } else {
                    shn_error_display_restricted_access();
                }
            } else {
                shn_error_display_restricted_access();
            }
        }

    } else {
        // if the steam is not HTML
        $allowed_mods = shn_get_allowed_mods_current_user();

        // check if requested module is within users allowed modules
        $res = array_search($module, $allowed_mods, false);

        // hack for messaging module receive function
        $res = ($stream = 'text' & $action = 'receive_message') ? true : $res;
        if (false !== $res) {
            if (shn_acl_check_perms($module, $module_function) == ALLOWED) {
                $module_function();
            } else {
                add_error(shn_error_get_restricted_access_message());
            }
        } else {
            add_error(shn_error_get_restricted_access_message());
        }
    }

    // close up the stream. In HTML send the footer
    shn_stream_close();
}
Beispiel #2
0
function shn_front_controller()
{
    global $global;
    global $conf;
    $approot = $global['approot'];
    $action = $global['action'];
    $module = $global['module'];
    // check the users access permissions for this action
    $req_act = 'shn_' . $module . '_' . $action;
    //  $acl_enabled=shn_acl_get_state($module);
    //@todo Errors should be thrown properly
    //    $module_enabled=shn_acl_is_enabled($module);
    //  $allow = (shn_acl_check_perms_action($_SESSION['user_id'],$req_act) ||
    //           !$acl_enabled)? true : false;
    // Redirect the module based on the action performed
    // redirect admin functions through the admin module
    if (preg_match('/^adm/', $action)) {
        $module = 'admin';
        $action = 'modadmin';
    }
    //include the coreect streaming library
    if ($global['stream_type'] && file_exists($approot . '/inc/lib_st_' . $global['stream_type'] . '.inc')) {
        require_once $approot . '/inc/lib_st_' . $global['stream_type'] . '.inc';
        if (file_exists($approot . '/mod/' . $module . '/' . $global['stream_type'] . '.inc')) {
            $default_file = $approot . '/mod/' . $module . '/' . $global['stream_type'] . '.inc';
        } else {
            $default_file = 'stream.inc';
        }
    } else {
        $default_file = 'main.inc';
    }
    // include the correct module file based on action and module
    $module_file = $approot . 'mod/' . $module . '/' . $default_file;
    if (!file_exists($module_file)) {
        $module_file = $approot . 'mod/home/' . $default_file;
    }
    //Initilize the stream
    if ($default_file == 'stream.inc') {
        shn_stream_init($module_file);
    }
    //Include the module file
    include $module_file;
    // include the module configuration files
    $d = dir($approot . 'mod/');
    while (false !== ($f = $d->read())) {
        if (file_exists($approot . 'mod/' . $f . '/conf.inc')) {
            include $approot . 'mod/' . $f . '/conf.inc';
        }
    }
    //Override config values with database ones
    shn_config_database_fetch('all');
    //    if($allow){
    // compose and call the relevant module function
    $module_function = 'shn_' . $module . '_' . $action;
    if (!function_exists($module_function)) {
        $module_function = 'shn_' . $module . '_default';
    }
    $_SESSION['last_module'] = $module;
    $_SESSION['last_action'] = $action;
    $output = $module_function();
    if ($default_file == 'stream.inc') {
        shn_stream_close($module_function, $output);
    }
    //   }else {
    //@todo : throw the error correctly
    //    }
}
Beispiel #3
0
function shn_main_web_installer()
{
    global $global, $APPROOT, $conf;
    // The 'help' action is a special case. The following allows the popup help text
    // to be accessed before the sysconf.inc file has been created.
    if ($global['action'] == "help") {
        require_once $APPROOT . "/inc/lib_stream_{$_REQUEST['stream']}.inc";
        $module = $global['module'];
        $module_file = $APPROOT . 'mod/' . $module . '/main.inc';
        include $module_file;
        shn_stream_init();
        $module_function = 'shn_' . $_REQUEST['stream'] . '_' . $module . '_' . $global['action'];
        $_SESSION['last_module'] = $module;
        $_SESSION['last_action'] = $action;
        $module_function();
        shn_stream_close();
    } else {
        // include the sysconfig template for basic conf dependancies
        require_once $APPROOT . 'conf/sysconf.inc.tpl.php';
        // launch the web setup wizard
        require $APPROOT . 'inst/setup.inc';
    }
}