Beispiel #1
0
 static function save_config($vars)
 {
     $out = array();
     $out[] = "<?" . "php";
     $out[] = "define('CORE_VERSION','" . CORE_VERSION . "');";
     $out[] = "define('CORE_VERSION_STRING','" . CORE_VERSION_STRING . "');";
     $out[] = "define('CORE_SGSML_VERSION','" . CORE_SGSML_VERSION . "');";
     foreach ($vars as $key => $var) {
         $out[] = "define('" . $key . "'," . $var . ");";
     }
     foreach (self::config_defaults() as $key => $var) {
         $var = setup_update::get_config_old($key, true, $var);
         $out[] = "define('" . $key . "'," . $var . ");";
     }
     $out[] = "if (TIMEZONE!='') date_default_timezone_set(TIMEZONE);\n" . "  elseif (!ini_get('date.timezone')) date_default_timezone_set(@date_default_timezone_get());";
     $out[] = "if (!ini_get('display_errors')) @ini_set('display_errors','1');";
     $out[] = "define('NOW',time());";
     $out[] = "define('LANG','" . LANG . "');";
     $out[] = "define('APC',function_exists('apc_store') and ini_get('apc.enabled'));";
     file_put_contents("simple_store/config.php", implode("\n", $out), LOCK_EX);
     if (!file_exists("simple_store/config.php") or filesize("simple_store/config.php") == 0) {
         sys_die("cannot write to: simple_store/config.php");
     }
     chmod("simple_store/config.php", 0600);
     sys_log_message_log("info", sprintf("{t}Setup: setup-data written to %s.{/t}", "simple_store/config.php"));
 }
Beispiel #2
0
function install()
{
    setup::out('
    <html>
    <head>
	<title>Simple Groupware & CMS</title>
	<style>
	  body { width:526px; margin:10px auto; }
	  body, a { color: #666666; font-size: 13px; font-family: Arial, Helvetica, Verdana, sans-serif; }
	  a { color: #0000FF; }
	</style>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    </head>
    <body>
	<div style="border-bottom: 1px solid #666666; letter-spacing: 2px; font-size: 18px; font-weight: bold;">Simple Groupware ' . CORE_VERSION_STRING . '</div>
  ');
    $_SESSION["groups"] = array();
    $_SESSION["username"] = "******";
    $_SESSION["password"] = "";
    $_SESSION["permission_sql"] = "1=1";
    $_SESSION["permission_sql_read"] = "1=1";
    $_SESSION["permission_sql_write"] = "1=1";
    define("SETUP_DB_TYPE", $_REQUEST["db_type"]);
    $update = sgsml_parser::table_column_exists("simple_sys_tree", "id");
    setup::out('<img src="http://www.simple-groupware.de/cms/logo.php/' . CORE_VERSION . '/' . SETUP_DB_TYPE . '/' . PHP_VERSION . '/' . (int) $update . '" style="width:1px; height:1px;">', false);
    setup::out(t("{t}Processing %s ...{/t}", "schema updates"));
    setup_update::change_database_pre();
    if (SETUP_DB_TYPE == "sqlite") {
        sql_query("begin");
        admin::rebuild_schema(false);
        sql_query("commit");
    } else {
        admin::rebuild_schema(false);
    }
    setup_update::change_database_post();
    setup::out(t("{t}Processing %s ...{/t}", "sessions"));
    db_delete("simple_sys_session", array(), array());
    setup::out(t("{t}Processing %s ...{/t}", "default groups"));
    $groups = array("admin_calendar", "admin_news", "admin_projects", "admin_bookmarks", "admin_contacts", "admin_inventory", "admin_helpdesk", "admin_organisation", "admin_files", "admin_payroll", "admin_surveys", "admin_hr", "admin_intranet", "users_self_registration");
    foreach ($groups as $group) {
        trigger::creategroup($group);
    }
    setup_update::database_triggers();
    setup::out(t("{t}Processing %s ...{/t}", "folder structure"));
    $count = db_select_value("simple_sys_tree", "id", array());
    if (empty($count)) {
        $folders = "modules/core/folders.xml";
        if (!empty($_REQUEST["folders"]) and file_exists(sys_custom($_REQUEST["folders"]))) {
            $folders = $_REQUEST["folders"];
        }
        if (SETUP_DB_TYPE == "sqlite") {
            sql_query("begin");
            folders::create_default_folders($folders, 0, true);
            sql_query("commit");
        } else {
            folders::create_default_folders($folders, 0, true);
        }
    }
    setup_update::database_folders();
    setup::out(t("{t}Processing %s ...{/t}", "css"));
    admin::build_css();
    setup::out(t("{t}Processing %s ...{/t}", "js"));
    admin::build_js();
    setup::out(t("{t}Processing %s ...{/t}", "icons"));
    admin::build_icons();
    setup::out(t("{t}Processing %s ...{/t}", "config.php"));
    $vars = array("SETUP_DB_TYPE" => "'" . $_REQUEST["db_type"] . "'", "SETUP_DB_HOST" => "'" . $_REQUEST["db_host"] . "'", "SETUP_DB_NAME" => "'" . $_REQUEST["db_name"] . "'", "SETUP_DB_USER" => "'" . $_REQUEST["db_user"] . "'", "SETUP_DB_PW" => "'" . sys_encrypt($_REQUEST["db_pw"], sha1($_REQUEST["admin_user"])) . "'", "SETUP_ADMIN_USER" => "'" . $_REQUEST["admin_user"] . "'", "SETUP_ADMIN_PW" => "'" . (isset($_REQUEST["auto_update"]) ? $_REQUEST["admin_pw"] : sha1($_REQUEST["admin_pw"])) . "'");
    setup::save_config($vars);
    setup::install_footer();
    db_optimize_tables();
}