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: Intermediate:
Need help modifying a script - I'm stuck

 



dumbperlgirl
Deleted

May 2, 2000, 11:25 PM

Post #1 of 3 (469 views)
Need help modifying a script - I'm stuck Can't Post

Hello there! I'm using the ezhompg.pl script to allow my users to make their own personlized genealogy homepages. The only problem I have is that I can't modify the script to allow my users to put up to 20 links on their sites. This script only allows the person to put 3 links on their pages.. I want my users who create genealogy pages to be able to put up to 20 links on their site, but I can't seem to get it to work. Another programmer told me to just modify the script by entering $linksname3 etc etc..but that didn't work.. Can someone please modify this darn thing before i get too frustrated and throw this awsome idea out? Here is the coding below for the script. Please help me.

#!/usr/local/bin/perl
#
# ezhomepg - EZ Home Page Generator - by Manny Juan <manny@jps.net>
# http://inet-images.com/manny/userpages/
# ver 1.20 - 10/8/98 added simple table creation
# ver 1.10 - 10/7/98 added deletion capability and handled un-selected graphics
# ver 1.00 - 9/25/98 changed to use same code for create/edit logic, eliminate makepage.html
# also added code to remember user's clip art choices
#
# original program was
# HomePageMaker v.1.6 written by Dave Palmer <dave@upstatepress.com>
# http://www.upstatepress.com/dave/perl.shtml
# Modified by Greg Mathews <webmaster@notts.net>.
#
#####################################################################################

# These variables need to be set

# Set this to the HTML directory where the new pages will reside. This is a PATH not a URL
$base_dir = "/data1/hypermart.net/rootssearch/pages";

# This is your URL of where the cgi programs are kept
$cgiurl = "http://rootssearch.hypermart.net/cgi-bin";

# This is your URL of where the new HTML pages will be kept. keep the trailing slash
$baseurl = "http://rootssearch.hypermart.net/pages/";

# This is a URL and dir for the images sub directory in the userpages directory.
# Create the images directory in the userpages directory. This is where
# you will upload your background images
$imageurl = "$baseurl" . "images";
$imagedir = "$base_dir/images";

#directory for the pictures
$tnp_dir_url = "$imageurl/pictures";
$tnp_dir = "$imagedir/pictures";
#directory for the lines graphics
$tn_dir_url = "$imageurl/lines";
$tn_dir = "$imagedir/lines";
#directory for the background graphics
$tnbg_dir_url = "$imageurl/backgrounds";
$tnbg_dir = "$imagedir/backgrounds";
#directory for the emailgif graphics
$tne_dir_url = "$imageurl/email";
$tne_dir = "$imagedir/email";
#directory for the bullets graphics
$tnb_dir_url = "$imageurl/bullets";
$tnb_dir = "$imagedir/bullets";

# This is the path for user pages. You don't really need to change this
# Just make sure to create a directory: userpages and chmod it 777
$page_dir = "$base_dir/";

# This is the index of all pages created by HPM
# This file should be chmod to 777 and placed in the userpages directory
$indexpage = "$base_dir/index.html";

# This is the location of the data.txt file. This holds each user's
# login name and e-mail address for confirmation
$data = "$base_dir/data.txt";

#Site title

$title="Roots-Search Free Genealogy Homepages";

# self explanatory variables for your site logo
$logo = "http://rootssearch.hypermart.net/banner01.gif";
$logoalt = "Roots Search Free Homepages";

# Location of the sendmail program
$sendmail = '/var/qmail/bin/qmail-inject';

# Your e-mail address here
$myemail = 'ivana2@juno.com';

# That's it.

# DO NOT CHANGE ANYTHING BELOW THIS LINE
######################################################################################
$SIG{__DIE__} = \&Error_Msg;

sub Error_Msg {
$msg = "@_";
print "\nContent-type: text/html\n\n";
print "The following error occurred : $msg\n";
exit;
}

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

# split the input
@pairs = split(/&/, $input);

# split the name/value pairs
foreach $pair (@pairs) {

($name, $value) = split(/=/, $pair);

$name =~ tr/+/ /;
$name =~ 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;

$FORM{$name} = $value;
}

# Lets do some translating first
$usrname = $FORM{'usrname'};
$email = $FORM{'email'};
$background = $FORM{'background'};
$emailgif = $FORM{'emailgif'};
$linkc = $FORM{'linkc'};
$vlinkc = $FORM{'vlinkc'};
$textc = $FORM{'textc'};
$headline = $FORM{'headline'};
$subhead = $FORM{'subhead'};
$headpos = $FORM{'headpos'};
$topimage = $FORM{'topimage'};
$line2 = $FORM{'line'};
$imageyn = "yes";
$imagepos = $FORM{'imagepos'};
$imdesc = $FORM{'imdesc'};
$usrlink1 = $FORM{'usrlink1'};
$usrlink2 = $FORM{'usrlink2'};
$usrlink3 = $FORM{'usrlink3'};
$linkname1 = $FORM{'linkname1'};
$linkname2 = $FORM{'linkname2'};
$linkname3 = $FORM{'linkname3'};
$content = $FORM{'content'};
$images = $FORM{'images'};
$pagename = $FORM{'pagename'};
$login = $FORM{'login'};
$bullet = $FORM{'bullet'};
$tbltext = $FORM{'tbltext'};
$updact = $FORM{'updact'};

# Add the line breaks for paragraph spacing
#$content =~ s/&&/<br><br>/g;
$content =~ s/&&/%%/g;

# This fixes the bug of white space and
# other wierd spacing:
$content =~ s/\cM//g;
$content =~ s/\n/ /g;
$tbltext =~ s/\cM//g;
$tbltext =~ s/\n/ /g;

# If the user tries to add more than one word in
# the page name field, this will put an underscore
# in the spaces to make it one word
$pagename =~ s/ /_/g;

# Find out what the user wants to do
if ($FORM{'action'} eq "New Page") {
&newpage;
}
if ($FORM{'action'} eq "Create Page") {
&create;
}
if ($FORM{'action'} eq "Edit Page") {
&confirm("edit");
}
if ($FORM{'action'} eq "checkuser") {
&checkuser;
}
if ($FORM{'action'} eq "recreate") {
&recreate;
}
if ($FORM{'action'} eq "Delete Page") {
&confirm("delete");
}

sub newpage() {
local($usrname, $mail, $head, $sub, $body, $bgimage, $linkcolor, $vlinkcolor,
$ahref1, $ahref2, $ahref3, $ahrefname1, $ahref2name, $ahref3name,
$filename, $imurl, $hrline, $emailpic, $textcolor, $bullet, $tbltext);

($usrname, $mail, $bgimage, $head, $sub, $body, $linkcolor, $vlinkcolor,
$ahref1, $ahref2, $ahref3, $ahrefname1, $ahref2name, $ahref3name,
$filename, $imurl, $hrline, $emailpic, $textcolor, $bullet, $tbltext) = split(/&&/, "");

$ahref1="http://";
$ahref2="http://";
$ahref3="http://";
$textcolor="#000000";
$linkcolor="#0000ff";
$vlinkcolor="#800000";
$bullet="0";
# To avoid any security risks. Take out the HTML tags added when HPM translated
# the && to: <br><br>. They will be re-translated to: && Once the user updates
# the page, the: && will be put back to: <br><br>
$body =~ s/<br><br>/&&/g;

# print the edit-page form

print "Content-type: text/html\n\n";
print "<html><head><title>Free Genealogy Homepages</title></head>\n";
print "<body bgcolor=\"#ffffff\" TEXT=\"#000000\" link=\"#008000\" vlink=\"#800040\">\n";
print "<center><img src=\"$logo\" alt=\"$logoalt\" border=0></center><p>\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "<table width=75% cellspacing=2 cellpadding=2 border=0>\n";
print "<tr><td width=100% align=left valign=top>\n";
print "<p><font face=\"Arial, Geneva\"><h2>Create Your Own Family HomePage</h2></font></p>\n";
print "<p>Below is an empty form for you to fill in. The next five fields (<b>bold</b> ) are required.\n";
print "You can edit any part of your page later</p>\n";
print "<p></p>\n";
print "<form action=\"$cgiurl/ezhomepg.pl\" method=POST>\n";
print "<input type=hidden name=\"action\" value=\"Create Page\">\n";
print "<b>Your name:</b><br>\n";
print "<font size=\"-1\">(will appear in page as a link to your email)</font><br>\n";
print "<input type=text size=40 name=\"usrname\" value=\"$usrname\"><br><br>\n";
print "<h3>(The next 3 fields will be used for editing)<h3>\n";
print "<b>Login Id:</b>\n";
print "<font size=\"-1\">(one word only, it will be used later for editing)</font><br>\n";
print "<input type=text size=40 name=\"login\" value=\"$login\"><br><br>\n";
print "<b>Your e-mail:</b>\n";
print "<font size=\"-1\">(used for editing, will also appear in your page)</font><br>\n";
print "<input type=text size=40 name=\"email\" value=\"$mail\"><br><br>\n";
print "<b>Your page:</b>\n";
print "<font size=\"-1\">(one word, will become the name of your html file, example sandy, smiths001)</font><br>\n";
print "<input type=text size=40 name=\"pagename\" value=\"$filename\"><br><br>\n";
print "<b>Headline:</b>\n";
print "<font size=\"-1\">(how your page will be listed in index example Bob's Family Online)</font><br>\n";
print "<input type=text size=40 name=\"headline\" value=\"$head\"><br><br>\n";
print "</td></tr></table>\n";
print "<b>Sub Head:</b><br>\n";
print "Example: The Berringer's Immigration<BR><input type=text size=40 name=\"subhead\" value=\"$sub\"><br><br>\n";
print "<b>Do you want the headings centered:</b> <input type=radio name=\"headpos\" value=\"yes\" checked>Yes\n";
print "<input type=radio name=\"headpos\" value=\"no\">No<p>\n";
&build_form_body($usrname, $mail, $head, $sub, $body, $bgimage, $linkcolor, $vlinkcolor,
$ahref1, $ahref2, $ahref3, $ahrefname1, $ahref2name, $ahref3name,
$filename, $imurl, $hrline, $emailpic, $textcolor, $bullet, $tbltext);
print "<P><input type=submit value=\"create page\">\n";
print "</form>\n";
print "</body></html>\n";
}

