Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Kante« (15.01.2006, 17:56)
Benutzerinformationen überspringen
Prof. Dr. Schlaumeier
Wohnort: Mecklenburg, zur Entwicklungshilfe in Chemnitz/Sachsen ;-)
Benutzerinformationen überspringen
Prof. Dr. Schlaumeier
Wohnort: Mecklenburg, zur Entwicklungshilfe in Chemnitz/Sachsen ;-)
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
#!/usr/bin/perl # DEFAULTS $HTTP_HEADER = "Wollmilchsau (Windows)"; $HTTP_REQUEST = 1; $LISTEN_PORT = 2345; $LOG_LEVEL = 10; $LOG_FILE = "log/wollmilchsau.log"; open FH,"etc/wollmilchsau.conf" or die "Can't open Configurationfile\n"; @settings=<FH>; close FH; foreach $zeile(@settings) { if ($zeile =~ m/(\S+)\s+\=\s+(.*;)/) { $EVAL="\$$1 = $2"; eval($EVAL); } } use IO::Socket; my $myport=2345; my $server=IO::Socket::INET->new(LocalPort=>$LISTEN_PORT, Type =>SOCK_STREAM, Reuse =>1, Listen =>10); my $client; my $client_adress; my $data; $http_response_header="HTTP/1.1 200 OK\nDate: Mon, 27 Sep 1999 21:23:20 GMT\nServer: Wollmilchsau (Windows)\nLast-Modified: Sun, 26 Sep 1999 16:40:44 GMT\nETag: "4b005-1616-37ee4c8c"\nAccept-Ranges: bytes\nContent-Length: 5654\nConnection: close\nContent-Type: text/html\n\n <html><head><title>Eierlegende Wollmilchsau</title></head><body>"; $http_response_footer="</body></html>"; while ( ($client,$client_adress) = $server->accept() ) { my( $client_port,$client_iaddr) = sockaddr_in($client_adress); my $client_dot_ip = inet_ntoa($client_iaddr); my $client_name = gethostbyaddr($client_iaddr,AF_INET); $client->recv($data,10000); print "$data"; if (($data =~ m/GET (.*) HTTP/)) { # Integrated webserver if ($HTTP_REQUESTS) { print "Received HTTP-Request\n"; # $1= e.g "/index.html".... print $client "$http_response_header\n"; open FHHTTP,"etc/http/index.html"; @REPLY = <FHHTTP>; close FHHTTP; foreach $line(@REPLY) { print $client "$line"; } } } else { if ($data =~ m/(\S+)\s+(\S*)\s*(\S*)\s*(.*)/) { print "$data\n"; $plugin = $1; $command=$2; $item = $3; $options = $4; if ($3 eq "ALL") {$item="";} $options=$4; $execute = "bin\\perl plugins\\$plugin".".pl -$command $item $options"; print "EXECUTING: $execute\n"; print "Received Request\n"; print "\n\n"; print $client `$execute`; } else { print "wrong usage ($data) from: $client_iaddr\n"; print $client "Usage of Wollmilchsau:<COMMAND> <ITEM> <OPTIONS>\n" } } close $client; close FH_LOG; } close $server; |