CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
How can do like that ?

 



damnass
Deleted

May 25, 2001, 3:55 AM

Post #1 of 4 (686 views)
How can do like that ? Can't Post

Can you tell me how can i make new-labels to my www board. ?

like this one

http://www.utti.org/wwwboard/

there is red and green words which means new message.
How can i apply those kind of script to my pl/cgi script ?

please help me ?

Kimmo




randor
User

May 25, 2001, 10:14 AM

Post #2 of 4 (675 views)
Re: How can do like that ? [In reply to] Can't Post

damnass,

ok, first.. we really need more input than what you gave, try showing us some code of what you have so far and we can see what we can do...

from looking at that board that you listed, i would say to use an "if" statement i n the html part.. likje so:

if ($new_posts == '0') {print <font color=red>posts</font>}
else {print <font color=blue>posts</font>}

or something to that affect....

i hope this helps..



kojr
Novice

May 26, 2001, 5:11 AM

Post #3 of 4 (664 views)
Re: How can do like that ? [In reply to] Can't Post

Unable to link the page



damnass
Deleted

May 27, 2001, 10:52 PM

Post #4 of 4 (647 views)
Re: How can do like that ? [In reply to] Can't Post

Thanks for your help.
But i am so damnass that I don't get it .
Here's the code:

#!/usr/bin/perl
##############################################################################
# WWWBoard Version 2.0 ALPHA 2.1 #
# Copyright 1996 Matt Wright mattw@worldwidemart.com #
# Created 10/21/95 Last Modified 11/25/95 #
# Security Patches/Bug Fixes: January 07, 2000 #
# Scripts Archive at: http://www.worldwidemart.com/scripts/ #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1996 Matthew M. Wright All Rights Reserved. #
# #
# WWWBoard may be used and modified free of charge by anyone so long as #
# this copyright notice and the comments above remain intact. By using this #
# code you agree to indemnify Matthew M. Wright from any liability that #
# might arise from it's use. #
# #
# Selling the code for this program without prior written consent is #
# expressly forbidden. In other words, please ask first before you try and #
# make money off of my program. #
# #
# Obtain permission before redistributing this software over the Internet or #
# in any other medium. In all cases copyright and header must remain intact.#
##############################################################################
# Define Variables

$basedir = "/d02/sec/s37/a00043a3/www/wwwboard";
$baseurl = "http://mousepoint.netfirms.com/wwwboard";
$cgi_url = "http://mousepoint.netfirms.com/cgi-bin/board.cgi";

$mesgdir = "messages";
$datafile = "data.txt";
$mesgfile = "wwwboard.html";
$faqfile = "faq.html";

$ext = "html";

$title = "WWWBoard Version 2.0 Test";

# Done
###########################################################################

###########################################################################
# Configure Options

$show_faq = 1; # 1 - YES; 0 = NO
$allow_html = 1; # 1 = YES; 0 = NO
$quote_text = 1; # 1 = YES; 0 = NO
$subject_line = 0; # 0 = Quote Subject Editable; 1 = Quote Subject
# UnEditable; 2 = Don't Quote Subject, Editable.
$use_time = 1; # 1 = YES; 0 = NO

$show_poster_ip = 1; # 1 = Show the IP of every poster; 0 = Don't
$enforce_max_len = 0; # 2 = YES, error; 1 = YES, truncate; 0 = NO
%max_len = ('name', 50,
'email', 70,
'subject', 80,
'url', 150,
'url_title', 80,
'img', 150,
'body', 3000,
'origsubject', 80,
'origname', 50,
'origemail', 70,
'origdate', 50);
# Done
###########################################################################

# Get the Data Number
&get_number;

# Get Form Information
&parse_form;

# Put items into nice variables
&get_variables;

# Open the new file and write information to it.
&new_file;

# Open the Main WWWBoard File to add link
&main_page;

# Now Add Thread to Individual Pages
if ($num_followups >= 1) {
&thread_pages;
}

# Return the user HTML
&return_html;

# Increment Number
&increment_num;

############################
# Get Data Number Subroutine

sub get_number {
open(NUMBER,"$basedir/$datafile");
$num = <NUMBER>;
close(NUMBER);
if ($num == 999999 || $num !~ /^\d+$/) {
$num = "1";
}
else {
$num++;
}
}

#######################
# Parse Form Subroutine

sub parse_form {
local($name,$value);

# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Split the name-value pairs
@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

# Remove any NULL characters, Server Side Includes
$value =~ s/\0//g;
$value =~ s/$num_responses)\n";
$work = 1;
}
}
if ($work != 1) {
print FOLLOWUP "$followup_line";
}
}
else {
print FOLLOWUP "$followup_line";
}
}
close(FOLLOWUP);
}
}

sub return_html {
print "Content-type: text/html\n\n";
print "<html><head><title>Message Added: $subject</title></head>\n";
print "<body><center><h1>Message Added: $subject</h1></center>\n";
print "The following information was added to the message board:<p><hr size=7 width=75%><p>\n";
print "<b>Name:</b> $name
\n";
print "<b>E-Mail:</b> $email
\n";
print "<b>Subject:</b> $subject
\n";
print "<b>Body of Message:</b><p>\n";
print "$body<p>\n";
if ($message_url) {
print "<b>Link:</b> <a href=\"$message_url\">$message_url_title</a>
\n";
}
if ($message_img) {
print "<b>Image:</b> <img src=\"$message_img\">
\n";
}
print "<b>Added on Date:</b> $date<p>\n";
print "<hr size=7 width=75%>\n";
print "<center>[ <a href=\"$baseurl/$mesgdir/$num\.$ext\">Go to Your Message</a> ] [ <a href=\"$baseurl/$mesgfile\">$title</a> ]</center>\n";
print "</body></html>\n";
}

