Exemplo n.º 1
0
 function Upgrade(&$request)
 {
     $this->request =& $request;
     $this->dbi =& $request->_dbi;
     // no reference for dbadmin ?
     $this->phpwiki_version = $this->current_db_version = phpwiki_version();
     //$this->current_db_version = 1030.13; // should be stored in the db. should be phpwiki_version
     $this->db_version = $this->dbi->get_db_version();
     $this->isSQL = $this->dbi->_backend->isSQL();
 }
Exemplo n.º 2
0
 function WikiRequest()
 {
     $this->_dbi = WikiDB::open($GLOBALS['DBParams']);
     // first mysql request costs [958ms]! [670ms] is mysql_connect()
     if (in_array('File', $this->_dbi->getAuthParam('USER_AUTH_ORDER'))) {
         // force our local copy, until the pear version is fixed.
         include_once dirname(__FILE__) . "/pear/File_Passwd.php";
     }
     if (ENABLE_USER_NEW) {
         // Preload all necessary userclasses. Otherwise session => __PHP_Incomplete_Class_Name
         // There's no way to demand-load it later. This way it's much slower, but needs slightly
         // less memory than loading all.
         if (ALLOW_BOGO_LOGIN) {
             include_once "lib/WikiUser/BogoLogin.php";
         }
         // UserPreferences POST Update doesn't reach this.
         foreach ($GLOBALS['USER_AUTH_ORDER'] as $method) {
             include_once "lib/WikiUser/{$method}.php";
             if ($method == 'Db') {
                 switch (DATABASE_TYPE) {
                     case 'SQL':
                         include_once "lib/WikiUser/PearDb.php";
                         break;
                     case 'ADODB':
                         include_once "lib/WikiUser/AdoDb.php";
                         break;
                     case 'PDO':
                         include_once "lib/WikiUser/PdoDb.php";
                         break;
                 }
             }
         }
         unset($method);
     }
     if (USE_DB_SESSION) {
         include_once 'lib/DbSession.php';
         $dbi =& $this->_dbi;
         $this->_dbsession = new DbSession($dbi, $dbi->getParam('prefix') . $dbi->getParam('db_session_table'));
     }
     // Fixme: Does pear reset the error mask to 1? We have to find the culprit
     //$x = error_reporting();
     $this->version = phpwiki_version();
     $this->Request();
     // [90ms]
     // Normalize args...
     $this->setArg('pagename', $this->_deducePagename());
     $this->setArg('action', $this->_deduceAction());
     if (DEBUG & _DEBUG_SQL or DATABASE_OPTIMISE_FREQUENCY > 0 and time() % DATABASE_OPTIMISE_FREQUENCY == 0) {
         if ($this->_dbi->_backend->optimize()) {
             trigger_error(_("Optimizing database"), E_USER_NOTICE);
         }
     }
     // Restore auth state. This doesn't check for proper authorization!
     $userid = $this->_deduceUsername();
     if (ENABLE_USER_NEW) {
         if (isset($this->_user) and !empty($this->_user->_authhow) and $this->_user->_authhow == 'session') {
             // users might switch in a session between the two objects.
             // restore old auth level here or in updateAuthAndPrefs?
             //$user = $this->getSessionVar('wiki_user');
             // revive db handle, because these don't survive sessions
             if (isset($this->_user) and (!isa($this->_user, WikiUserClassname()) or strtolower(get_class($this->_user)) == '_passuser')) {
                 $this->_user = WikiUser($userid, $this->_user->_prefs);
             }
             // revive other db handle
             if (isset($this->_user->_prefs->_method) and ($this->_user->_prefs->_method == 'SQL' or $this->_user->_prefs->_method == 'ADODB' or $this->_user->_prefs->_method == 'PDO' or $this->_user->_prefs->_method == 'HomePage')) {
                 $this->_user->_HomePagehandle = $this->getPage($userid);
             }
             // need to update the lockfile filehandle
             if (isa($this->_user, '_FilePassUser') and $this->_user->_file->lockfile and !$this->_user->_file->fplock) {
                 //$level = $this->_user->_level;
                 $this->_user = UpgradeUser($this->_user, new _FilePassUser($userid, $this->_user->_prefs, $this->_user->_file->filename));
                 //$this->_user->_level = $level;
             }
             $this->_prefs =& $this->_user->_prefs;
         } else {
             $user = WikiUser($userid);
             $this->_user =& $user;
             $this->_prefs =& $this->_user->_prefs;
         }
     } else {
         $this->_user = new WikiUser($this, $userid);
         $this->_prefs = $this->_user->getPreferences();
     }
 }
Exemplo n.º 3
0
/**
 * if page.cached_html does not exists:
 *   put _cached_html from pagedata into a new seperate blob, not huge serialized string.
 *
 * it is only rarelely needed: for current page only, if-not-modified
 * but was extracetd for every simple page iteration.
 */
function _upgrade_cached_html(&$dbh, $verbose = true)
{
    global $DBParams;
    if (!in_array($DBParams['dbtype'], array('SQL', 'ADODB'))) {
        return;
    }
    $count = 0;
    if (phpwiki_version() >= 1030.1) {
        if ($verbose) {
            echo _("check for extra page.cached_html column"), " ... ";
        }
        $database = $dbh->_backend->database();
        extract($dbh->_backend->_table_names);
        $fields = $dbh->_backend->listOfFields($database, $page_tbl);
        if (!strstr(strtolower(join(':', $fields)), "cached_html")) {
            if ($verbose) {
                echo "<b>", _("ADDING"), "</b>", " ... ";
            }
            $backend_type = $dbh->_backend->backendType();
            if (substr($backend_type, 0, 5) == 'mysql') {
                $dbh->genericSqlQuery("ALTER TABLE {$page_tbl} ADD cached_html MEDIUMBLOB");
            } else {
                $dbh->genericSqlQuery("ALTER TABLE {$page_tbl} ADD cached_html BLOB");
            }
            if ($verbose) {
                echo "<b>", _("CONVERTING"), "</b>", " ... ";
            }
            $count = _convert_cached_html($dbh);
            if ($verbose) {
                echo $count, " ", _("OK"), "<br />\n";
            }
        } else {
            if ($verbose) {
                echo _("OK"), "<br />\n";
            }
        }
    }
    return $count;
}