function restore()
{
    global $db, $db_type, $pun_config;
    $db->drop_table('httpbl') or error('Unable to drop table "adsense_config"', __FILE__, __LINE__, $db->error());
    $db->query('DELETE FROM ' . $db->prefix . 'config WHERE conf_name LIKE "o_httpbl_%"') or error('Unable to remove config entries', __FILE__, __LINE__, $db->error());
    forum_clear_cache();
}
        $db->query('UPDATE ' . $db->prefix . 'config SET conf_value = \'' . UPDATE_TO_PARSER_REVISION . '\' WHERE conf_name = \'o_parser_revision\'') or error('Unable to update parser revision number', __FILE__, __LINE__, $db->error());
        // Check the default language still exists!
        if (!file_exists(PUN_ROOT . 'lang/' . $pun_config['o_default_lang'] . '/common.php')) {
            $db->query('UPDATE ' . $db->prefix . 'config SET conf_value = \'English\' WHERE conf_name = \'o_default_lang\'') or error('Unable to update default language', __FILE__, __LINE__, $db->error());
        }
        // Check the default style still exists!
        if (!file_exists(PUN_ROOT . 'style/' . $pun_config['o_default_style'] . '.css')) {
            $db->query('UPDATE ' . $db->prefix . 'config SET conf_value = \'Air\' WHERE conf_name = \'o_default_style\'') or error('Unable to update default style', __FILE__, __LINE__, $db->error());
        }
        // This feels like a good time to synchronize the forums
        $result = $db->query('SELECT id FROM ' . $db->prefix . 'forums') or error('Unable to fetch forum IDs', __FILE__, __LINE__, $db->error());
        while ($row = $db->fetch_row($result)) {
            update_forum($row[0]);
        }
        // Empty the PHP cache
        forum_clear_cache();
        // Delete the update lock file
        @unlink(FORUM_CACHE_DIR . 'db_update.lock');
        ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php 
        echo $lang_common['lang_identifier'];
        ?>
" lang="<?php 
        echo $lang_common['lang_identifier'];
        ?>
" dir="<?php 
        echo $lang_common['lang_direction'];
        ?>