sub create {

# Now, lets do some error checking. Making sure they filled out each field
# This is pretty low tech now. I'll improve it later
&missing(missing_name) unless $usrname;
&missing(missing_email) unless $email;
&missing(missing_pagename) unless $pagename;

# if they try to name their page "index" This will stop them
if ($pagename eq "index") {
print "Content-type: text/html\n\n";
print "<html><head><title>Error</title></head>\n";
print "<body><center><img src=\"$logo\" alt=\"$logoalt\" border=0></center><p>\n";
print "<p>You cannot name your page <b>index</b>\n";
print "Please go back and re-name your page</p>\n";
print "<p>(Return to <a href=\"$baseurl\">User Pages</a> )\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
exit;
}
# if they Don't give their page a heading This will stop them
if ($headline eq "") {
print "Content-type: text/html\n\n";
print "<html><head><title>Error</title></head>\n";
print "<body><p>You MUST give your page a <b>Headline</b>\n";
print "Please go back and enter one for your page</p>\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
exit;
}

# if the user tries to name their page
# something that is already taken
# this will HOPEFULLY stop them Smile
# This block was written by Norm
if (-e "$page_dir$pagename\.html") {
print "Content-type: text/html\n\n";
print "<html><head><title>Error</title></head>\n";
print "<body><p>The page name: <b>$pagename</b>\n";
print "is already taken.\n";
print "Please go back and rename your page</p>\n";
print "<p>(Return to <a href=\"$baseurl\">User Pages</a> )\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
exit;
}

#now, lets create our new html page
&buildpage;

# Write the login name and email address to a separate file for confirmation
# when they want to edit their page
open (FILE, ">>$data") &#0124; &#0124; die "I can't open $data\n";
flock (FILE, 2) or die "can't lock data file\n";
print FILE "$login&&$email&&$pagename\n";
close(FILE);


# Suck the index page, and write the new entry to it
open(FILE, "$indexpage") &#0124; &#0124; die "I can't open that file\n";
flock (FILE, 1) or die "can't lock index file\n";
@lines = <FILE>;
close(FILE);
$sizelines = @lines;

# Now, re-open the links file, and add the new link
open(FILE, ">$indexpage") &#0124; &#0124; die "I can't open that file\n";
flock (FILE, 2) or die "can't lock index file\n";

for ($a = 0; $a <= $sizelines; $a++) {

$_ = $lines[$a];

if (/<!--begin-->/) {

print FILE "<!--begin-->\n";
print FILE "<p><font face=\"Arial, Geneva\" size=4><a href=\"$baseurl$pagename.html\">$headline</a></p>\n";

} else {
print FILE $_;
}
}
close(FILE);


# Give the user a response
print "Content-type: text/html\n\n";
print "<html><head><title>thanks</title></head>\n";
print "<body bgcolor=\"#ffffff\" TEXT=\"#000000\" link=\"#008000\" vlink=\"#800040\">\n";
print "<center><img src=\"$logo\" alt=\"$logoalt\" border=0></center><p>\n";
print "<BR><BR><FONT SIZE=4 FACE=\"COMIC SANS MS,ARIAL\">\n";

print "Your page has been created, and you will receive an e-mail confirming this!\n";
print "Your URL is: <a href=\"$baseurl$pagename\.html\">\n";
print "$baseurl$pagename\.html</a> - remember to press Reload\n";
print "<br>You can also find your homepage at<br> http://search4roots.cjb.net/pages/yourpagename.html\n";
print "If you haven't done so yet, Please go to http://search4roots.virtualave.net and add your family page to our listing.\n";
print "Thanks for your participation!\n";
print "<p>(Return to <a href=\"$baseurl\">User Pages</a> )\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "</body></html>\n";


# Send the user an e-mail confirming their page
open (MAIL, "| $sendmail -t") &#0124; &#0124; die "I can't open sendmail\n";
print MAIL "To: $usrname <$email>\n";
print MAIL "From: $myemail\n";
print MAIL "Subject: Your URL on the $title\n";
print MAIL "Your page can be viewed at the URL below:\n";
print MAIL "\n";
print MAIL "$baseurl$pagename\.html\n";
print MAIL "You can also find your homepage at\n";
print MAIL "http://search4roots.cjb.net/pages/$pagename\.html\n";
print MAIL "\n";
print MAIL "If you haven't done so yet, add your homepage to the Search4Roots Genealogy Search Engine at http://search4roots.virtualave.net\n";
print MAIL "\n";
print MAIL "Remember to go to http://rootssearch.hypermart.net to edit your pages or to create new ones to link together.\n";
print MAIL "\nThank you for using the $title\n";
print MAIL "\n\nWebmaster - $myemail\n";
close (MAIL);

# Notify us when someone creates a page
open (MAIL, "| $sendmail -t") &#0124; &#0124; die "I can't open sendmail\n";
print MAIL "To: $myemail\n";
print MAIL "From: $usrname <$email>\n";
print MAIL "Subject: New Genealogy Homepage Created\n";
print MAIL "$usrname created a new page:\n";
print MAIL "$baseurl$pagename\.html\n";
print MAIL "\nThe content is :\n$content\n";
close(MAIL);

}

sub recreate {
#now, lets create our new html page
&buildpage;

# Send the user a notice that their page has been re-done
open (MAIL, "| $sendmail -t") &#0124; &#0124; die "I can't open sendmail\n";
print MAIL "To: $usrname <$email>\n";
print MAIL "From: $myemail\n";
print MAIL "Subject: Your Changes on the $title\n";
print MAIL "Your revised page can be viewed at the URL below:\n";
print MAIL "\n";
print MAIL "$baseurl$pagename\.html\n";
print MAIL "You can also find your homepage at\n";
print MAIL "http://search4roots.cjb.net/pages/$pagename\.html\n";
print MAIL "\n";
print MAIL "If you haven't done so yet, add your homepage to the Search4Roots Genealogy Search Engine at http://search4roots.virtualave.net\n";
print MAIL "\n";
print MAIL "Remember to go to http://rootssearch.hypermart.net to edit your pages or to create new ones to link together.\n";
print MAIL "\nOnce again thank you for using the $title\n";
print MAIL "\n\nThe Webmaster\n";
close (MAIL);

# Give the user a response
print "Content-type: text/html\n\n";
print "<html><head><title>thanks</title></head>\n";
print "<body bgcolor=\"#ffffff\" TEXT=\"#000000\" link=\"#008000\" vlink=\"#800040\">\n";
print "<CENTER><IMG SRC=\"$logo\" alt=\"$logoalt\" border=0></CENTER>\n";

print "<P><BR><BR><FONT SIZE=4 FACE=\"COMIC SANS MS,ARIAL\">\n";

print "Your page has been revised, and you will receive an e-mail confirming this!\n";
print "Your URL is: <a href=\"$baseurl$pagename\.html\">\n";
print "$baseurl$pagename\.html</a> - remember to press Reload\n";
print "You can also find your homepage at http://search4roots.cjb.net/pages/yourpagename.html\n";
print "If you haven't done so yet, Please go to http://search4roots.virtualave.net and add your family page to our listing.\n";
print "Thanks for your participation!\n";
print "<p>(Return to <a href=\"$baseurl\">User Pages</a> )\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "</body></html>\n";
}

sub buildpage {
open(HTML, ">$page_dir$pagename\.html") &#0124; &#0124; die "I can't create $pagename\.html\n";
flock (HTML, 2) or die "can't lock html file\n";
print HTML "<html><head><title>$headline</title></head>\n";
print HTML "<body background=\"$background\" text=$textc link=$linkc vlink=$vlinkc><font face=\"Arial\">\n";
print HTML "<blockquote>\n";
if ($headpos eq "yes") {
print HTML "<center>\n";
}
print HTML "<p><font face=\"Arial, Geneva\" size=+7>$headline</font></p>\n";
if ($headpos eq "yes") {
print HTML "</center>\n";
}
if ($imageyn eq "yes") {
if ($imagepos eq "yes") {
print HTML "<center>\n";
}
if (($topimage eq "0") or ($topimage eq "")) {
print HTML "";
}
else {
print HTML "<img src=\"$topimage\">\n";
}
print HTML "<p><font face=\"Arial, Geneva\" size=+2><b>$subhead</b></font>\n";
if ($imagepos eq "yes") {
print HTML "</center>\n";
}
print HTML "<center>";
if (($line2 eq "0") or ($line2 eq "")) {
print HTML "";
}
else {
print HTML "<img src=\"$line2\"></center><P>\n";
}
}
@atxt = split(/%%/, $content);
if ($bullet eq "0") {
print HTML "<center>\n";
foreach $txtline(@atxt) {
print HTML "<p><font face=\"Arial, Geneva\" size=3>$txtline</font>\n";
}
print HTML "</center>";
}
else {
print HTML "<table border=0 cellpadding=5>\n";
foreach $txtline (@atxt) {
print HTML "<tr><td valign=top><img src=\"$bullet\"></td>\n";
print HTML "<td><font face=\"Arial, Geneva\" size=3>$txtline</font></td></tr>\n";
}
print HTML "</table>\n";
}

print HTML "<center>\n";
print HTML "<p><table border=1 cellspacing=3 cellpadding=3>";
@all = split(/%%/,$tbltext);
foreach $tbline (@all) {
print HTML "<tr>";
@flds = split(/\:\:/, $tbline);
foreach $fld (@flds) {
print HTML "<td>$fld</td>";
}
print HTML "</tr>";
}
print HTML "</table>";
print HTML "</center>";

if ($bullet eq "0") {
print HTML "\n";
}
print HTML "<p><i><font face=\"Arial, Geneva\" size=4><b>Other Links</i></b></font></p>\n";
print HTML "<p><font face=\"Arial, Geneva\" size=3><a href=\"$usrlink1\">$linkname1</a><br>\n";
print HTML "<a href=\"$usrlink2\">$linkname2</a><br>\n";
print HTML "<a href=\"$usrlink3\">$linkname3</a></font></p>\n";
if ($bullet eq "0") {
print HTML "\n";
}

print HTML "<center>";
if (($line2 eq "0") or ($line2 eq "")) {
print HTML "";
} else {
print HTML "<img src=\"$line2\"></center>\n";
}
print HTML "<p><center>";
if ($emailgif ne "") {
print HTML "<img src=\"$emailgif\"><br>\n";
}
print HTML "<a href=\"mailto:$email\">$usrname</a></font></center></p>\n";
print HTML "<p><center><font size=-1>";
print HTML "This page hosted by: ";
print HTML "<a href=http://rootssearch.hypermart.net>Roots-Search Free Family Homepages</a><br>\n";
print HTML "And <a href=http://search4roots.virtualave.net>Search4Roots Genealogy Search Engine</a></font><br><br>\n";
print HTML "<center><small><small><!--#echo banner=\"\"--></small></small><p></center>\n";
print HTML "</blockquote>\n";
print HTML "</center></body></html>";

close(HTML);


# Write all of the input into a flat file.
open(FILE, ">$page_dir$pagename\.dat") &#0124; &#0124; die "I can't create $pagename\.dat\n";
flock (FILE, 2) or die "can't lock user data file\n";
$tbltext =~ s/\n/%%/g;
print FILE "$usrname&&$email&&$background&&$headline&&$subhead&&$content&&$linkc&&$vlinkc&&$usrlink1&&$usrlink2&&$usrlink3&&$linkname1&&$linkname2&&$linkname3&&$pagename&&$topimage&&$line2&&$ emailgif&&$textc&&$bullet&&$tbltext\n";
close(FILE);
chmod 0777, '$page_dir$pagename.dat';
}

# Standard error message for any missing required fields
sub missing {
local ($missing) = @_;
print "Content-type: text/html\n\n";

print "<HTML><HEAD><TITLE>You missed something</TITLE></HEAD>\n";
print "<BODY>\n";
print "You forgot to fill in one of the fields. Please go back and make\n";
print "sure that all required fields are filled in! $missing\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "</BODY></HTML>\n";
exit;
}

sub confirm {
local ($updact) = @_;

print "Content-type: text/html\n\n";
print "<html><head><title>$updact Confirmation</title></head>\n";
print "<body bgcolor=\"#ffffff\" TEXT=\"#000000\" link=\"#008000\" vlink=\"#800040\" >\n";
print "<CENTER><IMG SRC=\"$logo\" alt=\"$logoalt\" border=0></CENTER>\n";
print "<P><BR><FONT SIZE=4 FACE=\"COMIC SANS MS,ARIAL\">\n";
print "<p><h3>Please Enter your login name, e-mail and name of your file to $updact</h3></p>\n";
print "<form action=\"$cgiurl/ezhomepg.pl\" method=POST>\n";
print "<P><BR><FONT SIZE=4 FACE=\"COMIC SANS MS,ARIAL\">\n";
print "Login name:<br>\n";
print "<input size=40 type=text name=\"login\"><br><br>\n";
print "E-mail:<br>\n";
print "<input size=40 type=text name=\"email\"><br><br>\n";
print "Name of your file:<br>\n";
print "<input type=text size=40 name=\"pagename\"><br><br>\n";
print "<input type=submit value=submit>\n";
print "<input type=hidden name=\"action\" value=\"checkuser\">\n";
print "<input type=hidden name=\"updact\" value=\"$updact\">\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "</FONT>\n";
print "</form></body></html>\n";
}

sub checkuser {
open(FILE, "$data") &#0124; &#0124; die "I can't open $data\n";
flock (FILE, 1) or die "can't lock data file\n";

while(<FILE> ) {
chop;
@all = split(/\n/);

foreach $line (@all) {
($loginname, $loginemail, $loginpagename) = split(/&&/, $line);
if($loginname eq "$login" && $loginemail eq "$email" && $loginpagename eq "$pagename") {
$match = 1;
if($updact eq "edit") {
&edit($loginpagename);
}
else {
&delpage($loginpagename);
}
}
}
}

close(FILE);

if (! $match) {
&error;
}

# del entry from data
if($updact eq "delete") {

# Suck the index page, and write the new entry to it
open(FILE, "$data") &#0124; &#0124; die "I can't open that file\n";
flock (FILE, 1) or die "can't lock data file\n";
@lines = <FILE>;
close(FILE);
$sizelines = @lines;

# Now, re-open the links file, and comment out the page to delete
open(FILE, ">$data") &#0124; &#0124; die "I can't open that file\n";
flock (FILE, 2) or die "can't lock index file for append\n";
chop;
for ($a = 0; $a <= $sizelines; $a++) {
$_ = $lines[$a];
$w = $_;
$w =~ s/\cM//g;
$w =~ s/\n//g;
($loginname, $loginemail, $loginpagename) = split(/&&/, $w);
if($loginname eq "$login" && $loginemail eq "$email" && $loginpagename eq "$pagename") {
# do nothing (ie. don't write)
}
else {
if($w eq "") {
# do nothing (skip)
}
else {
print FILE "$w\n";
}
}
}
close(FILE);
print "Content-type: text/html\n\n";
print "<html><head><title>$updact Confirmation</title></head>\n";
print "<body bgcolor=\"#ffffff\" TEXT=\"#000000\" link=\"#008000\" vlink=\"#800040\" >\n";
print "<CENTER><IMG SRC=\"$logo\" alt=\"$logoalt\" border=0></CENTER>\n";
print "<P><BR><FONT SIZE=4 FACE=\"COMIC SANS MS,ARIAL\">\n";
print "<p>your page has been deleted";
print "<p>(Return to <a href=\"$baseurl\">User Pages</a> )\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "</form></body></html>\n";
}
}

sub edit {

local ($editfile) = @_;

open(FILE, "$page_dir$editfile\.dat") &#0124; &#0124; die "I can't open $editfile\n";
flock (FILE, 1) or die "can't lock data file for edit\n";

while(<FILE> ) {
chop;
@datafile = split(/\n/);

foreach $line (@datafile) {
&build_edit_form($line);
}
}
close(FILE);
}

sub delpage {
local ($editfile) = @_;
$cnt=unlink "$page_dir$editfile\.dat", "$page_dir$editfile\.html";

# Suck the index page, and write the new entry to it
open(FILE, "$indexpage") &#0124; &#0124; die "I can't open that file\n";
flock (FILE, 1) or die "can't lock index file\n";
@lines = <FILE>;
close(FILE);
$sizelines = @lines;

# Now, re-open the links file, and comment out the page to delete
open(FILE, ">$indexpage") &#0124; &#0124; die "I can't open that file\n";
flock (FILE, 2) or die "can't lock index file to delete entry\n";

for ($a = 0; $a <= $sizelines; $a++) {

$_ = $lines[$a];

if (/$pagename.html/) {
# do nothing (ie. don't write)
}
else {
print FILE $_;
}
}
close(FILE);

}

sub build_edit_form($line) {
local ($line) = @_;
local($fullname, $mail, $head, $sub, $body, $bgimage, $linkcolor, $vlinkcolor,
$ahref1, $ahref2, $ahref3, $ahrefname1, $ahref2name, $ahref3name,
$filename, $imurl, $hrline, $emailpic, $textcolor, $bullet, $tbltext);

($fullname, $mail, $bgimage, $head, $sub, $body, $linkcolor, $vlinkcolor, $ahref1, $ahref2,
$ahref3, $ahrefname1, $ahref2name, $ahref3name, $filename, $imurl, $hrline, $emailpic,
$textcolor, $bullet, $tbltext) = split(/&&/, $line);

# To avoid any security risks. Take out the HTML tags added when HPM translated
# the && to: <br><br>. They will be re-translated to: && Once the user updates
# the page, the: && will be put back to: <br><br>
$body =~ s/<br><br>/&&/g;

# print the edit-page form

print "Content-type: text/html\n\n";
print "<html><head><title>Edit Your Page</title></head>\n";
print "<body bgcolor=\"#ffffff\" TEXT=\"#000000\" link=\"#008000\" vlink=\"#800040\">\n";
print "<center><img src=\"$logo\" alt=\"$logoalt\" border=0></center><p>\n";
print "<table width=75% cellspacing=2 cellpadding=2 border=0>\n";
print "<tr><td width=100% align=left valign=top>\n";
print "<p><font face=\"Arial, Geneva\"><h2>Edit Your Page</h2></font></p>\n";
print "<p>Below is a form with the contents\n";
print "of the home page you created. You can edit any part of your page</p>\n";
print "<p></p>\n";
print "<form action=\"$cgiurl/ezhomepg.pl\" method=POST>\n";
print "<input type=hidden name=\"action\" value=\"recreate\">\n";
print "Your name:<br>\n";
print "<input type=text size=40 name=\"usrname\" value=\"$fullname\"><br><br>\n";
print "Your e-mail:<br>\n";
print "<input type=text size=40 name=\"email\" value=\"$mail\"><br><br>\n";
print "Headline:<br>\n";
print "<input type=text size=40 name=\"headline\" value=\"$head\"><br><br>\n";
print "</td></tr></table>\n";
print "<b>Sub Head:</b><br>\n";
print "<input type=text size=40 name=\"subhead\" value=\"$sub\"><br><br>\n";
print "<b>Do you want the headings Centered:</b> <input type=radio name=\"headpos\" value=\"yes\" checked>Yes\n";
print "<input type=radio name=\"headpos\" value=\"no\">No<p>\n";
print "Name of HTML file: <b>$filename</b><br><br>\n";
print "<input type=hidden name=\"pagename\" value=\"$filename\">\n";
&build_form_body($fullname, $mail, $head, $sub, $body, $bgimage, $linkcolor, $vlinkcolor,
$ahref1, $ahref2, $ahref3, $ahrefname1, $ahref2name, $ahref3name,
$filename, $imurl, $hrline, $emailpic, $textcolor, $bullet, $tbltext);
print "<P><input type=submit value=\"update page\">\n";
print "</form>\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "</body></html>\n";
}

sub build_form_body($fullname, $mail, $head, $sub, $body, $bgimage, $linkcolor, $vlinkcolor,
$ahref1, $ahref2, $ahref3, $ahrefname1, $ahref2name, $ahref3name,
$filename, $imurl, $hrline, $emailpic, $textcolor, $bullet, $tbltext) {

print "<b>Splash Graphic:</b><br>\n";
opendir (TN, "$tnp_dir");
rewinddir (TN);
@tnlist = grep(!/^\.\.?$/, readdir (TN));
closedir (TN);

$tnnum = @tnlist;
$cnum = "0";
print "<input type=radio name=\"topimage\" value=\"0\">No Graphic</a><br><br>\n";
$lend = "0";
while ($tnnum > $cnum) {
print "<input type=radio name=\"topimage\" value=\"$tnp_dir_url/$tnlist[$cnum]\" ";
if ($imurl eq "$tnp_dir_url/$tnlist[$cnum]") {print "checked";}
print "><img src=\"$tnp_dir_url/$tnlist[$cnum]\" border=0></a>\n";
$cnum = $cnum + 1;
$lend = $lend + 1;
if ($lend eq "4"){
print "<br><br>\n";
$lend = 0;
}
}
print "<br><br><b>Do you want the image Centered? :</b> <input type=radio name=\"imagepos\" value=\"yes\" checked>Yes\n";
print "<input type=radio name=\"imagepos\" value=\"no\">No<p>\n";
print "<b>Body:</b> (use two percent signs (<b>%%</b> ) BETWEEN paragraphs)<br>\n";
print "<textarea cols=65 rows=6 wrap=on name=\"content\">$body</textarea><br><br>\n";
print << 'END'
<b>Table (Optional):</b> use two percent signs (<b>%%</b> ) BETWEEN rows, use 2 colons (<b>::</b> ) BETWEEN fields. for example:
<pre>
su :: mo :: tu :: we :: th :: fr :: sa
%% :: :: :: 1 :: 2 :: 3 :: 4
%% 5 :: 6 :: 7 :: 8 :: 9 :: 10 :: 11
%% 12 :: 13 :: 14 :: 15 :: 16 :: 17 :: 18
%% 19 :: 20 :: 21 :: 22 :: 23 :: 24 :: 25
%% 26 :: 27 :: 28 :: 29 :: 30
</pre>
END
;

$tbltext =~ s/%%/\n%%/g;
print "<textarea cols=65 rows=6 wrap=on name=\"tbltext\">$tbltext</textarea><br><br>";

print "<b>Links</b><br>\n";
print "<table width=75% cellpadding=2 cellspacing=2 border=0>\n";
print "<tr><td width=50% align=left valign=top>\n";
print "Link 1 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink1\" value=\"$ahref1\"><br><br>\n";
print "Link 2 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink2\" value=\"$ahref2\"><br><br>\n";
print "Link 3 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink3\" value=\"$ahref3\"><br><br>\n";
print "</td>\n";
print "<td width=50% align=left valign=top>\n";
print "Link 1 Name:<br>\n";
print "<input type=text size=40 name=\"linkname1\" value=\"$ahrefname1\"><br><br>\n";
print "Link 2 Name:<br>\n";
print "<input type=text size=40 name=\"linkname2\" value=\"$ahref2name\"><br><br>\n";
print "Link 3 Name:<br>\n";
print "<input type=text size=40 name=\"linkname3\" value=\"$ahref3name\"><br><br>\n";
print "</td></tr></table>\n";
print "<b>Text</b><br>\n";
print "Text color:<br>\n";
print "<input type=radio name=\"textc\" value=\"#000000\"";
if ($textcolor eq "#000000") {print "checked";}
print ">Black\n";
print "<input type=radio name=\"textc\" value=\"#800000\"";
if ($textcolor eq "#800000") {print "checked";}
print ">Maroon\n";
print "<input type=radio name=\"textc\" value=\"#ff0000\"";
if ($textcolor eq "#ff0000") {print "checked";}
print ">Red\n";
print "<input type=radio name=\"textc\" value=\"#ffff00\"";
if ($textcolor eq "#ffff00") {print "checked";}
print ">Yellow\n";
print "<input type=radio name=\"textc\" value=\"#00ff00\"";
if ($textcolor eq "#00ff00") {print "checked";}
print ">Green\n";
print "<input type=radio name=\"textc\" value=\"#ffffff\"";
if ($textcolor eq "#ffffff") {print "checked";}
print ">White\n";
print "<input type=radio name=\"textc\" value=\"#0000ff\"";
if ($textcolor eq "#0000ff") {print "checked";}
print ">Blue<br><br>\n";
print "Link color:<br>\n";
print "<input type=radio name=\"linkc\" value=\"#000000\"";
if ($linkcolor eq "#000000") {print "checked";}
print ">Black\n";
print "<input type=radio name=\"linkc\" value=\"#800000\"";
if ($linkcolor eq "#800000") {print "checked";}
print ">Maroon\n";
print "<input type=radio name=\"linkc\" value=\"#ff0000\"";
if ($linkcolor eq "#ff0000") {print "checked";}
print ">Red\n";
print "<input type=radio name=\"linkc\" value=\"#ffff00\"";
if ($linkcolor eq "#ffff00") {print "checked";}
print ">Yellow\n";
print "<input type=radio name=\"linkc\" value=\"#00ff00\"";
if ($linkcolor eq "#00ff00") {print "checked";}
print ">Green\n";
print "<input type=radio name=\"linkc\" value=\"#ffffff\"";
if ($linkcolor eq "#ffffff") {print "checked";}
print ">White\n";
print "<input type=radio name=\"linkc\" value=\"#0000ff\"";
if ($linkcolor eq "#0000ff") {print "checked";}
print ">Blue<br><br>\n";
print "Visited Link Color:<br>\n";
print "<input type=radio name=\"vlinkc\" value=\"#000000\"";
if ($vlinkcolor eq "#000000") {print "checked";}
print ">Black\n";
print "<input type=radio name=\"vlinkc\" value=\"#800000\"";
if ($vlinkcolor eq "#800000") {print "checked";}
print ">Maroon\n";
print "<input type=radio name=\"vlinkc\" value=\"#ff0000\"";
if ($vlinkcolor eq "#ff0000") {print "checked";}
print ">Red\n";
print "<input type=radio name=\"vlinkc\" value=\"#ffff00\"";
if ($vlinkcolor eq "#ffff00") {print "checked";}
print ">Yellow\n";
print "<input type=radio name=\"vlinkc\" value=\"#00ff00\"";
if ($vlinkcolor eq "#00ff00") {print "checked";}
print ">Green\n";
print "<input type=radio name=\"vlinkc\" value=\"#ffffff\"";
if ($vlinkcolor eq "#ffffff") {print "checked";}
print ">White\n";
print "<input type=radio name=\"vlinkc\" value=\"#0000ff\"";
if ($vlinkcolor eq "#0000ff") {print "checked";}
print ">Blue<br><br>\n";

print "<b>Background image:</b><br>\n";
opendir (TN, "$tnbg_dir");
rewinddir (TN);
@tnlist = grep(!/^\.\.?$/, readdir (TN));
closedir (TN);

$tnnum = @tnlist;
$cnum = "0";
while ($tnnum > $cnum) {
print "<input type=radio name=\"background\" value=\"$tnbg_dir_url/$tnlist[$cnum]\" " ;
if ($bgimage eq "$tnbg_dir_url/$tnlist[$cnum]") {print "checked";}
print "><img src=\"$tnbg_dir_url/$tnlist[$cnum]\" border=1></a><br><br>\n";
$cnum = $cnum + 1;
print "\n";
}
print "<b>Horizontal Line:</b><br>\n";
opendir (TN, "$tn_dir");
rewinddir (TN);
@tnlist = grep(!/^\.\.?$/, readdir (TN));
closedir (TN);

$tnnum = @tnlist;
$cnum = "0";
print "<input type=radio name=\"line\" value=\"0\"";
if ($line2 eq "0") { print " checked";}
print ">No Line</a><br><br>\n";
while ($tnnum > $cnum) {
print "<input type=radio name=\"line\" value=\"$tn_dir_url/$tnlist[$cnum]\"";
if ($hrline eq "$tn_dir_url/$tnlist[$cnum]") {print "checked";}
print "><img src=\"$tn_dir_url/$tnlist[$cnum]\" border=0></a><br><br>\n";
$cnum = $cnum + 1;
print "\n";
}

print "<b>Bullet:</b><br>\n";
opendir (TN, "$tnb_dir");
rewinddir (TN);
@tnlist = grep(!/^\.\.?$/, readdir (TN));
closedir (TN);

$tnnum = @tnlist;
$cnum = "0";
print "<input type=radio name=\"bullet\" value=\"0\"";
if($bullet eq "0") {print "checked";}
print ">No Bullet (all text will be centered)</a><br><br>\n";
$lend = "0";
while ($tnnum > $cnum) {
print "<input type=radio name=\"bullet\" value=\"$tnb_dir_url/$tnlist[$cnum]\"";
if ($bullet eq "$tnb_dir_url/$tnlist[$cnum]") {print "checked";}
print "><img src=\"$tnb_dir_url/$tnlist[$cnum]\" border=0></a>\n";
$cnum = $cnum + 1;
$lend = $lend + 1;
if ($lend eq "10"){
print "<br><br>\n";
$lend = 0;
}
}

print "<b>Email image:</b><br>\n";
opendir (TN, "$tne_dir");
rewinddir (TN);
@tnlist = grep(!/^\.\.?$/, readdir (TN));
closedir (TN);

$tnnum = @tnlist;
$cnum = "0";
$lend = "0";
while ($tnnum > $cnum) {
print "<input type=radio name=\"emailgif\" value=\"$tne_dir_url/$tnlist[$cnum]\"";
if ($emailpic eq "$tne_dir_url/$tnlist[$cnum]") {print "checked";}
print "><img src=\"$tne_dir_url/$tnlist[$cnum]\" border=0></a>\n";
$cnum = $cnum + 1;
$lend = $lend + 1;
if ($lend eq "4"){
print "<br><br>\n";
$lend = 0;
}
}
}

sub error {
local ($updact) = @_;
print "Content-type: text/html\n\n";
print "<html><head><title>Permission Denied</title></head>\n";
print "<body>\n";
print "<p><h1>Permission Denied</h1></p>\n";
print "You do not have permission to $updact\n";
print "<p>(Return to <a href=\"$baseurl\">User Pages</a> )\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "</body></html>\n";
exit;
}




darian
Deleted

May 3, 2000, 12:53 AM

Post #2 of 3 (469 views)
Re: Need help modifying a script - I'm stuck [In reply to] Can't Post

You needed to add 4-20 to the $ahref1 variable and $ahref1name variable. You also need to copy the
current HTML to add 4-20 on the forms. Hope this helps you. BTW I have not tested this so
you may want to run some tests on it to make sure I did not miss anything.
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

#!/usr/local/bin/perl
#
# ezhomepg - EZ Home Page Generator - by Manny Juan <manny@jps.net>
# http://inet-images.com/manny/userpages/
# ver 1.20 - 10/8/98 added simple table creation
# ver 1.10 - 10/7/98 added deletion capability and handled un-selected graphics
# ver 1.00 - 9/25/98 changed to use same code for create/edit logic, eliminate makepage.html
# also added code to remember user's clip art choices
#
# original program was
# HomePageMaker v.1.6 written by Dave Palmer <dave@upstatepress.com>
# http://www.upstatepress.com/dave/perl.shtml
# Modified by Greg Mathews <webmaster@notts.net>.
#
#####################################################################################

# These variables need to be set

# Set this to the HTML directory where the new pages will reside. This is a PATH not a URL
$base_dir = "/data1/hypermart.net/rootssearch/pages";

# This is your URL of where the cgi programs are kept
$cgiurl = "http://rootssearch.hypermart.net/cgi-bin";

# This is your URL of where the new HTML pages will be kept. keep the trailing slash
$baseurl = "http://rootssearch.hypermart.net/pages/";

# This is a URL and dir for the images sub directory in the userpages directory.
# Create the images directory in the userpages directory. This is where
# you will upload your background images
$imageurl = "$baseurl" . "images";
$imagedir = "$base_dir/images";

#directory for the pictures
$tnp_dir_url = "$imageurl/pictures";
$tnp_dir = "$imagedir/pictures";
#directory for the lines graphics
$tn_dir_url = "$imageurl/lines";
$tn_dir = "$imagedir/lines";
#directory for the background graphics
$tnbg_dir_url = "$imageurl/backgrounds";
$tnbg_dir = "$imagedir/backgrounds";
#directory for the emailgif graphics
$tne_dir_url = "$imageurl/email";
$tne_dir = "$imagedir/email";
#directory for the bullets graphics
$tnb_dir_url = "$imageurl/bullets";
$tnb_dir = "$imagedir/bullets";

# This is the path for user pages. You don't really need to change this
# Just make sure to create a directory: userpages and chmod it 777
$page_dir = "$base_dir/";

# This is the index of all pages created by HPM
# This file should be chmod to 777 and placed in the userpages directory
$indexpage = "$base_dir/index.html";

# This is the location of the data.txt file. This holds each user's
# login name and e-mail address for confirmation
$data = "$base_dir/data.txt";

#Site title

$title="Roots-Search Free Genealogy Homepages";

# self explanatory variables for your site logo
$logo = "http://rootssearch.hypermart.net/banner01.gif";
$logoalt = "Roots Search Free Homepages";

# Location of the sendmail program
$sendmail = '/var/qmail/bin/qmail-inject';

# Your e-mail address here
$myemail = 'ivana2@juno.com';

# That's it.

# DO NOT CHANGE ANYTHING BELOW THIS LINE
######################################################################################
$SIG{__DIE__} = \&Error_Msg;

sub Error_Msg {
$msg = "@_";
print "\nContent-type: text/html\n\n";
print "The following error occurred : $msg\n";
exit;
}

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

# split the input
@pairs = split(/&/, $input);

# split the name/value pairs
foreach $pair (@pairs) {

($name, $value) = split(/=/, $pair);

$name =~ tr/+/ /;
$name =~ 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;

$FORM{$name} = $value;
}

# Lets do some translating first
$usrname = $FORM{'usrname'};
$email = $FORM{'email'};
$background = $FORM{'background'};
$emailgif = $FORM{'emailgif'};
$linkc = $FORM{'linkc'};
$vlinkc = $FORM{'vlinkc'};
$textc = $FORM{'textc'};
$headline = $FORM{'headline'};
$subhead = $FORM{'subhead'};
$headpos = $FORM{'headpos'};
$topimage = $FORM{'topimage'};
$line2 = $FORM{'line'};
$imageyn = "yes";
$imagepos = $FORM{'imagepos'};
$imdesc = $FORM{'imdesc'};
$usrlink1 = $FORM{'usrlink1'};
$usrlink2 = $FORM{'usrlink2'};
$usrlink3 = $FORM{'usrlink3'};
$usrlink4 = $FORM{'usrlink4'};
$usrlink5 = $FORM{'usrlink5'};
$usrlink6 = $FORM{'usrlink6'};
$usrlink7 = $FORM{'usrlink7'};
$usrlink8 = $FORM{'usrlink8'};
$usrlink9 = $FORM{'usrlink9'};
$usrlink10 = $FORM{'usrlink10'};
$usrlink11 = $FORM{'usrlink11'};
$usrlink12 = $FORM{'usrlink12'};
$usrlink13 = $FORM{'usrlink13'};
$usrlink14 = $FORM{'usrlink14'};
$usrlink15 = $FORM{'usrlink15'};
$usrlink16 = $FORM{'usrlink16'};
$usrlink17 = $FORM{'usrlink17'};
$usrlink18 = $FORM{'usrlink18'};
$usrlink19 = $FORM{'usrlink19'};
$usrlink20 = $FORM{'usrlink20'};
$linkname1 = $FORM{'linkname1'};
$linkname2 = $FORM{'linkname2'};
$linkname3 = $FORM{'linkname3'};
$linkname4 = $FORM{'linkname4'};
$linkname5 = $FORM{'linkname5'};
$linkname6 = $FORM{'linkname6'};
$linkname7 = $FORM{'linkname7'};
$linkname8 = $FORM{'linkname8'};
$linkname9 = $FORM{'linkname9'};
$linkname10 = $FORM{'linkname10'};
$linkname11 = $FORM{'linkname11'};
$linkname12 = $FORM{'linkname12'};
$linkname13 = $FORM{'linkname13'};
$linkname14 = $FORM{'linkname14'};
$linkname15 = $FORM{'linkname15'};
$linkname16 = $FORM{'linkname16'};
$linkname17 = $FORM{'linkname17'};
$linkname18 = $FORM{'linkname18'};
$linkname19 = $FORM{'linkname19'};
$linkname20 = $FORM{'linkname20'};
$content = $FORM{'content'};
$images = $FORM{'images'};
$pagename = $FORM{'pagename'};
$login = $FORM{'login'};
$bullet = $FORM{'bullet'};
$tbltext = $FORM{'tbltext'};
$updact = $FORM{'updact'};

# Add the line breaks for paragraph spacing
#$content =~ s/&&/<br><br>/g;
$content =~ s/&&/%%/g;

# This fixes the bug of white space and
# other wierd spacing:
$content =~ s/\cM//g;
$content =~ s/\n/ /g;
$tbltext =~ s/\cM//g;
$tbltext =~ s/\n/ /g;

# If the user tries to add more than one word in
# the page name field, this will put an underscore
# in the spaces to make it one word
$pagename =~ s/ /_/g;

# Find out what the user wants to do
if ($FORM{'action'} eq "New Page") {
&newpage;
}
if ($FORM{'action'} eq "Create Page") {
&create;
}
if ($FORM{'action'} eq "Edit Page") {
&confirm("edit");
}
if ($FORM{'action'} eq "checkuser") {
&checkuser;
}
if ($FORM{'action'} eq "recreate") {
&recreate;
}
if ($FORM{'action'} eq "Delete Page") {
&confirm("delete");
}

sub newpage() {
local($usrname, $mail, $head, $sub, $body, $bgimage, $linkcolor, $vlinkcolor,
$ahref1, $ahref2, $ahref3, $ahref4, $ahref5, $ahref6, $ahref7, $ahref8, $ahref9, $ahref10,
$ahref11, $ahref12, $ahref13, $ahref14, $ahref15, $ahref16, $ahref17, $ahref18, $ahref19, $ahref20,
$ahrefname1, $ahref2name, $ahref3name, $ahref4name, $ahref5name, $ahref6name, $ahref7name,
$ahref8name, $ahref9name, $ahref10name, $ahref11name, $ahref12name, $ahref13name, $ahref14name,
$ahref15name, $ahref16name, $ahref17name, $ahref18name, $ahref19name, $ahref20name,
$filename, $imurl, $hrline, $emailpic, $textcolor, $bullet, $tbltext);

($usrname, $mail, $bgimage, $head, $sub, $body, $linkcolor, $vlinkcolor,
$ahref1, $ahref2, $ahref3, $ahrefname1, $ahref2name, $ahref3name,
$filename, $imurl, $hrline, $emailpic, $textcolor, $bullet, $tbltext) = split(/&&/, "");

$ahref1="http://";
$ahref2="http://";
$ahref3="http://";
$textcolor="#000000";
$linkcolor="#0000ff";
$vlinkcolor="#800000";
$bullet="0";
# To avoid any security risks. Take out the HTML tags added when HPM translated
# the && to: <br><br>. They will be re-translated to: && Once the user updates
# the page, the: && will be put back to: <br><br>
$body =~ s/<br><br>/&&/g;

# print the edit-page form

print "Content-type: text/html\n\n";
print "<html><head><title>Free Genealogy Homepages</title></head>\n";
print "<body bgcolor=\"#ffffff\" TEXT=\"#000000\" link=\"#008000\" vlink=\"#800040\">\n";
print "<center><img src=\"$logo\" alt=\"$logoalt\" border=0></center><p>\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "<table width=75% cellspacing=2 cellpadding=2 border=0>\n";
print "<tr><td width=100% align=left valign=top>\n";
print "<p><font face=\"Arial, Geneva\"><h2>Create Your Own Family HomePage</h2></font></p>\n";
print "<p>Below is an empty form for you to fill in. The next five fields (<b>bold</b> ) are required.\n";
print "You can edit any part of your page later</p>\n";
print "<p></p>\n";
print "<form action=\"$cgiurl/ezhomepg.pl\" method=POST>\n";
print "<input type=hidden name=\"action\" value=\"Create Page\">\n";
print "<b>Your name:</b><br>\n";
print "<font size=\"-1\">(will appear in page as a link to your email)</font><br>\n";
print "<input type=text size=40 name=\"usrname\" value=\"$usrname\"><br><br>\n";
print "<h3>(The next 3 fields will be used for editing)<h3>\n";
print "<b>Login Id:</b>\n";
print "<font size=\"-1\">(one word only, it will be used later for editing)</font><br>\n";
print "<input type=text size=40 name=\"login\" value=\"$login\"><br><br>\n";
print "<b>Your e-mail:</b>\n";
print "<font size=\"-1\">(used for editing, will also appear in your page)</font><br>\n";
print "<input type=text size=40 name=\"email\" value=\"$mail\"><br><br>\n";
print "<b>Your page:</b>\n";
print "<font size=\"-1\">(one word, will become the name of your html file, example sandy, smiths001)</font><br>\n";
print "<input type=text size=40 name=\"pagename\" value=\"$filename\"><br><br>\n";
print "<b>Headline:</b>\n";
print "<font size=\"-1\">(how your page will be listed in index example Bob's Family Online)</font><br>\n";
print "<input type=text size=40 name=\"headline\" value=\"$head\"><br><br>\n";
print "</td></tr></table>\n";
print "<b>Sub Head:</b><br>\n";
print "Example: The Berringer's Immigration<BR><input type=text size=40 name=\"subhead\" value=\"$sub\"><br><br>\n";
print "<b>Do you want the headings centered:</b> <input type=radio name=\"headpos\" value=\"yes\" checked>Yes\n";
print "<input type=radio name=\"headpos\" value=\"no\">No<p>\n";
&build_form_body($usrname, $mail, $head, $sub, $body, $bgimage, $linkcolor, $vlinkcolor,
$ahref1, $ahref2, $ahref3, $ahrefname1, $ahref2name, $ahref3name,
$filename, $imurl, $hrline, $emailpic, $textcolor, $bullet, $tbltext);
print "<P><input type=submit value=\"create page\">\n";
print "</form>\n";
print "</body></html>\n";
}

sub create {

# Now, lets do some error checking. Making sure they filled out each field
# This is pretty low tech now. I'll improve it later
&missing(missing_name) unless $usrname;
&missing(missing_email) unless $email;
&missing(missing_pagename) unless $pagename;

# if they try to name their page "index" This will stop them
if ($pagename eq "index") {
print "Content-type: text/html\n\n";
print "<html><head><title>Error</title></head>\n";
print "<body><center><img src=\"$logo\" alt=\"$logoalt\" border=0></center><p>\n";
print "<p>You cannot name your page <b>index</b>\n";
print "Please go back and re-name your page</p>\n";
print "<p>(Return to <a href=\"$baseurl\">User Pages</a> )\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
exit;
}
# if they Don't give their page a heading This will stop them
if ($headline eq "") {
print "Content-type: text/html\n\n";
print "<html><head><title>Error</title></head>\n";
print "<body><p>You MUST give your page a <b>Headline</b>\n";
print "Please go back and enter one for your page</p>\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
exit;
}

# if the user tries to name their page
# something that is already taken
# this will HOPEFULLY stop them
# This block was written by Norm
if (-e "$page_dir$pagename\.html") {
print "Content-type: text/html\n\n";
print "<html><head><title>Error</title></head>\n";
print "<body><p>The page name: <b>$pagename</b>\n";
print "is already taken.\n";
print "Please go back and rename your page</p>\n";
print "<p>(Return to <a href=\"$baseurl\">User Pages</a> )\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
exit;
}

#now, lets create our new html page
&buildpage;

# Write the login name and email address to a separate file for confirmation
# when they want to edit their page
open (FILE, ">>$data") | | die "I can't open $data\n";
flock (FILE, 2) or die "can't lock data file\n";
print FILE "$login&&$email&&$pagename\n";
close(FILE);


# Suck the index page, and write the new entry to it
open(FILE, "$indexpage") | | die "I can't open that file\n";
flock (FILE, 1) or die "can't lock index file\n";
@lines = <FILE>;
close(FILE);
$sizelines = @lines;

# Now, re-open the links file, and add the new link
open(FILE, ">$indexpage") | | die "I can't open that file\n";
flock (FILE, 2) or die "can't lock index file\n";

for ($a = 0; $a <= $sizelines; $a++) {

$_ = $lines[$a];

if (/<!--begin-->/) {

print FILE "<!--begin-->\n";
print FILE "<p><font face=\"Arial, Geneva\" size=4><a href=\"$baseurl$pagename.html\">$headline</a></p>\n";

} else {
print FILE $_;
}
}
close(FILE);


# Give the user a response
print "Content-type: text/html\n\n";
print "<html><head><title>thanks</title></head>\n";
print "<body bgcolor=\"#ffffff\" TEXT=\"#000000\" link=\"#008000\" vlink=\"#800040\">\n";
print "<center><img src=\"$logo\" alt=\"$logoalt\" border=0></center><p>\n";
print "<BR><BR><FONT SIZE=4 FACE=\"COMIC SANS MS,ARIAL\">\n";

print "Your page has been created, and you will receive an e-mail confirming this!\n";
print "Your URL is: <a href=\"$baseurl$pagename\.html\">\n";
print "$baseurl$pagename\.html</a> - remember to press Reload\n";
print "<br>You can also find your homepage at<br> http://search4roots.cjb.net/pages/yourpagename.html\n";
print "If you haven't done so yet, Please go to http://search4roots.virtualave.net and add your family page to our listing.\n";
print "Thanks for your participation!\n";
print "<p>(Return to <a href=\"$baseurl\">User Pages</a> )\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "</body></html>\n";


# Send the user an e-mail confirming their page
open (MAIL, "| $sendmail -t") | | die "I can't open sendmail\n";
print MAIL "To: $usrname <$email>\n";
print MAIL "From: $myemail\n";
print MAIL "Subject: Your URL on the $title\n";
print MAIL "Your page can be viewed at the URL below:\n";
print MAIL "\n";
print MAIL "$baseurl$pagename\.html\n";
print MAIL "You can also find your homepage at\n";
print MAIL "http://search4roots.cjb.net/pages/$pagename\.html\n";
print MAIL "\n";
print MAIL "If you haven't done so yet, add your homepage to the Search4Roots Genealogy Search Engine at http://search4roots.virtualave.net\n";
print MAIL "\n";
print MAIL "Remember to go to http://rootssearch.hypermart.net to edit your pages or to create new ones to link together.\n";
print MAIL "\nThank you for using the $title\n";
print MAIL "\n\nWebmaster - $myemail\n";
close (MAIL);

# Notify us when someone creates a page
open (MAIL, "| $sendmail -t") | | die "I can't open sendmail\n";
print MAIL "To: $myemail\n";
print MAIL "From: $usrname <$email>\n";
print MAIL "Subject: New Genealogy Homepage Created\n";
print MAIL "$usrname created a new page:\n";
print MAIL "$baseurl$pagename\.html\n";
print MAIL "\nThe content is :\n$content\n";
close(MAIL);

}

