From c64da384ea354a194cfdcbd552340261b5d547d9 Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 20 Apr 2006 19:31:12 +0000 Subject: partial merge -r1173:1174 from branch-1_6 to trunk: new configuration parameter die_on_sql_error (upgrade.php and install/upgrade_*.php not concerned on BSF) partial merge -r1208:1209 from branch-1_6 to trunk (only bug fix on incorrect insertion of complex upgrade identifiers) deletions: upgrade.php and all install/upgrade_*.php because these script are never up to date on BSF. Anyway, they are only required on a stable branch. git-svn-id: http://piwigo.org/svn/trunk@1221 68402e56-0260-453c-a942-63ccdbb3a9ee --- upgrade.php | 213 ------------------------------------------------------------ 1 file changed, 213 deletions(-) delete mode 100644 upgrade.php (limited to 'upgrade.php') diff --git a/upgrade.php b/upgrade.php deleted file mode 100644 index 8871ebc88..000000000 --- a/upgrade.php +++ /dev/null @@ -1,213 +0,0 @@ -'."\n"; -flush(); -// +-----------------------------------------------------------------------+ -// | functions | -// +-----------------------------------------------------------------------+ - -/** - * loads an sql file and executes all queries - * - * Before executing a query, $replaced is... replaced by $replacing. This is - * useful when the SQL file contains generic words. Drop table queries are - * not executed. - * - * @param string filepath - * @param string replaced - * @param string replacing - * @return void - */ -function execute_sqlfile($filepath, $replaced, $replacing) -{ - $sql_lines = file($filepath); - $query = ''; - foreach ($sql_lines as $sql_line) - { - $sql_line = trim($sql_line); - if (preg_match('/(^--|^$)/', $sql_line)) - { - continue; - } - $query.= ' '.$sql_line; - // if we reached the end of query, we execute it and reinitialize the - // variable "query" - if (preg_match('/;$/', $sql_line)) - { - $query = trim($query); - $query = str_replace($replaced, $replacing, $query); - // we don't execute "DROP TABLE" queries - if (!preg_match('/^DROP TABLE/i', $query)) - { - mysql_query($query); - } - $query = ''; - } - } -} -// +-----------------------------------------------------------------------+ -// | template initialization | -// +-----------------------------------------------------------------------+ - -$template = new Template(PHPWG_ROOT_PATH.'template/yoga'); -$template->set_filenames(array('upgrade'=>'upgrade.tpl')); -$template->assign_vars(array('RELEASE'=>PHPWG_VERSION)); - -// +-----------------------------------------------------------------------+ -// | versions upgradable | -// +-----------------------------------------------------------------------+ -$versions = array(); -$path = PHPWG_ROOT_PATH.'install'; -if ($contents = opendir($path)) -{ - while (($node = readdir($contents)) !== false) - { - if (is_file($path.'/'.$node) - and preg_match('/^upgrade_(.*?)\.php$/', $node, $match)) - { - array_push($versions, $match[1]); - } - } -} -natcasesort($versions); -// +-----------------------------------------------------------------------+ -// | upgrade choice | -// +-----------------------------------------------------------------------+ -if (!isset($_GET['version'])) -{ - $template->assign_block_vars('choices', array()); - foreach ($versions as $version) - { - $template->assign_block_vars( - 'choices.choice', - array( - 'URL' => PHPWG_ROOT_PATH.'upgrade.php?version='.$version, - 'VERSION' => $version - )); - } -} -// +-----------------------------------------------------------------------+ -// | upgrade launch | -// +-----------------------------------------------------------------------+ -else -{ - $upgrade_file = $path.'/upgrade_'.$_GET['version'].'.php'; - if (is_file($upgrade_file)) - { - $page['upgrade_start'] = get_moment(); - include($upgrade_file); - $page['upgrade_end'] = get_moment(); - - $template->assign_block_vars( - 'upgrade', - array( - 'VERSION' => $_GET['version'], - 'TOTAL_TIME' => get_elapsed_time($page['upgrade_start'], - $page['upgrade_end']), - 'SQL_TIME' => number_format($page['queries_time'], 3, '.', ' ').' s', - 'NB_QUERIES' => $page['count_queries'] - )); - - if (!isset($infos)) - { - $infos = array(); - } - array_push( - $infos, - '[security] delete files "upgrade.php", "install.php" and "install" -directory' - ); - - array_push( - $infos, - 'in include/mysql.inc.php, remove -
-define(\'PHPWG_IN_UPGRADE\', true);
-
' - ); - - array_push( - $infos, - 'Perform a maintenance check in [Administration>General>Maintenance] -if you encounter any problem.' - ); - - $template->assign_block_vars('upgrade.infos', array()); - - foreach ($infos as $info) - { - $template->assign_block_vars('upgrade.infos.info', - array('CONTENT' => $info)); - } - } - else - { - die('Hacking attempt'); - } -} -// +-----------------------------------------------------------------------+ -// | sending html code | -// +-----------------------------------------------------------------------+ -$template->pparse('upgrade'); -?> \ No newline at end of file -- cgit v1.2.3