Example #1
0
 /**
  * Template renderer constructor
  *
  * Creates a smarty instance and sets a compile directory path (this is required
  * by smarty)
  */
 public function __construct(Application $application)
 {
     $this->application = $application;
     $this->tpl = $this->getSmartyInstance();
     $this->tpl->load_filter('pre', 'config');
     $this->tpl->assign("BASE_URL", $this->application->getRouter()->getBaseUrl());
     $this->registerHelperList();
 }
Example #2
0
 private static function GetTemplate()
 {
     if (null == self::$mTemplate) {
         $smarty = new Smarty();
         $smarty->template_dir = TPL_TEMPLATE_DIR;
         $smarty->use_sub_dirs = defined('TPL_SUB_DIRS') ? TPL_SUB_DIRS : false;
         $smarty->compile_dir = TPL_COMPILED_DIR;
         $smarty->plugins_dir = isset($GLOBALS['CONFIG_TPLPLUGINS_DIRS']) ? $GLOBALS['CONFIG_TPLPLUGINS_DIRS'] : array('plugins', TPL_PLUGINS_DIR);
         $smarty->left_delimiter = '<{';
         $smarty->right_delimiter = '}>';
         $smarty->load_filter('output', 'cssholder');
         /* for convenience */
         //	global $current_user_id, $current_user_mobile, $current_user_active, $current_user_province, $current_user_city, $carrytime_beginning, $current_user_info, $current_header_type, $https_to_http;
         $current_error = $current_alert = '';
         if (!isset($https_to_http) || 0 >= $https_to_http) {
             $current_error = Session::GetInfo('error');
             $current_alert = Session::GetInfo('alert');
         }
         //$system_notice = array('type'=>'', 'message'=>'');
         $system_notice = 'null';
         if (!empty($current_alert)) {
             $system_notice = '{type:\'notice\',message:"' . $current_alert . '"}';
             //$system_notice = array('type'=>'info', 'message'=>$current_alert);
         } elseif (!empty($current_error)) {
             $system_notice = '{type:\'error\',message:"' . $current_error . '"}';
             //$system_notice = array('type'=>'error', 'message'=>$current_error);
         }
         if (!isset($current_header_type)) {
             $current_header_type = Utility::GetHeaderTypeByUrl();
         }
         /*   $smarty->assign('current_header_type', $current_header_type);
                     $smarty->assign('current_user_id', $current_user_id);
                     $smarty->assign('current_user_info', $current_user_info);
                     $smarty->assign('current_user_mobile', $current_user_mobile);
                     $smarty->assign('current_user_active', $current_user_active);
                     $smarty->assign('current_user_province', $current_user_province);
                     $smarty->assign('current_user_city', $current_user_city);
                     $smarty->assign('system_notice', $system_notice); 
         			$smarty->assign('carrytime_beginning', $carrytime_beginning);
                   */
         if (isset($_REQUEST['ajax'])) {
             $smarty->assign('ajax', $_REQUEST['ajax']);
         }
         //$smarty->assign( 'system_notice', json_encode($system_notice));
         /* end */
         self::$mTemplate = $smarty;
     }
     return self::$mTemplate;
 }