sub recreate {
#now, lets create our new html page
&buildpage;

# Send the user a notice that their page has been re-done
open (MAIL, "| $sendmail -t") | | die "I can't open sendmail\n";
print MAIL "To: $usrname <$email>\n";
print MAIL "From: $myemail\n";
print MAIL "Subject: Your Changes on the $title\n";
print MAIL "Your revised page can be viewed at the URL below:\n";
print MAIL "\n";
print MAIL "$baseurl$pagename\.html\n";
print MAIL "You can also find your homepage at\n";
print MAIL "http://search4roots.cjb.net/pages/$pagename\.html\n";
print MAIL "\n";
print MAIL "If you haven't done so yet, add your homepage to the Search4Roots Genealogy Search Engine at http://search4roots.virtualave.net\n";
print MAIL "\n";
print MAIL "Remember to go to http://rootssearch.hypermart.net to edit your pages or to create new ones to link together.\n";
print MAIL "\nOnce again thank you for using the $title\n";
print MAIL "\n\nThe Webmaster\n";
close (MAIL);

# Give the user a response
print "Content-type: text/html\n\n";
print "<html><head><title>thanks</title></head>\n";
print "<body bgcolor=\"#ffffff\" TEXT=\"#000000\" link=\"#008000\" vlink=\"#800040\">\n";
print "<CENTER><IMG SRC=\"$logo\" alt=\"$logoalt\" border=0></CENTER>\n";

print "<P><BR><BR><FONT SIZE=4 FACE=\"COMIC SANS MS,ARIAL\">\n";

print "Your page has been revised, and you will receive an e-mail confirming this!\n";
print "Your URL is: <a href=\"$baseurl$pagename\.html\">\n";
print "$baseurl$pagename\.html</a> - remember to press Reload\n";
print "You can also find your homepage at http://search4roots.cjb.net/pages/yourpagename.html\n";
print "If you haven't done so yet, Please go to http://search4roots.virtualave.net and add your family page to our listing.\n";
print "Thanks for your participation!\n";
print "<p>(Return to <a href=\"$baseurl\">User Pages</a> )\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "</body></html>\n";
}

sub buildpage {
open(HTML, ">$page_dir$pagename\.html") | | die "I can't create $pagename\.html\n";
flock (HTML, 2) or die "can't lock html file\n";
print HTML "<html><head><title>$headline</title></head>\n";
print HTML "<body background=\"$background\" text=$textc link=$linkc vlink=$vlinkc><font face=\"Arial\">\n";
print HTML "<blockquote>\n";
if ($headpos eq "yes") {
print HTML "<center>\n";
}
print HTML "<p><font face=\"Arial, Geneva\" size=+7>$headline</font></p>\n";
if ($headpos eq "yes") {
print HTML "</center>\n";
}
if ($imageyn eq "yes") {
if ($imagepos eq "yes") {
print HTML "<center>\n";
}
if (($topimage eq "0") or ($topimage eq "")) {
print HTML "";
}
else {
print HTML "<img src=\"$topimage\">\n";
}
print HTML "<p><font face=\"Arial, Geneva\" size=+2><b>$subhead</b></font>\n";
if ($imagepos eq "yes") {
print HTML "</center>\n";
}
print HTML "<center>";
if (($line2 eq "0") or ($line2 eq "")) {
print HTML "";
}
else {
print HTML "<img src=\"$line2\"></center><P>\n";
}
}
@atxt = split(/%%/, $content);
if ($bullet eq "0") {
print HTML "<center>\n";
foreach $txtline(@atxt) {
print HTML "<p><font face=\"Arial, Geneva\" size=3>$txtline</font>\n";
}
print HTML "</center>";
}
else {
print HTML "<table border=0 cellpadding=5>\n";
foreach $txtline (@atxt) {
print HTML "<tr><td valign=top><img src=\"$bullet\"></td>\n";
print HTML "<td><font face=\"Arial, Geneva\" size=3>$txtline</font></td></tr>\n";
}
print HTML "</table>\n";
}

print HTML "<center>\n";
print HTML "<p><table border=1 cellspacing=3 cellpadding=3>";
@all = split(/%%/,$tbltext);
foreach $tbline (@all) {
print HTML "<tr>";
@flds = split(/\:\:/, $tbline);
foreach $fld (@flds) {
print HTML "<td>$fld</td>";
}
print HTML "</tr>";
}
print HTML "</table>";
print HTML "</center>";

if ($bullet eq "0") {
print HTML "\n";
}
print HTML "<p><i><font face=\"Arial, Geneva\" size=4><b>Other Links</i></b></font></p>\n";
print HTML "<p><font face=\"Arial, Geneva\" size=3><a href=\"$usrlink1\">$linkname1</a><br>\n";
print HTML "<a href=\"$usrlink2\">$linkname2</a><br>\n";
print HTML "<a href=\"$usrlink3\">$linkname3</a><br>\n";
print HTML "<a href=\"$usrlink4\">$linkname4</a><br>\n";
print HTML "<a href=\"$usrlink5\">$linkname5</a><br>\n";
print HTML "<a href=\"$usrlink6\">$linkname6</a><br>\n";
print HTML "<a href=\"$usrlink7\">$linkname7</a><br>\n";
print HTML "<a href=\"$usrlink8\">$linkname8</a><br>\n";
print HTML "<a href=\"$usrlink9\">$linkname9</a><br>\n";
print HTML "<a href=\"$usrlink10\">$linkname10</a><br>\n";
print HTML "<a href=\"$usrlink11\">$linkname11</a><br>\n";
print HTML "<a href=\"$usrlink12\">$linkname12</a><br>\n";
print HTML "<a href=\"$usrlink13\">$linkname13</a><br>\n";
print HTML "<a href=\"$usrlink14\">$linkname14</a><br>\n";
print HTML "<a href=\"$usrlink15\">$linkname15</a><br>\n";
print HTML "<a href=\"$usrlink16\">$linkname16</a><br>\n";
print HTML "<a href=\"$usrlink17\">$linkname17</a><br>\n";
print HTML "<a href=\"$usrlink18\">$linkname18</a><br>\n";
print HTML "<a href=\"$usrlink19\">$linkname19</a><br>\n";
print HTML "<a href=\"$usrlink20\">$linkname20</a></font></p>\n";
if ($bullet eq "0") {
print HTML "\n";
}

print HTML "<center>";
if (($line2 eq "0") or ($line2 eq "")) {
print HTML "";
} else {
print HTML "<img src=\"$line2\"></center>\n";
}
print HTML "<p><center>";
if ($emailgif ne "") {
print HTML "<img src=\"$emailgif\"><br>\n";
}
print HTML "<a href=\"mailto:$email\">$usrname</a></font></center></p>\n";
print HTML "<p><center><font size=-1>";
print HTML "This page hosted by: ";
print HTML "<a href=http://rootssearch.hypermart.net>Roots-Search Free Family Homepages</a><br>\n";
print HTML "And <a href=http://search4roots.virtualave.net>Search4Roots Genealogy Search Engine</a></font><br><br>\n";
print HTML "<center><small><small><!--#echo banner=\"\"--></small></small><p></center>\n";
print HTML "</blockquote>\n";
print HTML "</center></body></html>";

close(HTML);


# Write all of the input into a flat file.
open(FILE, ">$page_dir$pagename\.dat") | | die "I can't create $pagename\.dat\n";
flock (FILE, 2) or die "can't lock user data file\n";
$tbltext =~ s/\n/%%/g;
print FILE "$usrname&&$email&&$background&&$headline&&$subhead&&$content&&$linkc&&$vlinkc&&$usrlink1&&$usrlink2&&$usrlink3&&usrlink4&&usrlink5&&usrlink6&&usrlink7&&usrlink8&&usrlink9&&usrlink 10&&usrlink11&&usrlink12&&usrlink13&&usrlink14&&usrlink15&&usrlink16&&usrlink17&&usrlink18&&usrlink19&&usrlink20&&$linkname1&&$linkname2&&$linkname3&&$linkname4&&$linkname5&&$linkn ame6&&$linkname7&&$linkname8&&$linkname9&&$linkname10&&$linkname11&&$linkname12&&$linkname13&&$linkname14&&$linkname15&&$linkname16&&$linkname17&&$linkname18&&$linkname19&&$linknam e20&&$pagename&&$topimage&&$line2&&$ emailgif&&$textc&&$bullet&&$tbltext\n";
close(FILE);
chmod 0777, '$page_dir$pagename.dat';
}

# Standard error message for any missing required fields
sub missing {
local ($missing) = @_;
print "Content-type: text/html\n\n";

print "<HTML><HEAD><TITLE>You missed something</TITLE></HEAD>\n";
print "<BODY>\n";
print "You forgot to fill in one of the fields. Please go back and make\n";
print "sure that all required fields are filled in! $missing\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "</BODY></HTML>\n";
exit;
}

sub confirm {
local ($updact) = @_;

print "Content-type: text/html\n\n";
print "<html><head><title>$updact Confirmation</title></head>\n";
print "<body bgcolor=\"#ffffff\" TEXT=\"#000000\" link=\"#008000\" vlink=\"#800040\" >\n";
print "<CENTER><IMG SRC=\"$logo\" alt=\"$logoalt\" border=0></CENTER>\n";
print "<P><BR><FONT SIZE=4 FACE=\"COMIC SANS MS,ARIAL\">\n";
print "<p><h3>Please Enter your login name, e-mail and name of your file to $updact</h3></p>\n";
print "<form action=\"$cgiurl/ezhomepg.pl\" method=POST>\n";
print "<P><BR><FONT SIZE=4 FACE=\"COMIC SANS MS,ARIAL\">\n";
print "Login name:<br>\n";
print "<input size=40 type=text name=\"login\"><br><br>\n";
print "E-mail:<br>\n";
print "<input size=40 type=text name=\"email\"><br><br>\n";
print "Name of your file:<br>\n";
print "<input type=text size=40 name=\"pagename\"><br><br>\n";
print "<input type=submit value=submit>\n";
print "<input type=hidden name=\"action\" value=\"checkuser\">\n";
print "<input type=hidden name=\"updact\" value=\"$updact\">\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "</FONT>\n";
print "</form></body></html>\n";
}

