コード例 #1
0
/**
 * Drops all tables created by singapore.
 * @param sgIO_sql  pointer to a singapore SQL backend object
 */
function sqlDropTables($io)
{
    $success = true;
    setupHeader("Deleting tables");
    if (!$io->query("SELECT * FROM " . $io->config->sql_prefix . "galleries")) {
        setupMessage("'" . $io->config->sql_prefix . "galleries' table not found - skipped");
    } elseif ($io->query("DROP TABLE " . $io->config->sql_prefix . "galleries")) {
        setupMessage("'" . $io->config->sql_prefix . "galleries' table deleted");
    } else {
        $success = setupError("Unable to delete '" . $io->config->sql_prefix . "galleries' table:" . $io->error());
    }
    if (!$io->query("SELECT * FROM " . $io->config->sql_prefix . "images")) {
        setupMessage("'" . $io->config->sql_prefix . "images' table not found - skipped");
    } elseif ($io->query("DROP TABLE " . $io->config->sql_prefix . "images")) {
        setupMessage("'" . $io->config->sql_prefix . "images' table deleted");
    } else {
        $success = setupError("Unable to delete '" . $io->config->sql_prefix . "images' table:" . $io->error());
    }
    if (!$io->query("SELECT * FROM " . $io->config->sql_prefix . "users")) {
        setupMessage("'" . $io->config->sql_prefix . "users' table not found - skipped");
    } elseif ($io->query("DROP TABLE " . $io->config->sql_prefix . "users")) {
        setupMessage("'" . $io->config->sql_prefix . "users' table deleted");
    } else {
        $success = setupError("Unable to delete '" . $io->config->sql_prefix . "users' table:" . $io->error());
    }
    return $success;
}
コード例 #2
0
ファイル: install.php プロジェクト: kyroskoh/singapore-1
            case "sqlite":
                include_once $basePath . "includes/io_sqlite.class.php";
                setupMessage("Setup will now create the database and tables necessary to run singapore on SQLite");
                setupHeader("Opening database file");
                $io = new sgIO_sqlite();
                if (!$io) {
                    setupError("Error connecting to database. Please ensure database settings are correct");
                    break;
                } else {
                    setupMessage("Success");
                }
                if (sqlCreateTables($io)) {
                    setupHeader("OK");
                    setupMessage("This step completed successfully");
                } else {
                    setupHeader("Oops!");
                    setupError('There was a problem. Please fix it and <a href="install.php?step=database">retry this step</a>');
                }
                break;
            default:
                setupError("Unrecognised io_handler.");
        }
        setupMessage("Don't forget to delete or protect this <code>install</code> directory to prevent unauthorised access");
        echo '<br /><a href="install.php?step=test">&lt;&lt; Previous: test server</a>';
        //echo '<br /><a href="install.php?step=directories">&lt;&lt; Previous: create directories</a>';
        echo ' | <a href="index.html">Finish</a>';
        break;
}
?>

</body>
コード例 #3
0
ファイル: install.inc.php プロジェクト: kyroskoh/singapore-1
/**
 * Creates the tables and inserts the default users.
 * @param sgIO_sql  pointer to a singapore SQL backend object
 */
function sqlCreateTables(&$io)
{
    $success = true;
    setupHeader("Creating tables");
    if (@$io->query("SELECT * FROM " . $io->config->sql_prefix . "galleries")) {
        setupMessage("'" . $io->config->sql_prefix . "galleries' table already exists - skipped");
    } elseif ($io->query("CREATE TABLE " . $io->config->sql_prefix . "galleries (" . "id varchar(250) NOT NULL, " . "lang varchar(16) NOT NULL DEFAULT '', " . "filename varchar(200), " . "owner varchar(32), " . "groups varchar(64), " . "permissions int UNSIGNED, " . "categories varchar(255), " . "name varchar(255), " . "artist varchar(255), " . "email varchar(255), " . "copyright varchar(255), " . "description text, " . "summary text, " . "date varchar(255)," . "hits smallint UNSIGNED," . "lasthit int UNSIGNED," . "PRIMARY KEY (id, lang)" . ")")) {
        setupMessage("'" . $io->config->sql_prefix . "galleries' table created");
    } else {
        $success = setupError("Unable to create '" . $io->config->sql_prefix . "galleries' table:" . $io->error());
    }
    if (@$io->query("SELECT * FROM " . $io->config->sql_prefix . "images")) {
        setupMessage("'" . $io->config->sql_prefix . "images' table already exists - skipped");
    } elseif ($io->query("CREATE TABLE " . $io->config->sql_prefix . "images (" . "galleryid varchar(250) NOT NULL, " . "filename varchar(200) NOT NULL, " . "lang varchar(16) NOT NULL DEFAULT '', " . "thumbnail varchar(255), " . "owner varchar(32), " . "groups varchar(64), " . "permissions int, " . "categories varchar(64), " . "name varchar(255), " . "artist varchar(255), " . "email varchar(255), " . "copyright varchar(255), " . "description text, " . "width smallint UNSIGNED, " . "height smallint UNSIGNED, " . "type tinyint UNSIGNED, " . "location varchar(255), " . "date varchar(255), " . "camera varchar(255), " . "lens varchar(255), " . "film varchar(255), " . "darkroom text, " . "digital text, " . "hits smallint UNSIGNED," . "lasthit int UNSIGNED," . "PRIMARY KEY (galleryid, filename, lang)" . ")")) {
        setupMessage("'" . $io->config->sql_prefix . "images' table created");
    } else {
        $success = setupError("Unable to create '" . $io->config->sql_prefix . "images' table:" . $io->error());
    }
    if (@$io->query("SELECT * FROM " . $io->config->sql_prefix . "users")) {
        setupMessage("'" . $io->config->sql_prefix . "users' table already exists - skipped");
    } elseif ($io->query("CREATE TABLE " . $io->config->sql_prefix . "users (" . "username varchar(32) NOT NULL, " . "userpass char(32) NOT NULL, " . "permissions int UNSIGNED, " . "groups varchar(64), " . "email varchar(255), " . "fullname varchar(255), " . "description varchar(255), " . "stats varchar(255), " . "PRIMARY KEY (username)" . ")")) {
        setupMessage("'" . $io->config->sql_prefix . "users' table created");
        if ($io->query("INSERT INTO " . $io->config->sql_prefix . "users VALUES" . '("admin", "5f4dcc3b5aa765d61d8327deb882cf99", 1024, "", "", "Administrator", "Default administrator account", "")') && $io->query("INSERT INTO " . $io->config->sql_prefix . "users VALUES" . '("guest", "5f4dcc3b5aa765d61d8327deb882cf99", 0, "", "", "Guest", "Restricted use account for guests who do not have a user account", "")')) {
            setupMessage("Inserted default users into '" . $io->config->sql_prefix . "users' table");
        } else {
            $success = setupError("Unable to insert default users into '" . $io->config->sql_prefix . "users' table:" . $io->error());
        }
    } else {
        $success = setupError("Unable to create '" . $io->config->sql_prefix . "users' table:" . $io->error());
    }
    return $success;
}