Ejemplo n.º 1
0
}
/**
 * Main update script
 */
function gu_update()
{
    return gu_config::save();
}
// If pluxml is used
if (isset($_profil['salt'])) {
    $salt = $_profil['salt'];
} else {
    $salt = gu_config::plx_charAleatoire();
}
// If settings already exist, go into update mode
$update_mode = gu_config::load();
// Check if everything is already up-to-date
$install_success = $update_mode && gu_config::get_version() == GUTUMA_VERSION_NUM;
if (!$install_success) {
    // Run installtion or update script
    if ($update_mode && is_post_var('update_submit')) {
        $install_success = gu_update();
    } elseif (!$update_mode && is_post_var('install_submit')) {
        $install_success = gu_install(get_post_var('collective_name'), get_post_var('admin_username'), sha1($salt . md5(get_post_var('admin_password'))), get_post_var('admin_email'), $salt);
    }
}
// Get title of page
if ($install_success) {
    $title = t('Finished');
} elseif ($update_mode) {
    $title = t('Update to Gutuma ') . GUTUMA_VERSION_NAME;
Ejemplo n.º 2
0
/**
 * Initializes the Gutuma application
 * @param bool $validate_session TRUE if session should be checked for a valid login, else FALSE
 * @param bool $install_redirect TRUE if we should redirect when install/update required
 */
function gu_init($validate_session = TRUE, $install_redirect = TRUE)
{
    // If settings couldn't be loaded we need to run the install script or if settings could be
    // loaded but version number is less than the built version number, we need to update
    if (!gu_config::load() || gu_config::get_version() < GUTUMA_VERSION_NUM) {
        if ($install_redirect) {
            header('Location: ' . absolute_url('install.php'));
            exit;
        }
    }
    if ($validate_session) {
        if (!gu_session_authenticate()) {
            // If we don't have a stored valid session, redirect to the login page
            header('Location: ' . absolute_url('login.php') . '?ref=' . urlencode(absolute_url()));
            exit;
        }
    }
}