I made this blog from code.  The password is Turners.

http://www.angelfire.com/scifi2/zpt/blog.html


The top part, a form, sends data to a Perl program by the post method.  The 
bottom script part of the HTML page displays an xml file.  You can view the 
HTML code by selecting view source.


The Perl program receives the string of data from the form. The data from the 
form is separated by & and = signs.  It is separated and feed into variables.  
From there it is popped pops it into an array and stored it in a file linked 
below. 


http://www.angelfire.com/scifi2/zpt/cgi-bin/BlogRelData.txt


The Perl program then goes on print this xml file.  This is the file that the 
HTML program reads.


http://www.angelfire.lycos.com/cgi-auth/webshell


If you have web page host that allows cgi Perl scripts you can do the same.
Angelfire allows me post scripts and web pages for $5 month.  I will send you a 
copy of the
Perl program upon request.  This was a challenge for me but I did it.  I cut 
and pasted it below.
It may be cut off if it is too long.


Frank Znidarsic



#!C:\Perl\bin\perl


#this program reads a string sent by the post method 
#and makes an xml file from it.  This xml file that is
#displayed in HTML as a blog.
$LengthOfArray=51;
print "Content-type:text/html\n\n";


#dummey input test string
$input="reset input variable";


#count test variable
$count=201;


#read input string sent by get method
$input =$ENV{'QUERY_STRING'};


#get rid of hex packing and other chars
$input =~ s/%(..)/pack("c",hex($1))/eg;
$input =~ tr|;|.|;
$input =~ tr|'| |;
$input =~ tr|"| |;


#security replace all control characters with a underbar commed out takes out 
my split stuff
#$input =~ tr/\000-\047/_/;


#split the incoming string string 
($name,$password, $comment, $select) = split(/&/,$input);


#split it again at equal sign relationship
($dummey,$name) = split(/=/,$name);
#replace a + with a space
$name =~ tr|+| |;
if(!$name)
{$name ="no_data";}


#split it again at equal sign relationship
($dummey,$comment) = split(/=/,$comment);
#replace a + with a space
$comment =~ tr|+| |;
if(!$comment)
{$comment ="no_data";}


#split it again at equal sign relationship
($dummey,$password) = split(/=/,$password);
#replace a + with a space
$name =~ tr|+| |;
if(!$passowrd)
{$passowrd ="no_data";}


#split it again at equal sign relationship
($dummey,$select) = split(/=/,$select);
#replace a + with a space
$select =~ tr|+| |;
if(!$select)
{$select ="no_data";}


# check to see if password entered 
if($password ne "Turners")
{$name ="Blocked!";
$comment ="Comment blocked, Wrong Password!";
$select ="Blocked!";}
if(!$comment)
{$name ="no_data";}


# open the relational data file for input 
..........................................................
open(RELDATA, "<BlogRelData.txt");
flock(RELDATA, 2);
@array = <RELDATA>;
flock(RELDATA, 8);
close (RELDATA);


($count, $xname, $xcomment, $date, $xselect)=split(/;/,$array[0]);


#count data test and reset
if($count eq "")
{$count ="0";}
else
{$count = $count+1;}
if($count > 1000)
{$count ="0";}


# compose a period delimited date variable
 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =                        
                      gmtime(time);


$mon=$mon+1;


#convert hour to eastern standard time
if($hour <= 5)
{
$hour=$hour+19;
$mday=$mday-1;
}
else
{$hour=$hour-5;}


$date = "Month-"."$mon"." Day-"."$mday"." Hour-"."$hour";


# compose a period delimited composite variable
$data = "$count".";"."$name".";"."$comment".";"."$date".";"."$select";


#Limit the length of the array 
$alength = @array;
if($alength >= $LengthOfArray)
{pop(@array);}


#unshift relational data file into array
unshift(@array,  $data);


#output the relational data------------------------------------------------


if($count >= 0 && $count < 100000)
{
open(RESULT, ">BlogRelData.txt");
flock(RESULT, 2);


foreach $array(@array)
{
$array =~ s/\n//g;
print RESULT $array;
print RESULT "\n";
}


flock(RESULT, 8);
close (RESULT);




}
#xml document code____________________________________________________


#open the xml file for 
output..........................................................
open(XML, ">BlogData.xml");
flock(XML, 2);


print XML "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
print XML "<Namefile>\n";


# xml output sequence...........................


for( $i=0; $i < $alength; $i=$i+1 )
{


$packet =  $array[$i];


($count, $xname, $xcomment, $xdate, $xselect)=split(/;/, $packet);




if($xpages eq "")
{$xpages ="no data";}




#security replace all control characters with an underbar
$xname =~ s/<(([^>]|\n)*)>/_/g;
$xcomment =~ s/<(([^>]|\n)*)>/_/g;
$xdate =~ s/<(([^>]|\n)*)>/_/g;
$xselect =~ s/<(([^>]|\n)*)>/_/g;




# xml output sequence...........................


print XML "<cd>\n";
print XML "<visitor>";
print XML  $count;
print XML "</visitor>\n";
print XML "<date>";
print XML "$xdate";
print XML "</date>\n";
print XML "<name>";
print XML "$xname";
print XML "</name>\n";
print XML "<comment>";
print XML   "$xcomment";
print XML "</comment>\n";
print XML "<select>";
print XML  "$xselect";
print XML "</select>\n";
print XML "</cd>\n";
}


print XML "</Namefile>";
flock(XML, 8);
close (XML);


#sleep for seconds
sleep(1);


# REDIRECT TO TABLE HTML..................




print "<html>\n";
print "<script>\n";
print 
"window.location.replace(\"http://www.angelfire.com/scifi2/zpt/blog.html\";)";
print "</script>\n";
print "</html>";



#end of Perl program


Reply via email to