#!/usr/bin/perl # # ezhomepg - EZ Home Page Generator - by Manny Juan # 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 # http://www.upstatepress.com/dave/perl.shtml # Modified by Greg Mathews . # ##################################################################################### # 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 = "/usr/local/psa/home/vhosts/cybermacro.com/httpdocs/pages/userpages"; # This is your URL of where the cgi programs are kept $cgiurl = "http://www.cybermacro.com/cgi-local"; # This is your URL of where the new HTML pages will be kept. keep the trailing slash $baseurl = "http://www.cybermacro.com/pages/userpages/"; # 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="Cybermacro Web Page Creator"; # self explanatory variables for your site logo $logo = "$imageurl/page.jpg"; $logoalt = "Cybermacro Logo"; # Location of the sendmail program $sendmail = '/usr/sbin/sendmail'; # Your e-mail address here $myemail = 'webpages@cybermacro.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/&&/

/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:

. They will be re-translated to: && Once the user updates # the page, the: && will be put back to:

$body =~ s/

/&&/g; # print the edit-page form print "Content-type: text/html\n\n"; print "Create Your Own Home Page\n"; print "\n"; print "
\"$logoalt\"

\n"; print "\n"; print "
\n"; print "

Create Your Own Home Page

\n"; print "

Below is an empty form for you to fill in. The next five fields (bold) are required.\n"; print "You can edit any part of your page later

\n"; print "

\n"; print "
\n"; print "\n"; print "Your name:
\n"; print "(will appear in page as link to your email)
\n"; print "

\n"; print "

(The next 3 fields will be used for editing)

\n"; print "Login Id:\n"; print "(one word only you should know, used later for editing)
\n"; print "

\n"; print "Your e-mail:\n"; print "(used for editing, will also appear in page)
\n"; print "

\n"; print "Your page:\n"; print "(one word, will become the name of your html file)
\n"; print "

\n"; print "Headline:\n"; print "(how your page will be listed in index)
\n"; print "

\n"; print "

\n"; print "Sub Head:
\n"; print "

\n"; print "Do you want the headings centered: Yes\n"; print "No

\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 "

\n"; print "\n"; print "\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 "Error\n"; print "

\"$logoalt\"

\n"; print "

You cannot name your page index\n"; print "Please go back and re-name your page

\n"; print "

(Return to User Pages)\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 "Error\n"; print "

You MUST give your page a Headline\n"; print "Please go back and enter one for your page

\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 "Error\n"; print "

The page name: $pagename\n"; print "is already taken.\n"; print "Please go back and rename your page

\n"; print "

