Index: trunk/admin/install/install_lib.php =================================================================== diff -u -r383 -r415 --- trunk/admin/install/install_lib.php (.../install_lib.php) (revision 383) +++ trunk/admin/install/install_lib.php (.../install_lib.php) (revision 415) @@ -13,25 +13,48 @@ return true; } +function VersionSort($a, $b) +{ + if ($a == $b) { + return 0; + } + else { + $tmp_a = str_replace("inportal_upgrade_v", "", $a); + $tmp_a = str_replace(".sql", "", $a); + + $tmp_b = str_replace("inportal_upgrade_v", "", $b); + $tmp_b = str_replace(".sql", "", $b); + + return (ConvertVersion($a) < ConvertVersion($b)) ? -1 : 1; + } +} + function GetMaxPortalVersion($admindirname) { $dir = @dir($admindirname.'/install/upgrades'); + $upgrades_arr = Array(); + $version = ''; while ($file = $dir->read()) { - if ($file != "." && $file != ".." && !is_dir($admindirname.$file)) - { + if ($file != "." && $file != ".." && !is_dir($dir_name.$file)) { if (strstr($file, 'inportal_upgrade_v')) { - $file = str_replace("inportal_upgrade_v", "", $file); - $file = str_replace(".sql", "", $file); - - if (ConvertVersion($file) > ConvertVersion($version)) { - $version = $file; - } + $upgrades_arr[] = $file; } - } + } } + usort($upgrades_arr, "VersionSort"); + + foreach($upgrades_arr as $file) { + $file_tmp = str_replace("inportal_upgrade_v", "", $file); + $file_tmp = str_replace(".sql", "", $file_tmp); + + if (ConvertVersion($file_tmp) > ConvertVersion($current_version)) { + $version = $file_tmp; + } + } + return $version; } @@ -121,7 +144,7 @@ $sql = ereg_replace($what, $replace, $sql); $what = "DROP TABLE "; - $replace = "DROP TABLE ".$g_TablePrefix; + $replace = "DROP TABLE IF EXISTS ".$g_TablePrefix; $sql = ereg_replace($what, $replace, $sql); $what = "INSERT INTO "; @@ -280,8 +303,9 @@ if(count($AllSql)>0) RunSQLText($ado,$AllSql); return (int)$FileOffset; -} +} + function inst_keyED($txt,$encrypt_key) { $encrypt_key = md5($encrypt_key);