コード例 #1
0
ファイル: setup.php プロジェクト: drognisep/Simple-Groupware
 static function validate_input($databases)
 {
     if ($validate = validate::username($_REQUEST["admin_user"]) and $validate != "") {
         setup::error_add("{t}Admin Username{/t} - {t}validation failed{/t} " . $validate, 30);
     }
     if ($_REQUEST["db_host"] == "") {
         setup::error_add(sprintf("{t}missing field{/t}: %s", "{t}Database Hostname / IP{/t}"), 31);
     }
     if ($_REQUEST["db_user"] == "") {
         setup::error_add(sprintf("{t}missing field{/t}: %s", "{t}Database User{/t}"), 32);
     }
     if ($_REQUEST["db_name"] == "") {
         setup::error_add(sprintf("{t}missing field{/t}: %s", "{t}Database Name{/t}"), 33);
     }
     if ($_REQUEST["admin_pw"] == "") {
         setup::error_add(sprintf("{t}missing field{/t}: %s", "{t}Admin Password{/t}"), 34);
     }
     if ($_REQUEST["admin_pw"] != "" and strlen($_REQUEST["admin_pw"]) < 5) {
         setup::error_add("{t}Admin Password{/t}: {t}Password must be not null, min 5 characters.{/t}", "34b");
     }
     if (!@sql_connect($_REQUEST["db_host"], $_REQUEST["db_user"], $_REQUEST["db_pw"], $_REQUEST["db_name"])) {
         if (!sql_connect($_REQUEST["db_host"], $_REQUEST["db_user"], $_REQUEST["db_pw"])) {
             setup::error_add("{t}Connection to database failed.{/t}\n" . sql_error(), 35);
         }
         setup::errors_show();
         if (!sgsml_parser::create_database($_REQUEST["db_name"])) {
             setup::error_add("{t}Creating database failed.{/t}\n" . sql_error(), 36);
         }
     }
     if (!sql_connect($_REQUEST["db_host"], $_REQUEST["db_user"], $_REQUEST["db_pw"], $_REQUEST["db_name"]) or empty(sys::$db)) {
         setup::error_add("{t}Connection to database failed.{/t}\n" . sql_error(), 37);
         setup::errors_show();
     }
     if (!($version = sgsml_parser::sql_version())) {
         setup::error_add(sprintf("{t}Could not determine database-version.{/t}"), 38);
     }
     $database_min = (int) substr(str_replace(".", "", $databases[SETUP_DB_TYPE][1]), 0, 3);
     if ($version < $database_min) {
         setup::error_add(sprintf("{t}Wrong database-version (%s). Please use at least %s !{/t}", $version, $databases[SETUP_DB_TYPE]), "20" . SETUP_DB_TYPE);
     }
     if (SETUP_DB_TYPE == "pgsql") {
         if (!sql_query("SELECT ''::tsvector;")) {
             setup::error_add("{t}Please install 'tsearch2' for the PostgreSQL database.{/t}\n(Run <postgresql>/share/contrib/tsearch2.sql)\n" . sql_error(), 21);
         }
         if (!sql_query(file_get_contents("modules/core/pgsql.sql"))) {
             setup::error_add("pgsql.sql: " . sql_error(), 50);
         }
     }
     setup::errors_show();
     return $version;
 }
