'; $message .= "
"; $message .= "

ERROR

"; $message .= "

".__('The sql file contains a dangerous query').'

'; $message .= ''; fwrite($error_file, $message); fclose($error_file); } else { if (file_exists($dir) && is_dir($dir)) { if (is_readable($dir)) { if (($number > $config['MR'] + 1) || ($number == $config['MR'])) { $message = 'bad_mr_filename'; } else if ($config['MR'] > $number) { if (!file_exists($config['homedir'].'/extras/mr/updated') || !is_dir($config['homedir'].'/extras/mr/updated')) { mkdir($config['homedir'].'/extras/mr/updated'); } $file_dest = $config['homedir']."/extras/mr/updated/$number.sql"; copy($file, $file_dest); $message = 'bad_mr_filename'; } else { $result = db_run_sql_file($file); if ($result) { $update_config = update_config_token('MR', $number); if ($update_config) { $config['MR'] = $number; } if ($config['MR'] == $number) { if (!file_exists($config['homedir'].'/extras/mr/updated') || !is_dir($config['homedir'].'/extras/mr/updated')) { mkdir($config['homedir'].'/extras/mr/updated'); } $file_dest = $config['homedir']."/extras/mr/updated/$number.sql"; copy($file, $file_dest); } } else { $error_file = fopen($config['homedir'].'/extras/mr/error.txt', 'w'); $message = '
'; $message .= "
"; $message .= "

ERROR

"; $message .= "

".__('An error occurred while updating the database schema to the minor release ').$number.'

'; $message .= '
'; fwrite($error_file, $message); fclose($error_file); } } } else { $error_file = fopen($config['homedir'].'/extras/mr/error.txt', 'w'); $message = '
'; $message .= "
"; $message .= "

ERROR

"; $message .= "

".__('The directory ').$dir.__(' should have read permissions in order to update the database schema').'

'; $message .= '
'; fwrite($error_file, $message); fclose($error_file); } } else { $error_file = fopen($config['homedir'].'/extras/mr/error.txt', 'w'); $message = '
'; $message .= "
"; $message .= "

ERROR

"; $message .= "

".__('The directory ').$dir.__(' does not exist').'

'; $message .= '
'; fwrite($error_file, $message); fclose($error_file); } } echo $message; return; } if ($remove_rr) { $numbers = get_parameter('number', 0); foreach ($numbers as $number) { for ($i = 1; $i <= $number; $i++) { $file = $config['homedir']."/extras/mr/$i.sql"; if (file_exists($file)) { unlink($file); } } } return; } if ($remove_rr_extras) { $dir = $config['homedir'].'/extras/mr/'; if (file_exists($dir) && is_dir($dir)) { if (is_readable($dir)) { $files = scandir($dir); // Get all the files from the directory ordered by asc if ($files !== false) { $pattern = '/^\d+\.sql$/'; $sqlfiles = preg_grep($pattern, $files); // Get the name of the correct files $files = null; $pattern = '/\.sql$/'; $replacement = ''; $sqlfiles_num = preg_replace($pattern, $replacement, $sqlfiles); // Get the number of the file foreach ($sqlfiles_num as $num) { $file = $dir."$num.sql"; if (file_exists($file)) { unlink($file); } } } } } return; } }