1
0
Fork 0
MySQLDumper/refresh_dblist.php

65 Zeilen
1,9 KiB
PHP

2015-05-22 11:43:20 +00:00
<?php
/**
* Loads all configuration files and refreshes the database list.
*
* Add configuration file names to array $excludedConfigurationFiles to skip configurations.
*/
error_reporting(E_ALL & ~E_NOTICE);
2015-05-22 11:43:20 +00:00
$verbose = true;
/**
* Build exclude array with configuration files that should be skipped
*/
$excludedConfigurationFiles = array(
2015-05-24 12:23:15 +00:00
//'mysqldumper',
//add more excluded files by adding their name
2015-05-22 11:43:20 +00:00
);
$verbose = true;
2015-05-24 12:23:15 +00:00
if (PHP_SAPI === 'cli' || empty($_SERVER['REMOTE_ADDR'])) {
2015-05-22 11:43:20 +00:00
// called via cli - check verbose param
2015-05-24 12:23:15 +00:00
define('NEWLINE', "\n");
2015-05-22 11:43:20 +00:00
$options = getopt('v::', array('verbose::'));
2015-05-24 12:23:15 +00:00
$verbose = isset($options['verbose']) || isset($options['v']) ? true : false;
} else {
define('NEWLINE', '<br />');
2015-05-22 11:43:20 +00:00
}
date_default_timezone_set('Europe/Berlin');
2015-05-24 12:23:15 +00:00
define('APPLICATION_PATH', __DIR__);
2015-05-22 11:43:20 +00:00
chdir(APPLICATION_PATH);
2015-05-24 12:23:15 +00:00
include(APPLICATION_PATH . '/inc/functions.php');
include(APPLICATION_PATH . '/inc/mysql.php');
include('language/en/lang.php');
2015-05-22 11:43:20 +00:00
// load default configuration
2015-05-24 12:23:15 +00:00
include('work/config/mysqldumper.php');
2015-05-22 11:43:20 +00:00
GetLanguageArray();
$configFiles = get_config_filenames();
foreach ($configFiles as $configFile) {
if (in_array($configFile, $excludedConfigurationFiles)) {
continue;
}
2015-05-24 12:23:15 +00:00
output('Refreshing database list for configuration file: ' . $configFile, $verbose);
2015-05-22 11:43:20 +00:00
$config['config_file'] = $configFile;
2015-05-24 12:23:15 +00:00
include($config['paths']['config'] . $configFile . '.php');
2015-05-22 11:43:20 +00:00
$out = '';
if (isset($config['dbconnection']) && is_resource($config['dbconnection'])) {
((is_null($___mysqli_res = mysqli_close($config['dbconnection']))) ? false : $___mysqli_res);
2015-05-22 11:43:20 +00:00
$config['dbconnection'] = false;
}
SetDefault();
2015-05-24 12:23:15 +00:00
output($out, $verbose);
}
/**
* @param string $message
* @param boolean $verbose
*/
function output($message, $verbose)
{
2015-05-22 11:43:20 +00:00
if ($verbose) {
2015-05-24 12:23:15 +00:00
$message = str_replace("\n", NEWLINE, $message);
echo $message . NEWLINE;
2015-05-22 11:43:20 +00:00
}
}