예제 #1
0
 /**
  * Connect to the database.
  *
  * @param
  *		The connection URL. (e.g. mysql://user:pass@whateverhost.com:2400/dbname#prefix)
  * @return
  */
 function connect($db_url)
 {
     global $WT;
     $this->mConnected = false;
     // Parse the Url.
     $url = wtUrlParse($db_url);
     $this->mDB = NULL;
     switch ($url['protocol']) {
         case "mysql":
             // MySQL protocol
             if (!$url['port']) {
                 $url['port'] = "3306";
             }
             require_once $WT->CoreDir . "include/wtDBTranslatorMySQL.php";
             $this->mDB = new wtDBTranslatorMySQL();
             break;
         default:
             // Unknown database protocol
             return false;
     }
     $this->mDB->mDB =& $this;
     $this->Prefix = $url['anchor'];
     $this->Name = substr($url['path'], 1);
     $this->mConnected = $this->mDB->connect($url['host'] . ":" . $url['port'], $url['user'], $url['password'], $this->Name);
     wtCallHook("Core/OnDBConnect", $url, $this->mConnected);
     return $this->mConnected;
 }
 function postInit()
 {
     foreach ($this->mActiveModules as $m) {
         if (!$m->Installed) {
             $this->mDB->q("UPDATE `@P@modules` SET `installed`=1 WHERE `mid`='%s'", $m->Id);
             if (file_exists($m->Dir . "ModuleInstall.php")) {
                 $m->_install($m->Dir . "ModuleInstall.php");
             }
             $m->Installed = true;
             wtCallHook("Core/OnModuleInstall", &$m);
         }
     }
     foreach ($this->mActiveModules as $m) {
         $m->onPostInit();
     }
 }
예제 #3
0
} else {
    $WT->DB->connect($WT->DBUrl);
}
if (!$WT->DB->connected()) {
    // TODO: Display database connection error message.
}
$WT->ModuleManager = new wtModuleManager();
// Is the core already installed?
$ok = wtRegGetKey("Core/Installed");
if (!$ok || $WT->DevMode) {
    if (wtDBInstall($WT->CoreDir . "include/wtCoreDB.php")) {
        wtUserGroupCreate("administrators");
        wtUserCreate("admin", "admin", "administrators");
        wtRegSetKey("Core/Installed", true);
        if (wtDBInstall($WT->CoreDir . "include/wtCoreModuleDB.php", wtDBGetConnection("Core"))) {
            include $WT->CoreDir . "include/wtModInstall.php";
            wtInstallModulesInDirectory($WT->CoreDir . "modules");
            // Finally, install the core modules.
            wtBuildModuleWeights();
        }
    }
}
unset($ok);
$WT->Theme = wtLoadTheme(NULL);
$WT->ModuleManager->read();
$WT->ModuleManager->preInit();
$WT->ModuleManager->postInit();
if (wtCallHook("Theme/OnCall", NULL) !== FALSE) {
    $WT->Theme->call();
}
//$WT->ModuleManager->call("user");