@conf = (); @conf[0]="C:/Perl/PerlHTTP/"; # base directory (root) of http system @conf[1]="www/"; # name of folder containing web files lib 'C:/perl/perlhttp/'; require "funct.pm"; chdir(@conf[0].@conf[1]) or die("Failed to find root web-directory"); print "Console Operating Colours\n"; print "xn :: x=background, n=foreground :: e.g- 01 (black background behind blue text)\n"; print "0 = black\n1 = blue\n2 = green\n3 = aqua\n4 = red\n5 = purple\n6 = yellow\n7 = grey\n8 = dark-grey\n9 = light-blue\n"; print "A = light-green\nB = light-aqua\nC = light red\nD = light purple\nE = light-yellow\nF = bright-white\n"; print "[use 00 to use current]\n"; print "Select Colours: "; $colour = ; if ($colour ne "00") { system("color ".$colour); } use IO::Socket; my $socket = new IO::Socket::INET ( LocalHost=>"localhost", LocalPort=>80, Proto=>tcp, Listen=>1, Reuse=>1, ) or die("Couldnt connect"); goto connects; connects: { print "Waiting on http connections...\n"; my $sock = $socket->accept(); @data = readsock($sock); while(<$sock>){ print "Http connection received...\n"; print $sock @data[2]." 200 Handling request...\r\n"; print $sock "Date: dunno .. do you?\r\n"; print $sock "Server: PerlHTTP V1a\r\n"; print $sock "MIME-version: 1.0\r\n"; print $sock "Content-type: text/html;text/text;text/css;image/jpg;image/gif;image/jpeg\r\n"; print $sock "Last-Modified: when i felt like it\r\n"; print $sock "\r\n"; my $filereq = substr(@data[1],1); if (@data[0] eq "GET") { if(@data[1]=="/") { if(-e "index.html") { @indexfile = getfile("index.html"); print $sock @indexfile; } else { nofile($sock); } } elsif(-e $filereq) { @reqfile = getfile($filereq); print $sock @reqfile; } elsif(!-e $filereq) { if(-e "index.html") { @indexfile = getfile("index.html"); print $sock @indexfile; } else { nofile($sock); } } } else { print $sock "Method not implemented yet."; } open(DATALOG, ">../datalog.txt") or die("failed data log"); foreach $i (@datanew) { print DATALOG $i . "\n"; } close(DATALOG); print "Page request dealt with appropriately\n"; close($sock); } goto connects; }