예제 #1
0
 /**
  * Sort out profile fields
  * 
  * @return	@e void
  */
 public function addProfile()
 {
     /* INIT */
     $fields = array();
     $prefix = $this->registry->dbFunctions()->getPrefix();
     $sourceFile = '';
     /* Get DB driver file */
     require_once IPSLib::getAppDir('core') . '/setup/versions/upg_30001/' . strtolower($this->registry->dbFunctions()->getDriverType()) . '_version_upgrade.php';
     /*noLibHook*/
     /* First off, move all current profile fields to group ID 3 */
     $this->DB->update('pfields_data', array('pf_group_id' => 3), 'pf_group_id=0');
     /* Grab all custom fields */
     $this->DB->build(array('select' => '*', 'from' => 'pfields_data'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $fields[$row['pf_id']] = $row;
     }
     foreach ($fields as $id => $data) {
         /* Now add any missing content fields */
         if (!$this->DB->checkForField("field_{$id}", 'pfields_content')) {
             $this->DB->addField('pfields_content', "field_{$id}", 'text');
         }
     }
     $this->DB->optimize('pfields_content');
     /* Now make add a key */
     $this->DB->build(array('select' => '*', 'from' => 'pfields_data', 'where' => 'pf_group_id=3'));
     $o = $this->DB->execute();
     while ($row = $this->DB->fetch($o)) {
         /* Attempt basic conversion of data */
         if ($row['pf_topic_format']) {
             if ($row['pf_topic_format'] == '{title}: {content}<br />') {
                 $row['pf_topic_format'] = '<span class="ft">{title}:</span><span class="fc">{content}</span>';
             } else {
                 if ($row['pf_topic_format'] == '{title}: {key}<br />') {
                     $row['pf_topic_format'] = '<span class="ft">{title}:</span><span class="fc">{key}</span>';
                 }
             }
         }
         /* 2.3.x used 'text', 3.0.0 uses 'input'... */
         $row['pf_type'] = $row['pf_type'] == 'text' ? 'input' : $row['pf_type'];
         $this->DB->update('pfields_data', array('pf_type' => $row['pf_type'], 'pf_topic_format' => $row['pf_topic_format'], 'pf_key' => IPSText::makeSeoTitle($row['pf_title'])), 'pf_id=' . $row['pf_id']);
     }
     /* Now, move profile data into the correct fields */
     foreach (array('aim_name' => 'aim', 'icq_number' => 'icq', 'website' => 'website', 'yahoo' => 'yahoo', 'interests' => 'interests', 'msnname' => 'msn', 'location' => 'location') as $old => $new) {
         $field = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'pfields_data', 'where' => 'pf_key=\'' . $new . '\''));
         $query = SQLVC::UpdateOne($old, $field);
         if (is_null($query)) {
             continue;
         }
         if (IPSSetUp::getSavedData('man')) {
             $query = trim($query);
             /* Ensure the last character is a semi-colon */
             if (substr($query, -1) != ';') {
                 $query .= ';';
             }
             $output .= $query . "\n\n";
         } else {
             $this->DB->query($query);
             if ($this->DB->error) {
                 $this->registry->output->addError($query . "<br /><br />" . $this->DB->error);
             } else {
                 $this->registry->output->addMessage("Конвертирование поля: {$old}....");
             }
         }
     }
     /* Update gender */
     $gender = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'pfields_data', 'where' => 'pf_key=\'gender\''));
     if ($gender['pf_id']) {
         $queries = array(SQLVC::UpdateTwo($gender), SQLVC::UpdateThree($gender));
         foreach ($queries as $query) {
             if (IPSSetUp::getSavedData('man')) {
                 $query = trim($query);
                 /* Ensure the last character is a semi-colon */
                 if (substr($query, -1) != ';') {
                     $query .= ';';
                 }
                 $output .= $query . "\n\n";
             } else {
                 $this->DB->query($query);
                 if ($this->DB->error) {
                     $this->registry->output->addError($query . "<br /><br />" . $this->DB->error);
                 } else {
                     $this->registry->output->addMessage("Конвертирование поля «Пол»....");
                 }
             }
         }
     }
     if (IPSSetUp::getSavedData('man') and $output) {
         /* Create source file */
         if ($this->registry->dbFunctions()->getDriverType() == 'mysql') {
             $sourceFile = IPSSetUp::createSqlSourceFile($output, '30001', 'pf');
         }
         $this->_output = $this->registry->output->template()->upgrade_manual_queries($output, $sourceFile);
     }
     /* Next Page */
     $this->request['workact'] = 'permsAndBbcode';
 }
