init III
This commit is contained in:
29
Windows Webserver via Perl/htdocs/index.html
Normal file
29
Windows Webserver via Perl/htdocs/index.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<a href=test.html>TEST</a>
|
||||
<hr>
|
||||
<a href=gibtsnicht.html>404</a>
|
||||
<hr>
|
||||
<a href="perl.html">Perl</a>
|
||||
<hr>
|
||||
Test by AW; index.html
|
||||
|
||||
<br>
|
||||
Form per GET<br>
|
||||
<form action="http://localhost:88/test.pl" method="get">
|
||||
<input name="vorname" type="text" size="30" maxlength="30">
|
||||
<input name="nachname" type="text" size="30" maxlength="30">
|
||||
<input type="submit" value="Absenden">
|
||||
</form>
|
||||
|
||||
Form per POST<br>
|
||||
<form action="http://localhost:88/test.pl" method="post">
|
||||
<input name="vorname" type="text" size="30" maxlength="30">
|
||||
<input name="nachname" type="text" size="30" maxlength="30">
|
||||
<input type="submit" value="Absenden">
|
||||
</form>
|
||||
<hr>
|
||||
</body>
|
||||
</html>
|
||||
15
Windows Webserver via Perl/htdocs/perl.html
Normal file
15
Windows Webserver via Perl/htdocs/perl.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<a href=index.html>INDEX</a>
|
||||
<hr>
|
||||
<a href=test.html>TEST</a>
|
||||
<hr>
|
||||
<a href=gibtsnicht.html>404</a>
|
||||
<hr>
|
||||
<perl>print "Hallo";</perl>
|
||||
<hr>
|
||||
Test by AW; perl.html
|
||||
</body>
|
||||
</html>
|
||||
13
Windows Webserver via Perl/htdocs/test.html
Normal file
13
Windows Webserver via Perl/htdocs/test.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<a href=index.html>INDEX</a>
|
||||
<hr>
|
||||
<a href=gibtsnicht.html>404</a>
|
||||
<hr>
|
||||
<a href="perl.html">Perl</a>
|
||||
<hr>
|
||||
Test by AW; test.html
|
||||
</body>
|
||||
</html>
|
||||
20
Windows Webserver via Perl/htdocs/test.pl
Normal file
20
Windows Webserver via Perl/htdocs/test.pl
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/perl
|
||||
|
||||
print "
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<a href=index.html>INDEX</a>
|
||||
<hr>
|
||||
<a href=gibtsnicht.html>404</a>
|
||||
<hr>
|
||||
<a href='perl.html'>Perl</a>
|
||||
<hr>
|
||||
Test by AW; test.pl\n";
|
||||
|
||||
print "<br>#<br>@ARGV<br>#<br>\n";
|
||||
|
||||
print "</body>
|
||||
</html>
|
||||
";
|
||||
38
Windows Webserver via Perl/waw.log
Normal file
38
Windows Webserver via Perl/waw.log
Normal file
@@ -0,0 +1,38 @@
|
||||
GET ./htdocs/index.html;OK
|
||||
Type of file unknown
|
||||
GET ./htdocs/favicon.ico;404
|
||||
GET ./htdocs/index.html;OK
|
||||
Type of file unknown
|
||||
GET ./htdocs/favicon.ico;404
|
||||
GET ./htdocs/index.html;OK
|
||||
Type of file unknown
|
||||
GET ./htdocs/favicon.ico;404
|
||||
GET ./htdocs/index.html;OK
|
||||
Type of file unknown
|
||||
GET ./htdocs/favicon.ico;404
|
||||
GET ./htdocs/index.html;OK
|
||||
Type of file unknown
|
||||
GET ./htdocs/favicon.ico;404
|
||||
GET ./htdocs/index.html;OK
|
||||
Type of file unknown
|
||||
GET ./htdocs/favicon.ico;404
|
||||
GET ./htdocs/index.html;OK
|
||||
Type of file unknown
|
||||
GET ./htdocs/favicon.ico;404
|
||||
GET ./htdocs/favicon.ico;404
|
||||
GET ./htdocs/index.html;OK
|
||||
Type of file unknown
|
||||
GET ./htdocs/favicon.ico;404
|
||||
GET ./htdocs/index.html;OK
|
||||
Type of file unknown
|
||||
GET ./htdocs/favicon.ico;404
|
||||
GET ./htdocs/index.html;OK
|
||||
Type of file unknown
|
||||
GET ./htdocs/favicon.ico;404
|
||||
GET ./htdocs/favicon.ico;404
|
||||
GET ./htdocs/index.html;OK
|
||||
Type of file unknown
|
||||
GET ./htdocs/favicon.ico;404
|
||||
GET ./htdocs/index.html;OK
|
||||
Type of file unknown
|
||||
GET ./htdocs/favicon.ico;404
|
||||
BIN
Windows Webserver via Perl/wawrun.exe
Normal file
BIN
Windows Webserver via Perl/wawrun.exe
Normal file
Binary file not shown.
33
Windows Webserver via Perl/wawrun.perlapp
Normal file
33
Windows Webserver via Perl/wawrun.perlapp
Normal file
@@ -0,0 +1,33 @@
|
||||
#!C:\Program Files\ActiveState Perl Dev Kit 9.0\bin\perlapp-gui.exe
|
||||
PAP-Version: 1.0
|
||||
Packer: ..\Program Files\ActiveState Perl Dev Kit 9.0\bin\perlapp.exe
|
||||
Script: wawrun.pl
|
||||
Cwd: C:\Webserver
|
||||
Clean: 0
|
||||
Date: 2012-02-13 08:57:03
|
||||
Debug:
|
||||
Dependent: 0
|
||||
Dyndll: 0
|
||||
Exe: wawrun.exe
|
||||
Force: 0
|
||||
Gui: 0
|
||||
Hostname: Andre-W7
|
||||
Manifest:
|
||||
No-Compress: 0
|
||||
No-Logo: 0
|
||||
Runlib:
|
||||
Shared: none
|
||||
Tmpdir:
|
||||
Verbose: 0
|
||||
Version-Comments:
|
||||
Version-CompanyName:
|
||||
Version-FileDescription:
|
||||
Version-FileVersion:
|
||||
Version-InternalName:
|
||||
Version-LegalCopyright:
|
||||
Version-LegalTrademarks:
|
||||
Version-OriginalFilename:
|
||||
Version-ProductName:
|
||||
Version-ProductVersion:
|
||||
Warnings: 0
|
||||
Xclude: 0
|
||||
145
Windows Webserver via Perl/wawrun.pl
Normal file
145
Windows Webserver via Perl/wawrun.pl
Normal file
@@ -0,0 +1,145 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use POE;
|
||||
use POE::Kernel;
|
||||
use POE::Loop::Select;
|
||||
use POE::Resource;
|
||||
use POE::Resource::Aliases;
|
||||
use POE::Resource::Events;
|
||||
use POE::Resource::Extrefs;
|
||||
use POE::Resource::FileHandles;
|
||||
use POE::Resource::SIDs;
|
||||
use POE::Resource::Sessions;
|
||||
use POE::Resource::Signals;
|
||||
#use POE::Resource::Statistics;
|
||||
use POE::Component::Server::TCP;
|
||||
|
||||
use strict;
|
||||
|
||||
my $logfile = './waw.log';
|
||||
my $configfile = './waw.conf';
|
||||
my $def_index = "index.html";
|
||||
my $def_port = 88;
|
||||
my $def_htdocs = './htdocs/';
|
||||
my %filetype = (htm=>'HTML', html=>'HTML', pl=>'PERL', php=>'PHP'); # extension => type
|
||||
my %interpreter = (PERL=>'/usr/bin/perl');
|
||||
|
||||
# turn on autoflush
|
||||
$|=1;
|
||||
|
||||
TCPServer ();
|
||||
POE::Kernel->run();
|
||||
|
||||
sub Log {
|
||||
my $msg = shift;
|
||||
open(my $f, ">>$logfile") or die $!;
|
||||
print $f "$msg";
|
||||
close $f;
|
||||
print "$msg";
|
||||
}
|
||||
|
||||
sub TCPServer {
|
||||
#my %daten=%{$_[0]};
|
||||
POE::Component::Server::TCP->new(
|
||||
Alias => "SERVER",
|
||||
Port => $def_port,
|
||||
ClientInput => sub {
|
||||
my ($session, $heap, $input) = @_[SESSION, HEAP, ARG0];
|
||||
print "$input\n";
|
||||
# GET /index.html HTTP/1.1
|
||||
if ($input =~ /GET|POST.*HTTP/) {
|
||||
my $file="";
|
||||
my $param="";
|
||||
my $method="";
|
||||
($method, $file) = $input =~ /(GET|POST) \/(.*) HTTP/; # lese anzuzeigende datei aus GET aus
|
||||
# GET,POST abfangen
|
||||
if ($file =~ /\?/) {
|
||||
($file,$param) = $file =~ /(.*)\?(.*)/;
|
||||
}
|
||||
if ($file eq "") { # wenn keine datei angegeben standard datei öffnen, normalerweise index.html
|
||||
$file = $def_index;
|
||||
}
|
||||
$file = "$def_htdocs$file";
|
||||
|
||||
Log ("$method $file;");
|
||||
|
||||
my $senddata;
|
||||
my $error=0;
|
||||
my @ausgabe=();
|
||||
if (-e "$file") { # existiert angeforderte datei diese öffnen
|
||||
Log("OK\n");
|
||||
# Dateityp?
|
||||
my $type = checkfiletype($file);
|
||||
if ($type ne "UNKNOWN") {
|
||||
@ausgabe = interpret ($type, $file, $param);
|
||||
}
|
||||
else {
|
||||
Log("Type of file unknown\n");
|
||||
}
|
||||
#$heap->{client}->put($input);
|
||||
}
|
||||
else { # fehler 404 wenn datei nicht existiert
|
||||
$senddata = error_html("404 Not found!");
|
||||
Log("404\n");
|
||||
$error=1;
|
||||
}
|
||||
|
||||
# Datei ausgelesen und kein Fehler
|
||||
if (!$error) {
|
||||
# Parsen auf perl Tags
|
||||
$senddata = parseperl(@ausgabe);
|
||||
}
|
||||
# Ausgabe zum Browser senden
|
||||
print "###\n$senddata\n###\n"; ##########################
|
||||
$heap->{client}->put("Content-type: text/html\n");########################
|
||||
$heap->{client}->put("$senddata\n");
|
||||
$_[KERNEL]->yield("shutdown");
|
||||
}
|
||||
else {
|
||||
#$heap->{client}->put($input);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
sub error_html {
|
||||
return "<html>\n<body>\n<h1>$_[0]</h1>\n</body>\n</html>\n";
|
||||
Log ()
|
||||
}
|
||||
|
||||
sub parseperl {
|
||||
my $ret;
|
||||
foreach (@_) {
|
||||
$ret.=$_;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
sub checkfiletype {
|
||||
my $type = '';
|
||||
my $ext;
|
||||
($ext)=$_[0]=~/\.(.*)?/;
|
||||
$type = $filetype{$ext};
|
||||
$type = 'UNKNOWN' if($type eq '');
|
||||
return $type;
|
||||
}
|
||||
|
||||
sub interpret {
|
||||
# Übergabe Filetype, File, Parameter
|
||||
my @ausgabe;
|
||||
if ($_[0] eq 'HTML') {
|
||||
open HTML, "<$_[1]";
|
||||
foreach (<HTML>) {
|
||||
push(@ausgabe, $_);
|
||||
}
|
||||
close HTML;
|
||||
}
|
||||
else {
|
||||
#Parameter auseinander nehmen und per Kommandozeile wieder übergeben
|
||||
#name=inhalt1&name2=inhalt2....
|
||||
my @parameter = split /&/, $_[2];
|
||||
#print "\n\n @parameter\n\n";
|
||||
@ausgabe = `$interpreter{$_[0]} $_[1] @parameter`;
|
||||
}
|
||||
return @ausgabe;
|
||||
}
|
||||
Reference in New Issue
Block a user