示例#1
0
文件: web.php 项目: xafr/gallery3
     break;
 case "save_db_info":
     $config = array("host" => $_POST["dbhost"], "user" => $_POST["dbuser"], "password" => $_POST["dbpass"], "dbname" => $_POST["dbname"], "prefix" => $_POST["prefix"], "type" => function_exists("mysqli_set_charset") ? "mysqli" : "mysql");
     if (!installer::connect($config)) {
         $content = render("invalid_db_info.html.php");
     } else {
         if (!installer::select_db($config)) {
             $content = render("missing_db.html.php");
         } else {
             if (!installer::db_empty($config)) {
                 $content = render("db_not_empty.html.php");
             } else {
                 if (!installer::unpack_var()) {
                     $content = oops("Unable to create files inside the <code>var</code> directory");
                 } else {
                     if (!installer::unpack_sql($config)) {
                         $content = oops("Failed to create tables in your database:" . mysql_error());
                     } else {
                         if (!installer::create_database_config($config)) {
                             $content = oops("Couldn't create var/database.php");
                         } else {
                             try {
                                 list($user, $password) = installer::create_admin($config);
                                 installer::create_admin_session($config);
                                 $content = render("success.html.php", array("user" => $user, "password" => $password));
                                 installer::create_private_key($config);
                             } catch (Exception $e) {
                                 $content = oops($e->getMessage());
                             }
                         }
                     }
示例#2
0
    return;
}
$config = parse_cli_params();
if (!installer::connect($config)) {
    oops("Unable to connect to the database.\n" . mysql_error() . "\n");
} else {
    if (!installer::select_db($config)) {
        oops("Database {$config['dbname']} doesn't exist and can't be created.  " . "Please create the database by hand.");
    } else {
        if (!installer::db_empty($config)) {
            oops("Database {$config['dbname']} already has tables in it. " . "Please specify an empty database.\n");
        } else {
            if (!installer::unpack_var()) {
                oops("Unable to create files inside the 'var' directory");
            } else {
                if (!installer::unpack_sql()) {
                    oops("Failed to create database tables\n" . mysql_error());
                } else {
                    if (!installer::create_database_config($config)) {
                        oops("Couldn't create var/database.php");
                    } else {
                        system("chmod -R 777 " . VARPATH);
                        list($user, $password) = installer::create_admin($config);
                        print "Your Gallery has been successfully installed!\n";
                        print "We've created an account for you to use:\n";
                        print "  username: {$user}\n";
                        print "  password: {$password}\n";
                        print "\n";
                        exit(0);
                    }
                }