예제 #2
0
 /**
  * Run SQL files
  * 
  * @param	int
  * @return	@e void
  */
 public function upgradeSql($id = 1)
 {
     $cnt = 0;
     $file = '_updates_' . $id . '.php';
     $output = "";
     $path = IPSLib::getAppDir('core') . '/setup/versions/upg_32000/' . strtolower($this->registry->dbFunctions()->getDriverType()) . $file;
     $prefix = $this->registry->dbFunctions()->getPrefix();
     $sourceFile = '';
     $options = IPSSetUp::getSavedData('custom_options');
     $postTable = $options['core'][32000]['manualPostsTableQuery'];
     if (is_file($path)) {
         $SQL = array();
         require $path;
         /*noLibHook*/
         /* Set DB driver to return any errors */
         $this->DB->return_die = 1;
         foreach ($SQL as $query) {
             $this->DB->allow_sub_select = 1;
             $this->DB->error = '';
             $query = str_replace("<%time%>", time(), $query);
             if ($this->settings['mysql_tbl_type']) {
                 if (preg_match("/^create table(.+?)/i", $query)) {
                     $query = preg_replace("/^(.+?)\\);\$/is", "\\1) ENGINE={$this->settings['mysql_tbl_type']};", $query);
                 }
             }
             /* Need to tack on a prefix? */
             if ($prefix) {
                 $query = IPSSetUp::addPrefixToQuery($query, $prefix);
             }
             if (IPSSetUp::getSavedData('man') or $id == 6 and $postTable) {
                 $query = trim($query);
                 /* Ensure the last character is a semi-colon */
                 if (substr($query, -1) != ';') {
                     $query .= ';';
                 }
                 $output .= $query . "\n\n";
             } else {
                 $this->DB->query($query);
                 if ($this->DB->error) {
                     $this->registry->output->addError("<br />" . $query . "<br />" . $this->DB->error);
                 } else {
                     $cnt++;
                 }
             }
         }
         $this->registry->output->addMessage("{$cnt} запросов выполнено....");
     }
     /* Next Page */
     if ($id < 6) {
         $nextid = $id + 1;
         $this->request['workact'] = 'sql' . $nextid;
     } else {
         $this->request['workact'] = 'logs';
     }
     if ($output) {
         /* Create source file */
         if ($this->registry->dbFunctions()->getDriverType() == 'mysql') {
             $sourceFile = IPSSetUp::createSqlSourceFile($output, '32000', $id);
         }
         $this->_output = $this->registry->output->template()->upgrade_manual_queries($output, $sourceFile);
     }
 }
예제 #3
0
 function upgrade_sql($id = 1)
 {
     $man = 0;
     // Manual upgrade ? intval( $this->request['man'] );
     $cnt = 0;
     $SQL = array();
     $file = '_updates_' . $id . '.php';
     $output = "";
     $path = IPSLib::getAppDir('core') . '/setup/versions/upg_21003/' . strtolower($this->registry->dbFunctions()->getDriverType()) . $file;
     $prefix = $this->registry->dbFunctions()->getPrefix();
     if (is_file($path)) {
         require $path;
         /*noLibHook*/
         $this->error = array();
         $this->sqlcount = 0;
         $output = "";
         $this->DB->return_die = 1;
         foreach ($SQL as $query) {
             $this->DB->allow_sub_select = 1;
             $this->DB->error = '';
             $query = str_replace("<%time%>", time(), $query);
             /* Need to tack on a prefix? */
             if ($prefix) {
                 $query = IPSSetUp::addPrefixToQuery($query, $prefix);
             }
             if (IPSSetUp::getSavedData('man')) {
                 $output .= preg_replace("/\\s{1,}/", " ", $query) . "\n\n";
             } else {
                 if (!$query) {
                     continue;
                 }
                 $this->DB->query($query);
                 if ($this->DB->error) {
                     $this->registry->output->addError($query . "<br /><br />" . $this->DB->error);
                 } else {
                     $this->sqlcount++;
                 }
             }
         }
         $this->registry->output->addMessage("{$this->sqlcount} queries ran....");
     }
     //--------------------------------
     // Next page...
     //--------------------------------
     $this->request['st'] = 0;
     if ($id != 4) {
         $nextid = $id + 1;
         $this->request['workact'] = 'sql' . $nextid;
     } else {
         $this->request['workact'] = 'polls';
     }
     if (IPSSetUp::getSavedData('man') and $output) {
         /* Create source file */
         if ($this->registry->dbFunctions()->getDriverType() == 'mysql') {
             $sourceFile = IPSSetUp::createSqlSourceFile($output, '21003', $id);
         }
         $this->_output = $this->registry->output->template()->upgrade_manual_queries($output, $sourceFile);
     }
 }
