diff --git a/filemanagement.php b/filemanagement.php index 4de2348..33f0f3d 100644 --- a/filemanagement.php +++ b/filemanagement.php @@ -307,8 +307,8 @@ switch ($action) $scriptdir=$config['cron_execution_path'].'crondump.'.$cext; $sfile=$config['cron_execution_path']."perltest.$cext"; $simplefile=$config['cron_execution_path']."simpletest.$cext"; - $scriptentry=Realpfad("./").$config['paths']['config']; - $cronabsolute=(substr($config['cron_execution_path'],0,1)=="/") ? $_SERVER['DOCUMENT_ROOT'].$scriptdir : Realpfad("./").$scriptdir; + $scriptentry=basePath(). $config['paths']['config']; + $cronabsolute=(substr($config['cron_execution_path'],0,1)=="/") ? $_SERVER['DOCUMENT_ROOT'].$scriptdir : basePath().$scriptdir; $confabsolute=$config['config_file']; $scriptref=getServerProtocol().$_SERVER['SERVER_NAME'].$refdir.$config['cron_execution_path'].'crondump.'.$cext."?config=".$confabsolute; $cronref="perl ".$cronabsolute." -config=".$confabsolute." -html_output=0"; diff --git a/inc/functions.php b/inc/functions.php index ab34125..099ccef 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -249,7 +249,7 @@ function WriteParams($as = 0, $restore_values = false) $config['cron_execution_path'] = "msd_cron/"; } if ($as == 0) { - $config['paths']['root'] = addslashes(Realpfad("./")); + $config['paths']['root'] = addslashes(basePath()); } $config['files']['parameter'] = $config['paths']['config'] . $config['config_file'] . '.php'; $config['files']['iconpath'] = './css/' . $config['theme'] . '/icons/'; diff --git a/inc/functions_global.php b/inc/functions_global.php index f35ae3e..136da46 100644 --- a/inc/functions_global.php +++ b/inc/functions_global.php @@ -1,884 +1,939 @@ '."\n"; - foreach ($parameter as $key=>$val) - { - if (is_array($val)) - { - foreach ($val as $key2=>$val2) - { - $page_parameter.=''."\n"; - } - } - else - $page_parameter.=''."\n"; - } - $page_parameter.=''; - return $page_parameter; + $page_parameter = '
'; + + return $page_parameter; } function mu_sort($array, $key_sort) { - $key_sorta=explode(',',$key_sort); - $keys=array_keys($array[0]); - $n=0; + $key_sorta = explode(',', $key_sort); + $keys = array_keys($array[0]); + $n = 0; - for ($m=0; $m'.$lang['L_LOGFILENOTWRITABLE'].' ('.$logfile.')
'; - } - else - { - $fp=@fopen($logfile,"ab"); - if ($fp) - { - @fwrite($fp,$log); - @fclose($fp); - } - else - echo ''.$lang['L_LOGFILENOTWRITABLE'].' ('.$logfile.')
'; - } + $fp = @gzopen($logfile, 'a'); + if ($fp) { + @gzwrite($fp, $log) . '' . $lang['L_LOGFILENOTWRITABLE'] . ' (' . $logfile . ')
'; + } + } else { + $fp = @fopen($logfile, "ab"); + if ($fp) { + @fwrite($fp, $log); + @fclose($fp); + } else { + echo '' . $lang['L_LOGFILENOTWRITABLE'] . ' (' . $logfile . ')
'; + } + } } -function ErrorLog($dest, $db, $sql, $error, $art=1) +function ErrorLog($dest, $db, $sql, $error, $art = 1) { - //$art=0 -> Fehlermeldung - //$art=1 -> Hinweis + //$art=0 -> Fehlermeldung + //$art=1 -> Hinweis - global $config; - if (strlen($sql)>100) $sql=substr($sql,0,100)." ... (snip)"; - //Error-Zeile generieren - $errormsg=date('d.m.Y H:i:s').': '; - $errormsg.=($dest=='RESTORE') ? ' Restore of db `'.$db.'`|:|' : ' Dump of db `'.$db.'`|:|'; + global $config; + if (strlen($sql) > 100) { + $sql = substr($sql, 0, 100) . " ... (snip)"; + } + //Error-Zeile generieren + $errormsg = date('d.m.Y H:i:s') . ': '; + $errormsg .= ($dest == 'RESTORE') ? ' Restore of db `' . $db . '`|:|' : ' Dump of db `' . $db . '`|:|'; - if ($art==0) - { - $errormsg.='Error-Message: '.$error.'|:|'; - } - else - { - $errormsg.='Notice: '.$error.'|:|'; - } + if ($art == 0) { + $errormsg .= 'Error-Message: ' . $error . '|:|'; + } else { + $errormsg .= 'Notice: ' . $error . '|:|'; + } - if ($sql>'') $errormsg.='SQL: '.$sql."\n"; + if ($sql > '') { + $errormsg .= 'SQL: ' . $sql . "\n"; + } - //Datei öffnen und schreiben - if ($config['logcompression']==1) - { - $fp=@gzopen($config['paths']['log'].'error.log.gz','ab'); - if ($fp) - { - @gzwrite($fp,($errormsg)); - @gzclose($fp); - } - } - else - { - $fp=@fopen($config['paths']['log'].'error.log','ab'); - if ($fp) - { - @fwrite($fp,($errormsg)); - @fclose($fp); - } - } + //Datei öffnen und schreiben + if ($config['logcompression'] == 1) { + $fp = @gzopen($config['paths']['log'] . 'error.log.gz', 'ab'); + if ($fp) { + @gzwrite($fp, ($errormsg)); + @gzclose($fp); + } + } else { + $fp = @fopen($config['paths']['log'] . 'error.log', 'ab'); + if ($fp) { + @fwrite($fp, ($errormsg)); + @fclose($fp); + } + } } -function DirectoryWarnings($path="") +function DirectoryWarnings($path = "") { - global $config,$lang; - $warn=''; - if (!is_writable($config['paths']['work'])) $warn.=sprintf($lang['L_WRONG_RIGHTS'],$config['paths']['work'],'0777'); - if (!is_writable($config['paths']['config'])) $warn.=sprintf($lang['L_WRONG_RIGHTS'],$config['paths']['config'],'0777'); - if (!is_writable($config['paths']['backup'])) $warn.=sprintf($lang['L_WRONG_RIGHTS'],$config['paths']['backup'],'0777'); - if (!is_writable($config['paths']['log'])) $warn.=sprintf($lang['L_WRONG_RIGHTS'],$config['paths']['log'],'0777'); + global $config, $lang; + $warn = ''; + if (!is_writable($config['paths']['work'])) { + $warn .= sprintf($lang['L_WRONG_RIGHTS'], $config['paths']['work'], '0777'); + } + if (!is_writable($config['paths']['config'])) { + $warn .= sprintf($lang['L_WRONG_RIGHTS'], $config['paths']['config'], '0777'); + } + if (!is_writable($config['paths']['backup'])) { + $warn .= sprintf($lang['L_WRONG_RIGHTS'], $config['paths']['backup'], '0777'); + } + if (!is_writable($config['paths']['log'])) { + $warn .= sprintf($lang['L_WRONG_RIGHTS'], $config['paths']['log'], '0777'); + } - if ($warn!='') $warn=''.$warn.''; - return $warn; + if ($warn != '') { + $warn = '' . $warn . ''; + } + + return $warn; } function TestWorkDir() { - global $config; + global $config; - $ret=SetFileRechte($config['paths']['work']); - if ($ret===true) $ret=SetFileRechte($config['paths']['backup']); - if ($ret===true) $ret=SetFileRechte($config['paths']['log']); - if ($ret===true) $ret=SetFileRechte($config['paths']['config']); + $ret = SetFileRechte($config['paths']['work']); + if ($ret === true) { + $ret = SetFileRechte($config['paths']['backup']); + } + if ($ret === true) { + $ret = SetFileRechte($config['paths']['log']); + } + if ($ret === true) { + $ret = SetFileRechte($config['paths']['config']); + } - if ($ret===true) - { - if (!file_exists($config['files']['parameter'])) SetDefault(true); - if (!file_exists($config['files']['log'])) DeleteLog(); - } - return $ret; + if ($ret === true) { + if (!file_exists($config['files']['parameter'])) { + SetDefault(true); + } + if (!file_exists($config['files']['log'])) { + DeleteLog(); + } + } + + return $ret; } -function SetFileRechte($file, $is_dir=1, $perm=0777) +function SetFileRechte($file, $is_dir = 1, $perm = 0777) { - global $lang; - $ret=true; - if ($is_dir==1) - { - if (substr($file,-1)!="/") $file.="/"; - } - clearstatcache(); + global $lang; + $ret = true; + if ($is_dir == 1) { + if (substr($file, -1) != "/") { + $file .= "/"; + } + } + clearstatcache(); - // erst pruefen, ob Datei oder Verzeichnis existiert - if (!file_exists($file)) - { - // Wenn es sich um ein Verzeichnis handelt -> anlegen - if ($is_dir==1) - { - $ret=@mkdir($file,$perm); - if (!$ret===true) - { - // Hat nicht geklappt -> Rueckmeldung - $ret=sprintf($lang['L_CANT_CREATE_DIR'],$file); - } - } - } + // erst pruefen, ob Datei oder Verzeichnis existiert + if (!file_exists($file)) { + // Wenn es sich um ein Verzeichnis handelt -> anlegen + if ($is_dir == 1) { + $ret = @mkdir($file, $perm); + if (!$ret === true) { + // Hat nicht geklappt -> Rueckmeldung + $ret = sprintf($lang['L_CANT_CREATE_DIR'], $file); + } + } + } - // wenn bisher alles ok ist -> Rechte setzen - egal ob Datei oder Verzeichnis - if ($ret===true) - { - $ret=@chmod($file,$perm); - if (!$ret===true) $ret=sprintf($lang['L_WRONG_RIGHTS'],$file,decoct($perm)); - } - return $ret; + // wenn bisher alles ok ist -> Rechte setzen - egal ob Datei oder Verzeichnis + if ($ret === true) { + $ret = @chmod($file, $perm); + if (!$ret === true) { + $ret = sprintf($lang['L_WRONG_RIGHTS'], $file, decoct($perm)); + } + } + + return $ret; } function SelectDB($index) { - global $databases; - if (is_string($index)) { - // name given - $dbNames = array_flip($databases['Name']); - if (array_key_exists($index, $dbNames)) { - $index = $dbNames[$index]; - } - } - if (isset($databases['Name'][$index])) - { - $databases['db_actual']=$databases['Name'][$index]; - if (isset($databases['praefix'][$index])) $databases['praefix'][$databases['db_selected_index']]=$databases['praefix'][$index]; - else - $databases['praefix'][$databases['db_selected_index']]=''; - if (isset($databases['db_selected_index'])) $databases['db_selected_index']=$index; - else - $databases['db_selected_index']=0; - } - else - { - // keine DB vorhanden - $databases['praefix'][$databases['db_selected_index']]=''; - $databases['db_selected_index']=0; - $databases['db_actual']=''; - } + global $databases; + if (is_string($index)) { + // name given + $dbNames = array_flip($databases['Name']); + if (array_key_exists($index, $dbNames)) { + $index = $dbNames[$index]; + } + } + if (isset($databases['Name'][$index])) { + $databases['db_actual'] = $databases['Name'][$index]; + if (isset($databases['praefix'][$index])) { + $databases['praefix'][$databases['db_selected_index']] = $databases['praefix'][$index]; + } else { + $databases['praefix'][$databases['db_selected_index']] = ''; + } + if (isset($databases['db_selected_index'])) { + $databases['db_selected_index'] = $index; + } else { + $databases['db_selected_index'] = 0; + } + } else { + // keine DB vorhanden + $databases['praefix'][$databases['db_selected_index']] = ''; + $databases['db_selected_index'] = 0; + $databases['db_actual'] = ''; + } } function EmptyDB($dbn) { - global $config; - $t_sql=array(); - @mysqli_query($GLOBALS["___mysqli_ston"], 'SET FOREIGN_KEY_CHECKS=0'); - $res=mysqli_query($config['dbconnection'], 'SHOW TABLE STATUS FROM `'.$dbn.'`') or die('EmptyDB: '.((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false))); - WHILE ($row=mysqli_fetch_array($res, MYSQLI_ASSOC)) - { - if (substr(strtoupper($row['Comment']),0,4)=='VIEW') - { - $t_sql[]='DROP VIEW `'.$dbn.'`.`'.$row['Name'].'`'; - } - else - { - $t_sql[]='DROP TABLE `'.$dbn.'`.`'.$row['Name'].'`'; - } - } - if (sizeof($t_sql)>0) - { - for ($i=0; $i'.$lang['L_FM_AUTODEL1'].'
';
- $r.=$delfile[3]."
";
- $part=$delfile[2];
- if ($part>0)
- {
- for ($i=$part; $i>0; $i--)
- {
- $delete=@unlink($config['paths']['backup'].$delfile[3]);
- if ($delete) WriteLog("autodeleted ($function) '$delfile[3]'.");
- }
- }
- else
- {
- WriteLog("autodeleted ($function) '$delfile[3]'.");
- unlink($config['paths']['backup'].$delfile[3]);
- }
- $r.='
' . $lang['L_FM_AUTODEL1'] . '
';
+ $r .= $delfile[3] . "
";
+ $part = $delfile[2];
+ if ($part > 0) {
+ for ($i = $part; $i > 0; $i--) {
+ $delete = @unlink($config['paths']['backup'] . $delfile[3]);
+ if ($delete) {
+ WriteLog("autodeleted ($function) '$delfile[3]'.");
+ }
+ }
+ } else {
+ WriteLog("autodeleted ($function) '$delfile[3]'.");
+ unlink($config['paths']['backup'] . $delfile[3]);
+ }
+ $r .= '
";print_r($tmp);echo ""; + $tmp = explode(",", $s); + //echo "
";print_r($tmp);echo ""; - for ($i=0; $i