uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); $app->tpl->setInclude('content_tpl',$template); $app->tpl->setVar("output",$output); $app->tpl->setVar("title",$title); $app->tpl->setVar("description",$description); $app->tpl_defaults(); $app->tpl->pparse(); function show_load(){ global $app; $html_out .= '
'; $fd = popen ("uptime", "r"); while (!feof($fd)) { $buffer .= fgets($fd, 4096); } $uptime = split(",",strrev($buffer)); $online = split(" ",strrev($uptime[4])); $proc_uptime = shell_exec("cat /proc/uptime | cut -f1 -d' '"); $days = floor($proc_uptime/86400); $hours = floor(($proc_uptime-$days*86400)/3600); $minutes = str_pad(floor(($proc_uptime-$days*86400-$hours*3600)/60), 2, "0", STR_PAD_LEFT); $html_out .= ''; $html_out .= ''; $ausl = split(":",strrev($uptime[2])); $ausl1 = $ausl[1]; $html_out .= ''; $html_out .= ''; $html_out .= ''; $html_out .= '
'.$app->lng("Server Online seit").':
'.$days.'d, '.$hours.':'.$minutes.'h
'.$app->lng("User Online").':
'.strrev($uptime[3]).'
'.$app->lng("System Load 1 Minute").':
'.$ausl1.'
'.$app->lng("System Load 5 Minuten").':
'.strrev($uptime[1]).'
'.$app->lng("System Load 15 Minuten").':
'.strrev($uptime[0]).'
'; return $html_out; } function show_disk () { global $app; $html_out .= '
'; $fd = popen ("df -h", "r"); while (!feof($fd)) { $buffer .= fgets($fd, 4096); } $df_out = split("\n",$buffer); $df_num = sizeof($df_out); for($i=0;$i<$df_num;$i++){ if(ltrim($df_out[$i]) != $df_out[$i]){ if(isset($df_out[($i-1)])){ $df_out[($i-1)] .= $df_out[$i]; unset($df_out[$i]); } } } $html_out .= ''; $mrow = 0; foreach($df_out as $df_line) { $values = preg_split ("/[\s]+/", $df_line); $mln = 0; $font_class = 'normal_bold'; if($mrow > 0) $font_class = 'normal'; foreach($values as $value) { $align = 'left'; if($mln > 0 and $mln < 5) $align = 'right'; if($mln < 6 and $value != "") $html_out .= ''; $mln++; } $mrow++; $html_out .= ''; } $html_out .= '
'.$value.'
'; return $html_out; } function show_memusage () { global $app; $html_out .= '
'; $fd = fopen ("/proc/meminfo", "r"); while (!feof($fd)) { $buffer .= fgets($fd, 4096); } fclose($fd); $meminfo = split("\n",$buffer); foreach($meminfo as $mline){ if($x > 2 and trim($mline) != "") { $mpart = split(":",$mline); $html_out .= ''; } $x++; } $html_out .= '
'.$mpart[0].': '.$mpart[1].'
'; return $html_out; } function show_cpu () { global $app; $html_out .= '
'; $n = 0; if(is_readable("/proc/cpuinfo")) { if($fd = fopen ("/proc/cpuinfo", "r")) { while (!feof($fd)) { $buffer .= fgets($fd, 4096); $n++; if($n > 100) break; } fclose($fd); } } $meminfo = split("\n",$buffer); if(is_array($meminfo)) { foreach($meminfo as $mline){ if(trim($mline) != "") { $mpart = split(":",$mline); $html_out .= ''; } } $x++; } $html_out .= '
'.$mpart[0].': '.$mpart[1].'
'; return $html_out; } function show_services () { global $app; $html_out .= '
'; // Checke Webserver if(_check_tcp('localhost',80)) { $status = 'Online'; } else { $status = 'Offline'; } $html_out .= ''; // Checke FTP-Server if(_check_ftp('localhost',21)) { $status = 'Online'; } else { $status = 'Offline'; } $html_out .= ''; // Checke SMTP-Server if(_check_tcp('localhost',25)) { $status = 'Online'; } else { $status = 'Offline'; } $html_out .= ''; // Checke POP3-Server if(_check_tcp('localhost',110)) { $status = 'Online'; } else { $status = 'Offline'; } $html_out .= ''; // Checke BIND-Server if(_check_tcp('localhost',53)) { $status = 'Online'; } else { $status = 'Offline'; } $html_out .= ''; // Checke MYSQL-Server //if($this->_check_tcp('localhost',3306)) { $status = 'Online'; //} else { //$status = 'Offline'; //} $html_out .= ''; $html_out .= '
Web-Server:
'.$status.'
FTP-Server:
'.$status.'
SMTP-Server:
'.$status.'
POP3-Server:
'.$status.'
DNS-Server:
'.$status.'
mySQL-Server:
'.$status.'
'; return $html_out; } function _check_tcp ($host,$port) { $fp = @fsockopen ($host, $port, &$errno, &$errstr, 2); if ($fp) { return true; fclose($fp); } else { return false; fclose($fp); } } function _check_udp ($host,$port) { $fp = @fsockopen ('udp://'.$host, $port, &$errno, &$errstr, 2); if ($fp) { return true; fclose($fp); } else { return false; fclose($fp); } } function _check_ftp ($host,$port){ $conn_id = @ftp_connect($host, $port); if($conn_id){ @ftp_close($conn_id); return true; } else { @ftp_close($conn_id); return false; } } ?>