📄 class.installer_version_manager.php
字号:
<?php
/**
* Version Manager Class
*
* This class is used during the installation and upgrade processes *
* @package Installer
* @access private
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: class.installer_version_manager.php 3716 2006-06-05 22:29:29Z drbyte $
*/
/*////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// HOW TO UPDATE FOR NEW RELEASES:
//// a. in function zen_database() below, set the $this->latest_version appropriately
//// b. in function check_check_all_versions(), update:
//// i) add a line to call a new check_versionXXXX() function
//// ii) add another IF statement to set the displayed version text ($retVal)
//// c. add a new check_versionXXXX() function to the end of the class (BEFORE the closing } in the file)
////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
class versionManager extends base{
var $latest_version, $found_version, $zdb_configuration_table_found;
function versionManager() {
/**
* The version that this edition of the installer is designed to support
*/
$this->latest_version = '1.3.0.2';
/**
* Check to see if the configuration table can be found...thus validating the installation, in part.
*/
$this->zdb_configuration_table_found = $this->check_configuration_table();
/**
* Check to see which versions are successfully detected
*/
$this->found_version = $this->check_check_all_versions();
}
function check_configuration_table() {
global $db_test;
// if (!defined('ZC_UPG_DEBUG')) define('ZC_UPG_DEBUG',false);
// Check to see if any Zen Cart tables exist
$tables = $db_test->Execute("SHOW TABLES like '".DB_PREFIX."configuration'");
if (ZC_UPG_DEBUG==true) echo 'ZEN-Configuration (should be 1) = '. $tables->RecordCount() .'<br>';
if ($tables->RecordCount() > 0) {
return true;
}
}
function check_check_all_versions() {
if (!$this->zdb_configuration_table_found) return false;
// $this->version103 = $this->check_version_103();
// $this->version104 = $this->check_version_104();
$this->version110 = $this->check_version_110();
$this->version111 = $this->check_version_111();
$this->version112 = $this->check_version_112();
// $this->version113 = $this->check_version_113(); // there were no db changes for 1.1.3
$this->version114 = $this->check_version_114();
$this->version1141 = $this->check_version_1141();
$this->version120 = $this->check_version_120();
$this->version121 = $this->check_version_121();
$this->version122 = $this->check_version_122();
$this->version123 = $this->check_version_123();
$this->version124 = $this->check_version_124();
$this->delete_bad_1_2_4_index_key();
$this->version125 = $this->check_version_125();
$this->version126 = $this->check_version_126();
$this->version127 = $this->check_version_127();
$this->version130 = $this->check_version_130();
$this->version1301 = $this->check_version_1301();
$this->version1302 = $this->check_version_1302();
// if ($this->version103 == true) $retVal = '1.0.3';
// if ($this->version104 == true) $retVal = '1.0.4';
if ($this->version110 == true) $retVal = '1.1.0';
if ($this->version111 == true) $retVal = '1.1.1';
if ($this->version112 == true) $retVal = '1.1.2 or 1.1.3';
if ($this->version114 == true) $retVal = '1.1.4';
if ($this->version1141 == true) $retVal = '1.1.4-patch1';
if ($this->version120 == true) $retVal = '1.2.0';
if ($this->version121 == true) $retVal = '1.2.1';
if ($this->version122 == true) $retVal = '1.2.2';
if ($this->version123 == true) $retVal = '1.2.3';
if ($this->version124 == true) $retVal = '1.2.4';
if ($this->version125 == true) $retVal = '1.2.5';
if ($this->version126 == true) $retVal = '1.2.6';
if ($this->version127 == true) $retVal = '1.2.7';
if ($this->version130 == true) $retVal = '1.3.0';
if ($this->version1301 == true) $retVal = '1.3.0.1';
if ($this->version1302 == true) $retVal = '1.3.0.2';
return $retVal;
}
function check_version_110() {
global $db_test;
// first test to see if they have run the 1.1 upgrade script (v1.0.4 to v.1.1.1)
$tables = $db_test->Execute("SHOW TABLES like '" . DB_PREFIX . "files_uploaded'");
if (ZC_UPG_DEBUG==true) echo '104-Table (should be 1) = '. $tables->RecordCount() .'<br>';
if ($tables->RecordCount() > 0) {
return true;
}
} //end of 1.1.0 check
function check_version_111() {
global $db_test;
// test to see if they have run the 1.1 -> 1.1.1 bugfix update
$got_v1_1_1 = false;
$sql = "SELECT count(*) as count FROM " . DB_PREFIX . "configuration WHERE configuration_key = 'CATEGORIES_COUNT_ZERO'";
$result = $db_test->Execute($sql);
if (ZC_UPG_DEBUG==true) echo 'v111-count (should be 1) =' . $result->fields['count'] .'<br>';
if ($result->fields['count'] > '0') {
$got_v1_1_1 = true;
}
return $got_v1_1_1;
} //end of 1.1.1 check
function check_version_112() {
global $db_test;
// test to see if they have run the 1.1.1 -> 1.1.2 update
$ccmodule_installed='false';
$got_v1_1_2 = false;
$sql = "SELECT configuration_value FROM " . DB_PREFIX . "configuration WHERE configuration_key = 'MODULE_PAYMENT_CC_STATUS'";
$result = $db_test->Execute($sql);
if ($result->RecordCount()>0 && $result->fields['configuration_value'] == 'True') { $ccmodule_installed = 'true'; }
$sql = "SELECT count(*) as count FROM " . DB_PREFIX . "configuration WHERE configuration_key = 'MODULE_PAYMENT_CC_STORE_NUMBER'";
$result = $db_test->Execute($sql);
if (ZC_UPG_DEBUG==true) echo 'v112-count=' . $result->fields['count'] .'(0 or 1 is okay)<br>';
if ($result->fields['count'] < 1 && $ccmodule_installed=='true') {
$got_v1_1_2 = false;
} else {
$got_v1_1_2 = true;
$zdb_ver = '1.1.2 or 1.1.3';
}
return $got_v1_1_2;
} //end of 1.1.2 check
function check_version_113(){
// there were no critical SQL changes from v1.1.2 to v1.1.3 -- just to change a default, but such change shouldn't
// be necessary if the installed shop/store is already functional, unless can't get free-shipping for 0-weight to work
if (ZC_UPG_DEBUG==true) echo '113-unknown-no way to determine<br>';
}
function check_version_114(){
global $db_test;
// test to see if they have run the 1.1.2 -> 1.1.4 update
$sql = "show fields from " . DB_PREFIX . "customers_basket_attributes"; // could we use "describe" as well ?
$result = $db_test->Execute($sql);
while (!$result->EOF) {
if (ZC_UPG_DEBUG==true) echo "114-fields (need products_options_sort_order) =" . $result->fields['Field'] . '<br>';
if ($result->fields['Field'] == 'products_options_sort_order') {
if ($result->fields['Type'] == 'text') {
$got_v1_1_4 = true;
}
}
$result->MoveNext();
}
return $got_v1_1_4;
} //end of 1.1.4 check
function check_version_1141() {
global $db_test;
// test to see if they have run the 1.1.4 -> PATCH1 update
$sql = "select configuration_title from " . DB_PREFIX . "configuration where configuration_key='SHIPPING_BOX_WEIGHT'"; // could use "describe" as well ?
$result = $db_test->Execute($sql);
while (!$result->EOF) {
if (ZC_UPG_DEBUG==true) echo "114patch-fields=" . $result->fields['configuration_title'] . '<br>';
if ($result->fields['configuration_title'] == 'Package Tare Small to Medium - added percentage:weight') {
$got_v1_1_4_patch1 = true;
}
$result->MoveNext();
}
return $got_v1_1_4_patch1;
} // end 1.1.4-patch1 check
function check_version_120() {
global $db_test;
// test to see if the v1.1.4->v1.2.0 upgrade has been completed
//1st check for v1.20
$sql = "select configuration_title from " . DB_PREFIX . "configuration where configuration_key='TUTORIAL_STATUS'";
$result = $db_test->Execute($sql);
$got_v1_2_0a = true; // set true -- if value found (but should be deleted), then set to false.
while (!$result->EOF) {
if (ZC_UPG_DEBUG==true) echo "120a-configtitle=" . $result->fields['configuration_title'] . '<br>';
if ($result->fields['configuration_title'] != '') {
$got_v1_2_0a = false;
}
$result->MoveNext();
}
//2nd check for v1.20
$tables = $db_test->Execute("SHOW TABLES like '" . DB_PREFIX . "product_type_layout'");
if (ZC_UPG_DEBUG==true) echo '120b-Table= '. $tables->RecordCount() .'<br>';
if ($tables->RecordCount() > 0) {
$got_v1_2_0b = true;
}
//3rd check for v1.20
$sql = "select configuration_group_title, configuration_group_description from " . DB_PREFIX . "configuration_group WHERE configuration_group_id = '13'";
$result = $db_test->Execute($sql);
while (!$result->EOF) {
if (ZC_UPG_DEBUG==true) echo "120c-cfggroup13=attrb ==" . $result->fields['configuration_group_title'] . '<br>';
if ($result->fields['configuration_group_title'] == 'Attribute Settings') {
$got_v1_2_0c = true;
}
$result->MoveNext();
}
//4th check for v1.20
$sql = "show fields from " . DB_PREFIX . "categories";
$result = $db_test->Execute($sql);
while (!$result->EOF) {
if (ZC_UPG_DEBUG==true) echo "120d-fields=" . $result->fields['Field'] . '<br>';
if ($result->fields['Field'] == 'categories_status') {
if ($result->fields['Type'] == 'tinyint(1)') {
$got_v1_2_0d = true;
}
}
$result->MoveNext();
}
//5th check for v1.20
$sql = "show fields from " . DB_PREFIX . "customers";
$result = $db_test->Execute($sql);
while (!$result->EOF) {
if (ZC_UPG_DEBUG==true) echo "120e-fields=" . $result->fields['Field'] . '<br>';
if ($result->fields['Field'] == 'customers_nick' || $result->fields['Field'] == 'customers_group_pricing' || $result->fields['Field'] == 'customers_email_format') {
$got_v1_2_0e = true;
}
$result->MoveNext();
}
//6th check for v1.20
$sql = "show fields from " . DB_PREFIX . "products";
$result = $db_test->Execute($sql);
while (!$result->EOF) {
if (ZC_UPG_DEBUG==true) echo "120f-fields=" . $result->fields['Field'] . '<br>';
if ($result->fields['Field'] == 'master_categories_id') {
$got_v1_2_0f = true;
}
$result->MoveNext();
}
//7th check for v1.2.0
$tables = $db_test->Execute("SHOW TABLES like '" . DB_PREFIX . "project_version'");
if ($tables->RecordCount() > 0) {
$sql = "SELECT project_version_major, project_version_minor from " . DB_PREFIX . "project_version WHERE project_version_key = 'Zen-Cart Main'";
$result = $db_test->Execute($sql);
if (ZC_UPG_DEBUG==true) echo "120g-project_version=" . $result->fields['project_version_major'] . '.' . $result->fields['project_version_minor'] . '<br>';
if ($result->fields['project_version_major']=='1' && $result->fields['project_version_minor']>='2') $got_v1_2_0g = true;
} //end project_version
// evaluate all 6 checks
if ($got_v1_2_0a && $got_v1_2_0b && $got_v1_2_0c && $got_v1_2_0d && $got_v1_2_0e && $got_v1_2_0f) {
$got_v1_2_0 = true;
if (ZC_UPG_DEBUG==true) echo 'Got 1.2.0<br>';
}
return $got_v1_2_0;
} // end 1.2.0 check
function check_version_121() {
global $db_test;
// test to see if the v1.2.0->v1.2.1 upgrade has been completed
$tables = $db_test->Execute("SHOW TABLES like '" . DB_PREFIX . "project_version'");
if ($tables->RecordCount() > 0) {
//1st check for v1.2.1
$sql = "select configuration_title from " . DB_PREFIX . "configuration where configuration_key='DISPLAY_PRICE_WITH_TAX_ADMIN'";
$result = $db_test->Execute($sql);
if (ZC_UPG_DEBUG==true) echo "121a-configkey_check=" . $result->fields['configuration_title'] . '<br>';
if ($result->RecordCount()>0) $got_v1_2_1a = true;
}
//2nd check for v1.2.1
$sql = "show fields from " . DB_PREFIX . "products_discount_quantity";
$result = $db_test->Execute($sql);
while (!$result->EOF) {
if (ZC_UPG_DEBUG==true) echo "121b-fields-'discount_qty'->FLOAT=" . $result->fields['Field'] . '->' . $result->fields['Type'] . '<br>';
if ($result->fields['Field'] == 'discount_qty') {
if (strtoupper($result->fields['Type']) == 'FLOAT') {
$got_v1_2_1b = true;
}
}
$result->MoveNext();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -