require_once R3_APP_ROOT . 'lib/r3_auth_gui_start.php'; } if (!defined("__R3_AUTH__")) { require_once R3_APP_ROOT . 'lib/r3auth.php'; } require_once R3_APP_ROOT . 'lib/r3auth_manager.php'; require_once R3_APP_ROOT . 'lib/default.um.php'; require_once R3_APP_ROOT . 'lib/r3auth_impexp.php'; require_once R3_APP_ROOT . 'lib/storevar.php'; require_once R3_APP_ROOT . 'lib/xajax.php'; require_once R3_APP_ROOT . 'lang/lang.php'; /** Authentication and permission check */ $auth = new R3AuthManagerImpExp($mdb2, $auth_options, APPLICATION_CODE); if (is_null($auth)) { $auth = new R3AuthManagerImpExp($mdb2, $auth_options, APPLICATION_CODE); R3AuthInstance::set($auth); } if (!$auth->isAuth()) { Header("location: logout.php?status=" . $auth->getStatusText()); die; } if (!$auth->hasPerm('IMPORT', 'CONFIG') && !$auth->hasPerm('IMPORT', 'ACNAME')) { die("PERMISSION DENIED\n"); } if (file_exists(R3_APP_ROOT . 'lib/custom.um.php')) { require_once R3_APP_ROOT . 'lib/custom.um.php'; $umDependenciesObj = getUmDependenciesObject(); } else { $umDependenciesObj = new R3UmDependenciesDefault(); } $smarty->assign('umDependencies', $umDependenciesObj->get());
/** * Handle all the active stuff that usually happens in config.php. * This are things as opening db connections, start sessions etc. * * Session is started * The folloy object are created: * - $smarty * - $auth */ function R3AppInit($type = null, array $opt = array()) { global $smarty, $auth, $pdo, $mdb2, $dbini; // output object global $mdb2_dsn, $lang; // output var global $dsn, $sessionOpt, $mdb2_options; // input vars global $auth_options; // input vars global $scriptStartTime; /* Default application type */ if ($type === null) { $type = 'admin'; } $opt = array_merge(array('session_start' => true, 'auth' => true, 'auth_manager' => false, 'dbini' => false), $opt); /* Session */ foreach ($sessionOpt as $key => $val) { switch ($key) { case 'name': session_name($val); break; case 'cache_limiter': session_cache_limiter($val); break; case 'save_path': session_save_path($val); break; case 'timeout': session_cache_expire(ceil($val / 60)); break; case 'warning_timeout': // do nothing; break; default: ini_set("session." . $key, $val); } } if ($opt['session_start'] === true && session_id() == '') { session_start(); } /* Smarty */ require_once R3_SMARTY_ROOT_DIR . 'Smarty.class.php'; $smarty = new Smarty(); $smarty->config_dir = R3_SMARTY_ROOT_DIR . 'configs/'; $smarty->cache_dir = R3_SMARTY_ROOT_DIR . 'cache/'; if (defined('R3_SMARTY_PLUGIN_DIR')) { $smarty->plugins_dir[] = R3_SMARTY_PLUGIN_DIR; } if ($type == 'admin') { $smarty->template_dir = R3_SMARTY_TEMPLATE_DIR_ADMIN; $smarty->compile_dir = R3_SMARTY_TEMPLATE_C_DIR_ADMIN; } else { if ($type == 'public') { // for public sites $smarty->template_dir = R3_SMARTY_TEMPLATE_DIR_PUBLIC; $smarty->compile_dir = R3_SMARTY_TEMPLATE_C_DIR_PUBLIC; } else { if ($type == 'map') { $smarty->template_dir = R3_SMARTY_TEMPLATE_DIR_MAP; $smarty->compile_dir = R3_SMARTY_TEMPLATE_C_DIR_MAP; } else { throw new Exception("Unknown smarty specialization"); } } } $smarty->load_filter('pre', 'r3quotevalue'); R3AppInitDB(); /* Authentication */ if ($opt['auth'] === true && !isset($auth_options)) { throw new Exception('Missing $auth_options'); } if ($opt['auth'] === true) { if ($opt['auth_manager'] === true) { require_once R3_LIB_DIR . 'r3auth_manager.php'; $auth = new R3AuthManager($mdb2, $auth_options, APPLICATION_CODE); } else { require_once R3_LIB_DIR . 'r3auth.php'; $auth = new R3Auth($mdb2, $auth_options, APPLICATION_CODE); } R3AuthInstance::set($auth); } /* DBIni */ if ($opt['dbini'] === true) { require_once R3_LIB_DIR . 'r3dbini.php'; $domainName = R3_IS_MULTIDOMAIN ? 'SYSTEM' : DOMAIN_NAME; $dbini = new R3DBIni($mdb2, $auth_options, $domainName, APPLICATION_CODE); } }