コード例 #1
0
function upgrade_LinksPlugin()
{
    global $_CONF, $_TABLES;
    require_once $_CONF['path_system'] . 'classes/config.class.php';
    $plugin_path = $_CONF['path'] . 'plugins/links/';
    require_once $plugin_path . 'install_defaults.php';
    if (file_exists($plugin_path . 'config.php')) {
        global $_DB_table_prefix, $_LI_CONF;
        require_once $plugin_path . 'config.php';
    }
    if (!plugin_initconfig_links()) {
        echo 'There was an error upgrading the Links plugin';
        return false;
    }
    $li_config = config::get_instance();
    $_LI_CONF = $li_config->get_config('links');
    if (empty($_LI_CONF['root'])) {
        $_LI_CONF['root'] = 'site';
    }
    $root = addslashes($_LI_CONF['root']);
    $P_SQL = array();
    $P_SQL[] = "\n    CREATE TABLE {$_TABLES['linkcategories']} (\n      cid varchar(32) NOT NULL,\n      pid varchar(32) NOT NULL,\n      category varchar(32) NOT NULL,\n      description text DEFAULT NULL,\n      tid varchar(20) DEFAULT NULL,\n      created datetime DEFAULT NULL,\n      modified datetime DEFAULT NULL,\n      owner_id mediumint(8) unsigned NOT NULL default '1',\n      group_id mediumint(8) unsigned NOT NULL default '1',\n      perm_owner tinyint(1) unsigned NOT NULL default '3',\n      perm_group tinyint(1) unsigned NOT NULL default '2',\n      perm_members tinyint(1) unsigned NOT NULL default '2',\n      perm_anon tinyint(1) unsigned NOT NULL default '2',\n      PRIMARY KEY (cid),\n      KEY links_pid (pid)\n    ) ENGINE=MyISAM\n    ";
    $blockadmin_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name='Block Admin'");
    $P_SQL[] = "ALTER TABLE {$_TABLES['linksubmission']} ADD owner_id mediumint(8) unsigned NOT NULL default '1' AFTER date";
    $P_SQL[] = "ALTER TABLE {$_TABLES['linksubmission']} CHANGE category cid varchar(32) NOT NULL";
    $P_SQL[] = "ALTER TABLE {$_TABLES['links']} CHANGE category cid varchar(32) NOT NULL";
    $P_SQL[] = "INSERT INTO {$_TABLES['linkcategories']} (cid, pid, category, description, tid, created, modified, group_id, owner_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('{$root}', 'root', 'Root', 'Website root', NULL, NOW(), NOW(), 5, 2, 3, 3, 2, 2)";
    $P_SQL[] = "UPDATE {$_TABLES['plugins']} SET pi_version = '2.0.0', pi_gl_version='1.5.0' WHERE pi_name='links'";
    $P_SQL = INST_checkInnodbUpgrade($P_SQL);
    foreach ($P_SQL as $sql) {
        $rst = DB_query($sql);
        if (DB_error()) {
            echo "There was an error upgrading the links, SQL: {$sql}<br>";
            return false;
        }
    }
    // get Links admin group number
    $group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Links Admin'");
    // loop through adding to category table, then update links table with cids
    $result = DB_query("SELECT DISTINCT cid AS category FROM {$_TABLES['links']}");
    $nrows = DB_numRows($result);
    for ($i = 0; $i < $nrows; $i++) {
        $A = DB_fetchArray($result);
        $category = addslashes($A['category']);
        $cid = $category;
        DB_query("INSERT INTO {$_TABLES['linkcategories']} (cid,pid,category,description,tid,owner_id,group_id,created,modified) VALUES ('{$cid}','{$root}','{$category}','{$category}','all',2,'{$group_id}',NOW(),NOW())", 1);
        if ($cid != $category) {
            // still experimenting ...
            DB_query("UPDATE {$_TABLES['links']} SET cid='{$cid}' WHERE cid='{$category}'", 1);
        }
        if (DB_error()) {
            echo "Error inserting categories into linkcategories table";
            return false;
        }
    }
    return true;
}
コード例 #2
0
ファイル: install.lib.php プロジェクト: JohnToro/glfusion
/**
 * Run all the database queries from the update file.
 *
 * @param   array $_SQL   Array of queries
 *
 */
function INST_updateDB($_SQL, $use_innodb)
{
    global $_DB, $_DB_dbms;
    $_DB->setDisplayError(true);
    $errors = '';
    $rc = true;
    $_SQL = INST_checkInnodbUpgrade($_SQL, $use_innodb);
    foreach ($_SQL as $sql) {
        DB_query($sql, 1);
        if (DB_error()) {
            $errors .= DB_error() . '<br />' . LB;
            $rc = false;
        }
    }
    return array($rc, $errors);
}
コード例 #3
0
ファイル: lib-upgrade.php プロジェクト: hostellerie/nexpro
/**
 * Run all the database queries from the update file.
 *
 * @param   array $_SQL   Array of queries to perform
 *
 */
function INST_updateDB($_SQL)
{
    global $progress, $use_innodb, $_DB, $_DB_dbms;
    $_SQL = INST_checkInnodbUpgrade($_SQL);
    foreach ($_SQL as $sql) {
        $progress .= "executing " . $sql . "<br" . XHTML . ">\n";
        if ($_DB_dbms == 'mssql') {
            $_DB->dbQuery($sql, 0, 1);
        } else {
            DB_query($sql);
        }
    }
}