Exemplo n.º 1
0
 function do_update()
 {
     global $DB, $UD, $conf, $REGX;
     $Q[] = "ALTER TABLE `exp_search` CHANGE `query` `query` MEDIUMTEXT NULL DEFAULT NULL";
     $Q[] = "ALTER TABLE `exp_search` CHANGE `custom_fields` `custom_fields` MEDIUMTEXT NULL DEFAULT NULL";
     $Q[] = "ALTER TABLE `exp_templates` ADD `last_author_id` INT(10) UNSIGNED NOT NULL AFTER `edit_date`";
     $Q[] = "ALTER TABLE `exp_revision_tracker` ADD `item_author_id` INT(10) UNSIGNED NOT NULL AFTER `item_date`";
     $query = $DB->query('SHOW FIELDS FROM exp_weblog_data');
     foreach ($query->result as $row) {
         if (strncmp($row['Field'], 'field_ft', 8) == 0) {
             $Q[] = "ALTER TABLE `exp_weblog_data` CHANGE `{$row['Field']}` `{$row['Field']}` TINYTEXT NULL";
         }
     }
     // run our queries
     foreach ($Q as $sql) {
         $DB->query($sql);
     }
     // for the benefit of Mr Kite! Okay, for the benefit of the Prefs class.
     if (!defined('REQ')) {
         define('REQ', 'UPDATE');
     }
     require PATH_CORE . 'core.regex' . EXT;
     $REGX = new Regex();
     require PATH_CORE . 'core.prefs' . EXT;
     // We need to add a new template preference, so we'll fetch the existing site template prefs
     $query = $DB->query("SELECT site_name, site_id, site_template_preferences FROM exp_sites");
     foreach ($query->result as $row) {
         $PREFS = new Preferences();
         $PREFS->site_prefs($row['site_name'], $row['site_id']);
         $prefs = $this->array_stripslashes(unserialize($row['site_template_preferences']));
         // Add our new pref to the array
         $prefs['strict_urls'] = $PREFS->ini('site_404') == FALSE ? 'n' : 'y';
         // Update the DB
         $DB->query($DB->update_string('exp_sites', array('site_template_preferences' => addslashes(serialize($prefs))), "site_id = '" . $row['site_id'] . "'"));
     }
     return TRUE;
 }
Exemplo n.º 2
0
// ----------------------------------------------
//  Instantiate the Preferences class
// ----------------------------------------------
require PATH_CORE . 'core.prefs' . EXT;
$PREFS = new Preferences();
// Assign the config file array to the preferences
// class so we can transport it as an object
$PREFS->core_ini = $conf;
$PREFS->default_ini = $conf;
$PREFS->exceptions = $exceptions;
unset($conf);
unset($exceptions);
// ----------------------------------------------
//  Connect to the database
// ----------------------------------------------
if (!in_array($PREFS->ini('db_type'), array('mysql'))) {
    return FALSE;
}
require PATH_DB . 'db.' . $PREFS->ini('db_type') . EXT;
$db_config = array('hostname' => $PREFS->ini('db_hostname'), 'username' => $PREFS->ini('db_username'), 'password' => $PREFS->ini('db_password'), 'database' => $PREFS->ini('db_name'), 'prefix' => $PREFS->ini('db_prefix'), 'conntype' => $PREFS->ini('db_conntype'), 'debug' => $PREFS->ini('debug') != 0 ? 1 : 0, 'show_queries' => TRUE, 'enable_cache' => FALSE);
$DB = new DB($db_config);
if (!$DB->db_connect(0)) {
    exit("Database Error:  Unable to connect to your database. Your database appears to be turned off or the database connection settings in your config file are not correct. Please contact your hosting provider if the problem persists.");
}
if (!$DB->select_db()) {
    exit("Database Error:  Unable to select your database");
}
// ----------------------------------------------
//  Instantiate the regular expressions class
// ----------------------------------------------
require PATH_CORE . 'core.regex' . EXT;