Exemplo n.º 1
0
 /**
  * Creates the database structure of the wcf.
  */
 protected function createDB()
 {
     $this->initDB();
     // get content of the sql structure file
     $sql = file_get_contents(TMP_DIR . 'setup/db/install.sql');
     // split by offsets
     $sqlData = explode('/* SQL_PARSER_OFFSET */', $sql);
     $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0;
     if (!isset($sqlData[$offset])) {
         throw new SystemException("Offset for SQL parser is out of bounds, " . $offset . " was requested, but there are only " . count($sqlData) . " sections");
     }
     $sql = $sqlData[$offset];
     // installation number value 'n' (WCF_N) must be reflected in the executed sql queries
     $sql = str_replace('wcf1_', 'wcf' . WCF_N . '_', $sql);
     // execute sql queries
     $parser = new SQLParser($sql);
     $parser->execute();
     // log sql queries
     preg_match_all("~CREATE\\s+TABLE\\s+(\\w+)~i", $sql, $matches);
     if (!empty($matches[1])) {
         $sql = "INSERT INTO\twcf" . WCF_N . "_package_installation_sql_log\n\t\t\t\t\t\t(sqlTable)\n\t\t\t\tVALUES\t\t(?)";
         $statement = self::getDB()->prepareStatement($sql);
         foreach ($matches[1] as $tableName) {
             $statement->execute(array($tableName));
         }
     }
     if ($offset < count($sqlData) - 1) {
         WCF::getTPL()->assign(array('__additionalParameters' => array('offset' => $offset + 1)));
         $this->gotoNextStep('createDB');
     } else {
         /*
          * Manually install PIPPackageInstallationPlugin since install.sql content is not escaped resulting
          * in different behaviour in MySQL and MSSQL. You SHOULD NOT move this into install.sql!
          */
         $sql = "INSERT INTO\twcf" . WCF_N . "_package_installation_plugin\n\t\t\t\t\t\t(pluginName, priority, className)\n\t\t\t\tVALUES\t\t(?, ?, ?)";
         $statement = self::getDB()->prepareStatement($sql);
         $statement->execute(array('packageInstallationPlugin', 1, 'wcf\\system\\package\\plugin\\PIPPackageInstallationPlugin'));
         $this->gotoNextStep('logFiles');
     }
 }
 /**
  * @see	\wcf\system\database\util\SQLParser::executeStandardStatement()
  */
 protected function executeStandardStatement($query)
 {
     if (!$this->test) {
         parent::executeStandardStatement($query);
     }
 }
Exemplo n.º 3
0
 /**
  * Creates the database structure of the wcf.
  */
 protected function createDB()
 {
     $this->initDB();
     // get content of the sql structure file
     $sql = file_get_contents(TMP_DIR . 'setup/db/install.sql');
     // installation number value 'n' (WCF_N) must be reflected in the executed sql queries
     $sql = StringUtil::replace('wcf1_', 'wcf' . WCF_N . '_', $sql);
     // execute sql queries
     $parser = new SQLParser($sql);
     $parser->execute();
     // log sql queries
     preg_match_all("~CREATE\\s+TABLE\\s+(\\w+)~i", $sql, $matches);
     if (count($matches[1])) {
         $sql = "INSERT INTO\twcf" . WCF_N . "_package_installation_sql_log\n\t\t\t\t\t\t(sqlTable)\n\t\t\t\tVALUES\t\t(?)";
         $statement = self::getDB()->prepareStatement($sql);
         foreach ($matches[1] as $tableName) {
             $statement->execute(array($tableName));
         }
     }
     /*
      * Manually install PIPPackageInstallationPlugin since install.sql content is not escaped resulting
      * in different behaviour in MySQL and MSSQL. You SHOULD NOT move this into install.sql!
      */
     $sql = "INSERT INTO\twcf" . WCF_N . "_package_installation_plugin\n\t\t\t\t\t(pluginName, priority, className)\n\t\t\tVALUES\t\t(?, ?, ?)";
     $statement = self::getDB()->prepareStatement($sql);
     $statement->execute(array('packageInstallationPlugin', 1, 'wcf\\system\\package\\plugin\\PIPPackageInstallationPlugin'));
     $this->gotoNextStep('logFiles');
 }