#!/usr/local/bin/perl #YOU HAD BETTER PASSWORD PROTECT THE DIRECTORY WHERE YOU USE THIS. @admins = ( "CHANGEME1", "CHANGEME2", "CHANGEME3" ); $adminName = "YOUR NAME"; $adminEmail = "YOUREMAIL@ADDRESS"; $dir = "/home/CHANGEME/public_html"; use CGI; $query = new CGI; print <Edit Pages

Edit Pages

EOM ; if ($query->param('edit') ne "") { &editPage($query->param('file')); } elsif ($query->param('new') ne "") { &editPage($query->param('newfile'), 1); } elsif ($query->param('editsubmit') ne "") { &editSubmitPage($query->param('file')); } else { &index(0); } sub index { my($nesting) = @_; my($p, $admin); # The index is not displayed for people who # are not admins. for $p (@admins) { if ($ENV{'REMOTE_USER'} eq $p) { $admin = 1; last; } } if (!$admin) { # Non-admins go straight to the edit page for themselves, # unless we are nesting already (don't enter endless # loops after displaying error messages!) if ($nesting) { return; } &editPage($ENV{'REMOTE_USER'} . ".html", 0); return; } opendir(DIR, $dir); my(@list); print $query->start_form(); print "Select the page you want to edit. Then click on\n"; print "Edit This Page. Or, if you want to create a new\n"; print "page, enter a name for the page and click on Create New Page.\n"; print "Complete editing instructions will\n"; print "appear on the next page.

\n"; print "\n"; print "\n"; print "
\n"; while ($name = readdir(DIR)) { if ($name !~ /.html$/) { next; } if ($name eq "template.html") { next; } push @list, $name; } closedir(DIR); @list = sort @list; print $query->scrolling_list("file", \@list, undef, 10); print "\n"; print $query->submit(-name=>"edit", -value=>"Edit This Page"); print "
\n"; print "Filename for New Page:
\n"; print "(The filename should end with .html.)
\n"; print $query->textfield(-name=>"newfile", -value=>""); print "
\n"; print $query->submit(-name=>"new", -value=>"Create New Page"); print "
\n"; print $query->end_form(); } sub editPage { my($file, $create) = @_; my($line); my($text); if ($create) { if ($file eq "") { print "

Enter a File Name First!

\n"; &index(1); return; } if ($file !~ /^[\w\.]+\.html$/) { print "

Sorry, that filename cannot be used.

\n"; print "The filename was: $file

\n"; print "Filenames must end in .html, and they must\n"; print "not contain spaces. Letters, numbers, _ and .\n"; print "are permitted. Example: bob.html\n"; print "

\n"; &index(1); return; } if (open(IN, "$dir/$file")) { print "

Sorry, that file already exists.

\n"; print "The filename was: $file

\n"; print "Instead, select the file from the list of\n"; print "files, and click on Edit This Page.\n"; &index(1); return; } } if ($file eq "") { print "

Select a File First!

\n"; &index(1); return; } print $query->start_form(); print "

File Name Is: $file

\n"; print "

Instructions

\n"; print "Use the text field below (after the instructions) "; print "to edit the text of the page. Then click on the Update This "; print "Page button beneath it. Please use blank "; print "lines to separate paragraphs.\n"; print "

\n"; print "\"What is all that <FONT> and <A HREF...>\n"; print "stuff about?\"

\n"; print "Those are HTML tags. If you know "; print "HTML, feel free to "; print "sprinkle in HTML tags. Keep in mind that your tags will "; print "already be in the \"body\" part of the page. "; print "If you don't, just use blank lines to separate paragraphs;\n"; print "edit the text all you like, but leave any HTML you don't\n"; print "understand just the way it is.\n

\n"; print "\"What if I want to add an image?\"

\n"; print "Please email the image to "; &mailAdmin; print " as an attachment and let him "; print "know where you want it to go. This is easy\n"; print "to do in most mail programs.

\n"; print "\"What if I don't have a scanner?\"

\n"; print "Give $adminName your photo at a meeting and he'll take care of\n"; print "scanning it for you.

\n"; if (!$create) { if (!open(IN, "$dir/$file")) { print "

Sorry, that filename cannot be edited.

\n"; print "The filename was: $file

\n"; print "Please report this problem to "; &mailAdmin; print ".\n"; return; } } else { open(IN, "$dir/template.html"); } while ($line = ) { if ($line =~ /\\n"; print OUT $text, "\n"; print OUT "\n"; } else { print OUT $line; } } close(TEMPLATE); close(OUT); print "

File Updated

\n"; print "The file has been successfully updated.\n"; print "It would be a good idea to "; print "test it. IMPORTANT: AFTER\n"; print "YOU CLICK ON \"TEST IT\", YOU MIGHT HAVE\n"; print "TO CLICK \"RELOAD\" OR \"REFRESH\" IN YOUR BROWSER\n"; print "if the page does not look different right away!\n"; print "

\n"; print "Ciel Home Page

\n"; print "Edit More Files

\n"; } sub mailAdmin { print "$adminName "; print "($adminEmail)"; }