예제 #4
0
 /**
  * Installs SQL schematic
  *
  * @return void
  */
 public function install_sql()
 {
     /* Lets grab that SQL! */
     $SQL = array();
     $count = 0;
     $output = '';
     $message = array();
     $sourceFile = '';
     $warnings = 0;
     /* Reset Errors */
     $this->_resetErrors();
     /* SQL */
     $file = IPSLib::getAppDir($this->_currentApp) . '/setup/versions/upg_' . $this->_uipLong . '/' . $this->_dbDriver . '_updates.php';
     /* Get file */
     if (is_file($file)) {
         require $file;
         /*noLibHook*/
         if (is_array($SQL) and count($SQL) > 0) {
             /* Loop */
             foreach ($SQL as $q) {
                 /* Set DB driver to return any errors */
                 $this->DB->return_die = 1;
                 $this->DB->allow_sub_select = 1;
                 $this->DB->error = '';
                 $q = str_replace("<%time%>", time(), $q);
                 $q = IPSSetUp::addPrefixToQuery($q, $this->registry->dbFunctions()->getPrefix());
                 if ($this->settings['mysql_tbl_type']) {
                     if (preg_match("/^create table(.+?)/i", $q)) {
                         $q = preg_replace("/^(.+?)\\);\$/is", "\\1) ENGINE={$this->settings['mysql_tbl_type']};", $q);
                     }
                 }
                 if (IPSSetUp::getSavedData('man')) {
                     $q = trim($q);
                     /* Ensure the last character is a semi-colon */
                     if (substr($q, -1) != ';') {
                         $q .= ';';
                     }
                     $output .= $q . "\n\n";
                 } else {
                     $this->DB->query($q);
                     if ($this->DB->error) {
                         /* Log but do not fail on certain error logs */
                         $msg = $this->DB->error;
                         if (preg_match("#table.*already exists#i", $msg) or preg_match("#Duplicate column name#i", $msg) or preg_match("#Duplicate entry.*for#i", $msg)) {
                             $warnings++;
                             IPSSetUp::addLogMessage("SQL Error: " . $q . "\n" . $msg, $this->_uipLong, $this->_currentApp);
                         } else {
                             $this->registry->output->addError(nl2br($q) . "<br /><br />" . $this->DB->error);
                         }
                     } else {
                         $count++;
                     }
                 }
             }
             $message[] = $count . " запросов выполнено ({$warnings} не критичных ошибок)";
         }
     } else {
         /* No SQL */
         //$this->registry->output->addMessage("Нет SQL запросов для выполнения.");
         $this->install_appclass();
         return;
     }
     /* Got queries to show? */
     if (IPSSetUp::getSavedData('man') and $output) {
         /* Create source file */
         if ($this->_dbDriver == 'mysql') {
             $sourceFile = IPSSetUp::createSqlSourceFile($output, $this->_uipLong);
         }
         $this->registry->output->setTitle("Обновление: База Данных");
         $this->registry->output->setNextAction('upgrade&do=appclass');
         $this->registry->output->addContent($this->registry->output->template()->upgrade_manual_queries($output, $sourceFile));
         $this->registry->output->sendOutput();
     } else {
         //-----------------------------------------
         // Next...
         //-----------------------------------------
         $output = (is_array($message) and count($message)) ? $message : array(0 => "Обновление Базы Данных завершено");
         $this->_finishStep($output, "Обновление: База Данных", 'upgrade&do=appclass');
     }
 }