Example #3
0
 private static function GetTemplate()
 {
     if (null == self::$mTemplate) {
         $smarty = new Smarty();
         $smarty->template_dir = TPL_TEMPLATE_DIR;
         $smarty->use_sub_dirs = defined('TPL_SUB_DIRS') ? TPL_SUB_DIRS : false;
         $smarty->compile_dir = TPL_COMPILED_DIR;
         $smarty->plugins_dir = isset($GLOBALS['CONFIG_TPLPLUGINS_DIRS']) ? $GLOBALS['CONFIG_TPLPLUGINS_DIRS'] : array('plugins', TPL_PLUGINS_DIR);
         $smarty->left_delimiter = '<{';
         $smarty->right_delimiter = '}>';
         $smarty->load_filter('output', 'cssholder');
         if (!isset($current_header_type)) {
             $current_header_type = Utility::GetHeaderTypeByUrl();
         }
         if (isset($_REQUEST['ajax'])) {
             $smarty->assign('ajax', $_REQUEST['ajax']);
         }
         self::$mTemplate = $smarty;
     }
     return self::$mTemplate;
 }
}
// August 2012 Zollkosten als Muster mit Group ID 15
/*
if($order->delivery['country_id'] !== STORE_COUNTRY):
	if (GROUP_CHECK == 'true') {
		$group_check = "and group_ids LIKE '%c_" . $_SESSION['customers_status']['customers_status_id'] . "_group%'";
	}
	$shop_content_query = "SELECT
                         content_text
                         FROM " . TABLE_CONTENT_MANAGER . "
                         WHERE content_group='15' " . $group_check . "
                         AND languages_id='" . $_SESSION['languages_id'] . "'";
	$shop_content_query = xtc_db_query($shop_content_query);
	$shop_content_data = xtc_db_fetch_array($shop_content_query);
	$smarty->assign('CHECKOUT_ZOLL', $shop_content_data['content_text']);
endif;
*/
$smarty->assign('language', $_SESSION['language']);
if ($kein_versand != 1) {
    $smarty->assign('SHIPPING_BLOCK', $shipping_block);
}
$payment_hidden = xtc_draw_hidden_field('payment', 'paypalexpress') . xtc_draw_hidden_field('act_payment', 'true');
$smarty->assign('PAYMENT_HIDDEN', $payment_hidden);
$smarty->caching = 0;
$main_content = $smarty->fetch(CURRENT_TEMPLATE . '/module/checkout_paypal.html');
$smarty->assign('main_content', $main_content);
if (!defined('RM')) {
    $smarty->load_filter('output', 'note');
}
$smarty->display(CURRENT_TEMPLATE . '/index.html');
include 'includes/application_bottom.php';
Example #5
0
 public function go()
 {
     header("Content-Type: text/html; charset=UTF-8");
     // Import Libraries
     \framework\import("org.yeager.framework.tools.password");
     \framework\import("org.yeager.ui.common");
     \framework\import("org.yeager.ui.koala");
     \framework\import("org.yeager.ui.icons");
     \framework\import("org.yeager.framework.tools.password");
     \framework\import("org.yeager.framework.tools.http.redirect");
     \framework\import("org.yeager.framework.tools.http.byteserve");
     \framework\import("org.yeager.core.versionable");
     \framework\import("org.yeager.core.tree");
     \framework\import("org.yeager.core.permissions");
     \framework\import("org.yeager.core.privileges");
     \framework\import("org.yeager.core.propertysettings");
     \framework\import("org.yeager.core.properties");
     \framework\import("org.yeager.core.history");
     \framework\import("org.yeager.core.jsqueue");
     \framework\import("org.yeager.core.tags");
     \framework\import("org.yeager.core.comments");
     \framework\import("org.yeager.core.cblock");
     \framework\import("org.yeager.core.cblockmgr");
     \framework\import("org.yeager.core.entrymasks");
     \framework\import("org.yeager.core.page");
     \framework\import("org.yeager.core.pagemgr");
     \framework\import("org.yeager.core.file");
     \framework\import("org.yeager.core.filemgr");
     \framework\import("org.yeager.core.filetypes");
     \framework\import("org.yeager.core.views");
     \framework\import("org.yeager.core.mailing");
     \framework\import("org.yeager.core.mailingmgr");
     \framework\import("org.yeager.core.templates");
     \framework\import("org.yeager.core.usergroups");
     \framework\import("org.yeager.core.sites");
     \framework\import("org.yeager.core.languages");
     \framework\import("org.yeager.core.reftracker");
     \framework\import("org.yeager.core.scheduler");
     \framework\import("org.yeager.core.extensionmgr");
     \framework\import("org.yeager.core.extensions");
     \framework\import("org.yeager.core.fileprocessor");
     \framework\import("org.yeager.core.cblockprocessor");
     \framework\import("org.yeager.core.emailprocessor");
     \framework\import("org.yeager.core.pageprocessor");
     \framework\import("org.yeager.core.user");
     \framework\import("org.yeager.core.usermgr");
     \framework\import("org.yeager.core.tree");
     \framework\import('org.yeager.core.updater');
     \framework\import('org.yeager.core.archive');
     // Set UTF8 for DB
     Singleton::YDB()->Execute("SET NAMES 'utf8';");
     // Set ADODB-Fetchmode to ADODB_FETCH_ASSOC
     Singleton::YDB()->SetFetchMode(ADODB_FETCH_ASSOC);
     // Create instance of Koala class
     $koala = new Koala($this->yeager);
     $username = $this->session->getSessionVar("username");
     $password = $this->session->getSessionVar("password");
     Singleton::register("session", $this->session);
     Singleton::register("request", $this->request);
     Singleton::register("config", $this->config);
     Singleton::register("UserMgr", new UserMgr());
     Singleton::register("guiUS", $this->request->parameters['us']);
     Singleton::register("guiLH", $this->request->parameters['lh']);
     // Get frontend timezone
     $this->frontendTimezone = (string) Singleton::config()->getVar('CONFIG/TIMEZONES/FRONTEND');
     if (!$this->frontendTimezone) {
         $this->frontendTimezone = 'Europe/Berlin';
     }
     $userID = Singleton::UserMgr()->validate($username, $password);
     Singleton::register("Usergroups", new Usergroups());
     if (!$userID) {
         $userID = Singleton::UserMgr()->getAnonymousID();
         $this->authenticated = false;
     } else {
         $this->authenticated = true;
         if ($userID != Singleton::UserMgr()->getAnonymousID()) {
             $this->session->setPSessionVar("username", $username);
             $this->session->setPSessionVar("password", $password);
             $this->session->setPSessionVar("userid", $userID);
             $this->session->setPSessionVar("isvalidated", true);
         }
         if ($this->session->getSessionVar('keepLoggedIn')) {
             $this->session->cookie_time = time() + 60 * 60 * 24 * 365;
         } else {
             $cookie_time = (int) Singleton::config()->getVar("CONFIG/SESSION/COOKIES/TIME");
             $this->session->cookie_time = $cookie_time;
         }
     }
     // write roles to sessions for cachekey
     $user = new User($userID);
     $roles = $user->getUsergroupIDs();
     if ($userID != Singleton::UserMgr()->getAnonymousID()) {
         $this->session->setPSessionVar("userroles", $roles);
         $this->session->setPSessionVar("userid", $userID);
         $this->session->setCookie("yg-userid", $userID);
         $roleHash = "";
         foreach ($roles as $r) {
             $roleHash .= $r["ID"] . "x";
         }
         $this->session->setCookie("yg-userroles", $roleHash);
     } elseif ($_COOKIE['yg-userid']) {
         // remove cookie if set
         $this->session->removeCookie("yg-userid");
         $this->session->removeCookie("yg-userroles");
     }
     $backendAllowed = $user->checkPermission('RBACKEND');
     if ((!$this->authenticated || !$backendAllowed) && $this->frontendMode != 'true') {
         if ($this->page != 'responder' && ($this->request->parameters['handler'] != 'userLogin' || $this->request->parameters['handler'] != 'recoverLogin' || $this->request->parameters['handler'] != 'setNewPassword')) {
             $header = $_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden';
             header($header);
             echo $header;
             die;
         }
     }
     $user_timezone = $user->properties->getValue('TIMEZONE');
     $timezoneAbbreviations = timezone_abbreviations_list();
     foreach ($timezoneAbbreviations as $timezoneAbbreviations_item) {
         foreach ($timezoneAbbreviations_item as $timezone_item) {
             if ($timezone_item['timezone_id'] == $user_timezone) {
                 global $tz;
                 $tz = $timezone_item;
             }
         }
     }
     Singleton::register("Tags", new Tags());
     Singleton::register("cbMgr", new CblockMgr());
     Singleton::register("fileMgr", new FileMgr());
     Singleton::register("sites", new Sites());
     Singleton::register("templates", new Templates());
     Singleton::register("entrymasks", new Entrymasks());
     Singleton::register("mailingMgr", new MailingMgr());
     Singleton::register("comments", new Comments());
     Singleton::register("filetypes", new Filetypes());
     Singleton::register("views", new Views());
     Singleton::register("app", $this);
     Singleton::register("koala", $koala);
     $versioninfo = new Updater();
     $versionp = $versioninfo->current_version_string;
     $this->yeager_version = $versionp;
     $this->yeager_revision = substr(YEAGER_REVISION, 4, 7);
     //$this->yeager_date = YEAGER_DATE;
     // get page to display
     if (empty($this->page)) {
         $this->page = "default";
     }
     if (empty($this->action)) {
         $this->action = $this->request->parameters['action'];
     }
     $this->base = $this->request->script_name . "/" . strtolower($this->applicationname);
     /* yeager */
     $this->docpath = Singleton::config()->getVar('CONFIG/DIRECTORIES/DOCPATH');
     $this->docabsolut = $this->baseabsolut = $this->request->prefix . "://" . $this->request->http_host . $this->docpath;
     $this->imgpath = $this->request->prefix . "://" . $this->request->http_host . $this->docpath . "ui/img/";
     $this->doc = $this->app_httproot;
     $this->sid = $this->session->id;
     $this->sidparam = "sid=" . $this->sid;
     // Regular Expressions for URL parsing
     $internalprefix = str_replace('/', '\\/', Singleton::config()->getVar('CONFIG/REFTRACKER/INTERNALPREFIX'));
     $this->URLRegEx1 = '/(.*)' . $internalprefix . '([a-z]*)\\/([0-9]*)(\\/*)(.*)/';
     $this->URLRegEx2 = '/(.*)' . $internalprefix . '([a-z]*)\\/([0-9]*)\\/([0-9]*)(\\/*)(.*)/';
     $filesdir = Singleton::config()->getVar('CONFIG/DIRECTORIES/FILESDIR');
     $filesdoc = Singleton::config()->getVar('CONFIG/DIRECTORIES/FILESDOC');
     $userpicdir = Singleton::config()->getVar('CONFIG/DIRECTORIES/USERPICDIR');
     $embeddedCblockFolder = (int) Singleton::config()->getVar("CONFIG/EMBEDDED_CBLOCKFOLDER");
     if (strlen($filesdir) < 1) {
         $filesdir = "files/";
     }
     if (strlen($userpicdir) < 1) {
         $userpicdir = $filesdir;
     }
     if (strlen($filesdoc) < 1) {
         $filesdoc = "/yeager/files/";
     }
     if (strlen($embeddedCblockFolder) < 1 || $embeddedCblockFolder == 99999) {
         throw new Exception("No or wrong blindfolder configured!");
     }
     $this->filesdir = $filesdir;
     $this->filesdoc = $filesdoc;
     $this->userpicdir = $userpicdir;
     $this->modules = Singleton::config()->getVars("CONFIG/MODULES");
     $this->files_procs = array_merge(Singleton::config()->getVars("CONFIG/FILES_PROCESSORS"), Singleton::config()->getVars("CONFIG/FILE_PROCESSORS"));
     $this->page_procs = Singleton::config()->getVars("CONFIG/PAGE_PROCESSORS");
     $this->cblock_procs = Singleton::config()->getVars("CONFIG/CBLOCK_PROCESSORS");
     $this->email_procs = Singleton::config()->getVars("CONFIG/EMAIL_PROCESSORS");
     $this->filesprocdir = (string) Singleton::config()->getVar("CONFIG/DIRECTORIES/FILES_PROCS");
     $this->pageprocdir = (string) Singleton::config()->getVar("CONFIG/DIRECTORIES/PAGE_PROCS");
     $this->cblockprocdir = (string) Singleton::config()->getVar("CONFIG/DIRECTORIES/CBLOCK_PROCS");
     $this->emailprocdir = (string) Singleton::config()->getVar("CONFIG/DIRECTORIES/EMAIL_PROCS");
     $this->templates = new Templates();
     $this->templatedir = $this->approot . (string) Singleton::config()->getVar('CONFIG/DIRECTORIES/TEMPLATEDIR');
     $this->templatedoc = (string) Singleton::config()->getVar('CONFIG/DIRECTORIES/TEMPLATEDOC');
     $this->templatedirabsolut = $this->request->prefix . "://" . $this->request->http_host . $this->templatedoc;
     $this->extensiondir = (string) Singleton::config()->getVar('CONFIG/DIRECTORIES/EXTENSIONSDIR');
     $this->extensiondoc = (string) Singleton::config()->getVar('CONFIG/DIRECTORIES/EXTENSIONSDOC');
     $this->processordir = (string) Singleton::config()->getVar('CONFIG/DIRECTORIES/PROCESSORSDIR');
     $this->webroot = "/" . rtrim(ltrim((string) Singleton::config()->getVar("CONFIG/DIRECTORIES/WEBROOT"), '/'), '/') . '/';
     if ($this->webroot == "//") {
         $this->webroot = "/";
     }
     $this->devmode = (string) Singleton::config()->getVar('CONFIG/DEVMODE');
     $this->languages = new Languages();
     $forceLangInclude = (string) Singleton::config()->getVar('CONFIG/PAGES/' . strtoupper($this->page) . '/FORCE_LANG_INCLUDE');
     if ($this->frontendMode != 'true' || $forceLangInclude == 'true') {
         // Read default language from config-file
         if ($this->authenticated) {
             $user = new User(Singleton::UserMgr()->getCurrentUserID());
             $langid = $user->getLanguage();
             $langinfo = $this->languages->get($langid);
             $lang = $langinfo["CODE"];
         } else {
             // Check if we have a language which matches the browser-language
             $browserLanguages = array();
             $tmpBrowserLanguages = explode(',', strtoupper(str_replace(' ', '', $_SERVER["HTTP_ACCEPT_LANGUAGE"])));
             foreach ($tmpBrowserLanguages as $tmpBrowserLanguage) {
                 array_push($browserLanguages, substr($tmpBrowserLanguage, 0, 2));
             }
             $browserLanguages = array_values(array_unique($browserLanguages));
             foreach ($browserLanguages as $browserLanguage) {
                 if (!$lang) {
                     if (file_exists($this->approot . "ui/lang/" . $browserLanguage . ".php")) {
                         $lang = $browserLanguage;
                     }
                 }
             }
         }
         // When everything fails, fallback to default language
         if (strlen($lang) < 1) {
             $defaultLanguage = Singleton::config()->getVar('CONFIG/DEFAULT_LANGUAGE');
             $lang = $defaultLanguage ? $defaultLanguage : 'DE';
         }
         require_once $this->approot . "ui/lang/" . $lang . ".php";
     }
     $this->itext =& $itext;
     Singleton::register("itext", $itext);
     if (!is_readable($this->page_file) || is_dir($this->page_file)) {
         $this->error->raise("Page " . $this->page . "'s code (" . $this->page_file . ") not found.", ERR_DEBUG);
     } else {
         $this->error->raise("loading " . $this->page_file, ERR_DEBUG);
         if ($this->page_template != "") {
             require_once "libs/org/smarty/libs/Smarty.class.php";
             $smarty = new Smarty();
             $this->smarty = $smarty;
             $smarty->compile_check = true;
             $smarty->debugging = false;
             $smarty->use_sub_dirs = false;
             // FIXME move to installer
             @mkdir($this->tmpdir . 'templates_compile', 0700);
             @mkdir($this->tmpdir . 'templates_cache', 0700);
             $smarty->compile_dir = $this->tmpdir . 'templates_compile';
             $smarty->cache_dir = $this->tmpdir . 'templates_cache';
             $smarty->force_compile = (string) $this->config->getVar('CONFIG/CACHE/SMARTY_FORCECOMPILE');
             $smarty->caching = 0;
             $smarty->load_filter('output', 'trimwhitespace');
             $smarty->assign("yeager_version", $this->yeager_version);
             $smarty->assign("yeager_revision", $this->yeager_revision);
             //$smarty->assign("yeager_date",$this->yeager_date);
             $smarty->assign("lang", $lang);
             $smarty->assign("docabsolut", $this->docabsolut);
             $smarty->assign("baseabsolut", $this->baseabsolut);
             $smarty->assign("imgpath", $this->imgpath);
             $smarty->assign("internalprefix", (string) Singleton::config()->getVar('CONFIG/REFTRACKER/INTERNALPREFIX'));
             $smarty->assign("request_prefix", $this->request->prefix);
             $smarty->assign("extensiondoc", $this->extensiondoc);
             $smarty->assign("extensiondir", $this->extensiondir);
             $smarty->assign("is_authenticated", $this->authenticated);
             $smarty->assign("base", $this->base);
             $smarty->assign("page", $this->page);
             $smarty->assign("sid", $this->sid);
             $smarty->assign("sidparam", $this->sidparam);
             $smarty->assign("templatedir", $this->templatedir);
             $smarty->assign("templatedoc", $this->templatedoc);
             $smarty->assign("templatedirabsolut", $this->templatedirabsolut);
             $smarty->assign("approot", getRealpath($this->approot));
             $smarty->assign("devmode", $this->devmode);
             $smarty->assign("webroot", $this->webroot);
             $smarty->assign("URLRegEx1", $this->URLRegEx1);
             require_once $this->approot . "libs/org/yeager/ui/smarty_modifiers.php";
         }
         $smarty->assign("itext", $itext);
         Singleton::register("smarty", $smarty);
         if ($_SERVER['HTTP_X_YEAGER_AUTHENTICATION'] == 'suppress') {
             $authHeader = 'X-Yeager-Authenticated: delayed';
         } else {
             $authHeader = 'X-Yeager-Authenticated: ' . ($this->authenticated ? 'true' : 'false');
         }
         header($authHeader);
         if ($this->frontendMode == "true" && $this->cached) {
             // capture ob
             include_once $this->page_file;
             $output = ob_get_clean();
             Singleton::FC()->write("output", $output);
             Singleton::FC()->flush();
             echo $output;
         } else {
             include_once $this->page_file;
         }
         if ($this->frontendMode != 'true') {
             $koala->getQueuedCommands();
             $koala->go();
         }
     }
 }
