⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 onionupgradescript.class.php

📁 ProjectPier 源码 很好的项目管理程序
💻 PHP
📖 第 1 页 / 共 2 页
字号:
      $this->printMessage('ProjectPier has been upgraded. You are now running ProjectPier 0.7. Enjoy!');    } // execute        /**    * Import message comments    *    * @param void    * @return boolean    */    private function importMessageComments() {      $this->printMessage('Starting to import comments...');            if ($result = mysql_query('SELECT * FROM `' . TABLE_PREFIX . 'message_comments', $this->database_connection)) {        mysql_query('BEGIN WORK', $this->database_connection);                $counter = 0;        while ($row = mysql_fetch_assoc($result)) {          $sql = sprintf("INSERT INTO `%scomments` (`rel_object_id`, `rel_object_manager`, `text`, `is_private`, `created_on`, `created_by_id`, `updated_on`, `updated_by_id`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",            TABLE_PREFIX, $row['message_id'], 'ProjectMessages', mysql_real_escape_string($row['text']), $row['is_private'], $row['created_on'], $row['created_by_id'], $row['updated_on'], $row['updated_by_id']);          if (!mysql_query($sql, $this->database_connection)) {            mysql_query('ROLLBACK', $this->database_connection);            $this->printMessage('Failed to move message comments. MySQL said: ' . mysql_error(), true);            return false;          } // if          $counter++;        } // while                mysql_query('COMMIT');        $this->printMessage("$counter message comments moved");                if (mysql_query('DROP TABLE IF EXISTS `' . TABLE_PREFIX . 'message_comments', $this->database_connection)) {          $this->printMessage('`' . TABLE_PREFIX . 'message_comments` table dropped');        } else {          $this->printMessage('Warning: Failed to drop old message comments table. MySQL said: ' . mysql_error(), true);        }      } // if            return true;    } // importMessageComments        /**    * This function will import project documents into the new files section and preserve message / file relations    *    * @param void    * @return boolean    */    function importProjectDocuments() {      $this->printMessage('Starting to import documents...');            if ($result = mysql_query('SELECT * FROM `' . TABLE_PREFIX . 'project_documents`')) {        mysql_query('BEGIN WORK', $this->database_connection);                $counter = 0;        while ($row = mysql_fetch_assoc($result)) {          $sql = sprintf("INSERT INTO `%sproject_files` (`project_id`, `filename`, `description`, `is_private`, `is_visible`, `created_on`, `created_by_id`, `updated_on`, `updated_by_id`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",            TABLE_PREFIX, $row['project_id'], mysql_real_escape_string($row['filename']), mysql_real_escape_string($row['description']), $row['is_private'], 1, $row['created_on'], $row['created_by_id'], $row['updated_on'], $row['updated_by_id']);                    if (!mysql_query($sql, $this->database_connection)) {            mysql_query('ROLLBACK', $this->database_connection);            $this->printMessage('Failed to move project documents. MySQL said: ' . mysql_error(), true);            return false;          } // if                    $file_id = mysql_insert_id($this->database_connection);          $file_type_id = 0;          $sql = sprintf("SELECT `id` FROM `%sfile_types` WHERE `extension` = '%s'", TABLE_PREFIX, mysql_real_escape_string(strtolower(get_file_extension($row['filename']))));          if ($file_type_result = mysql_query($sql)) {            if ($file_type_row = mysql_fetch_assoc($file_type_result)) {              $file_type_id = (integer) $file_type_row['id'];            } // if          } // if                    $repository_id = '';          $file_path = INSTALLATION_PATH . '/public/files/project_documents/' . $row['project_id'] . '/' . $row['filename'];          if (is_file($file_path)) {            do {              $repository_id = sha1(uniqid(rand(), true));              $repository_entry_exists = false;              if ($check_repository_id_result = mysql_query(sprintf(("SELECT COUNT (`id`) AS 'row_count' FROM `%sfile_repo` WHERE `id` = '%s'"), TABLE_PREFIX, $repository_id))) {                if ($check_repository_id_row = mysql_fetch_assoc($check_repository_id_result)) {                  $repository_entry_exists = (boolean) $check_repository_id_row['row_count'];                } // if              } // if            } while ($repository_entry_exists);                        $sql = sprintf("INSERT INTO `%sfile_repo` (`id`, `content`) VALUES ('%s', '%s')",              TABLE_PREFIX, $repository_id, mysql_real_escape_string(file_get_contents($file_path), $this->database_connection)            ); // sprintf            if (!mysql_query($sql, $this->database_connection)) {              mysql_query('ROLLBACK', $this->database_connection);              $this->printMessage('Failed to insert file content into file repository. MySQL said: ' . mysql_error(), true);              return false;            } // if          } // if                    $sql = sprintf("INSERT INTO `%sproject_file_revisions` (`file_id`, `file_type_id`, `repository_id`, `revision_number`, `type_string`, `filesize`, `created_on`, `created_by_id`, `updated_on`, `updated_by_id`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",             TABLE_PREFIX, $file_id, $file_type_id, $repository_id, 1, $row['type'], $row['size'], $row['created_on'], $row['created_by_id'], $row['updated_on'], $row['updated_by_id']          ); // sprintf                    if (!mysql_query($sql, $this->database_connection)) {            mysql_query('ROLLBACK', $this->database_connection);            $this->printMessage('Failed to move project documents. MySQL said: ' . mysql_error(), true);            return false;          } // if                    // Now, relations with messages...          if ($related_messages_result = mysql_query(sprintf("SELECT * FROM `%smessage_documents` WHERE `document_id` = '%s'", TABLE_PREFIX, $row['id']), $this->database_connection)) {            while ($related_messages_row = mysql_fetch_assoc($related_messages_result)) {              $sql = sprintf("INSERT INTO `%sattached_files` (`rel_object_manager`, `rel_object_id`, `file_id`, `created_on`, `created_by_id`) VALUES ('%s', '%s', '%s', '%s', '%s')",                TABLE_PREFIX, 'ProjectMessages', $related_messages_row['message_id'], $file_id, $row['created_on'], $row['created_by_id']              ); // sprintf              if (!mysql_query($sql, $this->database_connection)) {                mysql_query('ROLLBACK', $this->database_connection);                $this->printMessage('Failed to add message - file relation. MySQL said: ' . mysql_error(), true);                return false;              } // if            } // while          } // if                    $counter++;        } // while                mysql_query('COMMIT');        $this->printMessage("$counter documents moved");                // Drop tables        if (mysql_query('DROP TABLE IF EXISTS `' . TABLE_PREFIX . 'project_documents', $this->database_connection)) {          $this->printMessage('`' . TABLE_PREFIX . 'project_documents` table dropped');        } else {          $this->printMessage('Warning: Failed to drop old documents table. MySQL said: ' . mysql_error(), true);        } // if                if (mysql_query('DROP TABLE IF EXISTS `' . TABLE_PREFIX . 'document_downloads', $this->database_connection)) {          $this->printMessage('`' . TABLE_PREFIX . 'document_downloads` table dropped');        } else {          $this->printMessage('Warning: Failed to drop old document downloads table. MySQL said: ' . mysql_error(), true);        } // if                if (mysql_query('DROP TABLE IF EXISTS `' . TABLE_PREFIX . 'message_documents', $this->database_connection)) {          $this->printMessage('`' . TABLE_PREFIX . 'message_documents` table dropped');        } else {          $this->printMessage('Warning: Failed to drop old message - documents table. MySQL said: ' . mysql_error(), true);        } // if      } // if            return true;    } // importProjectDocuments        /**    * This function will clean up application logs and remove entries related to objects that are removed in 0.7     * (message comments and project documents)    *    * @param void    * @return null    */    function cleanApplicationLogs() {      $this->printMessage('Updating application logs');      mysql_query(sprintf("DELETE FROM `%sapplication_logs` WHERE `rel_object_manager` = '%s'", TABLE_PREFIX, 'MessageComments'));      mysql_query(sprintf("DELETE FROM `%sapplication_logs` WHERE `rel_object_manager` = '%s'", TABLE_PREFIX, 'ProjectDocuments'));      $this->printMessage('Application logs updated');    } // cleanApplicationLogs        /**    * This function will configuration file    *    * @param void    * @return null    */    function fixConfigFile() {      $this->printMessage('Updating configuration file');      $constants = array(        'DB_ADAPTER'           => DB_ADAPTER,        'DB_HOST'              => DB_HOST,        'DB_USER'              => DB_USER,        'DB_PASS'              => DB_PASS,        'DB_NAME'              => DB_NAME,        'DB_PERSIST'           => true,        'TABLE_PREFIX'         => TABLE_PREFIX,        'ROOT_URL'             => ROOT_URL,        'DEFAULT_LOCALIZATION' => DEFAULT_LOCALIZATION,        'DEBUG'                => false,        'PRODUCT_VERSION'      => $this->getVersionTo(),      ); // array      tpl_assign('config_file_constants', $constants);      if (file_put_contents(INSTALLATION_PATH . '/config/config.php', tpl_fetch(get_template_path('config_file')))) {        $this->printMessage('Configuration file updated');        return true;      } else {        $this->printMessage('Failed to update configuration file', true);        return false;      } // if    } // fixConfigFile    } // OnionUpgradeScript?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -