AOA Forums AOA Forums AOA Forums Folding For Team 45 AOA Files Home Front Page Become an AOA Subscriber! UserCP Calendar Memberlist FAQ Search Forum Home

Go Back   AOA Forums > Software > Programming and Assembly Language

Programming and Assembly Language Please read this Topic's rules!!

LinkBack Thread Tools Rate Thread
  #1 (permalink)  
Old 28th February, 2003, 10:18 AM
loop's Avatar
Join Date: December 2001
Location: Under bed with pan of water and 2 mines.
Posts: 866

My News posting program in cgi


#Determines whether the data sent was from Get or POST.
@pairs = split(/&/,
elsif ($ENV{'REQUEST_METHOD'} eq 'POST')
read (STDIN, $buffer,
@pairs = split(/&/, $buffer);
print "Content-type: text/html\n\n";
print "<p>Use Post or Get";

#Splits up the data into pairs and decodes the hex.
foreach $pair (@pairs)
($key, $value) = split (/=/, $pair);
$key =~ tr/+/ /;
$key =~ s/%([a-fA-F0-9] [a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9] [a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~s/<!--(.|\n)*-->//g;

#Converts characters such as "!" and "?" from their hex code to proper characters.
$value =~s/%3F/\?/g;
$value =~s/%21/\!/g;
$value =~s/%25/%/g;
$value =~s/%22/"/g;
$value =~s/%A3/£/g;
$value =~s/%24/\$/g;
$value =~s/%28/(/g;
$value =~s/%29/)/g;
$value =~s/%5B/[/g;
$value =~s/%5D/]/g;
$value =~s/%40/@/g;
$value =~s/%3A/:/g;
$value =~s/%2C/,/g;
$value =~s/%3D/=/g;
$value =~s/%2F/\//g;
$value =~s/%0D%0A/<br>/g;
if ($formdata{$key}) {
$formdata{$key} .= ", $value";
$formdata{$key} = $value;

#Authenticates User.
if (($formdata{'user'} eq "robb") && ($formdata{'pass'} eq "harrop"))

print "Content-type: text/html";
print "User not allowed access";

#Gets the date and time from the server and puts it into 9 variables.
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isd st)=localtime(time);
$year += 1900;
$mon += 1;

#Copies the current index into an array for storage.
open(INDEX, "<index.html");
@oldindex = <INDEX>;

#Calculates the length of the index.
$length = @oldindex;

#Deletes the old index.

#Output for user.
print "Content-type: text/html\n\n";
print "<a href=index.html>Click here for your msg. You may have to refresh your broweser once you get there.</a>";

#Creates the new index with the updated text.
open(NEWINDEX, ">>index.html");
flock(NEWINDEX, 2);
print NEWINDEX "@oldindex[0..70]";
print NEWINDEX "\n<tr><td bgcolor=\"cccccc\" width=130>";
print NEWINDEX "$mday/$mon/$year<br>";
print NEWINDEX "$formdata{'title'}";
print NEWINDEX "</td><td bgcolor=\"cccccc\" width=* valign=top>";
print NEWINDEX "$formdata{'text'}";
print NEWINDEX "</td></tr>";
print NEWINDEX "@oldindex[71..$length]";
flock(NEWINDEX, 8);

My only problem is that the program refuses to access files in any other place than its own folder, it just flatly refuses, even if I give the full path. The code that converts the hex at the top is stolen from a book by Elizabeth Castro entitled "Perl and CGI for the Wolrd Wide Web". That book has been brilliant.
Are you on drugs? If not should you be on drugs?
Warranties are there to invalidate.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 23rd March, 2003, 05:46 PM
cloasters's Avatar
Asst. BBS Administrator
Join Date: September 2001
Location: Location, Location
Posts: 21,956

When the world will be better.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Good news and bad news Strongwolf AOA's Community Support 529 15th March, 2008 07:28 PM
Well...I'm posting this from... Logan OS, Software, Firmware, and BIOS 9 21st April, 2005 09:16 AM
Good news, bad news. mookydooky Mookydooky's Just for laughs! 1 13th January, 2004 01:34 AM
Good News, Bad news. mookydooky Mookydooky's Just for laughs! 0 21st September, 2002 04:00 AM
Good News, Bad News Pinky Random Nonsense! 12 29th April, 2002 01:31 PM

All times are GMT +1. The time now is 03:47 PM.

Copyright ©2001 - 2023, AOA Forums
Don't Click Here Don't Click Here Either

Search Engine Friendly URLs by vBSEO 3.3.0