sub increment_num {
open(NUM,">$basedir/$datafile") || die $!;
print NUM "$num";
close(NUM);
}

sub error {
$error = $_[0];

print "Content-type: text/html\n\n";

if ($error eq 'no_name') {
print "<html><head><title>$title ERROR: No Name</title></head>\n";
print "<body><center><h1>ERROR: No Name</h1></center>\n";
print "You forgot to fill in the 'Name' field in your posting. Correct it below and re-submit. The necessary fields are: Name, Subject and Message.<p><hr size=7 width=75%><p>\n";
&rest_of_form;
}
elsif ($error eq 'no_subject') {
print "<html><head><title>$title ERROR: No Subject</title></head>\n";
print "<body><center><h1>ERROR: No Subject</h1></center>\n";
print "You forgot to fill in the 'Subject' field in your posting. Correct it below and re-submit. The necessary fields are: Name, Subject and Message.<p><hr size=7 width=75%><p>\n";
&rest_of_form;
}
elsif ($error eq 'no_body') {
print "<html><head><title>$title ERROR: No Message</title></head>\n";
print "<body><center><h1>ERROR: No Message</h1></center>\n";
print "You forgot to fill in the 'Message' field in your posting. Correct it below and re-submit. The necessary fields are: Name, Subject and Message.<p><hr size=7 width=75%><p>\n";
&rest_of_form;
}
elsif ($error eq 'field_size') {
printf "<html><head><title>$title ERROR: Field too Long</title></head>\n";
print "<body><center><h1>ERROR: Field too Long</h1></center>\n";
print "One of the form fields in the message submission was too long. The following are the limits on the size of each field (in characters):<p><ul>\n";
print "<li>Name: $max_len{'name'}\n";
print "<li>E-Mail: $max_len{'email'}\n";
print "<li>Subject: $max_len{'subject'}\n";
print "<li>Body: $max_len{'body'}\n";
print "<li>URL: $max_len{'url'}\n";
print "<li>URL Title: $max_len{'url_title'}\n";
print "<li>Image URL: $max_len{'img'}\n";
print "</ul>Please modify the form data and resubmit.<p><hr size=7 width=75%><p>\n";
&rest_of_form;
}
else {
print "ERROR! Undefined.\n";
}
exit;
}

sub rest_of_form {

print "<form method=POST action=\"$cgi_url\">\n";

if ($followup == 1) {
print "<input type=hidden name=\"origsubject\" value=\"$FORM{'origsubject'}\">\n";
print "<input type=hidden name=\"origname\" value=\"$FORM{'origname'}\">\n";
print "<input type=hidden name=\"origemail\" value=\"$FORM{'origemail'}\">\n";
print "<input type=hidden name=\"origdate\" value=\"$FORM{'origdate'}\">\n";
print "<input type=hidden name=\"followup\" value=\"$FORM{'followup'}\">\n";
}
print "Name: <input type=text name=\"name\" value=\"$FORM{'name'}\" size=50>
\n";
print "E-Mail: <input type=text name=\"email\" value=\"$FORM{'email'}\" size=50><p>\n";
if ($subject_line == 1) {
print "<input type=hidden name=\"subject\" value=\"$FORM{'subject'}\">\n";
print "Subject: <b>$FORM{'subject'}</b><p>\n";
}
else {
print "Subject: <input type=text name=\"subject\" value=\"$FORM{'subject'}\" size=50><p>\n";
}
print "Message:
\n";
print "<textarea COLS=50 ROWS=10 name=\"body\">\n";
$FORM{'body'} =~ s/</</g;
$FORM{'body'} =~ s/>/>/g;
$FORM{'body'} =~ s/"/"/g;
print "$FORM{'body'}\n";
print "</textarea><p>\n";
print "Optional Link URL: <input type=text name=\"url\" value=\"$FORM{'url'}\" size=45>
\n";
print "Link Title: <input type=text name=\"url_title\" value=\"$FORM{'url_title'}\" size=50>
\n";
print "Optional Image URL: <input type=text name=\"img\" value=\"$FORM{'img'}\" size=45><p>\n";
print "<input type=submit value=\"Post Message\"> <input type=reset>\n";
print "</form>\n";
print "
<hr size=7 width=75%>\n";
if ($show_faq == 1) {
print "<center>[ <a href=\"#followups\">Follow Ups</a> ] [ <a href=\"#postfp\">Post Followup</a> ] [ <a href=\"$baseurl/$mesgfile\">$title</a> ] [ <a href=\"$baseurl/$faqfile\">FAQ</a> ]</center>\n";
}
else {
print "<center>[ <a href=\"#followups\">Follow Ups</a> ] [ <a href=\"#postfp\">Post Followup</a> ] [ <a href=\"$baseurl/$mesgfile\">$title</a> ]</center>\n";
}
print "</body></html>\n";
}



 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives