1
0
Fork 0

Updated file refresh_dblist.

Dieser Commit ist enthalten in:
dsb 2015-05-24 14:23:15 +02:00
Ursprung a15ca02189
Commit d9b5665f63
2 geänderte Dateien mit 658 neuen und 612 gelöschten Zeilen

Datei anzeigen

@ -1,44 +1,45 @@
<?php <?php
if (!function_exists('get_page_parameter')) include ( './inc/functions_global.php' ); if (!function_exists('get_page_parameter')) {
include('./inc/functions_global.php');
}
if (!function_exists('str_ireplace')) // borrowed from http://www.dscripts.net if (!function_exists('str_ireplace')) // borrowed from http://www.dscripts.net
{ {
function str_ireplace($find, $replace, $string) function str_ireplace($find, $replace, $string)
{ {
if (!is_array($find)) $find=array( if (!is_array($find)) {
$find = array(
$find $find
); );
if (!is_array($replace)) }
{ if (!is_array($replace)) {
if (!is_array($find)) $replace=array( if (!is_array($find)) {
$replace = array(
$replace $replace
); );
else } else {
{
// this will duplicate the string into an array the size of $find // this will duplicate the string into an array the size of $find
$c = count($find); $c = count($find);
$rString = $replace; $rString = $replace;
unset($replace); unset($replace);
for ($i=0; $i < $c; $i++) for ($i = 0; $i < $c; $i++) {
{
$replace[$i] = $rString; $replace[$i] = $rString;
} }
} }
} }
foreach ($find as $fKey=>$fItem) foreach ($find as $fKey => $fItem) {
{
$between = explode(strtolower($fItem), strtolower($string)); $between = explode(strtolower($fItem), strtolower($string));
$pos = 0; $pos = 0;
foreach ($between as $bKey=>$bItem) foreach ($between as $bKey => $bItem) {
{
$between[$bKey] = substr($string, $pos, strlen($bItem)); $between[$bKey] = substr($string, $pos, strlen($bItem));
$pos += strlen($bItem) + strlen($fItem); $pos += strlen($bItem) + strlen($fItem);
} }
$string = implode($replace[$fKey], $between); $string = implode($replace[$fKey], $between);
} }
return ($string); return ($string);
} }
} }
@ -66,28 +67,35 @@ function Help($ToolTip, $Anker, $imgsize=12)
function DeleteFilesM($dir, $pattern = "*.*") function DeleteFilesM($dir, $pattern = "*.*")
{ {
$deleted = array(); $deleted = array();
$pattern=str_replace(array( $pattern = str_replace(
array(
"\*", "\*",
"\?" "\?"
),array( ),
array(
".*", ".*",
"." "."
),preg_quote($pattern)); ),
if (substr($dir,-1) != "/") $dir.="/"; preg_quote($pattern)
if (is_dir($dir)) );
{ if (substr($dir, -1) != "/") {
$dir .= "/";
}
if (is_dir($dir)) {
$d = opendir($dir); $d = opendir($dir);
while ($file=readdir($d)) while ($file = readdir($d)) {
{ if (is_file($dir . $file) && ereg("^" . $pattern . "$", $file)) {
if (is_file($dir . $file) && ereg("^" . $pattern . "$",$file)) if (unlink($dir . $file)) {
{ $deleted[$file] = true;
if (unlink($dir . $file)) $deleted[$file]=true; } else {
else $deleted[$file]=false; $deleted[$file] = false;
}
} }
} }
closedir($d); closedir($d);
return $deleted; return $deleted;
} }
} }
@ -96,34 +104,40 @@ function SetDefault($load_default=false)
{ {
global $config, $databases, $nl, $out, $lang, $preConfig; global $config, $databases, $nl, $out, $lang, $preConfig;
if ($load_default == true) if ($load_default == true) {
{ if (file_exists($config['files']['parameter']) && (is_readable($config['files']['parameter']))) {
if (file_exists($config['files']['parameter']) && ( is_readable($config['files']['parameter']) )) include ( $config['files']['parameter'] ); // alte Config lesen include($config['files']['parameter']);
} // alte Config lesen
} }
$restore_values = array(); $restore_values = array();
$restore_values['cron_dbindex'] = isset($config['cron_dbindex']) ? $config['cron_dbindex'] : -3; $restore_values['cron_dbindex'] = isset($config['cron_dbindex']) ? $config['cron_dbindex'] : -3;
$restore_values['cron_dbpraefix_array']=isset($config['cron_dbpraefix_array']) ? $config['cron_dbpraefix_array'] : ''; $restore_values['cron_dbpraefix_array'] = isset($config['cron_dbpraefix_array']) ? $config['cron_dbpraefix_array']
if ($restore_values['cron_dbindex'] >= 0 && isset($databases['Name'][$config['cron_dbindex']])) // eine bestimmte Db gewaehlt? : '';
if ($restore_values['cron_dbindex'] >= 0
&& isset($databases['Name'][$config['cron_dbindex']])
) // eine bestimmte Db gewaehlt?
{ {
// Ja, Namen merken, um spaeter den Index wieder herzustellen // Ja, Namen merken, um spaeter den Index wieder herzustellen
$restore_values['db_actual_cron'] = $databases['Name'][$config['cron_dbindex']]; $restore_values['db_actual_cron'] = $databases['Name'][$config['cron_dbindex']];
} }
$restore_values['db_actual'] = isset($databases['db_actual']) ? $databases['db_actual'] : ''; $restore_values['db_actual'] = isset($databases['db_actual']) ? $databases['db_actual'] : '';
$old_lang=isset($config['language']) && in_array($config['language'],$lang['languages']) ? $config['language'] : ''; $old_lang
if ($load_default == true) = isset($config['language']) && in_array($config['language'], $lang['languages']) ? $config['language'] : '';
{ if ($load_default == true) {
if (file_exists($config['files']['parameter'])) @unlink($config['files']['parameter']); if (file_exists($config['files']['parameter'])) {
@unlink($config['files']['parameter']);
}
include("./config.php"); include("./config.php");
if (is_array($preConfig)) if (is_array($preConfig)) {
{ foreach ($preConfig as $key => $val) {
foreach ($preConfig as $key=>$val)
{
$config[$key] = $val; $config[$key] = $val;
} }
} }
if ($old_lang != '') $config['language']=$old_lang; if ($old_lang != '') {
$config['language'] = $old_lang;
}
include("./language/" . $config['language'] . "/lang.php"); include("./language/" . $config['language'] . "/lang.php");
} }
@ -131,7 +145,9 @@ function SetDefault($load_default=false)
// Zuordnung nach Namen der Db zwischenspeichern, um Eingaben nicht zu verlieren // Zuordnung nach Namen der Db zwischenspeichern, um Eingaben nicht zu verlieren
if (isset($databases) && isset($databases['Name'])) { if (isset($databases) && isset($databases['Name'])) {
foreach ($databases['Name'] as $k => $v) { foreach ($databases['Name'] as $k => $v) {
if (!isset($oldVals[$k])) $oldVals[$v] = array(); if (!isset($oldVals[$k])) {
$oldVals[$v] = array();
}
$oldVals[$v]['praefix'] = $databases['praefix'][$k]; $oldVals[$v]['praefix'] = $databases['praefix'][$k];
$oldVals[$v]['command_before_dump'] = $databases['command_before_dump'][$k]; $oldVals[$v]['command_before_dump'] = $databases['command_before_dump'][$k];
$oldVals[$v]['command_after_dump'] = $databases['command_after_dump'][$k]; $oldVals[$v]['command_after_dump'] = $databases['command_after_dump'][$k];
@ -146,9 +162,7 @@ function SetDefault($load_default=false)
//DB-Liste holen //DB-Liste holen
MSD_mysql_connect(); MSD_mysql_connect();
$create_statement='CREATE TABLE `mysqldumper_test_abcxyvfgh` (`test` varchar(200) default NULL, `id` bigint(20) unsigned NOT NULL auto_increment,' . 'PRIMARY KEY (`id`)) TYPE=MyISAM;'; $res = mysql_query('SHOW DATABASES', $config['dbconnection']);
$res=mysql_query("SHOW DATABASES",$config['dbconnection']);
WHILE ($row = mysql_fetch_row($res)) { WHILE ($row = mysql_fetch_row($res)) {
$found_dbs[] = $row[0]; $found_dbs[] = $row[0];
} }
@ -157,14 +171,13 @@ function SetDefault($load_default=false)
sort($found_dbs); sort($found_dbs);
// now check each db // now check each db
$a = 0; $a = 0;
for ($i=0; $i<count($found_dbs);$i++) for ($i = 0; $i < count($found_dbs); $i++) {
{
$found_db = $found_dbs[$i]; $found_db = $found_dbs[$i];
// Testverbindung - Tabelle erstellen, nachschauen, ob es geklappt hat und dann wieder löschen
$use = @mysql_select_db($found_db); $use = @mysql_select_db($found_db);
if ($use) if ($use) {
{ if (isset($old_db) && $found_db == $old_db) {
if (isset($old_db) && $found_db == $old_db) $databases['db_selected_index']=$a; $databases['db_selected_index'] = $a;
}
$databases['Name'][$a] = $found_db; $databases['Name'][$a] = $found_db;
$databases['praefix'][$a] = ""; $databases['praefix'][$a] = "";
$databases['command_before_dump'][$a] = ""; $databases['command_before_dump'][$a] = "";
@ -178,13 +191,14 @@ function SetDefault($load_default=false)
$a++; $a++;
} }
} }
if (!isset($databases['db_selected_index'])) if (!isset($databases['db_selected_index'])) {
{
$databases['db_selected_index'] = 0; $databases['db_selected_index'] = 0;
$databases['db_actual'] = $databases['Name'][0]; $databases['db_actual'] = $databases['Name'][0];
} }
WriteParams(1, $restore_values); WriteParams(1, $restore_values);
if ($load_default === true) WriteLog("default settings loaded."); if ($load_default === true) {
WriteLog("default settings loaded.");
}
return $out; return $out;
} }
@ -196,35 +210,26 @@ function WriteParams($as=0, $restore_values=false)
global $config, $databases, $config_dontsave; global $config, $databases, $config_dontsave;
$nl = "\n"; $nl = "\n";
// alte Werte retten // alte Werte retten
if ($as) if ($as) {
{ if (is_array($restore_values)) {
if (is_array($restore_values)) if ($restore_values['cron_dbindex'] < 0) {
{
if ($restore_values['cron_dbindex'] < 0)
{
// Multidump oder "alle Datenbanken" war gewaehlt // Multidump oder "alle Datenbanken" war gewaehlt
$config['cron_dbindex'] = $restore_values['cron_dbindex']; $config['cron_dbindex'] = $restore_values['cron_dbindex'];
} } else {
else
{
//den Index der konkreten Datenbank aus der alten Konfiguration ermitteln //den Index der konkreten Datenbank aus der alten Konfiguration ermitteln
$db_names = array(); $db_names = array();
$db_names = array_flip($databases['Name']); $db_names = array_flip($databases['Name']);
if (isset($db_names[$restore_values['db_actual']])) if (isset($db_names[$restore_values['db_actual']])) {
{
// alte Db existiert noch -> Index uebernehmen // alte Db existiert noch -> Index uebernehmen
$databases['db_actual'] = $restore_values['db_actual']; $databases['db_actual'] = $restore_values['db_actual'];
} } else {
else
$databases['db_actual'] = $databases['Name'][0]; $databases['db_actual'] = $databases['Name'][0];
}
//Cron-Index wiederfinden //Cron-Index wiederfinden
if (isset($db_names[$restore_values['cron_dbindex']])) if (isset($db_names[$restore_values['cron_dbindex']])) {
{
$config['cron_dbindex'] = $db_names[$restore_values['cron_dbindex']]; $config['cron_dbindex'] = $db_names[$restore_values['cron_dbindex']];
} } else {
else
{
// DB wurde zwischenzeitlich geloescht - sicherheitshalber alle DBs sichern // DB wurde zwischenzeitlich geloescht - sicherheitshalber alle DBs sichern
$databases['cron_dbindex'] = -3; $databases['cron_dbindex'] = -3;
} }
@ -234,65 +239,60 @@ function WriteParams($as=0, $restore_values=false)
FillMultiDBArrays(); FillMultiDBArrays();
//Parameter zusammensetzen //Parameter zusammensetzen
$config['multipart_groesse']=$config['multipartgroesse1'] * ( ( $config['multipartgroesse2'] == 1 ) ? 1024 : 1024 * 1024 ); $config['multipart_groesse']
= $config['multipartgroesse1'] * (($config['multipartgroesse2'] == 1) ? 1024 : 1024 * 1024);
$param = $pars_all = '<?php ' . $nl; $param = $pars_all = '<?php ' . $nl;
if (!isset($config['email_maxsize'])) $config['email_maxsize']=$config['email_maxsize1'] * ( ( $config['email_maxsize2'] == 1 ) ? 1024 : 1024 * 1024 ); if (!isset($config['email_maxsize'])) {
if (!isset($config['cron_execution_path'])) $config['cron_execution_path']="msd_cron/"; $config['email_maxsize'] = $config['email_maxsize1'] * (($config['email_maxsize2'] == 1) ? 1024 : 1024 * 1024);
if ($as == 0) $config['paths']['root']=addslashes(Realpfad("./")); }
if (!isset($config['cron_execution_path'])) {
$config['cron_execution_path'] = "msd_cron/";
}
if ($as == 0) {
$config['paths']['root'] = addslashes(Realpfad("./"));
}
$config['files']['parameter'] = $config['paths']['config'] . $config['config_file'] . '.php'; $config['files']['parameter'] = $config['paths']['config'] . $config['config_file'] . '.php';
$config['files']['iconpath'] = './css/' . $config['theme'] . '/icons/'; $config['files']['iconpath'] = './css/' . $config['theme'] . '/icons/';
foreach ($config as $var=>$val) foreach ($config as $var => $val) {
{ if (!in_array($var, $config_dontsave)) {
if (!in_array($var,$config_dontsave)) if (is_array($val)) {
{
if (is_array($val))
{
$pars_all .= '$config[\'' . $var . '\']=array();' . $nl; $pars_all .= '$config[\'' . $var . '\']=array();' . $nl;
foreach ($val as $var2=>$val2) foreach ($val as $var2 => $val2) {
{ if ($config['magic_quotes_gpc'] == 1) {
if ($config['magic_quotes_gpc'] == 1)
{
$val2 = stripslashes($val2); $val2 = stripslashes($val2);
} }
$pars_all.='$config[\'' . $var . '\'][' . ( ( is_int($var2) ) ? $var2 : "'" . $var2 . "'" ) . '] = \'' . my_addslashes($val2) . "';$nl"; $pars_all .= '$config[\'' . $var . '\'][' . ((is_int($var2)) ? $var2 : "'" . $var2 . "'") . '] = \''
. my_addslashes($val2) . "';$nl";
} }
} } else {
else if ($config['magic_quotes_gpc'] == 1) {
{
if ($config['magic_quotes_gpc'] == 1)
{
$val = stripslashes($val); $val = stripslashes($val);
} }
if (!in_array($var,$config_dontsave)) $pars_all.='$config[\'' . $var . '\'] = \'' . my_addslashes($val) . "';$nl"; if (!in_array($var, $config_dontsave)) {
$pars_all .= '$config[\'' . $var . '\'] = \'' . my_addslashes($val) . "';$nl";
} }
} }
} }
foreach ($databases as $var=>$val) }
{ foreach ($databases as $var => $val) {
if (is_array($val)) if (is_array($val)) {
{
$pars_all .= '$databases[\'' . $var . '\']=array();' . $nl; $pars_all .= '$databases[\'' . $var . '\']=array();' . $nl;
foreach ($val as $var2=>$val2) foreach ($val as $var2 => $val2) {
{ if ($config['magic_quotes_gpc'] == 1 || $as == 1) {
if ($config['magic_quotes_gpc'] == 1 || $as == 1) $pars_all
{ .= '$databases[\'' . $var . '\'][' . ((is_int($var2)) ? $var2 : "'" . $var2 . "'") . '] = \''
$pars_all.='$databases[\'' . $var . '\'][' . ( ( is_int($var2) ) ? $var2 : "'" . $var2 . "'" ) . '] = \'' . my_addslashes(stripslashes($val2)) . "';$nl"; . my_addslashes(stripslashes($val2)) . "';$nl";
} } else {
else $pars_all
{ .= '$databases[\'' . $var . '\'][' . ((is_int($var2)) ? $var2 : "'" . $var2 . "'") . '] = \''
$pars_all.='$databases[\'' . $var . '\'][' . ( ( is_int($var2) ) ? $var2 : "'" . $var2 . "'" ) . '] = \'' . my_addslashes($val2) . "';$nl"; . my_addslashes($val2) . "';$nl";
} }
} }
} } else {
else if ($config['magic_quotes_gpc'] == 0 || $as == 1) {
{
if ($config['magic_quotes_gpc'] == 0 || $as == 1)
{
$pars_all .= '$databases[\'' . $var . '\'] = \'' . addslashes($val) . "';$nl"; $pars_all .= '$databases[\'' . $var . '\'] = \'' . addslashes($val) . "';$nl";
} } else {
else
{
$pars_all .= '$databases[\'' . $var . '\'] = \'' . $val . "';$nl"; $pars_all .= '$databases[\'' . $var . '\'] = \'' . $val . "';$nl";
} }
} }
@ -304,16 +304,20 @@ function WriteParams($as=0, $restore_values=false)
//Datei öffnen und schreiben //Datei öffnen und schreiben
$ret = true; $ret = true;
$file = $config['paths']['config'] . $config['config_file'] . '.php'; $file = $config['paths']['config'] . $config['config_file'] . '.php';
if ($fp=fopen($file,"wb")) if ($fp = fopen($file, "wb")) {
{ if (!fwrite($fp, $pars_all)) {
if (!fwrite($fp,$pars_all)) $ret=false;
if (!fclose($fp)) $ret=false;
@chmod($file,0777);
}
else
$ret = false; $ret = false;
}
if (!fclose($fp)) {
$ret = false;
}
@chmod($file, 0777);
} else {
$ret = false;
}
$ret = WriteCronScript($restore_values); $ret = WriteCronScript($restore_values);
return $ret; return $ret;
} }
@ -334,6 +338,7 @@ function escape_specialchars($text)
'\"' '\"'
); );
$text = str_replace($suchen, $ersetzen, $text); $text = str_replace($suchen, $ersetzen, $text);
return $text; return $text;
} }
@ -341,14 +346,22 @@ function escape_specialchars($text)
function my_implode($arr, $mode = 0) // 0=String, 1=intval function my_implode($arr, $mode = 0) // 0=String, 1=intval
{ {
global $nl; global $nl;
if (!is_array($arr)) return false; if (!is_array($arr)) {
foreach ($arr as $key=>$val) return false;
{
if ($mode == 0) $arr[$key]=escape_specialchars($val);
else $arr[$key]=intval($val);
} }
if ($mode == 0) $ret='("' . implode('","',$arr) . '");' . $nl; foreach ($arr as $key => $val) {
else $ret='(' . implode(',',$arr) . ');' . $nl; if ($mode == 0) {
$arr[$key] = escape_specialchars($val);
} else {
$arr[$key] = intval($val);
}
}
if ($mode == 0) {
$ret = '("' . implode('","', $arr) . '");' . $nl;
} else {
$ret = '(' . implode(',', $arr) . ');' . $nl;
}
return $ret; return $ret;
} }
@ -356,10 +369,18 @@ function WriteCronScript($restore_values=false)
{ {
global $nl, $config, $databases, $cron_db_array, $cron_dbpraefix_array, $cron_db_cbd_array, $cron_db_cad_array, $dontBackupDatabases; global $nl, $config, $databases, $cron_db_array, $cron_dbpraefix_array, $cron_db_cbd_array, $cron_db_cad_array, $dontBackupDatabases;
if (!isset($databases['db_selected_index'])) $databases['db_selected_index']=0; if (!isset($databases['db_selected_index'])) {
if (!isset($databases['praefix'][$databases['db_selected_index']])) $databases['praefix'][$databases['db_selected_index']]=""; $databases['db_selected_index'] = 0;
if (!isset($databases['db_actual_cronindex'])) $databases['db_actual_cronindex']=$databases['db_selected_index']; }
if (!isset($config['email_maxsize'])) $config['email_maxsize']=$config['email_maxsize1'] * ( ( $config['email_maxsize2'] == 1 ) ? 1024 : 1024 * 1024 ); if (!isset($databases['praefix'][$databases['db_selected_index']])) {
$databases['praefix'][$databases['db_selected_index']] = "";
}
if (!isset($databases['db_actual_cronindex'])) {
$databases['db_actual_cronindex'] = $databases['db_selected_index'];
}
if (!isset($config['email_maxsize'])) {
$config['email_maxsize'] = $config['email_maxsize1'] * (($config['email_maxsize2'] == 1) ? 1024 : 1024 * 1024);
}
$cron_dbname = $databases['db_actual']; $cron_dbname = $databases['db_actual'];
// -2 = Multidump configuration // -2 = Multidump configuration
@ -369,9 +390,10 @@ function WriteCronScript($restore_values=false)
$cron_dbpraefix_array = $databases['praefix']; $cron_dbpraefix_array = $databases['praefix'];
$cron_command_before_dump = $databases['command_before_dump']; $cron_command_before_dump = $databases['command_before_dump'];
$cron_command_after_dump = $databases['command_after_dump']; $cron_command_after_dump = $databases['command_after_dump'];
if (!isset($config['cron_dbindex'])) $config['cron_dbindex']=-3; if (!isset($config['cron_dbindex'])) {
if (intval($config['cron_dbindex']) == -2) $config['cron_dbindex'] = -3;
{ }
if (intval($config['cron_dbindex']) == -2) {
// get selected dbs from multidump-settings // get selected dbs from multidump-settings
$cron_db_array = $databases['multi']; $cron_db_array = $databases['multi'];
$cron_dbpraefix_array = $databases['multi_praefix']; $cron_dbpraefix_array = $databases['multi_praefix'];
@ -433,19 +455,18 @@ function WriteCronScript($restore_values=false)
'cron_use_sendmail', 'cron_use_sendmail',
'cron_smtp_port' 'cron_smtp_port'
); );
foreach ($int_array as $i) foreach ($int_array as $i) {
{ if (is_array($i)) {
if (is_array($i)) foreach ($i as $key => $val) {
{
foreach ($i as $key=>$val)
{
$int_array[$key] = intval($val); $int_array[$key] = intval($val);
} }
} } else {
else
$config[$i] = intval($config[$i]); $config[$i] = intval($config[$i]);
} }
if ($config['dbport'] == 0) $config['dbport']=3306; }
if ($config['dbport'] == 0) {
$config['dbport'] = 3306;
}
$cronscript = "<?php\n#Vars - written at " . date("Y-m-d") . $nl; $cronscript = "<?php\n#Vars - written at " . date("Y-m-d") . $nl;
$cronscript .= '$dbhost="' . $config['dbhost'] . '";' . $nl; $cronscript .= '$dbhost="' . $config['dbhost'] . '";' . $nl;
@ -501,30 +522,38 @@ function WriteCronScript($restore_values=false)
// Save config // Save config
$ret = true; $ret = true;
$sfile = $config['paths']['config'] . $config['config_file'] . '.conf.php'; $sfile = $config['paths']['config'] . $config['config_file'] . '.conf.php';
if (file_exists($sfile)) @unlink($sfile); if (file_exists($sfile)) {
@unlink($sfile);
if ($fp=fopen($sfile,"wb"))
{
if (!fwrite($fp,$cronscript)) $ret=false;
if (!fclose($fp)) $ret=false;
@chmod("$sfile",0777);
} }
else
if ($fp = fopen($sfile, "wb")) {
if (!fwrite($fp, $cronscript)) {
$ret = false; $ret = false;
}
if (!fclose($fp)) {
$ret = false;
}
@chmod("$sfile", 0777);
} else {
$ret = false;
}
// if standard config was deleted -> restore it with the actual values // if standard config was deleted -> restore it with the actual values
if (!file_exists($config['paths']['config'] . "mysqldumper.conf.php")) if (!file_exists($config['paths']['config'] . "mysqldumper.conf.php")) {
{
$sfile = $config['paths']['config'] . 'mysqldumper.conf.php'; $sfile = $config['paths']['config'] . 'mysqldumper.conf.php';
if ($fp=fopen($sfile,"wb")) if ($fp = fopen($sfile, "wb")) {
{ if (!fwrite($fp, $cronscript)) {
if (!fwrite($fp,$cronscript)) $ret=false;
if (!fclose($fp)) $ret=false;
@chmod("$sfile",0777);
}
else
$ret = false; $ret = false;
} }
if (!fclose($fp)) {
$ret = false;
}
@chmod("$sfile", 0777);
} else {
$ret = false;
}
}
return $ret; return $ret;
} }
@ -534,16 +563,15 @@ function LogFileInfo($logcompression)
global $config; global $config;
$l = Array(); $l = Array();
$sum=$s=$l['log_size']=$l['perllog_size']=$l['perllogcomplete_size']=$l['errorlog_size']=$l['log_totalsize']=0; $sum = $s
if ($logcompression == 1) =
{ $l['log_size'] = $l['perllog_size'] = $l['perllogcomplete_size'] = $l['errorlog_size'] = $l['log_totalsize'] = 0;
if ($logcompression == 1) {
$l['log'] = $config['files']['log'] . ".gz"; $l['log'] = $config['files']['log'] . ".gz";
$l['perllog'] = $config['files']['perllog'] . ".gz"; $l['perllog'] = $config['files']['perllog'] . ".gz";
$l['perllogcomplete'] = $config['files']['perllogcomplete'] . ".gz"; $l['perllogcomplete'] = $config['files']['perllogcomplete'] . ".gz";
$l['errorlog'] = $config['paths']['log'] . "error.log.gz"; $l['errorlog'] = $config['paths']['log'] . "error.log.gz";
} } else {
else
{
$l['log'] = $config['files']['log']; $l['log'] = $config['files']['log'];
$l['perllog'] = $config['files']['perllog']; $l['perllog'] = $config['files']['perllog'];
$l['perllogcomplete'] = $config['files']['perllogcomplete']; $l['perllogcomplete'] = $config['files']['perllogcomplete'];
@ -567,17 +595,18 @@ function DeleteLog()
global $config; global $config;
//Datei öffnen und schreiben //Datei öffnen und schreiben
$log = date('d.m.Y H:i:s') . " Log created.\n"; $log = date('d.m.Y H:i:s') . " Log created.\n";
if (file_exists($config['files']['log'] . '.gz')) @unlink($config['files']['log'] . '.gz'); if (file_exists($config['files']['log'] . '.gz')) {
if (file_exists($config['files']['log'] . '.gz')) @unlink($config['files']['log']); @unlink($config['files']['log'] . '.gz');
if ($config['logcompression'] == 1) }
{ if (file_exists($config['files']['log'] . '.gz')) {
@unlink($config['files']['log']);
}
if ($config['logcompression'] == 1) {
$fp = @gzopen($config['files']['log'] . '.gz', "wb"); $fp = @gzopen($config['files']['log'] . '.gz', "wb");
@gzwrite($fp, $log); @gzwrite($fp, $log);
@gzclose($fp); @gzclose($fp);
@chmod($config['files']['log'] . '.gz', 0777); @chmod($config['files']['log'] . '.gz', 0777);
} } else {
else
{
$fp = @fopen($config['files']['log'], "wb"); $fp = @fopen($config['files']['log'], "wb");
@fwrite($fp, $log); @fwrite($fp, $log);
@fclose($fp); @fclose($fp);
@ -595,15 +624,16 @@ function CreateDirsFTP()
// Einloggen mit Benutzername und Kennwort // Einloggen mit Benutzername und Kennwort
$login_result = ftp_login($conn_id, $install_ftp_user_name, $install_ftp_user_pass); $login_result = ftp_login($conn_id, $install_ftp_user_name, $install_ftp_user_pass);
// Verbindung überprüfen // Verbindung überprüfen
if (( !$conn_id ) || ( !$login_result )) if ((!$conn_id) || (!$login_result)) {
{
echo $lang['L_FTP_NOTCONNECTED']; echo $lang['L_FTP_NOTCONNECTED'];
echo $lang['L_CONNWITH'] . " $tinstall_ftp_server " . $lang['L_ASUSER'] . " $install_ftp_user_name " . $lang['L_NOTPOSSIBLE']; echo $lang['L_CONNWITH'] . " $tinstall_ftp_server " . $lang['L_ASUSER'] . " $install_ftp_user_name "
. $lang['L_NOTPOSSIBLE'];
return 0; return 0;
} else {
if ($config['ftp_mode'] == 1) {
ftp_pasv($conn_id, true);
} }
else
{
if ($config['ftp_mode'] == 1) ftp_pasv($conn_id,true);
//Wechsel in betroffenes Verzeichnis //Wechsel in betroffenes Verzeichnis
echo $lang['L_CHANGEDIR'] . ' `' . $install_ftp_path . '` ...<br>'; echo $lang['L_CHANGEDIR'] . ' `' . $install_ftp_path . '` ...<br>';
ftp_chdir($conn_id, $install_ftp_path); ftp_chdir($conn_id, $install_ftp_path);
@ -626,6 +656,7 @@ function CreateDirsFTP()
// Schließen des FTP-Streams // Schließen des FTP-Streams
ftp_quit($conn_id); ftp_quit($conn_id);
return 1; return 1;
} }
} }
@ -633,22 +664,23 @@ function CreateDirsFTP()
function ftp_mkdirs($config, $dirname) function ftp_mkdirs($config, $dirname)
{ {
$dir = split("/", $dirname); $dir = split("/", $dirname);
for ($i=0; $i < count($dir) - 1; $i++) for ($i = 0; $i < count($dir) - 1; $i++) {
{
$path .= $dir[$i] . "/"; $path .= $dir[$i] . "/";
@ftp_mkdir($config['dbconnection'], $path); @ftp_mkdir($config['dbconnection'], $path);
} }
if (@ftp_mkdir($config['dbconnection'],$dirname)) return 1; if (@ftp_mkdir($config['dbconnection'], $dirname)) {
return 1;
}
} }
function IsWritable($dir) function IsWritable($dir)
{ {
$testfile = $dir . "/.writetest"; $testfile = $dir . "/.writetest";
if ($writable=@fopen($testfile,'w')) if ($writable = @fopen($testfile, 'w')) {
{
@fclose($writable); @fclose($writable);
@unlink($testfile); @unlink($testfile);
} }
return $writable; return $writable;
} }
@ -656,57 +688,64 @@ function SearchDatabases($printout, $db='')
{ {
global $databases, $config, $lang; global $databases, $config, $lang;
if (!isset($config['dbconnection'])) MSD_mysql_connect(); if (!isset($config['dbconnection'])) {
MSD_mysql_connect();
}
$db_list = array(); $db_list = array();
if ($db > '') { if ($db > '') {
$db_list[] = $db; // DB wurde manuell angegeben $db_list[] = $db; // DB wurde manuell angegeben
} }
// Datenbanken automatisch erkennen // Datenbanken automatisch erkennen
$show_dbs = mysql_query("SHOW DATABASES", $config['dbconnection']); $show_dbs = mysql_query("SHOW DATABASES", $config['dbconnection']);
if (!$show_dbs === false) if (!$show_dbs === false) {
{ WHILE ($row = mysql_fetch_row($show_dbs)) {
WHILE ($row=mysql_fetch_row($show_dbs)) if (trim($row[0]) > '') {
{ $db_list[] = $row[0];
if (trim($row[0]) > '') $db_list[]=$row[0]; }
} }
} }
$db_list = array_unique($db_list); $db_list = array_unique($db_list);
sort($db_list); sort($db_list);
if (sizeof($db_list) > 0) if (sizeof($db_list) > 0) {
{
$databases['db_selected_index'] = 0; $databases['db_selected_index'] = 0;
for ($i=0; $i < sizeof($db_list); $i++) for ($i = 0; $i < sizeof($db_list); $i++) {
{
// Test-Select um zu sehen, ob Berechtigungen existieren // Test-Select um zu sehen, ob Berechtigungen existieren
if (!@mysql_query("SHOW TABLES FROM `" . $db_list[$i] . "`",$config['dbconnection']) === false) if (!@mysql_query("SHOW TABLES FROM `" . $db_list[$i] . "`", $config['dbconnection']) === false) {
{
$databases['Name'][$i] = $db_list[$i]; $databases['Name'][$i] = $db_list[$i];
$databases['praefix'][$i] = ''; $databases['praefix'][$i] = '';
$databases['command_before_dump'][$i] = ''; $databases['command_before_dump'][$i] = '';
$databases['command_after_dump'][$i] = ''; $databases['command_after_dump'][$i] = '';
if ($printout == 1) echo $lang['L_FOUND_DB'] . ' `' . $db_list[$i] . '`<br />'; if ($printout == 1) {
echo $lang['L_FOUND_DB'] . ' `' . $db_list[$i] . '`<br />';
}
} else { } else {
if ($printout == 1) echo '<span class="error">'.sprintf($lang['L_DB_MANUAL_ERROR'], $db_list[$i]) . '</span><br />'; if ($printout == 1) {
echo '<span class="error">' . sprintf($lang['L_DB_MANUAL_ERROR'], $db_list[$i]) . '</span><br />';
} }
} }
} }
if (isset($databases['Name'][0])) $databases['db_actual']=$databases['Name'][0]; }
if (isset($databases['Name'][0])) {
$databases['db_actual'] = $databases['Name'][0];
}
} }
// removes tags from inputs recursivly // removes tags from inputs recursivly
function my_strip_tags($value) function my_strip_tags($value)
{ {
global $dont_strip; global $dont_strip;
if (is_array($value)) if (is_array($value)) {
{ foreach ($value as $key => $val) {
foreach ($value as $key=>$val) if (!in_array($key, $dont_strip)) {
{ $ret[$key] = my_strip_tags($val);
if (!in_array($key,$dont_strip)) $ret[$key]=my_strip_tags($val); } else {
else $ret[$key]=$val; $ret[$key] = $val;
} }
} }
else } else {
$ret = trim(strip_tags($value)); $ret = trim(strip_tags($value));
}
return $ret; return $ret;
} }
@ -716,6 +755,7 @@ function my_strip_tags($value)
* Used for escaping strings in JS-alerts and config-files * Used for escaping strings in JS-alerts and config-files
* *
* @param $string * @param $string
*
* @return string * @return string
*/ */
function my_addslashes($string) function my_addslashes($string)
@ -729,6 +769,7 @@ function my_addslashes($string)
* Replaces quotes for outputing value in HTML-attributes without breaking HTML * Replaces quotes for outputing value in HTML-attributes without breaking HTML
* *
* @param string $value value to output * @param string $value value to output
*
* @return string * @return string
*/ */
function my_quotes($value) function my_quotes($value)
@ -741,15 +782,16 @@ function my_quotes($value)
function db_escape($string) function db_escape($string)
{ {
global $config; global $config;
if (function_exists('mysql_real_escape_string')) if (function_exists('mysql_real_escape_string')) {
{
$string = mysql_real_escape_string($string, $config['dbconnection']); $string = mysql_real_escape_string($string, $config['dbconnection']);
} } else {
else if (function_exists('mysql_escape_string')) if (function_exists('mysql_escape_string')) {
{
$string = mysql_escape_string($string, $config['dbconnection']); $string = mysql_escape_string($string, $config['dbconnection']);
} else {
$string = addslashes($string);
} }
else $string=addslashes($string); }
return $string; return $string;
} }

Datei anzeigen

@ -10,26 +10,22 @@ $verbose = true;
* Build exclude array with configuration files that should be skipped * Build exclude array with configuration files that should be skipped
*/ */
$excludedConfigurationFiles = array( $excludedConfigurationFiles = array(
'mysqldumper', //'mysqldumper',
//add more excluded files via: 'configFileName', //add more excluded files by adding their name
); );
$myNl = '<br />';
$verbose = true; $verbose = true;
if (isset ($_SERVER['SESSIONNAME'])) { if (PHP_SAPI === 'cli' || empty($_SERVER['REMOTE_ADDR'])) {
// called via cli - check verbose param // called via cli - check verbose param
$myNl = "\n"; define('NEWLINE', "\n");
$options = getopt('v::', array('verbose::')); $options = getopt('v::', array('verbose::'));
if (isset($options['v'])) { $verbose = isset($options['verbose']) || isset($options['v']) ? true : false;
$verbose = $options['v']; } else {
} define('NEWLINE', '<br />');
if (isset($options['verbose'])) {
$verbose = $options['verbose'];
}
} }
date_default_timezone_set('Europe/Berlin'); date_default_timezone_set('Europe/Berlin');
define('APPLICATION_PATH', realpath(dirname(__FILE__))); define('APPLICATION_PATH', __DIR__);
chdir(APPLICATION_PATH); chdir(APPLICATION_PATH);
include(APPLICATION_PATH . '/inc/functions.php'); include(APPLICATION_PATH . '/inc/functions.php');
include(APPLICATION_PATH . '/inc/mysql.php'); include(APPLICATION_PATH . '/inc/mysql.php');
@ -43,9 +39,7 @@ foreach ($configFiles as $configFile) {
if (in_array($configFile, $excludedConfigurationFiles)) { if (in_array($configFile, $excludedConfigurationFiles)) {
continue; continue;
} }
if ($verbose) { output('Refreshing database list for configuration file: ' . $configFile, $verbose);
echo 'Refreshing database list for configuration file: ' . $configFile . $myNl;
}
$config['config_file'] = $configFile; $config['config_file'] = $configFile;
include($config['paths']['config'] . $configFile . '.php'); include($config['paths']['config'] . $configFile . '.php');
$out = ''; $out = '';
@ -54,7 +48,17 @@ foreach ($configFiles as $configFile) {
$config['dbconnection'] = false; $config['dbconnection'] = false;
} }
SetDefault(); SetDefault();
output($out, $verbose);
}
/**
* @param string $message
* @param boolean $verbose
*/
function output($message, $verbose)
{
if ($verbose) { if ($verbose) {
echo str_replace("\n", $myNl, $out) . $myNl; $message = str_replace("\n", NEWLINE, $message);
echo $message . NEWLINE;
} }
} }