Webspace & Domain Names This is a discussion on, CGi problems within the Freedom2Surf forum; I am trying to creata cgi message board, however when you submit the sorm i get: The requested method POST ...

Reply
 
LinkBack Thread Tools
Old 26-11-2003, 08:30 PM   #1
Tiscali User Member
 
Thee_Psycho's Avatar
 
Join Date: Oct 2003
Location: Surrey
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy CGi problems

I am trying to creata cgi message board, however when you submit the sorm i get:

The requested method POST is not allowed for the URL /cgi-bin/easymsgb.

I have created a folder in my webspace called cgi-bin, just to try and keep my site tidy. I thought it was a rights issue, the CGI-Bin and easymsgb shoudl have right of CHMOD 755. But I have stuck them on this and got the above, so i put it on CHMOD 777. Still no use.

Any ideas where I may be going wrong?

One thing i am not sure about is if my script files should have an extension on, also not 100% sure about this whole having a folder called my username or URL. should i include this folder name in any paths?
Attached Files
File Type: txt easymsgb.txt (9.0 KB, 106 views)
Thee_Psycho is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 26-11-2003, 08:44 PM   #2
Tiscali User Member
 
Thee_Psycho's Avatar
 
Join Date: Oct 2003
Location: Surrey
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
OK i have now added the .pl extentions to my files and updated the form etc accordingly. I now get a different error:

The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@matsimons.f2s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Am i closer or further awway from resolving my problem??
Thee_Psycho is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 26-11-2003, 08:50 PM   #3
Site Founder
 
Justin's Avatar
 
Join Date: May 2002
Posts: 4,355
Thanks: 4
Thanked 4 Times in 4 Posts
Hi,

Am now looking into thios on a test freedom2surf account, and will get back to you asap.
__________________
Justin
Tiscali User
Justin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 26-11-2003, 08:55 PM   #4
Tiscali User Member
 
Thee_Psycho's Avatar
 
Join Date: Oct 2003
Location: Surrey
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
You are a star.. i think its just me being silly, not seeing the wood for the trees. Or maybe its staring at a monitor for 13 hours!


forgot to say, i got the script from http://www.geocentral.net/colscripts/emsgb/index.html

Last edited by Thee_Psycho; 26-11-2003 at 09:01 PM.
Thee_Psycho is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 26-11-2003, 09:03 PM   #5
Site Founder
 
Justin's Avatar
 
Join Date: May 2002
Posts: 4,355
Thanks: 4
Thanked 4 Times in 4 Posts
Yeah, I've just downloaded it and am looking at it, I know why it's giving the method not allowed errors, it's because the files don't have an extensition by default and the F2S webserver doesn't like that as it's a non-standard way of using/coding CGI Scripts, though I'm trying a workaround now which should be done soon, though I'm expecting a phonecall any minute so it might take a bit longer.
__________________
Justin
Tiscali User
Justin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 26-11-2003, 09:11 PM   #6
Site Founder
 
Justin's Avatar
 
Join Date: May 2002
Posts: 4,355
Thanks: 4
Thanked 4 Times in 4 Posts
Right, this is what you need in your two files:

post.html:
PHP Code:
<HTML>
<
HEAD>
<
TITLE>Message BoardPost A Message</TITLE>
</
HEAD>
<
BODY BACKGROUND="bg.gif" TEXT=White LINK=White VLINK=White>
<
H1>Message BoardPost a message</H1>
<
FORM METHOD=Post NAME=post_form ACTION="/cgi-bin/easymsgb.cgi">
  <
B>Your name: <BR>
  <