コード例 #2
0
 static function show_list($mirror_id)
 {
     setup::out("\n\t<div style='color:#ff0000;'>\n\t<b>{t}Warning{/t}</b>:<br>\n\t- Please make a complete backup of your database (e.g. using phpMyAdmin)<br>\n\t- Please make a complete backup of your sgs folder (e.g. /var/www/htdocs/sgs/)<br>\n\t- Make sure both backups are complete!\n    </div>\n\t<br>\n\t{t}Downloading update list{/t} ...<br>\n  ");
     $mirror = self::$mirrors[$mirror_id];
     $ctx = stream_context_create(array("http" => array("timeout" => 5)));
     $data = @file_get_contents($mirror["url"], 0, $ctx);
     $match = array();
     preg_match_all($mirror["pattern"], $data, $match);
     if (!empty($match[1]) and $data != "") {
         $found = false;
         foreach ($match[1] as $key => $item) {
             if ($key > 4) {
                 break;
             }
             if (strpos("@" . $item, CORE_VERSION_STRING) and !DEBUG) {
                 break;
             }
             if (!empty($match[3][$key]) and strtotime($match[3][$key]) + 3600 > time()) {
                 continue;
             }
             $found = true;
             $check = true;
             if (!empty($match[2][$key])) {
                 $match_version = array();
                 preg_match("/php (\\d+\\.\\d+\\.\\d+)/i", $match[2][$key], $match_version);
                 if (!empty($match_version[1]) and version_compare(PHP_VERSION, $match_version[1], "<")) {
                     setup::out(sprintf("{t}Setup needs php with at least version %s !{/t}", $match_version[1]));
                     $check = false;
                 }
                 preg_match("/" . SETUP_DB_TYPE . " (\\d+\\.\\d+\\.\\d+)/i", $match[2][$key], $match_version);
                 if (!empty($match_version[1])) {
                     $db_version = str_replace(".", "", $match_version[1]);
                     $curr_version = sgsml_parser::sql_version();
                     if ($curr_version < $db_version) {
                         setup::out(sprintf("{t}Wrong database-version (%s). Please use at least %s !{/t}", $curr_version, $match_version[1]));
                         $check = false;
                     }
                 }
             }
             if ($check) {
                 setup::out("<a href='updater.php?mirror=" . $mirror_id . "&token=" . modify::get_form_token() . "&release=" . $item . "'>{t}I n s t a l l{/t}</a>&nbsp; Simple Groupware ", false);
                 setup::out($item . " (<a target='_blank' href='http://www.simple-groupware.de/cms/Release-" . str_replace(".", "-", $item) . "'>Changelog</a>)<br>");
             }
         }
         if (!$found) {
             setup::out("{t}Already running latest release.{/t}<br>");
         }
     } else {
         setup::out(sprintf("{t}Connection error: %s [%s]{/t}", $mirror["url"], "HTTP") . "<br>" . strip_tags($data, "<br><p><h1><center>"));
     }
     setup::out("{t}Server{/t}: <b>" . $mirror["name"] . "</b>, {t}use mirror from{/t}: ", false);
     foreach (self::$mirrors as $key => $sel_mirror) {
         if ($key == $mirror_id) {
             continue;
         }
         setup::out("<a href='updater.php?mirror=" . $key . "'>" . $sel_mirror["name"] . "</a> ");
     }
     setup::out("<br/>{t}Package from local file system (.tar.gz){/t}:<br/>{t}current path{/t}: " . str_replace("\\", "/", getcwd()) . "/<br/>");
     foreach (scandir("./") as $file) {
         if ($file[0] == "." or !preg_match("|^SimpleGroupware\\_.*?.tar\\.gz\$|i", $file)) {
             continue;
         }
         setup::out("<a href='updater.php?token=" . modify::get_form_token() . "&cfile=" . $file . "'>{t}I n s t a l l{/t}</a>&nbsp; " . $file . "<br/>");
     }
     setup::out("<form method='POST'><input type='hidden' name='token' value='" . modify::get_form_token() . "'><input type='text' name='cfile' value='/tmp/SimpleGroupware_0.xyz.tar.gz' style='width:300px;'>&nbsp;<input type='submit' class='submit' value='{t}I n s t a l l{/t}'><br>");
     setup::out("<input type='checkbox' name='nobackup' value='1' onchange='change_links(this.checked);'/> " . sprintf("{t}Don't move old files to '%s'{/t}", SIMPLE_STORE . "/old/") . "</form>");
     setup::out_exit('<div style="border-top: 1px solid black;">Powered by Simple Groupware, Copyright (C) 2002-2012 by Thomas Bley.</div></div></body></html>');
 }
コード例 #3
0
    if ($content != "") {
        $content = "<pre>" . q($content) . "</pre>";
    }
} else {
    if ($_REQUEST["console"] == "sys") {
        $content = "";
        if ($code != "") {
            $content = sys_exec(str_replace("\n", "&", trim($code)));
        }
        $title = "SYS Console: " . getcwd() . " @ " . $_SERVER["SERVER_NAME"] . " [" . $_SERVER["SERVER_SOFTWARE"] . "]";
        if ($content != "") {
            $content = "<pre>" . q($content) . "</pre>";
        }
    } else {
        $content = "";
        $title = "SQL Console:&nbsp; " . SETUP_DB_USER . " @ " . SETUP_DB_NAME . "&nbsp; [" . SETUP_DB_TYPE . " " . sgsml_parser::sql_version() . "] ";
        if ($code != "") {
            if (($data = sql_fetch($code, false)) === false) {
                $content .= sql_error();
            } else {
                if (is_array($data) and count($data) > 0) {
                    $content .= show_table($data, isset($_REQUEST["full_texts"]), isset($_REQUEST["vertical"]));
                } else {
                    if (SETUP_DB_TYPE == "mysqli" and $num = mysqli_affected_rows(sys::$db)) {
                        $content .= t("{t}%s rows affected{/t}", $num);
                    } else {
                        $content .= t("{t}Empty{/t}");
                    }
                }
            }
        }