Version 1.02 verfügbar
-Bugfixes (Seitentitel und Statuszeile :roll: )
-New Features (Killfunktion)
Hier herunterladen.
<?php
/*************************************
* ftp-online für proftpd *
* PHP-Verbindungsviewer für proftpd *
* ftp-online@woerstenfeld.de *
* Version 1.02 - 20.09.2003 23:56 *
*************************************/
#### Konfiguration ####
$refresh = 10; # Alle x Sekunden neu laden
$title = "--=FTP-Online=--"; # Fenstertitel
$font = "Verdana"; # Schriftart
$headline = "Offene Verbindungen"; # Ueberschrift
$befehl = "/usr/local/bin/ftpwho -v"; # Auszufuehrender Befehl
$killbefehl = "/bin/kill -9"; # Auszufuehrender kill-Befehl
$tempfile = "/tmp/ftp.online"; # Temporäre Datei
$button1 = '<IMG alt="" src="start.gif" width="64" height="25" border="0">'; # Startknopf
$button2 = '<IMG alt="" src="stop.gif" width="64" height="25" border="0">'; # Stoppknopf
$img_server = '<IMG alt="" src="server.gif" width="16" height="16">'; # Serverbild
$img_client = '<IMG alt="" src="client.gif" width="16" height="16">'; # Benutzerbild
$img_location = '<IMG alt="" src="location.gif" width="16" height="16">'; # Verzeichnisbild
$img_status = '<IMG alt="" src="status.gif" width="16" height="16">'; # Status
$img_pid = '<IMG alt="" src="pid.gif" width="16" height="16">'; # PID
$img_user = '<IMG alt="" src="user.gif" width="16" height="16">'; # User
$STOR = "Der Benutzer lädt Daten hoch";
$RETR = "Der Benutzer lädt Daten herunter";
$idle = "Die Verbindung ruht";
$auth = "Der Benutzer meldet sich gerade an";
$nouser = "Es ist niemand mit dem Server verbunden.";
#### Programm ####
if (!isset($_GET["loop"]))
{
$do_refresh = true;
$start_stop = "?loop=0";
$button = $button2;
}
else
{
$start_stop = "";
$button = $button1;
}
$command = shell_exec("$befehl > $tempfile");
$handle = fopen ("$tempfile", "r");
if ($handle)
{
$content = "<FONT size=\"-2\" face=\"$font\">\n";
while (!feof ($handle))
{
$buffer = fgets($handle, 4096);
if (strstr($buffer,"\n")) $content .= "<BR>";
// if (strstr($buffer,"Service class")) $content .= "<HR>";
// $buffer = str_replace("Service class -", " ",$buffer);
// $buffer = str_replace("users", "Benutzer",$buffer);
$buffer = str_replace("client:", "$img_client<font color=blue><b> Benutzer:</b></font>",$buffer);
$buffer = str_replace("server:", "$img_server<font color=blue><b> Server:</b></font>",$buffer);
$buffer = str_replace("location:", "$img_location<font color=blue><b> Verzeichnis:</b></font>",$buffer);
if (strstr($buffer,"STOR") || strstr($buffer,"RETR") || strstr($buffer,"idle") || strstr($buffer,"authenticating") || strstr($buffer,"DELE"))
{
$pieces = explode(" ", $buffer);
$PID = $pieces[0];
$username = $pieces[1];
if ($_GET["kill_pid"] == $PID)
{
$buffer = str_replace("$PID", "$img_pid<font color=red><b> Versuche den Prozess $PID zu töten...</font></b><BR>",$buffer);
}
else
{
$buffer = str_replace("$PID", "$img_pid<font color=blue><b> Prozess-ID:</b></font> <a onmouseover=\"self.status='Prozess töten'; return true;\" href=\"?kill_pid=$PID&cs=".(md5(date("h:i:$PID")))."\"><font color=\"#000000\">$PID</FONT></a><BR>",$buffer);
}
$buffer = str_replace("$username", "$img_user<font color=blue><b> Loginname:</b></font> $username<BR>$img_status<font color=blue><b> Status:</b></font>",$buffer);
$buffer = "".$buffer;
}
$buffer = str_replace("RETR", "<font color=red><b>$RETR</b></font>",$buffer);
$buffer = str_replace("idle", "<font color=green><b>$idle</b></font>",$buffer);
$buffer = str_replace("STOR", "<font color=red><b>$STOR</b></font>",$buffer);
$buffer = str_replace("authenticating", "<font color=brown><b>$auth</b></font>",$buffer);
$buffer = str_replace("no users connected", "<font color=green><b>$nouser</b></font>",$buffer);
if (strstr($buffer,"$STOR") || strstr($buffer,"$RETR") || strstr($buffer,"$idle") || strstr($buffer,"$nouser") || strstr($buffer,"$auth"))
{
$content .= "<b><nobr>".$buffer."</nobr></b>";
}
elseif (strstr($buffer,"users"))
{
$content .= "<nobr><font color=\"#4040ff\"><B>".$buffer."</B></font></nobr>";
}
else
{
$content .= "<nobr><font color=\"#404040\">".$buffer."</font></nobr>";
}
}
$content .= "</FONT>\n";
fclose ($handle);
$content .= "<HR>";
unlink("$tempfile");
}
if (isset($_GET["kill_pid"]))
{
if ((md5(date("h:i:".$_GET["kill_pid"]))) === $_GET["cs"])
{
$command = shell_exec("$killbefehl ".intval($_GET["kill_pid"]));
$refresh = 10;
$msg = "<CENTER><b><FONT face=\"arial\" color=\"#c00000\">Bitte warten...</FONT></b><BR></CENTER>";
}
else
{
$msg = "<b><FONT face=\"arial\" color=\"#c00000\">Ungültiger Aufruf...</FONT></b><BR>";
}
}
$body = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
$body .= " <HTML>\n";
$body .= " <HEAD>\n";
$body .= " <META http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n";
if ($do_refresh == true ) $body .= " <META HTTP-EQUIV=Refresh CONTENT=\"$refresh; URL=http://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]."\">\n";
$body .= " <TITLE>$title</TITLE>\n";
$body .= " </HEAD>\n";
$body .= " <BODY onload=\"window.defaultStatus='".$title."';\">\n";
$body .= " <A href=\"http://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"].$start_stop."\"><FONT face=\"$font\" size=\"-2\">$button</FONT></A>\n";
$body .= " <BR>\n";
$body .= " <FONT face=\"$font\"><BIG>$headline<BIG></FONT>\n";
$body .= " $msg\n";
$body .= " <BR>\n";
$body .= " ".$content."<BR>\n";
$body .= " </BODY>\n";
$body .= " </HTML>\n";
echo $body;
### ENDE ###
?>