Example #1
0
 static function validate()
 {
     if (!sys_validate_token()) {
         return "{t}Invalid security token{/t}";
     }
     if ($_REQUEST["setup_admin_user"] != SETUP_ADMIN_USER and $validate = validate::username($_REQUEST["setup_admin_user"]) and $validate != "") {
         return "{t}Admin Username{/t}: {t}validation failed{/t} " . $validate;
     }
     if ($_REQUEST["setup_admin_user2"] != "" and $_REQUEST["setup_admin_user2"] != SETUP_ADMIN_USER2 and $validate = validate::username($_REQUEST["setup_admin_user2"]) and $validate != "") {
         return "{t}Admin Username{/t} (2): {t}validation failed{/t} " . $validate;
     }
     if (!is_numeric($_REQUEST["login_timeout"]) or $_REQUEST["login_timeout"] <= 60) {
         return "{t}Session timeout{/t}: {t}validation failed{/t}";
     }
     if ($_REQUEST["setup_db_host"] == "") {
         return "{t}missing field{/t}: {t}Database Hostname / IP{/t}";
     }
     if ($_REQUEST["setup_db_user"] == "") {
         return "{t}missing field{/t}: {t}Database User{/t}";
     }
     if ($_REQUEST["setup_db_name"] == "") {
         return "{t}missing field{/t}: {t}Database Name{/t}";
     }
     if (empty($_REQUEST["setup_auth"])) {
         return "{t}missing field{/t}: {t}Authentication Mode{/t}";
     }
     if (!sql_connect($_REQUEST["setup_db_host"], $_REQUEST["setup_db_user"], $_REQUEST["setup_db_pw"], $_REQUEST["setup_db_name"])) {
         return "{t}Connection to database failed.{/t}\n" . sql_error();
     }
     if (empty($_REQUEST["simple_cache"]) or !is_dir($_REQUEST["simple_cache"])) {
         return "SIMPLE_CACHE: {t}validation failed{/t} " . $_REQUEST["simple_cache"];
     }
     if (empty($_REQUEST["simple_store"]) or !is_dir($_REQUEST["simple_store"])) {
         return "SIMPLE_STORE: {t}validation failed{/t} " . $_REQUEST["simple_store"];
     }
     if (empty($_REQUEST["simple_custom"]) or !is_dir($_REQUEST["simple_custom"])) {
         return "SIMPLE_CUSTOM: {t}validation failed{/t} " . $_REQUEST["simple_custom"];
     }
     if (empty($_REQUEST["simple_ext"]) or !is_dir($_REQUEST["simple_ext"])) {
         return "SIMPLE_EXT: {t}validation failed{/t} " . $_REQUEST["simple_ext"];
     }
     if (!empty($_REQUEST["apc_session"]) and !APC) {
         return sprintf("{t}Please install the php-extension with name '%s'.{/t}", "apc");
     }
     if (strlen($_REQUEST["setup_admin_pw"]) < 5) {
         return "{t}Admin Password{/t}: {t}Password must be not null, min 5 characters.{/t}";
     }
     if (strlen($_REQUEST["setup_admin_pw2"]) < 5 and $_REQUEST["setup_admin_user2"] != "") {
         return "{t}Admin Password{/t} (2): {t}Password must be not null, min 5 characters.{/t}";
     }
     if (!empty($_REQUEST["sync4j"])) {
         echo sprintf("{t}Processing %s ...{/t}", "Funambol schema") . "<br>";
         if (SETUP_DB_TYPE == "mysqli") {
             $data = preg_replace("!/\\*.+?\\*/!s", "", file_get_contents("tools/funambolv7_syncML/mysql/funambol.sql"));
             if ($msg = db_query(explode(";", $data))) {
                 return "funambol.sql [mysql]: " . $msg . "<br>";
             }
         } else {
             if (SETUP_DB_TYPE == "pgsql") {
                 $data = file_get_contents("tools/funambolv7_syncML/postgresql/funambol.sql");
                 if ($msg = db_query($data)) {
                     return "funambol.sql [pgsql]: " . $msg . "<br>";
                 }
             } else {
                 return "{t}Funambol only works with MySQL and PostgreSQL.{/t}<br>";
             }
         }
     }
     return "";
 }
Example #2
0
 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;
 }