Beispiel #1
0
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "include/dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    if ($argc == 2) {
        switch ($argv[1]) {
            case "update":
                update_structure(true, true);
                return;
            case "dumpsql":
                print_structure(db_definition());
                return;
        }
    }
    // print help
    echo $argv[0] . " <command>\n";
    echo "\n";
    echo "commands:\n";
    echo "update\t\tupdate database schema\n";
    echo "dumpsql\t\tdump database schema\n";
    return;
}
if (array_search(__FILE__, get_included_files()) === 0) {
    dbstructure_run($_SERVER["argv"], $_SERVER["argc"]);
    killme();
}
Beispiel #2
0
    $database["sign"] = array("fields" => array("id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "signed_text" => array("type" => "mediumtext", "not null" => "1"), "signature" => array("type" => "text", "not null" => "1"), "signer" => array("type" => "varchar(255)", "not null" => "1")), "indexes" => array("PRIMARY" => array("id"), "iid" => array("iid"), "retract_iid" => array("retract_iid")));
    $database["spam"] = array("fields" => array("id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "uid" => array("type" => "int(11)", "not null" => "1"), "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "term" => array("type" => "varchar(255)", "not null" => "1"), "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00")), "indexes" => array("PRIMARY" => array("id"), "uid" => array("uid"), "spam" => array("spam"), "ham" => array("ham"), "term" => array("term")));
    $database["term"] = array("fields" => array("tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "oid" => array("type" => "int(10) unsigned", "not null" => "1"), "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1"), "type" => array("type" => "tinyint(3) unsigned", "not null" => "1"), "term" => array("type" => "varchar(255)", "not null" => "1"), "url" => array("type" => "varchar(255)", "not null" => "1"), "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0")), "indexes" => array("PRIMARY" => array("tid"), "oid_otype_type_term" => array("oid", "otype", "type", "term"), "uid_term_tid" => array("uid", "term", "tid"), "type_term" => array("type", "term"), "uid_otype_type_term_tid" => array("uid", "otype", "type", "term", "tid"), "otype_type_term_tid" => array("otype", "type", "term", "tid")));
    $database["thread"] = array("fields" => array("iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"), "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"), "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "network" => array("type" => "varchar(32)", "not null" => "1")), "indexes" => array("PRIMARY" => array("iid"), "created" => array("created"), "commented" => array("commented"), "uid_network_commented" => array("uid", "network", "commented"), "uid_network_created" => array("uid", "network", "created"), "uid_contactid_commented" => array("uid", "contact-id", "commented"), "uid_contactid_created" => array("uid", "contact-id", "created"), "wall_private_received" => array("wall", "private", "received"), "uid_created" => array("uid", "created"), "uid_commented" => array("uid", "commented")));
    $database["tokens"] = array("fields" => array("id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"), "secret" => array("type" => "text", "not null" => "1"), "client_id" => array("type" => "varchar(20)", "not null" => "1"), "expires" => array("type" => "int(11)", "not null" => "1"), "scope" => array("type" => "varchar(200)", "not null" => "1"), "uid" => array("type" => "int(11)", "not null" => "1")), "indexes" => array("PRIMARY" => array("id")));
    $database["unique_contacts"] = array("fields" => array("id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "url" => array("type" => "varchar(255)", "not null" => "1"), "nick" => array("type" => "varchar(255)", "not null" => "1"), "name" => array("type" => "varchar(255)", "not null" => "1"), "avatar" => array("type" => "varchar(255)", "not null" => "1")), "indexes" => array("PRIMARY" => array("id"), "url" => array("url")));
    $database["user"] = array("fields" => array("uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "guid" => array("type" => "varchar(64)", "not null" => "1"), "username" => array("type" => "varchar(255)", "not null" => "1"), "password" => array("type" => "varchar(255)", "not null" => "1"), "nickname" => array("type" => "varchar(255)", "not null" => "1"), "email" => array("type" => "varchar(255)", "not null" => "1"), "openid" => array("type" => "varchar(255)", "not null" => "1"), "timezone" => array("type" => "varchar(128)", "not null" => "1"), "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"), "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "default-location" => array("type" => "varchar(255)", "not null" => "1"), "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "theme" => array("type" => "varchar(255)", "not null" => "1"), "pubkey" => array("type" => "text", "not null" => "1"), "prvkey" => array("type" => "text", "not null" => "1"), "spubkey" => array("type" => "text", "not null" => "1"), "sprvkey" => array("type" => "text", "not null" => "1"), "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"), "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"), "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"), "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"), "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"), "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"), "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"), "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"), "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "pwdreset" => array("type" => "varchar(255)", "not null" => "1"), "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"), "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"), "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "service_class" => array("type" => "varchar(32)", "not null" => "1"), "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "allow_cid" => array("type" => "mediumtext", "not null" => "1"), "allow_gid" => array("type" => "mediumtext", "not null" => "1"), "deny_cid" => array("type" => "mediumtext", "not null" => "1"), "deny_gid" => array("type" => "mediumtext", "not null" => "1"), "openidserver" => array("type" => "text", "not null" => "1")), "indexes" => array("PRIMARY" => array("uid"), "nickname" => array("nickname")));
    $database["userd"] = array("fields" => array("id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "username" => array("type" => "varchar(255)", "not null" => "1")), "indexes" => array("PRIMARY" => array("id"), "username" => array("username")));
    return $database;
}
/*
 * run from command line
 */
function dbstructure_run(&$argv, &$argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "include/dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    update_structure(true, true);
}
if (array_search(__FILE__, get_included_files()) === 0) {
    dbstructure_run($argv, $argc);
    killme();
}