function admin_saveSettings($form) { foreach ($form->fields as $key => $value) { db_query("INSERT INTO {cc_config} (name, value) VALUES (:name,:value) \n ON DUPLICATE KEY UPDATE value=:value", array(":name" => $key, ":value" => $value)); } loadDBConfig(); }
function home__memberlist_saveSettings($form) { if (isset($_POST["btn_1"])) { header("Location: ?q=home/memberlist"); return null; } else { foreach ($form->fields as $key => $value) { db_query("INSERT INTO {cc_config} (name, value) \n VALUES (:name,:value) ON DUPLICATE KEY UPDATE value=:value", array(":name" => $key, ":value" => $value)); } loadDBConfig(); } }
<?php if (!$_REQUEST['dbtype']) { loadDBConfig(); } ?> <div class="container"> <div class="step_2"> <div style="padding-left:260px;padding-top:5px;width:600px;"> <h2><?php echo STR_DATABASE_CONFIGURATION; ?> </h2> <p> <?php echo STR_DATABASE_CONFIGURATION_DESC_1; ?> </p> <p> <?php echo STR_DATABASE_CONFIGURATION_DESC_2; ?> </p> <form id="setupform" name="setupform" method="post" action="install.php" style="margin-bottom:15px;"> <table class="input_table"> <tr> <td width="150"><label><?php echo STR_DATABASE_TYPE; ?>
/** * 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"; }
/** * save admin settings and reload config * * TODO: feature: automatically downsize logo file * * @param CTForm $form */ function admin_saveSettings($form) { $modules = churchcore_getModulesSorted(false, true); $modules[] = "churchadmin"; foreach ($modules as $module) { foreach ($form->fields as $key => $value) { if (function_exists($module . "_validateAdminForm")) { $res = call_user_func($module . "_validateAdminForm", $key, $value->getValue()); if ($res !== true) { $form->fields[$key]->setError($res); addErrorMessage(t("error.occured") . ": " . $res); return; } } } } foreach ($form->fields as $key => $value) { db_query("INSERT INTO {cc_config} (name, value)\n VALUES (:name,:value)\n ON DUPLICATE KEY UPDATE value=:value", array(":name" => $key, ":value" => $value)); } // TODO: test if max_uploadfile_size_kb is bigger then allowed in php.ini loadDBConfig(); }