Beispiel #1
0
$state_abbr = "";
$state_city_count = "";
$item_name = "";
$geo_placename = "";
$geo_position = "";
$icbm = "";
$geo_region = "";
$zip_code = "";
$country = "";
$clouds = "";
$page_title = MAIN_PAGE_TITLE;
$page_meta_description = MAIN_PAGE_META_DESCRIPTION;
$page_meta_keywords = MAIN_PAGE_META_KEYWORDS;
$page_h1 = MAIN_PAGE_H1;
$page_h2 = MAIN_PAGE_H2;
$menu_mapping = loadMapping("./menu_map/menu_map.ini");
#var_dump($menu_mapping);
#$current_page = "MAIN_PAGE";
#$tmpl_file_name="tmpl_main_block.html";
if (isset($menu_mapping[$url_region]) && empty($url_city) || empty($url_region) && $menu_mapping["/"]) {
    //if(isset($menu_mapping[$url_region]) && empty($url_city)){
    #echo "read menu mapping<br>";
    if (empty($url_region)) {
        $url_region = "/";
    }
    $tmpl_file_name = $menu_mapping[$url_region]["file"];
    $page_title = constant($menu_mapping[$url_region]["page_title"]);
    $page_meta_description = constant($menu_mapping[$url_region]["page_meta_description"]);
    $page_meta_keywords = constant($menu_mapping[$url_region]["page_meta_keywords"]);
    $current_page = $menu_mapping[$url_region]["page_label"];
    #echo "current_page menu mapping: '".$current_page.'\'<br>';
Beispiel #2
0
/**
 * TODO: put this into churchtools_main, no need for two functions
 *
 * Main entry point for churchtools.
 * This will be called from /index.php
 * Function loads i18n, configuration, check data security.
 * If everything is ok, it calls churchtools_processRequest()
 */
function churchtools_app()
{
    global $q, $q_orig, $currentModule, $add_header, $config, $mapping, $content, $base_url, $files_dir, $user, $embedded, $i18n;
    include_once CHURCHCORE . "/churchcore_db.php";
    $files_dir = DEFAULT_SITE;
    // which module is requested?
    $q = $q_orig = getVar("q", userLoggedIn() ? "home" : getConf("site_startpage", "home"));
    // $currentModule is needed for class autoloading and maybe other include paths
    list($currentModule) = explode('/', getVar("q"));
    // get first part of $q or churchcore
    $embedded = getVar("embedded", false);
    $base_url = getBaseUrl();
    $config = loadConfig();
    if ($config) {
        if (db_connect()) {
            // DBConfig overwrites the config files
            loadDBConfig();
            if (empty($config['site_name'])) {
                $config['site_name'] = 'ChurchTools';
            }
            //dont allow site_name to be empty
            date_default_timezone_set(getConf("timezone", "Europe/Berlin"));
            if (isset($_COOKIE["language"])) {
                $config["language"] = $_COOKIE["language"];
            }
            // Load i18n churchcore-bundle
            if (!isset($config["language"])) {
                if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
                    $config["language"] = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
                } else {
                    $config["language"] = DEFAULT_LANGUAGE;
                }
            }
            $i18n = new TextBundle(CHURCHCORE . "/resources/messages");
            $i18n->load("churchcore", $config["language"] != null ? $config["language"] : null);
            // Session Init
            if (!file_exists($files_dir . "/tmp")) {
                @mkdir($files_dir . "/tmp", 0775, true);
            }
            if (!file_exists($files_dir . "/tmp")) {
                // Admin should act accordingly, default suggestion is 0755.
                addErrorMessage(t("permission.denied.write.dir", $files_dir));
            } else {
                session_save_path($files_dir . "/tmp");
            }
            session_name("ChurchTools_" . $config["db_name"]);
            session_start();
            register_shutdown_function('handleShutdown');
            // Check for offline mode. If it's activated display message and return false;
            if (getConf("site_offline") == 1) {
                if (!isset($_SESSION["user"]) || !in_array($_SESSION["user"]->id, getConf("admin_ids"))) {
                    echo t("site.is.down");
                    return false;
                }
            }
            $embedded = getVar("embedded", false);
            $mapping = loadMapping();
            $success = true;
            // Check for DB-Updates and loginstr only if this is not an ajax call.
            if (strrpos($q, "ajax") === false) {
                $success = checkForDBUpdates();
            }
            // Log if debug ist activated
            if (isset($config["debug"])) {
                logParams();
            }
            if ($success) {
                // Is there a loginstr which does not fit to the current logged in user?
                if (getVar("loginstr") && getVar("id") && userLoggedIn() && $_SESSION["user"]->id != getVar("id")) {
                    logout_current_user();
                    session_start();
                } else {
                    loadUserObjectInSession();
                }
            }
            if ($success) {
                if (isset($_SESSION['user'])) {
                    $user = $_SESSION['user'];
                }
                // Accept data security?
                if (userLoggedIn() && !isset($_SESSION["simulate"]) && $q != "logout" && isset($config["accept_datasecurity"]) && $config["accept_datasecurity"] == 1 && !isset($user->acceptedsecurity)) {
                    $content .= pleaseAcceptDatasecurity();
                } else {
                    $content .= churchtools_processRequest($q);
                }
            }
        }
    }
    // TODO: i changed header/footer to a sort of template
    // probably some more logic could be removed from them by setting some more variables here
    // put header/footer into new file layout.php and add a variable $content
    $lang = getConf("language");
    $simulate = getVar("simulate", false, $_SESSION);
    $sitename = getConf("site_name");
    if (getConf("test")) {
        $sitename .= " TEST ";
    }
    $logo = ($logo = getConf("site_logo")) ? "{$files_dir}/files/logo/{$logo}" : '';
    include INCLUDES . "/header.php";
    echo $content;
    include INCLUDES . "/footer.php";
}