sub checkuser {
open(FILE, "$data") | | die "I can't open $data\n";
flock (FILE, 1) or die "can't lock data file\n";

while(<FILE> ) {
chop;
@all = split(/\n/);

foreach $line (@all) {
($loginname, $loginemail, $loginpagename) = split(/&&/, $line);
if($loginname eq "$login" && $loginemail eq "$email" && $loginpagename eq "$pagename") {
$match = 1;
if($updact eq "edit") {
&edit($loginpagename);
}
else {
&delpage($loginpagename);
}
}
}
}

close(FILE);

if (! $match) {
&error;
}

# del entry from data
if($updact eq "delete") {

# Suck the index page, and write the new entry to it
open(FILE, "$data") | | die "I can't open that file\n";
flock (FILE, 1) or die "can't lock data file\n";
@lines = <FILE>;
close(FILE);
$sizelines = @lines;

# Now, re-open the links file, and comment out the page to delete
open(FILE, ">$data") | | die "I can't open that file\n";
flock (FILE, 2) or die "can't lock index file for append\n";
chop;
for ($a = 0; $a <= $sizelines; $a++) {
$_ = $lines[$a];
$w = $_;
$w =~ s/\cM//g;
$w =~ s/\n//g;
($loginname, $loginemail, $loginpagename) = split(/&&/, $w);
if($loginname eq "$login" && $loginemail eq "$email" && $loginpagename eq "$pagename") {
# do nothing (ie. don't write)
}
else {
if($w eq "") {
# do nothing (skip)
}
else {
print FILE "$w\n";
}
}
}
close(FILE);
print "Content-type: text/html\n\n";
print "<html><head><title>$updact Confirmation</title></head>\n";
print "<body bgcolor=\"#ffffff\" TEXT=\"#000000\" link=\"#008000\" vlink=\"#800040\" >\n";
print "<CENTER><IMG SRC=\"$logo\" alt=\"$logoalt\" border=0></CENTER>\n";
print "<P><BR><FONT SIZE=4 FACE=\"COMIC SANS MS,ARIAL\">\n";
print "<p>your page has been deleted";
print "<p>(Return to <a href=\"$baseurl\">User Pages</a> )\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "</form></body></html>\n";
}
}

sub edit {

local ($editfile) = @_;

open(FILE, "$page_dir$editfile\.dat") | | die "I can't open $editfile\n";
flock (FILE, 1) or die "can't lock data file for edit\n";

while(<FILE> ) {
chop;
@datafile = split(/\n/);

foreach $line (@datafile) {
&build_edit_form($line);
}
}
close(FILE);
}

sub delpage {
local ($editfile) = @_;
$cnt=unlink "$page_dir$editfile\.dat", "$page_dir$editfile\.html";

# Suck the index page, and write the new entry to it
open(FILE, "$indexpage") | | die "I can't open that file\n";
flock (FILE, 1) or die "can't lock index file\n";
@lines = <FILE>;
close(FILE);
$sizelines = @lines;

# Now, re-open the links file, and comment out the page to delete
open(FILE, ">$indexpage") | | die "I can't open that file\n";
flock (FILE, 2) or die "can't lock index file to delete entry\n";

for ($a = 0; $a <= $sizelines; $a++) {

$_ = $lines[$a];

if (/$pagename.html/) {
# do nothing (ie. don't write)
}
else {
print FILE $_;
}
}
close(FILE);

}

sub build_edit_form($line) {
local ($line) = @_;
local($fullname, $mail, $head, $sub, $body, $bgimage, $linkcolor, $vlinkcolor,
$ahref1, $ahref2, $ahref3, $ahref4, $ahref5, $ahref6, $ahref7, $ahref8, $ahref9, $ahref10,
$ahref11, $ahref12, $ahref13, $ahref14, $ahref15, $ahref16, $ahref17, $ahref18, $ahref19,
$ahref20, $ahrefname1, $ahref2name, $ahref3name, $ahref4name, $ahref5name, $ahref6name,
$ahref7name, $ahref8name, $ahref9name, $ahref10name, $ahref11name, $ahref12name,
$ahref13name, $ahref14name, $ahref15name, $ahref16name, $ahref17name, $ahref18name,
$ahref19name, $ahref20name, $filename, $imurl, $hrline, $emailpic, $textcolor, $bullet, $tbltext);

($fullname, $mail, $bgimage, $head, $sub, $body, $linkcolor, $vlinkcolor, $ahref1, $ahref2,
$ahref3, $ahref4, $ahref5, $ahref6, $ahref7, $ahref8, $ahref9, $ahref10, $ahref11, $ahref12,
$ahref13, $ahref14, $ahref15, $ahref16, $ahref17, $ahref18, $ahref19, $ahref20, $ahrefname1, $ahref2name,
$ahref3name, $ahref4name, $ahref5name, $ahref6name, $ahref7name, $ahref8name, $ahref9name,
$ahref10name, $ahref11name, $ahref12name, $ahref13name, $ahref14name, $ahref15name,
$ahref16name, $ahref17name, $ahref18name, $ahref19name, $ahref20name, $filename, $imurl,
$hrline, $emailpic, $textcolor, $bullet, $tbltext) = split(/&&/, $line);

# To avoid any security risks. Take out the HTML tags added when HPM translated
# the && to: <br><br>. They will be re-translated to: && Once the user updates
# the page, the: && will be put back to: <br><br>
$body =~ s/<br><br>/&&/g;

# print the edit-page form

print "Content-type: text/html\n\n";
print "<html><head><title>Edit Your Page</title></head>\n";
print "<body bgcolor=\"#ffffff\" TEXT=\"#000000\" link=\"#008000\" vlink=\"#800040\">\n";
print "<center><img src=\"$logo\" alt=\"$logoalt\" border=0></center><p>\n";
print "<table width=75% cellspacing=2 cellpadding=2 border=0>\n";
print "<tr><td width=100% align=left valign=top>\n";
print "<p><font face=\"Arial, Geneva\"><h2>Edit Your Page</h2></font></p>\n";
print "<p>Below is a form with the contents\n";
print "of the home page you created. You can edit any part of your page</p>\n";
print "<p></p>\n";
print "<form action=\"$cgiurl/ezhomepg.pl\" method=POST>\n";
print "<input type=hidden name=\"action\" value=\"recreate\">\n";
print "Your name:<br>\n";
print "<input type=text size=40 name=\"usrname\" value=\"$fullname\"><br><br>\n";
print "Your e-mail:<br>\n";
print "<input type=text size=40 name=\"email\" value=\"$mail\"><br><br>\n";
print "Headline:<br>\n";
print "<input type=text size=40 name=\"headline\" value=\"$head\"><br><br>\n";
print "</td></tr></table>\n";
print "<b>Sub Head:</b><br>\n";
print "<input type=text size=40 name=\"subhead\" value=\"$sub\"><br><br>\n";
print "<b>Do you want the headings Centered:</b> <input type=radio name=\"headpos\" value=\"yes\" checked>Yes\n";
print "<input type=radio name=\"headpos\" value=\"no\">No<p>\n";
print "Name of HTML file: <b>$filename</b><br><br>\n";
print "<input type=hidden name=\"pagename\" value=\"$filename\">\n";
&build_form_body($fullname, $mail, $head, $sub, $body, $bgimage, $linkcolor, $vlinkcolor,
$ahref1, $ahref2, $ahref3, $ahrefname1, $ahref2name, $ahref3name,
$filename, $imurl, $hrline, $emailpic, $textcolor, $bullet, $tbltext);
print "<P><input type=submit value=\"update page\">\n";
print "</form>\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "</body></html>\n";
}