">
示例#3
0
 public function install()
 {
     if (class_exists('ZipArchive')) {
         if (!file_exists(PANTHER_ROOT . 'include/updates/' . $this->file_name)) {
             exit($this->lang['update failed']);
         }
         $zip = new ZipArchive();
         if ($zip->open(PANTHER_ROOT . 'include/updates/' . $this->file_name)) {
             if (!is_dir(PANTHER_ROOT . 'include/updates/' . $this->version_friendly($this->panther_updates['version']))) {
                 mkdir(PANTHER_ROOT . 'include/updates/' . $this->version_friendly($this->panther_updates['version']));
             }
             $zip->extractTo(PANTHER_ROOT . 'include/updates/' . $this->version_friendly($this->panther_updates['version']));
             $zip->close();
             unlink(PANTHER_ROOT . 'include/updates/' . $this->file_name);
             if (file_exists(PANTHER_ROOT . 'include/updates/' . $this->version_friendly($this->panther_updates['version']) . '/panther_database.php')) {
                 require PANTHER_ROOT . 'include/updates/' . $this->version_friendly($this->panther_updates['version']) . '/panther_database.php';
             }
             if (file_exists(PANTHER_ROOT . 'include/updates/' . $this->version_friendly($this->panther_updates['version']) . '/panther_updates.php')) {
                 require PANTHER_ROOT . 'include/updates/' . $this->version_friendly($this->panther_updates['version']) . '/panther_updates.php';
             }
             if (!defined('PANTHER_REQUIRED_MYSQL') || !defined('PANTHER_REQUIRED_PHP') || !defined('PANTHER_NEW_VERSION')) {
                 exit($this->lang['Invalid update patch']);
             }
             if (!preg_match('/^[0-9]{1}\\.[0-9]{1}\\.[0-9]{1}$/', PANTHER_NEW_VERSION) || !preg_match('/^[0-9]{1}\\.[0-9]{1}\\.[0-9]{2}(|[-a-z]+)$/', PANTHER_REQUIRED_MYSQL) || !preg_match('/^[0-9]{1}\\.[0-9]{1}\\.[0-9]{1,2}$/', PANTHER_REQUIRED_PHP)) {
                 exit($this->lang['Invalid update patch']);
             }
             $mysql = $this->db->get_version();
             $php_version = phpversion();
             if (PANTHER_REQUIRED_MYSQL > $mysql['version'] || PANTHER_REQUIRED_PHP > $php_version) {
                 exit(sprintf($this->lang['Hosting environment does not support Panther x'], PANTHER_NEW_VERSION, PANTHER_REQUIRED_MYSQL, PANTHER_REQUIRED_PHP, $mysql['version'], $php_version));
             }
             if (isset($this->database)) {
                 if (!empty($this->database['alter'])) {
                     foreach ($this->database['alter'] as $table => $query) {
                         $this->db->run('ALTER TABLE ' . $this->db->prefix . $table . $query);
                     }
                 }
                 if (!empty($this->database['drop'])) {
                     foreach ($this->database['drop'] as $table => $query) {
                         $this->db->drop_table($table);
                     }
                 }
                 if (!empty($this->database['create'])) {
                     foreach ($this->database['create'] as $table => $schema) {
                         $this->db->create_table($table, $schema);
                     }
                 }
                 if (!empty($this->database['rename'])) {
                     foreach ($this->database['rename'] as $old_name => $new_name) {
                         $this->db->rename_table($old_name, $new_name);
                     }
                 }
                 if (!empty($this->database['drop_field'])) {
                     foreach ($this->database['drop_field'] as $table => $field) {
                         $this->db->drop_field($table, $field);
                     }
                 }
                 if (!empty($this->database['query'])) {
                     foreach ($this->database['query'] as $table => $query) {
                         $query = str_replace($table, $this->db->prefix . $table, $query);
                         // Make sure a valid database prefix is present.
                         $this->db->run($query);
                     }
                 }
             }
             $update = array('conf_value' => PANTHER_NEW_VERSION);
             $data = array(':conf_name' => 'o_cur_version');
             $this->db->update('config', $update, 'conf_name=:conf_name', $data);
             $this->db->end_transaction();
             $this->db->close();
             if (isset($this->updates['replace'])) {
                 foreach ($this->updates['replace'] as $file => $replace) {
                     if (file_exists(PANTHER_ROOT . $file)) {
                         unlink(PANTHER_ROOT . $file);
                     }
                     rename(PANTHER_ROOT . 'include/updates/' . $this->version_friendly($this->panther_updates['version']) . '/' . $replace, PANTHER_ROOT . $file);
                 }
             }
             if (isset($this->updates['add'])) {
                 foreach ($this->updates['add'] as $file => $replace) {
                     rename(PANTHER_ROOT . 'include/updates/' . $this->version_friendly($this->panther_updates['version']) . '/' . $replace, PANTHER_ROOT . $file);
                 }
             }
             if (isset($this->updates['remove'])) {
                 foreach ($this->updates['remove'] as $file) {
                     unlink(PANTHER_ROOT . $file);
                 }
             }
             $files = array_diff(scandir(PANTHER_ROOT . 'include/updates/' . $this->version_friendly($this->panther_updates['version'])), array('.', '..'));
             foreach ($files as $file) {
                 unlink(PANTHER_ROOT . 'include/updates/' . $this->version_friendly($this->panther_updates['version']) . '/' . $file);
             }
             rmdir(PANTHER_ROOT . 'include/updates/' . $this->version_friendly($this->panther_updates['version']));
             forum_clear_cache();
         } else {
             exit(sprintf($this->lang['Unable to open archive'], $this->file_name));
         }
     } else {
         exit(sprintf($this->lang['ZipArchive not supported'], $this->panther_updates['version']));
     }
 }
示例#4
0
function regenerate_glob_vars()
{
    global $forum_db, $forum_config, $forum_hooks;
    // Empty the PHP cache
    forum_clear_cache();
    // Config and hooks might be changed. Let's get them
    // Get the forum config from the DB
    $query = array('SELECT' => 'c.*', 'FROM' => 'config AS c');
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $forum_config = array();
    while ($cur_config_item = $forum_db->fetch_row($result)) {
        $forum_config[$cur_config_item[0]] = $cur_config_item[1];
    }
    // Get hooks from the DB
    $query = array('SELECT' => 'eh.id, eh.code, eh.extension_id', 'FROM' => 'extension_hooks AS eh', 'JOINS' => array(array('INNER JOIN' => 'extensions AS e', 'ON' => 'e.id=eh.extension_id')), 'WHERE' => 'e.disabled=0', 'ORDER BY' => 'eh.priority, eh.installed');
    ($hook = get_hook('ch_qr_get_hooks')) ? eval($hook) : null;
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $forum_hooks = array();
    while ($cur_hook = $forum_db->fetch_assoc($result)) {
        $load_ext_info = '$ext_info_stack[] = array(' . "\n" . '\'id\'		 => \'' . $cur_hook['extension_id'] . '\',' . "\n" . '\'path\'	   => FORUM_ROOT.\'extensions/' . $cur_hook['extension_id'] . '\',' . "\n" . '\'url\'		=> $GLOBALS[\'base_url\'].\'/extensions/' . $cur_hook['extension_id'] . '\');' . "\n" . '
			$ext_info = $ext_info_stack[count($ext_info_stack) - 1];';
        $unload_ext_info = 'array_pop($ext_info_stack);' . "\n" . '$ext_info = empty($ext_info_stack) ? array() : $ext_info_stack[count($ext_info_stack) - 1];';
        $forum_hooks[$cur_hook['id']][] = $load_ext_info . "\n\n" . $cur_hook['code'] . "\n\n" . $unload_ext_info . "\n";
    }
}