(Return to User Pages)\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 = ; 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 (//) { print FILE "\n"; print FILE "

$headline

\n"; } else { print FILE $_; } } close(FILE); # Give the user a response print "Content-type: text/html\n\n"; print "thanks\n"; print "\n"; print "
\"$logoalt\"

\n"; print "

\n"; print "Your page has been created, and you will receive an e-mail confirming this!\n"; print "Your URL is: \n"; print "$baseurl$pagename\.html - remember to press Reload\n"; print "Thanks for your participation!\n"; print "

(Return to User Pages)\n"; print "\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 "\nThank you for using the $title\n"; print MAIL "\n\nThe Mall Manager - $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 Mall Page Report\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 "\nOnce again thank you for using the $title\n"; print MAIL "\n\nThe Mall Manager\n"; close (MAIL); # Give the user a response print "Content-type: text/html\n\n"; print "thanks\n"; print "\n"; print "

\"$logoalt\"
\n"; print "



\n"; print "Your page has been revised, and you will receive an e-mail confirming this!\n"; print "Your URL is: \n"; print "$baseurl$pagename\.html - remember to press Reload\n"; print "Thanks for your participation!\n"; print "

(Return to User Pages)\n"; print "\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 "$headline\n"; print HTML "\n"; print HTML "

\n"; if ($headpos eq "yes") { print HTML "
\n"; } print HTML "

$headline

\n"; if ($headpos eq "yes") { print HTML "
\n"; } if ($imageyn eq "yes") { if ($imagepos eq "yes") { print HTML "
\n"; } if (($topimage eq "0") or ($topimage eq "")) { print HTML ""; } else { print HTML "\n"; } print HTML "

$subhead\n"; if ($imagepos eq "yes") { print HTML "

\n"; } print HTML "
"; if (($line2 eq "0") or ($line2 eq "")) { print HTML ""; } else { print HTML "

\n"; } } @atxt = split(/%%/, $content); if ($bullet eq "0") { print HTML "

\n"; foreach $txtline(@atxt) { print HTML "

$txtline\n"; } print HTML "

"; } else { print HTML "\n"; foreach $txtline (@atxt) { print HTML "\n"; print HTML "\n"; } print HTML "
$txtline
\n"; } print HTML "
\n"; print HTML "

"; @all = split(/%%/,$tbltext); foreach $tbline (@all) { print HTML ""; @flds = split(/\:\:/, $tbline); foreach $fld (@flds) { print HTML ""; } print HTML ""; } print HTML "
$fld
"; print HTML "

"; if ($bullet eq "0") { print HTML "
\n"; } print HTML "

Other Places to go:

\n"; print HTML "

$linkname1
\n"; print HTML "$linkname2
\n"; print HTML "$linkname3

\n"; if ($bullet eq "0") { print HTML "
\n"; } print HTML "
"; if (($line2 eq "0") or ($line2 eq "")) { print HTML ""; } else { print HTML "
\n"; } print HTML "

"; if ($emailgif ne "") { print HTML "
\n"; } print HTML "$usrname

\n"; print HTML "

"; print HTML "

Back To Web Pages

\n"; print HTML "
\n"; print 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&&$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 "You missed something\n"; print "\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 "\n"; exit; } sub confirm { local ($updact) = @_; print "Content-type: text/html\n\n"; print "$updact Confirmation\n"; print "\n"; print "
\"$logoalt\"
\n"; print "


\n"; print "

Please Enter your login name, e-mail and name of your file to $updact

\n"; print "
\n"; print "


\n"; print "Login name:
\n"; print "

\n"; print "E-mail:
\n"; print "

\n"; print "Name of your file:
\n"; print "

\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "

\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() { 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 = ; 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 "$updact Confirmation\n"; print "\n"; print "
\"$logoalt\"
\n"; print "


\n"; print "

your page has been deleted"; print "

(Return to User Pages)\n"; print "\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() { 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 = ; 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, $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:

. They will be re-translated to: && Once the user updates # the page, the: && will be put back to:

$body =~ s/

/&&/g; # print the edit-page form print "Content-type: text/html\n\n"; print "Edit Your Page\n"; print "\n"; print "

\"$logoalt\"

\n"; print "\n"; print "
\n"; print "

Edit Your Page

\n"; print "

Below is a form with the contents\n"; print "of the home page you created. You can edit any part of your page

\n"; print "

\n"; print "
\n"; print "\n"; print "Your name:
\n"; print "

\n"; print "Your e-mail:
\n"; print "

\n"; print "Headline:
\n"; print "

\n"; print "
\n"; print "Sub Head:
\n"; print "

\n"; print "Do you want the headings Centered: Yes\n"; print "No

\n"; print "Name of HTML file: $filename

\n"; print "\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 "

\n"; print "\n"; print "\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 "Splash Graphic:
\n"; opendir (TN, "$tnp_dir"); rewinddir (TN); @tnlist = grep(!/^\.\.?$/, readdir (TN)); closedir (TN); $tnnum = @tnlist; $cnum = "0"; print "No Graphic

\n"; $lend = "0"; while ($tnnum > $cnum) { print "\n"; $cnum = $cnum + 1; $lend = $lend + 1; if ($lend eq "4"){ print "

\n"; $lend = 0; } } print "

Do you want the image Centered? : Yes\n"; print "No

\n"; print "Body: (use two percent signs (%%) BETWEEN paragraphs)
\n"; print "

\n"; print << 'END' Table (Optional): use two percent signs (%%) BETWEEN rows, use 2 colons (::) BETWEEN fields. for example:

   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
END ; $tbltext =~ s/%%/\n%%/g; print "

"; print "Links
\n"; print "\n"; print "\n"; print "
\n"; print "Link 1 URL:
\n"; print "

\n"; print "Link 2 URL:
\n"; print "

\n"; print "Link 3 URL:
\n"; print "

\n"; print "
\n"; print "Link 1 Name:
\n"; print "

\n"; print "Link 2 Name:
\n"; print "

\n"; print "Link 3 Name:
\n"; print "

\n"; print "
\n"; print "Text
\n"; print "Text color:
\n"; print "Black\n"; print "Maroon\n"; print "Red\n"; print "Yellow\n"; print "Green\n"; print "White\n"; print "Blue

\n"; print "Link color:
\n"; print "Black\n"; print "Maroon\n"; print "Red\n"; print "Yellow\n"; print "Green\n"; print "White\n"; print "Blue

\n"; print "Visited Link Color:
\n"; print "Black\n"; print "Maroon\n"; print "Red\n"; print "Yellow\n"; print "Green\n"; print "White\n"; print "Blue

\n"; print "Background image:
\n"; opendir (TN, "$tnbg_dir"); rewinddir (TN); @tnlist = grep(!/^\.\.?$/, readdir (TN)); closedir (TN); $tnnum = @tnlist; $cnum = "0"; while ($tnnum > $cnum) { print "

\n"; $cnum = $cnum + 1; print "\n"; } print "Horizontal Line:
\n"; opendir (TN, "$tn_dir"); rewinddir (TN); @tnlist = grep(!/^\.\.?$/, readdir (TN)); closedir (TN); $tnnum = @tnlist; $cnum = "0"; print "No Line

\n"; while ($tnnum > $cnum) { print "

\n"; $cnum = $cnum + 1; print "\n"; } print "Bullet:
\n"; opendir (TN, "$tnb_dir"); rewinddir (TN); @tnlist = grep(!/^\.\.?$/, readdir (TN)); closedir (TN); $tnnum = @tnlist; $cnum = "0"; print "No Bullet (all text will be centered)

\n"; $lend = "0"; while ($tnnum > $cnum) { print "\n"; $cnum = $cnum + 1; $lend = $lend + 1; if ($lend eq "10"){ print "

\n"; $lend = 0; } } print "Email image:
\n"; opendir (TN, "$tne_dir"); rewinddir (TN); @tnlist = grep(!/^\.\.?$/, readdir (TN)); closedir (TN); $tnnum = @tnlist; $cnum = "0"; $lend = "0"; while ($tnnum > $cnum) { print "\n"; $cnum = $cnum + 1; $lend = $lend + 1; if ($lend eq "4"){ print "

\n"; $lend = 0; } } } sub error { local ($updact) = @_; print "Content-type: text/html\n\n"; print "Permission Denied\n"; print "\n"; print "

Permission Denied

\n"; print "You do not have permission to $updact\n"; print "

(Return to User Pages)\n"; print "\n"; exit; }