<?php
$prefer_log = date("dmY"); // heutiges logfile.......
$path = 'timetip/time_data/logs/';
$kind_of_file = 'log';
if (!empty($_POST['delete']))
{
$fp = fopen($path . $_POST['delete'] . '.'.$kind_of_file, 'w');
unlink($path . $_POST['delete'] . '.'.$kind_of_file);
// fwrite($fp, '');
// fclose($fp);
header('Location: ' . $_SERVER['PHP_SELF']);
exit();
}
/**/
$logfile = (empty($_POST['logfile'])) ? '' : $_POST['logfile'];
$sortier = (empty($_POST['sort'])) ? 2 : $_POST['sort'];
$reload = (empty($_POST['reload'])) ? 0 : $_POST['reload'];
/**/
$ausgabe = <<<EOF
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="de" />
<meta http-equiv="Expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<title>Logdatei - {$logfile}.log</title>
<style type="text/css">
<!--
body
{
overflow: auto;
margin: 0px;
}
body, td, select, input, textarea
{
font-family: 'Courier New';
font-weight: bold;
font-size: 9pt;
}
form
{
display: inline;
}
select
{
background-color: #eee;
}
.sele
{
color: #dc143c;
}
input
{
background-color: #eef;
border: 1px solid #dc143c;
height: 20px;
color: #e00;
}
textarea
{
scrollbar-highlight-color: #6d8ea0;
scrollbar-darkshadow-color: #eee;
scrollbar-shadow-color: #6d8ea0;
scrollbar-arrow-color: #dc143c;
scrollbar-3dlight-color: #eee;
scrollbar-track-color: #eee;
scrollbar-face-color: #fff;
background-color: #eee;
border: 1px solid #000;
padding: 5px;
}
//-->
</style>
<script language="JavaScript" type="text/javascript">
<!--
function seite_neu()
{
setTimeout('self.location.replace(self.location);', 1500);
}
window.onresize = seite_neu;
/**/
function scroller()
{
if (document.body.offsetWidth)
{
var div_width = document.body.offsetWidth - 22;
var div_height = document.body.offsetHeight - 55;
}
else
{
var div_width = window.innerWidth - 20;
var div_height = window.innerHeight - 53;
}
with (document)
{
write ('<style type="text/css">'
+ '<'+'!--'
+ '#scroll'
+ '{'
+ ' overflow: auto;'
+ ' height: ' + div_height + 'px;'
+ ' width: ' + div_width + 'px;'
+ '}'
+ '//--'+'>'
+ '</style>');
}
}
/**/
with (document)
{
write ('<style type="text/css">'
+ '<'+'!--'
+ 'body'
+ '{'
+ ' overflow: hidden;'
+ '}'
+ '//--'+'>'
+ '</style>');
}
//-->
</script>
</head>
<body
EOF;
/**/
if ($reload > 0)
$ausgabe .= ' onload="setTimeout(\'document.forms[0].submit();\', ' . ($reload * 1000) . ');"';
/**/
$ausgabe .= <<<EOF
>
<script language="JavaScript" type="text/javascript">
<!--
scroller();
//-->
</script>
<table border="0" cellspacing="10" cellpadding="0">
<tr>
<td height="5%"><form action="{$_SERVER['PHP_SELF']}" method="post">
Logdatei:
<select name="logfile" size="1" onchange="document.forms[0].submit();">
<option value="{$prefer_log}">Heute</option>
EOF;
/**/
if (is_dir($path))
{
$_dir = dir($path);
while ($files = $_dir->read())
{
if (is_file($path . $files) && preg_match('/(\.'.$kind_of_file.'$)/i', $files) && filesize($path . $files) > 0)
{
$datei = preg_replace('/(\.'.$kind_of_file.'$)/i', '', $files);
$ausgabe .= ' <option';
if ($datei == $logfile)
$ausgabe .= ' class="sele"';
$ausgabe .= ' value="' . $datei . '"';
if ($datei == $logfile)
$ausgabe .= ' selected';
$file_to_show = substr($files,0,2)."-".substr($files,2,2)."-".substr($files,4,4);
$ausgabe .= '>' . $file_to_show . ' (' . number_format((filesize($path . $files) / pow(1024, 1)), 2, ',', '.') . ' KB)</option>' . "\r\n";
}
}
$_dir->close();
}
/**/
$ausgabe .= <<<EOF
</select></td>
<td>Sortieren:
<select name="sort" size="1" onchange="document.forms[0].submit();">
EOF;
/**/
$reihe = array(1 => 'älteste', 2 => 'neueste');
foreach ($reihe as $key => $elem)
{
$ausgabe .= ' <option';
if ($sortier == $key)
$ausgabe .= ' class="sele"';
$ausgabe .= ' value="' . $key . '"';
if ($sortier == $key)
$ausgabe .= ' selected';
$ausgabe .= '>' . $elem . '</option>' . "\r\n";
}
/**/
$ausgabe .= <<<EOF
</select></td>
<td>Reload in sek.:
<select name="reload" size="1" onchange="document.forms[0].submit();">
EOF;
/**/
for ($i = 0; $i <= 60; $i = $i + 5)
{
$az = ($i == 0) ? 'Aus' : $i;
$ausgabe .= ' <option';
if ($i == $reload)
$ausgabe .= ' class="sele"';
$ausgabe .= ' value="' . $i . '"';
if ($i == $reload)
$ausgabe .= ' selected';
$ausgabe .= '>' . $az . '</option>' . "\r\n";
}
/**/
$ausgabe .= <<<EOF
</select> <input type="button" value="start" onclick="document.forms[0].submit();" onfocus="this.blur();" /></form></td>
<td align="right"><form action="{$_SERVER['PHP_SELF']}" method="post">
<input name="delete" type="hidden" value="{$logfile}" />
<input type="button" value="löschen" onclick="document.forms[1].submit();" onfocus="this.blur();" /></form></td>
</tr>
<tr>
<td colspan="4" height="95%"><textarea id="scroll" cols="140" rows="34" wrap="off">
EOF;
/**/
if (!empty($logfile))
{
$log = file($path . $logfile . '.'.$kind_of_file);
if ($sortier == 2)
$log = array_reverse($log);
$ausgabe .= htmlentities(trim(implode('', $log)), ENT_QUOTES);
}
/**/
$ausgabe .= <<<EOF
</textarea></td>
</tr>
</table>
</body>
</html>
EOF;
/**/
echo $ausgabe;
?>