sub build_form_body($fullname, $mail, $head, $sub, $body, $bgimage, $linkcolor, $vlinkcolor,
$ahref1, $ahref2, $ahref3, $ahrefname1, $ahref2name, $ahref3name,
$filename, $imurl, $hrline, $emailpic, $textcolor, $bullet, $tbltext) {

print "<b>Splash Graphic:</b><br>\n";
opendir (TN, "$tnp_dir");
rewinddir (TN);
@tnlist = grep(!/^\.\.?$/, readdir (TN));
closedir (TN);

$tnnum = @tnlist;
$cnum = "0";
print "<input type=radio name=\"topimage\" value=\"0\">No Graphic</a><br><br>\n";
$lend = "0";
while ($tnnum > $cnum) {
print "<input type=radio name=\"topimage\" value=\"$tnp_dir_url/$tnlist[$cnum]\" ";
if ($imurl eq "$tnp_dir_url/$tnlist[$cnum]") {print "checked";}
print "><img src=\"$tnp_dir_url/$tnlist[$cnum]\" border=0></a>\n";
$cnum = $cnum + 1;
$lend = $lend + 1;
if ($lend eq "4"){
print "<br><br>\n";
$lend = 0;
}
}
print "<br><br><b>Do you want the image Centered? :</b> <input type=radio name=\"imagepos\" value=\"yes\" checked>Yes\n";
print "<input type=radio name=\"imagepos\" value=\"no\">No<p>\n";
print "<b>Body:</b> (use two percent signs (<b>%%</b> ) BETWEEN paragraphs)<br>\n";
print "<textarea cols=65 rows=6 wrap=on name=\"content\">$body</textarea><br><br>\n";
print << 'END'
<b>Table (Optional):</b> use two percent signs (<b>%%</b> ) BETWEEN rows, use 2 colons (<b>::</b> ) BETWEEN fields. for example:
<pre>
su :: mo :: tu :: we :: th :: fr :: sa
%% :: :: :: 1 :: 2 :: 3 :: 4
%% 5 :: 6 :: 7 :: 8 :: 9 :: 10 :: 11
%% 12 :: 13 :: 14 :: 15 :: 16 :: 17 :: 18
%% 19 :: 20 :: 21 :: 22 :: 23 :: 24 :: 25
%% 26 :: 27 :: 28 :: 29 :: 30
</pre>
END
;

$tbltext =~ s/%%/\n%%/g;
print "<textarea cols=65 rows=6 wrap=on name=\"tbltext\">$tbltext</textarea><br><br>";

print "<b>Links</b><br>\n";
print "<table width=75% cellpadding=2 cellspacing=2 border=0>\n";
print "<tr><td width=50% align=left valign=top>\n";
print "Link 1 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink1\" value=\"$ahref1\"><br><br>\n";
print "Link 2 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink2\" value=\"$ahref2\"><br><br>\n";
print "Link 3 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink3\" value=\"$ahref3\"><br><br>\n";
print "Link 4 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink4\" value=\"$ahref4\"><br><br>\n";
print "Link 5 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink5\" value=\"$ahref5\"><br><br>\n";
print "Link 6 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink6\" value=\"$ahref6\"><br><br>\n";
print "Link 7 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink7\" value=\"$ahref7\"><br><br>\n";
print "Link 8 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink8\" value=\"$ahref8\"><br><br>\n";
print "Link 9 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink9\" value=\"$ahref9\"><br><br>\n";
print "Link 10 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink10\" value=\"$ahref10\"><br><br>\n";
print "Link 11 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink11\" value=\"$ahref11\"><br><br>\n";
print "Link 12 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink12\" value=\"$ahref12\"><br><br>\n";
print "Link 13 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink13\" value=\"$ahref13\"><br><br>\n";
print "Link 14 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink14\" value=\"$ahref14\"><br><br>\n";
print "Link 15 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink15\" value=\"$ahref15\"><br><br>\n";
print "Link 16 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink16\" value=\"$ahref16\"><br><br>\n";
print "Link 17 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink17\" value=\"$ahref17\"><br><br>\n";
print "Link 18 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink18\" value=\"$ahref18\"><br><br>\n";
print "Link 19 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink19\" value=\"$ahref19\"><br><br>\n";
print "Link 20 URL:<br>\n";
print "<input type=text size=40 name=\"usrlink20\" value=\"$ahref20\"><br><br>\n";
print "</td>\n";
print "<td width=50% align=left valign=top>\n";
print "Link 1 Name:<br>\n";
print "<input type=text size=40 name=\"linkname1\" value=\"$ahrefname1\"><br><br>\n";
print "Link 2 Name:<br>\n";
print "<input type=text size=40 name=\"linkname2\" value=\"$ahref2name\"><br><br>\n";
print "Link 3 Name:<br>\n";
print "<input type=text size=40 name=\"linkname3\" value=\"$ahref3name\"><br><br>\n";
print "Link 4 Name:<br>\n";
print "<input type=text size=40 name=\"linkname4\" value=\"$ahref4name\"><br><br>\n";
print "Link 5 Name:<br>\n";
print "<input type=text size=40 name=\"linkname5\" value=\"$ahref5name\"><br><br>\n";
print "Link 6 Name:<br>\n";
print "<input type=text size=40 name=\"linkname6\" value=\"$ahref6name\"><br><br>\n";
print "Link 7 Name:<br>\n";
print "<input type=text size=40 name=\"linkname7\" value=\"$ahref7name\"><br><br>\n";
print "Link 8 Name:<br>\n";
print "<input type=text size=40 name=\"linkname8\" value=\"$ahref8name\"><br><br>\n";
print "Link 9 Name:<br>\n";
print "<input type=text size=40 name=\"linkname9\" value=\"$ahref9name\"><br><br>\n";
print "Link 10 Name:<br>\n";
print "<input type=text size=40 name=\"linkname10\" value=\"$ahref10name\"><br><br>\n";
print "Link 11 Name:<br>\n";
print "<input type=text size=40 name=\"linkname11\" value=\"$ahref11name\"><br><br>\n";
print "Link 12 Name:<br>\n";
print "<input type=text size=40 name=\"linkname12\" value=\"$ahref12name\"><br><br>\n";
print "Link 13 Name:<br>\n";
print "<input type=text size=40 name=\"linkname13\" value=\"$ahref13name\"><br><br>\n";
print "Link 14 Name:<br>\n";
print "<input type=text size=40 name=\"linkname14\" value=\"$ahref14name\"><br><br>\n";
print "Link 15 Name:<br>\n";
print "<input type=text size=40 name=\"linkname15\" value=\"$ahref15name\"><br><br>\n";
print "Link 16 Name:<br>\n";
print "<input type=text size=40 name=\"linkname16\" value=\"$ahref16name\"><br><br>\n";
print "Link 17 Name:<br>\n";
print "<input type=text size=40 name=\"linkname17\" value=\"$ahref17name\"><br><br>\n";
print "Link 18 Name:<br>\n";
print "<input type=text size=40 name=\"linkname18\" value=\"$ahref18name\"><br><br>\n";
print "Link 19 Name:<br>\n";
print "<input type=text size=40 name=\"linkname19\" value=\"$ahref19name\"><br><br>\n";
print "Link 20 Name:<br>\n";
print "<input type=text size=40 name=\"linkname20\" value=\"$ahref20name\"><br><br>\n";
print "</td></tr></table>\n";
print "<b>Text</b><br>\n";
print "Text color:<br>\n";
print "<input type=radio name=\"textc\" value=\"#000000\"";
if ($textcolor eq "#000000") {print "checked";}
print ">Black\n";
print "<input type=radio name=\"textc\" value=\"#800000\"";
if ($textcolor eq "#800000") {print "checked";}
print ">Maroon\n";
print "<input type=radio name=\"textc\" value=\"#ff0000\"";
if ($textcolor eq "#ff0000") {print "checked";}
print ">Red\n";
print "<input type=radio name=\"textc\" value=\"#ffff00\"";
if ($textcolor eq "#ffff00") {print "checked";}
print ">Yellow\n";
print "<input type=radio name=\"textc\" value=\"#00ff00\"";
if ($textcolor eq "#00ff00") {print "checked";}
print ">Green\n";
print "<input type=radio name=\"textc\" value=\"#ffffff\"";
if ($textcolor eq "#ffffff") {print "checked";}
print ">White\n";
print "<input type=radio name=\"textc\" value=\"#0000ff\"";
if ($textcolor eq "#0000ff") {print "checked";}
print ">Blue<br><br>\n";
print "Link color:<br>\n";
print "<input type=radio name=\"linkc\" value=\"#000000\"";
if ($linkcolor eq "#000000") {print "checked";}
print ">Black\n";
print "<input type=radio name=\"linkc\" value=\"#800000\"";
if ($linkcolor eq "#800000") {print "checked";}
print ">Maroon\n";
print "<input type=radio name=\"linkc\" value=\"#ff0000\"";
if ($linkcolor eq "#ff0000") {print "checked";}
print ">Red\n";
print "<input type=radio name=\"linkc\" value=\"#ffff00\"";
if ($linkcolor eq "#ffff00") {print "checked";}
print ">Yellow\n";
print "<input type=radio name=\"linkc\" value=\"#00ff00\"";
if ($linkcolor eq "#00ff00") {print "checked";}
print ">Green\n";
print "<input type=radio name=\"linkc\" value=\"#ffffff\"";
if ($linkcolor eq "#ffffff") {print "checked";}
print ">White\n";
print "<input type=radio name=\"linkc\" value=\"#0000ff\"";
if ($linkcolor eq "#0000ff") {print "checked";}
print ">Blue<br><br>\n";
print "Visited Link Color:<br>\n";
print "<input type=radio name=\"vlinkc\" value=\"#000000\"";
if ($vlinkcolor eq "#000000") {print "checked";}
print ">Black\n";
print "<input type=radio name=\"vlinkc\" value=\"#800000\"";
if ($vlinkcolor eq "#800000") {print "checked";}
print ">Maroon\n";
print "<input type=radio name=\"vlinkc\" value=\"#ff0000\"";
if ($vlinkcolor eq "#ff0000") {print "checked";}
print ">Red\n";
print "<input type=radio name=\"vlinkc\" value=\"#ffff00\"";
if ($vlinkcolor eq "#ffff00") {print "checked";}
print ">Yellow\n";
print "<input type=radio name=\"vlinkc\" value=\"#00ff00\"";
if ($vlinkcolor eq "#00ff00") {print "checked";}
print ">Green\n";
print "<input type=radio name=\"vlinkc\" value=\"#ffffff\"";
if ($vlinkcolor eq "#ffffff") {print "checked";}
print ">White\n";
print "<input type=radio name=\"vlinkc\" value=\"#0000ff\"";
if ($vlinkcolor eq "#0000ff") {print "checked";}
print ">Blue<br><br>\n";

print "<b>Background image:</b><br>\n";
opendir (TN, "$tnbg_dir");
rewinddir (TN);
@tnlist = grep(!/^\.\.?$/, readdir (TN));
closedir (TN);

$tnnum = @tnlist;
$cnum = "0";
while ($tnnum > $cnum) {
print "<input type=radio name=\"background\" value=\"$tnbg_dir_url/$tnlist[$cnum]\" " ;
if ($bgimage eq "$tnbg_dir_url/$tnlist[$cnum]") {print "checked";}
print "><img src=\"$tnbg_dir_url/$tnlist[$cnum]\" border=1></a><br><br>\n";
$cnum = $cnum + 1;
print "\n";
}
print "<b>Horizontal Line:</b><br>\n";
opendir (TN, "$tn_dir");
rewinddir (TN);
@tnlist = grep(!/^\.\.?$/, readdir (TN));
closedir (TN);

$tnnum = @tnlist;
$cnum = "0";
print "<input type=radio name=\"line\" value=\"0\"";
if ($line2 eq "0") { print " checked";}
print ">No Line</a><br><br>\n";
while ($tnnum > $cnum) {
print "<input type=radio name=\"line\" value=\"$tn_dir_url/$tnlist[$cnum]\"";
if ($hrline eq "$tn_dir_url/$tnlist[$cnum]") {print "checked";}
print "><img src=\"$tn_dir_url/$tnlist[$cnum]\" border=0></a><br><br>\n";
$cnum = $cnum + 1;
print "\n";
}

print "<b>Bullet:</b><br>\n";
opendir (TN, "$tnb_dir");
rewinddir (TN);
@tnlist = grep(!/^\.\.?$/, readdir (TN));
closedir (TN);

$tnnum = @tnlist;
$cnum = "0";
print "<input type=radio name=\"bullet\" value=\"0\"";
if($bullet eq "0") {print "checked";}
print ">No Bullet (all text will be centered)</a><br><br>\n";
$lend = "0";
while ($tnnum > $cnum) {
print "<input type=radio name=\"bullet\" value=\"$tnb_dir_url/$tnlist[$cnum]\"";
if ($bullet eq "$tnb_dir_url/$tnlist[$cnum]") {print "checked";}
print "><img src=\"$tnb_dir_url/$tnlist[$cnum]\" border=0></a>\n";
$cnum = $cnum + 1;
$lend = $lend + 1;
if ($lend eq "10"){
print "<br><br>\n";
$lend = 0;
}
}

print "<b>Email image:</b><br>\n";
opendir (TN, "$tne_dir");
rewinddir (TN);
@tnlist = grep(!/^\.\.?$/, readdir (TN));
closedir (TN);

$tnnum = @tnlist;
$cnum = "0";
$lend = "0";
while ($tnnum > $cnum) {
print "<input type=radio name=\"emailgif\" value=\"$tne_dir_url/$tnlist[$cnum]\"";
if ($emailpic eq "$tne_dir_url/$tnlist[$cnum]") {print "checked";}
print "><img src=\"$tne_dir_url/$tnlist[$cnum]\" border=0></a>\n";
$cnum = $cnum + 1;
$lend = $lend + 1;
if ($lend eq "4"){
print "<br><br>\n";
$lend = 0;
}
}
}

sub error {
local ($updact) = @_;
print "Content-type: text/html\n\n";
print "<html><head><title>Permission Denied</title></head>\n";
print "<body>\n";
print "<p><h1>Permission Denied</h1></p>\n";
print "You do not have permission to $updact\n";
print "<p>(Return to <a href=\"$baseurl\">User Pages</a> )\n";
print "<center><small><small><!--#echo banner=\"\"--></small></small></center><p>\n";
print "</body></html>\n";
exit;
}</pre><HR></BLOCKQUOTE>



dumbperlgirl
Deleted

May 3, 2000, 5:06 AM

Post #3 of 3 (469 views)
Re: Need help modifying a script - I'm stuck [In reply to] Can't Post

Thanks for helping me but that didn't work either. I did the exact same thing. I looked over the code and that is the same thing that the other people told me to do..I guess I'm chit out of luck Frown

Ivana

 
 


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

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