X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=admin%2Finst_upgrade.php;h=399cf8185667945426183cd0b01b8b8e3482399a;hb=5089910120614dfb8b76a0271b43739f90f38b01;hp=786e889a2f32037c1eb29c52a3adad8b4abc280b;hpb=1b163e169c22e3b38d3bb766ceee8fa2b08aa084;p=fa-stable.git diff --git a/admin/inst_upgrade.php b/admin/inst_upgrade.php index 786e889a..399cf818 100644 --- a/admin/inst_upgrade.php +++ b/admin/inst_upgrade.php @@ -20,39 +20,6 @@ include_once($path_to_root . "/admin/db/company_db.inc"); include_once($path_to_root . "/admin/db/maintenance_db.inc"); include_once($path_to_root . "/includes/ui.inc"); -// -// Checks $field existence in $table with given field $properties -// $table - table name without prefix -// $field - optional field name -// $properties - optional properties of field defined by MySQL: -// 'Type', 'Null', 'Key', 'Default', 'Extra' -// -function check_table($pref, $table, $field=null, $properties=null) -{ - $tables = @db_query("SHOW TABLES LIKE '".$pref.$table."'"); - if (!db_num_rows($tables)) - return 1; // no such table or error - - $fields = @db_query("SHOW COLUMNS FROM ".$pref.$table); - if (!isset($field)) - return 0; // table exists - - while( $row = db_fetch_assoc($fields)) - { - if ($row['Field'] == $field) - { - if (!isset($properties)) - return 0; - foreach($properties as $property => $value) - { - if ($row[$property] != $value) - return 3; // failed type/length check - } - return 0; // property check ok. - } - } - return 2; // field not found -} // // Creates table of installer objects sorted by version. // @@ -69,7 +36,7 @@ function get_installers() while(false !== ($fname = readdir($datadir))) { // check all php files but index.php if (!is_dir($patchdir . $fname) && ($fname != 'index.php') - && stristr($fname, '.php') != false) + && stristr($fname, '.php') != false && $fname[0] != '.') { unset($install); include_once($patchdir . $fname); @@ -110,7 +77,7 @@ function upgrade_step($index, $conn) $ret &= $inst->install($pref, $force); - error_log(_("Database upgarade finished.")); + error_log(_("Database upgrade finished.")); } else if ($state!==true) { @@ -121,26 +88,16 @@ function upgrade_step($index, $conn) return $ret; } -function db_open($conn) -{ - $db = mysql_connect($conn["host"] ,$conn["dbuser"], $conn["dbpassword"]); - if (!$db) - return false; - if (!mysql_select_db($conn["dbname"], $db)) - return false; - return $db; -} - $installers = get_installers(); if (get_post('Upgrade')) { $ret = true; - foreach ($db_connections as $conn) + foreach ($db_connections as $comp => $conn) { // connect to database - if (!($db = db_open($conn))) + if (!(set_global_connection($comp))) { display_error(_("Cannot connect to database for company") ." '".$conn['name']."'"); @@ -162,6 +119,7 @@ if (get_post('Upgrade')) // db_close($conn); ? if (!$ret) break; } + set_global_connection(); if($ret) { // re-read the prefs global $path_to_root; @@ -171,6 +129,7 @@ if (get_post('Upgrade')) display_notification(_('All companies data has been successfully updated')); } unset($_SESSION['SysPrefs']); // re-read system setup + $_SESSION['SysPrefs'] = new sys_prefs(); $Ajax->activate('_page_body'); }