コード例 #1
0
ファイル: Debug.php プロジェクト: selectSIFISO/.comsite
 public function process()
 {
     global $wpdb;
     if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['ManualDb'])) {
         wpsqt_main_install();
         update_option('wpsqt_manual', '1');
     }
     if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['ResetSession'])) {
         $_SESSION['wpsqt'] = array();
         echo '<pre>';
         var_dump($_SESSION);
         echo '</pre>';
     }
     if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['AllUpgrades'])) {
         print "<h3>Running all upgrades</h3>" . PHP_EOL;
         require_once WPSQT_DIR . 'lib/Wpsqt/Upgrade.php';
         $objUpgrade = new Wpsqt_Upgrade();
         $objUpgrade->getUpdate(0);
         $objUpgrade->execute();
         $needUpdate = 1;
         $oldVersion = '2.4.3';
         require_once WPSQT_DIR . 'lib/Wpsqt/Page/Maintenance/upgradeScript.php';
         echo '<p>You are up to date.</p>';
         exit;
     }
     $this->_pageView = "admin/maintenance/debug.php";
 }
コード例 #2
0
ファイル: upgradeScript.php プロジェクト: uoyknaht/kc
<?php

/**
 * Handles the upgrading of the plugin.
 * 
 * @author Iain Cambridge
 * @copyright Fubra Limited 2010-2011, all rights reserved.
 * @license http://www.gnu.org/licenses/gpl.html GPL v3 
 * @package WPSQT
 */