Example #6
0
if (isset($_GET['p'])) {
    $fullpath = $gitphp_conf['projectroot'] . $_GET['p'];
    $realprojroot = $gitphp_conf['projectroot'];
    $pathpiece = substr($fullpath, 0, strlen($realprojroot));
    if (strcmp($pathpiece, $realprojroot) === 0) {
        $project = str_replace(chr(0), '', $_GET['p']);
    }
}
$extraoutput = FALSE;
/*
 * Instantiate Smarty
 */
require_once $gitphp_conf['smarty_prefix'] . "Smarty.class.php";
$tpl = new Smarty();
if (!isset($_GET['a']) || $_GET['a'] != "commitdiff_plain" && $_GET['a'] != "blob_plain" && $_GET['a'] != "blobdiff_plain" && $_GET['a'] != "rss" && $_GET['a'] != "opml" && $_GET['a'] != "snapshot") {
    $tpl->load_filter('output', 'trimwhitespace');
    $extraoutput = TRUE;
}
/*
 * Debug
 */
if ($gitphp_conf['debug']) {
    if ($extraoutput) {
        define('GITPHP_START_TIME', microtime(true));
        error_reporting(E_ALL | E_STRICT);
    }
}
/*
 * Development
 */
if (!(isset($gitphp_conf['dev']) && $gitphp_conf['dev'])) {
Example #7
0
/**
 * 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);
    }
}
 public function loadFilter($filter, $name)
 {
     $this->_smarty->load_filter($filter, $name);
 }