コード例 #1
0
ファイル: eco_app.php プロジェクト: r3-gis/EcoGIS
/**
 * 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 R3AppStart($type = null, array $opt = array())
{
    global $smarty, $auth, $languages, $mdb2;
    global $lang;
    // output var
    global $scriptStartTime;
    initLog();
    // Initialize ezLog
    $text = "{$_SERVER['REMOTE_ADDR']}: {$_SERVER['SCRIPT_FILENAME']}?{$_SERVER['QUERY_STRING']} started ({$_SERVER['REQUEST_METHOD']})";
    ezcLog::getInstance()->log($text, ezcLog::DEBUG);
    require_once R3_LIB_DIR . 'eco_utils.php';
    $isAuth = $auth->isAuth();
    if (!$isAuth && isset($opt['allow_change_password']) && $opt['allow_change_password'] === true && ($auth->getStatus() == AUTH_PASSWORD_REPLACE || $auth->getStatus() == AUTH_PASSWORD_EXPIRED)) {
        $isAuth = true;
        $auth->getAllPermsAsString();
    }
    if (!$isAuth) {
        ezcLog::getInstance()->log(sprintf("Non authenticated request: Logged out [%s]", $auth->getStatusText()), ezcLog::NOTICE);
        Header("location: logout.php?status=" . $auth->getStatusText());
        die;
    }
    if (1 == 1) {
        $sql = "SELECT set_session_var('R3UID', '{$auth->getUID()}')";
        $db = ezcDbInstance::get();
        $db->exec($sql);
        $mdb2->exec($sql);
    }
    $_SESSION['lang'] = $auth->getParam('us_lang', 1);
    $lang = $_SESSION['lang'];
    $smarty->assign('lang', $lang);
    R3Locale::setLanguageID($lang);
    /** Apply locale */
    setLang($languages[$_SESSION['lang']], LC_MESSAGES);
    bindtextdomain('messages', R3_LANG_DIR);
    textdomain('messages');
    bind_textdomain_codeset('messages', R3_APP_CHARSET);
    // Force domain
    if ($auth->hasPerm('SHOW', 'ALL_DOMAINS')) {
        $domainList = R3EcoGisHelper::getDomainList();
        $smarty->assign('domains', $domainList);
        if (!isset($_SESSION['do_id'])) {
            if (R3_IS_MULTIDOMAIN) {
                $_SESSION['do_id'] = key($domainList);
                // 1st domain
            } else {
                $_SESSION['do_id'] = $auth->getDomainID();
                // Default domain
            }
        }
    } else {
        $_SESSION['do_id'] = $auth->getDomainID();
        // Default domain
    }
    $smarty->assign('do_id', $_SESSION['do_id']);
    if (!isset($_REQUEST['method'])) {
        // Don't rebuild on ajax request
        // Rebuild css
        R3BuildCSS();
        // Rebuild js
        R3BuildJS();
    }
    if (defined('GZIP_PHP_PAGE') && GZIP_PHP_PAGE == true) {
        // Compress php page
        ob_start("ob_gzhandler");
    }
}
コード例 #2
0
ファイル: getfile.php プロジェクト: r3-gis/EcoGIS
function shutdown_getfile()
{
    global $scriptStartTime;
    // Write a message to the log.
    $params = '';
    $params .= isset($_REQUEST['type']) ? '?type=' . $_REQUEST['type'] : '';
    $params .= isset($_REQUEST['domain']) ? '&domain=' . $_REQUEST['domain'] : '';
    $params .= isset($_REQUEST['file']) ? '&file=' . $_REQUEST['file'] : '';
    $params .= isset($_REQUEST['disposition']) ? '&disposition=' . $_REQUEST['disposition'] : '';
    if (defined('R3_FAST_SESSION') && R3_FAST_SESSION === true) {
        // Close immediatly the session to allow concurrency session
        session_write_close();
    }
    ezcLog::getInstance()->log(sprintf("Script [%s{$params}] execution time: %.2fsec", $_SERVER["SCRIPT_NAME"], microtime(true) - $scriptStartTime), ezcLog::DEBUG);
}
initLog();
// Initialize ezLog
register_shutdown_function('shutdown_getfile');
$type = isset($_GET['type']) ? $_GET['type'] : null;
$domain = isset($_GET['domain']) ? strtolower(basename($_GET['domain'])) . '/' : null;
$file = isset($_GET['file']) ? basename($_GET['file']) : null;
$name = isset($_GET['name']) ? basename($_GET['name']) : null;
$disposition = isset($_GET['disposition']) ? $_GET['disposition'] : 'inline';
switch ($type) {
    case 'style':
        $path = R3_WEB_CSS_DIR;
        $ttl = 7 * 24 * 60 * 60;
        break;
    case 'custom-style':
        $path = R3_UPLOAD_DATA_DIR . $domain . 'style/';
        $ttl = 7 * 24 * 60 * 60;
コード例 #3
0
ファイル: App.php プロジェクト: yanhaojie/buddy
 /**
  * run
  */
 public static function run()
 {
     self::init();
     //do log init
     initLog();
     self::exec();
     return;
 }