if ($needUpdate == '1') {
    if (version_compare($oldVersion, '2.1') <= 0) {
        $objUpgrade = new Wpsqt_Upgrade();
        $objUpgrade->getUpdate(0);
        $objUpgrade->execute();
    }
    switch ($oldVersion) {
        case '2.4.3':
            echo '<h4>Updating to 2.5</h4>';
            $wpdb->query("ALTER TABLE `" . WPSQT_TABLE_RESULTS . "` ADD `pass` BOOLEAN NOT NULL");
            echo '<p>Added the `pass` column</p>';
        case '2.5':
            echo '<h4>Updating to 2.5.1</h4>';
            $wpdb->query("ALTER TABLE `" . WPSQT_TABLE_QUIZ_SURVEYS . "` DEFAULT  CHARACTER SET utf8 COLLATE utf8_general_ci");
            $wpdb->query("ALTER TABLE `" . WPSQT_TABLE_SECTIONS . "` DEFAULT  CHARACTER SET utf8 COLLATE utf8_general_ci");
            $wpdb->query("ALTER TABLE `" . WPSQT_TABLE_QUESTIONS . "` DEFAULT  CHARACTER SET utf8 COLLATE utf8_general_ci");
            $wpdb->query("ALTER TABLE `" . WPSQT_TABLE_FORMS . "` DEFAULT  CHARACTER SET utf8 COLLATE utf8_general_ci");
            $wpdb->query("ALTER TABLE `" . WPSQT_TABLE_RESULTS . "` DEFAULT  CHARACTER SET utf8 COLLATE utf8_general_ci");
            $wpdb->query("ALTER TABLE `" . WPSQT_TABLE_SURVEY_CACHE . "` DEFAULT  CHARACTER SET utf8 COLLATE utf8_general_ci");
            $wpdb->query("ALTER TABLE  `" . WPSQT_TABLE_QUIZ_SURVEYS . "` CHANGE  `name`  `name` VARCHAR( 512 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
            echo '<p>Updated all columns to use UTF8</p>';
コード例 #3
0
ファイル: Upgrade.php プロジェクト: selectSIFISO/.comsite
 /**
  * The factory method that returns the upgrade object with all 
  * the queries and objects ready to roll. 
  *
  * @param string $verison
  */
 public static function getUpdate($version)
 {
     global $wpdb;
     $objUpgrade = new Wpsqt_Upgrade();
     $oldQuizTable = $wpdb->get_blog_prefix() . 'wpsqt_quiz';
     $oldQuizSectionTable = $wpdb->get_blog_prefix() . 'wpsqt_quiz_sections';
     $oldFormsTable = $wpdb->get_blog_prefix() . 'wpsqt_forms';
     $oldQuizQuestionTable = $wpdb->get_blog_prefix() . 'wpsqt_questions';
     $oldQuizAnswersTable = $wpdb->get_blog_prefix() . 'wpsqt_answer';
     $oldQuizResultsTable = $wpdb->get_blog_prefix() . 'wpsqt_results';
     $oldSurveyTable = $wpdb->get_blog_prefix() . 'wpsqt_survey';
     $oldSurveyQuestionsTable = $wpdb->get_blog_prefix() . 'wpsqt_questions';
     $oldSurveyAnswersTable = $wpdb->get_blog_prefix() . 'wpsqt_questions_answers';
     $oldSurveyResultsTable = $wpdb->get_blog_prefix() . 'wpsqt_survey_results';
     $oldSurveySingleResultsTable = $wpdb->get_blog_prefix() . 'wpsqt_survey_single_results';
     $oldSurveySectionsTable = $wpdb->get_blog_prefix() . 'wpsqt_survey_sections';
     if (version_compare($version, "1.3") < 0) {
         $objUpgrade->addQuery("ALTER TABLE `" . $oldQuizTable . "` ADD `use_wp_user` VARCHAR( 3 ) NOT NULL DEFAULT 'no'");
         $objUpgrade->addQuery("ALTER TABLE `" . $oldQuizSectionTable . "` ADD `orderby` VARCHAR( 255 ) NOT NULL DEFAULT 'random'");
         $objUpgrade->addQuery("ALTER TABLE `" . $oldSurveySectionsTable . "` ADD `orderby` VARCHAR( 255 ) NOT NULL DEFAULT 'random'");
         $objUpgrade->addQuery("ALTER TABLE `" . $oldQuizTable . "` DROP `type` ");
         // 1.3
         $objUpgrade->addQuery("ALTER TABLE `" . $oldSurveyTable . "` ADD `send_email` VARCHAR( 3 ) NOT NULL DEFAULT 'no'");
         $objUpgrade->addQuery("ALTER TABLE `" . $oldQuizTable . "` ADD `email_template` TEXT NULL DEFAULT NULL");
         $objUpgrade->addQuery("ALTER TABLE `" . $oldSurveyTable . "` ADD `email_template` TEXT NULL DEFAULT NULL");
     }
     if (version_compare($version, "1.3.1") < 0) {
         // 1.3.1
         $objUpgrade->addQuery("ALTER TABLE `" . $oldSurveyQuestionsTable . "` ADD `include_other` VARCHAR( 3 ) NOT NULL DEFAULT 'no'");
     }
     if (version_compare($version, "1.3.2") < 0) {
         // 1.3.2
         $objUpgrade->addQuery("ALTER TABLE `" . $oldQuizTable . "` ADD `display_review` VARCHAR( 3 ) NOT NULL DEFAULT 'no'");
     }
     if (version_compare($version, "1.3.16") < 0) {
         // 1.3.16
         $objUpgrade->addQuery("CREATE TABLE IF NOT EXISTS `" . $oldSurveySingleResultsTable . "` (\n\t\t\t\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t  `surveyid` int(11) NOT NULL,\n\t\t\t\t\t\t  `person` text NOT NULL,\n\t\t\t\t\t\t  `name` varchar(255) NOT NULL,\n\t\t\t\t\t\t  `results` text NOT NULL,\n\t\t\t\t\t\t  `ipaddress` varchar(255) NOT NULL,\n\t\t\t\t\t\t  `user_agent` varchar(255) NOT NULL,\n\t\t\t\t\t\t  PRIMARY KEY (`id`)\n\t\t\t\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=latin1;");
     }
     if (version_compare($version, "1.3.21") < 0) {
         // 1.3.21
         foreach (array($oldQuizTable, $oldQuizSectionTable, $oldQuizQuestionTable, $oldQuizAnswersTable, $oldFormsTable, $oldQuizResultsTable, $oldSurveyTable, $oldSurveySectionsTable, $oldSurveyQuestionsTable, $oldSurveyAnswersTable, $oldSurveyResultsTable, $oldSurveySingleResultsTable) as $tableName) {
             $wpdb->query("ALTER TABLE  `" . $tableName . "` CHARACTER SET utf8 COLLATE utf8_general_ci");
         }
         $objUpgrade->addQuery("ALTER TABLE  `" . $oldQuizQuestionTable . "` \n\t\t\t\t\t\t  CHANGE  `hint`  `hint` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `difficulty`  `difficulty` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `type`  `type` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `text`  `text` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `section_type`  `section_type` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT  'multiple'");
         $objUpgrade->addQuery("ALTER TABLE  `" . $oldQuizAnswersTable . "` \n\t\t\t\t\t\t  CHANGE  `text`  `text` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `correct`  `correct` VARCHAR( 3 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
         $objUpgrade->addQuery("ALTER TABLE  `" . $oldFormsTable . "` \n\t\t\t\t\t\t  CHANGE  `name`  `name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `type`  `type` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `required`  `required` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
         $objUpgrade->addQuery("ALTER TABLE  `" . $oldQuizTable . "` CHANGE  `name`  `name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `display_result`  `display_result` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT  'no',\n\t\t\t\t\t\t  CHANGE  `status`  `status` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT  'disabled',\n\t\t\t\t\t\t  CHANGE  `notification_type`  `notification_type` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT  'none',\n\t\t\t\t\t\t  CHANGE  `take_details`  `take_details` VARCHAR( 3 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT  'no',\n\t\t\t\t\t\t  CHANGE  `use_wp_user`  `use_wp_user` VARCHAR( 3 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT  'no',\n\t\t\t\t\t\t  CHANGE  `email_template`  `email_template` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,\n\t\t\t\t\t\t  CHANGE  `display_review`  `display_review` VARCHAR( 3 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT  'no'");
         $objUpgrade->addQuery("ALTER TABLE  `" . $oldQuizSectionTable . "` \n\t\t\t\t\t\t  CHANGE  `name`  `name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `type`  `type` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `difficulty`  `difficulty` VARCHAR( 11 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `orderby`  `orderby` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT  'random'");
         $objUpgrade->addQuery("ALTER TABLE  `" . $oldQuizResultsTable . "` \n\t\t\t\t\t\t  CHANGE  `person`  `person` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,\n\t\t\t\t\t\t  CHANGE  `sections`  `sections` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `status`  `status` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT  'Unviewed',\n\t\t\t\t\t\t  CHANGE  `person_name`  `person_name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `ipaddress`  `ipaddress` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
         $objUpgrade->addQuery("ALTER TABLE  `" . $oldSurveyTable . "` \n\t\t\t\t\t\t  CHANGE  `name`  `name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `take_details`  `take_details` VARCHAR( 11 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `status`  `status` VARCHAR( 11 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `send_email`  `send_email` VARCHAR( 3 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT  'no',\n\t\t\t\t\t\t  CHANGE  `email_template`  `email_template` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
         $objUpgrade->addQuery("ALTER TABLE  `" . $oldSurveyQuestionsTable . "` CHANGE  `text`  `text` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `type`  `type` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `include_other`  `include_other` VARCHAR( 3 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT  'no'");
         $objUpgrade->addQuery("ALTER TABLE  `" . $oldSurveyAnswersTable . "` \n\t\t\t\t\t\t  CHANGE  `text`  `text` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
         $objUpgrade->addQuery("ALTER TABLE  `" . $oldSurveyResultsTable . "` \n\t\t\t\t\t\t  CHANGE  `other`  `other` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `type`  `type` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT  'multiple'");
         $objUpgrade->addQuery("ALTER TABLE  `" . $oldSurveySectionsTable . "` \n\t\t\t\t\t\t\t\t   CHANGE  `name`  `name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t\t\t   CHANGE  `type`  `type` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t\t\t   CHANGE  `orderby`  `orderby` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
         $objUpgrade->addQuery("ALTER TABLE  `" . $oldSurveySingleResultsTable . "` \n\t\t\t\t\t\t  CHANGE  `person`  `person` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `name`  `name` VARCHAR( 255 ) CHARACTER SET ucs2 COLLATE ucs2_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `results`  `results` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `ipaddress`  `ipaddress` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n\t\t\t\t\t\t  CHANGE  `user_agent`  `user_agent` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
     }
     if (version_compare($version, "1.3.22") < 0) {
         // 1.3.22
         $wpdb->query("ALTER TABLE `" . $oldQuizResultsTable . "` CHANGE `sections` `sections` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
     }
     if (version_compare($version, "1.3.23") < 0) {
         // 1.3.23
         $wpdb->query("ALTER TABLE `" . $oldQuizTable . "` ADD `email_wp_user` VARCHAR( 3 ) NOT NULL DEFAULT 'no'");
     }
     if (version_compare($version, "1.3.24") < 0) {
         $wpdb->query("ALTER TABLE `" . $oldQuizTable . "` CHANGE  `additional` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
     }
     if (version_compare($version, "1.3.27") < 0) {
         $wpdb->query("ALTER TABLE  `" . $oldQuizTable . "` ADD  `limit_one` VARCHAR( 255 ) NULL DEFAULT NULL");
     }
     if (version_compare($version, '2.0.0') < 0) {
         $objUpdate = Wpsqt_Core::getObject('Wpsqt_Upgrade_1322');
         $objUpgrade->addObject($objUpdate, 'Upgraded to 2.0');
     }
     if (version_compare($version, '2.0.0.3') < 0) {
         $objUpgrade->addQuery("ALTER TABLE  `" . WPSQT_TABLE_RESULTS . "` ADD  `score` INT NULL , ADD  `total` INT  NULL , ADD  `percentage` INT NULL", "Added scores columns to results");
     }
     apply_filters('wpsqt_upgrade_object', $objUpgrade, $version);
     return $objUpgrade;
 }