INPUT TYPE=Text NAME=username SIZE=50 MAXLENGTH=60>
<
BR>Email address (optional):
<
BR><INPUT TYPE=Text NAME=emailaddr SIZE=50 MAXLENGTH=60>
<
BR><B>WWW address</B> (optional):
<
BR><INPUT TYPE=Text NAME=wwwaddr VALUE="http://" SIZE=50 MAXLENGTH=60></B>
<
BR><B>Subject:
<
BR><INPUT TYPE=Text NAME=subject SIZE=50 MAXLENGTH=60>
<
BR>Your message:
<
BR><TEXTAREA COLS=50 ROWS=8 NAME="message" WRAP=virtual></TEXTAREA></B>
<
P><INPUT TYPE=Submit VALUE="Post Message"> <INPUT TYPE=Reset>
</
FORM>
</
BODY>
</
HTML
__________________
Justin
Tiscali User
Justin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 26-11-2003, 09:11 PM   #7
Site Founder
 
Justin's Avatar
 
Join Date: May 2002
Posts: 4,355
Thanks: 4
Thanked 4 Times in 4 Posts
easymsgb.cgi (In the CGI-BIN)

The Base Dir information you need (bits highlighted in bold) will be different from this example to what you need for your site, itcan be located in your members area by going to my website details and full CGI/PHP Path, simply copy and paste it exactly how it is with /emsgb on the end.
PHP Code:
#!/usr/bin/perl

############################################################################
# Colored Scripts: Easy Message Board
# Copyright 1999-2001 Stelian Dumitrascu
# [email]stelian@ottawa.com[/email]
############################################################################
# You may use this script in whole or in part; you may copy, re-distribute,
# change it in any way as long as you keep this copyright note in place.
#
# Once implemented, please email the URL at [email]stelian@ottawa.com[/email]
# and I will link it to my collection of smart users.
#
# Critical suggestions and bug reports are much appreciated.
#
# Happy scripting!
#
############################################################################

# Variables

$thisurl "/cgi-bin/easymsgb.cgi";
# The URL of this Perl script. It is a good idea to have stored it in
# the cgi-bin directory of your HTTP server

$baseurl "http://www.yoursubdomainname.f2s.com/emsgb";
$basedir "[b]/web/sites/xxx/username/www.username.f2s.com/emsgb[/b]";
# The URL and path to a WWW accessible directory

$msgdir "$basedir/messages";
$msgcountfile "$msgdir/msgcount";
# Where the messages and their count are being held

$posturl "$baseurl/post.html";
# Holds the Post Message form

$msgbname "Message Board";
# A name for your message board

$textcolor White;
$hightextcolor Yellow;
$bg "$baseurl/bg.gif";
# The messages look like white and yellow graffiti on this background

$numcols 4;
$numrows 3;
# The messages are displayed in a table, in 4 columns and 3 rows

$subjmaxlen 35;
# In headers, only the first 35 characters of the subject line are displayed

############################################################################
# Main program

$query $ENV{'QUERY_STRING'};

### Post a message ###

if ($query eq 'post') {
  &
parse_form;
  &
warning unless (&prep_post);
  &
newmsgfile;
  &
acknowledge_post;
}

### Print a message ###

elsif ($query =~ /print=(.*)/) {
  &
print_msg($1);
}

### Print message board, start with ###

elsif ($query =~ /start=(.*)/) {
  &
print_msgb($1);
}

### Print message board default ###

else {
  &
print_msgb;
}

############################################################################
# Subroutines

sub parse_form {
  
my($name$value);

  
read(STDIN$buffer$ENV{'CONTENT_LENGTH'});
  @
pairs split(/&/, $buffer);
  foreach 
$pair (@pairs) {
    (
$name$value) = split(/=/, $pair);
    
$value =~ tr/+/ /;
    
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C"hex($1))/eg;
    
$value =~ s/<!--.*-->//gs;
    
$value =~ s/<form.*?>//igs;
    $FORM{$name} = $value;
  }
}

### Prepare the submitted message ###

sub prep_post {

  $subject = "$FORM{'subject'}";
  $subject = "Untitled" if ($subject eq '');
  $username = "$FORM{'username'}";
  return(0) if ($username eq '');
  $useremail = "$FORM{'emailaddr'}"
    if ($FORM{'emailaddr'} =~ /.*\@.*\..*/);
# A correct email address has the form [email]smth@smth.smth[/email]

  $userurl = "$FORM{'wwwaddr'}" 
    if ($FORM{'wwwaddr'} =~ /http:\/\/.*\..*/);
# A correct url has the form [url]http://smth.smth[/url]

  $message = "$FORM{'message'}";
  $message =~ s/\n{2,}/<p>/g;
  $message =~ s/\n//g;
# Single hard returns are ignored; 2 or more will produce a new paragraph

  &get_date;
  return(1);
}      