예제 #5
0
 /**
  * Fix posts table
  * 
  * @param	int
  * @return	@e void
  */
 public function updatePostsTable()
 {
     $doManual = $options['core'][33000]['manualPostsTableQuery'];
     $prefix = $this->registry->dbFunctions()->getPrefix();
     $output = '';
     if ($doManual && !$this->DB->checkForField('post_field_int', 'posts')) {
         foreach (array('ALTER TABLE posts ADD post_field_int INT(10) DEFAULT 0', 'ALTER TABLE posts ADD post_field_t1 TEXT NULL DEFAULT NULL', 'ALTER TABLE posts ADD post_field_t2 TEXT NULL DEFAULT NULL') as $query) {
             $query = trim($query);
             /* Need to tack on a prefix? */
             if ($prefix) {
                 $query = IPSSetUp::addPrefixToQuery($query, $prefix);
             }
             /* Ensure the last character is a semi-colon */
             if (substr($query, -1) != ';') {
                 $query .= ';';
             }
             $output .= $query . "\n\n";
         }
     } else {
         if (!$this->DB->checkForField('post_field_int', 'posts')) {
             $this->DB->addField('posts', 'post_field_int', 'INT(10)', '0');
         }
         if (!$this->DB->checkForField('post_field_t1', 'posts')) {
             $this->DB->addField('posts', 'post_field_t1', 'TEXT');
         }
         if (!$this->DB->checkForField('post_field_t2', 'posts')) {
             $this->DB->addField('posts', 'post_field_t2', 'TEXT');
         }
     }
     if ($output) {
         /* Create source file */
         if ($this->registry->dbFunctions()->getDriverType() == 'mysql') {
             $sourceFile = IPSSetUp::createSqlSourceFile($output, '33000', 'posts');
         }
         $this->_output = $this->registry->output->template()->upgrade_manual_queries($output, $sourceFile);
     }
     $this->registry->output->addMessage("Posts table updated");
     $this->request['workact'] = 'ban';
 }
 /**
  * Installs SQL schematic
  *
  * @return void
  */
 public function install_sql()
 {
     /* Lets grab that SQL! */
     $SQL = array();
     $cnt = 0;
     $output = '';
     $message = array();
     $sourceFile = '';
     /* Reset Errors */
     $this->_resetErrors();
     /* SQL */
     $file = IPSLib::getAppDir($this->_currentApp) . '/setup/versions/upg_' . $this->_uipLong . '/' . $this->_dbDriver . '_updates.php';
     /* Get file */
     if (file_exists($file)) {
         require $file;
         if (is_array($SQL) and count($SQL) > 0) {
             /* Loop */
             foreach ($SQL as $q) {
                 /* Set DB driver to return any errors */
                 $this->DB->return_die = 1;
                 $this->DB->allow_sub_select = 1;
                 $this->DB->error = '';
                 $q = str_replace("<%time%>", time(), $q);
                 $q = IPSSetUp::addPrefixToQuery($q, $this->registry->dbFunctions()->getPrefix());
                 if ($this->settings['mysql_tbl_type']) {
                     if (preg_match("/^create table(.+?)/i", $q)) {
                         $q = preg_replace("/^(.+?)\\);\$/is", "\\1) TYPE={$this->settings['mysql_tbl_type']};", $q);
                     }
                 }
                 if (IPSSetUp::getSavedData('man')) {
                     $q = trim($q);
                     /* Ensure the last character is a semi-colon */
                     if (substr($q, -1) != ';') {
                         $q .= ';';
                     }
                     $output .= $q . "\n\n";
                 } else {
                     $this->DB->query($q);
                     if ($this->DB->error) {
                         $this->registry->output->addError(nl2br($q) . "<br /><br />" . $this->DB->error);
                     } else {
                         $count++;
                     }
                 }
             }
             $message[] = $count . " queries run...";
         }
     } else {
         /* No SQL */
         $this->registry->output->addMessage("No native SQL to run....");
         $this->install_appclass();
         return;
     }
     /* Got queries to show? */
     if (IPSSetUp::getSavedData('man') and $output) {
         /* Create source file */
         if ($this->_dbDriver == 'mysql') {
             $sourceFile = IPSSetUp::createSqlSourceFile($output, $this->_uipLong);
         }
         $this->registry->output->setTitle("Upgrade: SQL");
         $this->registry->output->setNextAction('upgrade&do=appclass');
         $this->registry->output->addContent($this->registry->output->template()->upgrade_manual_queries($output, $sourceFile));
         $this->registry->output->sendOutput();
     } else {
         //-----------------------------------------
         // Next...
         //-----------------------------------------
         $output = (is_array($message) and count($message)) ? $message : array(0 => "SQL complete");
         $this->_finishStep($output, "Upgrade: SQL", 'upgrade&do=appclass');
     }
 }