Пример #1
0
 static function install($source, $filename)
 {
     $target = SIMPLE_EXT . substr($filename, 0, -3);
     setup::out("{t}Download{/t}: " . $source . " ...");
     if ($fz = gzopen($source, "r") and $fp = fopen($target, "w")) {
         $i = 0;
         while (!gzeof($fz)) {
             $i++;
             setup::out(".", false);
             if ($i % 160 == 0) {
                 setup::out();
             }
             fwrite($fp, gzread($fz, 16384));
         }
         gzclose($fz);
         fclose($fp);
     } else {
         sys_die("{t}Error{/t}: gzopen [2] " . $source);
     }
     setup::out();
     if (!file_exists($target) or filesize($target) == 0 or filesize($target) % 10240 != 0) {
         sys_die("{t}Error{/t}: file-check [3] Filesize: " . filesize($target) . " " . $target);
     }
     setup::out(sprintf("{t}Processing %s ...{/t}", basename($target)));
     $tar_object = new Archive_Tar($target);
     $tar_object->setErrorHandling(PEAR_ERROR_PRINT);
     $tar_object->extract(SIMPLE_EXT);
     $file_list = $tar_object->ListContent();
     if (!is_array($file_list) or !isset($file_list[0]["filename"]) or !is_dir(SIMPLE_EXT . $file_list[0]["filename"])) {
         sys_die("{t}Error{/t}: tar [4] " . $target);
     }
     self::update_modules_list();
     $ext_folder = db_select_value("simple_sys_tree", "id", "anchor=@anchor@", array("anchor" => "extensions"));
     foreach ($file_list as $file) {
         sys_chmod(SIMPLE_EXT . $file["filename"]);
         setup::out(sprintf("{t}Processing %s ...{/t}", SIMPLE_EXT . $file["filename"]));
         if (basename($file["filename"]) == "install.php") {
             setup::out("");
             require SIMPLE_EXT . $file["filename"];
             setup::out("");
         }
         if (basename($file["filename"]) == "readme.txt") {
             $data = file_get_contents(SIMPLE_EXT . $file["filename"]);
             setup::out(nl2br("\n" . q($data) . "\n"));
         }
         if (!empty($ext_folder) and basename($file["filename"]) == "folders.xml") {
             setup::out(sprintf("{t}Processing %s ...{/t}", "folder structure"));
             folders::create_default_folders(SIMPLE_EXT . $file["filename"], $ext_folder, false);
         }
     }
 }
Пример #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();
}
Пример #3
0
function folder_build_selfolder($tfolder, $tview)
{
    if (!is_numeric($tfolder)) {
        $url = sys_parse_folder($tfolder);
        $handler = $url["handler"];
        $mfolder = $url["mfolder"];
        $level = substr_count($url["path"], "/") - 1;
        $sel_folder = db_select_first("simple_sys_tree", array("fmountpoint", "flevel"), array("id=@id@", $_SESSION["permission_sql_read"]), "", array("id" => (int) $mfolder));
        if (!empty($sel_folder["flevel"])) {
            $level += $sel_folder["flevel"] - substr_count($sel_folder["fmountpoint"], "/") + 1;
            $mp = $sel_folder["fmountpoint"];
        } else {
            $mp = "";
        }
        $sel_folder = array("id" => $tfolder, "ftitle" => basename($tfolder), "fdescription" => "", "children" => array(), "lft" => 1, "rgt" => 2, "ftype" => "sys_nodb_" . $handler, "fcount" => 0, "fsizecount" => 0, "fchcount" => 0, "fchsizecount" => 0, "ffcount" => 0, "flevel" => $level, "quota" => 0, "anchor" => "", "folders" => "", "icon" => "", "notification" => "", "fmountpoint" => $mp, "rights" => db_get_rights($mfolder, $tview));
    } else {
        if (db_get_right($tfolder, "read")) {
            $sel_folder = db_select_first("simple_sys_tree", "*", array("id=@id@"), "", array("id" => $tfolder));
        } else {
            $sel_folder = db_select_first("simple_sys_tree", "*", $_SESSION["permission_sql_read"], "lft asc");
            if (DEBUG and empty($sel_folder)) {
                folders::create_default_folders("modules/core/folders.xml", 0, true);
                sys_die("tree created.");
            }
            if (!empty($_REQUEST["iframe"]) and $tfolder != 1) {
                sys_die("{t}Access denied.{/t}");
            }
        }
        if (!is_array($sel_folder)) {
            sys_die("ERROR " . sql_error());
        }
        if (count($sel_folder) == 0) {
            sys_die("{t}Access denied.{/t} <a href='index.php?logout'>{t}Login/-out{/t}</a>");
        }
        $sel_folder["quota"] = db_get_quota($sel_folder);
        $sel_folder["rights"] = db_get_rights($sel_folder["id"], $tview);
    }
    return $sel_folder;
}
Пример #4
0
 static function runxml($id, $data, $params)
 {
     list($file, $parent_anchor) = $params;
     $home = folder_from_path("^" . $parent_anchor);
     if (!empty($home) and file_exists(sys_custom($file))) {
         sys_notification(sprintf("{t}Processing %s ...{/t}", $file));
         $folder = folders::create_default_folders($file, $home, false, $data);
         sys_notification(sprintf("{t}Folder structure created.{/t} (%s)", modify::getpath($folder) . " / "));
     }
     return "";
 }