### Reject a post attempt ##

sub warning {

  print "Content-type: text/html\n\n";
  print "<html>\n";
  print "<head>\n";
  print "<title>Warning</title>\n";
  print "</head>\n";
  print "<body background=$bg text=$textcolor link=$textcolor vlink=$textcolor>\n";
  print "<center><h1>Invalid posting: No user name</h1>\n";
  print "<b><a href=\"$thisurl\">$msgbname</a> |\n";
  print "<a href=\"$posturl\">Post message</a></b></center>\n";
  print "</body>\n";
  print "</html>\n";
  exit;
}

### Get the number of posted messages ###

sub get_msgnum {

  open(FILE,"$msgcountfile") || die "Cannot open $msgcountfile\n";
  $msgnum = <FILE>;
  close(FILE);
  return($msgnum);
}

### Create a new message file ###

sub newmsgfile {

  $msgnum = &get_msgnum;
  $msgnum++;
  open(FILE,">$msgcountfile") || die "Cannot write into $msgcountfile\n";
  print FILE "$msgnum";
  close(FILE);
  open(FILE,">$msgdir/$msgnum") || die "Cannot create $msgdir/$msgnum\n";
  print FILE "$subject\n";
  if (defined $userurl) {
    print FILE "<a href=\"$userurl\">$username</a>\n";
  }
  elsif (defined $useremail) {
    print FILE "<a href=\"mailto:$useremail\">$username</a>\n";
  }
  else {
    print FILE "$username\n";
  }
  print FILE "$date at $time\n";
  print FILE "$message\n";
  close(FILE);
  chmod 0666, "$msgdir/$msgnum";
}

### Post acknowledgement and preview ###

sub acknowledge_post {

  print "Content-type: text/html\n\n";
  print "<html>\n";
  print "<head>\n";
  print "<title>Post Acknowledgment</title>\n";
  print "</head>\n";
  print "<body background=$bg text=$textcolor link=$textcolor vlink=$textcolor>\n";
  print "<center><h1>Message \#$msgnum Added</h1></center>\n";
  print "<hr>\n";

  print "Subject: <b>$subject</b>\n";
  print "<br>Posted by: <b>$username</b>\n";
  print "<br>on $date at $time\n";
  print "<p>$message\n";
  print "<hr>\n";
  print "<p><center><b><a href=\"$thisurl\">$msgbname</a>\n";
  print "</body>\n";
  print "</html>\n";
}

### Display a message ###

sub print_msg {
  my($msgnum) = @_;

  open(FILE,"$msgdir/$msgnum") || die "Cannot open $msgdir/$msgnum\n";
  @lines = <FILE>;
  close(FILE);
  $subject = shift(@lines);
  $username = shift(@lines);
  $datetime = shift(@lines);
  chop($subject,$username,$datetime);
  print "Content-type: text/html\n\n";
  print "<html>\n";
  print "<head>\n";
  print "<title>$msgbname: Message \#$msgnum</title>\n";
  print "</head>\n";
  print "<body background=$bg text=$textcolor link=$textcolor vlink=$textcolor>\n";
  print "<center><h1>Message \#$msgnum</h1></center>\n";
  print "<hr>\n";
  print "<fint color=$hightextcolor><b>$subject</b></font>\n";
  print "<br>by <b>$username</b>\n";
  print "<br>$datetime\n";
  print "<p><b>@lines</b>\n";                       # the message itself
  print "<hr>\n";
  print "<p><center><a href=\"$thisurl\"><b>$msgbname</b></a></center>\n";
  print "</body>\n";
  print "</html>\n";
}

### Print the message board ###

sub print_msgb {
  my($startnum) = @_;

  $num_msgs = &get_msgnum;            # Messages in all
  $tablesize = $numcols * $numrows;   # How many cells there are in the table
  $colwidth = int(100 / $numcols);    # All columns have the same width
  $startnum = $num_msgs if (!defined($startnum) || ($startnum > $num_msgs));
  $finishnum = ($startnum > $tablesize) ? ($startnum - $tablesize + 1) : 1;

  print "Content-type: text/html\n\n";
  print "<html>\n";
  print "<head>\n";
  print "<title>$msgbname</title>\n";
  print "</head>\n";
  print "<body background=\"$bg\" text=$textcolor link=$textcolor vlink=$textcolor>\n";
  print "<center><h1>$msgbname</h1>\n";
  print "<p><b>\n";
  if ($startnum < $num_msgs) {
    $newerstart = $startnum + $tablesize;
    print "<a href=\"$thisurl?start=$newerstart\">Newer messages</a> |\n";
  }
  if ($startnum > $tablesize) {
    $olderstart = $startnum - $tablesize;
    print "<a href=\"$thisurl?start=$olderstart\">Older messages</a> |\n";
  }
  print "<a href=\"$posturl\">Post Message</a></b></center>\n";
  print "<p><hr size=3>\n";
# Message board's menu

  $col = 0;
  print "<p><table cellpadding=5 cellspacing=5 align=Center cols=$numcols>\n";
  for ($msgnum = $startnum; $msgnum >= $finishnum; $msgnum--) {
    open(FILE,"$msgdir/$msgnum") || die "Cannot open $msgdir/$msgnum\n";
    @lines = <FILE>;
    close(FILE);
    chop(@lines);
    ($subject, $username, $datetime) = @lines;
    ($date,$foo,$time) = split(/ /,$datetime);
    $subject = substr($subject,0,$subjmaxlen) . "..."
      if (length($subject) > $subjmaxlen);
# A too long subject is reduced to the first $subjmaxlen characters
# Still it's diplayed in full by &print_msg !

    print "<tr>\n" unless ($col);
# It's time to begin a new table row

    print "<td width=$colwidth\% valign=Top>\n";
    print "<a href=\"$thisurl?print=$msgnum\"><font color=$hightextcolor><b>$subject</b></font></a>\n";
    print "by <b>$username</b>\n";
    print "$date\n";
    print "</td>\n";
    $col++;
    print "</tr>\n" if ($msgnum == $finishnum || !($col %= $numcols));
# A table row completed
  }
  print "</table>\n";
  print "<p><hr size=3>\n";
  print "<font size=-1>&copy; 1999-2001 &nbsp;<a href=\"mailto:stelian\@ottawa.com\">Stelian Dumitrascu</a><p>\n";
  print "</body>\n";
  print "</html>\n";
}

### Get local date and time ###

sub get_date {

  @months = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
  $min = "0$min" if ($min < 10);
  $hour = "0$hour" if ($hour < 10);
  $mday = "0$mday" if ($mday < 10);
  $year += 1900;
  $date = "$mday-$months[$mon]-$year";
  $time = "$hour-$min";

__________________
Justin
Tiscali User
Justin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 27-11-2003, 11:12 AM   #8
Tiscali User Member
 
Thee_Psycho's Avatar
 
Join Date: Oct 2003
Location: Surrey
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Excellent Thank you, I will give it a go when I get home from work. Didn't realise the root was so high up!
Thee_Psycho is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Freedom2Surf ADSL Speed Problems Justin Tiscali / TalkTalk News & Announcements 0 04-03-2003 03:16 PM
Connection Problems ThePHM Freedom2Surf Broadband 10 07-07-2002 02:55 PM
Freedom2surf Routing Problems - Information Here. Justin Tiscali / TalkTalk News & Announcements 1 27-06-2002 03:16 PM
Freedom2surf Database Problems Justin Tiscali / TalkTalk News & Announcements 0 26-06-2002 05:37 PM


All times are GMT. The time now is 08:28 AM.