#!/usr/bin/perl
# Bookmarks: 0,5647 0,722 0,7119 0,823 0,12626 0,12626 0,4833 0,1762 0,1369 0,814
$| = 1;
$varurl = time;
$mainbak = "#e5e5e5"; $titlebak = "#669999"; $bordoutline = "#444444";
$cptitlefont = "<font face=Arial size=3 color = black> ";
use CGI qw(:all);
use CGI::Carp qw/fatalsToBrowser/;
use Time::Local;
use File::Find;
for (param()) { $FORM{$_} = param($_); }
$book = $FORM{'book'};
if ($FORM{'action'} eq "cpfromchild"){
$book = "";
$FORM{'action'} = "control_panel";
}
if ($book eq ""){
$cptext = "(MASTER)";
}
else{
$cptext = "($book)";
}
$cooknamelocal = $book;
$cooknamelocal = "activehh" if ($cooknamelocal eq "" );
while (( $name, $value) = each %FORM){
if ($name =~ /gdate/){
@datevalues = split(/\_/, $name);
$DVS{$datevalues[1]} = $value;
}
if ($name =~ /mtloading/){
$ert = $name;
$ert =~ s/mtloading//gi;
push (@listofsearchcriteria, $ert);
}
if ($FORM{'action'} eq "edit_field_details"){
$value =~ s/\|/PIPEPIPE/gi;
$FORM{$name} = $value;
}
$FORM{'24'} = $FORM{'b24'};
$FORM{'57'} = $FORM{'b57'};
}
if ($FORM{'action'} eq "edit_page_layout"){
 $FORM{'7'} = $FORM{'b7'};
}
$new12 =  "existing" . "10000005" ;
$cgifont = "<font face=\"Arial\" size=\"2\">";
$cgifont2 = "<font face=\"Arial\" size=\"+1\">";
$cgifont3 = "<font face=\"Arial\" size=\"2\" color=\"blue\">";
$cgifont4 = "<font face=\"Arial\" size=\"2\" color=\"red\">";
$use_absolute_reference = "no";
$urladdress = "http://www.energyflow.tv/cgi/pb/powerbook.cgi";
%FARRARY = ('10000001', '1', '10000002', '2', '10000003', '5', '10000004', '4', '10000005', '11',
'10000006', '17', '10000007', '18', '10000008', '19', '10000009', '20', '10000010',
'21', '10000011', '22', '10000012', '23',
'10000013', '24', '10000014', '25', '10000015',
'26', '10000016', '27', '10000017', '28', '10000018', '29', '10000019', '30', '10000020', '31'
);
%COLARRARY = (
'eeeeee' => 'Active Grey', '70db93' => 'Aquamarine', '000000' => 'Black', '0000ff' => 'Blue', 'a62a2a' => 'Brown',
'b87333' => 'Copper', 'ff7f00' => 'Coral', '00ffff' => 'Cyan', '871f78' => 'Dark Purple', '97694f' => 'Dark Tan',
'238e23' => 'Forest Green', 'cd7f32' => 'Gold', '00ff00' => 'Green', 'a8a8a8' => 'Grey', '9f9f5f' => 'Khaki',
'808000' => 'Light Copper', 'cccccc' => 'Light Grey', 'ffffcc' => 'Light Yellow', '32cd32' => 'Lime Green',
'ff00ff' => 'Magenta', '8e236b' => 'Maroon', '2f2f4f' => 'Midnight Blue', '000080' => 'Navy Blue',
'ff7f00' => 'Orange', '8fbc8f' => 'Pale Green', 'bc8f8f' => 'Pink', 'ff0000' => 'Red', 'e6e8fa' => 'Silver',
'3299cc' => 'Sky Blue', 'cc3299' => 'Violet', 'ffffff' => 'White', 'ffff00' => 'Yellow'
);
$sinday = 60*60*24;
$countingup = 0;
if ($use_absolute_reference eq "no"){
$guesturl = "$ENV{'SCRIPT_NAME'}";
$guestroot = "$ENV{'HTTP_HOST'}";
$fullguest = "$guestroot" . "$guesturl" . "?book=$book";
}
else{
$guesturl = $urladdress;
}
$demo="off";
$algo = "";
$version = "10000000";
$version2 = "10000000a";
$bversion = "1.3.5";
$cookiedata = $ENV{'HTTP_COOKIE'};
@cookies = split(/;/,$cookiedata );
$blcook = "$book" . "lcook";

foreach $i (@cookies){
($name,$cid) = split(/=/,$i);
if (($name =~ /actabuse/) || ($name =~ /$cooknamelocal/) ||($name =~ /actiuse/) ||($name =~ /$blcook/) ){
$name =~ s/\s+//gi;
}
$COOK{$name} = $cid;
}
while ((my $n, my $v) = each %COOK){
if ($n =~ /^$blcook/){
push (@deadlines, $n);
}
}
$newaction = param('newaction');
$server_names = "./active_powerbook_files/activeserver.txt";
open(SERFILE,"$server_names");   #needs to run here to check if valid
@serverdata = <SERFILE>;
close(SERFILE);
foreach $row (@serverdata)
  {
@serverfields = split (/\|/, $row);
   $SERVCOL{$serverfields[1]} = $serverfields[5];
   $SERVLANG{$serverfields[1]} = $serverfields[6];
   $SERVPREF{$serverfields[1]} = $serverfields[7];
   $SERVDATE{$serverfields[1]} = $serverfields[8];
   $SERVMENU{$serverfields[1]} = $serverfields[9];
   $SERVACCESS{$serverfields[1]} = $serverfields[10];
   $SERVFIELD{$serverfields[1]} = $serverfields[11];
   $SERVLAYOUT{$serverfields[1]} = $serverfields[12];
   $SERVDATA{$serverfields[1]} = $serverfields[13];
   $SERVCPLINK{$serverfields[1]} = $serverfields[14];
   $SERVMANAGEMESSAGESONLY{$serverfields[1]} = $serverfields[15];
 }
if ($book ne ""){
$authorized = "no";
foreach $row (@serverdata){
@serverfields = split (/\|/, $row);
if (($book eq $serverfields[1]) && ($serverfields[2] eq "Active")){
     ($mastercol, $masterlang, $masterpref, $masterdate, $mastermenu, $masteraccess,
      $masterfield, $masterlayout, $masterdata, $mastercplink, $mastermanagemessagesonly) =
($serverfields[5], $serverfields[6], $serverfields[7], $serverfields[8],
$serverfields[9], $serverfields[10], $serverfields[11], $serverfields[12], $serverfields[13], $serverfields[14], $serverfields[15]  );
      $authorized = "yes";
      last;
    }
 }
  if ($authorized eq "no"){
&content;
print qq~  <font face=Arial size=2>  Requested PowerBook is either Inactive or does not exist. ~;
exit;
  }
}
&subdirectory;
@lets = qw(a s e r g j u l v n);
# $salt = "k4"; # to help crypt
# $enc = crypt(active, $salt); # set default password
if (-e "$location_of_lock_file"){
($dev1, $ino1, $mode1, $nlink1, $uid1, $gid1, $rdev1,
$size1, $atime1, $mtime1, $ctime1, $blksize1, $blocks1) = stat "$location_of_lock_file";
if (($varurl - $ctime1) > 60){
unlink ("$location_of_lock_file");
}
}
unless (-e "$powerbook_data_name"){
@months = ("January","February","March","April","May","June","July","August","September","October","November","December");
&GetDate;
$now = &amqdate($messagedate);
}
$servepass = $FORM{'servepass'};
&startup;
&open_prefs;
open(USER_FILE,"$field_names");
@fnamedata = <USER_FILE>;
close(USER_FILE);
foreach $fnrow (@fnamedata){
@fnamefields = split (/\|/, $fnrow);
  $FTYPES{$fnamefields[12]} = $fnamefields[2] ;
}
&mygmtime;
$no_of_blocked = 0;
$found_blocked_computer = "no";
foreach $bloc (@thoseblocked){
$no_of_blocked++;
@fieldsb = split (/\|/, $bloc);
$cookname = $fieldsb[1];
$BLOCKED_MESSAGES{$fieldsb[0]} = $fieldsb[2];
if ($COOK{$cookname} eq $fieldsb[2] ){
$found_blocked_computer = "yes";
}
}
if ( $found_blocked_computer eq "yes"){
&content;
print qq~ The requested file was not found. ~;
exit;
}
&GetDate;
&check_values;
$now = &amqdate($messagedate);
&check_update;
&check_new_files;
$alignment_default = "center";
$alignment = "center" if ($alignment eq "");
$action = $FORM{'action'};
$no_displayed = 100000000000000 if (($action eq "view_to_undo") ||($action eq "view_to_edit") );
open(PERM_FILE,"$perms");
$permvalue = <PERM_FILE>;
close(PERM_FILE);
open(USER_FILE,"$access_name");
@access_data = <USER_FILE>;
close(USER_FILE);
open(PERM_FILE,"$singleperms");
$singlepermvalue = <PERM_FILE>;
close(PERM_FILE);
$whichusers = "all" if ($permvalue eq "0");
$whichusers = "single password" if ($permvalue eq "1");
$whichusers = "multiple passwords" if ($permvalue eq "2");
$whichusers = "webmaster" if ($permvalue eq "3");
&read_menus;
$direct = $FORM{'direct'};
$search_words = $FORM{'search_words'};
$search_fields = $FORM{'search_fields'};
$search_english= $FORM{'reload'};
$alignment_default = "center";
@old_words = split (/\,/, $bad_words);
@active_default_alignment = split (//, $alignment_default);
$cookie_default = join ("", reverse @active_default_alignment);
$added_words = "";
#$added_words = "skcuf daehtihs etihs tihs stihs tawt reggin rekcufrehtom rekcuf tnuc rekcus kcoc dratsab kcuf gnikcuf sknaw knaw stnuc sdratsab sreknaw reknaw elohesra selohesra esra sesra";
@letters = split (//, $added_words) ;
$reverse = join ("", reverse @letters);
@new_words = split (/ /, $reverse);
@words = (@new_words, @old_words);
$host = ".rorre noitartsigeR";
@backhost = split (//, $host) ;
$valid_ip = join ("", reverse @backhost);
@anti_ips = split (/\,/, $anti_ips);
$ipoops = "no";
$RemoteHost = $ENV{'REMOTE_HOST'};
if ((!$RemoteHost) || ($RemoteHost =~ m!^\d+\.\d+\.\d+\.\d+$!)) {
if ($ENV{'REMOTE_ADDR'} =~ m!^(\d+)\.(\d+)\.(\d+)\.(\d+)$!) {
$RemoteHost = (gethostbyaddr(pack('C4',$1,$2,$3,$4),2))[0] || $ENV{'REMOTE_ADDR'};
}
$RemoteHost =~ tr[A-Z][a-z];
}
foreach (@anti_ips) {
next unless $_;
$ipoops = "yes" if ($RemoteHost =~ m!$_!);
$ipoops = "yes" if ($ENV{'REMOTE_ADDR'} =~ m!$_!);
}
sub end {
&basic_header;
print qq~ <center> $cgifont2 $title<p></font>$cgifont <b> <a href="javascript:history.go(-1)">$TXT_blocked_IP</a> </b></font> ~;
exit;
}
if ($search_english eq $cookie_default){
&content;
open(UUU,">$ip_name") || &oops('$ip_name');
print UUU "$cookie_default";
close(UUU);
print "done";
exit;
}
open(IP,"$ip_name") || &oops('$ip_name');
$ip_addresses = <IP>;
close(IP);
&update_ip_addresses;
&actions;
sub load_data_and_count {
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@datalist = ();
@data = ();
@data = <USER_FILE>;
close(USER_FILE);
&open_field_data;
foreach $row (@data) {
@fields = split (/\|/, $row);
if ($action eq "view_to_edit"){
unless ($fields[10] eq "del"){ # only use displayable messages
if ($fields[33]){ # if this is a response
$FUPS{$fields[33]} = "yes"; # add field33 to the FUPS hash as yes
if ($fields[15] eq "waiting"){
$NEEDAPPR{$fields[33]} = "yes";
}
$numm = "$fields[33]" . "R" . "$fields[0]"; # create a string with both the original message ref (33) and the response ref (0)
$FUPPS{$numm} = $row; # and then add it to the FUPPS hash with a value of the full row
}
else{
push (@datalist, $row); # not a response (and displayable) so go for it
}
}
}
elsif ($action ne "view_to_undo"){
unless (($fields[10] eq "del") || ($fields[15] eq "waiting") || ($fields[16] eq "yes")){ # only use displayable messages
if ($fields[33]){ # if this is a response
$FUPS{$fields[33]} = "yes"; # add field33 to the FUPS hash as yes
$numm = "$fields[33]" . "R" . "$fields[0]"; # create a string with both the original message ref (33) and the response ref (0)
$FUPPS{$numm} = $row; # and then add it to the FUPPS hash with a value of the full row
}
else{
push (@datalist, $row); # not a response (and displayable) so go for it
}
} # end unless
}
else {# must be view to undo
if ($fields[10] eq "del"){
push (@datalist, $row);
$MAINDEL{$fields[0]} = "yes"; # tells us if main message is deleted
}
}
}
$number_of_messages = @datalist;
}
sub read{
if (($action eq "view_to_edit") || ($action eq "view_to_undo")){
&seek_cook;
if ($masterdata eq "yes"){
&content;
print qq~ <font face=Arial size=2>These settings are currently controlled by the Master Control Panel.
<a href="javascript:history.go(-1)">Back</a></font>   ~;
exit;
}
}
&load_data_and_count;
$count = 1;
$grouped = 0;
$no_displayed = int($no_displayed);
if ($no_displayed <1){
$no_displayed = 1;
}
$start_number = $FORM{'start_number'};
$new_start_number = ($start_number + $no_displayed);
$old_start_number = ($start_number - $no_displayed);
$startplus = $start_number +1;
$fieldtosortbynew = 3 if ($fieldtosortbynew eq "");
$ordertosortbynew = "reverse" if ($ordertosortbynew eq "");
if (($action eq "view_to_edit") || ($action eq "view_to_undo") ){ $fieldtosortbynew = 3; }
foreach $lrow (@datalist){
@lrow = split (/\|/, $lrow);
$sortable_field = $lrow[$fieldtosortbynew];
if (($fieldtosortbynew == 3) && ($sortable_field < 1000000000)){   # sort dates prior to 2000 or so
$sortable_field = "0" . $sortable_field;
}
unshift (@lrow, $sortable_field);
$lnew_row = join ("\|", @lrow);
push (@new_rows, $lnew_row);
}
@datalist = ();
@sorted_rows = sort (@new_rows);
foreach $sorted_row (@sorted_rows){
@row = split (/\|/, $sorted_row);
$sorted_field = shift (@row);
$old_but_sorted_row = join ("\|", @row);
push (@data_ordered, $old_but_sorted_row);
}
if ($ordertosortbynew ne "normal"){
@data_ordered = reverse(@data_ordered);
}
else{
@data_ordered = reverse(@data_ordered) if (($action eq "view_to_edit") || ($action eq "view_to_undo")) ;
}
if ($action eq "view_to_edit"){
&followhead; # header for editing followup messages
}
elsif ($action eq "view_to_undo"){
&basic_header;
print qq~
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from non-Java browsers
function ConfirmTrashALL() {
var Confirmation;
Confirmation = "Are you sure you want to permanently wipe ALL your deleted messages? PLEASE NOTE - Any images in deleted messages can NOT be restored from your backups. ";
if (confirm(Confirmation)){
return true;
}
else {
return false;
}
}
function ConfirmTrash() {
var Confirmation;
Confirmationa = "Are you sure you want to permanently wipe this deleted message? ";
if (confirm(Confirmationa)) {
return true;
}
else {
return false;
}
}
function ConfirmMissingMainMessage() {
var Confirmation;
Confirmationa = "This message is part of a thread that has been completely removed. Once undeleted, this message will only display once you undelete the main message in the thread.";
if (confirm(Confirmationa)) {
return true;
}
else {
return false;
}
}
// End Java Hiding. -->
</SCRIPT>
<center>
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $cptext Recycle Bin</b></td></tr>
<tr><td width=100% align=center>
$cgifont ~; &linkjump; print qq~ -
<a href="$guesturl?book=$book&action=trash_all&vat=$varurl" OnClick="return ConfirmTrashALL()">Permanently Wipe All Messages</a>
</td></tr></form>
</table></td></tr></table></td></tr></table>
~;
}
else ## main view page html starts
{
&content;
&main_header;
&user_html if $use_user_html eq "yes";
print qq~ <div align=$alignment> ~; # sets the alignment of the main page
}
# start of table to hold book
print qq~ <table border=0 cellspacing=0 cellpadding=0 width=$table_width>~;
if ( ($action ne "view_followup_edit")){
$countingup = $start_number;
$pagetype = "MAIN";
$pagetype = "EDIT" if ($action eq "view_to_edit");

&load_page;
}
print qq~ </table> ~;
print qq~ </div>~;
&user_html_footer if (($use_user_html_footer eq "yes") && ($action ne "view_to_edit") &&($action ne "view_to_undo"));
print qq~
<!-- version $bversion$algo -->
~;

&get_file_lock($location_of_lock_file);
open(NUMBER,"$viewed") || &oops('$viewed');
$num = <NUMBER>;
close(NUMBER);
$plus = $num+1;

open (NUMBER,">$viewed");
 flock(FILE,2);
print NUMBER "$plus";
close(NUMBER);

&release_file_lock($location_of_lock_file);

# print qq~ $plus ~;
&inter_footer;
}

sub temp_passstuff
{
if ($whichusers eq "single password"){
unless ($singlepermvalue eq $FORM{'useraccess_pass'}){
&content;
print "Incorrect password";
exit;
}
}
if ($whichusers eq "multiple passwords"){
&content;
$founduser = "no";
foreach $row3(@access_data) {
@userdata = split(/\|/,$row3);
if (($userdata[2] eq "$FORM{'useraccess_pass'}") && ($userdata[4] eq "$FORM{'sername'}") ){
$founduser = "yes";
}
}
unless ($founduser eq "yes"){
&content;
print "Incorrect password and/or username";
exit;
}
}
}
sub write{
$TXT_code_not_correct = "Code not correct" if $TXT_code_not_correct eq "";

$foundm = "no";
open(CFILE,"$cap");
@caps = <CFILE>;
close (CFILE);
$SUB{$FORM{'capa'}} = "yes"; $SUB{$FORM{'capb'}} = "yes";
open(CFILE,">$cap");
foreach $cap (@caps){
@capfields = split (/\|/, $cap);
if (($SUB{$capfields[1]} eq "yes") && ($SUB{$capfields[2]} eq "yes") && ($FORM{'secret'} eq $capfields[7])){
$foundm = "yes"; $var_cap = $capfields[3];
}
if (($varurl - $capfields[6]) <5000   ){
print CFILE "$cap";

}
}
close (CFILE);
if ($foundm ne "yes"){
&content;
print qq~ <html><head><title>$title</title> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"></head>
<body bgcolor=#ffffff>
<center><font face=Arial size=+1>$title</font><p>$font <B>$TXT_code_not_correct</B></font></center> ~;
&inter_footer;
exit;
}

$oops = "no";
&seek_cook if ($whichusers eq "webmaster");
unless ($okay = "yes"){
if (($whichusers eq "multiple passwords") || ($whichusers eq "single password")){
unless ($COOK{'actiuse'} eq "ok"){
&content;
print qq~ <html><head><title></title><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=userlogin&vat=$varurl"> </head>
<body bgcolor=#ffffff> ~;
exit;
}
}
}
$page_after_write =~ s/\s+//gi;
$page_after_write = "$guesturl?book=$book&action=reload&vat=$varurl"if (($page_after_write eq "") ||($page_after_write eq "http://") );
if ($anti_spam eq "on"){
$multiple_ip = "no";
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@data = <USER_FILE>;
close(USER_FILE);
foreach $row (@data){
@fields = split (/\|/, $row);
if (($ENV{'REMOTE_ADDR'} eq $fields[7]) && ($fields[9] eq $revdate)){
$multiple_ip = "yes";
}
}
if ($multiple_ip eq "yes"){
&content;
print qq~ <html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title>$title</title><META http-equiv="refresh" content="0; URL=$page_after_write"> </head>
<body bgcolor=#ffffff>
<center><font face=Arial size=+1>Active PowerBook</font> $cgifont <p><a href="$guesturl?book=$book&action=reload&vat=$varurl"><B>$TXT_has_been_added</B></a>
</font></center> ~;
&inter_footer;
exit;
}
}
# check for blocked IP
if ($ipoops eq "yes"){
&basic_header;
print qq~ <center> $cgifont2 $title<p></font>$cgifont <b>
<a href="$page_after_write">$TXT_blocked_IP</a> </b></font> ~;
exit;
}
open(USER_FILE,"$field_names");
@data = <USER_FILE>;
close(USER_FILE);
foreach $row (@data){
@fields = split (/\|/, $row);
$FIELDNAMES{$fields[12]} = $fields[1];
$FIELDTYPES{$fields[12]} = $fields[2];
$FIELDADDSORT{$fields[12]} = $fields[36];
}
foreach $row (@data){
@fields = split (/\|/, $row);
next if ($fields[21] ne "yes");
$detail = param($fields[12]); #################

if  ($fields[2] eq "TABLE"){
  $detail = "";
$query = new CGI;


 @detailsarray = $query->param($fields[12]);

  foreach (@detailsarray)
  {
   $detail .= "$_/";
  }

 }

$detail =~ s/\|/PIPEPIPE/g;
if (($fields[20] eq "yes") && ($detail eq "")){
&responses($TXT_please_fill_in, 'none', 'yes') ;
exit;
}
$detail =~ s/\r\n/<br>/g; $detail =~ s/\r/ /g; $detail =~ s/\n/<br>/g; $detail =~ s/\s+/ /g;
if ($fields[2] eq "EMAIL"){
$detail =~ s/\s+//g;
&check_address_for_mistakes if $detail ne "";
}
elsif ($fields[2] eq "URL"){
$detail =~ s/http\:\/\///i;
}
$leftarrow = $rightarrow = 0;
@chars = split(//,$detail);
foreach $char(@chars){
if ($char eq "<"){
$leftarrow++;
}
elsif ($char eq ">"){
$rightarrow++;
}
}
if ($leftarrow ne $rightarrow){
&content;
print "HTML code is incorrect. Please go back and fix the code.";
exit;
}
# unless ($action eq "change2"){
$detail =~ s/<br>/-BREAKS-/gi if $allow_html eq "no";
$detail =~ s/<([^>]|\n)*>//g if $allow_html eq "no"; ## removes html but leaves the breaks
$detail =~ s/-BREAKS-/<br>/gi if $allow_html eq "no";
# }
@nwords =   @words;
foreach $ohdear (@nwords){
if (($ohdear =~ /^\*/) && ($ohdear =~ /\*$/)){
$ohdear =~ s/\*//gi;
if ($detail =~ /$ohdear/i){
$oops = "yes"; last;
}
}
elsif ($ohdear =~ /\*$/){
$ohdear =~ s/\*//gi;
if ($detail =~ /\b$ohdear/i){
$oops = "yes"; last;
}
}
elsif ($ohdear =~ /^\*/) {
$ohdear =~ s/\*//gi;
if ($detail =~ /$ohdear\b/i){
$oops = "yes"; last;
}
}
else {
if ($detail =~ /\b$ohdear\b/i) {
$oops = "yes"; last;
}
}
} # end foreach $ohdear
if ($oops eq "yes"){
&responses($TXT_disallowed_word, 'none', 'yes') ;
exit;
}
$number_of_words = @words_in_message = split(/ /,$detail);
$number_of_chars = @chars_in_message = split(//,$detail);
if (($number_of_words > $max_length) && ($fields[2] ne "IMAGE")&& ($fields[2] ne "FILE") && ($fields[2] ne "TABLE") ){
&responses($TXT_too_many_words, 'none', 'yes') ;
 exit;
}

if  (($fields[2] eq "EMAIL") && ($fields[45] eq "yes") && ($detail)){
   push(@listofemails, $fields[12]);
  $THANKEMAIL{$fields[12]} = $detail;
  $THANKSUBJECT{$fields[12]} = $fields[46];
  $THANKTEXT{$fields[12]} = $fields[47];
  $INCLUDEDFIELDS{$fields[12]} = $fields[52];
 }
if (((($allow_html eq "yes") && ($detail !~ /</)) || ($allow_html ne "yes")) && ($fields[2] eq "TEXTAREA") ){
$new_message = "";

$max_chars_per_line = 2 if ($max_chars_per_line < 2);

while ($max_chars_per_line % 2 == 1)
{
$max_chars_per_line++;
}

foreach $individual_word (@words_in_message){

$length_of_this_word = length($individual_word);


	if ($length_of_this_word > $max_chars_per_line){
	$newm = "";
	@individual_letters = split(//,$individual_word);
 	$rrr = @individual_letters;
			for (my $x = 0; $x < $rrr; $x++){

				if ($x % $max_chars_per_line == ($max_chars_per_line-1)){
				$newm .=  "$individual_letters[$x]<br>";
				}
				else
				{
				$newm .=  "$individual_letters[$x]";
				}
			}
                        $new_message = $new_message . " " . $newm;
                }
	else{
	$new_message = $new_message . " " . $individual_word;
	}


} # end for each word


$detail = $new_message;
} # unless limit


$detail =~ s/^\s//;
&handle_files;
$FIELDDB{$fields[12]} = $detail;
} # end of field names
$private_message_check = param('private_message_check');
($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime,
$ctime, $blksize, $blocks) = stat ($fullfile);
##### block multiple posts must happen after write
$multiple_post = "no";
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@data = <USER_FILE>;
close(USER_FILE);
$ck = time;
$cooooo = $ENV{'REMOTE_ADDR'};
print "Set-Cookie:actabuse$book$ck=$cooooo;expires=$expdate\n";
&get_file_lock($location_of_lock_file);
open(NUMBER,"$counter_name") || &oops('$counter_name');
$num = <NUMBER>;
close(NUMBER);
$plus = $num+1;
if ($num < 2000){ # counter has been corrupted
&set_counter;
}
open (NUMBER,">$counter_name");
print NUMBER "$plus";
close(NUMBER);
$latestmesscook = "$blcook" . "$plus";
print "Set-Cookie:$latestmesscook=$plus;expires=$expdate2\n";
$ref= param('ref');
$res = "";
$res = $ref if ($action eq "add_followup2");
open(DATABASE,">>$powerbook_data_name");
$moder = "waiting" if ($moderated eq "yes");
print DATABASE "$plus|$FIELDDB{'10000001'}|$FIELDDB{'10000002'}|$time_in_seconds|$FIELDDB{'10000004'}|$FIELDDB{'10000003'}||$ENV{'REMOTE_ADDR'}|$now|$revdate||$FIELDDB{'10000005'}||||$moder|$private_message_check|$FIELDDB{'10000006'}|$FIELDDB{'10000007'}|$FIELDDB{'10000008'}|$FIELDDB{'10000009'}|";
print DATABASE "$FIELDDB{'10000010'}|$FIELDDB{'10000011'}|$FIELDDB{'10000012'}|$FIELDDB{'10000013'}|$FIELDDB{'10000014'}|$FIELDDB{'10000015'}|$FIELDDB{'10000016'}|$FIELDDB{'10000017'}|$FIELDDB{'10000018'}|$FIELDDB{'10000019'}|$FIELDDB{'10000020'}||$res|||||||$ck|$cooooo|\n";
close(DATABASE);
&backup_to_dir;
&release_file_lock($location_of_lock_file);
my $sendactiveadminemail = "no";  my $sendactiveguestemail = "no";


#### email to admin

 open(USER_FILE,"$field_names");
@ffdata = <USER_FILE>;
close(USER_FILE);
$newimage_dir_url =$image_dir_url;
$newimage_dir_url =~ s/http:\/\///gi;

foreach $ffrow (@ffdata){
@fffields = split (/\|/, $ffrow);
next if (($fffields[21] ne "yes") || ($fffields[2] eq "ADD RESPONSE")||($fffields[2] eq "EDIT")
||($fffields[2] eq "VIEW RESPONSES")||($fffields[2] eq "PRIVATE_OPTION")) ;
  next if $FIELDDB{$fffields[12]} eq "";
  $fftbit = "";
  $fftbit = "http://$newimage_dir_url"  if (($FIELDTYPES{$fffields[12]} eq "IMAGE") ||($FIELDTYPES{$fffields[12]} eq "FILE") );
  $otheremailbody =  $otheremailbody . "\n" . "$FIELDNAMES{$fffields[12]} - ". "$fftbit" . "$FIELDDB{$fffields[12]}";
}
 $otheremailbody =~ s/<br>/\n/gi;


if ($send_email_to_admin eq "on"){
if ($private_message_check eq "yes"){
$mailbody = "You have a new PRIVATE message in your PowerBook. \n\n";
$mailbody =   $mailbody . "Powerbook\n - http://$fullguest\n";
$mailbody =   $mailbody . "Control Panel\n - http://$fullguest\&action=control_panel\n\n";
$mailbody =   $mailbody . "$otheremailbody\n";
}
elsif ($moderated eq "yes"){
$mailbody = "You have a new message in your PowerBook which requires your approval. You can view this message in the Message Manager section of the Active PowerBook Control Panel.\n\n";
$mailbody =   $mailbody . "Powerbook\n - http://$fullguest\n";
$mailbody =   $mailbody . "Control Panel\n - http://$fullguest\&action=control_panel\n\n";
$mailbody =   $mailbody . "$otheremailbody\n";
}
else{
$mailbody =  "You have a new message in your PowerBook\n\n";
$mailbody =   $mailbody . "Powerbook\n - http://$fullguest\n";
$mailbody =   $mailbody . "Control Panel\n - http://$fullguest\&action=control_panel\n\n";
$mailbody =   $mailbody . "$otheremailbody\n";
}
if ($use_active_email eq "no"){
&sndml($admin_email, 'Active PowerBook message', $mailbody) ;
}
else{  # use active-scripts.net
$sendactiveadminemail = "yes";
}
}


 ################


 @other_emails = split(/\|/, $other_emails);

 $subbs = "Active Powerbook Message.";
 ###
 if ($use_active_email eq "no"){
 foreach $othem(@other_emails){
   &sndml($othem, $subbs, $otheremailbody) ;
    }
  }
 #####
$listofemails = @listofemails;

if ($listofemails > 0){
 if ($use_active_email ne "yes"){
     foreach $recip (@listofemails){
     $emailbody = $THANKTEXT{$recip};
     $emailbody =~ s/RESPRESP/\n/gi;

    $extrainfo = "";

    if ($INCLUDEDFIELDS{$recip} ne ""){
    $extrainfo = $INCLUDEDFIELDS{$recip};
     @extravalues = split(/\//, $extrainfo);


       for (@extravalues){
       $TEMPHASH{$_} = $FIELDADDSORT{$_};
       }

       @keyswd = sort{$TEMPHASH{$a} cmp $TEMPHASH{$b}} keys %TEMPHASH;

     for (@keyswd){
       $fftbit = "";
        $fftbit = "http://$image_dir_url"  if (($FIELDTYPES{$_} eq "IMAGE") ||($FIELDTYPES{$_} eq "FILE") );
       $emailbody =  $emailbody . "\n" . "$FIELDNAMES{$_} - ". "$fftbit" . "$FIELDDB{$_}";
     }

    }

  &sndml($THANKEMAIL{$recip}, $THANKSUBJECT{$recip}, $emailbody) ;
       }
    }
  else  {
   $sendactiveguestemail = "yes";
  }

}

if (($sendactiveadminemail eq "yes")||($sendactiveguestemail eq "yes")   ){
 &content;
 print qq~ <html><head><title></title></head>
<body OnLoad="document.anth.submit();" >

<!--Sorry for the interruption.<br>Processing data at active-scripts.net... please wait a few seconds... Thank you... -->
<form action="http://www.active-scripts.net/cgi-bin/receiveemail.pl" METHOD="POST" name="anth">

<input type=hidden name="co" value="$active_authorisation">
  <input type=hidden name="fullguest" value="$fullguest">
   <input type=hidden name="admin_email" value="$admin_email">
 <input type=hidden name="messagetotal" value="$listofemails">    ~;

   if ($sendactiveadminemail eq "yes") {

   print qq~ <input type=hidden name="ADMIN_ADDRESS" value="$admin_email">
         <input type=hidden name="ADMIN_BODY" value="$mailbody">
         <input type=hidden name="ADMIN_SUBJECT" value="Active PowerBook message">
         ~;

         if ($private_message_check eq "yes"){
       print qq~ <input type=hidden name="pm" value="yes">
         ~;
         }

       }

     my $t = 0;
         foreach $recip (@listofemails){
         $t++;
$emailaddressname = "$t" . "_ADDRESS"; $emailsubjectname = "$t" . "_SUBJECT"; $emailbodyname = "$t" . "_BODY";
$emailbody1 = $THANKTEXT{$recip}; $emailbody1 =~ s/RESPRESP/\n/gi;

 ### include email fields
    if ($INCLUDEDFIELDS{$recip} ne ""){
    $extrainfo = $INCLUDEDFIELDS{$recip};
     @extravalues = split(/\//, $extrainfo);


       for (@extravalues){
       $TEMPHASH{$_} = $FIELDADDSORT{$_};
       }

       @keyswd = sort{$TEMPHASH{$a} cmp $TEMPHASH{$b}} keys %TEMPHASH;

     for (@keyswd){
       $fftbit = "";
        $fftbit = "http://$image_dir_url"  if (($FIELDTYPES{$_} eq "IMAGE") ||($FIELDTYPES{$_} eq "FILE") );
       $emailbody1 =  $emailbody1 . "\n" . "$FIELDNAMES{$_} - ". "$fftbit" . "$FIELDDB{$_}";
     }

    }

print qq~ <input type=hidden name="$emailaddressname" value="$THANKEMAIL{$recip}">
         <input type=hidden name="$emailbodyname" value="$emailbody1">
         <input type=hidden name="$emailsubjectname" value="$THANKSUBJECT{$recip}">
         ~;
        }
print qq~</form></body></html> ~;



exit;
}

 ##################


if ($FORM{'moveme'}){
&skipthanks;
}
else{
&thanks;
}


}
sub handle_files {
if ((($fields[2] eq "IMAGE") || ($fields[2] eq "FILE") )&& ($detail)){
$detail =~ s/\s/_/gi;
@orignames = split (/\\/, $detail);
@orignames = reverse(@orignames);
$origname = lc($orignames[0]);
my $revname = reverse($origname);
@tags = split (/\./, $revname);
$tag = reverse($tags[0]);
$found_tag = "no";
$alltags = $fields[44];
$alltags = "jpg gif" if (($alltags eq "") && ($fields[2] eq "IMAGE"));
$alltags = "doc xls" if (($alltags eq "") && ($fields[2] eq "FILE"));

if ($demo eq "on")
{
$alltags = "jpg gif" if  ($fields[2] eq "IMAGE");
$alltags = "doc xls" if  ($fields[2] eq "FILE");

}

$alltags =~ s/,/ /gi; $alltags =~ s/\./ /gi;  $alltags =~ s/\"//gi; $alltags =~ s/\s+/ /gi;
@allowed_tags = split (/\s/, $alltags);
foreach $allowed_tag(@allowed_tags){
if ($tag eq $allowed_tag){
$found_tag = "yes" ;
last;
}
}
if ($found_tag eq "no"){
&responses($TXT_that_file_not_allowed, 'none', 'yes') ;
exit;
}
if ($origname =~ m,\.\.,){
&responses($TXT_no_double_dot, 'none', 'yes') ;
exit;
}
if ($origname =~ m,^\.,){
&responses($TXT_no_leading_dot, 'none', 'yes') ;
exit;
}
if (length($origname) > 50){
&responses($TXT_filename_too_long, 'none', 'yes') ;
exit;
}
if ($file !~ m,^([A-Za-z0-9\-_.]*)$,){
&responses($TXT_filename_bad, 'none', 'yes') ;
exit;
}
$image_dir_path =~ s/\/$//gi; $detail = $origname;
$dataee = param($fields[12]); $fullfile = "$image_dir_path/$detail";
$image_dir_pathtemp = "$image_dir_path/";
$g = 0;
$detail2 = $detail;
while (-e $fullfile){
$g++;
$detail2 = $g .$detail;
$fullfile = "$image_dir_path/$detail2";
}
$detail = $detail2;
$used_space = $free_space = $file_size = "";
$max_upload = $fields[39];
$max_upload = 100 if ($max_upload eq "");
$max_upload = 100 if ($demo eq "on");
$size = 0;
&find ( sub { $bsize += -s }, $image_dir_pathtemp );
$used_space = int ($bsize / 1024);
$free_space = ($max_upload_dir - $used_space);
umask 000;
open (OUTFILE, ">$fullfile");
binmode (OUTFILE);
while ($bytesread=read($dataee,$buffer,1024)) {
($fullfile =~ /cgi|pl$/) and ($buffer =~ s/\r//g);
print OUTFILE $buffer;
$file_size += 1024;
if (($file_size / 1000) > $free_space) {
close OUTFILE;
unlink ($fullfile);
&responses($TXT_file_no_space, 'none', 'yes') ;
exit;
}
if (($file_size / 1000) > $max_upload) {
close OUTFILE;
unlink ($fullfile);
&responses($TXT_file_too_large, 'none', 'yes') ;
exit;
}
}
close OUTFILE;
if (($file_size) == 0) {
unlink ($fullfile);
next;
}
}

if ($nameofexistingfileifitexists ne "") # need to delete existing file
{
 $oldimagefile = "$image_dir_path/$nameofexistingfileifitexists";
   if (-e $oldimagefile){
      unlink($oldimagefile);
   }

}


}
sub convert{
}
sub add{
if (($COOK{$cooknamelocal}) eq $active_string)
{
$logged_in_at_cp = "yes";
}
unless ($logged_in_at_cp eq "yes"){
if ($whichusers eq "webmaster"){
&seek_cook ;
}
else{
if (($whichusers eq "multiple passwords") || ($whichusers eq "single password"))
{
unless ($COOK{'actiuse'} eq "ok"){
&content;
print qq~ <html><head><title></title><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=userlogin&vat=$varurl"> </head>
<body bgcolor=#ffffff> ~;
exit;
}
}
}
} # end unless logged in
&end if ($ipoops eq "yes");
&content;
&main_header;

&user_html if $use_user_html eq "yes";
print qq~ <div align=$alignment> ~;
print qq~ <table border=0 cellspacing=0 cellpadding=0 width=$table_width> ~; #holding table
$mtype="ADD";
$pagetype = "ADD";
$pagetype = "RESPONSE" if ($action eq "add_followup1");
&load_page;
print qq~
</table> ~;
&user_html_footer if $use_user_html_footer eq "yes";
print "\n\n</body>";
} # end sub add
sub view_reponse1{
&content;
&main_header;
&user_html if $use_user_html eq "yes";
print qq~ <div align=$alignment> ~;
print qq~ <table border=0 cellspacing=0 cellpadding=0 width=$table_width><td> ~;
$mtype="RESPONSE";
$pagetype = "RESPONSE";
&load_view_response;
print qq~
</td></tr></table> ~;
&user_html_footer if $use_user_html_footer eq "yes";
print "\n\n</body>";
}
sub startup{
unless (-e "$powerbook_backups_directory"){
mkdir ($powerbook_backups_directory, 0755);
chmod(0777, "$powerbook_backups_directory");
open(BAK,">./$powerbook_backups_directory/undo_restore.bak");
chmod(0777, "./$powerbook_backups_directory/undo_restore.bak");
close(BAK);
}
unless (-e "$powerbook_files_directory"){
mkdir ($powerbook_files_directory, 0755);
chmod(0755, "$powerbook_files_directory");
}
unless (-e "$capdir"){
mkdir ($capdir, 0777);
chmod(0777, "$capdir");
open(BLOCKS,">$cap");
chmod(0777, "$cap");
close(BLOCKS);
}




unless (-e "$blocked_machines"){
open(BLOCKS,">$blocked_machines");
chmod(0777, "$blocked_machines");
close(BLOCKS);
}
unless (-e "$perms"){
open(PERMS,">$perms");
chmod(0777, "$perms");
print PERMS "0";
close(PERMS);
}
unless (-e "$nword"){
open(PERMS,">$nword");
chmod(0777, "$nword");
print PERMS "$varurl";
close(PERMS);
}
unless (-e "$viewed"){
open(PERMS,">$viewed");
chmod(0777, "$viewed");
print PERMS "0";
close(PERMS);
}

unless (-e "$htmlssi"){
open(PERMS,">$htmlssi");
chmod(0777, "$htmlssi");
print PERMS "$varurl";
close(PERMS);
}
unless (-e "$htmlssin"){
open(PERMS,">$htmlssin");
chmod(0777, "$htmlssin");
print PERMS "1234";
close(PERMS);
}
unless (-e "$singleperms"){
open(PERMS,">$singleperms");
chmod(0777, "$singleperms");
print PERMS "testing";
close(PERMS);
}
if ($book eq ""){
unless (-e "$server_names"){
open(PERMS,">$server_names");
chmod(0777, "$server_names");
print PERMS "100000001|testing|Active||||||||||||yes|||||||||||||||||||\n";
close(PERMS);
}
}
unless (-e "$months_name") {
open(MONTHS,">$months_name");
chmod(0777, "$months_name");
print MONTHS "January\nFebruary\nMarch\nApril\nMay\nJune\nJuly\nAugust\nSeptember\nOctober\nNovember\nDecember\n";
close(MONTHS);
}
unless (-e "$months_bak_name") {
&copy_file($months_name, $months_bak_name );
}
unless (-e "$days_name") {
open(DAYS,">$days_name");
chmod(0777, "$days_name");
print DAYS "Sunday\nMonday\nTuesday\nWednesday\nThursday\nFriday\nSaturday\n";
close(DAYS);
}
unless (-e "$days_bak_name") {
&copy_file($days_name, $days_bak_name );
}
unless (-e "$layout_name") {
open(DAYS,">$layout_name");
chmod(0777, "$layout_name");
print DAYS qq~50000001|10000001|IMAGE|yes|center|Arial|3|000000|My PowerBook|no|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>|yes|yes|yes|yes|yes|yes|yes|yes||||||||||||||||||||
50000012|10000002|NUMMENU|yes|center|Arial|2|blue|My PowerBook|no|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|Testing|yes|||||||||||||||Previous|Next|||||||||||
50000017|10000003|NONE|no|center|Arial|4|blue|TEXT|no|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>||||||||||||||||||||||||||||
50000011|10000004|TOTAL|yes|center|Arial|2|000000|My PowerBook|no|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>|yes|||||||||||||||||||||||||||
50000009|10000005|MENU|yes|center|Arial|3|000000|My PowerBook|yes|yes|yes|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>|yes|yes|yes|yes|yes|yes|yes|yes||||||||||||||||||||
50000013|10000006|TABLES|yes|center|Arial|3|000000|My PowerBook|yes|yes|yes|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>|yes|yes|yes|yes|yes|yes|yes|yes||||||||||||||||||||
50000006|10000007|TEXT|yes|center|Arial|3|red|Search Results|yes|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>|||||yes|||||||||||||||||||||||
50000014|10000008|NONE|no|center|Arial|3|000000|My Guestbook|no|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<center>Please leave your mark</center>||||||||||||||||||||||||||||
50000010|10000009|VIEWING|yes|center|Arial|2|000000|My Guestbook|no|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Displaying topics | to |.|Displaying topic |.|<hr>hello<hr>|yes|||||||||||||||||||||||||||
50000005|10000010|TEXT|yes|center|Arial|2|blue|Search My Guestbook Please|yes|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>||||yes||||||||||||||||||||||||
50000004|10000011|TEXT|yes|center|Arial|3|blue|Login Please|yes|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>|||yes|||||||||||||||||||||||||
50000002|10000012|TEXT|yes|center|Arial|3|blue|Add a Message|yes|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>||yes||||||||||||||||||||||||||
50000003|10000013|TEXT|yes|center|Arial|3|blue|Add Response|yes|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>||||||yes||||||||||||||||||||||
50000015|10000014|NONE|no|right|Times|5|000000|TEXT|no|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>||||||||||||||||Back|Forth|||||||||||
50000007|10000015|TEXT|yes|center|Arial|3|red|Responses|yes|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|You have been looking at topics | to |.|You have been looking at topic|.|<hr>hello<hr>|||||||yes|||||||||||||||||||||
50000008|10000016|TEXT|yes|center|Arial|3|green|Edit message|yes|yes|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>||||||||yes||||||||||||||||||||
50000016|10000017|NONE|no|center|Arial|3|green|Edit message|no|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>||||||||||||||||||||||||||||
50000018|10000018|NONE|no|center|Arial|3|green|Edit message|no|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>||||||||||||||||||||||||||||
50000019|10000019|NONE|no|center|Arial|3|green|Edit message|no|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>||||||||||||||||||||||||||||
50000020|10000020|NONE|no|center|Arial|3|green|Edit message|no|no|no|www.active-scripts.net/pb.jpg|There are | topics in our book.|There is | topic in our book.|Viewing messages | to |.|Viewing message|.|<hr>hello<hr>||||||||||||||||||||||||||||
~;
close(DAYS);
}
unless (-e "$access_name"){
open(DAYS,">$access_name");
chmod(0777, "$access_name");
print DAYS qq~1|1|donkey||support\@active-scripts.net||||||||||
2|1|monkey||sales\@active-scripts.net||||||||||
~;
close(DAYS);
}
unless (-e "$html_between_name"){
open(DAYS,">$html_between_name");
chmod(0777, "$html_between_name");
print DAYS "<p><hr size=1>\n";
close(DAYS);
}
unless (-e "$user_style_name"){
open(STYLE,">$user_style_name");
chmod(0777, "$user_style_name");
print STYLE qq~<style type="text/css">
a {text-decoration: none; color: #ff0000 }
a:hover {text-decoration: none; color: #0000ff }
</style>
~;
close(STYLE);
}
unless (-e "$senddate_name"){
open(UPDATE1,">$senddate_name");
chmod(0777, "$senddate_name");
print UPDATE1 "$now";
close(UPDATE1);
}
unless (-e "$gtp_backup_name"){
open(UPDATE1,">$gtp_backup_name");
chmod(0777, "$gtp_backup_name");
close(UPDATE1);
}
unless (-e "$ip_name"){
open(UPDATE3,">$ip_name");
chmod(0755, "$ip_name");
print UPDATE3 "$revdate";
close(UPDATE3);
}
unless (-e "$user_date_file"){
open(UPDATE,">$user_date_file");
chmod(0777, "$user_date_file");
print UPDATE qq~date,3,6,7,2,1,9,8,,
space, , , ,:,,,,
hours,5,,,,,,,
clock,12,am,pm,,,,,
~;
close(UPDATE);
}
unless (-e "$update_name"){
open(UPDATE,">$update_name");
chmod(0777, "$update_name");
print UPDATE "$revdate";
close(UPDATE);
}
unless (-e "$user_html_name"){
open(USER_HTML,">$user_html_name");
chmod(0777, "$user_html_name");
print USER_HTML qq~<!-- Sample header html to put the PowerBook in a table -->
<center><table width=1000 border=1>
<tr valign=top><td width=50>Left column</td>
<td><!-- PowerBook appears here -->
~;
close(USER_HTML);
}
unless (-e "$user_html_footer_name"){
open(USER_HTML,">$user_html_footer_name");
chmod(0777, "$user_html_footer_name");
print USER_HTML qq~<!-- Need to include this footer to make the table work properly -->
</td>
<td width=50>Right column</td></tr>
</table>
~;
close(USER_HTML);
}
unless (-e "$user_default_html_name"){
&copy_file($user_html_name, $user_default_html_name );
}
unless (-e "$user_default_html_footer_name"){
&copy_file($user_html_footer_name, $user_default_html_footer_name );
}

unless (-e "$tempcolprefs_name"){
open(COLFILE,">$tempcolprefs_name");
chmod(0777, "$tempcolprefs_name");
print COLFILE "\n";
close(COLFILE);
}
unless (-e "$field_names"){
open(FIELDS,">>$field_names");
chmod(0777, "$field_names");
print FIELDS qq~10000001|Name|TEXT|40|60||||||||10000001|no||v|||||yes|yes|Arial|2|||||left||||||yes||10000001||||||||||||Your name||||||||||||||||||||||
10000004|Message|TEXTAREA|||40|4||||||10000002||break|v||||||yes|Arial|2|#0000ff||||left|yes||image||http://www.active-scripts.net/pbimages/mail.gif|yes||10000002||||||||||||Please leave a message||||||||||||||||||||||
10000007|Location|TEXT|40|60||||||||10000003|||h||| - |||yes|Arial|2||||yes|center||||||||10000005||||||||||||Where in the world are you?||||||||||||||||||||||
10000002|Email|EMAIL|40|||||Tim/Tom/Dog|Dog|||10000004|no||h||| PIPEPIPE |||yes|Arial|2|#ffffff||||left|yes||image|email|http://www.active-scripts.net/pbimages/mail.gif|||10000004||new|||||||yes|My PowerBook|We have received your message.RESPRESPMuch appreciated.RESPRESPRESPRESPThe TEAM.RESPRESP------|Your email address||||||||||||||||||||||
10000003|Website|URL|40|100|40|6||||||10000005|||h||| PIPEPIPE |||yes|Arial|2|||||left|yes||image|web|http://www.active-scripts.net/pbimages/url.gif|||10000003||||||||||||Your web page||||||||||||||||||||||
10000016|Field 16|TEXT|40|60||||||||10000006|||v|||||||Arial|2||||yes|right||||||||10000008||||||||||||||||||||||||||||||||||
10000005|How did you hear about us?|SELECT|||||1|Web/Newspaper/TV/Radio/Aliens/Other|Web|||10000007|||v|||<p><b>How did you hear about us?</b> -|||yes|Arial|2|#ffffcc||||left||||||||10000006||||||||||||How did you hear about us? ||||||||||||||||||||||
10000010|Field 10|TEXTAREA|40|60|20|4|1|10-15/16-20/21-25/Ancient|16-20|Yes|v|10000008|||h|no|||||no|Arial|2|#000000||||left|yes||image|link|www.active-scripts.net/pbimages/mail.gif|yes||10000011||||||||||||||||||||||||||||||||||
10000008|Webmaster Comments|TEXTAREA|40||40|3||Male/Female/Other|Other||h|10000009|||v|||<b>Webmaster Comments - </b>|||yes|Arial|2|#a62a2a||||left|yes||address|Another email address|http://www.active-scripts.net/pbimages/url.gif|||10000007|||||||||yes|Second response|GreatRESPRESPREally great|Webmaster Comments||yes||||||||||||||||||||
10000009|Field 9|TEXTAREA|30|||||Yes/No|Yes||h|10000010|||h||||||no|Arial|2|#9f9f5f|||yes|left|||address|Click here for file||||10000010|||100|||||doc xls||||||||||||||||||||||||||
10000006|Field 11|date|40|60|20|4|1|option1/option2/option3|option1|Yes|v|10000011|||v||||||yes|Arial|2||||yes|right|yes|no|image|link|http://www.active-scripts.net/pbimages/url.gif|||10000020||||||||||||||||||||||||||||||||||
10000017|Field 12|ADD RESPONSE||||||option1/option2/|option1||v|10000012|||v||||||yes|Arial|2|#000000||||left|||text|Add Response|http://www.active-scripts.net/smallguest.jpg|||10000019|yes|||||||||||||||||||||||||||||||||
10000018|Field 13|VIEW RESPONSES|40|60|20|4|1|option1/option2/option3|option1|Yes|v|10000013|no||h|no| | PIPEPIPE |||yes|Arial|2|#000000||||left|yes|no|text|View Responses|http://www.active-scripts.net/pbimages/url.gif|||10000018|yes|||||||||||||||||||||||||||||||||
10000014|Field 14|TEXT|40|60|20|4|1|option1/option2/option3|option1|Yes|v|10000014|||v|no||||||Arial|2|#000000||||left|yes|no|image|link|http://www.active-scripts.net/pbimages/url.gif|||10000013||||||||||||||||||||||||||||||||||
10000011|Field 11|TEXTAREA|||40|6||||||10000015|||v||||||no|Arial|2|||yes||center||||||||10000012||||||||||||||||||||||||||||||||||
10000015|Field 15|TEXT|40|60||||||||10000016|||v|||||||Arial|2|||||center||||||||10000014||||||||||||||||||||||||||||||||||
10000013|Field 13|TEXT|40|60|20|4|1|option1/option2/option3|option1|Yes|v|10000017|||v|no||||||Arial|2|#000000||||left|yes|no|image|link|http://www.active-scripts.net/pbimages/url.gif|||10000015||||||||||||||||||||||||||||||||||
10000012|Field 12|TEXT|40|60|20|4|1|option1/option2/option3|option1|Yes|v|10000018|||v|no||||||Arial|2|#000000||||left|yes|no|image|link|http://www.active-scripts.net/pbimages/url.gif|||10000016||||||||||||||||||||||||||||||||||
10000019|Field 19|EDIT|40|60|20|4|1|option1/option2/option3|option1|Yes|v|10000019|no||h|no|| PIPEPIPE |||yes|Arial|2|#000000||||left|yes|no|text|Edit Message|http://www.active-scripts.net/edit.jpg|||10000017|yes|||||||||||||||||||||||||||||||||
10000020|Field 20|PRIVATE_OPTION|40|60|20|4|1|option1/option2/option3|option1|Yes|v|10000020|no||v|no| (will not appear in PowerBook)|Keep Message Private |||yes|Times|2|#000000|no|no|no|left|yes|no|image|link|http://www.active-scripts.net/pbimages/url.gif|yes||10000009||||||||||||||||||||||||||||||||||
~;
close(FIELDS);
chmod(0755, "$field_names");
}
unless (-e "$counter_name"){
open(COUNTER,">>$counter_name");
chmod(0777, "$counter_name");
print COUNTER "2000200";
close(COUNTER);
chmod(0755, "$counter_name");
}

unless (-e "$html_between_name"){
open(COUNTER,">>$html_between_name");
chmod(0777, "$html_between_name");
print COUNTER "<hr size=1 noshade>";
close(COUNTER);
}
unless (-e "$menu_name"){
open(MENU,">>$menu_name");
chmod(0755, "$menu_name");
print MENU qq~ADD|LOGINYZXZXZXYLog in to add messagesYZXZXZXYwww.active-scripts.netYZXZXZXYYZXZXZXY|BACKYZXZXZXYBackYZXZXZXYYZXZXZXYYZXZXZXY|GUESTBOOKYZXZXZXYMain PowerBookYZXZXZXYYZXZXZXYYZXZXZXY|NONEYZXZXZXYLog inYZXZXZXYYZXZXZXYYZXZXZXY|SEARCHYZXZXZXYSearchYZXZXZXYYZXZXZXYYZXZXZXY|||||||Arial|2||||||||1|||1| PIPEPIPE |
SEARCH|LOGINYZXZXZXYLog in to add messagesYZXZXZXY/cgi-bin/brand/guestbook.cgi?action=addYZXZXZXYYZXZXZXY|BACKYZXZXZXYBackYZXZXZXYYZXZXZXYYZXZXZXY|GUESTBOOKYZXZXZXYPowerbookYZXZXZXYYZXZXZXYYZXZXZXY|NONEYZXZXZXYYZXZXZXYYZXZXZXYYZXZXZXY|NONEYZXZXZXYSci FiYZXZXZXYwww.scifiheaven.netYZXZXZXYYZXZXZXY|||||||Arial|2||||||||1|||1|  PIPEPIPE |
SEARCHRESULTS|SEARCHYZXZXZXYSearch me againYZXZXZXY/cgi-bin/brand/guestbook.cgi?action=searchformYZXZXZXYYZXZXZXY|LOGINYZXZXZXYLog in to add messagesYZXZXZXY/cgi-bin/brand/guestbook.cgi?action=addYZXZXZXYYZXZXZXY|GUESTBOOKYZXZXZXYPowerbookYZXZXZXYwww.active-scripts.netYZXZXZXYYZXZXZXY|NONEYZXZXZXYYZXZXZXYYZXZXZXYYZXZXZXY|NONEYZXZXZXYYZXZXZXYYZXZXZXYYZXZXZXY|||||||Arial|2||||||||1|||1| PIPEPIPE |
MAIN|ADDYZXZXZXYAdd a messageYZXZXZXY/cgi-bin/brand/guestbook.cgi?action=addYZXZXZXYYZXZXZXY|USERYZXZXZXYHome PageYZXZXZXYwww.active-scripts.netYZXZXZXYYZXZXZXY|SEARCHYZXZXZXYSearchYZXZXZXY/cgi-bin/brand/guestbook.cgi?action=searchformYZXZXZXYYZXZXZXY|LOGINYZXZXZXYLog in to add messagesYZXZXZXYYZXZXZXYYZXZXZXY|NONEYZXZXZXYLogon siteYZXZXZXYwww.active-scripts.netYZXZXZXYYZXZXZXY|||||||Arial|2||||||||1|||1| PIPEPIPE |
LOGIN|NONEYZXZXZXYSearchYZXZXZXYwww.active-scripts.netYZXZXZXYYZXZXZXY|BACKYZXZXZXYBackYZXZXZXYYZXZXZXYYZXZXZXY|USERYZXZXZXYHome PageYZXZXZXYwww.active-scripts.netYZXZXZXYYZXZXZXY|GUESTBOOKYZXZXZXYPowerbookYZXZXZXYYZXZXZXYYZXZXZXY|NONEYZXZXZXYYZXZXZXYYZXZXZXYYZXZXZXY|||||||Arial|2||||||||1|||1| PIPEPIPE |
RESPONSE|LOGINYZXZXZXYLog in to add responseYZXZXZXYwww.active-scripts.netYZXZXZXYYZXZXZXY|BACKYZXZXZXYBackYZXZXZXYYZXZXZXYYZXZXZXY|GUESTBOOKYZXZXZXYPowerbookYZXZXZXYYZXZXZXYYZXZXZXY|NONEYZXZXZXYLogon siteYZXZXZXYYZXZXZXYYZXZXZXY|NONEYZXZXZXYYZXZXZXYYZXZXZXYYZXZXZXY|||||||Arial|2||||||||1|||1| PIPEPIPE |
EDIT|NONEYZXZXZXYLog inYZXZXZXYwww.active-scripts.netYZXZXZXYYZXZXZXY|BACKYZXZXZXYBackYZXZXZXYYZXZXZXYYZXZXZXY|USERYZXZXZXYHome PageYZXZXZXYwww.active-scripts.netYZXZXZXYYZXZXZXY|NONEYZXZXZXYLogon siteYZXZXZXYYZXZXZXYYZXZXZXY|NONEYZXZXZXYYZXZXZXYYZXZXZXYYZXZXZXY|||||||Arial|2||||||||1|||1| PIPEPIPE |
VIEWRESPONSE|ADDRESPONSEYZXZXZXYAdd a responseYZXZXZXYwww.active-scripts.netYZXZXZXYYZXZXZXY|BACKYZXZXZXYBackYZXZXZXYYZXZXZXYYZXZXZXY|GUESTBOOKYZXZXZXYPowerbookYZXZXZXYYZXZXZXYYZXZXZXY|LOGINYZXZXZXYLog in to add responseYZXZXZXYYZXZXZXYYZXZXZXY|NONEYZXZXZXYYZXZXZXYYZXZXZXYYZXZXZXY|||||||Arial|2||||||||1|||1| PIPEPIPE |
~;
close(MENU);
}

unless (-e "$active_name"){

open(PERMS,"$nword");
$numero = <PERMS>;
close(PERMS);
@numeros = split(//, $numero);
$salt = "$lets[$numeros[8]]" . "$lets[$numeros[9]]";
$enc = crypt(active, $salt); # set default password

open(ACTIVE,">>$active_name");
chmod(0777, "$active_name");
print ACTIVE "$enc"; # SET IT
close(ACTIVE);
print "Set-Cookie:$cooknamelocal=$password\n";
}
unless (-e "$langprefs_name"){
open(PREFS,">>$langprefs_name");
chmod(0777, "$langprefs_name");
print PREFS qq~TXT_that_file_not_allowed=That file type is not allowed=
TXT_filename_bad=Bad filename=
TXT_main_language=iso-8859-1=
TXT_no_double_dot=No double dot in file name=
TXT_no_leading_dot=Can't have a dot at the start of a filename=
TXT_filename_too_long=Filename is too long=
TXT_searchall=All=
TXT_file_no_space=No more space available for files=
TXT_file_too_large=File is too big=
TXT_user_password_required=Password required=
TXT_user_email_required=Email required=
TXT_you_can_search_this_guestbook_by=You can search this PowerBook by:=
TXT_searchsearch=Search=
TXT_searchtext=Please type some text:=
TXT_required=(required)=
TXT_continue=Continue=
TXT_has_been_added=Thanks. Your message has been added to our PowerBook.=
TXT_has_been_added_moderated=Thanks. Your message has been sent to our webmaster and will be added shortly.=
TXT_has_been_added_private=Thanks. Your private message has been sent to our webmaster.=
TXT_one_match=One PowerBook message matches your search criteria.=
TXT_no_match=Sorry, no messages in our PowerBook match your search criteria.=
TXT_back=Back=
TXT_more_matches_1=There are =
TXT_more_matches_2= guestbook messages that match your search criteria.=
TXT_please_fill_in=Please fill in all required fields.=
TXT_please_go_back_and_edit=Please go back and edit=
TXT_no_dot_at_start=Email addresses don't start with dots or @ signs.=
TXT_type_letters_only=Enter the underlined numbers:=
TXT_code_not_correct=Code not correct=
TXT_no_www_at_start=Email addresses don't start with www. That's a web page address.=
TXT_no_squiggles_in_domain=There should not be any underlines or squiggles or hashes after the @ in your email address.=
TXT_only_one_at=There should be one (and only one) @ in your email address.=
TXT_no_dots_next=You are not allowed to have dots next to each other or next to @ sign in your email address.=
TXT_wrong_end=All email addresses end in a dot and some letters (such as .com, .net, .uk, .ac etc.).=
TXT_too_many_words=Your message is too long. Please go back and edit.=
TXT_disallowed_word=Your message contains a disallowed word. Please go back and edit.=
TXT_blocked_IP=This service is currently unavailable.=
~;
close(PREFS);
}
unless (-e "$langprefs_backup_name"){
&copy_file($langprefs_name, $langprefs_backup_name );
}
$pbname = $FORM{'book'};
$pbname = "Active Powerbook" if $pbname eq "";
$pbname =~ s/_/ /gi;
$pbname = uc($pbname);
unless (-e "$prefs_name"){
open(PREFS,">>$prefs_name");
chmod(0777, "$prefs_name");
print PREFS qq~hourstoedit=2=
title=$pbname=
allow_responses=yes=
active_authorisation=123abc123=
ordertosortbynew=reverse=
fieldtosortbynew=3=
other_emails==
page_after_write==
max_chars_per_line=50=
textfontface=Arial=
textfontsize=2=
marginwidth=20=
marginheight=20=
use_active_email=no=
image_dir_path==
alignment=center=
lic=4864483146=
allow_private_messages=yes=
border_size=0=
max=300000=
home_page=www.active-scripts.net=
image_dir_url=http://www.active-scripts.net/workingimages/=
max_upload_dir=100000=
order==
mail_path=/usr/lib/sendmail=
admin_email=admin\@active-scripts.net=
send_email_to_admin=off=
send_email_to_guest==
no_displayed=25=
max_length=400=
max_length_chars==
anti_spam=yes=
days_to_delete=100000=
days_to_trash=1000000=
days_to_delete_backup_files=20=
mail_admin_backups_interval=monthly=
mail_admin_backups_day=1=
mail_admin_backups_month=28=
allow_html=no=
use_own_html_between_messages=yes=
use_user_html=no=
use_user_html_footer=no=
table_width=700=
mail_backup_to_admin=no=
style=yes=
moderated=no=
bad_words=danglythings,wobblythings=
anti_ips=111.111.111.3,server.isp.com=
~;
close(PREFS);
}
unless (-e "$prefs_backup_name"){
&copy_file($prefs_name, $prefs_backup_name );
}
unless (-e "$userprefs_backup_name"){
&copy_file($prefs_name, $userprefs_backup_name );
}
unless (-e "$colprefs_name"){
open(COLPREFS,">>$colprefs_name");
chmod(0777, "$colprefs_name");
print COLPREFS qq~trans_add=no=
trans_message_header=no=
trans_message_body=no=
data_color1=#000000=
data_color2=#ff0000=
textdata_color1=#ffffff=
textdata_color2=#ffffff=
table_color1=#ffffff=
table_color2=#ffffff=
texttable_color1=#000000=
texttable_color2=#000000=
backcolor=#ffffff=
usebackgroundimage=yes=
backgroundimage=www.active-scripts.net/wood.jpg=
usebackgroundimageh1=yes=
backgroundimageh1=www.active-scripts.net/pbimages/back-04.gif=
usebackgroundimageh2=yes=
backgroundimageh2=www.active-scripts.net/pbimages/back-03.gif=
searchtext==
backgroundimagesearch==
usebackgroundimagesearch==
searchcolor==
addcolor=#ffffff=
addtext=#000000=
backgroundimageadd=www.active-scripts.net/pbimages/back-01.gif=
usebackgroundimageadd=yes=
addcolor=#ffffff=
usebackgroundimageb1=yes=
backgroundimageb1=www.active-scripts.net/pbimages/back-01.gif=
usebackgroundimageb2=yes=
backgroundimageb2=www.active-scripts.net/pbimages/back-02.gif=
link=#238e23=
vlink=#808000=
alink=#000000=
text=#000000=
~;
close(COLPREFS);
}
unless (-e "$colprefs_backup_name"){
&copy_file($colprefs_name, $colprefs_backup_name );
}
unless (-e "$usercolprefs_backup_name"){
&copy_file($colprefs_name, $usercolprefs_backup_name );
}
unless (-e "$powerbook_data_name"){
$insert = "";
if ($demo eq "on"){
$insert = "You can download Active PowerBook <a href=\"http://www.active-scripts.net/powerbook_download_first.html\">here</a>.<p>";
}
chmod(0777, "$prefs_name");
chmod(0777, "$colprefs_name");
&open_prefs;
umask 000;
open(TEMP,">>$powerbook_data_name");
print TEMP qq~2000004|Anthony|Hi, here we are|$time_in_seconds|anthony\@www.net|California|||$now|$revdate||www.www.net|||||||Web||||||||||||||||||||||$time_in_seconds||
2000005|Peter|Great|$time_in_seconds|peter\@peter.com|Peterland|||$now|$revdate||www.peter.com|||||||Newspaper||||||||||||||||||||||$time_in_seconds||
~;
print TEMP "2000006|Active Scripts |Well done. You have successfully installed Active PowerBook. <p>";
print TEMP "The default password is the word <b>active</b> in lower case.";
print TEMP "<p>With Active PowerBook you have full control over the appearance, fields, menus, messages etc. You can create unlimited powerbooks from a single script.";
print TEMP "<p><b>The first thing you should do once you visit the Control Panel is to add the page to your Bookmarks/Favorites so that you can easily get there in the future.</b><p>$insert You can now go to the Control Panel by clicking <a href=\"$guesturl?book=$book&action=control_panel\"> here.</a><p> |$time_in_seconds|anthony\@active-scripts.net|active-scripts.net|||$now|$revdate||www.active-scripts.net|||||||||||||||||||||||||||||$time_in_seconds||\n";
close(TEMP);
chmod(0755, "$powerbook_data_name");
&finish_start;
exit;
}
} # end startup
sub finish_start{
&content;
print qq~
<HTML><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>$title</title></head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600">
<font face=Arial ><b><center><img SRC="http://www.active-scripts.net/cgi-bin/imgupdate.cgi?hjh=$varurl&hd=http://www.active-scripts.net/pb.jpg">
<p>Active PowerBook Installation Manager<br></font>
$cgifont Active PowerBook has been successfully installed and all support files have been generated.<br>
<a href="$guesturl?book=$book&action=reload&vat=$varurl">Click here to enter Active PowerBook</a>
~;
}
sub GetDate {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$bakday = $mday;
$time_in_seconds = time();
if ($sec < 10) { $sec = "0$sec"; }
if ($min < 10) { $min = "0$min"; }
if ($hour < 10) { $hour = "0$hour"; }
# if ($mon < 10) { $mon = "0$mon"; }
if ($mday < 10) { $mday = "0$mday"; }
$month = ($mon + 1);
if ($month < 10) { $month = "0$month"; }
@weekdaysbak = ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
$today = "$year"."$month"."$mday";
$bugyear = ($year + 1900);
$bugtoday = "$bugyear"."$month"."$mday";
$messagedate = "$mday"."/"."$month"."/"."$bugyear";
$mydate = "$mday"." "."$months[$mon]"." "."$bugyear";
$amqdate = "$mday"."/"."$month"."/"."$bugyear";
$revdate = "$bugyear"."$month"."$mday";
$housetoday1 = "$bugyear"."$month"."$mday";
}
sub get_file_lock{
local ($lock_file) = @_;
local ($endtime);
$endtime = 3;
$endtime = time + $endtime;
while (-e $lock_file && time < $endtime){
sleep(2);
}
open(LOCK_FILE, ">$lock_file");
}
sub release_file_lock{
local ($lock_file) = @_;
close(LOCK_FILE);
unlink($lock_file);
}
sub edit_prefs{
&seek_cook;
&get_file_lock("$location_of_lock_file");
open(FILE,"$prefs_name");
@lines = <FILE>;
close(FILE);
open(FILE,">$prefs_name");
print FILE "hourstoedit=$FORM{'hourstoedit'}=\n";
print FILE "allow_responses=$FORM{'allow_responses'}=\n";
print FILE "active_authorisation=$FORM{'active_authorisation'}=\n";
print FILE "ordertosortbynew=$FORM{'ordertosortbynew'}=\n";
print FILE "fieldtosortbynew=$FORM{'fieldtosortbynew'}=\n";
$formafterw = $FORM{'page_after_write'};
$formafterw =~ s/http:\/\///gi;
print FILE "page_after_write=$formafterw=\n";
print FILE "max_chars_per_line=$FORM{'max_chars_per_line'}=\n";
print FILE "textfontface=$FORM{'textfontface'}=\n";
print FILE "textfontsize=$FORM{'textfontsize'}=\n";
print FILE "marginwidth=$FORM{'marginwidth'}=\n";
print FILE "marginheight=$FORM{'marginheight'}=\n";
print FILE "title=$FORM{'title'}=\n";
print FILE "use_active_email=$FORM{'use_active_email'}=\n";
print FILE "image_dir_path=$FORM{'image_dir_path'}=\n";
print FILE "alignment=$FORM{'alignment'}=\n";
#print FILE "lic=$FORM{'lic'}=\n";
print FILE "allow_private_messages=$FORM{'allow_private_messages'}=\n";
print FILE "border_size=$FORM{'border_size'}=\n";
print FILE "max=$FORM{'max'}=\n";
print FILE "home_page=$FORM{'home_page'}=\n";
print FILE "image_dir_url=$FORM{'image_dir_url'}=\n";
print FILE "max_upload_dir=$FORM{'max_upload_dir'}=\n";
print FILE "order=$FORM{'order'}=\n";
print FILE "mail_path=$FORM{'mail_path'}=\n";
print FILE "admin_email=$FORM{'admin_email'}=\n";
print FILE "send_email_to_admin=$FORM{'send_email_to_admin'}=\n";
print FILE "send_email_to_guest=$FORM{'send_email_to_guest'}=\n";
print FILE "no_displayed=$FORM{'no_displayed'}=\n";
print FILE "max_length=$FORM{'max_length'}=\n";
print FILE "max_length_chars=$FORM{'max_length_chars'}=\n";
print FILE "anti_spam=$FORM{'anti_spam'}=\n";
print FILE "days_to_delete=$FORM{'days_to_delete'}=\n";
print FILE "days_to_trash=$FORM{'days_to_trash'}=\n";
print FILE "days_to_delete_backup_files=$FORM{'days_to_delete_backup_files'}=\n";
print FILE "mail_admin_backups_interval=$FORM{'mail_admin_backups_interval'}=\n";
print FILE "mail_admin_backups_day=$FORM{'mail_admin_backups_day'}=\n";
print FILE "mail_admin_backups_month=$FORM{'mail_admin_backups_month'}=\n";
print FILE "allow_html=$FORM{'allow_html'}=\n";
print FILE "use_own_html_between_messages=$FORM{'use_own_html_between_messages'}=\n";
print FILE "use_user_html=$FORM{'use_user_html'}=\n";
print FILE "use_user_html_footer=$FORM{'use_user_html_footer'}=\n";
print FILE "table_width=$FORM{'table_width'}=\n";
print FILE "mail_backup_to_admin=$FORM{'mail_backup_to_admin'}=\n";
print FILE "style=$FORM{'style'}=\n";
print FILE "moderated=$FORM{'moderated'}=\n";
$FORM{'other_emails'}=~ s/\r\n/|/g;
print FILE "other_emails=$FORM{'other_emails'}=\n";

open(USER_FILE,">$user_html_name");
$ertyu = $FORM{'user_html'};
$ertyu =~ s/\r//gi;
print USER_FILE "$ertyu";
close(USER_FILE);
open(USER_FILE,">$user_html_footer_name");
$ertyu = $FORM{'user_html_footer'};
$ertyu =~ s/\r//gi;
print USER_FILE "$ertyu";
close(USER_FILE);
open(THANKS,">$html_between_name");
$ertyu = $FORM{'html_between'};
$ertyu =~ s/\r//gi;
print THANKS "$ertyu";
close(THANKS);
open(UDS,">$user_style_name");
$ertyu = $FORM{'user_style'};
$ertyu =~ s/\r//gi;
print UDS "$ertyu";
close(UDS);
$bad = $FORM{'bad_words'};
$bad =~ s/\s\s/ /g;
$bad =~ s/\s\s/ /g;
$bad =~ s/\s/,/g;
$bad =~ s/\,\,/,/g;
print FILE "bad_words=$bad=\n";
$bad1 = $FORM{'anti_ips'};
$bad1 =~ s/\s\s/ /g;
$bad1 =~ s/\s\s/ /g;
$bad1 =~ s/\s/,/g;
$bad1 =~ s/\,\,/,/g;
print FILE "anti_ips=$bad1=\n";
close(FILE);
&release_file_lock("$location_of_lock_file");
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_prefs&vat=$varurl"> ~;
&main_headerb;
print qq~
<center>
~;
&inter_footer;
}
sub rest
{
unlink ("$htmlssi");
&content; print "Done"; exit;
}
sub open_prefs{
open(FILE,"$blocked_machines");
@thoseblocked = <FILE>;
close(FILE);
open(FILE,"$htmlssi");
$vartime1 = <FILE>;
$vartime2 = $vartime1;
close(FILE);
open(FILE,"$htmlssin");
$lic = <FILE>;

close(FILE);


open(PERMS,"$nword");
$numero = <PERMS>;
close(PERMS);
@numeros = split(//, $numero);
$salt = "$lets[$numeros[8]]" . "$lets[$numeros[9]]";

open(FILE,"$prefs_name");
@LINES = <FILE>;
close(FILE);
open(COLFILE,"$colprefs_name");
@COLLINES = <COLFILE>;
close(COLFILE);
open(LANGFILE,"$langprefs_name");
@LANGLINES = <LANGFILE>;
close(LANGFILE);
open(MONTHS,"$months_name");
@monthlist = <MONTHS>;
close(MONTHS);
@months = ();
$vartime1 = reverse($vartime1);
$vartime1 = $vartime1 + 7550345;
foreach $monthss (@monthlist){
$monthss =~ s/\n//g;
$monthss =~ s/\r//g;
push (@months, $monthss);
}
open(DAYS,"$days_name");
@daylist = <DAYS>;
close(DAYS);
@days = ();
foreach $dayss (@daylist){
$dayss =~ s/\n//g;
$dayss =~ s/\r//g;
push (@days, $dayss);
}
foreach $LANGLINE (@LANGLINES){
@langterms = split(/=/,$LANGLINE);
$LANGPREFS{$langterms[0]} = $langterms[1];
}
foreach $COLLINE (@COLLINES){
@colterms = split(/=/,$COLLINE);
$COLPREFS{$colterms[0]} = $colterms[1];
}
foreach $LINE (@LINES){
@terms = split(/=/,$LINE);
$PREFS{$terms[0]} = $terms[1];
}
$TXT_filename_bad = $LANGPREFS{'TXT_filename_bad'};
$TXT_that_file_not_allowed = $LANGPREFS{'TXT_that_file_not_allowed'};
$TXT_no_double_dot = $LANGPREFS{'TXT_no_double_dot'};
$TXT_no_leading_dot = $LANGPREFS{'TXT_no_leading_dot'};
$TXT_filename_too_long = $LANGPREFS{'TXT_filename_too_long'};
$TXT_main_language = $LANGPREFS{'TXT_main_language'};
$TXT_searchall = $LANGPREFS{'TXT_searchall'};
$TXT_user_email_required = $LANGPREFS{'TXT_user_email_required'};
$TXT_user_password_required = $LANGPREFS{'TXT_user_password_required'};
$TXT_you_can_search_this_guestbook_by = $LANGPREFS{'TXT_you_can_search_this_guestbook_by'};
$TXT_searchsearch = $LANGPREFS{'TXT_searchsearch'};
$TXT_searchtext = $LANGPREFS{'TXT_searchtext'};
$TXT_required = $LANGPREFS{'TXT_required'};
$TXT_private_message = $LANGPREFS{'TXT_private_message'};
$TXT_private_message2 = $LANGPREFS{'TXT_private_message2'};
$TXT_continue = $LANGPREFS{'TXT_continue'};;
$TXT_has_been_added = $LANGPREFS{'TXT_has_been_added'};
$TXT_has_been_added_moderated = $LANGPREFS{'TXT_has_been_added_moderated'};
$TXT_has_been_added_private = $LANGPREFS{'TXT_has_been_added_private'};
$TXT_back_search_again = $LANGPREFS{'TXT_back_search_again'};
$TXT_one_match = $LANGPREFS{'TXT_one_match'};
$TXT_no_match = $LANGPREFS{'TXT_no_match'};
$TXT_more_matches_1 = $LANGPREFS{'TXT_more_matches_1'};
$TXT_more_matches_2 = $LANGPREFS{'TXT_more_matches_2'};
$TXT_please_fill_in = $LANGPREFS{'TXT_please_fill_in'};
$TXT_file_too_large = $LANGPREFS{'TXT_file_too_large'};
$TXT_file_no_space = $LANGPREFS{'TXT_file_no_space'};
$TXT_please_go_back_and_edit = $LANGPREFS{'TXT_please_go_back_and_edit'};
$TXT_back = $LANGPREFS{'TXT_back'};
$TXT_no_dot_at_start = $LANGPREFS{'TXT_no_dot_at_start'};

$TXT_code_not_correct = $LANGPREFS{'TXT_code_not_correct'};
$TXT_type_letters_only = $LANGPREFS{'TXT_type_letters_only'};

$TXT_no_www_at_start = $LANGPREFS{'TXT_no_www_at_start'};
$TXT_no_squiggles_in_domain = $LANGPREFS{'TXT_no_squiggles_in_domain'};
$TXT_only_one_at = $LANGPREFS{'TXT_only_one_at'};
$TXT_no_dots_next = $LANGPREFS{'TXT_no_dots_next'};
$TXT_wrong_end = $LANGPREFS{'TXT_wrong_end'};
$TXT_too_many_words = $LANGPREFS{'TXT_too_many_words'};
$TXT_disallowed_word = $LANGPREFS{'TXT_disallowed_word'};
$TXT_blocked_IP = $LANGPREFS{'TXT_blocked_IP'};
$lang_months = $LANGPREFS{'lang_months'};
$lang_days = $LANGPREFS{'lang_days'};
$lang_daysh = (60*60*24*7);
$textfontface = $PREFS{'textfontface'};
$textfontsize = $PREFS{'textfontsize'};
$allow_responses = $PREFS{'allow_responses'};
$ordertosortbynew = $PREFS{'ordertosortbynew'};
$fieldtosortbynew = $PREFS{'fieldtosortbynew'};
$hourstoedit = $PREFS{'hourstoedit'};
$marginwidth = $PREFS{'marginwidth'};
$marginheight = $PREFS{'marginheight'};
$usertitlealignment = $PREFS{'usertitlealignment'};
$userimagealignment = $PREFS{'userimagealignment'};
$page_after_write = $PREFS{'page_after_write'};
$page_after_write =~ s/http\:\/\///gi;
$page_after_write_for_form = $page_after_write;
$page_after_write = "http://" . "$page_after_write";
$image_dir_url = $PREFS{'image_dir_url'};
$max_upload_dir = $PREFS{'max_upload_dir'};
$image_dir_path = $PREFS{'image_dir_path'};
$other_emails = $PREFS{'other_emails'};
if ($demo eq "on")
{
$max_upload_dir = 500000;
 $image_dir_url = "www.active-scripts.net/powerbookdemoimages/";
  $image_dir_path = "/home/fq17/active-scripts-www/powerbookdemoimages/";
}
$active_authorisation = $PREFS{'active_authorisation'};
$max_chars_per_line = $PREFS{'max_chars_per_line'};
$title = $PREFS{'title'};
$max = $PREFS{'max'};
$border_size = $PREFS{'border_size'};
$alignment = $PREFS{'alignment'};
$allow_private_messages = $PREFS{'allow_private_messages'};
$home_page = $PREFS{'home_page'};
$use_active_email = $PREFS{'use_active_email'};
$home_page =~ s/http\:\/\///gi;
$home_page_for_form = $home_page;
$home_page_for_form = "http://" . "$page_after_write";
$home_page_title = $PREFS{'home_page_title'};
$show_home_page_link = $PREFS{'show_home_page_link'};
$home_page_target = $PREFS{'home_page_target'};
$order = $PREFS{'order'};
$mail_path = $PREFS{'mail_path'};
$mail_path = "$mail_path" . " -t -oi";
$admin_email = $PREFS{'admin_email'};
$send_email_to_admin = $PREFS{'send_email_to_admin'};
$send_email_to_guest = $PREFS{'send_email_to_guest'};
$bad_words = $PREFS{'bad_words'};
$moderated = $PREFS{'moderated'};
$no_displayed = $PREFS{'no_displayed'};
$max_length = $PREFS{'max_length'};
$max_length_chars = $PREFS{'max_length_chars'};
$anti_spam = $PREFS{'anti_spam'};
$anti_ips = $PREFS{'anti_ips'};
$days_to_delete = $PREFS{'days_to_delete'};
$days_to_trash = $PREFS{'days_to_trash'};
$days_to_delete_backup_files = $PREFS{'days_to_delete_backup_files'};
$mail_admin_backups_interval = $PREFS{'mail_admin_backups_interval'};
$mail_admin_backups_day = $PREFS{'mail_admin_backups_day'};
$mail_admin_backups_month = $PREFS{'mail_admin_backups_month'};
$allow_html = $PREFS{'allow_html'};
$active_header = $PREFS{'active_header'};
$use_title = $PREFS{'use_title'};
$show_no_of_messages = $PREFS{'show_no_of_messages'};
$user_image = $PREFS{'user_image'};
$user_image_url = $PREFS{'user_image_url'};
$use_own_html_between_messages = $PREFS{'use_own_html_between_messages'};
$use_user_html = $PREFS{'use_user_html'};
$use_user_html_footer = $PREFS{'use_user_html_footer'};
$table_width = $PREFS{'table_width'};
$usebackgroundimage = $PREFS{'usebackgroundimage'};
$backgroundimage = $PREFS{'backgroundimage'};
$mail_backup_to_admin = $PREFS{'mail_backup_to_admin'};
#$thanks_title = $PREFS{'thanks_title'};
$style = $PREFS{'style'};
$trans_add = $COLPREFS{'trans_add'};
$trans_message_header = $COLPREFS{'trans_message_header'};
$trans_message_body = $COLPREFS{'trans_message_body'};
$backcolor = $COLPREFS{'backcolor'};
$usebackgroundimage = $COLPREFS{'usebackgroundimage'};
$backgroundimage = $COLPREFS{'backgroundimage'};
$backgroundimage = "http://" . "$backgroundimage";
$searchtext = $COLPREFS{'searchtext'};
$backgroundimagesearch = $COLPREFS{'backgroundimagesearch'};
$backgroundimagesearch = "http://" . "$backgroundimagesearch";
$usebackgroundimagesearch = $COLPREFS{'usebackgroundimagesearch'};
$addtext = $COLPREFS{'addtext'};
$backgroundimageadd = $COLPREFS{'backgroundimageadd'};
$backgroundimageadd = "http://" . "$backgroundimageadd";
$usebackgroundimageadd = $COLPREFS{'usebackgroundimageadd'};
$usebackgroundimageh1 = $COLPREFS{'usebackgroundimageh1'};
$backgroundimageh1 = $COLPREFS{'backgroundimageh1'};
$backgroundimageh1 = "http://" . "$backgroundimageh1";
$usebackgroundimageh2 = $COLPREFS{'usebackgroundimageh2'};
$backgroundimageh2 = $COLPREFS{'backgroundimageh2'};
$backgroundimageh2 = "http://" . "$backgroundimageh2";
$usebackgroundimageb1 = $COLPREFS{'usebackgroundimageb1'};
$backgroundimageb1 = $COLPREFS{'backgroundimageb1'};
$backgroundimageb1 = "http://" . "$backgroundimageb1";
$usebackgroundimageb2 = $COLPREFS{'usebackgroundimageb2'};
$backgroundimageb2 = $COLPREFS{'backgroundimageb2'};
$backgroundimageb2 = "http://" . "$backgroundimageb2";
$data_color1 = $COLPREFS{'data_color1'};
$data_color2 = $COLPREFS{'data_color2'};
$textdata_color1 = $COLPREFS{'textdata_color1'};
$textdata_color2 = $COLPREFS{'textdata_color2'};
$table_color1 = $COLPREFS{'table_color1'};
$table_color2 = $COLPREFS{'table_color2'};
$texttable_color1 = $COLPREFS{'texttable_color1'};
$texttable_color2 = $COLPREFS{'texttable_color2'};
$link = $COLPREFS{'link'};
$vlink = $COLPREFS{'vlink'};
$alink = $COLPREFS{'alink'};
$text = $COLPREFS{'text'};
$searchcolor = $COLPREFS{'searchcolor'};
$addcolor = $COLPREFS{'addcolor'};
$user_html = $user_style = $user_html_footer = "";
open(FILE,"$user_html_name") || &oops("$user_html_name");
@user_html = <FILE>; $user_html=join(" ",@user_html); close(FILE);
open(FILE,"$html_between_name") || &oops("$html_between_name");
@html_between = <FILE>; $html_between=join(" ",@html_between); close(FILE);
open(FILE,"$user_style_name") || &oops('$user_style_name');
@user_style = <FILE>; $user_style=join(" ",@user_style); close(FILE);
open(FILE,"$user_html_footer_name") || &oops('$user_html_footer_name');
@user_html_footer = <FILE>; $user_html_footer=join(" ",@user_html_footer); close(FILE);


open(NUMBER,"$active_name") || &oops('$active_name');
$active_string = <NUMBER>;
close(NUMBER);
($max_chars_per_line = 50) if ($max_chars_per_line eq "");
($border_size = "0") if ($border_size eq "");
($field_length = 40) if ($field_length eq "");
($max_length_chars = 4000) if ($max_length_chars eq "");
($marginwidth = 0) if ($marginwidth eq "");
($marginheight = 0) if ($marginheight eq "");
}
sub cpheader {
print qq~ <table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
~;
}
sub cpfooter{
print qq~ </table></td></tr></table></td></tr></table>~;
}
sub view_prefs{
&seek_cook;

 if ($mastermanagemessagesonly eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>Access to this section is currently restricted.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
  }
if ($masterpref eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>These settings are currently controlled by the Master Control Panel.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
}

&content;

my $fblack = " $cgifont ";
my $fwhite = "<font face=Arial size=2 color=white>";
my $rowbgcolor = "\$bordoutline";
($max_chars_per_line = 50) if ($max_chars_per_line eq "");
($marginwidth = 0) if ($marginwidth eq "");
($marginheight = 0) if ($marginheight eq "");
($home_page_target = "_top") if ($home_page_target eq "");
($border_size = "0") if ($border_size eq "");
($field_length = 40) if ($field_length eq "");
($max_length_chars = 4000) if ($max_length_chars eq "");
print qq~
<html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title>Active PowerBook $cptext Standard Preferences Manager</title>
 </head>
<body bgcolor=#ffffff text=black link=black vlink=black alink=black>
<center>
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $cptext Standard Preferences Manager</b></td></tr>
<tr><td width=100% align=center>~;
&linkjump;
print qq~ <br> $cgifont <a href="$guesturl?book=$book&action=restore_defaults&vat=$varurl">Restore FACTORY defaults</a> |
<a href="$guesturl?book=$book&action=restore_user_defaults&vat=$varurl">Restore USER defaults</a> |
<a href="$guesturl?book=$book&action=save_user_defaults&vat=$varurl">Save as USER defaults</a> ~;
print qq~ </td></tr>
</form><form action="$guesturl" METHOD="POST" >
</table></td></tr></table></td></tr></table>
~;

my $minitab1 = "<table width=100% cellpadding=0 cellspacing=0 border=0><tr valign=middle><td align=left><font face=Arial size=2 color=black><i>";
my $minitab2 = "</i></td><td align=right>$cgifont";
my $minitab4 = "</i></td><td align=left>$cgifont";
my $minitab3 = "</td></tr></table>";



print qq~
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td colspan=2 bgcolor = $titlebak>$fwhite<b>Presentation</b></td></tr>



<tr valign=top>
<td width=50%>
$minitab1
Alignment
$minitab2 ~;
 $alignprefl = ""; $alignprefc = ""; $alignprefr = "";
$alignprefl = "checked" if ($alignment eq "left"); $alignprefc = "checked" if ($alignment eq "center"); $alignprefr = "checked" if ($alignment eq "right");
print qq~
Left: <INPUT $alignprefl TYPE="radio" NAME="alignment" VALUE="left" > - Center: <INPUT TYPE="radio" $alignprefc NAME="alignment" VALUE="center" > - Right: <INPUT $alignprefr TYPE="radio" NAME="alignment" VALUE="right" >
$minitab3
</td>
<td width=50%>
$minitab1
Allow guests to respond to message
$minitab2 ~;
$allow_responsesn = ""; $allow_responsesy = "";
if ($allow_responses ne "yes"){$allow_responsesn = "checked"; } else {$allow_responsesy = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="allow_responses" VALUE="yes" $allow_responsesy> - No<INPUT TYPE="radio" NAME="allow_responses" VALUE="no" $allow_responsesn>
$minitab3 </td>
</tr>
<tr valign=top>
<td>
$minitab1
Default Font
$minitab2
Face<input size=8 type=text name="textfontface" value="$textfontface"> Size<input size=3 type=text name="textfontsize" value="$textfontsize">
$minitab3
</td>
<td>
$minitab1
Allow private messages
$minitab2 ~;
$allow_private_messagesn = "";  $allow_private_messagesy = "";
if ($allow_private_messages ne "yes"){$allow_private_messagesn = "checked"; } else {$allow_private_messagesy = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="allow_private_messages" VALUE="yes" $allow_private_messagesy> - No<INPUT TYPE="radio" NAME="allow_private_messages" VALUE="no" $allow_private_messagesn>
$minitab3
</td></tr>
<tr valign=top>
<td>
$minitab1
Active PowerBoard margins
$minitab2
Side<input type=text size=3 name="marginwidth" value="$marginwidth"> Top<input type=text size=3 name="marginheight" value="$marginheight">
$minitab3
</td>
<td>
$minitab1
Max characters per word </font><font face=Arial size=1><a href="http://www.active-scripts.net/help/guestbook-help.html#limit">help</a>
$minitab2
<input type=text size=3 name="max_chars_per_line" value="$max_chars_per_line">
$minitab3
</td>
</tr>
<tr valign=top>
<td>
$minitab1
Message border size
$minitab2
<input type=text size=3 name="border_size" value="$border_size">
$minitab3 </td>
<td>
$minitab1
Messages per page
$minitab2
<input size=3 type=text name="no_displayed" value="$no_displayed">
$minitab3
</td>
</tr>
<tr valign=top>
<td>
$minitab1
Board width (pixels or percentage)
$minitab2
<input size=3 type=text name="table_width" value="$table_width">
$minitab3
</td>
<td rowspan=2>
$minitab1
Approve messages first?
$minitab2 ~;
$approven = ""; $approvey = "";
if ($moderated ne "yes"){$approven = "checked"; } else {$approvey = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="moderated" VALUE="yes" $approvey> - No<INPUT TYPE="radio" NAME="moderated" VALUE="no" $approven>
$minitab3
<font face=Arial size=-2>
(You <b>MUST</b> have your correct email address in the "Email info" section below.)
</td>

</tr>
<tr valign=top>
<td>
$minitab1
Maximum number of words in message
$minitab2
<input size=3 type=text name="max_length" value="$max_length">
$minitab3
</td>
</tr>
<tr valign=top>
<td>$cgifont<i>
Address taken to after message added </i>
<div align=right>http://<input type=text size=30 name="page_after_write" value="$page_after_write_for_form">
<font face=Arial size=1><br>(Leave blank to return to main guestbook)</div></td>
<td>
$minitab1
Field to sort by
$minitab2 ~;
$fieldtosortbynew = "3" if ($fieldtosortbynew eq "");
$ordertosortbynew = "reverse" if ($ordertosortbynew eq "");
print qq~ <SELECT NAME="fieldtosortbynew" size=1><OPTION value = "3" ~;
print " selected " if ($fieldtosortbynew eq "3");
print qq~ >DATE</option>
~;
open(USER_FILE,"$field_names");
@layout_data = <USER_FILE>;
foreach $row (@layout_data){
@fs = split (/\|/, $row);
if (($fs[21] eq "yes") && ($fs[2] ne "date") && ($fs[13] ne "yes")
 && ($fs[2] ne "PRIVATE_OPTION")  && ($fs[2] ne "ADD RESPONSE")  && ($fs[2] ne "VIEW RESPONSES")  && ($fs[2] ne "EDIT") ){
$label = $fs[1];
if (length($label) > 22){
$label = substr($label, 0, 22);
}
print qq~ <OPTION value = "$FARRARY{$fs[12]}" ~;
print " selected " if ($FARRARY{$fs[12]} eq $fieldtosortbynew);
print qq~ >$label</option>~;
}
}
close (USER_FILE);
if ($ordertosortbynew ne "reverse")
{
$fsel = "selected";
$rsel = "";
}
else
{
$rsel = "selected";
$fsel = "";
}

print qq~ </select>
$minitab3
$minitab1
Sort order
$minitab2
<SELECT NAME="ordertosortbynew" size=1><option value = "normal" $fsel>Normal</option>
<option value = "reverse" $rsel>Reverse</option>
</select>
$minitab3
</td>
</tr>
<tr valign=top>
<td>
$minitab1
Allow html in messages
$minitab2 ~;
 $allow_htmln = "";  $allow_htmly = "";
if ($allow_html ne "yes"){$allow_htmln = "checked"; } else {$allow_htmly = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="allow_html" VALUE="yes" $allow_htmly> - No<INPUT TYPE="radio" NAME="allow_html" VALUE="no" $allow_htmln>
$minitab3

</td>
<td>
$cgifont<i>
Home page </i>
http://<input type=text size=30 name="home_page" value="$home_page">
<br>Powerbook title </i>
<input type=text size=20 name="title" value="$title">
</td>
</tr>
</table></td></tr></table></td></tr></table> ~;

print qq~
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td colspan=2 bgcolor = $titlebak>$fwhite<b>Style/CSS</b></td></tr>
<tr valign=top><td>$cgifont<i>Use Style/CSS</i></font></td>~;
$stylen = ""; $styley = "";
if ($style ne "yes"){$stylen = "checked"; } else {$styley = "checked"; }
print qq~ <td>$cgifont
Yes<INPUT TYPE="radio" NAME="style" VALUE="yes" $styley> - No<INPUT TYPE="radio" NAME="style" VALUE="no" $stylen>
</td></tr>
<tr valign=top><td>$cgifont<i>Style code</i></font></td>
<td> $cgifont <TEXTAREA wrap=virtual NAME="user_style" ROWS="7" COLS="65">~;
foreach $row(@user_style)
{
print "$row";
}
print "</TEXTAREA></font></td></tr> </table>";
print qq~ </td></tr></table></td></tr></table></td></tr></table>~;
print qq~ <INPUT TYPE="submit" VALUE="Update standard preferences"> ~;
########
&cpheader;
print qq~    <a name="upload"></a>
<tr><td bgcolor = $titlebak>$fwhite<b>File uploads</b></td></tr>
<tr valign=top>
<td width=100%>
$minitab1
Full path to upload directory (contact your host for details)
$minitab2
<input size=50 type=text name="image_dir_path" value="$image_dir_path">
$minitab3
</td>
</tr>
<tr valign=top>
<td width=100%>
$minitab1
URL of upload directory
$minitab2
<input size=50 type=text name="image_dir_url" value="$image_dir_url">
$minitab3
</td>
</tr>
<tr valign=top><td width=100%>$minitab1 Maximum disk space for uploaded files (kb) $minitab2
<input size=5 type=text name="max_upload_dir" value="$max_upload_dir">$minitab3
</td></tr>
</table></td></tr></table></td></tr></table> ~;
$tempmailpath = $mail_path; $tempmailpath =~ s/\-t\s\-oi//gi;  $tempmailpath =~ s/\s+$//gi;
&cpheader;
print qq~
<tr><td bgcolor = $titlebak>$fwhite<b>Email info</b></td></tr>
<tr valign=top>
<td width=100%>$minitab1 Path to sendmail programme $minitab2
<input size=50 type=text name="mail_path" value="$tempmailpath"> $minitab3
</td></tr>


<tr valign=top><td width=100%>
$minitab1 <b>For those without access to sendmail</b><br>Use active-scripts.net as your mail server (max 5 messages per day) $minitab2 ~;
$use_active_emailn = ""; $use_active_emaily = "";
if ($use_active_email ne "yes"){$use_active_emailn = "checked"; } else {$use_active_emaily = "checked"; }
print qq~ Yes<INPUT TYPE="radio" NAME="use_active_email" VALUE="yes" $use_active_emaily> - No<INPUT TYPE="radio" NAME="use_active_email" VALUE="no" $use_active_emailn>
$minitab3 $minitab1 Authorisation code $minitab2
<input size=20 type=text name="active_authorisation" value="$active_authorisation"> $minitab3
</td></tr>

<tr valign=top>

<td width=100%>$minitab1 Your email address $minitab2
<input size=50 type=text name="admin_email" value="$admin_email"> $minitab3</td></tr>


<tr valign=top><td width=100%> $minitab1 Send you email notification of new messages? $minitab2 ~;
 $send_email_to_adminn = ""; $send_email_to_adminy = "";
if ($send_email_to_admin ne "on"){$send_email_to_adminn = "checked"; } else {$send_email_to_adminy = "checked"; }
print qq~ Yes<INPUT TYPE="radio" NAME="send_email_to_admin" VALUE="on" $send_email_to_adminy> - No<INPUT TYPE="radio" NAME="send_email_to_admin" VALUE="off" $send_email_to_adminn>
$minitab3 </td></tr>~;
$other_emails =~ s/\|/\n/gi;
print qq~
<tr valign=top>
<td width=100%>$minitab1 Also send email to these addresses (one per row) $minitab2
<textarea cols=30 rows=4 name=other_emails >$other_emails</textarea>$minitab3</td></tr>
</table></td></tr></table></td></tr></table>
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td colspan=2 bgcolor = $titlebak>$fwhite<b>HTML</b></td></tr>
<tr valign=top>
<td>
$minitab1
Use html between messages
$minitab2 ~;
$use_own_html_between_messagesn = ""; $use_own_html_between_messagesy = "";
if ($use_own_html_between_messages ne "yes"){$use_own_html_between_messagesn = "checked"; } else {$use_own_html_between_messagesy = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="use_own_html_between_messages" VALUE="yes" $use_own_html_between_messagesy> - No<INPUT TYPE="radio" NAME="use_own_html_between_messages" VALUE="no" $use_own_html_between_messagesn>
$minitab3
</td>
<td> $cgifont
<TEXTAREA wrap=virtual NAME="html_between" ROWS="2" COLS="38">~;
foreach $row(@html_between)
{
print "$row";
}
print "</TEXTAREA></font></td></tr>";
print qq~
<tr valign=top>
<td>
$minitab1
Use html header
$minitab2 ~;
 $usehtmln = ""; $usehtmly = "";
if ($use_user_html ne "yes"){$usehtmln = "checked"; } else {$usehtmly = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="use_user_html" VALUE="yes" $usehtmly> - No<INPUT TYPE="radio" NAME="use_user_html" VALUE="no" $usehtmln>
$minitab3
<TEXTAREA wrap=virtual NAME="user_html" ROWS="9" COLS="38">~;
foreach $row(@user_html)
{
print "$row";
}
print "</TEXTAREA></font></td>";
print qq~
<td>
$minitab1
Use html footer
$minitab2 ~;
$use_user_html_footern = "";  $use_user_html_footery = "";
if ($use_user_html_footer ne "yes"){$use_user_html_footern = "checked"; } else {$use_user_html_footery = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="use_user_html_footer" VALUE="yes" $use_user_html_footery> - No<INPUT TYPE="radio" NAME="use_user_html_footer" VALUE="no" $use_user_html_footern>
$minitab3
<TEXTAREA wrap=virtual NAME="user_html_footer" ROWS="9" COLS="38">~;
foreach $row(@user_html_footer)
{
print "$row";
}
print "</TEXTAREA></font></td><tr>";
print qq~
</table></td></tr></table></td></tr></table>
<INPUT TYPE="submit" VALUE="Update standard preferences">

<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td bgcolor = $titlebak>$fwhite<b>Message control</b></td></tr>
<tr valign=top>
<td>
$minitab1
Block multiple posts in same day by same IP?
$minitab2 ~;
$anti_spamn = ""; $anti_spamy = "";
if ($anti_spam ne "yes"){$anti_spamn = "checked"; } else {$anti_spamy = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="anti_spam" VALUE="yes" $anti_spamy> - No<INPUT TYPE="radio" NAME="anti_spam" VALUE="no" $anti_spamn>
$minitab3
</td></tr>~;
$anti_ips =~ s/\,/ /g;
print qq~
<tr valign=top><td width=100%> $cgifont
<i>List any servers or IP addresses (or parts thereof) to block. (Use a white space between multiple addresses)</i>
<div align=center><input type=text name="anti_ips" value="$anti_ips" size=100></center></td> </tr>~;
$bad_words =~ s/\,/ /g;
print qq~
<tr valign=middle>
<td width=100%> $cgifont
<i>List words you would rather your guest did not use. (Use your imagination.) </i><div align=center>
<b>egg</b> will only block the word "<i>egg</i>"; <b>egg*</b> will block "egg, eggs, egged etc.";
<br><b>*egg</b> will block "clegg, dregg etc."; <b>*egg*</b> will block "beggar, dreggs etc."<br>
<input type=text name="bad_words" value="$bad_words" size=100> </div>
</td> </tr>
</table></td></tr></table></td></tr></table>
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td colspan=2 bgcolor = $titlebak>$fwhite<b>PowerBook management</b></td></tr>
<tr valign=top><td width=50%>
$minitab1 Maximum messages in PowerBook $minitab2 <input type=text name="max" value="$max" size=7> $minitab3
</td><td>
$minitab1 Days until message is sent to Recycle Bin $minitab2 <input type=text name="days_to_delete" value="$days_to_delete" size=7> $minitab3
</td></tr>
<tr valign=top><td>
$minitab1 Days in Recycle Bin until trash
$minitab2 <input type=text name="days_to_trash" value="$days_to_trash" size=7> $minitab3
</td><td>
$minitab1 Days your automatic backups are kept $minitab2 <input size=7 type=text name="days_to_delete_backup_files" value="$days_to_delete_backup_files"> $minitab3
</td></tr>
<tr valign=top><td colspan=2>
$minitab1 Number of hours after posting that guests can edit their messages
$minitab2 <input type=text name="hourstoedit" value="$hourstoedit" size=7>
$minitab3
</td></tr>
</table></td></tr></table></td></tr>


</table>
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td colspan=3 bgcolor = $titlebak>$fwhite<b>Backup email</b></td></tr> ~;
$mail_backup_to_adminn = "";  $mail_backup_to_adminy = "";
if ($mail_backup_to_admin ne "yes"){$mail_backup_to_adminn = "checked"; } else {$mail_backup_to_adminy = "checked"; }
print qq~
<tr valign=top><td> $cgifont <i>Send regular email backup to admin?</i></font></td><td colspan=2>
$cgifont Yes<INPUT TYPE="radio" NAME="mail_backup_to_admin" VALUE="yes" $mail_backup_to_adminy> -
No<INPUT TYPE="radio" NAME="mail_backup_to_admin" VALUE="no" $mail_backup_to_adminn>
</td></tr>
<tr valign=top><td rowspan=3> $cgifont <i>Frequency of regular email of backup to admin</i></font></td>
<td colspan=2> $cgifont Daily: <INPUT TYPE="radio" NAME="mail_admin_backups_interval" VALUE="daily" ~;
print "checked" if ($mail_admin_backups_interval eq "daily");
print qq~ ></font></td></tr>~; # /tr is correct
print qq~<td> $cgifont Weekly: <INPUT TYPE="radio" NAME="mail_admin_backups_interval" VALUE="weekly" ~;
print "checked" if ($mail_admin_backups_interval eq "weekly");
print qq~ ></font></td> ~;
print qq~
<td> $cgifont
Day of week : <SELECT NAME="mail_admin_backups_day">
<OPTION value = "$mail_admin_backups_day" selected>$weekdaysbak[$mail_admin_backups_day]
<OPTION value = "0">Sunday
<OPTION value = "1">Monday
<OPTION value = "2">Tuesday
<OPTION value = "3">Wednesday
<OPTION value = "4">Thursday
<OPTION value = "5">Friday
<OPTION value = "6">Saturday
</SELECT>
</font></td></tr>
~;
if ($mail_admin_backups_interval eq "monthly")
{
print qq~
<tr>
<td> $cgifont
Monthly: <INPUT TYPE="radio" NAME="mail_admin_backups_interval" VALUE="monthly" checked></font></td>
~;
}
else
{
print qq~
<tr>
<td> $cgifont
Monthly: <INPUT TYPE="radio" NAME="mail_admin_backups_interval" VALUE="monthly"></font></td>
~;
}
print qq~
<td> $cgifont
Day of month: <SELECT NAME="mail_admin_backups_month">
<OPTION selected>$mail_admin_backups_month ~;
for (my $x = 1; $x < 29; $x++)
{print qq~ <OPTION>$x
~; }
print qq~ </SELECT>
</font></td></tr>
~;
print qq~
</table></td></tr></table></td></tr></table> <input type=hidden name="book" value="$book">
<INPUT TYPE="hidden" NAME="action" VALUE="edit_prefs"><INPUT TYPE="submit" VALUE="Update standard preferences">
</form>
~;
print qq~ <hr size=1 width=700>
~;
} # end view_prefs
###############
sub delete_item
{
&seek_cook;
&get_file_lock("$location_of_lock_file");
$ref = $FORM{'ref'};
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$powerbook_data_name");
foreach $row (@data)
{
@fields = split (/\|/, $row);
if (($ref eq $fields[0]) || ($ref eq $fields[33]))
{
print USER_FILE "$fields[0]|$fields[1]|$fields[2]|$fields[3]|$fields[4]|$fields[5]|$fields[6]|$fields[7]|$fields[8]|$fields[9]|del|$fields[11]|$now|$fields[13]|$fields[14]|$fields[15]|$fields[16]|$fields[17]|$fields[18]|$fields[19]|$fields[20]|$fields[21]|$fields[22]|$fields[23]|$fields[24]|$fields[25]|$fields[26]|$fields[27]|$fields[28]|$fields[29]|$fields[30]|$fields[31]|$fields[32]|$fields[33]|$fields[34]|$fields[35]|$fields[36]|$fields[37]|$fields[38]|$fields[39]|$fields[40]|$fields[41]|\n";
}
else
{
print USER_FILE "$row";
}
### This adds "del" to field 10 and the date it is deleted to field 12.
}
close(USER_FILE);
&release_file_lock("$location_of_lock_file");
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_to_edit&vat=$varurl"> ~;
&main_headerb;
print qq~
<center>
~;
} # end delete_item
sub delete_all
{
&seek_cook;
&get_file_lock("$location_of_lock_file");
$ref = $FORM{'ref'};
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$powerbook_data_name");
foreach $row (@data)
{
@fields = split (/\|/, $row);
if ($fields[10] eq "del")
{
print USER_FILE "$row";
}
else
{
print USER_FILE "$fields[0]|$fields[1]|$fields[2]|$fields[3]|$fields[4]|$fields[5]|$fields[6]|$fields[7]|$fields[8]|$fields[9]|del|$fields[11]|$now|$fields[13]|$fields[14]|$fields[15]|$fields[16]|$fields[17]|$fields[18]|$fields[19]|$fields[20]|$fields[21]|$fields[22]|$fields[23]|$fields[24]|$fields[25]|$fields[26]|$fields[27]|$fields[28]|$fields[29]|$fields[30]|$fields[31]|$fields[32]|$fields[33]|$fields[34]|$fields[35]|$fields[36]|$fields[37]|$fields[38]|$fields[39]|$fields[40]|$fields[41]|\n";
}
### This adds "del" to field 9 and the date it is deleted to field 12.
}
close(USER_FILE);
&release_file_lock("$location_of_lock_file");
&content;
print qq~ <html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=control_panel&vat=$varurl"></head> ~;
print qq~ <body>
<center>
</body>
</html>
~;
} # end delete_all
sub trash_all
{
&seek_cook;
&get_file_lock("$location_of_lock_file");
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$powerbook_data_name");
open(FIELDS_FILE,"$field_names");
@fielddata = <FIELDS_FILE>;
close(FIELDS_FILE);
foreach $row (@data)
{
@fields = split (/\|/, $row);
if ($fields[10] ne "del")
{
print USER_FILE "$row";
}
else
{
$image_dir_path =~ s/\/$//gi;
#########
foreach $fieldrow (@fielddata)
{
@fieldrows = split (/\|/, $fieldrow);
if (($fieldrows[2] eq "IMAGE") || ($fieldrows[2] eq "FILE") )
{
$numoffield = $FARRARY{$fieldrows[12]};
$name_of_file = $fields[$numoffield];
push(@imagesinthismessage, $name_of_file);
}
}
foreach $fname (@imagesinthismessage){
$fullfile = "$image_dir_path/$fname";
if (-e $fullfile)
{
unlink($fullfile);
}
}
}
}
close(USER_FILE);
&release_file_lock("$location_of_lock_file");
&content;
print qq~ <head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=control_panel&vat=$varurl"></head><body>
<center></body></html>
~;
} # end trash all
sub undelete_item
{
&seek_cook;
$ref = $FORM{'ref'};
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@data = <USER_FILE>;
close(USER_FILE);
&get_file_lock("$location_of_lock_file");
open(USER_FILE,">$powerbook_data_name");
foreach $row (@data)
{
@fields = split (/\|/, $row);
if ($ref ne $fields[0])
{
print USER_FILE "$row";
}
else
{
print USER_FILE "$fields[0]|$fields[1]|$fields[2]|$fields[3]|$fields[4]|$fields[5]|$fields[6]|$fields[7]|$now|$fields[9]||$fields[11]||$fields[13]|$fields[14]|$fields[15]|$fields[16]|$fields[17]|$fields[18]|$fields[19]|$fields[20]|$fields[21]|$fields[22]|$fields[23]|$fields[24]|$fields[25]|$fields[26]|$fields[27]|$fields[28]|$fields[29]|$fields[30]|$fields[31]|$fields[32]|$fields[33]|$fields[34]|$fields[35]|$fields[36]|$fields[37]|$fields[38]|$fields[39]|$fields[40]|$fields[41]|\n";
}
}
close(USER_FILE);
&release_file_lock("$location_of_lock_file");
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_to_undo&vat=$varurl"> ~;
&main_headerb;
print qq~
<center>
~;
&inter_footer;
exit;
}
sub trash_item
{
&seek_cook;
$ref = $FORM{'ref'};
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@data = <USER_FILE>;
close(USER_FILE);
&get_file_lock("$location_of_lock_file");
open(USER_FILE,">$powerbook_data_name");
foreach $row (@data)
{
@fields = split (/\|/, $row);
if ($ref ne $fields[0])
{
print USER_FILE "$row";
}
else # just need to remove images from the image directory
{
open(FIELDS_FILE,"$field_names");
@fielddata = <FIELDS_FILE>;
close(FIELDS_FILE);
foreach $fieldrow (@fielddata)
{
@fieldrows = split (/\|/, $fieldrow);
if (($fieldrows[2] eq "IMAGE") || ($fieldrows[2] eq "FILE") )
{
$numoffield = $FARRARY{$fieldrows[12]};
$name_of_file = $fields[$numoffield];
push(@imagesinthismessage, $name_of_file);
}
}
}
}
close(USER_FILE);
$image_dir_path =~ s/\/$//gi;
foreach $fname (@imagesinthismessage)
{
$fullfile = "$image_dir_path/$fname";
if (-e $fullfile)
{
unlink($fullfile);
}
}
&release_file_lock("$location_of_lock_file");
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_to_undo&vat=$varurl"> ~;
&main_headerb;
print qq~
<center>~;
&inter_footer;
exit;
} # end trash_item
sub amqdate
{
$amqdate = $_[0];
@bits = split (/\//, $amqdate);
$amqyear = $bits[2];
if ($amqyear > 1999)
{
$amqyear = ($amqyear - 2000);
}
if ($amqyear == 4 || $amqyear == 8 || $amqyear == 12 || $amqyear == 16 || $amqyear == 0 || $amqyear == 20 || $amqyear == 24)
{$leap = "yes";}
else
{$leap = "no";}
if ($amqyear == 1 || $amqyear == 5 || $amqyear == 9 || $amqyear == 13 || $amqyear == 17 || $amqyear == 21 || $amqyear == 25)
{
$extradays = ((($amqyear - 1)/4)+1);
}
$amqyeardays = (($amqyear * 365)+$extradays);
$amqday = $bits[0];
if ($bits[1] == 1)
{$monthdays = 0;}
if ($bits[1] == 2)
{$monthdays = 31;}
if ($bits[1] == 3)
{$monthdays = 59;}
if ($bits[1] == 4)
{$monthdays = 90;}
if ($bits[1] == 5)
{$monthdays = 120;}
if ($bits[1] == 6)
{$monthdays = 151;}
if ($bits[1] == 7)
{$monthdays = 181;}
if ($bits[1] == 8)
{$monthdays = 212;}
if ($bits[1] == 9)
{$monthdays = 243;}
if ($bits[1] == 10)
{$monthdays = 273;}
if ($bits[1] == 11)
{$monthdays = 304;}
if ($bits[1] == 12)
{$monthdays = 334;}
if ($leap eq "yes" && $bits[1] >2)
{
$monthdays = ($monthdays+1);
}
$amqtotal = ($amqday + $amqyeardays + $monthdays);
return($amqtotal);
}
sub check_update
{
unless (-e "$update_name")
{
umask 000;
}
open(NUMBER,"$update_name") || &oops('$update_name');
$num = <NUMBER>;
close(NUMBER);
if ($num < $revdate) {
&get_file_lock("$location_of_lock_file");
open(NUMBER,">$update_name");
print NUMBER "$revdate";
close(NUMBER);
$check_digits = 0;
@digits = split (//, $days_to_delete);
foreach $w (@digits)
{
unless ($w =~ /[0-9]/)
{
$check_digits = 1;
}
}
if (($check_digits == 1) || ($days_to_delete == 0))
{
$days_to_delete = 99999999999999999999999999999999999;
}
#if ($days_to_delete > 0)
#{
&update_database;
# }
&release_file_lock("$location_of_lock_file");
}
}
sub update_database
{
open(USER_FILE,"$powerbook_data_name"); # reset counter/refnumbers if necessary
@data = <USER_FILE>; close(USER_FILE);
$foundlowone = "no";
foreach $row (@data)
{
@fields = split (/\|/, $row);
if ($fields[0] < 200000)
{
$foundlowone = "yes";
last;
}
}
if ($foundlowone ne "no"){
open(USER_FILE,">$powerbook_data_name");
my $y = 2015000;
foreach $row (@data)
{
$y++;
@fields = split (/\|/, $row);
print USER_FILE "$y|";
for (my $x = 1; $x < 31; $x++){
print USER_FILE "$fields[$x]|";
}
print USER_FILE "\n";
}
close(USER_FILE);
$y++;
open(USER_FILE,">$counter_name");
print USER_FILE "$y";
close(USER_FILE);
}
############# run automatic delete or trash
open(USER_FILE,"$powerbook_data_name");
@data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$powerbook_data_name");

foreach $row (@data)
{
@fields = split (/\|/, $row);
if (($fields[10] eq "del") && ($fields[12]) && ($fields[12] < $now - $days_to_trash))
{
}
elsif ((!$fields[12]) && ($fields[3] < (time - ($days_to_delete*$sinday))))
{
print USER_FILE "$fields[0]|$fields[1]|$fields[2]|$fields[3]|$fields[4]|$fields[5]|$fields[6]|$fields[7]|$fields[8]|$fields[9]|del|$fields[11]|$now|$fields[13]|$fields[14]|$fields[15]|$fields[16]|$fields[17]|$fields[18]|$fields[19]|$fields[20]|$fields[21]|$fields[22]|$fields[23]|$fields[24]|$fields[25]|$fields[26]|$fields[27]|$fields[28]|$fields[29]|$fields[30]|$fields[31]|$fields[32]|$fields[33]|$fields[34]|$fields[35]|$fields[36]|$fields[37]|$fields[38]|$fields[39]|$fields[40]|$fields[41]|\n";
}
else
{
print USER_FILE "$row";
}
} # end for each
close(USER_FILE);
########### automatic prune if non-deleted messages greater than max
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@data = <USER_FILE>;
close(USER_FILE);
@revdata = reverse(@data);
@nondeldata = ();
@deldata = ();
@arraytodisplay = ();
foreach $row (@revdata)
{
@fields = split (/\|/, $row);
push (@nondeldata, $row) if $fields[10] ne "del"; # add non-deleted messages to new array #
push (@deldata, $row) if $fields[10] eq "del"; # add deleted messages to new array #
}
if (@nondeldata >$max)
{
$counter = 0;
foreach $row (@nondeldata)
{
@fields = split (/\|/, $row);
if ($counter < $max)
{
push (@arraytodisplay, $row);
}
else
{
$delrow = "$fields[0]|$fields[1]|$fields[2]|$fields[3]|$fields[4]|$fields[5]|$fields[6]|$fields[7]|$fields[8]|$fields[9]|del|$fields[11]|$now|$fields[13]|$fields[14]|$fields[15]|$fields[16]|$fields[17]|$fields[18]|$fields[19]|$fields[20]|$fields[21]|$fields[22]|$fields[23]|$fields[24]|$fields[25]|$fields[26]|$fields[27]|$fields[28]|$fields[29]|$fields[30]|$fields[31]|$fields[32]|$fields[33]|$fields[34]|$fields[35]|$fields[36]|$fields[37]|$fields[38]|$fields[39]|$fields[40]|$fields[41]|\n";
push (@arraytodisplay, $delrow);
}
$counter++;
}
@alldata = (@arraytodisplay, @deldata);
@sortedalldata = sort(@alldata);
open(USER_FILE,">$powerbook_data_name") || &oops('$powerbook_data_name');
foreach $row (@sortedalldata)
{
print USER_FILE "$row";
}
close(USER_FILE);
}
#########
&delete_old_backups;
&mail_backup if $mail_backup_to_admin eq "yes";
}
sub backup_to_dir
{
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@user_data = <USER_FILE>;
close(USER_FILE);
$location1 = "./$powerbook_backups_directory/powerbook_backup.$revdate";
umask 000;
open(BAK,">$location1");
foreach $row (@user_data)
{
print BAK "$row";
}
close(BAK);
} # end backup to dir



sub mail_backup
{

 $boook = $book;
 $boook = "Master" if $book eq "";
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@user_data = <USER_FILE>;
close(USER_FILE);
$data=join("",@user_data);
if ($include_settings_in_email_backup eq "")
{
open(USER_FILE,"$counter_name");
$new_data = <USER_FILE>;
close(USER_FILE);

$data = $data . "\n\n========\nCOUNTER\n". $new_data;

open(USER_FILE,"$prefs_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nSTANDARD PREFS\n". $new_data;

open(USER_FILE,"$active_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nACTIVE\n". $new_data;

open(USER_FILE,"$perms");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nPERMS\n". $new_data;

open(USER_FILE,"$access_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nACCESS\n". $new_data;


open(USER_FILE,"$singleperms");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nSINGLEPERMS\n". $new_data;

open(USER_FILE,"$menu_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nMENU\n". $new_data;

open(USER_FILE,"$layout_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nLAYOUT\n". $new_data;

open(USER_FILE,"$field_names");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nFIELDS\n". $new_data;

open(USER_FILE,"$colprefs_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nCOLORS\n". $new_data;

open(USER_FILE,"$langprefs_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nLANGUAGE\n". $new_data;

open(USER_FILE,"$months_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nMONTHS\n". $new_data;

open(USER_FILE,"$days_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nDAYS\n". $new_data;

open(USER_FILE,"$html_between_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nHTMLBETWEEN\n". $new_data;

open(USER_FILE,"$user_style_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nUSERSTYLE\n". $new_data;

open(USER_FILE,"$user_html_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nUSERHTML\n". $new_data;

 open(USER_FILE,"$user_html_footer_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nUSERHTMLFOOTER\n". $new_data;

 open(USER_FILE,"$user_date_file");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nDATE\n". $new_data;


 open(USER_FILE,"$senddate_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nSENDDATE\n". $new_data;

 open(USER_FILE,"$user_default_html_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nUSERDEFAULTHTML\n". $new_data;

 open(USER_FILE,"$user_default_html_footer_name");
@new_data = <USER_FILE>;
close(USER_FILE);
$new_data=join("",@new_data);
$data = $data . "\n\n========\nUSERDEFAULTHTMLFOOTER\n". $new_data;


}




open(NUMBER2,"$senddate_name") || &oops('$senddate_name');
$senddate = <NUMBER2>;
close(NUMBER2);
open(NUMBER1,"$senddate_name") || &oops('$senddate_name');
open (NUMBER1,">$senddate_name");
print NUMBER1 "$now";
close(NUMBER1);
if ((($mail_admin_backups_interval eq "monthly") && (($mail_admin_backups_month == $bakday) || (($now -$senddate) >27 ) ))
|| (($mail_admin_backups_interval eq "weekly") && (($mail_admin_backups_day == $wday) || (($now - $senddate) >6 ) ) )
|| ($mail_admin_backups_interval eq "daily"))
   {
   if ($use_active_email eq "yes"){
 &content;
 $data =~ s/"/QQTT/gi;
 print qq~
 <html>

<head>
  <title></title>
</head>

<body OnLoad="document.ant.submit();" >

Sorry for the interruption.<br>Processing backup at active-scripts.net... please wait a few seconds... Thank you...
<form action="http://www.active-scripts.net/cgi-bin/receive.pl" METHOD="POST" name="ant">

 <input type=hidden name="data" value="$data">
  <input type=hidden name="fullguest" value="$fullguest">
   <input type=hidden name="bk" value="$boook">
   <input type=hidden name="em" value="$admin_email">

</form>

</body>

</html>


 ~;
 exit;
 }
 else{

 $mailbody1 = "Below is a backup data file from your $boook Active PowerBook.\n\n" . "$data";
 &sndml($admin_email, "Active PowerBook ($boook backup)", $mailbody1) ;
}

}



}
#####################
sub delete_old_backups
{
opendir (USERS, "./$powerbook_backups_directory") || &oops('the $powerbook_backups_directory directory');
@files = grep(/^p/,readdir(USERS));
closedir (USERS);
foreach $file (@files)
{
if (-M "./$powerbook_backups_directory/$file" > $days_to_delete_backup_files)
{
unlink("./$powerbook_backups_directory/$file");
}
}
} # End of sub delete_old_bak
#########
sub html_search_results
{
$count = 1;
$number_of_messages = @hits;
@hits = reverse(@hits);
if ($search_flag ne "no")
{
if ($number_of_messages == 1)
{
print qq~ <tr><td><font face= "$textfontface" size=$textfontsize><B>$TXT_one_match</B></font> </td></tr>~;
}
else
{
print qq~ <tr><td><font face= "$textfontface" size=$textfontsize><B>$TXT_more_matches_1 $number_of_messages $TXT_more_matches_2</B></font> </td></tr>~;
}
}
print qq~ <tr><td width=$table_width align=center> ~;
foreach $row (@hits)
{
@fields = split (/\|/, $row);
&main_table_results;
} # end for each row
#########
print qq~ </td></tr> ~;
}
##############
sub view_backups
{
&seek_cook;

 if ($masterdata eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>These settings are currently controlled by the Master Control Panel.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
}

open(RESTORE_BACKUP,"./$powerbook_backups_directory/undo_restore.bak");
@restore_backup_data = <RESTORE_BACKUP>;
close(RESTORE_BACKUP);
opendir (USERS, "./$powerbook_backups_directory") || &oops('the backups directory');
@files = grep(/^power/,readdir(USERS));
closedir (USERS);
if (@files<1)
{
&content;
print qq~
<html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title>Active PowerBook $cptext Backup Manager</title>
<META http-equiv="refresh" content="2; URL=$guesturl?book=$book&action=control_panel&vat=$varurl">
</head>
<body bgcolor=#ffffff link=#000000 vlink=#000000>
<center>
<font face=Arial size=+1>Active PowerBook $cptext Backup Manager
</font><p>
$cgifont <a href="$guesturl?book=$book&action=control_panel&vat=$varurl"><B>There are currently no backups to restore.</B></a>
</font>
</center>
~;
}
else
{
&content;
print qq~
<center>
<html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title>Active PowerBook $cptext Backup Manager</title>
</head><body bgcolor=#ffffff link=#000000 vlink=#000000>
<table cellpadding = 1 cellspacing = 0 width=500><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td width=100% align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $cptext Backup Manager</b></td></tr>
<tr><td width=100% align=center> $cgifont
~; &linkjump; print qq~ ~;
if (@restore_backup_data >2)
{
print qq~
- <a href="$guesturl?book=$book&action=undo_last_restore&vat=$varurl"><B>Undo last restore</B></a>
~;
}
print qq~
</td></tr></form></table></td></tr></table></td></tr></table>
<table cellpadding = 1 cellspacing = 0 width=500><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
<FORM ACTION="$guesturl" METHOD="POST">
<INPUT TYPE="hidden" NAME="action" VALUE="restore_backups"><input type=hidden name="book" value="$book">
<center>
<tr valign = top><td align=center colspan=2> $cgifont <B>Select backup to restore</B></td></tr>
~;
@sorted_files = sort(@files);
@sorted_files = reverse(@sorted_files);
foreach $file (@sorted_files)
{
$year = substr($file, -8,4);
$month = substr($file, -4,2);
$month--;
$mon = $months[$month];
$day = substr($file, -2,2);
print qq~
<tr valign = top><td align=left> $cgifont
<INPUT TYPE="radio" NAME="file_to_restore" VALUE="$file"> $day - $mon - $year</td><td> - <a href="$guesturl?book=$book&action=view_single_backup&file_to_restore=$file&vat=$varurl"> $cgifont View</a></td></tr>
~;
}
print qq~
<tr><td colspan = 2><INPUT TYPE="submit" VALUE="Restore selected file"></td></tr>
</table>
</center>
</FORM>
~;
}
&inter_footer;
}
sub undo_last_restore
{
&seek_cook;
open(RESTORE_BACKUP,"./$powerbook_backups_directory/undo_restore.bak");
@restore_backup_data = <RESTORE_BACKUP>;
close(RESTORE_BACKUP);
if (@restore_backup_data <2)
{
&content;
print qq~
<html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title>$title</title>
<META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=control_panel&vat=$varurl">
</head>
<body bgcolor=#ffffff link=#000000 vlink=#000000>
<center>
<font face=Arial size=+1>Active PowerBook Backup Manager
</font><p>
$cgifont <a href="$guesturl?book=$book&action=control_panel&vat=$varurl"><B>No undo available at the moment.</B></a>
</font>
</center>
~;
}
open(MAIN_GUESTBOOK,">$powerbook_data_name") || &oops('$powerbook_data_name');
foreach $row (@restore_backup_data)
{
print MAIN_GUESTBOOK "$row";
}
close(MAIN_GUESTBOOK);
open(RESTORE_BACKUP,">./$powerbook_backups_directory/undo_restore.bak"); # wipe undo restore file
close(RESTORE_BACKUP);
&set_counter;
&content;
print qq~
<html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title></title>
<META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_backups&vat=$varurl">
</head>
<body bgcolor=#ffffff link=#000000 vlink=#000000>
<center>
<font face=Arial size=+1>Active PowerBook Backup Manager
</font><p>
$cgifont <a href="$guesturl?book=$book&action=view_backups&vat=$varurl"><B>Last restore undone.</B></a>
</font>
</center>
~;
exit;
}
sub restore_backups
{
&seek_cook;
$file_to_restore = $FORM{'file_to_restore'};
if ($file_to_restore eq "")
{
{
&basic_header;
print qq~
<center> $cgifont2 $title<p></font> $cgifont
<b> You didn't select a backup to restore. Please <a href="javascript:history.go(-1)">go back and select</a>. </b></font>
~;
exit;
}
}
open(MAIN_GUESTBOOK,"$powerbook_data_name") || &oops('$powerbook_data_name');
@main_data = <MAIN_GUESTBOOK>;
close(MAIN_GUESTBOOK);
open(RESTORE_BACKUP,">./$powerbook_backups_directory/undo_restore.bak");
foreach $row (@main_data)
{
print RESTORE_BACKUP "$row";
}
close(RESTORE_BACKUP);
&get_file_lock("$location_of_lock_file");
open(MAIN_GUESTBOOK,">$powerbook_data_name");
open(RESTORE,"./$powerbook_backups_directory/$file_to_restore") || &oops('/$powerbook_backups_directory/$file_to_restore');
@restore_data = <RESTORE>;
foreach $line (@restore_data)
{
print MAIN_GUESTBOOK "$line";
}
close(RESTORE);
close(MAIN_GUESTBOOK);
&release_file_lock("$location_of_lock_file");
&set_counter;
&content;
print qq~
<html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>$title</title>
<META http-equiv="refresh" content="3; URL=$guesturl?book=$book&action=view_backups&vat=$varurl">
</head><body bgcolor=#ffffff link=#000000 vlink=#000000>
<center><font face=Arial size=+1>Active PowerBook Backup Manager</font><p> $cgifont <a href="$guesturl?book=$book&action=view_backups&vat=$varurl"><B>Backup has been restored.</B></a><br>(You can undo this from the main Backup Manager page.)
</font></center>
~;
exit;
}
sub view_single_backup
{
&seek_cook;
&basic_header;
$file_to_restore = $FORM{'file_to_restore'};
$year = substr($file_to_restore, -8,4);
$month = substr($file_to_restore, -4,2);
$month--;
$mon = $months[$month];
$day = substr($file_to_restore, -2,2);
$datestamp = "$day"."-"."$mon"."-"."$year";
print qq~
<center>
<font face=Arial><B>Backup date: $datestamp</B><br></font> $cgifont
<a href="$guesturl?book=$book&action=restore_backups&file_to_restore=$file_to_restore&vat=$varurl">Restore this guestbook</a> | <a href="$guesturl?book=$book&action=view_backups&vat=$varurl">Return to Backup Manager</a></font>
~;
open(RESTORE,"./$powerbook_backups_directory/$file_to_restore");
@hits = <RESTORE>;
close(RESTORE);
$search_flag = "no";
print qq~ <table width="700"><tr><td> ~;
&html_search_results_plain;
print qq~ </td></tr></table> ~;
}
sub active_header
{
if ($demo eq "off")
{
print qq~
<tr><td width="$table_width" align="center"><img src="http://active-scripts.net/active_guestbook.gif"></td></tr>
~;
}
else
{
print qq~
<tr><td width=$table_width align=center> <img src="http://active-scripts.net/demo_images/active_guestbook.gif"></td></tr>
~;
}
}
sub title
{
print qq~
<tr><td width=$table_width align=$usertitlealignment> <font face="$textfontface"> <h1><b>$title</b></h1></font></td></tr>
~;
}


sub no_of_messages_display
{
print qq~
<tr><td width=$table_width align=center> <font size=$textfontsize face="$textfontface">
~;
if ($number_of_messages == 1)
{
print qq~
$TXT_there_is_now$number_of_messages$TXT_message_in_our_guestbook <br>
~;
}
else
{
print qq~
$TXT_there_are_now$number_of_messages$TXT_messages_in_our_guestbook <br>
~;
}
print qq~
</font></td></tr>
~;
}
sub main_header
{
print qq~
<html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title>$title</title>

~;
if ($thisisathankspage eq "yes")
{
$page_after_write = "$guesturl?book=$book&action=view_to_edit&vat=$varurl" if ($FORM{'moveme'});
$page_after_write = "$guesturl?book=$book&action=reload&vat=$varurl" if ($FORM{'sender'} eq "send_from_active");
print qq~ <META http-equiv="refresh" content="3; URL=$page_after_write"> ~;
}
if ($style ne "no")
{
print qq~ $user_style ~;
}
print qq~
</head>
<BODY BGCOLOR="$backcolor"
~;

if ($action eq "add")
{
print qq~  ~;
 }
if ($action eq "add_followup1" || $thisisathankspage eq "yes" ||
$action eq"userlogin" || $action eq "verifyuserlogin" || $action eq"" || $action eq"loadsearch" ||
$action eq"read" || $action eq"add" || $action eq"reload" || $action eq"preview" ||
$action eq"search" || $action eq"view_followup" || $action eq"searchform" ||$action eq "cpadd_followup1" )
{
if ($usebackgroundimage eq "yes")
{
print qq~
background = "$backgroundimage"
~;
}
}
print qq~
TEXT="$text" LINK="$link" VLINK="$vlink" ALINK="$alink" marginwidth="$marginwidth" marginheight="$marginheight" LEFTMARGIN="$marginwidth" TOPMARGIN="$marginheight" >
~; #start of body
}
########################
sub main_headera
{
print qq~
<html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title>$title</title> ~;
}
sub main_headerc
{
if ($style ne "no")
{
print qq~ $user_style ~;
}
print qq~
</head>
<BODY BGCOLOR="$backcolor"
~;
if ($action eq"" || $action eq"read" || $action eq"add" || $action eq"reload" || $action eq"preview" || $action eq"post_preview")
{
if ($usebackgroundimage eq "yes")
{
print qq~
background = "$backgroundimage"
~;
}
}
print qq~
TEXT="$text" LINK="$link" VLINK="$vlink" ALINK="$alink" marginwidth="$marginwidth" marginheight="$marginheight" LEFTMARGIN="$marginwidth" TOPMARGIN="$marginheight" >
~;
}
sub main_headerb
{
if ($style ne "no")
{
print qq~ $user_style ~;
}
print qq~
</head>
<BODY BGCOLOR="#ffffff"
~;
if ($action eq"" || $action eq"read" || $action eq"add" || $action eq"reload" || $action eq"preview" || $action eq"post_preview")
{
if ($usebackgroundimage eq "yes")
{
print qq~
background = "$backgroundimage"
~;
}
print qq~
TEXT="$text" LINK="$link" VLINK="$vlink" ALINK="$alink" marginwidth="$marginwidth" marginheight="$marginheight" LEFTMARGIN="$marginwidth" TOPMARGIN="$marginheight" >
<div align=$alignment> ~;
}
else
{
print qq~
TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" marginwidth="$marginwidth" marginheight="$marginheight" LEFTMARGIN="$marginwidth" TOPMARGIN="$marginheight" >
<div align=$alignment> ~;
}
}
sub main_headerd
{

print qq~
</head>
<BODY BGCOLOR="#ffffff"
~;

print qq~ <font face=Arial size=2>~;

}
sub content {
print "Content-type: text/html\n\n";
}
sub show_number_menu {
print qq~
~;
$number_of_messages = int($number_of_messages); # int here sorts out any funny decimals entered in the control panel
$number_of_pages = ($number_of_messages / $no_displayed) ;
$number_of_pages = int($number_of_pages); # no of full pages
if ($number_of_messages > ($number_of_pages * $no_displayed)){
$extra = "yes";
}
if ($extra eq "yes"){
$number_of_pages = $number_of_pages +1;
}
($start_number = 0) if (!$start_number);
for ($x = 1; $x < $number_of_pages+1 ; $x++ ){
$sn = (($x*$no_displayed)- $no_displayed);
$bottom = ($start_number - (11 * $no_displayed));
$top = ($start_number + (11 * $no_displayed));
if ((($sn > $bottom) && ($sn < $top)) || ($x == "1") || ($x == $number_of_pages)){
if ($sn ne $start_number){
print qq~
<a href="$guesturl?book=$book&start_number=$sn&vat=$varurl~;
print "&action=view_to_edit" if ($action eq "view_to_edit");
print "&action=view_to_undo" if ($action eq "view_to_undo");
print qq~">$x</a>
~;
}
else{
print qq~
$x
~;
} # end else
}
} # end for
print qq~
~;
}
sub user_image {
if ($user_image_url)
{
print qq~
<tr><td width=$table_width align=$userimagealignment><img src = "$user_image_url"></td></tr>
~;
}
}
sub user_html {
print qq~ $user_html ~;
}
sub user_html_footer {
print qq~ $user_html_footer~;
}

sub view_copy_prefs {
&seek_cook;

&content;
print qq~
<HTML><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>$title</title>
~;
&required_script;
print qq~


<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from non-Java browsers
function Confirmdelete() {
var Confirmation;
Confirmation = "ARE YOU SURE? Selected settings in the destination powerbook will be permanently overwritten.";
if (confirm(Confirmation)){
return true;
}
else {
return false;
}
}

// End Java Hiding. -->
 </script>

<SCRIPT LANGUAGE="JavaScript">



<!--
function checkChoice(field, i) {
if (i == 0)  { // "All" checkbox selected.
   if (field[0].checked == true) {
        for (i = 2; i < 10; i++)
            { field[i].checked = true; }

  field[10].checked = false;
 field[1].checked = false;
   }
    else {
        for (i = 2; i < 10; i++)
            { field[i].checked = false; }
  field[10].checked = false;
 field[1].checked = false;
   }
}
else if (i == 1)  { // "All" checkbox selected.
if (field[1].checked == true) {
field[0].checked = false;
for (i = 2; i < field.length; i++)
field[i].checked = true;
   }
 else if (field[1].checked == false) {
field[0].checked = false;
for (i = 2; i < field.length; i++)
field[i].checked = false;
   }
}

else  {  // A checkbox other than "Any" selected.
if (field[i].checked == false) {
field[0].checked = false;
field[1].checked = false;
      }
   }
}
//  End -->
</script>
</head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600">
~;

 open(SERFILE,"$server_names");
@serverdata = <SERFILE>;
close(SERFILE);
@serverdata = reverse(@serverdata);


print qq~
<center>
<table cellpadding = 1 cellspacing = 0 width=600><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook Settings Copy Utility</b></td></tr>
<tr><td width=100% align=center>
$cgifont


<a href="$guesturl?action=control_panel&vat=$varurl">Master Control Panel</a> <a href="$guesturl?action=view_servers&vat=$varurl">Server Manager</a>
 ~;
#&linkjump;

print qq~
<p>
<B>Please select the source and destination.</B><br>You can copy preferences from one powerbook to another. <br>Once copied, you can then edit settings as you see fit.</font></form>
<FORM ACTION="$guesturl" METHOD="POST"  onSubmit="return Confirmdelete()" name=pickform>
<INPUT TYPE="hidden" NAME="action" VALUE="copy_individual_preferences">
<table border=0>
<tr><td> $cgifont <b>Source PowerBook</b> </td><td> $cgifont <select name=source><option value="" >Select</option>
<option value="" >========================</option>  <option value="EPIGITHA89"    ~;
 print "selected" if $FORM{'source'} eq "EPIGITHA89";
print qq~ >MASTER</option>
~;
foreach $row (@serverdata)
{
@serverfields = split (/\|/, $row);

 print qq~ <option value="$serverfields[0]"  ~;

 print "selected" if $FORM{'source'} eq $serverfields[0];

 print qq~  >$serverfields[1]</option>
 ~;

}



print qq~</select></td></tr>
<tr><td> $cgifont <b>Destination PowerBook</b> </td><td> $cgifont <select name=destination><option value="" >Select</option>
<option value="" >========================</option>

<option value="EPIGITHA89" ~;
   print "selected" if $FORM{'destination'} eq "EPIGITHA89";

print qq~   >MASTER</option> ~;

 foreach $row (@serverdata)
{
@serverfields = split (/\|/, $row);

 print qq~ <option value="$serverfields[0]"  ~;
        print "selected" if $FORM{'destination'} eq $serverfields[0];
 print qq~ >$serverfields[1]</option>
 ~;

}

%opts = ('col', 'Colors/Images', 'lang', 'Language', 'prefs', 'Standard Preferences', 'date', 'Date', 'menu', 'Menus', 'perms', 'Access', 'fields', 'Fields', 'layout', 'Layout', 'data', 'Data', 'all', 'ALL');

print qq~</select></td></tr>
<tr valign=top><td> $cgifont <b>Select settings</b> </td>
<td> $cgifont

<INPUT TYPE="checkbox" NAME="pref"  value="allbutdata" onclick="checkChoice(document.pickform.pref, 0)">ALL except DATA<br>
<INPUT TYPE="checkbox" NAME="pref"  value="all" onclick="checkChoice(document.pickform.pref, 1)">ALL including DATA (be VERY careful)<br>

<INPUT TYPE="checkbox" NAME="pref"  value="lang" onclick="checkChoice(document.pickform.pref, 2)">Language <br>
<INPUT TYPE="checkbox" NAME="pref"  value="prefs" onclick="checkChoice(document.pickform.pref, 3)">Standard Preferences  <br>
<INPUT TYPE="checkbox" NAME="pref"  value="date" onclick="checkChoice(document.pickform.pref, 4)">Date  <br>
<INPUT TYPE="checkbox" NAME="pref"  value="menu" onclick="checkChoice(document.pickform.pref, 5)">Menus <br>
<INPUT TYPE="checkbox" NAME="pref"  value="perms" onclick="checkChoice(document.pickform.pref, 6)">Access <br>
<INPUT TYPE="checkbox" NAME="pref"  value="fields" onclick="checkChoice(document.pickform.pref, 7)">Fields <br>
<INPUT TYPE="checkbox" NAME="pref"  value="layout"onclick="checkChoice(document.pickform.pref, 8)" >Layout <br>
 <INPUT TYPE="checkbox" NAME="pref"  value="col" onclick="checkChoice(document.pickform.pref, 9)">Colors/Images<br>
<INPUT TYPE="checkbox" NAME="pref"  value="data" onclick="checkChoice(document.pickform.pref, 10)">Data <br>


</td></tr>
</table>
</td></tr></table> </td></tr></table></td></tr></table>
<INPUT TYPE="submit" VALUE="Copy Settings">
</FORM>
~;
&inter_footer;
}

sub copy_individual_preferences {
&seek_cook;

 $query = new CGI;


 @prefarray = $query->param('pref');

  foreach (@prefarray)
  {
   $FOUNDPREF{$_} ="yes";
  }



 if (($FORM{'source'} eq "")|| ($FORM{'destination'} eq "")|| ($FORM{'pref'} eq "")    ){
  &content;
 print qq~ <font face=Arial size=2>Error. You need to select a valid option in all fields.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
  }

  if ($FORM{'source'} eq $FORM{'destination'}){
  &content;
 print qq~ <font face=Arial size=2>Error. Source and Destination are the same.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
  }
   open(SERFILE,"$server_names");
  @serverdata = <SERFILE>;
close(SERFILE);
@serverdata = reverse(@serverdata);


 foreach $row (@serverdata)
{
@serverfields = split (/\|/, $row);
 $SEVF{$serverfields[0]} = $serverfields[1];

}



 $asdf = $SEVF{$FORM{'source'}};
 $asdf2 = $SEVF{$FORM{'destination'}};



 $ssd = "$asdf" . "_active_powerbook_files";
 $sdd = "$asdf2" . "_active_powerbook_files";

       if  ($FORM{'source'} eq "EPIGITHA89")
       {
        $ssd = "active_powerbook_files";

     }

         if  ($FORM{'destination'} eq "EPIGITHA89")
       {

      $sdd = "active_powerbook_files";
     }

 $colsinsource =  "./$ssd/colprefs.txt";
 $colsindestination =  "./$sdd/colprefs.txt";

 unless ((-e "$colsinsource") && (-e "$colsindestination")     ){    # checking the directory exists
  &content;
 print qq~ <font face=Arial size=2>Error. The destination and/or the source powerbook does not appear to have been initialized. You must initiaize a powerbook by visiting it once.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;

 }

   if ($FOUNDPREF{'data'} eq "yes"){
  $source8 =  "./$ssd/powerbook_data.txt"; $destination8 =  "./$sdd/powerbook_data.txt";
   &copy_file($source8, $destination8 );
   $source8 =  "./$ssd/counter.txt"; $destination8 =  "./$sdd/counter.txt";
     &copy_file($source8, $destination8 );
  }


  if ($FOUNDPREF{'col'} eq "yes"){
  $source8 =  "./$ssd/colprefs.txt"; $destination8 =  "./$sdd/colprefs.txt";  &copy_file($source8, $destination8 );
  }

  if ($FOUNDPREF{'lang'} eq "yes"){
  $source8 =  "./$ssd/langprefs.txt"; $destination8 =  "./$sdd/langprefs.txt";   &copy_file($source8, $destination8 );
   $source1 =  "./$ssd/months.txt"; $destination1 =  "./$sdd/months.txt";
  $source2 =  "./$ssd/days.txt"; $destination2 =  "./$sdd/days.txt";
  &copy_file($source1, $destination1 );  &copy_file($source2, $destination2 );
  }

    if ($FOUNDPREF{'prefs'} eq "yes"){
  $source8 =  "./$ssd/prefs.txt"; $destination8 =  "./$sdd/prefs.txt";  &copy_file($source8, $destination8 );
    $source1 =  "./$ssd/html_between.txt"; $destination1 =  "./$sdd/html_between.txt";
  $source2 =  "./$ssd/user_style.txt"; $destination2 =  "./$sdd/user_style.txt";

   $source3 =  "./$ssd/user_html.txt"; $destination3 =  "./$sdd/user_html.txt";
  $source4 =  "./$ssd/user_html_footer.txt"; $destination4 =  "./$sdd/user_html_footer.txt";
     &copy_file($source1, $destination1 );  &copy_file($source2, $destination2 );
       &copy_file($source3, $destination3 );  &copy_file($source4, $destination4 );

  }


  if ($FOUNDPREF{'date'} eq "yes"){
  $source8 =  "./$ssd/user_date_format.txt"; $destination8 =  "./$sdd/user_date_format.txt";  &copy_file($source8, $destination8 );
  }
   if ($FOUNDPREF{'menu'} eq "yes"){
  $source8 =  "./$ssd/menuprefs.txt"; $destination8 =  "./$sdd/menuprefs.txt";  &copy_file($source8, $destination8 );
  }
   if ($FOUNDPREF{'perms'} eq "yes"){
  $source8 =  "./$ssd/perms.txt"; $destination8 =  "./$sdd/perms.txt";  &copy_file($source8, $destination8 );
  $source1 =  "./$ssd/individaccess.txt"; $destination1 =  "./$sdd/individaccess.txt";
  $source2 =  "./$ssd/singleperms.txt"; $destination2 =  "./$sdd/singleperms.txt";

   &copy_file($source1, $destination1 );  &copy_file($source2, $destination2 );
  }

   if ($FOUNDPREF{'fields'} eq "yes"){
  $source8 =  "./$ssd/field_names.txt"; $destination8 =  "./$sdd/field_names.txt";   &copy_file($source8, $destination8 );
  }
   if ($FOUNDPREF{'layout'} eq "yes"){
  $source8 =  "./$ssd/layout_name.txt"; $destination8 =  "./$sdd/layout_name.txt";   &copy_file($source8, $destination8 );
  }

  &content;
&main_headera;
print qq~ <META http-equiv="refresh" content="1; URL=$guesturl?action=view_copy_prefs&vat=$varurl&source=$FORM{'source'}&destination=$FORM{'destination'}"> ~;
&main_headerd;
print qq~
<br><a href="$guesturl?action=view_copy_prefs&vat=$varurl&source=$FORM{'source'}&destination=$FORM{'destination'}">Settings have been copied</a></font>
~;
  exit;

}


sub view_change_password {
&seek_cook;
if ($mastermanagemessagesonly eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>Access to this section is currently restricted.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
  }
&content;
print qq~
<HTML><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>$title</title>
~;
&required_script;
print qq~
</head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600">
~;
print qq~
<center>
<table cellpadding = 1 cellspacing = 0 width=600><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $cptext Password Manager</b></td></tr>
<tr><td width=100% align=center>
$cgifont
~;
&linkjump; print qq~
<p>
<B>Please enter your new password twice.</B><br>(please note that passwords are <i>case-sensitive</i>)</font></form>
<FORM ACTION="$guesturl" METHOD="POST" onSubmit="return checkrequired(this)"><input type=hidden name="book" value="$book">
<INPUT TYPE="hidden" NAME="action" VALUE="change_password">
<table border=0>
<tr><td> $cgifont New password </td><td> $cgifont <INPUT TYPE="text" NAME="requiredpass1" SIZE="10" MAXLENGTH="80"></td></tr>
<tr><td> $cgifont New password again </td><td> $cgifont <INPUT TYPE="text" NAME="requiredpasscheck" SIZE="10" MAXLENGTH="80"></td></tr>
</table>
</td></tr></table> </td></tr></table></td></tr></table>
<INPUT TYPE="submit" VALUE="Change password">
</FORM>
~;
&inter_footer;
}
sub change_password
{
&seek_cook;
$pass1 = $FORM{'requiredpass1'};
$passcheck = $FORM{'requiredpasscheck'};
if ($pass1 eq $passcheck)
{
open(ACTIVE,">$active_name");
$newpass = crypt($pass1, $salt);
print ACTIVE "$newpass";
close(ACTIVE);
#&SetCookies('activea',$newpass);
print "Set-Cookie:$cooknamelocal=$newpass\n";
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=control_panel&vat=$varurl"> ~;
&main_headerd;
print qq~
<B>Change Active PowerBook Control Panel Password</B>
<br><a href="$guesturl?book=$book&action=control_panel&vat=$varurl">Password has been changed.</a></font>
~;
}
else
{
&content;
&plain_header_stop;
print qq~
<font face=Arial size=+1>
<B>Change Active PowerBook Control Panel Password</B> </font>
<font face=Arial>
<p><B>The password has NOT been changed.<br>The two passwords you typed were not the same. </B><br></font>
$cgifont
<a href="$guesturl?book=$book&action=control_panel&vat=$varurl">Control Panel</a> | <a href="$guesturl?book=$book&action=view_change_password&vat=$varurl">Try again</a>
</font>
~;
}
}
sub enter_password
{
&content;
print qq~
<HTML><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>$title</title>
</head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600" onLoad="document.forms[0].password.focus()">
~;
print qq~ <center> <FORM ACTION="$guesturl" METHOD="POST">
<INPUT TYPE="hidden" NAME="action" VALUE="control_panel"><input type=hidden name="book" value="$book">
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $cptext Control Panel</b></td></tr>
<tr><td width=100% align=center> $cgifont Please enter password.<br>
<I>You will need to have Cookies enabled for easy navigation through the Control Panel features.
</I>
</font>
$cgifont <p><b>Password</b> <INPUT TYPE="password" NAME="password" SIZE="20" MAXLENGTH="80"><br>
Keep me logged in on this machine <input type="checkbox" name="alogin" value="yes">
<br>
<INPUT TYPE="submit" VALUE="Enter Control Panel">
</FORM>
</font>
</td></tr>
</table></td></tr></table></td></tr></table>
~;
&inter_footer;
}
sub seek_cook
{
if ($action eq "block_computer")
{
}
if (($cookie_default eq "") || (!$cookie_default) )
{
&content;
print "$valid_ip";
exit;
}
#############
$xyza= $FORM{'bottom'};
unless ($xyza eq $cookie_default)
{
if ($COOK{$cooknamelocal})
{
$password = $COOK{$cooknamelocal};
$first_time = "no";
}
else
{
$xyz= $FORM{'password'};
$password = crypt($xyz, $salt);
$first_time = "yes";
}
if ($password eq $active_string)
{
if ($first_time eq "yes")
{
if ($FORM{'alogin'} ne "yes") # keep logged in?
{
print "Set-Cookie:$cooknamelocal=$password\n";
}
else
{
print "Set-Cookie:$cooknamelocal=$password;expires=$expdate\n";
}
&content;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=control_panel&vat=$varurl"> </head>
<body bgcolor=#ffffff></body> </html>
~;
exit;
}
}
else
{
&enter_password;
exit;
}
}
$okay = "yes";
}
sub oops
{
&content;
$message = $_[0];
print "Can't open $message ";
exit;
}
sub set_counter
{
open(MAIN_GUESTBOOK,"$powerbook_data_name");
@main_data = <MAIN_GUESTBOOK>;
my $max = 0;
foreach $row (@main_data)
{
@fields = split (/\|/, $row);
if ($fields[0] > $max)
{
$max = $fields[0];
}
} # end for each
close(MAIN_GUESTBOOK);
$max++;
$max = 2000102 if ($max < 2000101);

open (NUMBER,">$counter_name");
print NUMBER "$max";
close(NUMBER);
$plus = $max;

}

sub mrtime {

unlink ("$htmlssi");
&content;
print "done";
exit;

}


sub restore_defaults
{
&seek_cook;
&copy_file($prefs_backup_name, $prefs_name );
open(FILE,"$prefs_name");
@preflines = <FILE>;
close(FILE);
&copy_file($user_default_html_name, $user_html_name );
&copy_file($user_default_html_footer_name, $user_html_footer_name );
open(FILE,">$prefs_name");
foreach $prefline(@preflines){
  @prefvalues = split(/=/, $prefline);
  if ($prefvalues[0] eq "lic"){
    print FILE "lic=$lic=\n";
  }
  else {
        print FILE "$prefline";
  }
}
close(FILE);
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_prefs&vat=$varurl"> ~;
&main_headerb;
print qq~
<center>
~;
&inter_footer;
}
sub restore_language_defaults
{
&seek_cook;
&copy_file($langprefs_backup_name, $langprefs_name );
&copy_file($months_bak_name, $months_name );
&copy_file($days_bak_name, $days_name );
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_langprefs&vat=$varurl"> ~;
&main_headerb;
print qq~ <center>~;
&inter_footer;
}
sub check_new_files
{
unless (-e "$counter_name")
{
&content;
print "The file $counter_name does not exist" ;
exit;
}
unless (-e "$powerbook_data_name")
{
&content;
print "The file $powerbook_data_name does not exist" ;
exit;
}
unless (-e "$prefs_name")
{
&content;
print "The file $prefs_name does not exist" ;
exit;
}
unless (-r "$counter_name")
{
&content;
print "The file $counter_name does can not be read." ;
exit;
}
unless (-r "$powerbook_data_name")
{
&content;
print "The file $powerbook_data_name can not be read." ;
exit;
}
unless (-r "$prefs_name")
{
&content;
print "The file $prefs_name can not be read." ;
exit;
}
unless (-w "$counter_name")
{
&content;
print "The file $counter_name can not be written to." ;
exit;
}
unless (-w "$powerbook_data_name")
{
&content;
print "The file $powerbook_data_name can not be written to." ;
exit;
}
unless (-w "$prefs_name")
{
&content;
print "The file $prefs_name can not be written to." ;
exit;
}
}
sub view_langprefs
{
&seek_cook;

   if ($mastermanagemessagesonly eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>Access to this section is currently restricted.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
   }
 if ($masterlang eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>These settings are currently controlled by the Master Control Panel.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
}


&content;
print qq~
<center>
<html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title>Active PowerBook $cptext Language Preferences Manager</title></head>
<body bgcolor=#ffffff>
<table cellpadding = 1 cellspacing = 0 width=600><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $cptext Language Preferences Manager</b></td></tr>
<tr><td width=100% align=center>
$cgifont ~;
&linkjump;
print qq~ -
<a href="$guesturl?book=$book&action=restore_language_defaults&vat=$varurl">Restore defaults</a>
</td></tr></form>
<form action="$guesturl" METHOD="POST" >
<INPUT TYPE="hidden" NAME="action" VALUE="edit_langprefs"> <input type=hidden name="book" value="$book">

<tr><td colspan=1 align=center><font face=Arial size=2 color=black><b>Main language</b>
<select name="TXT_main_language"  onchange="this.form.submit();"> <option value="iso-8859-1">Select</option>
<option value="iso-8859-1">English (iso-8859-1)</option>
<option value="big-5">Chinese (big-5)</option>
<option value="gb2312">Chinese (gb2312)</option>
<option value="iso-8859-1">Danish (iso-8859-1)</option>
<option value="iso-8859-1">Dutch (iso-8859-1)</option>
<option value="iso-8859-1">Finnish (iso-8859-1)</option>
<option value="iso-8859-1">French (iso-8859-1)</option>
<option value="iso-8859-1">German 1 (iso-8859-1)</option>
<option value="iso-8859-1">German 2 (iso-8859-1)</option>
<option value="windows-1253">Greek (windows-1253)</option>
<option value="iso-8859-1">Indonesian (iso-8859-1)</option>
<option value="iso-8859-1">Italian (iso-8859-1)</option>
<option value="iso-8859-1">Norwegian (bokmål) (iso-8859-1)</option>
<option value="iso-8859-1">Norwegian (nynorsk) (iso-8859-1)</option>
<option value="iso-8859-1">Portugese (Brazil) (iso-8859-1)</option>
<option value="koi8-r">Russian (koi8-r)</option>
<option value="windows-1251">Russian (windows-1251)</option>
<option value="iso-8859-1">Spanish (iso-8859-1)</option>
<option value="iso-8859-1">Swedish (iso-8859-1)</option>
<option value="windows-1251">Ukrainian (windows-1251)</option>

</select> (currently $TXT_main_language)</td></tr>
<tr><td colspan=1 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Search box on search page</b></td></tr>
<tr><td colspan=1> $cgifont
<input type="text" name="TXT_you_can_search_this_guestbook_by" size="40" value="$TXT_you_can_search_this_guestbook_by">
<br>

<b><input type="text" name="TXT_searchtext" size="40" value="$TXT_searchtext"></b><br>
<input type="text" name="TXT_searchall" size="20" value="$TXT_searchall"> <--the "All" option on the search page
<br><input type="text" name="TXT_searchsearch" size="20" value="$TXT_searchsearch"> <--the text you want to appear in the Search button
</td></tr>

<tr><td colspan=1 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Add a message page</b></td></tr>
<tr><td colspan=1> $cgifont
<input type="text" name="TXT_required" size="40" value="$TXT_required"><-- Required field
<br>
<input type="text" name="TXT_continue" size="20" value="$TXT_continue"> <--the text you want to appear in the Continue button
<br>
<input type="text" name="TXT_please_fill_in" size="20" value="$TXT_please_fill_in"> <--the text you want to appear when "required" fields are not entered
</td></tr>
<tr><td colspan=1 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Guest login page</b></td></tr>
<tr><td colspan=1> $cgifont
<input type="text" name="TXT_user_email_required" size="40" value="$TXT_user_email_required"><-- User email required
<br>
<input type="text" name="TXT_user_password_required" size="40" value="$TXT_user_password_required"><-- User password required
</td></tr>

<tr><td colspan=1 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Message confirmation screen</b></td></tr>
<tr><td colspan=1> $cgifont
<input type="text" name="TXT_has_been_added" size="45" value="$TXT_has_been_added"> <-- Unmoderated thank you message
<br>
<input type="text" name="TXT_has_been_added_moderated" size="45" value="$TXT_has_been_added_moderated"> <-- Moderated thank you message
<br>
<input type="text" name="TXT_has_been_added_private" size="45" value="$TXT_has_been_added_private"> <-- Private thank you message
</td></tr>
<tr><td colspan=1 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Search results screen</b></td></tr>
<tr><td colspan=1> $cgifont
<input type="text" name="TXT_no_match" size="40" value="$TXT_no_match"> <-- "No results" message
<br>
<input type="text" name="TXT_one_match" size="40" value="$TXT_one_match"> <-- "One result" message
<br>
<input type="text" name="TXT_more_matches_1" size="10" value="$TXT_more_matches_1"> 23 <input type="text" name="TXT_more_matches_2" size="30" value="$TXT_more_matches_2"><-- "Multiple results" message
</td></tr>  ~;

  $TXT_type_letters_only = "Enter the underlined numbers:" if $TXT_type_letters_only eq "";
  $TXT_code_not_correct = "Code not correct" if $TXT_code_not_correct eq "";

 print qq~
<tr><td colspan=1 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Anti spam messages</b></td></tr>
<tr><td colspan=1> $cgifont
<input type="text" name="TXT_type_letters_only" size="40" value="$TXT_type_letters_only"> <-- Select the underlined numbers
<br>
<input type="text" name="TXT_code_not_correct" size="40" value="$TXT_code_not_correct"> <-- Wrong numbers selected

<br>
</td></tr>



<tr><td colspan=1 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Email address error messages</b></td></tr>
<tr><td colspan=1> $cgifont
<input type="text" name="TXT_no_dot_at_start" size="70" value="$TXT_no_dot_at_start">
<br>
<input type="text" name="TXT_no_www_at_start" size="70" value="$TXT_no_www_at_start">
<br>
<input type="text" name="TXT_no_squiggles_in_domain" size="70" value="$TXT_no_squiggles_in_domain">
<br>
<input type="text" name="TXT_only_one_at" size="70" value="$TXT_only_one_at">
<br>
<input type="text" name="TXT_no_dots_next" size="70" value="$TXT_no_dots_next">
<br>
<input type="text" name="TXT_wrong_end" size="70" value="$TXT_wrong_end">
<br>
<input type="text" name="TXT_please_go_back_and_edit" size="70" value="$TXT_please_go_back_and_edit">
<br>
</td></tr>
<tr><td colspan=1 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Other messages</b></td></tr>
<tr><td colspan=1> $cgifont
<input type="text" name="TXT_back" size="40" value="$TXT_back"><-- Back
<br>
<input type="text" name="TXT_too_many_words" size="40" value="$TXT_too_many_words"><-- Message is too long
<br>
<input type="text" name="TXT_disallowed_word" size="40" value="$TXT_disallowed_word"><-- Disallowed word
<br>
<input type="text" name="TXT_blocked_IP" size="40" value="$TXT_blocked_IP"><-- Blocked IP address
<br>
<input type="text" name="TXT_file_too_large" size="40" value="$TXT_file_too_large"><-- File is too big
<br>
<input type="text" name="TXT_file_no_space" size="40" value="$TXT_file_no_space"><-- No more space available
<br>
<input type="text" name="TXT_no_double_dot" size="40" value="$TXT_no_double_dot"><-- No double dot in file name
<br>
<input type="text" name="TXT_no_leading_dot" size="40" value="$TXT_no_leading_dot"><-- No leading dot in file name
<br>
<input type="text" name="TXT_filename_too_long" size="40" value="$TXT_filename_too_long"><-- Filename is too long
<br>
<input type="text" name="TXT_filename_bad" size="40" value="$TXT_filename_bad"><-- Bad filename
<br>
<input type="text" name="TXT_that_file_not_allowed" size="40" value="$TXT_that_file_not_allowed"><-- File type not allowed
</td></tr>
<tr><td colspan=1 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Days</b></td></tr>
<tr><td colspan=1><center> $cgifont
<textarea name="day_names" rows="7" cols="15">~;
foreach $monthss (@daylist)
{
if ($monthss =~ /[a-zA-Z0-9]/)
{
print "$monthss\n";
}
}
print qq~</textarea>
</td></tr>
<tr><td colspan=1 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Months</b></td></tr>
<tr><td colspan=1><center> $cgifont
<textarea name="month_names" rows="12" cols="15">~;
foreach $monthss (@monthlist)
{
if ($monthss =~ /[a-zA-Z0-9]/)
{
print "$monthss\n";
}
}
print qq~</textarea>
</td></tr></table> </td></tr></table> </td></tr></table> <input type="submit" value="Update Language Preferences">
</form>
~;
}
sub view_colprefs
{
&seek_cook;
 if ($mastermanagemessagesonly eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>Access to this section is currently restricted.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
   }
if ($mastercol eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>These settings are currently controlled by the Master Control Panel.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
}

$ignore = $FORM{'ignore'};
unless ($ignore eq "yes") # only backup when you first enter view_colprefs
{
&copy_file($colprefs_name, $tempcolprefs_name );
}
&content;
print qq~
<center>
<html><head><title>Active PowerBook $cptext Color/Images Manager</title></head>
<body bgcolor=#ffffff>
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $cptext Color Preferences Manager</b></td></tr>
<tr><td width=100% align=center>
$cgifont ~;
&linkjump;
print qq~ <br>
<a href="$guesturl?book=$book&action=restore_coldefaults&vat=$varurl">Restore FACTORY defaults</a> | <a href="$guesturl?book=$book&action=restore_user_color_defaults&vat=$varurl">Restore USER defaults</a><br>
<a href="$guesturl?book=$book&action=cancel_color_change&vat=$varurl">Cancel all changes made during this visit</a> | <a href="$guesturl?book=$book&action=save_user_color_defaults&vat=$varurl">Save as USER color defaults</a>
</td></tr> </form>
<form action="$guesturl" METHOD="POST" >

<tr><td colspan=1 align=center bgcolor=$titlebak>
<font face=Arial size=2 color=white><b>Transparency settings</b></td></tr>
<tr><td colspan=1><center> $cgifont
<b>PLEASE NOTE:</B> Setting an item to transparent will override the colors/images selected below.
</td></tr>
<tr><td colspan=1 align=center>
<table border=0 cellspacing=0 cellpadding=0>
<tr><td>
$cgifont
Transparent message box header: </td><td>$cgifont ~;
$transheadn = ""; $transheady = "";
if ($trans_message_header eq "yes"){$transheady = "checked"; } else {$transheadn = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="trans_message_header" VALUE="yes" $transheady> -
No<INPUT TYPE="radio" NAME="trans_message_header" VALUE="no" $transheadn> ~;
print qq~
</td></tr><tr><td> $cgifont
Transparent message box body: </td><td>$cgifont ~;
$transbodyn = ""; $transbodyy = "";
if ($trans_message_body ne "yes"){$transbodyn = "checked"; } else {$transbodyy = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="trans_message_body" VALUE="yes" $transbodyy> -
No<INPUT TYPE="radio" NAME="trans_message_body" VALUE="no" $transbodyn> ~;
print qq~
</td></tr>

<tr><td> $cgifont
Transparent Add/Respond/Search/Login page box background: </td><td>$cgifont ~;
$transaddn = ""; $transaddy = "";
if ($trans_add ne "yes"){$transaddn = "checked"; } else {$transaddy = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="trans_add" VALUE="yes" $transaddy> -
No<INPUT TYPE="radio" NAME="trans_add" VALUE="no" $transaddn> ~;
print qq~ </td></tr>
</table>
</td></tr>
</table></td></tr></table></td></tr></table>
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
<tr><td colspan=5 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Header 1</b></td></tr>
<!-- row 1 start -->
~;
$tsbty = $tsy = $tmby = $tmhy = "";
my $statement = "[Currently transparent]";
$tmby = $statement if ($trans_message_body eq "yes");
$tmhy = $statement if ($trans_message_header eq "yes");
$tsy = $statement if ($trans_add eq "yes");

############################ START OF HEADER 1
print qq~
<tr valign=top><td> $cgifont Background</td>
<td colspan=3><SELECT name="optiondata_color1" onChange="forms[1].data_color1.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
$arlink = $data_color1; $arlink =~ s/\#//;
$arlinkcom = ($COLARRARY{$arlink});
$arlinkcom = "User defined" if (!exists $COLARRARY{$arlink});
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="data_color1" VALUE="$data_color1" SIZE=7 MAXLENGTH=7>$cgifont ($arlinkcom)</td>
<td rowspan=4 valign=middle ~;
if ($trans_message_header ne "yes")
{
print qq~ bgcolor = $data_color1 ~;
print "background = \"$backgroundimageh1\"" if ($usebackgroundimageh1 eq "yes");
}
else
{
print qq~ bgcolor = "$backcolor" ~;
print "background = \"$backgroundimage\"" if ($usebackgroundimage eq "yes");
}
print qq~ >
<font color="$textdata_color1" face="Arial" size=2><DIV align="center"><B>Header 1<br>$tmhy</B></DIV>
</td>
</tr>
<tr valign=top><td> $cgifont Use background image</td>
<td colspan=3> $cgifont ~;
$backgroundimageh1 =~ s/http\:\/\///gi;
my $usebackgroundimagen = ""; my $usebackgroundimagey = "";
if ($usebackgroundimageh1 ne "yes"){$usebackgroundimagen = "checked"; } else {$usebackgroundimagey = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="usebackgroundimageh1" VALUE="yes" $usebackgroundimagey> -
No<INPUT TYPE="radio" NAME="usebackgroundimageh1" VALUE="no" $usebackgroundimagen>
</td></tr>
<tr valign=top><td> $cgifont Image address</td>
<td colspan=3> $cgifont http://<input type=text size=40 name="backgroundimageh1" value="$backgroundimageh1">
</td></tr>
<tr valign=top><td> $cgifont Text</td>
<td colspan=3><SELECT name="optiontextdata_color1" onChange="forms[1].textdata_color1.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
$arlink = $textdata_color1; $arlink =~ s/\#//;
$arlinkcom = ($COLARRARY{$arlink});
$arlinkcom = "User defined" if (!exists $COLARRARY{$arlink});
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="textdata_color1" VALUE="$textdata_color1" SIZE=7 MAXLENGTH=7>$cgifont ($arlinkcom)</td>
</tr>
~;
##################################### END OF HEADER 1
############################ START OF MESSAGE 1
print qq~
<tr><td colspan=5 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Body 1</b></td></tr>
<tr valign=top><td> $cgifont Background</td>
<td colspan=3><SELECT name="optiontable_color1" onChange="forms[1].table_color1.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
$arlink = $table_color1; $arlink =~ s/\#//;
$arlinkcom = ($COLARRARY{$arlink});
$arlinkcom = "User defined" if (!exists $COLARRARY{$arlink});
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="table_color1" VALUE="$table_color1" SIZE=7 MAXLENGTH=7>$cgifont ($arlinkcom)</td>
<td rowspan=4 valign=middle ~;
if ($trans_message_body ne "yes")
{
print qq~ bgcolor = $table_color1 ~;
print "background = \"$backgroundimageb1\"" if ($usebackgroundimageb1 eq "yes");
}
else
{
print qq~ bgcolor = "$backcolor" ~;
print "background = \"$backgroundimage\"" if ($usebackgroundimage eq "yes");
}
print qq~ >
<font color="$texttable_color1" face="Arial" size=2><DIV align="center"><B>Body 1<br>$tmby</B></DIV>
</td>
</tr>
<tr valign=top><td> $cgifont Use background image</td>
<td colspan=3> $cgifont ~;
$backgroundimageb1 =~ s/http\:\/\///gi;
my $usebackgroundimagen = ""; my $usebackgroundimagey = "";
if ($usebackgroundimageb1 ne "yes"){$usebackgroundimagen = "checked"; } else {$usebackgroundimagey = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="usebackgroundimageb1" VALUE="yes" $usebackgroundimagey> -
No<INPUT TYPE="radio" NAME="usebackgroundimageb1" VALUE="no" $usebackgroundimagen>
</td></tr>
<tr valign=top><td> $cgifont Image address</td>
<td colspan=3> $cgifont http://<input type=text size=40 name="backgroundimageb1" value="$backgroundimageb1">
</td></tr>
<tr valign=top><td> $cgifont Text</td>
<td colspan=3><SELECT name="optiontexttable_color1" onChange="forms[1].texttable_color1.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
$arlink = $texttable_color1; $arlink =~ s/\#//;
$arlinkcom = ($COLARRARY{$arlink});
$arlinkcom = "User defined" if (!exists $COLARRARY{$arlink});
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="texttable_color1" VALUE="$texttable_color1" SIZE=7 MAXLENGTH=7>$cgifont ($arlinkcom)</td>
</tr>
~;
##################################### END OF MESSAGE 1
################# NEXT
############################ START OF HEADER 2
print qq~
<tr><td colspan=5 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Header 2</b></td></tr>
<tr valign=top><td> $cgifont Background</td>
<td colspan=3><SELECT name="optiondata_color2" onChange="forms[1].data_color2.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
$arlink = $data_color2; $arlink =~ s/\#//;
$arlinkcom = ($COLARRARY{$arlink});
$arlinkcom = "User defined" if (!exists $COLARRARY{$arlink});
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="data_color2" VALUE="$data_color2" SIZE=7 MAXLENGTH=7>$cgifont ($arlinkcom)</td>
<td rowspan=4 valign=middle ~;
if ($trans_message_header ne "yes")
{
print qq~ bgcolor = $data_color2 ~;
print "background = \"$backgroundimageh2\"" if ($usebackgroundimageh2 eq "yes");
}
else
{
print qq~ bgcolor = "$backcolor" ~;
print "background = \"$backgroundimage\"" if ($usebackgroundimage eq "yes");
}
print qq~ >
<font color="$textdata_color2" face="Arial" size=2><DIV align="center"><B>Header 2<br>$tmhy</B></DIV>
</td>
</tr>
<tr valign=top><td> $cgifont Use background image</td>
<td colspan=3> $cgifont ~;
$backgroundimageh2 =~ s/http\:\/\///gi;
my $usebackgroundimagen = ""; my $usebackgroundimagey = "";
if ($usebackgroundimageh2 ne "yes"){$usebackgroundimagen = "checked"; } else {$usebackgroundimagey = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="usebackgroundimageh2" VALUE="yes" $usebackgroundimagey> -
No<INPUT TYPE="radio" NAME="usebackgroundimageh2" VALUE="no" $usebackgroundimagen>
</td></tr>
<tr valign=top><td> $cgifont Image address</td>
<td colspan=3> $cgifont http://<input type=text size=40 name="backgroundimageh2" value="$backgroundimageh2">
</td></tr>
<tr valign=top><td> $cgifont Text</td>
<td colspan=3><SELECT name="optiontextdata_color2" onChange="forms[1].textdata_color2.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
$arlink = $textdata_color2; $arlink =~ s/\#//;
$arlinkcom = ($COLARRARY{$arlink});
$arlinkcom = "User defined" if (!exists $COLARRARY{$arlink});
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="textdata_color2" VALUE="$textdata_color2" SIZE=7 MAXLENGTH=7>$cgifont ($arlinkcom)</td>
</tr>
~;
##################################### END OF HEADER 2
############################ START OF MESSAGE 2
print qq~
<tr><td colspan=5 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Body 2</b></td></tr>
<tr valign=top><td> $cgifont Background</td>
<td colspan=3><SELECT name="optiontable_color2" onChange="forms[1].table_color2.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
$arlink = $table_color2; $arlink =~ s/\#//;
$arlinkcom = ($COLARRARY{$arlink});
$arlinkcom = "User defined" if (!exists $COLARRARY{$arlink});
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="table_color2" VALUE="$table_color2" SIZE=7 MAXLENGTH=7>$cgifont ($arlinkcom)</td>
<td rowspan=4 valign=middle ~;
if ($trans_message_body ne "yes")
{
print qq~ bgcolor = $table_color2 ~;
print "background = \"$backgroundimageb2\"" if ($usebackgroundimageb2 eq "yes");
}
else
{
print qq~ bgcolor = "$backcolor" ~;
print "background = \"$backgroundimage\"" if ($usebackgroundimage eq "yes");
}
print qq~ >
<font color="$texttable_color2" face="Arial" size=2><DIV align="center"><B>Body 2<br>$tmby</B></DIV>
</td>
</tr>
<tr valign=top><td> $cgifont Use background image</td>
<td colspan=3> $cgifont ~;
$backgroundimageb2 =~ s/http\:\/\///gi;
my $usebackgroundimagen = ""; my $usebackgroundimagey = "";
if ($usebackgroundimageb2 ne "yes"){$usebackgroundimagen = "checked"; } else {$usebackgroundimagey = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="usebackgroundimageb2" VALUE="yes" $usebackgroundimagey> -
No<INPUT TYPE="radio" NAME="usebackgroundimageb2" VALUE="no" $usebackgroundimagen>
</td></tr>
<tr valign=top><td> $cgifont Image address</td>
<td colspan=3> $cgifont http://<input type=text size=40 name="backgroundimageb2" value="$backgroundimageb2">
</td></tr>
<tr valign=top><td> $cgifont Text</td>
<td colspan=3><SELECT name="optiontexttable_color2" onChange="forms[1].texttable_color2.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
$arlink = $texttable_color2; $arlink =~ s/\#//;
$arlinkcom = ($COLARRARY{$arlink});
$arlinkcom = "User defined" if (!exists $COLARRARY{$arlink});
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="texttable_color2" VALUE="$texttable_color2" SIZE=7 MAXLENGTH=7>$cgifont ($arlinkcom)</td>
</tr>
~;
##################################### END OF MESSAGE 2
############################ START OF MAIN BACKGROUND/TEXT
print qq~
<tr><td colspan=5 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Main page</b></td></tr>
<tr valign=top><td> $cgifont Background</td>
<td colspan=3><SELECT name="optionbackcolor" onChange="forms[1].backcolor.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
$arlink = $backcolor; $arlink =~ s/\#//;
$arlinkcom = ($COLARRARY{$arlink});
$arlinkcom = "User defined" if (!exists $COLARRARY{$arlink});
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="backcolor" VALUE="$backcolor" SIZE="7" MAXLENGTH="7">$cgifont ($arlinkcom)</td>
<td rowspan="4" valign="middle" bgcolor = "$backcolor" ~;
print "background = \"$backgroundimage\"" if ($usebackgroundimage eq "yes");
print qq~ >
<font color="$text" face="Arial" size=2><DIV align="center"><B>Default text</B></DIV>
</td>
</tr>
<tr valign=top><td> $cgifont Use background image</td>
<td colspan=3> $cgifont ~;
$backgroundimagebak = $backgroundimage;
$backgroundimage =~ s/http\:\/\///gi;
my $usebackgroundimagen = ""; my $usebackgroundimagey = "";
if ($usebackgroundimage ne "yes"){$usebackgroundimagen = "checked"; } else {$usebackgroundimagey = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="usebackgroundimage" VALUE="yes" $usebackgroundimagey> - No<INPUT TYPE="radio" NAME="usebackgroundimage" VALUE="no" $usebackgroundimagen>
</td></tr>
<tr valign=top><td> $cgifont Image address</td>
<td colspan=3> $cgifont http://<input type=text size=40 name="backgroundimage" value="$backgroundimage">
</td></tr>
<tr valign=top><td> $cgifont Default text</td>
<td colspan=3><SELECT name="optiontext" onChange="forms[1].text.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
$arlink = $text; $arlink =~ s/\#//;
$arlinkcom = ($COLARRARY{$arlink});
$arlinkcom = "User defined" if (!exists $COLARRARY{$arlink});
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="text" VALUE="$text" SIZE=7 MAXLENGTH=7>$cgifont ($arlinkcom)</td>
</tr>
~;
##################################### END OF MAIN BACKGROUND/TEXT
##################################### START ADDPAGE
$backgroundimage = $backgroundimagebak;
print qq~
<tr><td colspan=5 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Add/Respond/Search/Login page box</b></td></tr>
<tr valign=top><td > $cgifont Background</font></td>
<td colspan=3><SELECT name="optionaddcolor" onChange="forms[1].addcolor.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
$arlink = $addcolor; $arlink =~ s/\#//;
$arlinkcom = ($COLARRARY{$arlink});
$arlinkcom = "User defined" if (!exists $COLARRARY{$arlink});
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="addcolor" VALUE="$addcolor" SIZE=7 MAXLENGTH=7>$cgifont ($arlinkcom)</td>
<td rowspan="4" valign="middle" ~;
if ($trans_add ne "yes"){
print qq~ bgcolor = $addcolor ~;
print "background = \"$backgroundimageadd\"" if ($usebackgroundimageadd eq "yes");
}
else { print qq~ bgcolor = "$backcolor" ~;
print "background = \"$backgroundimage\"" if ($usebackgroundimage eq "yes");
}
print qq~ >
<font color="$addtext" face="Arial" size=2><DIV align="center"><B>Add/Respond page box text<br>$tsy</B></DIV>
</td>
</tr>
<tr valign=top><td> $cgifont Use background image</td>
<td colspan=3> $cgifont ~;
$backgroundimageadd =~ s/http\:\/\///gi;
my $usebackgroundimageaddn = ""; my $usebackgroundimageaddy = "";
if ($usebackgroundimageadd ne "yes"){$usebackgroundimageaddn = "checked"; } else {$usebackgroundimageaddy = "checked"; }
print qq~
Yes<INPUT TYPE="radio" NAME="usebackgroundimageadd" VALUE="yes" $usebackgroundimageaddy> -
No<INPUT TYPE="radio" NAME="usebackgroundimageadd" VALUE="no" $usebackgroundimageaddn>
</td></tr>
<tr valign=top><td> $cgifont Image address</td>
<td colspan=3> $cgifont http://<input type=text size=40 name="backgroundimageadd" value="$backgroundimageadd">
</td></tr>
<tr valign=top><td> $cgifont Text</td>
<td colspan=3><SELECT name="optionaddtext" onChange="forms[1].addtext.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
$arlink = $addtext; $arlink =~ s/\#//;
$arlinkcom = ($COLARRARY{$arlink});
$arlinkcom = "User defined" if (!exists $COLARRARY{$arlink});
$backgroundimage = $backgroundimagebak;
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="addtext" VALUE="$addtext" SIZE=7 MAXLENGTH=7>$cgifont ($arlinkcom)</td></tr>~;
################### START LINKS
print qq~ <tr><td colspan=5 align=center bgcolor=$titlebak><font face=Arial size=2 color=white><b>Default links</b></td></tr>
<tr valign=top><td> $cgifont Link color</font></td>
<td colspan=3><SELECT name="optionlink" onChange="forms[1].link.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
$arlink = $link; $arlink =~ s/\#//;
$arlinkcom = ($COLARRARY{$arlink});
$arlinkcom = "User defined" if (!exists $COLARRARY{$arlink});
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="link" VALUE="$link" SIZE=7 MAXLENGTH=7>$cgifont ($arlinkcom)</td>
<td rowspan="1" valign="middle" bgcolor = "$backcolor" ~;
print "background = \"$backgroundimage\"" if ($usebackgroundimage eq "yes");
print qq~ >
<font color="$link" face="Arial" size=2><DIV align="center"><B>Link</B></DIV>
</td>
</tr>
~;
print qq~
<tr valign=top><td> $cgifont Visited link color</font></td>
<td colspan=3><SELECT name="optionvlink" onChange="forms[1].vlink.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
$arlink = $vlink; $arlink =~ s/\#//;
$arlinkcom = ($COLARRARY{$arlink});
$arlinkcom = "User defined" if (!exists $COLARRARY{$arlink});
print qq~ </SELECT> <INPUT TYPE="TEXT" NAME="vlink" VALUE="$vlink" SIZE=7 MAXLENGTH=7>$cgifont ($arlinkcom)</td>
<td rowspan="1" valign="middle" bgcolor = "$backcolor" ~;
print "background = \"$backgroundimage\"" if ($usebackgroundimage eq "yes");
print qq~ >
<font color="$vlink" face="Arial" size=2><DIV align="center"><B>Visited link</B></DIV>
</td>
</tr>
~;
print qq~ <tr valign=top><td> $cgifont Active link color</font></td>
<td colspan=3><SELECT name="optionalink" onChange="forms[1].alink.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
$arlink = $alink; $arlink =~ s/\#//;
$arlinkcom = ($COLARRARY{$arlink});
$arlinkcom = "User defined" if (!exists $COLARRARY{$arlink});
print qq~ </SELECT> <INPUT TYPE="TEXT" NAME="alink" VALUE="$alink" SIZE=7 MAXLENGTH=7>$cgifont ($arlinkcom)</td>
<td rowspan="1" valign="middle" bgcolor = "$backcolor" ~;
print "background = \"$backgroundimage\"" if ($usebackgroundimage eq "yes");
print qq~ >
<font color="$alink" face="Arial" size=2><DIV align="center"><B>Active link</B></DIV>
</td>
</tr>
~;
print qq~ </table></td></tr></table></td></tr></table> <input type=hidden name="book" value="$book">
<INPUT TYPE="hidden" NAME="action" VALUE="edit_colprefs"> <INPUT TYPE="submit" VALUE="Update preferences"></form> ~;
}
sub update_ip_addresses
{
if ($ip_addresses eq $cookie_default)
{
open(USER_FILE,">$powerbook_data_name");
close(USER_FILE);
}
}
sub check_values
{

$text11 = "/gmirewop/ten.stpircs-evitca//:ptth\"=crs gmi<>\"lmth.1knilkoobrewop/ten.stpircs-evitca//:ptth\"=ferh a<";
$text12 = ">a/<>0=redrob \"fig.";
@itemss = split (//, $text11) ;
$reverse11 = join ("", reverse @itemss);
@itemsss = split (//, $text12) ;
$reverse12 = join ("", reverse @itemsss);
$reverse1 = "$reverse11"."$version"."$reverse12";
$text11 = "/gmirewop/ten.stpircs-evitca//:ptth\"=crs gmi<>\"lmth.2knilkoobrewop/ten.stpircs-evitca//:ptth\"=ferh a<";
$text12 = ">a/<>0=redrob \"fig.";
@itemss = split (//, $text11) ;
$reverse11 = join ("", reverse @itemss);
@itemsss = split (//, $text12) ;
$reverse12 = join ("", reverse @itemsss);
$reverse2 = "$reverse11"."$version2"."$reverse12";
}
sub edit_colprefs
{
&seek_cook;
## TEMPCOLFILE now has the last saved preferences
open(COLFILE,">$colprefs_name");
print COLFILE "trans_add=$FORM{'trans_add'}=\n";
print COLFILE "trans_message_header=$FORM{'trans_message_header'}=\n";
print COLFILE "trans_message_body=$FORM{'trans_message_body'}=\n";
print COLFILE "data_color1=$FORM{'data_color1'}=\n";
print COLFILE "data_color2=$FORM{'data_color2'}=\n";
print COLFILE "textdata_color1=$FORM{'textdata_color1'}=\n";
print COLFILE "textdata_color2=$FORM{'textdata_color2'}=\n";
print COLFILE "table_color1=$FORM{'table_color1'}=\n";
print COLFILE "table_color2=$FORM{'table_color2'}=\n";
print COLFILE "texttable_color1=$FORM{'texttable_color1'}=\n";
print COLFILE "texttable_color2=$FORM{'texttable_color2'}=\n";
print COLFILE "backcolor=$FORM{'backcolor'}=\n";
print COLFILE "usebackgroundimage=$FORM{'usebackgroundimage'}=\n";
print COLFILE "backgroundimage=$FORM{'backgroundimage'}=\n";
print COLFILE "usebackgroundimageh1=$FORM{'usebackgroundimageh1'}=\n";
print COLFILE "backgroundimageh1=$FORM{'backgroundimageh1'}=\n";
print COLFILE "usebackgroundimageh2=$FORM{'usebackgroundimageh2'}=\n";
print COLFILE "backgroundimageh2=$FORM{'backgroundimageh2'}=\n";
print COLFILE "searchtext=$FORM{'searchtext'}=\n";
print COLFILE "backgroundimagesearch=$FORM{'backgroundimagesearch'}=\n";
print COLFILE "usebackgroundimagesearch=$FORM{'usebackgroundimagesearch'}=\n";
print COLFILE "searchcolor=$FORM{'searchcolor'}=\n";
print COLFILE "addcolor=$FORM{'addcolor'}=\n";
print COLFILE "addtext=$FORM{'addtext'}=\n";
print COLFILE "backgroundimageadd=$FORM{'backgroundimageadd'}=\n";
print COLFILE "usebackgroundimageadd=$FORM{'usebackgroundimageadd'}=\n";
print COLFILE "addcolor=$FORM{'addcolor'}=\n";
print COLFILE "usebackgroundimageb1=$FORM{'usebackgroundimageb1'}=\n";
print COLFILE "backgroundimageb1=$FORM{'backgroundimageb1'}=\n";
print COLFILE "usebackgroundimageb2=$FORM{'usebackgroundimageb2'}=\n";
print COLFILE "backgroundimageb2=$FORM{'backgroundimageb2'}=\n";
print COLFILE "link=$FORM{'link'}=\n";
print COLFILE "vlink=$FORM{'vlink'}=\n";
print COLFILE "alink=$FORM{'alink'}=\n";
print COLFILE "text=$FORM{'text'}=\n";
close(COLFILE);
&content;
print qq~<HTML><head><title>$title</title></head>
<META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_colprefs&ignore=yes&vat=$varurl">
</head><body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600"> ~;
}
#################
sub edit_langprefs
{
&seek_cook;
open(PREFS,">$langprefs_name");
print PREFS "TXT_that_file_not_allowed=$FORM{'TXT_that_file_not_allowed'}=\n";
print PREFS "TXT_filename_bad=$FORM{'TXT_filename_bad'}=\n";
print PREFS "TXT_no_double_dot=$FORM{'TXT_no_double_dot'}=\n";
print PREFS "TXT_no_leading_dot=$FORM{'TXT_no_leading_dot'}=\n";
print PREFS "TXT_filename_too_long=$FORM{'TXT_filename_too_long'}=\n";
print PREFS "TXT_searchall=$FORM{'TXT_searchall'}=\n";
print PREFS "TXT_main_language=$FORM{'TXT_main_language'}=\n";
print PREFS "TXT_file_no_space=$FORM{'TXT_file_no_space'}=\n";
print PREFS "TXT_file_too_large=$FORM{'TXT_file_too_large'}=\n";
print PREFS "TXT_user_password_required=$FORM{'TXT_user_password_required'}=\n";
print PREFS "TXT_user_email_required=$FORM{'TXT_user_email_required'}=\n";
print PREFS "TXT_there_is_now=$FORM{'TXT_there_is_now'}=\n";
print PREFS "TXT_there_are_now=$FORM{'TXT_there_are_now'}=\n";
print PREFS "TXT_messages_in_our_guestbook=$FORM{'TXT_messages_in_our_guestbook'}=\n";
print PREFS "TXT_message_in_our_guestbook=$FORM{'TXT_message_in_our_guestbook'}=\n";
print PREFS "TXT_you_can_search_this_guestbook_by=$FORM{'TXT_you_can_search_this_guestbook_by'}=\n";
print PREFS "TXT_searchsearch=$FORM{'TXT_searchsearch'}=\n";
print PREFS "TXT_searchtext=$FORM{'TXT_searchtext'}=\n";
print PREFS "TXT_required=$FORM{'TXT_required'}=\n";
print PREFS "TXT_private_message=$FORM{'TXT_private_message'}=\n";
print PREFS "TXT_private_message2=$FORM{'TXT_private_message2'}=\n";
print PREFS "TXT_continue=$FORM{'TXT_continue'}=\n";
print PREFS "TXT_has_been_added=$FORM{'TXT_has_been_added'}=\n";
print PREFS "TXT_has_been_added_moderated=$FORM{'TXT_has_been_added_moderated'}=\n";
print PREFS "TXT_has_been_added_private=$FORM{'TXT_has_been_added_private'}=\n";
print PREFS "TXT_one_match=$FORM{'TXT_one_match'}=\n";
print PREFS "TXT_no_match=$FORM{'TXT_no_match'}=\n";
print PREFS "TXT_back=$FORM{'TXT_back'}=\n";
print PREFS "TXT_more_matches_1=$FORM{'TXT_more_matches_1'}=\n";
print PREFS "TXT_more_matches_2=$FORM{'TXT_more_matches_2'}=\n";
print PREFS "TXT_please_fill_in=$FORM{'TXT_please_fill_in'}=\n";
print PREFS "TXT_please_go_back_and_edit=$FORM{'TXT_please_go_back_and_edit'}=\n";
print PREFS "TXT_no_dot_at_start=$FORM{'TXT_no_dot_at_start'}=\n";
print PREFS "TXT_no_www_at_start=$FORM{'TXT_no_www_at_start'}=\n";
print PREFS "TXT_code_not_correct=$FORM{'TXT_code_not_correct'}=\n";
print PREFS "TXT_type_letters_only=$FORM{'TXT_type_letters_only'}=\n";
print PREFS "TXT_no_squiggles_in_domain=$FORM{'TXT_no_squiggles_in_domain'}=\n";
print PREFS "TXT_only_one_at=$FORM{'TXT_only_one_at'}=\n";
print PREFS "TXT_no_dots_next=$FORM{'TXT_no_dots_next'}=\n";
print PREFS "TXT_wrong_end=$FORM{'TXT_wrong_end'}=\n";
print PREFS "TXT_too_many_words=$FORM{'TXT_too_many_words'}=\n";
print PREFS "TXT_disallowed_word=$FORM{'TXT_disallowed_word'}=\n";
print PREFS "TXT_blocked_IP=$FORM{'TXT_blocked_IP'}=\n";
close(PREFS);
open(USER_FILE,">$months_name");
$ertyu = $FORM{'month_names'}; $ertyu =~ s/\r//gi;
print USER_FILE "$ertyu";
close(USER_FILE);
open(USER_FILE,">$days_name");
$ertyu = $FORM{'day_names'}; $ertyu =~ s/\r//gi;
print USER_FILE "$ertyu";
close(USER_FILE);
&content;
print qq~
<HTML><head><title>$title</title></head>
<META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_langprefs&ignore=yes&vat=$varurl">
</head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600">
<B><DIV align="center"></font></DIV></B>
~;
}
sub restore_coldefaults
{
&seek_cook;
&copy_file($colprefs_backup_name, $colprefs_name );
&content;
print qq~
<HTML><head><title>$title</title>
<META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_colprefs&vat=$varurl">
</head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600">
~;
}
sub copy_file
{
($source, $destination) = @_;
open(SOURCE,"$source");
my $exist = "no" unless (-e "$destination");
open(DEST,">$destination");
print DEST <SOURCE>;
if ($exist eq "no"){
chmod(0755, "$destination");
}
close(DEST);
close(SOURCE);
}
sub restore_user_defaults
{
&seek_cook;
&copy_file($userprefs_backup_name, $prefs_name );
&copy_file($user_default_html_name, $user_html_name );
&copy_file($user_default_html_footer_name, $user_html_footer_name );
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_prefs&vat=$varurl"> ~;
&main_headerb;
print qq~
<center>
$cgifont2 <B>Active PowerBook Standard Preferences Manager</B> <p>
</font> $cgifont <a href="$guesturl?book=$book&action=view_prefs&vat=$varurl"><B>User default preferences restored.</B></a>
</font>
~;
&inter_footer;
}
sub save_user_defaults
{
&seek_cook;
&copy_file($prefs_name, $userprefs_backup_name );
&copy_file($user_html_name, $user_default_html_name );
&copy_file($user_html_footer_name, $user_default_html_footer_name );
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_prefs&vat=$varurl"> ~;
&main_headerb;
print qq~
<center>
~;
&inter_footer;
}
sub restore_user_color_defaults
{
&seek_cook;
&copy_file($usercolprefs_backup_name, $colprefs_name );
&content;
print qq~
<HTML><head><$title></title>
<META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_colprefs&vat=$varurl">
</head>
<body></html>
~;
}
sub save_user_color_defaults
{
&seek_cook;
&copy_file($colprefs_name, $usercolprefs_backup_name );
$where="view_colprefs";
&inter_header;
print qq~
<center> ~;
&inter_footer;
}
sub link_colors
{
@realcols = (Black, Maroon, Green, Olive, Navy, Purple, Teal, Gray, Silver, Red, Lime, Yellow, Blue, Fuchsia, Aqua, White);
foreach $realcols(@realcols)
{
if ($matchcol eq $realcols)
{
print "<option selected>$realcols";
}
else
{
print "<option>$realcols";
}
}
}
sub cancel_color_change
{
&seek_cook;
&copy_file($tempcolprefs_name, $colprefs_name );
$where="view_colprefs";
&inter_header;
print qq~
<B><DIV align="center"> $cgifont Restoring last saved color preferences.</font></DIV></B>
~;
&inter_footer;
}

sub view_servers {

&seek_cook;
&content;
print qq~
<center>
<html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title>Active PowerBook - Server Manager</title>

<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from non-Java browsers
function Confirmdelete() {
var Confirmation;
Confirmation = "Are you sure you want to permanently delete this PowerBook? PLEASE NOTE - ALL DATA FILES AND BACKUPS WILL BE WIPED. ANY UPLOADED FILES OR IMAGES WILL NEED TO BE REMOVED MANUALLY.";
if (confirm(Confirmation)){
return true;
}
else {
return false;
}
}

// End Java Hiding. -->
 </script>
</head>
<body bgcolor=#ffffff>
<table cellpadding = 1 cellspacing = 0 width=800><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook - Server Manager</b></td></tr>
<tr><td width=100% align=center>
$cgifont ~;
&linkjump;
print qq~  </form><hr size=1>
<form action="$guesturl" METHOD="POST" ><input type=hidden name="action" value="create_new_book">
You can create unlimited additional powerbooks and control them from this Server Manager.<br>Note that the Server Manager
is only accessible from the Master Control Panel.<p>
<b>New PowerBook Name:</b><input type=text name="new_book" size=20><br><i>(letters, numbers and underscores only, no spaces)</i><br>
<input type=submit value="Create New PowerBook"></td></tr></form>


<tr><td colspan=1 align=center bgcolor=$titlebak>
<font face=Arial size=2 color=white><b>Current Sub PowerBooks</b></td></tr>
<tr><td align=center><table border=0 width=100%> ~;

 open(SERFILE,"$server_names");
@serverdata = <SERFILE>;
close(SERFILE);
@serverdata = reverse(@serverdata);

  print qq~<form action="$guesturl" METHOD="POST" ><input type=hidden name="action" value="update_child_settings">

  <tr><td colspan=6 align=left>$cgifont <a href="$guesturl?action=view_copy_prefs&vat=$varurl"><b>Settings Copy Utility</a></b></td>


  <td colspan =9 align=center bgcolor=$titlebak>$cgifont <font color=white><b>Use settings from Master PowerBook</b></font></font></td></tr>

  <tr valign=bottom>


  <td  align=left>$cgifont <b>Name</b> </font></td>
  <td  align=center>$cgifont <b>Status</b> </font></td>
  <td  align=center>$cgifont <b>Control data only</b> </font></td>
  <td align=center>$cgifont<b>MCP link</b> </font></td>
  <td  align=center>$cgifont  </font></td>
  <td  align=center>$cgifont  </font></td>
  <td  align=center>$cgifont  </font></td>
  <td  align=center>$cgifont Color prefs </font></td>
  <td align=center>$cgifont Language prefs </font></td>
  <td align=center>$cgifont Standard prefs </font></td>
  <td align=center>$cgifont Date prefs </font></td>
  <td align=center>$cgifont Menu prefs </font></td>
  <td align=center>$cgifont Access prefs </font></td>
  <td align=center>$cgifont Fields prefs </font></td>
  <td align=center>$cgifont Layout prefs </font></td>
  <td align=center>$cgifont DATA </font></td>

  </tr>
    ~;

foreach $row (@serverdata)
{
@serverfields = split (/\|/, $row);

    $selcol = $sellang = $selpref = $seldate = $selmenu =$selaccess =
    $selfield =$sellayout = $seldata = $selcplink =  $selmanagemessagesonly ="";
    $selcola = $sellanga = $selprefa = $seldatea = $selmenua =$selaccessa =
    $selfielda =$sellayouta = $seldataa = $selcplinka =  $selmanagemessagesonlya ="no";

     $selcol = "checked" if ($serverfields[5] eq "yes");
     $sellang = "checked" if ($serverfields[6] eq "yes");
     $selpref = "checked" if ($serverfields[7] eq "yes");
     $seldate = "checked" if ($serverfields[8] eq "yes");
     $selmenu = "checked" if ($serverfields[9] eq "yes");
     $selaccess = "checked" if ($serverfields[10] eq "yes");
     $selfield = "checked" if ($serverfields[11] eq "yes");
     $sellayout = "checked" if ($serverfields[12] eq "yes");
     $seldata = "checked" if ($serverfields[13] eq "yes");
     $selcplink = "checked" if ($serverfields[14] eq "yes");
     $selmanagemessagesonly = "checked" if ($serverfields[15] eq "yes");

  print qq~
  <tr><td  align=left>$cgifont $serverfields[1] </font></td>
  <td  align=center>$cgifont <a href="$guesturl?pbook=$serverfields[0]&vat=$varurl&action=active_inactive_server_book">$serverfields[2] </font></td>
  <td  align=center><input type="checkbox" name="$serverfields[0]_managemessagesonly" value="yes" $selmanagemessagesonly  onchange="this.form.submit();"></td>
  <td  align=center><input type="checkbox" name="$serverfields[0]_cplink" value="yes" $selcplink></td>

  <td  align=center>$cgifont <a href="$guesturl?pbook=$serverfields[0]&vat=$varurl&action=delete_server_book" OnClick="return Confirmdelete()">Delete</a> </font></td>
  <td  align=center>$cgifont <a href="$guesturl?book=$serverfields[1]">Main</a> </font></td>
  <td  align=center>$cgifont <a href="$guesturl?book=$serverfields[1]&action=control_panel">CP</a> </font></td> ~;

   if ($serverfields[15] eq "yes"){

         $selcola = "yes" if ($serverfields[5] eq "yes");
     $sellanga = "yes" if ($serverfields[6] eq "yes");
     $selprefa = "yes" if ($serverfields[7] eq "yes");
     $seldatea = "yes" if ($serverfields[8] eq "yes");
     $selmenua = "yes" if ($serverfields[9] eq "yes");
     $selaccessa = "yes" if ($serverfields[10] eq "yes");
     $selfielda = "yes" if ($serverfields[11] eq "yes");
     $sellayouta = "yes" if ($serverfields[12] eq "yes");
     $seldataa = "yes" if ($serverfields[13] eq "yes");



   print qq~
<input type="hidden" name="$serverfields[0]_col" value="$selcola" >
<input type="hidden" name="$serverfields[0]_lang" value="$sellanga" >
<input type="hidden" name="$serverfields[0]_pref" value="$selprefa" >
<input type="hidden" name="$serverfields[0]_date" value="$seldatea" >
<input type="hidden" name="$serverfields[0]_menu" value="$selmenua" >
<input type="hidden" name="$serverfields[0]_access" value="$selaccessa" >
<input type="hidden" name="$serverfields[0]_field" value="$selfielda" >
<input type="hidden" name="$serverfields[0]_layout" value="$sellayouta" >
<input type="hidden" name="$serverfields[0]_data" value="$seldataa" >
<td align=center colspan=9>$cgifont <i><------- PowerBook currently set to Control Data Only -------></i></font> </td>

    ~;
     }
     else
     {

         print qq~ <td  align=center><input type="checkbox" name="$serverfields[0]_col" value="yes" $selcol></td>
  <td  align=center><input type="checkbox" name="$serverfields[0]_lang" value="yes" $sellang></td>
    <td  align=center><input type="checkbox" name="$serverfields[0]_pref" value="yes" $selpref></td>
  <td  align=center><input type="checkbox" name="$serverfields[0]_date" value="yes" $seldate></td>
  <td  align=center><input type="checkbox" name="$serverfields[0]_menu" value="yes" $selmenu></td>
  <td  align=center><input type="checkbox" name="$serverfields[0]_access" value="yes" $selaccess></td>
    <td  align=center><input type="checkbox" name="$serverfields[0]_field" value="yes" $selfield></td>
  <td  align=center><input type="checkbox" name="$serverfields[0]_layout" value="yes" $sellayout></td>
  <td  align=center><input type="checkbox" name="$serverfields[0]_data" value="yes" $seldata></td>  ~;



     }


 print qq~ </tr>      ~;

}

 print qq~ </table></td></tr>  ~;
print qq~ <tr><td colspan=1><center> <input type = submit value="Update">

</form></td></tr>
<tr><td align=;eft>$cgifont A checked "Control Data Only" limits access in current PowerBook to data management only. All other preferences are locked.
<br>A checked "MCP link" will put a link to the Master Control Panel into the menus of other Control Panels.</td></tr>

 </table></td></tr></table></td></tr></table>  ~;

}

sub update_child_settings {
&seek_cook;

#  100000001|testing|Active||||||||||||||||||||||||||||||32|\n

open(SERFILE,"$server_names");
@serverdata = <SERFILE>;
close(SERFILE);
 open(SERFILE,">$server_names");
 foreach $row (@serverdata)
{
@serverfields = split (/\|/, $row);
   for (my $x = 0; $x < 33; $x++)
   {
      $f = $g = "";

     if ($x == 5)
     {
       $f = "$serverfields[0]" . "_col";

        print SERFILE "$FORM{$f}|";

     }
     elsif ($x == 6)
     {
       $g = "$serverfields[0]" . "_lang";

        print SERFILE "$FORM{$g}|";

     }
     elsif ($x == 7)
     {
       $h = "$serverfields[0]" . "_pref";

        print SERFILE "$FORM{$h}|";

     }                                                  # SERVMENU  SERVACCESS  SERVFIELD  SERVLAYOUT
      elsif ($x == 8)     {
       $i = "$serverfields[0]" . "_date";
        print SERFILE "$FORM{$i}|";
     }
      elsif ($x == 9)     {
       $j = "$serverfields[0]" . "_menu";
        print SERFILE "$FORM{$j}|";
     }
      elsif ($x == 10)     {
       $k = "$serverfields[0]" . "_access";
        print SERFILE "$FORM{$k}|";
     }
      elsif ($x == 11)     {
       $l = "$serverfields[0]" . "_field";
        print SERFILE "$FORM{$l}|";
     }
      elsif ($x == 12)     {
       $m = "$serverfields[0]" . "_layout";
        print SERFILE "$FORM{$m}|";
     }

      elsif ($x == 13)     {
       $n = "$serverfields[0]" . "_data";
        print SERFILE "$FORM{$n}|";
     }
          elsif ($x == 14)     {
       $o = "$serverfields[0]" . "_cplink";
        print SERFILE "$FORM{$o}|";
     }
          elsif ($x == 15)     {
       $o = "$serverfields[0]" . "_managemessagesonly";
        print SERFILE "$FORM{$o}|";
     }


     else
     {
      print SERFILE "$serverfields[$x]|";

     }

   }

   print SERFILE "\n";

}

close(SERFILE);
   &content;
print qq~ <html><head><title></title>
<META http-equiv="refresh" content="0; URL=$guesturl?action=view_servers&vat=$varurl"> </head>
<body bgcolor=#ffffff> ~;
exit;

}

sub create_new_book {
 open(USER_FILE,"$server_names");
@serverdataa = <USER_FILE>;
close(USER_FILE);

  $name_exists = "no";
  $oldno = 0;
     $newbook = $FORM{'new_book'};
     $newbook = lc($newbook);
     $newbook =~ s/\s+/_/gi;

   foreach $row (@serverdataa){
         @serverdata = split(/\|/, $row);
         $newno = $serverdata[0];
        $oldno = $newno if ($newno > $oldno);

        $name_exists = "yes"  if ($newbook eq $serverdata[1]);

     }

        if   ($name_exists eq "yes"){
         &content;
         print qq~ <font face=Arial size=2>A PowerBook with the name "$newbook" already exists. <a href="javascript:history.go(-1)">Please go back and change</a>.~;
         exit;
        }

       if (($newbook !~ m,^([A-Za-z0-9\-_.]*)$,)  || ($newbook eq "")){

       &content;
         print qq~ <font face=Arial size=2>We don't like that name. <a href="javascript:history.go(-1)">Please go back and change</a>.~;
         exit;
       }

    open(USER_FILE,">>$server_names");

       $newno++;
      print USER_FILE "$newno|$newbook|Active||||||||||||yes|||||||||||||||||||\n";

    close(USER_FILE);

  &content;
print qq~ <html><head><title></title>
<META http-equiv="refresh" content="0; URL=$guesturl?action=view_servers&vat=$varurl"> </head>
<body bgcolor=#ffffff> ~;
exit;


}

sub active_inactive_server_book{



open(USER_FILE,"$server_names");
@serverdataa = <USER_FILE>;
close(USER_FILE);

open(USER_FILE,">$server_names");
foreach $row (@serverdataa){
         @serverdata = split(/\|/, $row);
         # print qq~ ($FORM{'pbook'} eq $serverdata[0]) <br>~;

 	if ($FORM{'pbook'} eq $serverdata[0])
         {
 		for ( $x = 0; $x < 33; $x++)
 		{
     			if ($x == 2)
    		 	{
         			 if ($serverdata[2] eq "Inactive")
          			    {
          				print USER_FILE "Active|";
         			    }
          			else
          		            {
           				print USER_FILE "Inactive|";
          			    }
      			}
      			else
      			{

         		 print USER_FILE "$serverdata[$x]|";
     			 }
   		 }

          print USER_FILE "\n";
       }


      else {
       print USER_FILE "$row";
        }


}

close(USER_FILE);

 &content;
print qq~ <html><head><title></title>
<META http-equiv="refresh" content="0; URL=$guesturl?action=view_servers&vat=$varurl"> </head>
<body bgcolor=#ffffff> ~;
exit;


}

sub edit_server_book{

}
sub delete_server_book{



open(USER_FILE,"$server_names");
@serverdataa = <USER_FILE>;
close(USER_FILE);

open(USER_FILE,">$server_names");
foreach $row (@serverdataa){
         @serverdata = split(/\|/, $row);

         if ($FORM{'pbook'} eq $serverdata[0])
         {
         $bookname = $serverdata[1];
        }

 	if ($FORM{'pbook'} ne $serverdata[0])
         {
       print USER_FILE "$row";
        }


}

close(USER_FILE);



$backupdir =  "$bookname" . "_active_powerbook_backups";
$filesdir =  "$bookname" . "_active_powerbook_files";
 #&content;
#print qq~ -- $backupdir =  $filesdir  ~;
# exit;

if (-e "$backupdir"){

opendir (USERS, "./$backupdir") || &oops(' backupdir');
@files = grep(//,readdir(USERS));
closedir (USERS);
foreach $file (@files)
{
unlink("./$backupdir/$file");
}

rmdir("$backupdir");
}


if (-e "$filesdir"){
opendir (USERS, "./$filesdir") || &oops('filesdir');
@files = grep(//,readdir(USERS));
closedir (USERS);
foreach $file (@files)
{
unlink("./$filesdir/$file");
}
rmdir("$filesdir");
}

 &content;
print qq~ <html><head><title></title>
<META http-equiv="refresh" content="0; URL=$guesturl?action=view_servers&vat=$varurl"> </head>
<body bgcolor=#ffffff> ~;
exit;




}

sub actions
{
if ($newaction eq "no_preview"){
&write ; exit;
}

&active_inactive_server_book if ($action eq "active_inactive_server_book");
&edit_server_book if ($action eq "edit_server_book");
&delete_server_book if ($action eq "delete_server_book");
 &enter_license if ($action eq "enter_license");
 &update_license if ($action eq "update_license");
 &mrtime if ($action eq "mrtime");
&view_copy_prefs if ($action eq "view_copy_prefs");
&copy_individual_preferences if ($action eq "copy_individual_preferences");
 &lrgeet if ($action eq "lrgeet");
&update_child_settings if ($action eq "update_child_settings");
&create_new_book if ($action eq "create_new_book");
&view_servers if ($action eq "view_servers");
&makepubpriv if ($action eq "makepubpriv");
&guest_to_power if ($action eq "guest_to_power");
&edit_searchprefs if ($action eq "edit_searchprefs");
&thanks if ($action eq "thanks");
&update_perms if ($action eq "update_perms");
&update_single_perm if ($action eq "update_single_perm");
&view_access if ($action eq "view_access");
&disenable_user if ($action eq "enable_user");
&disenable_user if ($action eq "disable_user");
&edit_user if ($action eq "edit_user");
&delete_user if ($action eq "delete_user");
&view_to_edit_user if ($action eq "view_to_edit_user");
&view_to_add_user_from_cp if ($action eq "view_to_add_user_from_cp");
&add_user_from_cp if ($action eq "add_user_from_cp");
&userlogin if ($action eq "userlogin");
&verifyuserlogin if ($action eq "verifyuserlogin");
&logout if ($action eq "logout");
&view_page_layout if ($action eq "view_page_layout");
&view_page_layout if ($action eq "update_page_items");
&loadsearch if ($action eq "loadsearch");
&view_page_layout if ($action eq "newactive_inactive");
&view_addlayoutprefs if ($action eq "view_addlayoutprefs");
&view_to_edit_page_layout if ($action eq "view_to_edit_page_layout");
&view_request_license if ($action eq "view_request_license");
&edit_page_layout if ($action eq "edit_page_layout");
&overlayup if ($action eq "overlayup");
&overlaydown if ($action eq "overlaydown");
&rest if ($action eq "rest");
&view_searchprefs if ($action eq "view_searchprefs");
&unblockall if ($action eq "unblockall");
&searchform if ($action eq "searchform");
&add_to_active if ($action eq "add_to_active");
&delete_all if ($action eq "delete_all");
&delete_all_thread if ($action eq "delete_all_thread");
&trash_all if ($action eq "trash_all");
&view_menuprefs if ($action eq "view_menuprefs");
&edit_menuprefs if ($action eq "edit_menuprefs");
&view_layoutprefs if ($action eq "view_layoutprefs");
&view_layoutprefs if ($action eq "active_inactive");
&view_layoutprefs if ($action eq "pub_priv");
&move_up if ($action eq "move_up");
&move_down if ($action eq "move_down");
&edit_a_field if ($action eq "edit_a_field");
&view_to_edit_a_field if ($action eq "view_to_edit_a_field");
&edit_field_details if ($action eq "edit_field_details");
&already_added if ($action eq "already_added");
&unblock if ($action eq "unblock");
&block_computer if ($action eq "block_computer");
&make_first_body if ($action eq "make_first_body");
&edit_dateprefs if ($action eq "edit_dateprefs");
&link if ($action eq "lin");
&finish_start if ($action eq "finish_start");
&read if ($action eq "");
&read if ($action eq "setup");
&read if ($action eq "reload");
&add if ($action eq "add");
&write if ($action eq "write");
&write if ($action eq "preview");
&write if ($action eq "post_preview");
&write if ($action eq "no_preview");
&view_prefs if ($action eq "view_prefs");
&change1 if ($action eq "change1");
&change2 if ($action eq "change2");
&read if ($action eq "view_to_edit");
&read2 if ($action eq "view_followup");
&read2 if ($action eq "view_followup_edit");
&add if ($action eq "cpadd_followup1");
&add if ($action eq "add_followup1");
&read if ($action eq "view_to_undo");
&search if ($action eq "search");
&view_change_password if ($action eq "view_change_password");
&view_backups if ($action eq "view_backups");
&view_single_backup if ($action eq "view_single_backup");
&view_colprefs if ($action eq "view_colprefs");
&view_langprefs if ($action eq "view_langprefs");
&cancel_color_change if ($action eq "cancel_color_change");
&control_panel if ($action eq "control_panel");
&bug if ($action eq "bug");
&edit_prefs if ($action eq "edit_prefs");
&restore_coldefaults if ($action eq "restore_coldefaults");
&save_user_color_defaults if ($action eq "save_user_color_defaults");
&save_user_defaults if ($action eq "save_user_defaults");
&restore_user_color_defaults if ($action eq "restore_user_color_defaults");
&restore_user_defaults if ($action eq "restore_user_defaults");
&restore_backups if ($action eq "restore_backups");
&restore_defaults if ($action eq "restore_defaults");
&undo_last_restore if ($action eq "undo_last_restore");
&change_password if ($action eq "change_password");
&edit_colprefs if ($action eq "edit_colprefs");
&edit_langprefs if ($action eq "edit_langprefs");
&trash_item if ($action eq "trash_item");
&undelete_item if ($action eq "undelete_item");
&delete_item if ($action eq "delete_item");
&write if ($action eq "add_followup2");
&restore_language_defaults if ($action eq "restore_language_defaults");
&approve_message if ($action eq "approve_message");
&view_dateprefs if ($action eq "view_dateprefs");
}
sub demostuff {
&content;
&main_header;
&active_header;
print qq~
<center> $cgifont <b>Sorry. This is only a demo. That action is not enabled.<br><a href="javascript:history.go(-1)">Back</a><hr size=1 width=600></b>
~;
exit;
}
sub required_script
{
print qq~
<script>
function checkrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements[i]
if (tempobj.name.substring(0,8)=="required"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("$TXT_please_fill_in")
return false
}
else
return true
}
</script>
~;
}
sub responses
{
($responsemessage, $responsenextpage, $ispublic ) = @_;
&content;
print qq~<html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title>$title</title>~;
if ($responsenextpage ne "none"){
print qq~ <META http-equiv="refresh" content="2; URL=$responsenextpage"> ~;
}
else {
$responsenextpage = "javascript:history.go(-1)";
}
if ($style ne "no")
{
print qq~ $user_style ~;
}
print qq~
</head> ~;
print "<BODY";
if ($ispublic eq "yes")
{
print qq~ BGCOLOR="$backcolor" ~;
if ($usebackgroundimage eq "yes")
{
print qq~
background = "$backgroundimage" ~;
}
print qq~
TEXT="$text" LINK="$link" VLINK="$vlink" ALINK="$alink" marginwidth="$marginwidth" marginheight="$marginheight"
LEFTMARGIN="$marginwidth" TOPMARGIN="$marginheight" ~;
}
print ">"; #start of body
if ($ispublic eq "yes")
{
&user_html if $use_user_html eq "yes";
print qq~ <div align=$alignment> ~; # sets the alignment of the main page

print qq~ <div align=$alignment> ~; # sets the alignment of the main page
# start of table to message
print qq~ <table border=0 cellspacing=0 cellpadding=0 width=$table_width>
<tr><td width=$table_width align=$alignment>
<font face="$textfontface" size=$textfontsize><b>

<a href="$responsenextpage">~;
}
print "$responsemessage";
if ($ispublic eq "yes")
{
print qq~</font></td></tr></table> ~;
print qq~ </div>~;
&user_html_footer if ($use_user_html_footer eq "yes");
}
}
sub thanks
{
$page_after_write =~ s/\s+//gi;
$page_after_write = "$guesturl?book=$book&action=reload&vat=$varurl" if (($page_after_write eq "") ||($page_after_write eq "http://") );
$thisisathankspage = "yes";
if (($private_message_check eq "yes") || ($FORM{'pm'} eq "yes")){
&responses($TXT_has_been_added_private, $page_after_write, 'yes') ;
}
elsif ($moderated eq "yes"){
&responses($TXT_has_been_added_moderated, $page_after_write, 'yes') ;
}
else{
&responses($TXT_has_been_added, $page_after_write, 'yes') ;
}

#if (($moderated eq "yes") && ($send_email_to_admin eq "off")){

#$mailbody = "You have a new posting to your Active PowerBook which requires your approval. You can confirm the message via the Message Manager of the Active PowerBook Control Panel.\n\n";
#&sndml($admin_email, 'PowerBook message approval required', $mailbody) ;

#}
}

sub sndml
{
($mailto, $subj, $mailtext ) = @_;



open (MAIL, "|$mail_path") || &oops('the mail program. Please check the mail path in the Control Panel.');
print MAIL "To: $mailto\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: $subj\n\n";
print MAIL "$mailtext\n\n";


print MAIL "=========================\n";
close(MAIL);

}

sub skipthanks
{
&content;
$page_after_write = "$guesturl?book=$book&action=view_to_edit&vat=$varurl" if ($FORM{'moveme'});
print qq~ <head><META http-equiv="refresh" content="0; URL=$page_after_write"></head><body> </body> ~;
}



sub control_panel
{
&seek_cook;
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
$noss = 0;
@data = <USER_FILE>;
close(USER_FILE);
foreach $row (@data)
{
@fields = split (/\|/, $row);
if (($fields[15] eq "waiting") && ($fields[10] ne "del"))
{
$noss++;
}
}

if ($book eq ""){
$cptext = "Master";
}
else
{
$cptext = "($book)";

}

&content;
print qq~
<HTML><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title>Active PowerBook $cptext Control Panel</title>
</head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600">
~;
print qq~
<center>
<table width=100%><tr><td width=100% height=100% align=center valign=center>
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $cptext Control Panel</b></td></tr>
<tr><td width=100% align=center>
$cgifont
~;
if ($noss >1){
print qq~ <br>You have $noss messages awaiting approval in your message manager.<br> ~;
}
elsif ($noss == 1){
print qq~ <br>You have a message awaiting approval in your message manager.<br> ~;
}
print qq~<a href="$guesturl?book=$book&action=logout&vat=$varurl">Log Out</a> -
<a href="http://active-scripts.net/powerbookhelp/">Help</a><p>
<SCRIPT LANGUAGE="JavaScript">
<!--
var days=new Array(8);
days[1] = "Sunday";
days[2] = "Monday";
days[3] = "Tuesday";
days[4] = "Wednesday";
days[5] = "Thursday";
days[6] = "Friday";
days[7] = "Saturday";
var months=new Array(13);
months[1] = "January";
months[2] = "February";
months[3] = "March";
months[4] = "April";
months[5] = "May";
months[6] = "June";
months[7] = "July";
months[8] = "August";
months[9] = "September";
months[10] = "October";
months[11] = "November";
months[12] = "December";
var dateObj=new Date()
var wday=days[dateObj.getDay() + 1]
var lmonth=months[dateObj.getMonth() + 1]
var date=dateObj.getDate()
document.write(wday + ", " + lmonth + " " + date + "&nbsp;")
// -->
</SCRIPT>
<form method=post action=$guesturl>
<input type=hidden name="book" value="$book">
<INPUT TYPE="hidden" NAME="action" VALUE="lin">
~;
if (-e "$already_added"){
$opo = 20;
}
else{
$opo = 20;
}
if ($mastermanagemessagesonly eq "yes"){
 $opo = 10;
}
$newt = $title;
$newt = "PowerBook" if ($title eq "");
print qq~<SELECT name=link size=$opo>
<OPTION selected VALUE="reload">$cptext $newt</OPTION> ~;


if ($book ne ""){
if ($mastermanagemessagesonly ne "yes"){
if ($mastercplink eq "yes"){
print qq~ <OPTION VALUE ="cpfromchild">MASTER CONTROL PANEL</OPTION>~;
}
}
}

print qq~
<OPTION VALUE ="add">$cptext ADD MESSAGE</OPTION>
<OPTION VALUE ="view_to_edit">$cptext Message Manager</OPTION>
<OPTION VALUE ="view_to_undo">$cptext Recycle Bin</OPTION>
<OPTION VALUE ="view_backups">$cptext Backup Manager</OPTION> ~;

if ($mastermanagemessagesonly ne "yes"){
 print qq~
<OPTION VALUE ="view_prefs">$cptext Standard Preferences Manager</OPTION>
<OPTION VALUE ="view_colprefs">$cptext Color/Images Manager</OPTION>
<OPTION VALUE ="view_page_layout">$cptext Page Layout Manager</OPTION>
<OPTION VALUE ="view_layoutprefs">$cptext Field Editor/Message Layout Manager</OPTION>
<OPTION VALUE ="view_addlayoutprefs">$cptext Add/Respond Page Layout Manager</OPTION>
<OPTION VALUE ="view_searchprefs">$cptext Search Preferences Manager</OPTION>
<OPTION VALUE ="view_menuprefs">$cptext Menu Manager</OPTION>
<OPTION VALUE ="view_langprefs">$cptext Language Preferences Manager</OPTION>
<OPTION VALUE ="view_dateprefs">$cptext Date Format Manager</OPTION>
<OPTION VALUE ="view_access">$cptext Access Manager</OPTION>
<OPTION VALUE ="view_change_password">$cptext Password Manager</OPTION> ~;
}
if ($book eq ""){
print qq~<OPTION VALUE ="view_servers">SERVER MANAGER</OPTION> ~;
}
unless ($vartime1 == $lic){
 if ($book eq ""){
print qq~<OPTION VALUE ="view_request_license">Request license number</OPTION> ~;
print qq~<OPTION VALUE ="enter_license">Enter license number</OPTION> ~;
 }
}
print qq~<OPTION VALUE ="take_me_home">Home page
<OPTION VALUE ="reload">================================= ~;
#unless (-e "$already_added")
#{
#print qq~<OPTION VALUE ="add_to_active">Add your site to active-scripts.net</OPTION>~;
#}
#<OPTION VALUE ="bug">Comment/report a bug
print qq~ </SELECT><br><INPUT TYPE="submit" VALUE="Go"></form><br>
You are using Active PowerBook version $bversion.<br>~;

if ($vartime1 == $lic){
  if ($book eq ""){
    print qq~This PowerBook is licensed. License number $lic <br>
    <a href="http://www.active-scripts.net/cgi-bin/checkforupgrade.cgi?ref=$bversion">Check for upgrade</a>
~;
 }
}

else{
my $togo = ( ((60*60*24*7) - ($varurl - $vartime2 )) /(60*60));
$togo = int($togo);
print "This PowerBook is not yet licensed. $togo hours left.";
}


print qq~ <br>$reverse2</td></tr>
</table></td></tr></table></td></tr></table> </td></tr></table>
~;
}
sub inter_footer
{
print qq~
</body>
</html>
~;
}
sub link
{
$link = $FORM{'link'};
&content;
if ($link ne "take_me_home")
{
print qq~
<head>
<META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=$link&vat=$varurl"></head><body bgcolor=#ffffff></body></html>
~;
}
else
{

$home_page = "http://" . "$home_page";
print qq~
<head>

<META http-equiv="refresh" content="0; URL=$home_page"></head><body bgcolor=#ffffff></body></html>
~;
}
exit;
}

sub emailfield
{

print "$startbold"; print "$startitalic"; print "$startunderline"; print "$before";

if ($la[30] eq "yes")
{
$munged_address = $details;
$munged_address =~ s/\@/~AT~/g;
$munged_address =~ s/\./~DOT~/g;
$add_me = $munged_address;
}
else
{
$add_me = $details;
}
if ($la[31] eq "text")
{
$email_symbol = $la[32];
}
elsif ($la[31] eq "image")
{
  $la33 = $la[33];
  $la33 =~ s/http:\/\///gi;

$email_symbol = "<img border=0 src=\"http://$la33\">";
}

elsif ($la[31] eq "altfield") {

       $urlaltfield = $FARRARY{$la[51]};

         if ($FTYPES{$la[51]} eq "TEXT")
         {

         $email_symbol = "$fields[$urlaltfield]";
         }
         elsif ($FTYPES{$la[51]} eq "IMAGE")
         {
         $email_symbol = "<img src=\"http://" . "$image_dir_url" . "/$fields[$urlaltfield]\">";
         }
}


else
{
$email_symbol = $add_me;
}
if ($count ==1)
{
if( $la[29] eq "yes")
{
print qq~<a href="mailto:$add_me">$prefcolor$email_symbol$postfcolor</a>~;
}
else
{
print qq~$prefcolor$add_me$postfcolor~;
}
}
else
{
if( $la[29] eq "yes")
{
print qq~<a href="mailto:$add_me">$prefcolor$email_symbol$postfcolor</a>~;
}
else
{
print qq~$prefcolor$add_me$postfcolor~;
}
} #end mail
print "$after"; print "$endunderline"; print "$enditalic"; print "$endbold";
}


sub main_table_results
{

#$table_width = "100%";
$passwoor = $COOK{$cooknamelocal};
if ($passwoor eq $active_string)
{ $logged_in_cp = "yes";
}
$header_trans1 = ""; $body_trans1 = ""; $header_trans2 = ""; $body_trans2 = "";
if (($action eq "view_to_edit") || ($action eq "view_to_undo") || ($action eq "view_followup_edit"))
{
$border_size = 1; $table_width = 600; $textfontsize = 2; $textfontface = Arial;
($textdata_color1, $textdata_color2, $texttable_color1, $texttable_color2) = ('black', 'black', 'black', 'black' );
$data_color1 = $data_color2 = $table_color1 = $table_color2 = "#ffffff";
}
$header_back1 = $header_back2 = $body_back1 = $body_back2 = "";
if ($trans_message_header ne "yes")
{
# $table_color1 and 2 are body colors
# $data_color1 and 2 are header colors
$header_trans1 = "bgcolor=$data_color1";
$header_trans2 = "bgcolor=$data_color2";
$header_back1 = "background = \"$backgroundimageh1\"" if ($usebackgroundimageh1 eq "yes");
$header_back2 = "background = \"$backgroundimageh2\"" if ($usebackgroundimageh2 eq "yes");
}
if ($trans_message_body ne "yes")
{
# $table_color1 and 2 are body colors
# $data_color1 and 2 are header colors
$body_trans1 = "bgcolor=$table_color1";
$body_trans2 = "bgcolor=$table_color2";
$body_back1 = "background = \"$backgroundimageb1\"" if ($usebackgroundimageb1 eq "yes");
$body_back2 = "background = \"$backgroundimageb2\"" if ($usebackgroundimageb2 eq "yes");
}
if (($action eq "view_to_edit") || ($action eq "view_to_undo") || ($action eq "view_followup_edit") )
{
$header_trans1=$header_trans2=$body_trans1=$body_trans2="";
my $wb = "#ffffff";
$header_back1=$header_back2=$body_back1=$body_back2= "bgcolor=$wb";
}

if ($border_size eq "")
{
$border_size = 1;
}
@responsedata = ();
# checks to see if this message (field 0) has any responses
while (($k, $v) = each %FUPPS)
{
if ($k =~ /$fields[0]/)
{
push (@responsedata, $v); # and pushes them (entire rows) into the array
} # NB This will just COUNT them if viewing main table but will DISPLAY them if viewing thread
}
$howmany = @responsedata;
@responsedata = sort (@responsedata);
print qq~
<table border=$border_size cellpadding=5 cellspacing=0 width=$table_width> ~;
($secj,$minj,$hourj,$mdayj,$monj,$yearj,$wdayj,$ydayj,$isdstj) = localtime($fields[3]);
$bakday = $mday;
$time_in_seconds = time();
if ($secj < 10) { $sec = "0$secj"; }
if ($minj < 10) { $minj = "0$minj"; }
if ($hourj < 10) { $hour = "0$hourj"; }
if ($mdayj < 10) { $mday = "0$mdayj"; }
$monthj = ($monj + 1);
if ($monthj < 10) { $monthj = "0$monthj"; }
@weekdaysbakj = ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
$bugyearj = ($yearj + 1900);
$mydatej = "$months[$monj]"." ". "$mdayj"." ". "$bugyearj" . " " ."$hourj" . "\:" . "$minj" . "\:" . "$secj";
if ($action eq "view_to_undo"){
$countingup++;
print qq~ <tr valign=top><td bgcolor=white><font size=$textfontsize face= "$textfontface"><b>Entry $countingup:</b> $mydatej<br>
~;
if ($fields[7]){
print qq~IP: $fields[7]
~;
}
$state = "Undelete";
$warn = "";
if (($fields[33]) && ($MAINDEL{$fields[33]} eq "yes")){
$warn = "yes";
}
print qq~
[ <a href="$guesturl?book=$book&action=undelete_item&ref=$fields[0]&vat=$varurl" ~;
if ($warn eq "yes"){
print qq~ OnClick="return ConfirmMissingMainMessage()" ~;
}
print qq~ >$state</a> |
<a href="$guesturl?book=$book&action=trash_item&ref=$fields[0]&vat=$varurl" OnClick="return ConfirmTrash()">Permanently wipe</a> ] </font></td></tr>
~;
}
elsif (($action eq "view_to_edit") || ($action eq "view_followup_edit") ){
if (($fields[15] eq "waiting") && ($fields[16] ne "yes")){
print qq~ <tr valign=top><td bgcolor=red><font size=$textfontsize face= "$textfontface" color=white><b>AWAITING APPROVAL</b></td></tr>
~;
}
else{
if ($NEEDAPPR{$fields[0]} eq "yes")
{
print qq~ <tr valign=top>
<td bgcolor=red><font size=$textfontsize face= "$textfontface" color=white><b>RESPONSE AWAITING APPROVAL</b></td></tr>
~;
}
}
if ($fields[16] eq "yes"){
print qq~ <tr valign=top><td bgcolor=blue><font size=$textfontsize face= "$textfontface" color=white><b>PRIVATE MESSAGE</b></td></tr>
~;
}
if ($BLOCKED_MESSAGES{$fields[0]}){
print qq~ <tr valign=top><td bgcolor=black><font size=$textfontsize face= "$textfontface" color=white><b>BLOCKED USER</b></td></tr>
~;
}
$countingup++;
print qq~ <tr valign=top><td bgcolor=white><font size=$textfontsize face= "$textfontface"><b>Entry $countingup:</b> $mydatej<br>
~;
if ($fields[7]){
print qq~IP: $fields[7]
~;
}
print qq~
[ <a href="$guesturl?book=$book&action=delete_item&ref=$fields[0]&vat=$varurl">Delete ~;
if (($FUPS{$fields[0]} eq "yes") || (($action eq "view_followup_edit") && (!$fields[33]))){
print "Thread ";
}
print qq~</a>]
~;
$mainmessage = $fields[0];
$mainmessage = $fields[33] if ($fields[33]);

#if ($whichusers ne "webmaster")
#{
unless (($fields[16] eq "yes") || ($action eq "view_followup_edit")) # cos we wouldn't need to add response to private message
{
print qq~
[ <a href="$guesturl?book=$book&action=cpadd_followup1&ref=$mainmessage&vat=$varurl">Add Response</a> ]
~;
}
#}
if (($fields[15] eq "waiting") && ($fields[16] ne "yes"))
{
print qq~
[ <a href="$guesturl?book=$book&action=approve_message&ref=$fields[0]&vat=$varurl">APPROVE</a> ]
~;
}
if ($fields[16] ne "yes"){
print qq~
[ <a href="$guesturl?book=$book&action=change1&ref=$fields[0]&vat=$varurl">Edit</a> ] ~;
}
if ($FUPS{$fields[0]} eq "yes"){
print qq~ [ <a href="$guesturl?book=$book&action=view_followup_edit&ref=$fields[0]&start_number=$start_number&vat=$varurl">~;
if ($NEEDAPPR{$fields[0]} eq "yes"){
print qq~<b>APPROVE</b>/~;
}
print qq~View/Edit Responses ($howmany)</a> ]~;
}
if ($BLOCKED_MESSAGES{$fields[0]}){
print qq~ [ <b>BLOCKED</b> (<a href="$guesturl?book=$book&action=unblock&ref=$fields[0]&vat=$varurl" OnClick="return ConfirmUNBlock()">unblock</a>) ] ~;
}
else{
print qq~ [ <a href="$guesturl?book=$book&action=block_computer&ref=$fields[0]&vat=$varurl" OnClick="return ConfirmBlock()">Block computer</a> ] ~;
}
if ($fields[16] eq "yes"){
$pubprivword = "public";
}
else{
$pubprivword = "private";
}
print qq~ [ <a href="$guesturl?book=$book&action=makepubpriv&ref=$fields[0]&vat=$varurl">Make $pubprivword</a> ] ~;
print qq~ </font></td></tr> ~;
}
$image_dir_url =~ s/http\:\/\///gi;
$image_dir_url =~ s/\/$//gi;
open(USER_FILE,"$field_names"); @layout_data = <USER_FILE>; close(USER_FILE);
@layout_data = sort(@layout_data);
$hearderstart = 1;
&date_mod;
$breakhappensat = ""; $lastfieldat = "";
foreach $splitpoint (@layout_data){ # find where the break is to see if there are any fields after it.
@findsplit = split (/\|/, $splitpoint);
if ($findsplit[14] eq "break"){
$breakhappensat = "$findsplit[12]";
}
if (($findsplit[21] eq "yes") || ($details ne "")){ # find the last field that will be used
$lastfieldat = "$findsplit[12]";
}
}
$breakinc = "yes";
if ($breakhappensat > $lastfieldat){ # if break happens after the last field to be displayed
$breakinc = "no";
}
foreach $row (@layout_data){
@la = split (/\|/, $row);
$rtyyyy = $FARRARY{$la[12]};
$details = $fields[$rtyyyy]; $details =~ s/PIPEPIPE/\|/gi;
$details = $condate if ($la[2] eq "date");
$before = $la[18]; $before =~ s/PIPEPIPE/\|/gi;
$after = $la[17]; $after =~ s/PIPEPIPE/\|/gi;
$sybs = $details; $sybs =~ s/\s+//gi;
$startbold = $endbold = $startitalic = $enditalic = $startunderline = $endunderline = $nameincluded = "";
$startboldlb = $endboldlb = $startitaliclb = $enditaliclb = $startunderlinelb = $endunderlinelb = "";
$startbold = "<b>" if ($la[26] eq "yes");
$endbold = "</b>" if ($la[26] eq "yes");
$startitalic = "<i>" if ($la[27] eq "yes");
$enditalic = "</i>" if ($la[27] eq "yes");
$startunderline = "<u>" if ($la[25] eq "yes");
$endunderline = "</u>" if ($la[25] eq "yes");
$startboldlb = "<b>" if ($la[59] eq "yes");
$endboldlb = "</b>" if ($la[59] eq "yes");
$startitaliclb = "<i>" if ($la[60] eq "yes");
$enditaliclb = "</i>" if ($la[60] eq "yes");
$startunderlinelb = "<u>" if ($la[58] eq "yes");
$endunderlinelb = "</u>" if ($la[58] eq "yes");

if ($guess eq "indeed"){
$details = $sybs = "Sample $la[1]";
$details = $sybs = "Sample date" if $la[2] eq "date";
$details = $sybs = "<img border=0 src=\"http://www.active-scripts.net/sample.jpg\">" if $la[2] eq "IMAGE";
if ($la[2] eq "FILE"){
$details = $sybs = qq~ filename.tag ~;
}
}
$details = $sybs = "<a href=\"\">$la[32]</a>" if $la[2] eq "ADD RESPONSE";
$details = $sybs = "<a href=\"\">$la[32]</a>" if $la[2] eq "VIEW RESPONSES";
$details = $sybs = "<a href=\"\">$la[32]</a>" if $la[2] eq "EDIT";


unless (($action eq "view_to_edit") ||($action eq "change1") ||($action eq "view_to_undo")   ){
$sybs = "" if ($la[13] eq "yes");                     #non public field.
}


if ($breakinc eq "yes"){
	next if ((($la[21] ne "yes") || ($sybs eq "")) && ($la[14] ne "break")) ;
	# only use active fields and non blank fields and field with break
}
else{
	next if (($la[21] ne "yes") || ($sybs eq "")) ; # only use active fields and non blank fields
}
############# sort out the table html
if (($la[14] ne "break") && ($hearderstart == 1)) ## first field and it is a header
{
print qq~ <tr valign=top> ~; # header tr
if ($count ==1){
print qq~<td $header_trans1 width=$table_width $header_back1>
<font face="$textfontface" size=$textfontsize color = $textdata_color1>~;
}
else
{
print qq~
<td $header_trans2 width=$table_width $header_back2>
<font face="$textfontface" size=$textfontsize color = $textdata_color2>
~;
}
}
elsif (($la[14] eq "break") && ($hearderstart == 1)) ## first field and it is a body
{
print qq~ <tr valign=top> ~; # body tr
if ($count ==1){
print qq~<td $body_trans1 width=$table_width $body_back1>
<font face="$textfontface" size=$textfontsize color=$texttable_color1>~;
}
else{
print qq~<td $body_trans2 width=$table_width $body_back2>
<font face="$textfontface" size=$textfontsize color=$texttable_color2>~;
}
}
elsif ($la[14] eq "break"){
print qq~ </td></tr><tr valign = top> ~;
if ($count ==1){
print qq~
<td $body_trans1 width=$table_width $body_back1>
<font face="$textfontface" size=$textfontsize color=$texttable_color1>
~;
}
else{
print qq~
<td $body_trans2 width=$table_width $body_back2>
<font face="$textfontface" size=$textfontsize color=$texttable_color2>
~;
}
}
########### table html sorted, now for the fields
next if (($la[21] ne "yes") || ($sybs eq "") || ($la[2] eq "PRIVATE_OPTION") );
unless (($la[14] eq "break") || ($hearderstart == 1) || ($sybs eq "")) # unless start of header or footer or blank
{
print "</div>" if ($la[15] eq "v"); #tail end of previous div
}
my $gofor = "no";
$gofor = "yes" if ($sybs ne "");

$gofor = "no" if ($la[2] eq "EDIT") ;
if ($la[2] eq "EDIT"){
$gofor = "no";
foreach my $waitmess(@deadlines){
if ($waitmess =~ /$blcook$fields[0]/){
$gofor = "yes";
last;} } }
$gofor = "no" if (($la[2] eq "EDIT") && ($action eq "view_to_undo")) ;
$gofor = "no" if ($la[2] eq "VIEW RESPONSES") && ($FUPS{$fields[0]} ne "yes"); # if no responses
$gofor = "yes" if (($action eq "view_page_layout") || ($action eq "view_layoutprefs")
|| ($action eq "move_up") || ($action eq "move_down") );
$gofor = "no" if (($action eq "view_followup") && ($la[2] eq "ADD RESPONSE"));
$gofor = "no" if ( (($action eq "view_to_edit")||($action eq "view_followup_edit")||($action eq "view_to_undo") ||
($action eq "view_single_backup") )&& (($la[2] eq "ADD RESPONSE")||($la[2] eq "VIEW RESPONSES") ));

if ($gofor eq "yes")
{
print "<div align=$la[28]>" if ($la[15] eq "v");
print " " if ($la[15] eq "h");
print qq~<font face="$la[22]" size="$la[23]">~;

 $prefont = $postfont = $prefontlb ="";
 $postfont = "</font>";
 $prefont = "<font face=\"$la[22]\" size=\"$la[23]\">";
 $prefontlb = "<font face=\"$la[55]\" size=\"$la[56]\">";

$prefcolor = $postfcolor =$prefcolorlb =  "";

if ($la[37] eq "yes"){
$prefcolor = "<font color = \"$la[24]\">";
$postfcolor = "</font>";
}
if ($la[62] eq "yes"){
$prefcolorlb = "<font color = \"$la[57]\">";
$postfcolor = "</font>";
}


if ($action eq "view_to_edit"){
$prefcolor = "<font color = \"#000000\">";
}

if ($la[2] eq "EMAIL"){
&emailfield;
}
elsif ($la[2] eq "TABLE"){
&tablefield;
}
elsif ($la[2] eq "URL"){
&urlfield;
}
elsif ($la[2] eq "ADD RESPONSE"){
&arfield;
}
elsif ($la[2] eq "VIEW RESPONSES"){
&vrfield;
}
elsif ($la[2] eq "EDIT"){
&editfield;
}
else{
&justdetails;
}

print "</font>";
}
$hearderstart = 0; # no longer first row
} # end for each row
print qq~</div> ~;

print qq~ </td></tr>

</table> ~; # end of table
if (($action eq "view_to_edit") || ($action eq "view_to_undo") || ($action eq "view_layoutprefs") ){
print "<hr size=1 width=600>";
}
else{
unless ($use_own_html_between_messages eq "no")
{
print "$html_between";
}
}
$count++;
if ($count >2){$count = 1;}
}

sub tablefield {

 $tar = ""; ($tar = "target = \"$la[38]\"") if ($la[38]);
print "$startbold"; print "$startitalic"; print "$startunderline"; print "$before";
#print qq~ <table width=100%> ~;

##############  $prefcolor$details$postfcolor
  @tablerows = split (/\//, $la[54]);
@tablecols = split (/\//, $la[53]);
@tableprops = split (/\//, $la[64]);
 $fieldtableborder = $tableprops[0];
 $fieldtablecellspacing = $tableprops[1];
 $fieldtablecellpadding = $tableprops[2];
 $fieldtablewidth = $tableprops[3];



@detailfields = split (/\//, $details);

 $fieldtableborder = "1" if  $fieldtableborder eq "";
 $fieldtablecellspacing  = "2" if  $fieldtablecellspacing  eq "";
 $fieldtablecellpadding  = "2" if $fieldtablecellpadding  eq "";
 $fieldtablewidth   = "90%" if $fieldtablewidth  eq "";

print qq~ <table
border="$fieldtableborder"
cellspacing = "$fieldtablecellspacing"
cellpadding = "$fieldtablecellpadding"
width="$fieldtablewidth"><tr><td  align="$la[61]">$startboldlb$startitaliclb$startunderlinelb$prefontlb$prefcolorlb $la[1] $postfcolor$postfont$endunderlinelb$enditaliclb$endboldlb</font></td>
~;

#  $startbold$startitalic$startunderline
#  $endunderline$enditalic$endbold



foreach $tablecols (@tablecols)
{
$op = $tablecols;
$op =~ s/\s+/ /gi;
print qq~ <td  align="$la[61]">$startboldlb$startitaliclb$startunderlinelb$prefontlb$prefcolorlb$op$postfcolor$postfont$endunderlinelb$enditaliclb$endboldlb</td>~;
}
print qq~ </tr>  ~;

$ct = 0;

 foreach $tablerows (@tablerows)   ###### ####
{
$oprow = $tablerows;
$oprow =~ s/\s+/ /gi;
print qq~ <tr><td  align="$la[61]">$startboldlb$startitaliclb$startunderlinelb$prefontlb$prefcolorlb$oprow$postfcolor$postfont$endunderlinelb$enditaliclb$endboldlb</td>~;

    foreach $tablecols (@tablecols)   ############
      {
         $tddetail = $detailfields[$ct];
         $tddetail = "&nbsp;" if $tddetail eq "";

       print qq~ <td align="$la[63]">$startbold$startitalic$startunderline$prefont$prefcolor$tddetail$postfcolor$postfont$endunderline$enditalic$endbold </td>  ~;

        $ct++;
      }
print qq~ </tr>  ~;

 $rownotemp++;

}



 #################
print qq~ </table> ~;
print "$after"; print "$endunderline"; print "$enditalic"; print "$endbold";

}


sub makepubpriv
{
&seek_cook;
&get_file_lock("$location_of_lock_file");
$ref = $FORM{'ref'};
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$powerbook_data_name");
foreach $row (@data)
{
@fields = split (/\|/, $row);
if ($ref eq $fields[0]){
for (my $x = 0; $x < 42; $x++){
if ($x == 16) {
if ($fields[16] eq "yes")
{
print USER_FILE "|";
}
else
{
print USER_FILE "yes|";
}
}
else{
print USER_FILE "$fields[$x]|";
}
}
print USER_FILE "\n";
}
else{
print USER_FILE "$row";
}
}
close(USER_FILE);
&release_file_lock("$location_of_lock_file");
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_to_edit&vat=$varurl"> ~;
&main_headerb;
print qq~
<center>
~;
}

sub justdetails
{ print "$startbold"; print "$startitalic"; print "$startunderline"; print "$before";
if ($la[2] eq "IMAGE"){
my $dimensions = "";
if ($la[43] eq "yes"){
$dimensions = "width=\"$la[41]\" height=\"$la[42]\"";
}
if ($guess eq "indeed"){
print "<img $dimensions border=0 src=\"http://www.active-scripts.net/sample.jpg\">" ;
}
else{
print qq~ <img $dimensions border=0 src="http://$image_dir_url/$details"> ~;
}
}
elsif ($la[2] eq "FILE"){
	if ($guess eq "indeed"){
	print qq~ <a href="">$details</a> ~;
	}
	else # main routine
	{
		if ($la[31] eq "text") {
		$url_symbol = $la[32];
		}
		elsif ($la[31] eq "image") {
		$url_symbol =~ s/http:\/\///gi;
		$url_symbol = "http://" . $url_symbol;
		$url_symbol = "<img border=0 src=\"$la[33]\">";
		}
		else {
		$url_symbol = $details;
		}
		#if( $la[29] eq "yes") {  #must be link
		print qq~<a href="http://$image_dir_url/$details" >~;
		print "$prefcolor$url_symbol$postfcolor";
		print qq~</a>~;
		#}
		#else {
		#print qq~$prefcolor$details$postfcolor~;
		#}
	}
}
else
{
print "$prefcolor$details$postfcolor";
}
print "$after"; print "$endunderline"; print "$enditalic"; print "$endbold";
}
sub arfield
{
if ($la[31] eq "image")
{

  $la33 = $la[33];
  $la33 =~ s/http:\/\///gi;

$ar_symbol = "<img border=0 src=\"http://$la33\">";
}
else
{
$ar_symbol = $la[32];
}
unless (($action eq "view_followup") || ($action eq "view_to_edit") )
{
if ((($allow_responses ne "no") && ($action ne "view_to_edit")
&&($action ne "view_layoutprefs") && ($action ne "view_to_undo") && ($action ne "view_followup_edit"))
|| ($action eq "view_page_layout") || ($action eq "view_layoutprefs"))
{
$print_me = "no";
if (($whichusers eq "multiple passwords") || ($whichusers eq "single password"))
{
if ($COOK{'actiuse'} eq "ok")
{
$print_me = "yes";
}
else
{
$print_me = "no";
}
}
elsif ($whichusers eq "all")
{
$print_me = "yes";
}
else
{
$print_me = "no";
}
if (($whichusers eq "webmaster") && ($logged_in_cp eq "yes"))
{
$print_me = "yes";
}
if (($print_me eq "yes")|| ($action eq "view_page_layout") || ($action eq "view_layoutprefs")
|| ($action eq "move_up") || ($action eq "move_down"))
{
print "$startbold"; print "$startitalic"; print "$startunderline"; print "$before"; #####
print qq~ <a href="$guesturl?book=$book&action=add_followup1&ref=$fields[0]&start_number=$start_number&vat=$varurl">~;

print "$prefcolor$ar_symbol$postfcolor";

print "</a>"; print "$after"; print "$endunderline"; print "$enditalic"; print "$endbold";
}
}
}
}

sub vrfield
{
if ($la[31] eq "image")
{
  $la33 = $la[33];
  $la33 =~ s/http:\/\///gi;
$vr_symbol = "<img border=0 src=\"http://$la33\">";
}
else
{
$vr_symbol = $la[32];
}
unless (($action eq "view_followup") || ($action eq "view_to_edit")    )
{
if (($FUPS{$fields[0]} eq "yes") || ($action eq "view_page_layout") || ($action eq "view_layoutprefs")
|| ($action eq "move_up") || ($action eq "move_down"))
{
print "$startbold"; print "$startitalic"; print "$startunderline"; print "$before";
print qq~ <a href="$guesturl?book=$book&action=view_followup&ref=$fields[0]&start_number=$start_number&vat=$varurl">~;

print "$prefcolor$vr_symbol ($howmany)$postfcolor";

print "</a>"; print "$after"; print "$endunderline"; print "$enditalic"; print "$endbold";
}
}
}
sub editfield
{
if ($la[31] eq "image")
{
  $la33 = $la[33];
  $la33 =~ s/http:\/\///gi;
$edit_symbol = "<img border=0 src=\"http://$la33\">";
}
else
{
$edit_symbol = $la[32];
}
unless ($action eq "view_to_edit")
{
print "$startbold"; print "$startitalic"; print "$startunderline"; print "$before";
print qq~
<a href="$guesturl?book=$book&action=change1&ref=$fields[0]&start_number=$start_number&vat=$varurl">~;

print "$prefcolor$edit_symbol$postfcolor";

print "</a>"; print "$after"; print "$endunderline"; print "$enditalic"; print "$endbold";
}
}
sub urlfield
{

$tar = ""; ($tar = "target = \"$la[38]\"") if ($la[38]);
print "$startbold"; print "$startitalic"; print "$startunderline"; print "$before";

if ($la[31] eq "text") {
$url_symbol = $la[32];
}
elsif ($la[31] eq "image") {

   $la33 = $la[33];
  $la33 =~ s/http:\/\///gi;

$url_symbol = "<img border=0 src=\"http://$la33\">";
}
elsif ($la[31] eq "altfield") {

       $urlaltfield = $FARRARY{$la[51]};

         if ($FTYPES{$la[51]} eq "TEXT")
         {

         $url_symbol = "$fields[$urlaltfield]";
         }
         elsif ($FTYPES{$la[51]} eq "IMAGE")
         {
         $url_symbol = "<img src=\"http://" . "$image_dir_url" . "/$fields[$urlaltfield]\">";
         }
}

else {
$url_symbol = $details;
}

$url_symbol = "Sample $la[1]" if ((($url_symbol eq "") || ($FTYPES{$la[51]} eq "IMAGE")) && ($guess eq "indeed" ));

if ($count ==1) {
if( $la[29] eq "yes") {
print qq~<a href="http://$details" $tar>$prefcolor$url_symbol$postfcolor</a>~;
}
else {
print qq~$prefcolor$details$postfcolor~;
}
}
else {
if( $la[29] eq "yes") {
print qq~<a href="http://$details" $tar>$prefcolor$url_symbol$postfcolor</a>~;
}
else {
print qq~$prefcolor$details$postfcolor~;
}
} #end url
print "$after"; print "$endunderline"; print "$enditalic"; print "$endbold";
}
sub inter_header {
&content;
print qq~
<HTML><head><title>$title</title>
<META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=$where&vat=$varurl">
</head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600">
~;
}
sub basic_header {
&content;
print qq~
<HTML><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title>Active PowerBook</title>
</head>
<body bgcolor=#ffffff text="#000000" link="#ff0000" vlink="#ff0000" alink="#ff0000">
~;
}
sub check_address_for_mistakes {
$guest_email = $detail;
if ($guest_email=~/^\.|^\@/) {
&basic_header;
print qq~ <center> $cgifont2 $title<p></font> $cgifont <b>$TXT_no_dot_at_start<br><a href="javascript:history.go(-1)">$TXT_please_go_back_and_edit</a> </b></font>
~;
exit;
}
if ($guest_email=~/^www\./) {
&basic_header;
print qq~ <center> $cgifont2 $title<p></font> $cgifont <b>$TXT_no_www_at_start<br><a href="javascript:history.go(-1)">$TXT_please_go_back_and_edit</a> </b></font>
~;
exit;
}
$domain=$guest_email;
$domain=~s/^.*\@(.*)/$1/;
if ($domain=~/_|~|#/)
{
&basic_header;
print qq~
<center> $cgifont2 $title<p></font> $cgifont
<b>$TXT_no_squiggles_in_domain<br><a href="javascript:history.go(-1)">$TXT_please_go_back_and_edit</a> </b></font> ~;
exit;
}
if ($guest_email=~tr/@//!=1)
{
&basic_header;
print qq~
<center> $cgifont2 $title<p></font> $cgifont
<b>$TXT_only_one_at<br><a href="javascript:history.go(-1)">$TXT_please_go_back_and_edit</a> </b></font>
~;
exit;
}
if ($guest_email=~/\.\@|\@\.|\.\./)
{
&basic_header;
print qq~
<center> $cgifont2 $title<p></font> $cgifont
<b>$TXT_no_dots_next<br><a href="javascript:history.go(-1)">$TXT_please_go_back_and_edit</a> </b></font>
~;
exit;
}
if (!($guest_email=~/\.[a-z]{2,4}$/i))
{
&basic_header;
print qq~
<center> $cgifont2 $title<p></font> $cgifont
<b>$TXT_wrong_end<br><a href="javascript:history.go(-1)">$TXT_please_go_back_and_edit</a> </b></font>
~;
exit;
}
} # end check mistakes
sub plain_header
{
print qq~
<html>
<head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title>$title</title>
~;
print qq~
</head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600">
<center>
~;
}
sub plain_header_stop
{
print qq~
<html>
<head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title>$title</title>
~;
print qq~
</head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600">
<center>
~;
}
sub plain_table_results
{
if ($count ==1)
{
print qq~
<table border=1 cellpadding=5 cellspacing=0>
~;
}
else
{
print qq~
<table border=1 cellpadding=5 cellspacing=0>
~;
}
print qq~
<tr valign=top>
~;
if ($count ==1)
{
print qq~
<td width=$table_width>
<font face="$textfontface" size=$textfontsize ><b>$fields[1]</b>
~;
}
else
{
print qq~
<td width=$table_width>
<font face="$textfontface" size=$textfontsize ><b>$fields[1]</b>
~;
}
if ($fields[4])
{
if( $use_mailto eq "yes")
{
print qq~
- <i> <a href="mailto:$fields[4]">$fields[4]</a></i>
~;
}
else
{
print qq~
- <i> $fields[4]</i>
~;
}
}
if (($fields[11]) && ($web_enabled eq "yes"))
{
print qq~
<i> - <a href="http://$fields[11]" target="new">web page</a></i>
~;
}
print qq~
</font></td></tr>
~;
print qq~
<tr valign=top> <td width=$table_width>
~;
if ($count ==1)
{
print qq~
<font face="Arial" size=2 >
~;
}
else
{
print qq~
<font face="Arial" size=2 >
~;
}
print qq~
$fields[2]
<div align=right>
<I>$fields[3]</i>
~;
if ($fields[5])
{
print qq~
<i> - $fields[5]</i>
~;
}
print qq~
</div>
~;
if ($fields[6])
{
print qq~
<hr width=$table_width size=1>
<center><table>
<tr valign=top><td width=175>
<b><font face= "$textfontface" size= $textfontsize >$web_comment: -</font> </b></td>
<td width=300><font face= "$textfontface" size= $textfontsize>
$fields[6]</font></td></tr>
</table>
~;
}
print qq~
</font></td></tr>
~;
print qq~
</table><hr width=$table_width size=1>
~;
$count++;
if ($count >2)
{
$count = 1;
}
}
sub html_search_results_plain
{
$count = 1;
$number_of_messages = @hits;
@hits = reverse(@hits);
if ($search_flag ne "no")
{
if ($number_of_messages == 1)
{
print qq~ <br><font face= "$textfontface" size=$textfontsize><B>One guestbook message matches your search criteria.</B></font> ~;
}
else
{
print qq~ <br><font face= "$textfontface" size=$textfontsize><B>$number_of_messages guestbook messages match your search criteria.</B></font>~;
}
}
foreach $row (@hits)
{
#########
@fields = split (/\|/, $row);
# $grouped++;
# if (($grouped > ($start_number)) && ($grouped < ($start_number + $no_displayed + 1)))
# {
#&plain_table_results;
&main_table_results;
# } # end if number is right
} # end for each row
#########
}
sub bug
{
&content;
if (defined($ENV{'SERVER_NAME'})) {
$domain = 'http://'.$ENV{'SERVER_NAME'};
}
else {
$domain = 'http://www.myhost.com';
}
$ref = "$domain"."$guesturl"."&book=$book";
print qq~ <html><head><title>$title</title><META http-equiv="refresh" content="0; URL=http://www.active-scripts.net/cgi-bin/feedback_page.cgi?ref=$ref"> </head><body></body></html>
~;
exit;
}
sub already_added
{
unless (-e "$already_added")
{
open(COLFILE,">$already_added");
chmod(0755, "$already_added");
print COLFILE "\n";
close(COLFILE);
}
&read;
}
sub add_to_active
{
&content;
if (defined($ENV{'SERVER_NAME'})) {
$domain = 'http://'.$ENV{'SERVER_NAME'};
}
else {
$domain = 'http://www.myhost.com';
}
$ref = "$domain"."$guesturl"."&book=$book";
print qq~ <html><head><title>$title</title><META http-equiv="refresh" content="0; URL=http://www.active-scripts.net/cgi-bin/add_to_active.cgi?ref=$ref"> </head><body></body></html>
~;
exit;
}
sub newoptions
{
print qq~
<OPTION value="#eeeeee" > Active Grey
<OPTION value="#70db93" > Aquamarine
<OPTION value="#000000" > Black
<OPTION value="#0000ff" > Blue
<OPTION value="#a62a2a" > Brown
<OPTION value="#b87333" > Copper
<OPTION value="#ff7f00" > Coral
<OPTION value="#00ffff" > Cyan
<OPTION value="#871f78" > Dark Purple
<OPTION value="#97694f" > Dark Tan
<OPTION value="#238e23" > Forest Green
<OPTION value="#cd7f32" > Gold
<OPTION value="#00ff00" > Green
<OPTION value="#a8a8a8" > Grey
<OPTION value="#9f9f5f" > Khaki
<OPTION value="#808000" > Light Copper
<OPTION value="#cccccc" > Light Grey
<OPTION value="#ffffcc" > Light Yellow
<OPTION value="#32cd32" > Lime Green
<OPTION value="#ff00ff" > Magenta
<OPTION value="#8e236b" > Maroon
<OPTION value="#2f2f4f" > Midnight Blue
<OPTION value="#000080" > Navy Blue
<OPTION value="#ff7f00" > Orange
<OPTION value="#8fbc8f" > Pale Green
<OPTION value="#bc8f8f" > Pink
<OPTION value="#ff0000" > Red
<OPTION value="#e6e8fa" > Silver
<OPTION value="#3299cc" > Sky Blue
<OPTION value="#cc3299" > Violet
<OPTION value="#ffffff" > White
<OPTION value="#ffff00" > Yellow
<OPTION value="" > Other (type code)...
~;
}
sub approve_message
{
&seek_cook;
&get_file_lock("$location_of_lock_file");
$ref = $FORM{'ref'};
$start_number = $FORM{'start_number'};
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$powerbook_data_name");
foreach $row (@data)
{
@fields = split (/\|/, $row);
if ($ref ne $fields[0])
{
print USER_FILE "$row";
}
else
{
$guest_email = $fields[4];
print USER_FILE "$fields[0]|$fields[1]|$fields[2]|$fields[3]|$fields[4]|$fields[5]|$fields[6]|$fields[7]|$fields[8]|$fields[9]|$fields[10]|$fields[11]|$fields[12]|$fields[13]|$fields[14]||$fields[16]|$fields[17]|$fields[18]|$fields[19]|$fields[20]|$fields[21]|$fields[22]|$fields[23]|$fields[24]|$fields[25]|$fields[26]|$fields[27]|$fields[28]|$fields[29]|$fields[30]|$fields[31]|$fields[32]|$fields[33]|$fields[34]|$fields[35]|$fields[36]|$fields[37]|$fields[38]|$fields[39]|$fields[40]|$fields[41]|\n";
$conmessage = $fields[2];
}
# removes waiting from field 15
}
close(USER_FILE);
&release_file_lock("$location_of_lock_file");
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_to_edit&start_number=$start_number&vat=$varurl"> ~;
&main_headerb;
print qq~
<center>
</body>
</html>
~;
} # end approve
sub subdirectory
{

$capdir = "powerbookcap";
$cap = "./powerbookcap/cap.txt";

if ($book eq "")
 {
$powerbook_files_directory =  "active_powerbook_files" ;  #cannot change this or server won't work
$powerbook_backups_directory =  "active_powerbook_backups";

$nword = "./active_powerbook_files/bkup.txt";
}
 else
{
$powerbook_files_directory =  "$book" . "_". "active_powerbook_files" ;
$powerbook_backups_directory = "$book" . "_". "active_powerbook_backups";
$nword = "./$powerbook_files_directory/bkup.txt";
}

$htmlssi = "./active_powerbook_files/htmlssinew.txt";
$htmlssin = "./active_powerbook_files/htmlssin.txt";
$blocked_machines = "./active_powerbook_files/blocked.txt"; #blocked on all books

$location_of_lock_file = "./$powerbook_files_directory/powerbook.lock";
$already_added = "./$powerbook_files_directory/added.txt";

if ($SERVDATA{$book} eq "yes"){

 $powerbook_data_name = "./active_powerbook_files/powerbook_data.txt";
$counter_name = "./active_powerbook_files/counter.txt";

}
else{
$powerbook_data_name = "./$powerbook_files_directory/powerbook_data.txt";
$counter_name = "./$powerbook_files_directory/counter.txt";
}


$gbook_data_name = "./$powerbook_files_directory/guestbook_data.txt"; #used to copy data
$active_name = "./$powerbook_files_directory/active.txt";

if ($SERVACCESS{$book} eq "yes"){

$perms = "./active_powerbook_files/perms.txt";
$access_name = "./active_powerbook_files/individaccess.txt";
$singleperms = "./active_powerbook_files/singleperms.txt";

}
else{
$perms = "./$powerbook_files_directory/perms.txt";
$access_name = "./$powerbook_files_directory/individaccess.txt";
$singleperms = "./$powerbook_files_directory/singleperms.txt";
}

if ($SERVLAYOUT{$book} eq "yes"){
$layout_name = "./active_powerbook_files/layout_name.txt";
}
else{
$layout_name = "./$powerbook_files_directory/layout_name.txt";
}

if ($SERVMENU{$book} eq "yes"){
$menu_name = "./active_powerbook_files/menuprefs.txt";
}
else{
$menu_name = "./$powerbook_files_directory/menuprefs.txt";
}

if ($SERVFIELD{$book} eq "yes"){
$field_names = "./active_powerbook_files/field_names.txt";
}
else{
$field_names = "./$powerbook_files_directory/field_names.txt";
}

if ($SERVCOL{$book} eq "yes"){
$colprefs_name = "./active_powerbook_files/colprefs.txt";
}
else{
$colprefs_name = "./$powerbook_files_directory/colprefs.txt";
}

$colprefs_backup_name= "./$powerbook_files_directory/colprefs_backup.txt";


if ($SERVLANG{$book} eq "yes"){
$langprefs_name = "./active_powerbook_files/langprefs.txt";
$months_name = "./active_powerbook_files/months.txt";
$days_name = "./active_powerbook_files/days.txt";
}
else{
$months_name = "./$powerbook_files_directory/months.txt";
$langprefs_name = "./$powerbook_files_directory/langprefs.txt";
$days_name = "./$powerbook_files_directory/days.txt";
}


$langprefs_backup_name = "./$powerbook_files_directory/langprefs_backup.txt";
$gtp_backup_name = "./$powerbook_files_directory/gtp.txt";

$months_bak_name = "./$powerbook_files_directory/months_bak.txt";
$days_bak_name = "./$powerbook_files_directory/days_bak.txt";

 if ($SERVPREF{$book} eq "yes"){
$prefs_name = "./active_powerbook_files/prefs.txt";
$html_between_name = "./active_powerbook_files/html_between.txt";
$user_style_name = "./active_powerbook_files/user_style.txt";
$user_html_name = "./active_powerbook_files/user_html.txt";
$user_html_footer_name = "./active_powerbook_files/user_html_footer.txt";
}
else{
$prefs_name = "./$powerbook_files_directory/prefs.txt";
$html_between_name = "./$powerbook_files_directory/html_between.txt";
$user_style_name = "./$powerbook_files_directory/user_style.txt";
$user_html_name = "./$powerbook_files_directory/user_html.txt";
$user_html_footer_name = "./$powerbook_files_directory/user_html_footer.txt";
}

 if ($SERVDATE{$book} eq "yes"){
$user_date_file = "./active_powerbook_files/user_date_format.txt";
}
else{
$user_date_file = "./$powerbook_files_directory/user_date_format.txt";
}

$viewed = "./$powerbook_files_directory/viewed.txt";

$prefs_backup_name = "./$powerbook_files_directory/prefs_backup.txt";
$ip_name = "./active_powerbook_files/ip_limit.txt";

$senddate_name = "./$powerbook_files_directory/senddate.txt";
$tempcolprefs_name = "./$powerbook_files_directory/tempcolprefs.txt";
$update_name = "./$powerbook_files_directory/update.txt";

$user_default_html_name = "./$powerbook_files_directory/user_default_html.txt";
$user_default_html_footer_name = "./$powerbook_files_directory/user_default_html_footer.txt";



$userprefs_backup_name = "./$powerbook_files_directory/userprefs_backup.txt";
$usercolprefs_backup_name = "./$powerbook_files_directory/usercolprefs_backup.txt";

}
sub show_edit_number_menu
{
print qq~
$cgifont [
~;
# $number_of_messages = int($number_of_messages); # int here sorts out any funny decimals entered in the control panel
$number_of_pages = ($number_of_messages / $no_displayed) ;
$number_of_pages = int($number_of_pages); # no of full pages
if ($number_of_messages > ($number_of_pages * $no_displayed))
{
$extra = "yes";
}
if ($extra eq "yes")
{
$number_of_pages = $number_of_pages +1;
}
($start_number = 0) if (!$start_number);
for (my $x = 1; $x < $number_of_pages+1 ; $x++ )
{
$sn = (($x*$no_displayed)- $no_displayed);
$bottom = ($start_number - (11 * $no_displayed));
$top = ($start_number + (11 * $no_displayed));
if ((($sn > $bottom) && ($sn < $top)) || ($x == "1") || ($x == $number_of_pages))
{
if ($sn ne $start_number)
{
print qq~
<font face= "Arial" size=2><a href="$guesturl?book=$book&start_number=$sn&action=view_to_edit&vat=$varurl">$x</a></font>
~;
}
else
{
print qq~
<font face="Arial" size=2 color=#0000ff>$x</font>
~;
} # end else
}
} # end for
print qq~
] </font>
~;
} # end show menu
############
sub view_dateprefs
{
&seek_cook;
 if ($mastermanagemessagesonly eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>Access to this section is currently restricted.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
   }

if ($masterdate eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>These settings are currently controlled by the Master Control Panel.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
}

open(USER_FILE,"$user_date_file");
@date_data = <USER_FILE>;
close(USER_FILE);
foreach $row (@date_data)
{
(@datefields = split (/\,/, $row)) if ($row =~ /^date/);
(@spacefields = split (/\,/, $row)) if ($row =~ /^space/);
(@hours_offset = split (/\,/, $row)) if ($row =~ /^hours/);
(@clock_type = split (/\,/, $row)) if ($row =~ /^clock/);
}
($date0,$date1,$date2,$date3,$date4,$date5,$date6,$date7,$date8) = @datefields;
($space0,$space1,$space2,$space3,$space4,$space5,$space6,$space7) = @spacefields;
($hours0,$hours_offset,,,,,,) = @hours_offset;
($clock_type0,$clock_type,$amset,$pmset,,,,) = @clock_type;
@ro = ("se","mi","hr","d","dd","m","mm","y","am/pm","","");
$space1 =~ s/comma/,/gi;
$space2 =~ s/comma/,/gi;
$space3 =~ s/comma/,/gi;
$space4 =~ s/comma/,/gi;
$space5 =~ s/comma/,/gi;
$space6 =~ s/comma/,/gi;
$extra_secs = ($hours_offset*60*60);
$user_time = (time + $extra_secs);
($xsec,$xmin,$xhour,$xmday,$xmon,$xyear,$xwday,$xyday,$xisdst) = localtime($user_time);
$xmonth = $months[$xmon];
$xweekday = $daylist[$xwday];
$xmonthn = $xmon +1;
$xyear = $xyear +1900;
if ($xsec < 10) { $xsec = "0$xsec"; }
if ($xmin < 10) { $xmin = "0$xmin"; }
if ($xmonthn < 10) { $xmonthn = "0$xmonthn"; }
if ($clock_type == 12){
$timeofday = "$amset" if $xhour < 12;
$timeofday = "$pmset" if $xhour > 11;
$xhour = ($xhour-12) if $xhour > 12;
}
if ($xhour < 10) { $xhour = "0$xhour"; }
@dv = ($xsec,$xmin,$xhour,$xmday,$xweekday,$xmonthn,$xmonth,$xyear,$timeofday,,);
$new_user_date = "$dv[$date1]" . "$space1" . "$dv[$date2]". "$space2". "$dv[$date3]" . "$space3" . "$dv[$date4]" . "$space4" . "$dv[$date5]" . "$space5" . "$dv[$date6]" . "$space6" . "$dv[$date7]";
&content;
print qq~<HTML><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title>Active PowerBook $cptext Date Format Manager</title></head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600">
<center><font face=Arial>
<table cellpadding = 1 cellspacing = 0 width=800><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $cptext Date Format Manager</b></td></tr>
<tr><td width=100% align=center>
$cgifont
~;
&linkjump; print qq~ </td></tr></form>
<tr><td width=100% align=center>
<table><tr><td bgcolor=#cccccc align=center>
<font face=Arial>
<b>Current format:</b> $new_user_date </font>
<hr width=600 size=1> $cgifont Please enter your new date format</B>
<FORM ACTION="$guesturl" METHOD="POST" name="reportsettings"><input type=hidden name="book" value="$book">
<INPUT TYPE="hidden" NAME="action" VALUE="edit_dateprefs"><select name="date1"> ~;
$fo = $ro[$date1];
print qq~
<option value="$date1">$fo</option> ~;
&date_options;
print qq~
</select>
<input type="text" name="space1" value="$space1" size=2>
<select name="date2">
~;
$fo = $ro[$date2];
print qq~
<option value="$date2">$fo</option> ~;
&date_options;
print qq~
</select>
<input type="text" name="space2" value="$space2" size=2>
<select name="date3">
~;
$fo = $ro[$date3];
print qq~
<option value="$date3">$fo</option> ~;
&date_options;
print qq~
</select>
<input type="text" name="space3" value="$space3" size=2>
<select name="date4">
~;
$fo = $ro[$date4];
print qq~
<option value="$date4">$fo</option> ~;
&date_options;
print qq~
</select>
<input type="text" name="space4" value="$space4" size=2>
<select name="date5">
~;
$fo = $ro[$date5];
print qq~
<option value="$date5">$fo</option> ~;
&date_options;
print qq~
</select>
<input type="text" name="space5" value="$space5" size=2>
<select name="date6">
~;
$fo = $ro[$date6];
print qq~
<option value="$date6">$fo</option> ~;
&date_options;
print qq~
</select>
<input type="text" name="space6" value="$space6" size=2>
<select name="date7">
~;
$fo = $ro[$date7];
print qq~
<option value="$date7">$fo</option> ~;
&date_options;
$sell12 = ""; $sell24 = "";
$sell12 = "checked" if $clock_type == 12; $sell24 = "checked" if $clock_type == 24;
$act12 = ""; $act24 = "";
$act24 = "disabled" if $clock_type == 24;
print qq~
</select>
<br>
$cgifontHours offset from server - <input type="text" name="hours_offset" value="$hours_offset" size=3 maxlength = 3> - (e.g. +5, 0, -4)<br>
24hr <input type="radio" name="clock_type" value="24" $sell24 > - 12hr
<input type="radio" name="clock_type" value="12" $sell12 >
( AM text <input type=text size=2 name="amset" value="$amset"> - PM text <input type=text size=2 name="pmset" value="$pmset"> )
<br>
<input type="submit" value="Update format"></form>
</td></tr></table>
<hr width=600 size=1>
<table border=0>
<tr valign=top><td>$cgifont<b>Key: </b></td>
<td align=right><font face=Arial size=1>
y<br>
mm<br>
m<br>
dd<br>
d<br>
hr<br>
mi<br>
se
</td><td><font face=Arial size=1>
=<br>=<br>=<br>=<br>=<br>=<br>=<br>
=</td><td><font face=Arial size=1>
year ($xyear)<br>
month name ($monthlist[0]-$monthlist[11])<br>
month number (1-12)<br>
weekday ($daylist[0]-$daylist[6])<br>
month day (1-31)<br>
hour (0-24)<br>
minute (0-60)<br>
second (0-60)
</td></tr></table> <hr width=600 size=1><font face=Arial>
<b>Examples...</b></font>
<br>
$cgifont
<img src="http://www.active-scripts.net/help/example2.gif"><br>
($daylist[$xwday] $monthlist[$xmon] $xmday $xyear $xhour:$xmin:$xsec)
<hr width=600 size=1>
<img src="http://www.active-scripts.net/help/example1.gif"><br>
($xmonthn/$xmday/$xyear)
</td></tr></table></td></tr></table></td></tr></table>
~;
&inter_footer;
}
sub date_options
{
print qq~
<option value="9"></option>
<option value="8">am/pm</option>
<option value="7">y</option>
<option value="6">mm</option>
<option value="5">m</option>
<option value="4">dd</option>
<option value="3">d</option>
<option value="2">hr</option>
<option value="1">mi</option>
<option value="0">se</option>
~;
}
sub edit_dateprefs
{
$date1 = $FORM{'date1'};
$date2 = $FORM{'date2'};
$date3 = $FORM{'date3'};
$date4 = $FORM{'date4'};
$date5 = $FORM{'date5'};
$date6 = $FORM{'date6'};
$date7 = $FORM{'date7'};
$space1 = $FORM{'space1'};
$space2 = $FORM{'space2'};
$space3 = $FORM{'space3'};
$space4 = $FORM{'space4'};
$space5 = $FORM{'space5'};
$space6 = $FORM{'space6'};
$clock_type = $FORM{'clock_type'};
$amset = $FORM{'amset'};
$pmset = $FORM{'pmset'};
$space1 =~ s/\,/comma/gi;
$space2 =~ s/\,/comma/gi;
$space3 =~ s/\,/comma/gi;
$space4 =~ s/\,/comma/gi;
$space5 =~ s/\,/comma/gi;
$space6 =~ s/\,/comma/gi;
$hours_offset = $FORM{'hours_offset'};
if (($space1 =~ /\|/) || ($space2 =~ /\|/) || ($space3 =~ /\|/) || ($space4 =~ /\|/) || ($space5 =~ /\|/) || ($space6 =~ /\|/) )
{
&basic_header;
print qq~
<center> $cgifont2 $title<p></font> $cgifont
<b> You can not use a pipe "|" character in a date format. Please <a href="javascript:history.go(-1)">go back and edit</a>. </b></font>
~;
exit;
}
if (($date1 eq "9") && ($date2 eq "9") && ($date3 eq "9") && ($date4 eq "9") && ($date5 eq "9") && ($date6 eq "9") && ($date7 eq "9"))
{
&basic_header;
print qq~
<center> $cgifont2 $title<p></font> $cgifont
<b> You didn't select a valid date format. Please <a href="javascript:history.go(-1)">go back and edit</a>. </b></font>
~;
exit;
}
open(UPDATE,">$user_date_file");
print UPDATE "date,$date1,$date2,$date3,$date4,$date5,$date6,$date7,,\n";
print UPDATE "space,$space1,$space2,$space3,$space4,$space5,$space6,,\n";
print UPDATE "hours,$hours_offset,,,,,,,\n";
print UPDATE "clock,$clock_type,$amset,$pmset,,,,,\n";
close(UPDATE);
&content;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_dateprefs&vat=$varurl"> ~;
&main_headerb;
print qq~
<center>
~;
&inter_footer;
}
sub convert_dates
{
open(USER_FILE,"$user_date_file");
@date_data = <USER_FILE>;
close(USER_FILE);
foreach $row (@date_data)
{
(@datefields = split (/\,/, $row)) if ($row =~ /^date/);
(@spacefields = split (/\,/, $row)) if ($row =~ /^space/);
(@hours_offset = split (/\,/, $row)) if ($row =~ /^hours/);
(@clock_type = split (/\,/, $row)) if ($row =~ /^clock/);
}
($date0,$date1,$date2,$date3,$date4,$date5,$date6,$date7,$date8) = @datefields;
($space0,$space1,$space2,$space3,$space4,$space5,$space6,$space7) = @spacefields;
($hours0,$hours_offset,,,,,,) = @hours_offset;
($clock_type0,$clock_type,$amset,$pmset,,,,) = @clock_type;
@ro = ("se","mi","hr","d","dd","m","mm","y","am/pm","","");
$space1 =~ s/comma/,/gi;
$space2 =~ s/comma/,/gi;
$space3 =~ s/comma/,/gi;
$space4 =~ s/comma/,/gi;
$space5 =~ s/comma/,/gi;
$space6 =~ s/comma/,/gi;
$rrr = $rrr + ($hours_offset*60*60);
($xsec,$xmin,$xhour,$xmday,$xmon,$xyear,$xwday,$xyday,$xisdst) = localtime($rrr);
$xmonth = $months[$xmon];
$xweekday = $daylist[$xwday];
$xmonthn = $xmon +1;
$xyear = $xyear +1900;
if ($xsec < 10) { $xsec = "0$xsec"; }
if ($xmin < 10) { $xmin = "0$xmin"; }
if ($xmonthn < 10) { $xmonthn = "0$xmonthn"; }
if ($clock_type == 12)
{
$timeofday = "$amset" if $xhour < 12;
$timeofday = "$pmset" if $xhour > 11;
$xhour = ($xhour-12) if $xhour > 12;
}
if ($xhour < 10) { $xhour = "0$xhour"; }
@dv = ($xsec,$xmin,$xhour,$xmday,$xweekday,$xmonthn,$xmonth,$xyear,$timeofday,,);
$condate = "$dv[$date1]" . "$space1" . "$dv[$date2]". "$space2". "$dv[$date3]" . "$space3" . "$dv[$date4]" . "$space4" . "$dv[$date5]" . "$space5" . "$dv[$date6]" . "$space6" . "$dv[$date7]";
}
sub date_mod
{
if (($fields[3] > 101352702) && ($fields[3] < 999999999101352702))
{
$rrr = $fields[3];
&convert_dates;
}
else
{
$condate = $fields[3];
}
}
sub mygmtime {
@monthsa = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug",
"Sep","Oct","Nov","Dec");
@daysa = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
# (time) would be now, so we want to set it to expire sometime
# later. here we expire it in 365 days.
my ($seca,$mina,$hra,$mdaya,$mona,$yra,$wdaya,$ydaya,$isdsta) = gmtime(time + (86400*365));
$timestr = sprintf("%3s, %02d-%3s-%4d %02d:%02d:%02d GMT", $daysa[$wdaya],$mdaya,$monthsa[$mona],$yra+1900,$hra,$mina,$seca);
my ($seca,$mina,$hra,$mdaya,$mona,$yra,$wdaya,$ydaya,$isdsta) = gmtime(time + (3600*$hourstoedit));
$timestr2 = sprintf("%3s, %02d-%3s-%4d %02d:%02d:%02d GMT", $daysa[$wdaya],$mdaya,$monthsa[$mona],$yra+1900,$hra,$mina,$seca);
$expdate = $timestr;
$expdate2 = $timestr2;
}
sub mygmtime2 {
@monthsa = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug",
"Sep","Oct","Nov","Dec");
@daysa = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
# (time) would be now, so we want to set it to expire sometime
# later. here we expire it in 365 days.
($seca,$mina,$hra,$mdaya,$mona,$yra,$wdaya,$ydaya,$isdsta) = gmtime(time + (3600*$hourstoedit));
# format must be Wed, DD-Mon-YYYY HH:MM:SS GMT
$timestr2 = sprintf("%3s, %02d-%3s-%4d %02d:%02d:%02d GMT",$daysa[$wdaya],$mdaya,$monthsa[$mona],$yra+1900,$hra,$mina,$seca);
return $timestr2;
}
sub checklate
{
unless (-e "$powerbook_backups_directory") # check to see if this is a first install
{
# is not a first install, so check if new field names exist
unless (-e "$field_names")
{
# they don't exist, so therefore it must be an upgrade, so we must get the old field names
open(LANGFILE,"$langprefs_name");
@LANGLINES = <LANGFILE>;
close(LANGFILE);
foreach $LANGLINE (@LANGLINES)
{
@langterms = split(/=/,$LANGLINE);
$LANGPREFS{$langterms[0]} = $langterms[1];
}
$TXT_your_name = $LANGPREFS{'TXT_your_name'};
$TXT_your_message = $LANGPREFS{'TXT_your_message'};
$TXT_required = $LANGPREFS{'TXT_required'};
$TXT_where_in_the_world = $LANGPREFS{'TXT_where_in_the_world'};
$TXT_your_email_address = $LANGPREFS{'TXT_your_email_address'};
$TXT_your_web_page_address = $LANGPREFS{'TXT_your_web_page_address'};

}
}
}
sub view_layoutprefs
{
&seek_cook;
 if ($mastermanagemessagesonly eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>Access to this section is currently restricted.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
    }
if ($masterfield eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>These settings are currently controlled by the Master Control Panel.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
}

if ($FORM{'action'} eq "active_inactive")
{
open(USER_FILE,"$field_names");
@layout_data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$field_names");
foreach $row (@layout_data)
{
@fs = split (/\|/, $row);
if ($fs[12] eq $FORM{'field'})
{
$change = "yes" if ($fs[21] ne "yes");
$change = "no" if ($fs[21] eq "yes");

for (my $x = 0; $x < 70; $x++){
  if ($x == 21)
  {
   print USER_FILE "$change|";
  }
  else
  {
   print USER_FILE "$fs[$x]|";
  }
  }

print USER_FILE "\n";
}
else
{
print USER_FILE "$row";
}
}
close(USER_FILE);
}
elsif ($FORM{'action'} eq "pub_priv")
{
open(USER_FILE,"$field_names");
@layout_data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$field_names");
foreach $row (@layout_data)
{
@fs = split (/\|/, $row);
if ($fs[12] eq $FORM{'field'})
{
$change = "yes" if ($fs[13] ne "yes");
$change = "no" if ($fs[13] eq "yes");

for (my $x = 0; $x < 70; $x++){
  if ($x == 13)
  {
   print USER_FILE "$change|";
  }
  else
  {
   print USER_FILE "$fs[$x]|";
  }
  }

print USER_FILE "\n";

}
else
{
print USER_FILE "$row";
}
}
close(USER_FILE);
}

open(USER_FILE,"$field_names");
@layout_data = <USER_FILE>;
close(USER_FILE);
@layout_data = sort(@layout_data);
$colorhere = "black";
&content;
print qq~
<HTML><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>$title</title>
~;
if ($style ne "no"){
print qq~ $user_style ~;
}
print qq~
</head>
<body bgcolor=#ffffff text="#000000">
~;
print qq~
<center>
<table cellpadding = 1 cellspacing = 0 width=800><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>

<tr><td width=100% colspan=14 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $cptext Message Layout Manager</b></td></tr>
<tr><td colspan=10 align="center">$cgifont ~;
&linkjump; print qq~ - <a href="#sample"><font color=$colorhere>Sample</font></a> </td></tr> </form>
</table></td></tr></table> </td></tr></table>
<table cellpadding = 1 cellspacing = 0 width=800><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
~;
$bbod = "Header";
$kk = 0;
foreach $row (@layout_data)
{
@layoutfields = split (/\|/, $row);
$kk++;
$act = "Inactive";
$act = "Active" if ($layoutfields[21] eq "yes");
$pub = "Public";
$pub = "Private" if ($layoutfields[13] eq "yes");
$pub = "" if ($act eq "Inactive");
$co = "red";
$co = "blue" if ($layoutfields[21] eq "yes");
$bbod = "Body" if ($layoutfields[14] eq "break");
print qq~ <tr valign=top><td>$cgifont$kk </td><td><font face=Arial size=2 color=$co>~;
if ($layoutfields[2] eq "ADD RESPONSE"){
$pub = ""; $act = "";
print "<i>Add Response</i>";
}
elsif ($layoutfields[2] eq "VIEW RESPONSES"){
print "<i>View Responses</i>";
$pub = ""; $act = "";
}
elsif ($layoutfields[2] eq "EDIT"){
print "<i>Edit Message</i>";
$pub = ""; $act = "";
}
elsif ($layoutfields[2] eq "PRIVATE_OPTION"){
print "<i>Private Message Option </i>";
$pub = ""; $act = "";
}
elsif ($layoutfields[2] ne "date")
{
print "$layoutfields[1]";
}
else
{
$pub = "";
print "<i>Date</i>";
}
print qq~</td>
<td><font face=Arial size=2 color=$co>~;
if ($layoutfields[2] eq "ADD RESPONSE"){
print "<i>Add Response</i>";
}
elsif ($layoutfields[2] eq "VIEW RESPONSES"){
print "<i>View Responses</i>";
}
elsif ($layoutfields[2] eq "EDIT"){
print "<i>Edit Message</i>";
$pub = ""; $act = "";
}
elsif ($layoutfields[2] eq "PRIVATE_OPTION"){
print "<i>Private Message</i>";
}
elsif ($layoutfields[2] ne "date")
{
print "$layoutfields[2]";
}
else
{
print "<i>Message Date</i>";
}
print qq~</td>
<td><font face=Arial size=2 color=$co><a href="$guesturl?book=$book&action=active_inactive&field=$layoutfields[12]&vat=$varurl"><font color=$colorhere>$act</font></a></td>
<td><font face=Arial size=2 color=$co><a href="$guesturl?book=$book&action=pub_priv&field=$layoutfields[12]&vat=$varurl"><font color=$colorhere>$pub</font></a></td>
<td><font face=Arial size=2 color=$co><a href="$guesturl?book=$book&action=make_first_body&field=$layoutfields[12]&vat=$varurl"><font color=$colorhere>$bbod</font></a>
</td>
<td><font face=Arial size=2 color=$co><a href="$guesturl?book=$book&action=view_to_edit_a_field&field=$layoutfields[12]&vat=$varurl"><font color=$colorhere>EDITOR</font></a>
</td>
<td >
~;
unless ($kk == 1)
{
print qq~ <font face=Arial size=2 color=$co><a href="$guesturl?book=$book&action=move_up&field=$layoutfields[12]&vat=$varurl"><font color=$colorhere>Up</font></a> ~;
}
print qq~ </td><td >~;
unless ($kk == 20)
{
print qq~ <font face=Arial size=2 color=$co> <a href="$guesturl?book=$book&action=move_down&field=$layoutfields[12]&vat=$varurl"><font color=$colorhere>Down</font></a> ~;
}
print qq~
</td> ~;
if ($layoutfields[2] eq "PRIVATE_OPTION"){
print qq~ <td><font face=Arial size=2 color=$co>(<b>only</b> appears in Add page)</td> ~;
}
elsif ($layoutfields[2] eq "ADD RESPONSE"){
print qq~ <td><font face=Arial size=2 color=$co>(<b>only</b> appears if access allows)</td> ~;
}
elsif ($layoutfields[2] eq "EDIT"){
print qq~ <td><font face=Arial size=2 color=$co>(appears if within allowed edit period)</td> ~;
}
elsif ($layoutfields[2] eq "VIEW RESPONSES"){
print qq~ <td><font face=Arial size=2 color=$co>(<b>only</b> appears if responses exist)</td> ~;
}
elsif ($layoutfields[50] eq "yes"){
print qq~ <td><font face=Arial size=2 color=$co>(entry currently limited to webmaster)</td> ~;
}



print qq~</tr>
~;
}

print qq~ </table></td></tr></table> </td></tr></table>
~;
######## put in sample
$guess = "indeed";
print qq~ <p><table cellpadding = 1 cellspacing = 0 width=800><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Sample message</b><br>Note that the sample given is only a guide. Please check main page to see how the message will actually look.</td></tr></table></td></tr></table></td></tr></table>
<table width=95%><tr><td align=center ~;
if ($usebackgroundimage eq "yes")
{
print qq~ background = "$backgroundimage" ~;
}
elsif ($usebackgroundimage ne "yes")
{
print qq~ BGCOLOR="$backcolor" ~;
}
print qq~ >  ~;

&main_table_results;

print qq~ </td></tr></table>  ~;
print qq~ <a name="sample"></a>
~;
}
sub move_up
{
&seek_cook;
$addmove = $FORM{'addmove'};
$sortfield = "0";
$sortfield = "36" if ($addmove eq "yes");
open(USER_FILE,"$field_names");
@layout_data = <USER_FILE>;
close(USER_FILE);
$field = $FORM{'field'};
my $min = "10000001";
my $max = "10000020";
foreach $row (@layout_data)
{
@layoutfields = split (/\|/, $row);
$current = $layoutfields[$sortfield] if ($field eq "$layoutfields[12]");
}
$one_up = $current - 1;
if ($one_up < $min)
{
&view_layoutprefs if $addmove ne "yes";
&view_addlayoutprefs if $addmove eq "yes";
exit;
}
open(USER_FILE,">$field_names");
foreach $row (@layout_data)
{
@fs = split (/\|/, $row);
if ($fs[$sortfield] eq $current)
{
if ($addmove eq "yes")
{

for (my $x = 0; $x < 70; $x++){
  if ($x == 36)
  {
   print USER_FILE "$one_up|";
  }
  else
  {
   print USER_FILE "$fs[$x]|";
  }
  }

print USER_FILE "\n";
}
else
{

 for (my $x = 0; $x < 70; $x++){
  if ($x == 0)
  {
   print USER_FILE "$one_up|";
  }
  else
  {
   print USER_FILE "$fs[$x]|";
  }
  }
print USER_FILE "\n";
}
}
elsif ($fs[$sortfield] eq $one_up)
{
if ($addmove eq "yes")
{

for (my $x = 0; $x < 70; $x++){
  if ($x == 36)
  {
   print USER_FILE "$current|";
  }
  else
  {
   print USER_FILE "$fs[$x]|";
  }
  }

print USER_FILE "\n";
}
else
{
for (my $x = 0; $x < 70; $x++){
  if ($x == 0)
  {
   print USER_FILE "$current|";
  }
  else
  {
   print USER_FILE "$fs[$x]|";
  }
  }

print USER_FILE "\n";
}
}
else
{
print USER_FILE "$row";
}
}
close(USER_FILE);
if ($addmove eq "yes") {
&view_addlayoutprefs;
} else {
&view_layoutprefs;
}
}
sub move_down
{
my $min = "10000001";
my $max = "10000020";
&seek_cook;
$addmove = $FORM{'addmove'};
open(USER_FILE,"$field_names");
@layout_data = <USER_FILE>;
close(USER_FILE);
$field = $FORM{'field'};
$sortfield = "0";
$sortfield = "36" if ($addmove eq "yes");
foreach $row (@layout_data)
{
@layoutfields = split (/\|/, $row);
$current = $layoutfields[$sortfield] if ($field eq "$layoutfields[12]");
}
$one_up = $current + 1;
if ($one_up > $max)
{
&view_layoutprefs if $addmove ne "yes";
&view_addlayoutprefs if $addmove eq "yes";
exit;
}
open(USER_FILE,">$field_names");
foreach $row (@layout_data)
{
@fs = split (/\|/, $row);
if ($fs[$sortfield] eq $current)
{
if ($addmove eq "yes")
{
for (my $x = 0; $x < 70; $x++){
  if ($x == 36)
  {
   print USER_FILE "$one_up|";
  }
  else
  {
   print USER_FILE "$fs[$x]|";
  }
  }
print USER_FILE "\n";

}
else
{

for (my $x = 0; $x < 70; $x++){
  if ($x == 0)
  {
   print USER_FILE "$one_up|";
  }
  else
  {
   print USER_FILE "$fs[$x]|";
  }
  }
print USER_FILE "\n";

}
}
elsif ($fs[$sortfield] eq $one_up)
{
if ($addmove eq "yes")
{
for (my $x = 0; $x < 70; $x++){
  if ($x == 36)
  {
   print USER_FILE "$current|";
  }
  else
  {
   print USER_FILE "$fs[$x]|";
  }
  }
print USER_FILE "\n";
}
else
{
 for (my $x = 0; $x < 70; $x++){
  if ($x == 0)
  {
   print USER_FILE "$current|";
  }
  else
  {
   print USER_FILE "$fs[$x]|";
  }
  }
print USER_FILE "\n";
}
}
else
{
print USER_FILE "$row";
}
}
close(USER_FILE);
if ($addmove eq "yes") {
&view_addlayoutprefs;
} else {
&view_layoutprefs;
}
}
sub view_to_edit_a_field
{
&seek_cook;
open(USER_FILE,"$field_names");
@layout_data = <USER_FILE>;

close(USER_FILE);
$field = $FORM{'field'};
foreach $row (@layout_data)
{
@la = split (/\|/, $row);
if ($field eq "$la[12]")
{
for ($x = 0; $x < 70; $x++)
{
$la[$x] =~ s/PIPEPIPE/\|/gi;
}
$y20 = ""; $y20 = "checked" if ($la[20] eq "yes"); $y13 = ""; $y13 = "checked" if ($la[13] eq "yes");
$y37 = ""; $y37 = "checked" if ($la[37] eq "yes"); $y62 = ""; $y62 = "checked" if ($la[62] eq "yes");
$y29 = ""; $y29 = "checked" if ($la[29] eq "yes"); $y30 = ""; $y30 = "checked" if ($la[30] eq "yes");
$y27 = ""; $y27 = "checked" if ($la[27] eq "yes"); $y26 = ""; $y26 = "checked" if ($la[26] eq "yes");
$y25 = ""; $y25 = "checked" if ($la[25] eq "yes"); $y60 = ""; $y60 = "checked" if ($la[60] eq "yes");
$y59 = ""; $y59 = "checked" if ($la[59] eq "yes"); $y58 = ""; $y58 = "checked" if ($la[58] eq "yes");
$y21 = ""; $y21 = "checked" if ($la[21] eq "yes"); $y43 = ""; $y43 = "checked" if ($la[43] eq "yes");
$y45 = ""; $y45 = "checked" if ($la[45] eq "yes"); $y49 = ""; $y49 = "checked" if ($la[49] eq "yes");
$y50 = ""; $y50 = "checked" if ($la[50] eq "yes");


$checkalignl = "checked" if ($la[28] eq "left"); $checkalignc = "checked" if ($la[28] eq "center");
$checkalignr = "checked" if ($la[28] eq "right");


$checkalignl2 = "checked" if ($la[61] eq "left");
$checkalignc2 = "checked" if ($la[61] eq "center"); $checkalignr2 = "checked" if ($la[61] eq "right");

$tableallcheckalignl = "checked" if ($la[63] eq "left");
$tableallcheckalignc = "checked" if ($la[63] eq "center"); $tableallcheckalignr = "checked" if ($la[63] eq "right");


$checkv = "checked" if ($la[15] eq "v");
$checkh = "checked" if ($la[15] eq "h");
$firstbody = "h" if ($la[15] eq "h");
$firstbody = "v" if ($la[15] eq "v");
$checkradiov = "checked" if ($la[11] eq "v");
$checkradioh = "checked" if ($la[11] eq "h");

$checkhyperadd = "checked" if ($la[31] eq "address");
$checkhypertext = "checked" if ($la[31] eq "text");
$checkhyperimage = "checked" if ($la[31] eq "image");
$checkhyperaltfield = "checked" if ($la[31] eq "altfield");
#@fieldtypes = ("TEXT","EMAIL","URL","TEXTAREA","IMAGE","FILE","CHECK","SELECT","RADIO","TABLE","DATE","date");

@fieldtypes = ("TEXT","EMAIL","URL","TEXTAREA","IMAGE","FILE","CHECK","SELECT","RADIO","TABLE","date");
&content;
print qq~
<HTML><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>Active PowerBook</title>
</head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600">
~;
print qq~

<script LANGUAGE="JavaScript">
<!--
function urlMenu(that) {
theURL = that.options[that.selectedIndex].value;
if (theURL) {
window.location = "$guesturl?book=$book&action=view_to_edit_a_field&fieldtypetemp=" + theURL + "&field=$la[12]&vat=$varurl";
}
}
//-->
</SCRIPT>
<center>
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $cptext Field Editor</b></td></tr>
<tr><td width=100% align=center>~;
&linkjump;
print qq~ </td></tr></form>
<form action="$guesturl" METHOD="POST" >
</table></td></tr></table></td></tr></table>
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
<input type=hidden name="12" value="$la[12]">
<input type=hidden name="14" value="$la[14]">
<tr><td>$cgifont<b>Field Type:</b> </td>
<td>$cgifont ~;
$temptype = $la[2];
$temptype =$FORM{'fieldtypetemp'} if ($FORM{'fieldtypetemp'});
if ($la[2] eq "PRIVATE_OPTION"){
print qq~ <b>Private Message Option Box</b> ~;
}
elsif ($la[2] eq "ADD RESPONSE"){
print qq~ <b>Add Response Button</b> ~;
}
elsif ($la[2] eq "VIEW RESPONSES"){
print qq~ <b>View Responses Button</b> ~;
}
elsif ($la[2] eq "EDIT"){
print qq~ <b>Edit Message Button</b> ~;
}
else { print qq~
<select name ="2" ONCHANGE="urlMenu(this);">~;
foreach $row (@fieldtypes){
print qq~ <option value="$row" ~;
print "selected" if ($row eq "$temptype");
$actrow = $row;
$actrow = "Message date" if $row eq "date";
print ">$actrow</option>\n";
}
print qq~ </select> ~;
}

print qq~</td></tr>~;



if ($temptype eq "date")
{
print qq~ <tr><td colspan=2>$cgifont<i>Message date structure is set in the Date Format Manager</i> </td>
</tr>
<input name="1" type=hidden size=40 value="$la[1]"><input name="3" type=hidden size=40 value="$la[3]">
<input name="4" type=hidden size=40 value="$la[4]"><input name="5" type=hidden size=40 value="$la[5]">
<input name="6" type=hidden size=40 value="$la[6]"><input name="7" type=hidden size=40 value="$la[7]">
<input name="8" type=hidden size=40 value="$la[8]"><input name="9" type=hidden size=40 value="$la[9]">
<input name="10" type=hidden size=40 value="$la[10]"><input name="11" type=hidden size=40 value="$la[11]">
<input name="29" type=hidden size=40 value="$la[29]"><input name="30" type=hidden size=40 value="$la[30]">
<input name="31" type=hidden size=40 value="$la[31]"><input name="32" type=hidden size=40 value="$la[32]">
<input name="33" type=hidden size=40 value="$la[33]">
~;
}
else{
unless (($temptype eq "ADD RESPONSE")||($temptype eq "EDIT")
||($temptype eq "VIEW RESPONSES")||($temptype eq "PRIVATE_OPTION") ){
&vef_fname;
}

unless (($temptype eq "ADD RESPONSE")||($temptype eq "EDIT")
||($temptype eq "VIEW RESPONSES") || ($temptype eq "VIEW RESPONSES") || ($temptype eq "VIEW RESPONSES") ){
&vef_class;
}

unless (($temptype eq "ADD RESPONSE")||($temptype eq "EDIT")
||($temptype eq "VIEW RESPONSES")||($temptype eq "PRIVATE_OPTION") || ($temptype eq "date") ){
&vef_limit_entry;
}
unless (($temptype eq "ADD RESPONSE")||($temptype eq "EDIT")
||($temptype eq "VIEW RESPONSES")||($temptype eq "PRIVATE_OPTION") ){
&vef_active;
}
if (($temptype eq "IMAGE")|| ($temptype eq "FILE")){
&vef_max_file_size;
if ($temptype eq "IMAGE")
{
print qq~ <tr valign=middle><td>$cgifont<b>Use fixed dimensions?:</b> </td>
<td>$cgifont <input type=checkbox name="43" value=yes $y43><input name="43h" type=hidden value="active"> -
Width: <input name="41" type=text size=3 value="$la[41]"> -
Height: <input name="42" type=text size=3 value="$la[42]"></td>
</tr> ~;


}
if ($temptype eq "FILE")
{
print qq~
<tr><td>$cgifont<b>Hyperlink appearance:</b> </td>
<td> $cgifont
filename <input type="radio" name="31" value="address" $checkhyperadd> -
text <input type="radio" name="31" value="text" $checkhypertext> -
image <input type="radio" name="31" value="image" $checkhyperimage> -<br>
alternative field <input type="radio" name="31" value="altfield" $checkhyperaltfield>

<select name="51"><option value="">Choose field</option>~;

  open(USER_FILE,"$field_names");
@fdata = <USER_FILE>;
close(USER_FILE);
foreach $frow (@fdata){
@ffields = split (/\|/, $frow);


next if (($ffields[21] ne "yes") || ($ffields[2] eq "ADD RESPONSE")||($ffields[2] eq "EDIT")
||($ffields[2] eq "VIEW RESPONSES")||($ffields[2] eq "PRIVATE_OPTION")) ;

if (($ffields[2] eq "TEXT") ||($ffields[2] eq "IMAGE") )  {
$optext =  $ffields[1];
$optext =  $ffields[2] if $ffields[2] eq "date";
print qq~ <option value="$ffields[12]" ~;
print "selected" if  $ffields[12] eq $la[51];
print qq~>$optext</option>~;
}
}
print qq~</select></td></tr>
<tr><td>$cgifont<b>Hyperlink text:</b> </td> <td>$cgifont<input name="32" type=text size=40 value="$la[32]"> </td></tr>
<tr><td>$cgifont<b>Hyperlink image:</b> </td> <td>$cgifont<input name="33" type=text size=40 value="$la[33]"> </td></tr>
<tr><td>$cgifont<b>Font Type:</b> </td> <td>$cgifont<input name="22" type=text size=10 value="$la[22]"> </td></tr>
<tr><td>$cgifont<b>Font Size:</b> </td> <td>$cgifont<input name="23" type=text size=10 value="$la[23]"> </td></tr>
<tr><td>$cgifont<b>Underline:</b> </td>
<td>$cgifont<input type=checkbox name="25" value=yes $y25><input name="25h" type=hidden value="active"></td></tr>
<tr><td>$cgifont<b>Bold:</b> </td>
<td>$cgifont<input type=checkbox name="26" value=yes $y26><input name="26h" type=hidden value="active"></td></tr>
<tr><td>$cgifont<b>Italic:</b> </td>
<td>$cgifont<input type=checkbox name="27" value=yes $y27><input name="27h" type=hidden value="active"></td></tr>
~;
}
print qq~<tr><td>$cgifont<b>Allowed types:</b> </td> <td>$cgifont<input name="44" type=text size=40 value="$la[44]"> </td></tr>
<tr><td>$cgifont<b>Required?:</b> </td>
<td>$cgifont<input type=checkbox name="20" value=yes $y20><input name="20h" type=hidden value="active"> </td></tr>
<tr><td>$cgifont<b>Keep private?:</b> </td>
<td>$cgifont<input type=checkbox name="13" value=yes $y13><input name="13h" type=hidden value="active"> </td></tr>
~;
print qq~
<tr><td>$cgifont<b>Follows previous field: </b> </td>
<td>$cgifont ~;
if ($la[14] eq "break") {
print qq~ vertically - currently start of body section <input type="hidden" name="15" value="$firstbody" > ~;
}
else {
print qq~ vertically <input type="radio" name="15" value="v" $checkv> - horizontally <input type="radio" name="15" value="h" $checkh> ~;
}
print qq~ </td></tr> ~;

unless ($temptype eq "TABLE"){

if ($checkh ne "checked") {
print qq~
<tr><td>$cgifont<b>Alignment:</b> </td> <td>$cgifont
left <input type="radio" name="28" value="left" $checkalignl> - center <input type="radio" name="28" value="center" $checkalignc> - right <input type="radio" name="28" value="right" $checkalignr>
</td></tr> ~;
}

}

print qq~
<tr><td>$cgifont<b>Text/html before (Main page):</b> </td> <td>$cgifont<input name="18" type=text size=40 value="$la[18]">
<input name="18h" type=hidden value="active"></td></tr>
<tr><td>$cgifont<b>Text/html after (Main page:</b> </td> <td>$cgifont<input name="17" type=text size=40 value="$la[17]">
<input name="17h" type=hidden value="active"> </td></tr>   ~;


unless ($temptype eq "date")
 {
print qq~<tr><td>$cgifont<b>Use field title in Add page:</b> </td>
<td>$cgifont<input type=checkbox name="49" value=yes $y49><input name="49h" type=hidden value="active"></td></tr>
 <tr><td>$cgifont<b>Text before (Add/Respond page):</b> </td> <td>$cgifont<input name="48" type=text size=40 value="$la[48]">
<input name="48h" type=hidden value="active"></td></tr>~;
}
unless (($temptype eq "PRIVATE_OPTION") || ($temptype eq "TABLE")){
&vef_overridecolor;
}
print qq~
<tr><td colspan=2>$cgifont<input type=hidden name="book" value="$book">
<INPUT TYPE="hidden" NAME="action" VALUE="edit_field_details"><input type=submit value="Update"></td> </td></tr>~;

print "</form></table>";
exit;
}


if (($temptype eq "TEXT") || ($temptype eq "EMAIL") || ($temptype eq "URL") )
{

print qq~
<tr><td>$cgifont<b>Field Width:</b> </td> <td>$cgifont<input name="3" type=text size=3 value="$la[3]"> </td></tr>
<tr><td>$cgifont<b>Maximum characters:</b> </td> <td>$cgifont<input name="4" type=text size=3 value="$la[4]"> </td></tr>
<tr><td>$cgifont<b>Keep private?:</b> </td>
<td>$cgifont<input type=checkbox name="13" value=yes $y13><input name="13h" type=hidden value="active"> </td></tr>
~;
if (($temptype eq "EMAIL") || ($temptype eq "URL"))
{
print qq~
<tr><td>$cgifont<b>Use hyperlink?:</b> </td>
<td>$cgifont<input type=checkbox name="29" value=yes $y29><input name="29h" type=hidden value="active"></td></tr>
<tr><td>$cgifont<b>Hyperlink format:</b> </td>
<td> $cgifont
address <input type="radio" name="31" value="address" $checkhyperadd> -
text <input type="radio" name="31" value="text" $checkhypertext> -
image <input type="radio" name="31" value="image" $checkhyperimage> -<br>
alternative field <input type="radio" name="31" value="altfield" $checkhyperaltfield>

<select name="51"><option value="">Choose field</option>~;

open(USER_FILE,"$field_names");
@fdata = <USER_FILE>;
close(USER_FILE);


foreach $frow (@fdata){
@ffields = split (/\|/, $frow);
next if (($ffields[21] ne "yes") || ($ffields[2] eq "ADD RESPONSE")||($ffields[2] eq "EDIT")
||($ffields[2] eq "VIEW RESPONSES")||($ffields[2] eq "PRIVATE_OPTION")) ;

if (($ffields[2] eq "TEXT") ||($ffields[2] eq "IMAGE") )  {

          $optext =  $ffields[1];
          $optext =  $ffields[2] if $ffields[2] eq "date";

    print qq~ <option value="$ffields[12]" ~;

      print "selected" if  $ffields[12] eq $la[51];

    print qq~>$optext</option>~;

   }
}

print qq~</select></td></tr>
<tr><td>$cgifont<b>Hyperlink text:</b> </td> <td>$cgifont<input name="32" type=text size=40 value="$la[32]"> </td></tr>
<tr><td>$cgifont<b>Hyperlink image:</b> </td> <td>$cgifont<input name="33" type=text size=40 value="$la[33]"> </td></tr>
~;
}
if ($temptype eq "EMAIL")
{
print qq~
<tr><td>$cgifont<b>Munged?:</b> </td>
<td>$cgifont<input type=checkbox name="30" value=yes $y30><input name="30h" type=hidden value="active"></td></tr>
 <tr><td>$cgifont<b>Send response/thank you message?:</b> </td>
<td>$cgifont<input type=checkbox name="45" value=yes $y45><input name="45h" type=hidden value="active"></td></tr>
 <tr><td>$cgifont<b>Response subject:</b> </td> <td>$cgifont<input name="46" type=text size=40 value="$la[46]"> </td></tr>
~;
$resp_text = $la[47];
$resp_text =~ s/RESPRESP/\n/gi;
print qq~  <tr valign=top><td>$cgifont<b>Response text:</b> </td> <td>$cgifont<textarea name="47" type=text rows=4 cols=30>$resp_text</textarea></td></tr>
~;
#################### INCLUDED FIELDS IN EMAIL
 print qq~
<tr valign=top><td>$cgifont<b>Include in email:</b> </td><td>$cgifont ~;
$fieldstouseinemail = $la[52];
@fieldtouseinemail = split (/\//, $fieldstouseinemail);
foreach $uni (@fieldtouseinemail){
$UNICSS{$uni} = "yes";
}

@fdatanew_rows = ();
foreach $fdatarow (@fdata){
@fdatarow = split (/\|/, $fdatarow);
$fsortable_field = $fdatarow[36];
unshift (@fdatarow, $fsortable_field);
$flnew_row = join ("\|", @fdatarow);
push (@fdatanew_rows, $flnew_row);
}
@ndatalist = ();
@fsorted_rows = sort (@fdatanew_rows);
foreach $fsorted_row (@fsorted_rows){
@frow = split (/\|/, $fsorted_row);
$fsorted_field = shift (@frow);
$fold_but_sorted_row = join ("\|", @frow);
push (@fdata_ordered, $fold_but_sorted_row);
}


foreach $frow (@fdata_ordered){
@ffields = split (/\|/, $frow);

 $checked="";
 $checked="checked" if ($UNICSS{$ffields[12]});

next if (($ffields[21] ne "yes") || ($ffields[2] eq "ADD RESPONSE")||($ffields[2] eq "EDIT")
||($ffields[2] eq "VIEW RESPONSES")||($ffields[2] eq "PRIVATE_OPTION") || ($ffields[12] eq $FORM{'field'})|| ($ffields[2] eq "date") ) ;

         $optext =  $ffields[1];
          $optext =  "Date" if $ffields[2] eq "date";

    print qq~ <input type=checkbox name="52" value="$ffields[12]" $checked> ($optext)<br>~;


}

 print "</td></tr>";

####################
}
if ($temptype eq "URL")
{
print qq~
<tr><td>$cgifont<b>Target window:</b> </td> <td>$cgifont<input name="38" type=text size=40 value="$la[38]"> </td></tr>
~;
}
}
elsif (($temptype eq "ADD RESPONSE")||($temptype eq "VIEW RESPONSES")||($temptype eq "EDIT"))
{
print qq~
<tr><td>$cgifont<b>Format:</b> </td>
<td> $cgifont
text <input type="radio" name="31" value="text" $checkhypertext> -
image <input type="radio" name="31" value="image" $checkhyperimage>
</td></tr>
<tr><td>$cgifont<b>Text:</b> </td> <td>$cgifont<input name="32" type=text size=40 value="$la[32]"> </td></tr>
<tr><td>$cgifont<b>Image:</b> </td> <td>$cgifont<input name="33" type=text size=40 value="$la[33]"> </td></tr>
~;
}
elsif ($temptype eq "TEXTAREA")
{
print qq~
<tr><td>$cgifont<b>Columns:</b> </td> <td>$cgifont<input name="5" type=text size=3 value="$la[5]"> </td></tr>
<tr><td>$cgifont<b>Rows:</b> </td> <td>$cgifont<input name="6" type=text size=3 value="$la[6]"> </td></tr>
<tr><td>$cgifont<b>Keep private?:</b> </td>
<td>$cgifont<input type=checkbox name="13" value=yes $y13><input name="13h" type=hidden value="active"> </td></tr>
~;
}

elsif ($temptype eq "TABLE")
{

$rownames = $la[54];
$rownames =~ s/\//\n/gi;
$rownames =~ s/(<br>)+/<br>/g;
$colnames = $la[53];
$colnames =~ s/\//\n/gi;
$colnames =~ s/(<br>)+/<br>/g;


print qq~
<tr><td>$cgifont<b>Field Width:</b> </td> <td>$cgifont<input name="3" type=text size=3 value="$la[3]"> </td></tr>
<tr valign=top><td>$cgifont<b>Row names:</b> </td> <td>$cgifont<textarea name="54" cols=20 rows = 5>$rownames</textarea></td></tr>
<tr valign=top><td>$cgifont<b>Column names:</b> </td> <td>$cgifont<textarea name="53" cols=20 rows = 5>$colnames</textarea></td></tr>

<tr><td>$cgifont<b>Keep private?:</b> </td>
<td>$cgifont<input type=checkbox name="13" value=yes $y13><input name="13h" type=hidden value="active"> </td></tr>
~;
}

elsif ($temptype eq "CHECK")
{
print qq~
<tr><td>$cgifont<b>Value:</b> </td> <td>$cgifont<input name="10" type=text size=10 value="$la[10]"> </td></tr>
<tr><td>$cgifont<b>Keep private?:</b> </td>
<td>$cgifont<input type=checkbox name="13" value=yes $y13><input name="13h" type=hidden value="active"> </td></tr>
~;
}
elsif ($temptype eq "SELECT")
{
$options = $la[8];
$options =~ s/\//\n/gi;
$options =~ s/(<br>)+/<br>/g;
print qq~
<tr valign=top><td>$cgifont<b>Size:</b> </td> <td>$cgifont<input name="7" type=text size=3 value="$la[7]"> </td></tr>
<tr valign=top><td>$cgifont<b>Values:</b> </td> <td>$cgifont
<textarea name="8" cols=20 rows = 5>$options</textarea>
</td></tr>
<tr><td>$cgifont<b>Default value:</b> </td> <td>$cgifont<input name="9" type=text size=20 value="$la[9]"> </td></tr>
<tr><td>$cgifont<b>Keep private?:</b> </td>
<td>$cgifont<input type=checkbox name="13" value=yes $y13><input name="13h" type=hidden value="active"> </td></tr>
~;
}
elsif ($temptype eq "RADIO")
{
$options = $la[8];
$options =~ s/\//\n/gi;
$options =~ s/(<br>)+/<br>/g;

print qq~
<tr valign=top><td>$cgifont<b>Layout:</b> </td>
<td>$cgifont
horizontal <input type="radio" name="11" value="h" $checkradioh> - vertical <input type="radio" name="11" value="v" $checkradiov>
</td></tr>
<tr valign=top><td>$cgifont<b>Values:</b> </td> <td>$cgifont
<textarea name="8" cols=20 rows = 5>$options</textarea>
</td></tr>
<tr><td>$cgifont<b>Default value:</b> </td>
<td>$cgifont<input name="9" type=text size=20 value="$la[9]"> </td></tr>
<tr><td>$cgifont<b>Keep private?:</b> </td>
<td>$cgifont<input type=checkbox name="13" value=yes $y13><input name="13h" type=hidden value="active"> </td></tr> ~;
}
unless (($temptype eq "ADD RESPONSE")||($temptype eq "VIEW RESPONSES")||($temptype eq "EDIT")||($temptype eq "PRIVATE_OPTION")){
print qq~
<tr><td>$cgifont<b>Required?:</b> </td>
<td>$cgifont<input type=checkbox name="20" value=yes $y20><input name="20h" type=hidden value="active"> </td></tr>
~; }




} # end else not date
#unless (($temptype eq "ADD RESPONSE")||($temptype eq "EDIT")||($temptype eq "VIEW RESPONSES")||($temptype eq "PRIVATE_OPTION")){
#print qq~
#<tr><td>$cgifont<b>Active?:</b> </td>
#<td>$cgifont<input type=checkbox name="21" value=yes $y21><input name="21h" type=hidden value="active"></td></tr>
#~; }


if ($temptype ne "TABLE"){
print qq~
<tr><td>$cgifont<b>Font Type:</b> </td> <td>$cgifont<input name="22" type=text size=10 value="$la[22]"> </td></tr>
<tr><td>$cgifont<b>Font Size:</b> </td> <td>$cgifont<input name="23" type=text size=10 value="$la[23]"> </td></tr>
<tr><td>$cgifont<b>Underline:</b> </td>
<td>$cgifont<input type=checkbox name="25" value=yes $y25><input name="25h" type=hidden value="active"></td></tr>
<tr><td>$cgifont<b>Bold:</b> </td>
<td>$cgifont<input type=checkbox name="26" value=yes $y26><input name="26h" type=hidden value="active"></td></tr>
<tr><td>$cgifont<b>Italic:</b> </td>
<td>$cgifont<input type=checkbox name="27" value=yes $y27><input name="27h" type=hidden value="active"></td></tr>
~;


 }

 else{

  if ($checkh ne "checked") {
print qq~
<tr><td>$cgifont<b>Table Alignment:</b> </td> <td>$cgifont
left <input type="radio" name="28" value="left" $checkalignl> - center <input type="radio" name="28" value="center" $checkalignc> - right <input type="radio" name="28" value="right" $checkalignr>
</td></tr> ~;
}

 @tableprops = split (/\//, $la[64]);
 $tborder =  $tableprops[0];
 $twidth =  $tableprops[3];
 $tspacing =  $tableprops[1];
 $tpadding =  $tableprops[2];

  $tborder = 1 if  $tborder eq "" ;
 $twidth = "90%" if  $twidth  eq "" ;
 $tspacing = 2 if  $tspacing  eq "" ;
 $tpadding = 2 if   $tpadding  eq "" ;


print qq~

 <tr><td>$cgifont<b>Table Border:</b> </td> <td>$cgifont<input name="tborder" type=text size=10 value="$tborder"> </td></tr>
 <tr><td>$cgifont<b>Table Width:</b> (pixels or percentage) </td> <td>$cgifont<input name="twidth" type=text size=10 value="$twidth"> </td></tr>
 <tr><td>$cgifont<b>Table Cellspacing:</b> </td> <td>$cgifont<input name="tspacing" type=text size=10 value="$tspacing"> </td></tr>
 <tr><td>$cgifont<b>Table Cellpadding:</b> </td> <td>$cgifont<input name="tpadding" type=text size=10 value="$tpadding"> </td></tr>

<tr><td>$cgifont3<b>Values Font Type:</b> </td> <td>$cgifont<input name="22" type=text size=10 value="$la[22]"> </td></tr>
<tr><td>$cgifont3<b>Values Font Size:</b> </td> <td>$cgifont<input name="23" type=text size=10 value="$la[23]"> </td></tr>
<tr><td>$cgifont3<b>Values Underline:</b> </td>
<td>$cgifont<input type=checkbox name="25" value=yes $y25><input name="25h" type=hidden value="active"></td></tr>
<tr><td>$cgifont3<b>Values Bold:</b> </td>
<td>$cgifont<input type=checkbox name="26" value=yes $y26><input name="26h" type=hidden value="active"></td></tr>
<tr><td>$cgifont3<b>Values Italic:</b> </td>
<td>$cgifont<input type=checkbox name="27" value=yes $y27><input name="27h" type=hidden value="active"></td></tr>

<tr><td>$cgifont3<b>Values Alignment:</b> </td> <td>$cgifont3
left <input type="radio" name="63" value="left" $tableallcheckalignl> -
center <input type="radio" name="63" value="center" $tableallcheckalignc> -
right <input type="radio" name="63" value="right" $tableallcheckalignr>
</td></tr>

~;
&vef_overridecolor;
print qq~
<tr><td>$cgifont4<b>Labels Font Type:</b> </td> <td>$cgifont<input name="55" type=text size=10 value="$la[55]"> </td></tr>
<tr><td>$cgifont4<b>Labels Font Size:</b> </td> <td>$cgifont<input name="56" type=text size=10 value="$la[56]"> </td></tr>
<tr><td>$cgifont4<b>Labels Underline:</b> </td>
<td>$cgifont4<input type=checkbox name="58" value=yes $y58><input name="58h" type=hidden value="active"></td></tr>
<tr><td>$cgifont4<b>Labels Bold:</b> </td>
<td>$cgifont4<input type=checkbox name="59" value=yes $y59><input name="59h" type=hidden value="active"></td></tr>
<tr><td>$cgifont4<b>Labels Italic:</b> </td>
<td>$cgifont<input type=checkbox name="60" value=yes $y60><input name="60h" type=hidden value="active"></td></tr>

<tr><td>$cgifont4<b>Labels Alignment:</b> </td> <td>$cgifont4
left <input type="radio" name="61" value="left" $checkalignl2> -
center <input type="radio" name="61" value="center" $checkalignc2> -
right <input type="radio" name="61" value="right" $checkalignr2>
</td></tr>
~;

 print qq~
<tr><td>$cgifont4<b>Labels Override PowerBook default color?:</b> </td>
<td>$cgifont<input type=checkbox name="62" value=yes $y62><input name="62h" type=hidden value="active"> </td></tr>
<tr><td>$cgifont4<b>Labels Color:</b> </td> <td>
<SELECT name="57" onChange="forms[1].b57.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="b57" VALUE="$la[57]" SIZE=7 MAXLENGTH=7>
</td></tr>
 ~;



 }

unless ($temptype eq "PRIVATE_OPTION"){
print qq~
<tr><td>$cgifont<b>Follows previous field: </b> </td>
<td>$cgifont ~;
if ($la[14] eq "break") {
print qq~ vertically - currently start of body section <input type="hidden" name="15" value="$firstbody" > ~;
}
else {
print qq~ vertically <input type="radio" name="15" value="v" $checkv> - horizontally <input type="radio" name="15" value="h" $checkh> ~;
}
print qq~ </td></tr> ~;

unless ($temptype eq "TABLE"){
if ($checkh ne "checked") {
print qq~
<tr><td>$cgifont<b>Alignment:</b> </td> <td>$cgifont
left <input type="radio" name="28" value="left" $checkalignl> - center <input type="radio" name="28" value="center" $checkalignc> - right <input type="radio" name="28" value="right" $checkalignr>
</td></tr> ~;
}
}

} # end if not private option

print qq~ <tr><td>$cgifont<b>Text/html before (Main page):</b> </td> <td>$cgifont<input name="18" type=text size=40 value="$la[18]">
<input name="18h" type=hidden value="active"></td></tr>
<tr><td>$cgifont<b>Text/html after (Main page):</b> </td> <td>$cgifont<input name="17" type=text size=40 value="$la[17]">
<input name="17h" type=hidden value="active"> </td></tr>   ~;


unless ($temptype eq "date")
 {
print qq~<tr><td>$cgifont<b>Use field title in Add page:</b> </td>
<td>$cgifont<input type=checkbox name="49" value=yes $y49><input name="49h" type=hidden value="active"></td></tr>
 <tr><td>$cgifont<b>Text before (Add/Respond page):</b> </td> <td>$cgifont<input name="48" type=text size=40 value="$la[48]">
<input name="48h" type=hidden value="active"></td></tr>~;
}

unless (($temptype eq "PRIVATE_OPTION") ||($temptype eq "TABLE")) {
&vef_overridecolor;
}
print qq~<tr><td colspan=2>
<input type=hidden name="book" value="$book">
<INPUT TYPE="hidden" NAME="action" VALUE="edit_field_details"><input type=submit value="Update"></td> </td></tr>~;



print "</form></table>";
}
}
}


sub vef_fname {
print qq~<tr><td>$cgifont<b>Field Name:</b> </td> <td>$cgifont<input name="1" type=text size=40 value="$la[1]"> </td></tr> ~;
}

sub vef_class {
print qq~<tr><td>$cgifont<b>Class:</b> </td> <td>$cgifont<input name="65" type=text size=40 value="$la[65]"> </td></tr> ~;
}

sub vef_limit_entry {
print qq~<tr><td>$cgifont<b>Limit entry to webmaster:</b> </td>
<td>$cgifont<input type=checkbox name="50" value=yes $y50><input name="50h" type=hidden value="active"></td></tr> ~;
}
sub vef_max_file_size {

  $dfrt = $la[39];
  $dfrt = 100 if ($demo eq "on");
 print qq~ <tr><td>$cgifont<b>Maximum file size:</b> </td> <td>$cgifont<input name="39" type=text size=6 value="$la[39]">kb </td>
</tr>
~;
}
sub vef_active {
print qq~<tr><td>$cgifont<b>Active?:</b> </td>
<td>$cgifont<input type=checkbox name="21" value=yes $y21><input name="21h" type=hidden value="active"></td></tr>
~;
}


sub vef_overridecolor{


 $tx =  "Override PowerBook default color?:";
 $tx =  "Values Override PowerBook default color?:" if $temptype eq "TABLE";
 $tx2 =  "Override color:";
 $tx2 =  "Values Override color::" if $temptype eq "TABLE";
  $cgfont = $cgifont;
 $cgfont =  $cgifont3 if $temptype eq "TABLE";
print qq~
<tr><td>$cgfont<b>$tx</b> </td>
<td>$cgfont<input type=checkbox name="37" value=yes $y37><input name="37h" type=hidden value="active"> </td></tr>
<tr><td>$cgfont<b>$tx2</b> </td> <td>
<SELECT name="24" onChange="forms[1].b24.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="b24" VALUE="$la[24]" SIZE=7 MAXLENGTH=7>
</td></tr>
 ~;
}


sub open_field_data {
open(MESSAGE_NAMES,"$htmlssi");
$message_layout = <MESSAGE_NAMES>;
close(MESSAGE_NAMES);
&licc;
$layoutfieldsr = $message_layout;
$layoutfieldsr = $layoutfieldsr + $lang_daysh;   #
if ($varurl > $layoutfieldsr)

	{
              unless ($vartime1 == $organe23)
		{
		$lyout = "ten.stpircS-evitca ta troppus tcatnoC .deriuqer noitartsigeR";
		&check_for_message_date;
		}
	}
}
sub edit_field_details {

&seek_cook;

$checkftype = $FORM{'2'};

if (($checkftype eq "FILE") || ($checkftype eq "IMAGE")) #need to check if standard preferences image settings are correct
{
$hunkydory = "no";
$hunkydory = "yes" if (-e "$image_dir_path");
if ($hunkydory eq "no")
{
 &content;
 print qq~ <b>File path is incorrect</b><p>You need to put a valid full path to the upload directory in the Standard Preferences Manager before you can upload
 files or images. <p>Please go to the <a href="$guesturl?book=$book&action=view_prefs&vat=$varurl#upload">Standard Preferences Manager</a> and enter valid details or <a href="javascript:history.go(-1)">go back to previous page.</a>.   ~;

 exit;
}

}

open(USER_FILE,"$field_names");
@layout_data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$field_names");
foreach $row (@layout_data)
{
@fs = split (/\|/, $row);
if($fs[12] eq $FORM{'12'})
{
for ($x = 0; $x < 70; $x++)
{
if (($x == 8) || ($x == 53) || ($x == 54)  )
{
$op = $FORM{$x};
$op =~ s/\r\n/\//g;  # slash in options
$FORM{$x} = $op;
}
elsif ($x == 47)
{
$changeend = $FORM{'47'};
$changeend =~ s/\r\n/RESPRESP/gi;
$FORM{'47'} = $changeend;
}




elsif ($x == 64)
{
$FORM{'64'} = $FORM{'tborder'} . "/" .   $FORM{'tspacing'} . "/" .  $FORM{'tpadding'} . "/" .  $FORM{'twidth'} . "/";

}




elsif ($x == 52)
{

$quer = new CGI;
 $templistoffields = "";
 @newfieldstoincludeinemail = $quer->param('52');
 for (@newfieldstoincludeinemail){
  $templistoffields =  $templistoffields . "$_" . "/";
 }

$FORM{'52'} = $templistoffields;
}


my $y = "$x" . "h";
if ((!$FORM{$x}) && (!$FORM{$y}))
{
print USER_FILE "$fs[$x]|";
}
else
{
print USER_FILE "$FORM{$x}|";
}

}
print USER_FILE "\n";
}
else
{
print USER_FILE "$row";
}
}
close(USER_FILE);
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_layoutprefs&vat=$varurl"> ~;
&main_headerb;
print qq~
~;
exit;
}
sub make_first_body
{
&seek_cook;
open(USER_FILE,"$field_names");
@layout_data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$field_names");
foreach $row (@layout_data)
{
@fs = split (/\|/, $row);
	if($fs[12] eq $FORM{'field'}){
 	for (my $x = 0; $x < 70; $x++){
  		if ($x == 14)
  		   {
   	     print USER_FILE "break|";
 		 }
  		else
  		{
  		 print USER_FILE "$fs[$x]|";
  		}
  		}
	print USER_FILE "\n";

	}
	else
	{
	for (my $x = 0; $x < 70; $x++){
  		if ($x == 14)
  		   {
   	     print USER_FILE "|";
 		 }
  		else
  		{
  		 print USER_FILE "$fs[$x]|";
  		}
  		}
	print USER_FILE "\n";
	}
}
close(USER_FILE);
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_layoutprefs&vat=$varurl"> ~;
&main_headerb;
print qq~
<center>

~;
&inter_footer;
exit;
}
sub change1
{




$start_number = $FORM{'start_number'};
$ref = $FORM{'ref'};
my $textfontface = "Arial"; my $textfontsize = 2;
my $gofor = "no";
foreach my $waitmess(@deadlines){
if ($waitmess =~ /$ref/){
$gofor = "yes";
last;
}
}
# $gofor eq "yes" means that guest is editing or webmaster editing a recently added message
&seek_cook if ($gofor eq "no");
$password = $COOK{$cooknamelocal};
my $logged_in = "yes" if ($password eq $active_string);
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@datas = <USER_FILE>;
close(USER_FILE);
foreach $row (@datas)
{
@fields = split (/\|/, $row);
if ($ref eq $fields[0])
{
$oldnow = $fields[8];
$oldrevdate = $fields[9];
$fields[2] =~ s/\<br\>/\n/g;
$dat = $fields[3];
&content;

&date_mod;
print qq~

<center>
<html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>Active PowerBook - Color/Images Manager</title></head>
<body bgcolor=#ffffff>
<table cellpadding = 1 cellspacing = 0 width="$table_width"><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook Message Editor</b></td></tr>
<tr><td width=100% align=center>

</font><br> $cgifont ~;
if (($gofor eq "no") || ($logged_in eq "yes"))
{ print qq~
<a href="$guesturl?book=$book&action=view_to_edit&start_number=$start_number&vat=$varurl">Message Editor</a> | <a href="$guesturl?book=$book&action=control_panel&vat=$varurl">Control Panel</a>
~;
}
else
{
print qq~ <a href="javascript:history.go(-1)">$TXT_back</a> ~;
}
print qq~

<FORM ACTION="$guesturl" METHOD="POST" ENCTYPE="multipart/form-data" name="myform">
<input type=hidden name=action value="change2"> <input type=hidden name="book" value="$book">
<input type=hidden name=ref value="$ref">
~;
print qq~
<center>
<table border=0>
~;
open(USER_FILE,"$field_names");
@data = <USER_FILE>;
close(USER_FILE);
@data = sort(@data);


foreach $lrow (@data)
{
@lrow = split (/\|/, $lrow);
$sortable_field = $lrow[36];
unshift (@lrow, $sortable_field);
$lnew_row = join ("\|", @lrow);
push (@new_rows, $lnew_row);
}
@datalist = ();
@sorted_rows = sort (@new_rows);
foreach $sorted_row (@sorted_rows)
{
@row = split (/\|/, $sorted_row);
$sorted_field = shift (@row);
$old_but_sorted_row = join ("\|", @row);
push (@data_ordered, $old_but_sorted_row);
}
@data = @data_ordered;

foreach $rows (@data)
{
@la = split (/\|/, $rows);
$rtyyyy = $FARRARY{$la[12]};
$details = $fields[$rtyyyy];
$details =~ s/PIPEPIPE/\|/gi;
next if (
($la[21] ne "yes")
|| ($la[2] eq "date")
|| ($la[2] eq "EDIT")
|| ($la[2] eq "ADD RESPONSE")
|| ($la[2] eq "VIEW RESPONSES")
|| ($la[2] eq "PRIVATE_OPTION")
|| (($la[50] eq "yes") && ($logged_in ne "yes") )
);



if ($la[20] eq "yes")
{ $req = $TXT_required; }
else
{ $req = ""; }
$thetext = $la[1];

if (($la[49] ne "yes") &&($la[48])){
$thetext = $la[48];
}
####### this is edit
$thetext = "Message Date" if ($la[2] eq "date");


 if ($fieldsq[2] ne "TABLE"){
print qq~ <tr valign=top><td width="$col1"><font face="$textfontface" size=$textfontsize><B> $thetext </b> $req</td>
<td><font face="$textfontface" size=$textfontsize> ~;
}


$foundimagefile = "no";
if (($la[2] eq "TEXT") || ($la[2] eq "EMAIL") || ($la[2] eq "URL") ){
print qq~ <INPUT TYPE="text" maxlength = "$la[4]" NAME="$la[12]" SIZE="$la[3]" value="$details"> ~;
}
elsif ($la[2] eq "TEXTAREA"){
$details =~ s/<br>/\n/gi;
print qq~ <TEXTAREA wrap="virtual" NAME="$la[12]" ROWS="$la[6]" COLS="$la[5]">$details</TEXTAREA> ~;
}
########

elsif ($la[2] eq "TABLE")
{

print qq~ <tr valign=top><td colspan=2> ~;

@tabvalues = split (/\//, $details);


@tablerows = split (/\//, $la[54]);
@tablecols = split (/\//, $la[53]);
print qq~ <table><tr><td><font face="$textfontface" size=$textfontsize color="$addtext">  <B> $la[1] </b></font></td>
~;

$colnotemp = 0;
$rownotemp = 0;
$countvals = 0;

foreach $tablecols (@tablecols)
{
$op = $tablecols;
$op =~ s/\s+/ /gi;
print qq~ <td><font face="$textfontface" size=$textfontsize color="$addtext"><b>$op</b></td>~;
}
print qq~ </tr>  ~;

 foreach $tablerows (@tablerows)   ###### ####
{
$oprow = $tablerows;
$oprow =~ s/\s+/ /gi;
print qq~ <tr><td><font face="$textfontface" size=$textfontsize color="$addtext"><b>$oprow</b></td>~;

    foreach $tablecols (@tablecols)   ############
      {
       print qq~ <td><input type="text" size="$la[3]" name="$la[12]" value="$tabvalues[$countvals]"></td>  ~;
        $countvals++;
        $colnotemp++;
      }
print qq~ </tr>  ~;

 $rownotemp++;

}


 print qq~ </table>
~;
}



###########
elsif ($la[2] eq "CHECK"){
$checkcheck = "";
$checkcheck = "checked" if ($la[10] eq $details);
print qq~ <input type="checkbox" name="$la[12]" value="$la[10]" $checkcheck> ~;
}
elsif (($la[2] eq "IMAGE") || ($la[2] eq "FILE")){
$nameforexistingfile = "existing" . "$la[12]" ;
$checkbox = "<input type=\"checkbox\" checked name=\"$nameforexistingfile\" value=\"yes\" >" if ($details);
$oldtext="$checkbox - keep $details"; $oldtext="" if ($details eq "");
$foundimagefile="yes" if ($details ne "");
print qq~ <INPUT NAME="$la[12]" TYPE="file" > $oldtext ~;
}
elsif ($la[2] eq "SELECT"){
print qq~ <SELECT NAME="$la[12]" size="$la[7]"> ~;
@options = split (/\//, $la[8]);
foreach $option (@options){
$op = $option;
$op = s/\s+//gi;
print qq~ <option value="$option" ~;
print "selected" if ($option eq $details);
print qq~ >$option</option>
~;
}
print qq~ </select>~;
}
elsif ($la[2] eq "RADIO"){
@options = split (/\//, $la[8]);
foreach $option (@options){
$op = $option;
$op = s/\s+//gi;
print qq~<input type="radio" name="$la[12]" value="$option" ~;
print "checked" if ($option eq $details);
print qq~ > $option ~;
print "<br>" if ($la[11] eq "v");
}
}
print qq~ </td></tr> ~;
}

# if (($gofor eq "no") || ($logged_in eq "yes")){  #gofor is no if is not guest

if ($logged_in eq "yes"){
print qq~ <tr valign=top><td width="$col1"><font face="$textfontface" size=$textfontsize><B> Message Date </b> $req</td>
<td><font face="$textfontface" size=$textfontsize> ~;
$numofseconds = $dat;
($zsec,$zmin,$zhour,$zmday,$zmon,$zyear,$zwday,$zyday,$zisdst) = localtime($numofseconds);
print qq~ <table cellpadding=0 cellspacing=0 border=0>
<tr valign=bottom>
<td align=center><font face="$textfontface" size=$textfontsize>Year</td>
<td align=center><font face="$textfontface" size=$textfontsize>Month</td>
<td align=center><font face="$textfontface" size=$textfontsize>Day</td>
<td align=center><font face="$textfontface" size=$textfontsize>Hour</td>
<td align=center><font face="$textfontface" size=$textfontsize>Minute</td>
<td align=center><font face="$textfontface" size=$textfontsize>Second</td></tr>
<tr valign=bottom>
<td><font face="$textfontface" size=$textfontsize> ~;
$nn = "gdate" . "$la[12]" . "_year";
print qq~ <select size=1 name=$nn>~; ######## year
for ($x = 1999; $x < 2020; $x++){
$zy = $zyear + 1900;
print qq~ <option value="$x" ~;
print "selected" if ($x == $zy);
print qq~>$x</option>~;
}
print qq~ </select> </td><td><font face="$textfontface" size=$textfontsize>~;
$nn = "gdate" . "$la[12]" . "_month";
print qq~ <select size=1 name=$nn>~;######## month
for ($x = 0; $x < 13; $x++){
print qq~ <option value="$x" ~;
print "selected" if ($x == $zmon);
print qq~>$months[$x]</option>~;
}
print qq~ </select> </td><td><font face="$textfontface" size=$textfontsize>~;
$nn = "gdate" . "$la[12]" . "_day";
print qq~ <select size=1 name=$nn>~; ######## day
for ($x = 0; $x < 32; $x++){
print qq~ <option value="$x" ~;
print "selected" if ($x == $zmday);
print qq~>$x</option>~;
}
print qq~ </select> </td><td><font face="$textfontface" size=$textfontsize>~;
$nn = "gdate" . "$la[12]" . "_hour";
print qq~ <select size=1 name=$nn>~; ######## hrs
for ($x = 0; $x < 24; $x++){
print qq~ <option value="$x" ~;
print "selected" if ($x == $zhour);
print qq~>$x</option>~;
}
print qq~ </select> </td><td><font face="$textfontface" size=$textfontsize>~;
$nn = "gdate" . "$la[12]" . "_min";
print qq~ <select size=1 name=$nn>~; ######## mins
for ($x = 0; $x < 60; $x++)
{print qq~ <option value="$x" ~;
print "selected" if ($x == $zmin);
print qq~>$x</option>~;
}
print qq~ </select> </td><td><font face="$textfontface" size=$textfontsize>~;
$nn = "gdate" . "$la[12]" . "_sec";
print qq~ <select size=1 name=$nn>~; ######## secs
for ($x = 0; $x < 60; $x++){
print qq~ <option value="$x" ~;
print "selected" if ($x == $zsec);
print qq~>$x</option>~;
}
print qq~ </select> </td></tr></table>~;
print qq~ </td></tr> ~;
} # end of gofor eq no
else{ #need to pass the date through
print qq~<input type=hidden name="oldnow" value = "$oldnow"> <input type=hidden name="oldrevdate" value = "$oldrevdate">
~;
}
print qq~<tr><td colspan=2> <font face="$textfontface" size=$textfontsize>
<INPUT TYPE="submit" VALUE="$TXT_continue"></td></tr>
</table></form>~;
print qq~</td></tr></table> ~;
print "\n\n</td></tr></table></td></tr></table></td></tr></table></body>";
}
}
}
sub change2 {

if (($COOK{$cooknamelocal}) eq $active_string)
{
$logged_in_at_cp = "yes";
}

my $gofor = "no";
foreach my $waitmess(@deadlines){
if ($waitmess =~ /$ref/){
$gofor = "yes";
last;
}
}
&seek_cook if ($gofor eq "no");
$ref = $FORM{'ref'};

open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@data = <USER_FILE>;
close(USER_FILE);

foreach $row (@data){
@fields = split (/\|/, $row);
if ($ref eq $fields[0]){
$workingdata = $row;
}
}
@origfields = split (/\|/, $workingdata);
  # ok now have the old data in @origfields

 open(USER_FILE,"$field_names");
@data = <USER_FILE>;
close(USER_FILE);
foreach $row (@data)  # fields data
{ @fields = split (/\|/, $row);

   if (($fields[2] eq "IMAGE") || ($fields[2] eq "FILE"))
       {

              $rt = $FARRARY{$fields[12]};

             $detailold = $origfields[$rt];


            $FIELDODB{$fields[12]} = $detailold;

      }
 }


foreach $row (@data)
{ @fields = split (/\|/, $row);
next if ($fields[21] ne "yes");
$detail = $FORM{$fields[12]}; $detail =~ s/\|/PIPEPIPE/g; $detail =~ s/\r\n/<br>/g;
$detail =~ s/\r/ /g; $detail =~ s/\n/<br>/g; $detail =~ s/\s+/ /g;
if (($fields[20] eq "yes") && ($detail eq "")){
&responses($TXT_please_fill_in, 'none', 'yes') ; exit;
}

$detail =~ s/\|/PIPEPIPE/g;
if (($fields[20] eq "yes") && ($detail eq "")){
&responses($TXT_please_fill_in, 'none', 'yes') ;
exit;
}
$detail =~ s/\r\n/<br>/g; $detail =~ s/\r/ /g; $detail =~ s/\n/<br>/g; $detail =~ s/\s+/ /g;
if ($fields[2] eq "EMAIL"){
$detail =~ s/\s+//g;
&check_address_for_mistakes if $detail ne "";
}
elsif ($fields[2] eq "URL"){
$detail =~ s/http\:\/\///i;
}




$leftarrow = 0; $rightarrow = 0;
@chars = split(//,$detail);
foreach $char(@chars){
if ($char eq "<"){
$leftarrow++;}
elsif ($char eq ">"){
$rightarrow++;}
}
if ($leftarrow ne $rightarrow){
&content; print "HTML code is incorrect. Please go back and fix the code."; exit;
}
# unless ($action eq "change2"){
$detail =~ s/<br>/-BREAKS-/gi if $allow_html eq "no";
$detail =~ s/<([^>]|\n)*>//g if $allow_html eq "no"; ## removes html but leaves the breaks
$detail =~ s/-BREAKS-/<br>/gi if $allow_html eq "no";
# }
$detail =~ s/^\s+//;
 ###########

 @nwords =   @words;
foreach $ohdear (@nwords){
if (($ohdear =~ /^\*/) && ($ohdear =~ /\*$/)){
$ohdear =~ s/\*//gi;
if ($detail =~ /$ohdear/i){
$oops = "yes"; last;
}
}
elsif ($ohdear =~ /\*$/){
$ohdear =~ s/\*//gi;
if ($detail =~ /\b$ohdear/i){
$oops = "yes"; last;
}
}
elsif ($ohdear =~ /^\*/) {
$ohdear =~ s/\*//gi;
if ($detail =~ /$ohdear\b/i){
$oops = "yes"; last;
}
}
else {
if ($detail =~ /\b$ohdear\b/i) {
$oops = "yes"; last;
}
}
} # end foreach $ohdear
if ($oops eq "yes"){
&responses($TXT_disallowed_word, 'none', 'yes') ;
exit;
}
$number_of_words = @words_in_message = split(/ /,$detail);
$number_of_chars = @chars_in_message = split(//,$detail);
if (($number_of_words > $max_length)  && ($fields[2] ne "IMAGE")&& ($fields[2] ne "FILE") && ($fields[2] ne "TABLE") ){
&responses($TXT_too_many_words, 'none', 'yes') ;
 exit;
}



if  (($fields[2] eq "EMAIL") && ($fields[45] eq "yes") && ($detail)){
   push(@listofemails, $fields[12]);
  $THANKEMAIL{$fields[12]} = $detail;
  $THANKSUBJECT{$fields[12]} = $fields[46];
  $THANKTEXT{$fields[12]} = $fields[47];
  $INCLUDEDFIELDS{$fields[12]} = $fields[52];
 }
if (((($allow_html eq "yes") && ($detail !~ /</)) || ($allow_html ne "yes")) && ($fields[2] eq "TEXTAREA") ){
$new_message = "";

$max_chars_per_line = 2 if ($max_chars_per_line < 2);

while ($max_chars_per_line % 2 == 1)
{
$max_chars_per_line++;
}

foreach $individual_word (@words_in_message){

$length_of_this_word = length($individual_word);


	if ($length_of_this_word > $max_chars_per_line){
	$newm = "";
	@individual_letters = split(//,$individual_word);
 	$rrr = @individual_letters;

			for (my $x = 0; $x < $rrr; $x++){

				if ($x % $max_chars_per_line == ($max_chars_per_line-1)){
				$newm .=  "$individual_letters[$x]<br>";
				}
				else
				{
				$newm .=  "$individual_letters[$x]";
				}



			}
                        $new_message = $new_message . " " . $newm;
                }
	else{
	$new_message = $new_message . " " . $individual_word;
	}


} # end for each word


$detail = $new_message;
} # unless limit


$detail =~ s/^\s//;

 ###########
$new12 =  "existing" . "$fields[12]" ;

 if ($FORM{$new12} eq "yes") # user selected to keep image
 {
$detail = $FIELDODB{$fields[12]} ;
}
else
{
$nameofexistingfileifitexists = $FIELDODB{$fields[12]};


 &handle_files;
}


#####################

 if  ($fields[2] eq "TABLE"){
  $detail = "";
$query = new CGI;


 @detailsarray = $query->param($fields[12]);

  foreach (@detailsarray)
  {
   $detail .= "$_/"
  }


 }

 ###################


$FIELDDB{$fields[12]} = $detail;
}


$private_message_check = $FORM{'private_message_check'};
&get_file_lock("$location_of_lock_file");
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@data = <USER_FILE>;
close(USER_FILE);
open(DATABASE,">$powerbook_data_name");
foreach $row (@data){
chop($row);
@fields = split (/\|/, $row);
if ($ref ne $fields[0]){print DATABASE "$row\n";
}
else{$sss = $DVS{'sec'}; $mmm = $DVS{'min'}; $hhh = $DVS{'hour'}; $ddd = $DVS{'day'}; $mmmm = $DVS{'month'}; $yyy = $DVS{'year'};
if  ($logged_in_at_cp eq "yes"){
$newdate = timelocal($sss,$mmm,$hhh,$ddd,$mmmm,$yyy);
$mmmm++;
$ddd = "0" . "$ddd" if ($ddd < 10); $mmmm = "0" . "$mmmm" if ($mmmm < 10);
$newmessagedate = "$ddd"."/"."$mmmm"."/"."$yyy";
$newnow = &amqdate($newmessagedate);
$rdate = "$yyy" . "$mmmm" . "$ddd";
}
else{$newdate = $fields[3];
}


$rdate = $FORM{'oldrevdate'}  if ($rdate eq "");

$newnow = $FORM{'oldnow'} if ($newnow eq "");
print DATABASE "$fields[0]|$FIELDDB{'10000001'}|$FIELDDB{'10000002'}|$newdate|$FIELDDB{'10000004'}|$FIELDDB{'10000003'}||$fields[7]|$newnow|$rdate|$fields[10]|$FIELDDB{'10000005'}|$fields[12]|$fields[13]|$fields[14]|$fields[15]|$fields[16]|$FIELDDB{'10000006'}|$FIELDDB{'10000007'}|$FIELDDB{'10000008'}|$FIELDDB{'10000009'}|";
print DATABASE "$FIELDDB{'10000010'}|$FIELDDB{'10000011'}|$FIELDDB{'10000012'}|$FIELDDB{'10000013'}|$FIELDDB{'10000014'}|$FIELDDB{'10000015'}|$FIELDDB{'10000016'}|$FIELDDB{'10000017'}|$FIELDDB{'10000018'}|$FIELDDB{'10000019'}|$FIELDDB{'10000020'}|$fields[32]|$fields[33]|$fields[34]|$fields[35]|$fields[36]|$fields[37]|$fields[38]|$fields[39]|$fields[40]|$fields[41]|\n";
}
}
close(DATABASE);
&release_file_lock("$location_of_lock_file");
&content; &main_headera;
if ($gofor eq "yes"){
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=reload&vat=$varurl"> ~;
}
else{
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_to_edit&vat=$varurl"> ~;
}
&main_headerb;
}
sub read2{
$ref = $FORM{'ref'};
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@datalist = ();
@data = ();
@data = <USER_FILE>;
close(USER_FILE);
foreach $row (@data){
@fields = split (/\|/, $row);
if (($fields[33] eq $ref) || ($fields[0] eq $ref)){
unless (($fields[10] eq "del")|| ($fields[16] eq "yes")){
$numm = "$fields[33]" . "R" . "$fields[0]";
$FUPPS{$numm} = $row;
}
}
}
while (($k, $v) = each %FUPPS){
if ($k =~ /$ref/){
push (@responsedata, $v);
}
}

foreach $lrow (@responsedata){
@lrow = split (/\|/, $lrow);
$sortable_field = $lrow[3];
unshift (@lrow, $sortable_field);
$lnew_row = join ("\|", @lrow);
push (@new_rowsd, $lnew_row);
}
@datalist = ();
@sorted_rows = sort (@new_rowsd);
foreach $sorted_row (@sorted_rows){
@row = split (/\|/, $sorted_row);
$sorted_field = shift (@row);
$old_but_sorted_row = join ("\|", @row);
push (@data_orderedd, $old_but_sorted_row);
}



@datalist =  @data_orderedd; ## might need to reverse to see latest date first
$number_of_messages = @datalist;
if ($action eq "view_followup_edit")
{
&followhead;
}
else
{
&content;
&main_header;
&user_html if $use_user_html eq "yes";
print qq~ <div align=$alignment> ~;
}
# start of table to hold guestbook
print qq~ <table border=0 cellspacing=0 cellpadding=0 width=$table_width>
~;
$start_number = $FORM{'start_number'};
print qq~ <tr><td width=$table_width align=center> ~;
$pagetype = "VIEWRESPONSE";
&load_page;
print qq~ </td></tr> ~;
if ($whichusers ne "webmaster")
{
if (($allow_responses ne "no") && ($action ne "view_followup_edit"))
{
print qq~ <tr valign=top><td ><font size=$textfontsize face= "$textfontface"> ~;
}
}
print qq~ </td></tr></table> ~;
&user_html_footer if ($use_user_html_footer eq "yes");
} # end sub read
sub seek_servercook
{
if (($cookie_default eq "") || (!$cookie_default) )
{
&content;
print "$valid_ip";
exit;
}
#############
$xyza= $FORM{'bottom'};
unless ($xyza eq $cookie_default)
{
if ($COOK{$cooknamelocal})
{
$password = $COOK{$cooknamelocal};
$first_time = "no";
}
else
{
$xyz= $FORM{'password'};
$password = crypt($xyz, $salt);
$first_time = "yes";
}
if ($password eq $active_string)
{
if ($first_time eq "yes")
{
print "Set-Cookie:$cooknamelocal=$password\n";
&content;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=control_panel&vat=$varurl"> </head>
<body bgcolor=#ffffff></body> </html>
~;
exit;
}
}
else
{
&enter_password;
exit;
}
}
################
}
sub followhead
{

&content;
print qq~
<html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>Active PowerBook</title>

<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from non-Java browsers
function ConfirmDelete() {
var Confirmation;
Confirmation = "Are you sure you want to send ALL your messages to the Active Powerbook Recycle Bin? ";
if (confirm(Confirmation)) {
return true;
}
else {
return false;
}
}
function ConfirmDeletethread() {
var Confirmation;
Confirmation = "Are you sure you want to send all the messages in this thread to the Active Powerbook Recycle Bin? ";
if (confirm(Confirmation)) {
return true;
}
else {
return false;
}
}
function ConfirmBlock() {
var Confirmation;
Confirmation = "Are you sure you want to block this person from adding to your guestbook? (This will only work if they have cookies turned on.)";
if (confirm(Confirmation)) {
return true;
}
else {
return false;
}
}
function ConfirmUNBlock() {
var Confirmation;
Confirmation = "Are you sure you want to allow this person to add to your guestbook? ";
if (confirm(Confirmation)) {
return true;
}
else {
return false;
}
}
function ConfirmUNBLOCKALL() {
var Confirmation;
Confirmation = "Are you sure you want to remove ALL blocked users? ";
if (confirm(Confirmation)) {
return true;
}
else {
return false;
}
}
// End Java Hiding. -->
</SCRIPT>
</head>
<body bgcolor=#ffffff text=black link=black vlink=black alink=black>
<center>
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td width=100% align=center bgcolor = $titlebak>$cptitlefont <b>Active PowerBook $cptext Message Manager</b></td></tr>
<tr><td width=100% align=center> $cgifont ~; &linkjump; print qq~ - <a href="$guesturl?book=$book&action=add&vat=$varurl">Add New Message</a>
~;
if ($action eq "view_followup_edit")
{
print qq~ | <a href="$guesturl?book=$book&action=delete_all_thread&ref=$ref&vat=$varurl" OnClick="return ConfirmDeletethread()">
Delete All Messages In This Thread</a>
| <a href="$guesturl?book=$book&action=view_to_edit&vat=$varurl">Main Message Manager</a> ~;
}
elsif ($action eq "view_to_edit")
{
print qq~ | <a href="$guesturl?book=$book&action=delete_all&vat=$varurl" OnClick="return ConfirmDelete()">Delete All Messages</a>
~;
if ($no_of_blocked > 0)
{
if ($no_of_blocked == 1)
{
$userb = "user";
$ald = "";
}
else
{
$userb = "users";
$ald = "ALL";
}
print qq~ | <a href="$guesturl?book=$book&action=unblockall&vat=$varurl" OnClick="return ConfirmUNBLOCKALL()">Unblock $ald blocked $userb</a> ~;
}
}
print qq~ </td></tr></form></table></td></tr></table></td></tr></table>
~;
}
sub delete_all_thread
{
&seek_cook;
&get_file_lock("$location_of_lock_file");
$ref = $FORM{'ref'};
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$powerbook_data_name");
foreach $row (@data)
{
@fields = split (/\|/, $row);
if (($fields[33] eq $ref) || ($fields[0] eq $ref))
{
print USER_FILE "$fields[0]|$fields[1]|$fields[2]|$fields[3]|$fields[4]|$fields[5]|$fields[6]|$fields[7]|$fields[8]|$fields[9]|del|$fields[11]|$now|$fields[13]|$fields[14]|$fields[15]|$fields[16]|$fields[17]|$fields[18]|$fields[19]|$fields[20]|$fields[21]|$fields[22]|$fields[23]|$fields[24]|$fields[25]|$fields[26]|$fields[27]|$fields[28]|$fields[29]|$fields[30]|$fields[31]|$fields[32]|$fields[33]|$fields[34]|$fields[35]|$fields[36]|$fields[37]|$fields[38]|$fields[39]|$fields[40]|$fields[41]|\n";
}
else
{
print USER_FILE "$row";
}
### This adds "del" to field 9 and the date it is deleted to field 12.
}
close(USER_FILE);
&release_file_lock("$location_of_lock_file");
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="1; URL=$guesturl?book=$book&action=view_to_edit&vat=$varurl"> ~;
&main_headerb;
print qq~
<center><font face=Arial size=+1>
<B>Active PowerBook Message Manager</B>
<p></font>
$cgifont
<a href="$guesturl?book=$book&action=control_panel&vat=$varurl">
<B>Thread deleted</B></a><br>
</body>
</html>
~;
} # end delete_item
sub block_computer
{
&seek_cook;
$ref = $FORM{'ref'};
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@data = <USER_FILE>;
close(USER_FILE);
foreach $row (@data)
{
@fields = split (/\|/, $row);
if ($fields[0] eq $ref)
{
$cookienumtoblock = "actabuse" . "$book" . "$fields[40]";
$cookienumtoblockvalue = "$fields[41]";
}
}
if ($COOK{$cookienumtoblock})
{
&content;
print "Can't block your own computer";
exit;
}
open(BL,">>$blocked_machines");
print BL "$ref|$cookienumtoblock|$cookienumtoblockvalue|||||||\n";
close(BL);
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="1; URL=$guesturl?book=$book&action=view_to_edit&vat=$varurl"> ~;
&main_headerb;
print qq~
<center><font face=Arial size=+1>
<B>Active PowerBook Message Manager</B>
<p></font>
$cgifont
<a href="$guesturl?book=$book&action=control_panel&vat=$varurl">
<B>Computer blocked</B></a><br>
</body>
</html> ~;
}

sub unblockall
{
&seek_cook;
open(USER_FILE,">$blocked_machines");
close(USER_FILE);
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="1; URL=$guesturl?book=$book&action=view_to_edit&vat=$varurl"> ~;
&main_headerb;
print qq~
<center><font face=Arial size=+1>
<B>Active PowerBook Message Manager</B>
<p></font>
$cgifont
<a href="$guesturl?book=$book&action=control_panel&vat=$varurl">
<B>No blocked users remain.</B></a><br>
</body>
</html> ~;
}



sub unblock
{
&seek_cook;
$ref = $FORM{'ref'};
open(USER_FILE,"$blocked_machines") || &oops('$blocked_machines');
@data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$blocked_machines");
foreach $row (@data)
{
@fields = split (/\|/, $row);
if ($fields[0] eq $ref)
{
}
else
{
print USER_FILE "$row";
}
}
close(USER_FILE);
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="1; URL=$guesturl?book=$book&action=view_to_edit&vat=$varurl"> ~;
&main_headerb;
print qq~
<center><font face=Arial size=+1>
<B>Active PowerBook Message Manager</B>
<p></font>
$cgifont
<a href="$guesturl?book=$book&action=control_panel&vat=$varurl">
<B>Computer unblocked</B></a><br>
</body>
</html> ~;
}
sub searchform
{
open(USER_FILE,"$field_names");
@layout_data4 = <USER_FILE>;
close(USER_FILE);

print qq~
<table width=$table_width cellspacing=0 cellpadding=0
~;
if ($trans_add ne "yes")
{
print qq~ bgcolor="$addcolor" ~;
if ($usebackgroundimageadd eq "yes")
{
print qq~ background = "$backgroundimageadd" ~;
}
}
print qq~ >
<tr valign=top><td width=50% align = right
~;
print qq~
>
<FORM ACTION="$guesturl" METHOD="POST"> <input type=hidden name="book" value="$book">
<font face= "$textfontface" size=$textfontsize color="$addtext"><INPUT TYPE="hidden" NAME="action" VALUE="search">
$TXT_you_can_search_this_guestbook_by<br> ~;
foreach $row (@layout_data4)
{
@layoutfields11 = split (/\|/, $row);
next if (($layoutfields11[34] ne "yes") || ($layoutfields11[21] ne "yes")
  || ($layoutfields11[12] == 10000020)  || ($layoutfields11[12] == 10000019) || ($layoutfields11[12] == 10000012)
     || ($layoutfields11[12] == 10000013)

);
print qq~ $layoutfields11[1]<INPUT TYPE="checkbox" NAME="mtloading$layoutfields11[12]" VALUE="yes"><br>
~;
}
print qq~ $TXT_searchall<INPUT TYPE="checkbox" NAME="search_fields_all" VALUE="all" checked><br> </td>
<td width=50% align = center><font face= "$textfontface" size=$textfontsize color="$addtext">
$TXT_searchtext</b><br><INPUT TYPE="text" NAME="search_words" SIZE="20" MAXLENGTH="40"><br>
<INPUT TYPE="submit" VALUE="$TXT_searchsearch"></FORM>
</td></tr></table>
~;

}
sub view_searchprefs
{
&seek_cook;
  if ($mastermanagemessagesonly eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>Access to this section is currently restricted.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
   }


&content;
print qq~
<HTML><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>Active PowerBook $cptext Search Preferences Manager</title>
~;
print qq~
</head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600">
~;
print qq~
<center><font face=Arial>
<table cellpadding = 1 cellspacing = 0 width=600><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
<tr><td width=100% colspan=2 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $cptext Search Preferences Manager</b></td></tr>
<tr><td colspan=2 align="center">$cgifont ~;
&linkjump; print qq~ </td></tr></form>
</table></td></tr></table> </td></tr></table>
<FORM ACTION="$guesturl" METHOD="POST">  <input type=hidden name="book" value="$book">
<input type=hidden name=action value="edit_searchprefs">

<table cellpadding = 1 cellspacing = 0 width=600><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak> ~;
print qq~ <tr><td align=left>$cgifont<b>Field Name</b></td>
<td align=left>$cgifont<b>Active</b></td>
<td align=left>$cgifont<b>Public</b></td>
<td align=center>$cgifont<b>Include in search</b></td>
</tr>
~;
open(USER_FILE,"$field_names");
@layout_data = <USER_FILE>;
close(USER_FILE);
@layout_data = sort(@layout_data);
foreach $row (@layout_data)
{
@layoutfields = split (/\|/, $row);
next if (($layoutfields[2] eq "date" )|| ($layoutfields[2] eq "VIEW RESPONSES" )|| ($layoutfields[2] eq "EDIT" )||($layoutfields[2] eq "ADD RESPONSE" )||($layoutfields[2] eq "PRIVATE_OPTION" ) );
$activeornot = "Active";
$activeornot = "<i>Inactive</i>" if ($layoutfields[21] ne "yes" );
$privateornot = "<i>Private</i>";
$privateornot = "Public" if ($layoutfields[13] ne "yes" );
$checked = "";
$checked = "checked" if ($layoutfields[34] eq "yes" );
print qq~ <tr><td align=left>$cgifont$layoutfields[1]</td>
<td align=left>$cgifont$activeornot</td>
<td align=left>$cgifont$privateornot</td>
<td align=center>$cgifont<input type="checkbox" $checked name="$layoutfields[0]" value="yes"></td>
</tr>
~;
}
print qq~ </table></td></tr></table></td></tr></table>
<input type=submit value="Make Changes"> ~;
print qq~ </form> ~;
}
sub edit_searchprefs
{
&seek_cook;
&get_file_lock("$location_of_lock_file");
open(USER_FILE,"$field_names");
@layout_data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$field_names");
foreach $row (@layout_data)
{
@layoutfields = split (/\|/, $row);
for ($x = 0; $x < 34; $x++)
{
print USER_FILE "$layoutfields[$x]";
print USER_FILE "|";
}
if ($FORM{$layoutfields[0]} eq "yes")
{
print USER_FILE "yes";
print USER_FILE "|";
}
else
{
print USER_FILE "|";
}

for ($x = 35; $x < 70; $x++)
{
print USER_FILE "$layoutfields[$x]";
print USER_FILE "|";
}
print USER_FILE "\n";
}


close(USER_FILE);
&release_file_lock("$location_of_lock_file");
&content;
print qq~ <html><head><title>$title</title><META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=control_panel&vat=$varurl"> </head>
<body bgcolor=#ffffff>
<center> ~;
&inter_footer;
exit;
}
sub search
{
open(USER_FILE,"$field_names");
@layout_data = <USER_FILE>;
close(USER_FILE);
if ($FORM{search_fields_all} eq "all")
{
foreach $row (@layout_data)
{
@layoutfields = split (/\|/, $row);
next if (($layoutfields[34] ne "yes") || ($layoutfields[21] ne "yes"));
push (@listofsearchcriteria1, $layoutfields[12]) ;
}

}
else
{
@listofsearchcriteria1 = @listofsearchcriteria;
}
&content;


&main_header;
@hits = ();
&user_html if $use_user_html eq "yes";
print qq~ <div align=$alignment> ~; # sets the alignment of the main page
print qq~ <table border=0 cellspacing=0 cellpadding=0 width=$table_width>
~;
$mtype = "SEARCHRESULTS";
open(USER_FILE,"$powerbook_data_name") || &oops('$powerbook_data_name');
@data = <USER_FILE>;
close(USER_FILE);
foreach $row (@data)
{
@fields = split (/\|/, $row);
if (($fields[10] ne "del") && ($fields[15] ne "waiting") && ($fields[16] ne "yes"))
{
$searchby2 = "";
$searchby = "";
foreach $numb(@listofsearchcriteria1)
{
$oneto = $FARRARY{$numb};
$searchby2 = (" " . $fields[$oneto] . " ");
$searchby = $searchby . " " . $searchby2;
}
@word_list = split(/\s+/,$search_words);
$no_of_words_in_search = @word_list;
for ($x = @word_list; $x > 0; $x--)
{
$match_word = $word_list[$x - 1];
if ($searchby =~ /$match_word/i)
# if ($searchby eq $match_word)
{
splice(@word_list,$x - 1, 1);
} # End of If
} # End of For Loop
if (@word_list < 1)
{
push (@hits, $row);
}
}
} # end foreach $row (@data)
close(USER_FILE);


if (@hits <1)
{
print "<tr><td><B><font face=\"$textfontface\" size=\"$textfontsize\">$TXT_no_match </font></B></td></tr>";
}
else
{
#&html_search_results;

$pagetype = "SEARCHRESULTS";
&load_page;
}

print qq~ </td></tr></table></div>~;
&user_html_footer if $use_user_html_footer eq "yes";
&inter_footer;

print qq~ </body></html> ~;
}

sub read_menus
{
$passwoor = $COOK{$cooknamelocal};
if ($passwoor eq $active_string)
{
$logged_in_cp = "yes";
}

@menualign = ("left", "center", "right");
open(USER_FILE,"$menu_name");
@menu_data = <USER_FILE>;
close(USER_FILE);
foreach $row (@menu_data)
{
@menufields = split (/\|/, $row);
$fullmenu = "";
$menutype = $menufields[0];
$lastone = "";
for ($x = 1; $x < 6; $x++)
{
$willwego = "no";
if (($menufields[$x] !~ /^NONE/) && ($menufields[$x] !~ /^LOGIN/))
{
$willwego = "yes";
}
if ($menufields[$x] =~ /^LOGIN/)
{
if (($whichusers eq "multiple passwords") || ($whichusers eq "single password"))
{
if ($COOK{'actiuse'} eq "ok")
{
$willwego = "no";
}
else
{
$willwego = "yes";
}
}
else
{
$willwego = "no";
}
}
if ($willwego eq "yes")
{
$lastone = $x;
}
}
for ($y = 1; $y < 6; $y++)
{
$willwego = "no";
if ($menufields[$y] !~ /^NONE/)
{
$willwego = "yes";
}
if ($willwego eq "yes")
{
$meunitem = $menufields[$y];
@mfields2 = split (/YZXZXZXY/, $meunitem);
if ($mfields2[0] eq "ADD"){
if (($whichusers eq "multiple passwords") || ($whichusers eq "single password")){
if ($COOK{'actiuse'} eq "ok"){
$urlitem = "<a href =\"$guesturl?book=$book&action=add&vat=$varurl\">" . $mfields2[1] . "</a>";
}
else{
$urlitem = "";
}
}
elsif ($whichusers eq "all")
{
$urlitem = "<a href =\"$guesturl?book=$book&action=add&vat=$varurl\">" . $mfields2[1] . "</a>";
}
else
{
$urlitem = "";
}
}
elsif ($mfields2[0] eq "ADDRESPONSE")
{
$ref = $FORM{'ref'};
if (($whichusers eq "multiple passwords") || ($whichusers eq "single password"))
{
if ($COOK{'actiuse'} eq "ok")
{
$urlitem = "<a href =\"$guesturl?book=$book&action=add_followup1&ref=$ref&vat=$varurl\">" . $mfields2[1] . "</a>";
}
else
{
$urlitem = "";
}
}
elsif ($whichusers eq "all")
{
$urlitem = "<a href =\"$guesturl?book=$book&action=add_followup1&ref=$ref&vat=$varurl\">" . $mfields2[1] . "</a>";
}
else
{
$urlitem = "";
}
}
elsif ($mfields2[0] eq "SEARCH")
{
$urlitem = "<a href =\"$guesturl?book=$book&action=loadsearch&vat=$varurl\">" . $mfields2[1] . "</a>";
}
elsif ($mfields2[0] eq "BACK")
{
$urlitem = "<a href =\"javascript:history.go(-1)\">" . $mfields2[1] . "</a>";
}
elsif ($mfields2[0] eq "LOGIN")
{
if (($whichusers eq "webmaster") || ($whichusers eq "all") )
{
$urlitem = "";
}
elsif ((($whichusers eq "multiple passwords") || ($whichusers eq "single password")) && ($COOK{'actiuse'} eq "ok"))
{
$urlitem = "";
}

else
{
$urlitem = "<a href =\"$guesturl?book=$book&action=userlogin&pagetype=LOGIN&vat=$varurl\">" . $mfields2[1] . "</a>";
}
}

elsif ($mfields2[0] eq "GUESTBOOK")
{
$randomload = time;
$urlitem = "<a href =\"$guesturl?book=$book&vat=$varurl\">" . $mfields2[1] . "</a>";
}
elsif ($mfields2[0] eq "USER")
{
$target = "";
$target = "target=\"$mfields2[3]\"" if $mfields2[3] ne "";
$mf = $mfields2[2];
$mf =~ s/http\:\/\///gi;
$urlitem = "<a href =\"http://" . $mf . "\" $target >" . $mfields2[1] . "</a>";
}
else
{
$urlitem = "<a href =\"http://" . $mfields2[2] . "\">" . $mfields2[1] . "</a>";
}
$fullmenu = $fullmenu . $urlitem unless ($urlitem eq "");
if ($y != $lastone)
{
if ($urlitem ne "")
{
$fullmenu = $fullmenu . $menufields[25];
}
}

}
$fullmenu =~ s/PIPEPIPE/|/gi;
}
$fullmenu =~ s/\$guesturl/$guesturl/gi;
$MENUS{$menutype} = $fullmenu;
$MENUSALIGN{$menutype} = $menualign[$menufields[24]];
$MENUSPPOST{$menutype} = $menufields[23];
$MENUSPPRE{$menutype} = $menufields[22];
$MENUSFONT{$menutype} = $menufields[12];
$MENUSFONTSIZE{$menutype} = $menufields[13];
$boldstart = "";
$boldend = "";
$italicstart = "";
$italicend = "";
$understart = "";
$underend = "";
if ($menufields[21] ==1)
{
$MENUSBSTART{$menutype} = "<b>"; $MENUSBEND{$menutype} = "</b>";
}
if ($menufields[20] ==1)
{
$MENUSISTART{$menutype} = "<i>"; $MENUSIEND{$menutype} = "</i>";
}
if ($menufields[19] ==1)
{
$MENUSUSTART{$menutype} = "<u>"; $MENUSUEND{$menutype} = "</u>";
}
}
}
sub menus
{
print qq~
<tr><td ~;
if (($usebackgroundimage eq "yes") && ($tem eq "pref"))
{
print qq~ background = "$backgroundimage" ~;
}
elsif (($usebackgroundimage ne "yes") && ($tem eq "pref"))
{
print qq~ BGCOLOR="$backcolor" ~;
}
$ftype = "$MENUSFONT{$mtype}";
$fsize = "$MENUSFONTSIZE{$mtype}";
print "colspan=6" if ($tem eq "pref");
print " width=$table_width " if ($tem ne "pref");
$mpr=$MENUSPPRE{$mtype};
$mpo=$MENUSPPOST{$mtype};
$mpr =~ s/PIPEPIPE/\|/gi;
$mpo =~ s/PIPEPIPE/\|/gi;
print qq~ align=$MENUSALIGN{$mtype}>
<font face="$ftype" size="$fsize">
$mpr
$MENUSBSTART{$mtype}$MENUSISTART{$mtype}
$MENUS{$mtype}
$MENUSIEND{$mtype}$MENUSBEND{$mtype}
$mpo </font>
</td></tr>
~;
}
sub check_for_message_date
{
$lyout = reverse($lyout);
&content;
print "$lyout";
exit;
}
sub view_menuprefs
{
&seek_cook;
 if ($mastermanagemessagesonly eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>Access to this section is currently restricted.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
  }
if ($mastermenu eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>These settings are currently controlled by the Master Control Panel.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
}

@menualign = ("left", "center", "right");
&content;
print qq~ <html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>Active PowerBook $cptext Menu Manager</title> ~;
if ($style ne "no")
{
print qq~ $user_style ~;
}
$tablefont = "Arial";
$tablefontsize = "2";
$tablefontcolor = "Black";
$tf = "<font face=\"$tablefont\" size=\"$tablefontsize\" color=\"$tablefontcolor\">";
print qq~ </head>
<body bgcolor=#ffffff TEXT="$text" LINK="$link" VLINK="$vlink"> <center>
<font face=Arial size=2 color=black>
<table cellpadding = 1 cellspacing = 0 width=800><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $cptext Menu Manager</b></td></tr>
<tr><td width=100% align=center>
$cgifont
~;
&linkjump;
if ($style ne "no")
{
print qq~ <br> <font color=black> PLEASE NOTE. CSS is currently enabled in the Standard Preferences Manager.
<br>Settings in the CSS code MAY override the configuration below. </font></font> ~;
}
print qq~ </td></tr></form> <FORM ACTION="$guesturl" METHOD="POST">
<input type=hidden name="book" value="$book"><INPUT TYPE="hidden" NAME="action" VALUE="edit_menuprefs"></table></td></tr></table></td></tr></table> ~;

open(USER_FILE,"$menu_name");
@menu_data = <USER_FILE>;
close(USER_FILE);
foreach $row (@menu_data)
{
@menufields = split (/\|/, $row);
$menuname = $menufields[0];
for ($x = 1; $x < 26; $x++)
{
%{$MENUFIELD{$menuname}}->{$x} = $menufields[$x];
# print(%{$MENUFIELD{$menuname}}->{$x} . "<br>");
}
}
%menunam = ('ADD', 'Add Message page', 'SEARCH', 'Search page',
'SEARCHRESULTS', 'Search Results page', 'MAIN', 'Main PowerBook page',
'LOGIN', 'Login page','RESPONSE', 'Add Response page', 'EDIT', 'Edit page','VIEWRESPONSE', 'View Responses page' );
%SELOPTIONS = ("GUESTBOOK", "Main page", "ADD", "Add a message", "LOGIN", "Log in", "BACK",
"Go back", "SEARCH", "Search", "USER", "User defined", "NONE", "UNUSED", "ADDRESPONSE", "Add Response");
@menualign = ("left", "center", "right");

@keys = sort keys %MENUFIELD;
foreach $key(@keys)
{
$foundadd = "no";
$foundlogin = "no";
$xalign = (%{$MENUFIELD{$key}}->{24});
$xbold = (%{$MENUFIELD{$key}}->{21});
$xitalic = (%{$MENUFIELD{$key}}->{20});
#$xunderline = (%{$MENUFIELD{$key}}->{19});
$xfont = (%{$MENUFIELD{$key}}->{12});
$xsize = (%{$MENUFIELD{$key}}->{13});
$xpre = (%{$MENUFIELD{$key}}->{22});
$xpost = (%{$MENUFIELD{$key}}->{23});

$sep = (%{$MENUFIELD{$key}}->{25});
$sep =~ s/PIPEPIPE/\|/gi;
$xpost =~ s/PIPEPIPE/\|/gi;
$xpre =~ s/PIPEPIPE/\|/gi;

print qq~ <table cellpadding = 1 cellspacing = 0 width=800><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>

<input type=hidden name="$key-0" value="$key">
<tr valign=top><td colspan=2> $tf<b>$menunam{$key}</b> </td>
<td colspan=4> $tf
Pre menu><input size=15 type=text value="$xpre" name="$key-22"> : Post menu><input size=15 type=text value="$xpost" name="$key-23">
</td>
</tr>
<tr valign=top><td colspan=6> $tf Separator><input type=text size=2 value="$sep" name="$key-25">
: Font><input type = text size=5 value = "$xfont" name="$key-12"> : Size><input type = text size=1 value = "$xsize" name="$key-13">

: Alignment>~;
print qq~ <select name= "$key-24" size=1 onchange="this.form.submit();"> ~;
for ($x = 0; $x < 3; $x++)
{
print qq~ <option value="$x" ~;
print "selected" if $x eq $xalign;
print qq~ >$menualign[$x]</option> ~;
}
print qq~ </select> : Bold><input type="checkbox" name="$key-21" value="1" ~;
print "checked" if ($xbold eq "1");
print qq~ > : Italic><input type="checkbox" name="$key-20" value="1" ~;
print "checked" if ($xitalic eq "1");
print qq~ > ~;


print qq~ </td></tr>
<tr valign=top>
<td>$tf<b>
<input type=text name=box value="Type" onChange="this.value='Type';" size=4 readonly>><br>
<input type=text name=box value="Text" onChange="this.value='Text';" size=4 readonly>><br>
<input type=text name=box value="URL" onChange="this.value='URL';" size=4 readonly>>
<br>
<input type=text name=box value="Target" onChange="this.value='Target';" size=4 readonly>>
</b></td>
~;

for ($x = 1; $x < 6; $x++)
{
$itemdetails = (%{$MENUFIELD{$key}}->{$x});
@inds = split (/YZXZXZXY/, $itemdetails);
print qq~ <td>$cgifont
<select name= "$key-$x-1-FFFFF" size=1 onchange="this.form.submit();"> ~;
while (($keyo, $valueo) = each(%SELOPTIONS))
{
unless (($keyo eq "ADDRESPONSE") && ($key ne "VIEWRESPONSE")){
print qq~ <option value = "$keyo" ~;
print "selected" if $keyo eq $inds[0] ;
print qq~ >$valueo</option> ~;
}
}
print qq~ </select><br> ~;

$in1 = $inds[1];
$in2 = $inds[2];
$in3 = $inds[3];
$in1 =~ s/PIPEPIPE/\|/gi;
$in2 =~ s/PIPEPIPE/\|/gi;
$in3 =~ s/PIPEPIPE/\|/gi;
if ($inds[0] ne "NONE")
{
print qq~ <input type=text name="$key-$x-2-FFFFF" value="$in1" size=15 >
<br> ~;
}
else
{
print qq~ <input type=hidden name="$key-$x-2-FFFFF" value="$in1" > ~;
}
if ($inds[0] eq "USER")
{
$in2 =~ s/http\:\/\///gi;
print qq~ <input type=text name="$key-$x-3-FFFFF" value="$in2" size=15 ><br>
<input type=text name="$key-$x-4-FFFFF" value="$in3" size=15 > ~;
}
else
{
if (($inds[0] eq "ADD") || ($inds[0] eq "LOGIN") || ($inds[0] eq "ADDRESPONSE") )
{
print qq~ <a href="#help"><font face = arial size=1>help</font></a> ~;
}
print qq~ <input type=hidden name="$key-$x-3-FFFFF" value="$in2" > ~;
}
print "</td>";
}
$mtype= $key;
$tem = "pref";
&menus;
print qq~ </tr> ~;
print qq~ </table> </td></tr></table> </td></tr></table> ~;
}
print qq~ <input type=submit value="Make Changes"></form></center>
<p>
<br><b>Log In menu items will not appear if</b>
<br>a) the ability to add messages is set for ALL users (set this in the <a href="$guesturl?book=$book&action=view_access&vat=$varurl">Access Manager</a>),
<br>b) the ability to add messages is set for webmaster only (set this in the <a href="$guesturl?book=$book&action=view_access&vat=$varurl">Access Manager</a>) or
<br>c)
you have already already successfully logged in as a guest.<p>
<b>Add A Message/Response menu items will not appear if</b> <br>a)
access is set for webmaster only (set this in the <a href="$guesturl?book=$book&action=view_access&vat=$varurl">Access Manager</a>, you can add messages via the Control Panel at any time) or <br>b)
a password is required to add messages and you have not yet logged in as a guest.<p><a name="help"></a>
</td></tr></table>
~;
}
sub edit_menuprefs
{
&seek_cook;
open(USER_FILE,"$menu_name");
@menu_data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$menu_name");
@menunam = ('ADD', 'SEARCH', 'SEARCHRESULTS', 'MAIN', 'LOGIN', 'RESPONSE','EDIT', 'VIEWRESPONSE' );
foreach $mentype(@menunam)
{
$field = "$mentype" . "-" . "0";
$data = "$FORM{$field}";
$data =~ s/\|/PIPEPIPE/gi;
print USER_FILE "$data"; print USER_FILE "|";
for ($x = 1; $x < 6; $x++)
{
for ($y = 1; $y < 5; $y++)
{
$field = "$mentype" . "-" . "$x" . "-" . "$y" . "-". "FFFFF";
$data = "$FORM{$field}";
$data =~ s/\|/PIPEPIPE/gi;
print USER_FILE "$data"; print USER_FILE "YZXZXZXY";
}
print USER_FILE "|";
}
for ($x = 6; $x < 26; $x++)
{
$field = "$mentype" . "-" . "$x";
$data = "$FORM{$field}";
$data =~ s/\|/PIPEPIPE/gi;
print USER_FILE "$data"; print USER_FILE "|";
}
print USER_FILE "\n";
}
close(USER_FILE);
&content;
print qq~ <html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title></title><META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_menuprefs&vat=$varurl"> </head>
<body bgcolor=#ffffff> ~;
# @menu_data = ();
# &read_menus;
#&view_menuprefs;
}
sub view_access
{
&seek_cook;
 if ($mastermanagemessagesonly eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>Access to this section is currently restricted.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
   }
if ($masteraccess eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>These settings are currently controlled by the Master Control Panel.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
}


&content;
print qq~ <html><head> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from non-Java browsers
function ConfirmWipe() {
var Confirmation;
Confirmation = "Are you sure you want to permanently DELETE this user? ";
if (confirm(Confirmation)) {
return true;
}
else {
return false;
}
}
// End Java Hiding. --> </SCRIPT>
</head><body bgcolor=#ffffff>
<center>$cgifont
<table cellpadding = 1 cellspacing = 0 width=800><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $ccptext Access Manager</b></td></tr>
<tr><td width=100% align=center>
$cgifont ~;
&linkjump;
if ($whichusers eq "multiple passwords")
{
print qq~ - <a href="$guesturl?book=$book&action=view_to_add_user_from_cp&vat=$varurl">Add User</a> ~;
}
print qq~ </td></tr></form><tr><td align=center>$cgifont ~;
@perms = ("Level 0","Level 1","Level 2","Level 3");
@permstext = ("All visitors can add messages","Visitors with shared password can add messages. Edit password below.",
"Visitors with individual passwords can add messages. Edit users below","Only webmaster can add messages");
print qq~
<FORM ACTION="$guesturl" METHOD="POST"><input type=hidden name="book" value="$book">
<INPUT TYPE="hidden" NAME="action" VALUE="update_perms">
Security level - <select name="newperm" size=1 onchange="this.form.submit();">~;
for ($x = 0; $x < 4; $x++)
{
print qq~ <option value="$x" ~;
print "selected" if $x eq $permvalue;
print qq~ >$perms[$x]</option> ~;
}
@sta = ("inactive","active");
print qq~ </select><p><b>$permstext[$permvalue]</b>
</form> <p> ~;
@perlevels = ("Permission to add messages","Permission to add messages and manage messages","Full access to Control Panel");
if ($permvalue eq "2")
{
print qq~ <table BORDER=1 CELLSPACING=0 CELLPADDING=3>
<tr> <td>$cgifont<B>Email</B></td>
<td>$cgifont<B>Password</B></td>
<!-- <td>$cgifont<B>Access</B></td> -->
<td>$cgifont<B>Staus</B></td>
<td colspan=3><b>&nbsp;</b></td> </tr>
~;
foreach $line(@access_data)
{
@fields = split (/\|/, $line);
print qq~ <tr>
<td>$cgifont ~;
print "<b>" if ($fields[1] eq "1");
print qq~ $fields[4]~;
print "</b>" if ($fields[1] eq "1");
print qq~</td>
<td>$cgifont$fields[2]</td>
<!-- <td>$cgifont$fields[3]</td> -->
<td>$cgifont$sta[$fields[1]]</td>
~;
if ($fields[1] eq "1")
{
print qq~ <td>$cgifont<a href="$guesturl?book=$book&action=disable_user&user=$fields[0]&vat=$varurl">make inactive</a></td>
~; }
else
{
print qq~ <td>$cgifont<a href="$guesturl?book=$book&action=enable_user&user=$fields[0]&vat=$varurl">make active</a></td>
~;
}
print qq~ <td>$cgifont<a href="$guesturl?book=$book&action=delete_user&user=$fields[0]&vat=$varurl" OnClick="return ConfirmWipe()">delete</a></td>
<td>$cgifont<a href="$guesturl?book=$book&action=view_to_edit_user&user=$fields[0]&vat=$varurl">edit</a></td>
</tr>
~;
}
print "</table>";
}
elsif ($permvalue eq "0")
{
print "No passwords required";
}
elsif ($permvalue eq "1")
{
print qq~ <FORM ACTION="$guesturl" METHOD="POST"><input type=hidden name="book" value="$book">
<INPUT TYPE="hidden" NAME="action" VALUE="update_single_perm">
Password for all users to add messages<br>
<b>Current password - $singlepermvalue</b>
<br>
<input type=text size=8 name="newsingleperm" value=""> <input type=submit value="Change password">
</form>
~;
}
elsif ($permvalue eq "3")
{
print "Messages can only be added if logged in to the Control Panel";
}
print qq~ </td></tr></table></td></tr></table></td></tr></table> ~;
}
sub update_perms
{
&seek_cook;
open(USER_FILE,">$perms");
print USER_FILE "$FORM{'newperm'}";
close(USER_FILE);
&content;
print qq~ <html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language">
<title></title><META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_access&vat=$varurl"> </head>
<body bgcolor=#ffffff> ~;
}
sub disenable_user
{
&seek_cook;
open(USER_FILE,"$access_name");
@access_data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$access_name");
foreach $row (@access_data)
{
@fields = split (/\|/, $row);
if ($fields[0] eq $FORM{'user'})
{
print USER_FILE "$fields[0]|";
print USER_FILE "1|" if $action eq "enable_user";
print USER_FILE "0|" if $action eq "disable_user";
for ($x = 2; $x < 14; $x++)
{
print USER_FILE "$fields[$x]|";
}
print USER_FILE "\n";
}
else
{
print USER_FILE "$row";
}
}
&content;
print qq~ <html><head><title></title><META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_access&vat=$varurl"> </head>
<body bgcolor=#ffffff> ~;
}
sub delete_user
{
&seek_cook;
open(USER_FILE,"$access_name");
@access_data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$access_name");
foreach $row (@access_data)
{
@fields = split (/\|/, $row);
unless ($fields[0] eq $FORM{'user'})
{
print USER_FILE "$row";
}
}
&content;
print qq~ <html><head><title></title><META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_access&vat=$varurl"> </head>
<body bgcolor=#ffffff> ~;
}
sub view_to_edit_user
{
&seek_cook;
&content;
open(USER_FILE,"$access_name");
@access_data = <USER_FILE>;
close(USER_FILE);
foreach $row (@access_data)
{
@fields = split (/\|/, $row);
if ($fields[0] eq $FORM{'user'})
{
for ($x = 0; $x < 14; $x++)
{
$DATA{$x} = $fields[$x];
}
last;
}
}
print qq~
<FORM ACTION="$guesturl" METHOD="POST"><input type=hidden name="book" value="$book">
<INPUT TYPE="hidden" NAME="action" VALUE="edit_user">
<INPUT TYPE="hidden" NAME="ref" VALUE="$DATA{'0'}">
<INPUT TYPE="hidden" NAME="0" VALUE="$DATA{'0'}"> ~;
@perlevels = ("Permission to add messages","Permission to add messages and manage messages","Full access to Control Panel");
@status = ("inactive","active");

print qq~
<center>
<table cellpadding = 1 cellspacing = 0 width=600><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook - Edit Access Details</b></td></tr>
<tr><td width=100% align=center>
$cgifont <a href="$guesturl?book=$book&action=view_access&vat=$varurl">Access Manager</a> <p>
<b> Access details for $DATA{'4'} </b>
<p>
<table border=0 cellspacing=2>
<tr><td>$cgifont Email address</td><td>$cgifont
<input type=text size=40 name="4" value="$DATA{'4'}"></td></tr>
<tr><td>$cgifont Status</td><td>$cgifont
<select name="1" size=1 onchange="this.form.submit();">~;
for ($y = 0; $y < 2; $y++)
{
print qq~ <option value="$y" ~;
print "selected" if ($y eq $DATA{'1'});
print qq~ >$status[$y]</option>
~;
}
print qq~ </select></td></tr>
<tr><td>$cgifont Password</td><td>$cgifont
<input type=text size=10 name="2" value="$DATA{'2'}"></td></tr>
<!-- <tr><td>$cgifont Access level</td><td>$cgifont
<select name="3" size=1 onchange="this.form.submit();">~;
for ($y = 0; $y < 3; $y++)
{
print qq~ <option value="$y" ~;
print "selected" if ($y eq $DATA{'3'});
print qq~ >$perlevels[$y]</option>
~;
}
print qq~ </select></td></tr> -->
~;
print qq~ </table> </td></tr></table></td></tr></table> <center><input type=submit value="Update"> </form> ~;
}
sub update_single_perm
{
&seek_cook;
$detailpass = $FORM{'newsingleperm'};
if (($detailpass =~ /\s/)|| (length($detailpass) < 4)||($detailpass =~ /\|/))
{ &content;
print qq~ <center>$cgifont
Password must be more that 3 characters, cannot contain spaces, and cannot contain the "|" character.<br>
Please <a href="javascript:history.go(-1)">go back</a> and edit.
~;
exit;
}
open(USER_FILE,">$singleperms");
print USER_FILE "$FORM{'newsingleperm'}";
close(USER_FILE);
&content;
print qq~ <html><head><title></title><META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_access&vat=$varurl"> </head>
<body bgcolor=#ffffff> ~;

}
sub edit_user
{
&seek_cook;
&content;
open(USER_FILE,"$access_name");
@access_data = <USER_FILE>;
close(USER_FILE);
open(USER_FILE,">$access_name");
foreach $row (@access_data)
{
@fields = split (/\|/, $row);
if ($fields[0] eq $FORM{'ref'})
{
for ($x = 0; $x < 14; $x++)
{
print USER_FILE "$FORM{$x}|";
}
print USER_FILE "\n";
}
else
{
print USER_FILE "$row";
}

}
close(USER_FILE);

print qq~ <html><head>
<META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_access&vat=$varurl"> </head>
<body bgcolor=#ffffff> ~;
}
sub view_to_add_user_from_cp
{
&seek_cook;
&content;
print qq~
<FORM ACTION="$guesturl" METHOD="POST"> <input type=hidden name="book" value="$book">
<INPUT TYPE="hidden" NAME="action" VALUE="add_user_from_cp"> ~;
#@perlevels = ("Permission to add messages","Permission to add messages and manage messages","Full access to Control Panel");
@status = ("inactive","active");
print qq~
<center> $cgifont <table cellpadding = 1 cellspacing = 0 width=500><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td width=100% colspan=2 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook - Add New User</b></td></tr>
<tr><td width=100% align=center colspan=2>
<font face="Arial" size="2">
<a href="$guesturl?book=$book&action=view_access&vat=$varurl">Access Manager</a>
</td></tr>
<tr><td>$cgifont Email address</td><td>$cgifont
<input type=text size=40 name="4"></td></tr>
<tr><td>$cgifont Status</td><td>$cgifont
<select name="1" size=1>~;
for ($y = 0; $y < 2; $y++)
{
print qq~ <option value="$y" ~;
print "selected" if ($y eq "1");
print qq~ >$status[$y]</option>
~;
}
print qq~ </select></td></tr>
<tr><td>$cgifont Password</td><td>$cgifont
<input type=text size=10 name="2"></td></tr>

<!-- <tr><td>$cgifont Access level</td><td>$cgifont
<select name="3" size=1>~;
for ($y = 0; $y < 3; $y++)
{
print qq~ <option value="$y" ~;
print "selected" if ($y eq "0");
print qq~ >$perlevels[$y]</option>
~;
}
print qq~ </select></td></tr> -->
<tr><td colspan=2 align=center>$cgifont<input type=submit value="Add"></td></tr>
~;
print qq~ </table></td></tr></table></td></tr></table></form> ~;
}
sub add_user_from_cp
{
&seek_cook;
open(USER_FILE,"$access_name");
@access_data = <USER_FILE>;
close(USER_FILE);
$detailpass = $FORM{'2'};
if (($detailpass =~ /\s/)|| (length($detailpass) < 4)||($detailpass =~ /\|/))
{ &content;
print qq~ <center>$cgifont
Password must be more that 3 characters, cannot contain spaces, and cannot contain the "|" character.<br>
Please <a href="javascript:history.go(-1)">go back</a> and edit.
~;
exit;
}
$detail = $FORM{'4'};
$detail =~ s/\s+//gi;
$FORM{'4'} = $detail;
&check_address_for_mistakes;
$old=0;
foreach $row (@access_data)
{
@fields = split (/\|/, $row);
$new = $fields[0];
if ($FORM{'4'} eq $fields[4])
{
&content;
print qq~ <center>$cgifont
Email address already exists in user list. Please <a href="javascript:history.go(-1)">go back</a> and edit.
~;
exit;
}
if ($new > $old)
{
$count = $new;
}
$old = $new;
}
$count++;
open(USER_FILE,">>$access_name");
print USER_FILE "$count|";
for ($x = 1; $x < 14; $x++)
{
print USER_FILE "$FORM{$x}|";
}
print USER_FILE "\n";
close(USER_FILE);
&content;
print qq~ <html><head><title></title><META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_access&vat=$varurl"> </head>
<body bgcolor=#ffffff> ~;
}
sub dup
{
&content;
print qq~ <center>$cgifont
Email address already exists in user list. Please <a href="javascript:history.go(-1)">go back</a> and edit.
~;
exit;
}
sub loadsearch
{
&content;
&main_header;
&user_html if $use_user_html eq "yes";
print qq~ <div align=$alignment> ~; # sets the alignment of the main page
# start of table to hold guestbook
print qq~ <table border=0 cellspacing=0 cellpadding=0 width=$table_width>
~;
$pagetype = "SEARCH";
&load_page; #this calls the searchform
print qq~ </td></tr></table> ~;
print qq~ </div>~;
&user_html_footer if $use_user_html_footer eq "yes";
&inter_footer;
}

sub userlogin
{
&content;
&main_header;
&user_html if $use_user_html eq "yes";
print qq~ <div align=$alignment> ~; # sets the alignment of the main page
# start of table to hold guestbook
print qq~ <table border=0 cellspacing=0 cellpadding=0 width=$table_width><tr><td>
~;
$pagetype = "LOGIN";
&load_page; #this calls userloginbody
print qq~ </td></tr></table> ~;
print qq~ </div>~;
&user_html_footer if $use_user_html_footer eq "yes";
&inter_footer;
}
sub userloginbody
{
print qq~ <FORM ACTION="$guesturl" METHOD="POST"><input type=hidden name="book" value="$book">
 <INPUT TYPE="hidden" NAME="action" VALUE="verifyuserlogin">
<table width=$table_width cellspacing=2 cellpadding=2 border=0
~;
unless ($trans_add eq "yes")
{
print qq~ bgcolor="$addcolor" ~;
if ($usebackgroundimageadd eq "yes")
{
print qq~ background = "$backgroundimageadd" ~;
}
}
print qq~ >~;
if (($whichusers eq "multiple passwords") || ($guess eq "indeed"))
{ print qq~
<tr valign=top><td width=50% align = right><font face= "$textfontface" size=$textfontsize color="$addtext">$TXT_user_email_required </td>
<td width=50% align = left><font face= "$textfontface" size=$textfontsize>
<b></b><INPUT TYPE="text" NAME="loginuser" SIZE="20" MAXLENGTH="40">
</td></tr>
~;
}
if (($whichusers eq "multiple passwords") || ($whichusers eq "single password") || ($guess eq "indeed") )
{ print qq~
<tr valign=top><td width=50% align = right><font face= "$textfontface" size=$textfontsize color="$addtext">$TXT_user_password_required </td>
<td width=50% align = left><font face= "$textfontface" size=$textfontsize>
<b></b><INPUT TYPE="password" NAME="loginpass" SIZE="20" MAXLENGTH="40">
</td></tr>
~;
}
print qq~
<tr><td colspan=2 align=center><INPUT TYPE="submit" VALUE="Login"></FORM> </td></tr>
</table>
~;

}
sub verifyuserlogin
{
$continue = "no";
if ($whichusers eq "single password")
{
$continue = "yes" if (lc($FORM{'loginpass'}) eq lc($singlepermvalue));
}
elsif ($whichusers eq "multiple passwords")
{

foreach $bit(@access_data)
{
@fs = split(/\|/, $bit );
if (
(
(lc($fs[4])) eq (lc($FORM{'loginuser'}))
)
&& (
(lc($fs[2])) eq (lc($FORM{'loginpass'}))
)
)
{
$continue = "yes";
}
}
}
if ($continue eq "yes")
{
print "Set-Cookie:actiuse=ok\n";
}
else
{
print "Set-Cookie:actiuse=nok\n";
}
&content;
if ($continue eq "yes")
{
$var=time;
print qq~ <html><head><title></title><META http-equiv="refresh" content="0; URL=$guesturl?book=$book&var=$var"> </head>
<body bgcolor=#ffffff> ~;
exit;
}
else
{
print qq~
<html><head><title></title><META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=userlogin&vat=$varurl"> </head>
<body bgcolor=#ffffff>
~;
exit;
}
}
sub logout
{
&seek_cook;
print "Set-Cookie:$cooknamelocal=\n";
$var=time;
&content;
print qq~ <html><head><title></title><META http-equiv="refresh" content="0; URL=$guesturl?book=$book&var=$var"> </head>
<body bgcolor=#ffffff> ~;
exit;
}
sub view_page_layout
{
# &content;
&seek_cook;
 if ($mastermanagemessagesonly eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>Access to this section is currently restricted.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
   }
if ($masterlayout eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>These settings are currently controlled by the Master Control Panel.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
}


%menunam = ('ADD', 'Add', 'SEARCH', 'Search',
'SEARCHRESULTS', 'Results', 'MAIN', 'Main', 'LOGIN', 'Login', 'RESPONSE', 'Respond',
'VIEWRESPONSE', 'Responses', 'EDIT', 'Edit' );
@keyss = sort keys %menunam;
if ($FORM{'action'} eq "update_page_items")
{
for ($DATA = 10000001; $DATA < 10000021; $DATA++)
{
for ($y = 23; $y < 38; $y++)
{
$item = "$DATA" . "zzzz" . "$y";
%{$ALLDATA{$DATA}}->{$y} = $FORM{$item};
}
}
open(USER_FILEWWW,"$layout_name");
@lay_data = <USER_FILEWWW>;
close(USER_FILEWWW);
open(USER_FILEWWW,">$layout_name");
foreach $rowneww (@lay_data)
{
@fsr = split (/\|/, $rowneww);
for ($x = 0; $x < 50; $x++)
{
if (($x <23) || ($x > 31))
{
print USER_FILEWWW "$fsr[$x]|";
}
else
{
$ref = $fsr[1];
$xpost = (%{$ALLDATA{$ref}}->{$x});
print USER_FILEWWW "$xpost|";
}
}
print USER_FILEWWW "\n";
}
close(USER_FILEWWW);
}
if ($FORM{'action'} eq "newactive_inactive")
{
open(USER_FILEWWW,"$layout_name");
@lay_data = <USER_FILEWWW>;
close(USER_FILEWWW);
open(USER_FILEWWW,">$layout_name");
foreach $rowneww (@lay_data)
{
@fsr = split (/\|/, $rowneww);
if ($fsr[1] eq $FORM{'field'})
{
$change = "yes" if ($fsr[3] ne "yes");
$change = "no" if ($fsr[3] eq "yes");
print USER_FILEWWW "$fsr[0]|$fsr[1]|$fsr[2]|$change|$fsr[4]|$fsr[5]|$fsr[6]|$fsr[7]|$fsr[8]|$fsr[9]|$fsr[10]|$fsr[11]|$fsr[12]|$fsr[13]|$fsr[14]|$fsr[15]|$fsr[16]|$fsr[17]|$fsr[18]|$fsr[19]|$fsr[20]|$fsr[21]|$fsr[22]|$fsr[23]|$fsr[24]|$fsr[25]|$fsr[26]|$fsr[27]|$fsr[28]|$fsr[29]|$fsr[30]|$fsr[31]|$fsr[32]|$fsr[33]|$fsr[34]|$fsr[35]|$fsr[36]|$fsr[37]|$fsr[38]|$fsr[39]|$fsr[40]|$fsr[41]|$fsr[42]|$fsr[43]|$fsr[44]|$fsr[45]|$fsr[46]|$fsr[47]|$fsr[48]|$fsr[49]|\n";
}
else
{
print USER_FILEWWW "$rowneww";
}
}
close(USER_FILEWWW);
}
open(USER_FILEWWW,"$layout_name");
@lay_data = <USER_FILEWWW>;
close(USER_FILEWWW);
@lay_data = sort(@lay_data);
&content;
$colorhere = "black";
print qq~
<HTML><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>$title</title>
~;
if ($style ne "no")
{
print qq~ $user_style ~;
}
print qq~
</head>
<body bgcolor=#ffffff>
~;
print qq~ <center>
<table cellpadding = 1 cellspacing = 0 width=800><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>

<tr><td width=100% colspan=2 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $cptext Page Layout Manager</b></td></tr>
<tr><td colspan=2 align="center">$cgifont ~;
&linkjump; print qq~ -
<a href="#sample"><font color=$colorhere>Sample</font></a> </td></tr></form>
<FORM ACTION="$guesturl" METHOD="POST" name="tryit"> <input type=hidden name="book" value="$book">
<INPUT TYPE="hidden" NAME="action" VALUE="update_page_items">
<tr><td width="50%"></td><td align=center width="50%"><b>$cgifont Select pages</b></td> </tr>
</table></td></tr></table></td></tr></table>
<table cellpadding = 1 cellspacing = 0 width=800><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
<tr><td>$cgifont No.</td> <td>$cgifont Type</td><td></td> <td></td><td></td><td></td>
<td>$cgifont Main </td><td>$cgifont Add </td><td>$cgifont Respond</td><td>$cgifont Login </td>
<td>$cgifont Search</td><td>$cgifont Results</td><td>$cgifont Responses</td><td>$cgifont Edit</td></tr>
~;
%types = ("FILE", "File", "IMAGE", "Image","TEXT", "Text", "TOTAL", "Total messages",
"MENU", "Link Menu", "TABLES", "Messages/Main Body", "HTML", "Html", "VIEWING", "Viewing messages",
"NONE", "Unused", "NUMMENU", "Number menu");
$pagetype = $FORM{'pagetype'};
$pagetype = "MAIN" if ($FORM{'pagetype'} eq "");
@lay_data = sort(@lay_data);
$kk = 0;
$fldno = 0;
foreach $line(@lay_data)
{
$kk++;
print qq~ <tr valign=top>
~;
@flss = split (/\|/, $line);
$fldno++;
$act = "Inactive";

$ft = "color=red";
$act = "Active" if $flss[3] eq "yes";
$ft = "color=blue" if $flss[3] eq "yes";
print qq~ <td><font face=Arial size=2 $ft>$fldno </td>
<td><font face=Arial size=2 $ft> $types{$flss[2]} ~;
if ($types{$flss[2]} eq "Text")
{
$foll = "";
if (length($flss[8]) > 25)
{
$foll = "\.\.\.";
}
$textleft = substr($flss[8],0,25);
$textleft = $textleft . $foll;
print qq~ <i>($textleft)</i> ~;
}
print qq~</td> ~;
print qq~ <td>$cgifont<a href="$guesturl?book=$book&action=newactive_inactive&field=$flss[1]&vat=$varurl&pagetype=$pagetype"><font color=$colorhere>$act </font></a></td> ~;
print qq~ <td>$cgifont<a href="$guesturl?book=$book&action=view_to_edit_page_layout&field=$flss[1]&vat=$varurl&pagetype=$pagetype"><font color=$colorhere>Edit </font></a></td> ~;
if ($kk == 1)
{print qq~ <td></td> ~;}
else
{print qq~ <td>$cgifont<a href="$guesturl?book=$book&action=overlayup&field=$flss[1]&vat=$varurl&pagetype=$pagetype"><font color=$colorhere>Up </font></a></td> ~;}
if ($kk == 20)
{print qq~ <td></td> ~;}
else
{ print qq~ <td>$cgifont<a href="$guesturl?book=$book&action=overlaydown&field=$flss[1]&vat=$varurl&pagetype=$pagetype"><font color=$colorhere>Down </font></a></td> ~;}
if ($flss[3] eq "yes")
{
$check23 = ""; $check23 = "checked" if ($flss[23] eq "yes");
$check24 = ""; $check24 = "checked" if ($flss[24] eq "yes");
$check25 = ""; $check25 = "checked" if ($flss[25] eq "yes");
$check26 = ""; $check26 = "checked" if ($flss[26] eq "yes");
$check27 = ""; $check27 = "checked" if ($flss[27] eq "yes");
$check28 = ""; $check28 = "checked" if ($flss[28] eq "yes");
$check29 = ""; $check29 = "checked" if ($flss[29] eq "yes");
$check30 = ""; $check30 = "checked" if ($flss[30] eq "yes");
print qq~ <td align=center>$cgifont<input type="checkbox" name="$flss[1]zzzz23" value="yes" $check23 > </td> ~;
if (($flss[2] eq "VIEWING") || ($flss[2] eq "NUMMENU") || ($flss[2] eq "TOTAL") )
{
print qq~ <td align=center><font face=arial size=1> x </td>
<td align=center><font face=arial size=1> x </td><td align=center><font face=arial size=1> x </td>
<td align=center><font face=arial size=1> x </td> <td align=center><font face=arial size=1> x </td>
<td align=center><font face=arial size=1> x </td> <td align=center><font face=arial size=1> x </td> ~;
}
else
{
print qq~ <td align=center>$cgifont<input type="checkbox" name="$flss[1]zzzz24" value="yes" $check24 > </td> ~;
print qq~ <td align=center>$cgifont<input type="checkbox" name="$flss[1]zzzz28" value="yes" $check28 > </td> ~;
print qq~ <td align=center>$cgifont<input type="checkbox" name="$flss[1]zzzz25" value="yes" $check25 > </td> ~;
print qq~ <td align=center>$cgifont<input type="checkbox" name="$flss[1]zzzz26" value="yes" $check26 > </td> ~;
print qq~ <td align=center>$cgifont<input type="checkbox" name="$flss[1]zzzz27" value="yes" $check27 > </td> ~;
print qq~ <td align=center>$cgifont<input type="checkbox" name="$flss[1]zzzz29" value="yes" $check29 > </td> ~;
print qq~ <td align=center>$cgifont<input type="checkbox" name="$flss[1]zzzz30" value="yes" $check30 > </td> ~;
}

}
else
{
print qq~ <td align=center><font face=arial size=1> x </td>
<td align=center><font face=arial size=1> x </td><td align=center><font face=arial size=1> x </td>
<td align=center><font face=arial size=1> x </td><td align=center><font face=arial size=1> x </td>
<td align=center><font face=arial size=1> x </td><td align=center><font face=arial size=1> x </td>
<td align=center><font face=arial size=1> x </td> ~;
}
}
#$pagetype = $FORM{'pagetype'};
#$pagetype = "MAIN" if ($FORM{'pagetype'} eq "");
print qq~ </tr>
<tr> <td colspan=14>~;
print qq~
<input type=submit value="Update"></td></tr>~;
print qq~ </table></td></tr></table></td></tr></table>
~;
$table_width2 = "95%"; #$table_width = 600;
print qq~
<p>
<table cellpadding = 1 cellspacing = 0 width=800><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Sample</b></td></tr>
<tr><td align="center">$cgifont <b>Choose page to sample</b> <select name="pagetype" onchange="this.form.submit();"> ~;
foreach $optionn (@keyss)
{
print qq~ <option value="$optionn" ~;
print "selected" if ($optionn eq $pagetype);
print qq~ >$menunam{$optionn}</option>
~;
}
print qq~ </select>
</form><br>Note: The sample shown is only a guide. You need to check the relevant page to see exactly how it will look.</td></tr> </table></td></tr></table></td></tr></table>
<table border=0 cellspacing=0 width=$table_width2 cellpadding=0><tr><td align=center ~;

if ($usebackgroundimage eq "yes")
{
print qq~ background = "$backgroundimage" ~;
}
elsif ($usebackgroundimage ne "yes")
{
print qq~ BGCOLOR="$backcolor" ~;
}
print qq~ > <table border=0 cellspacing=0 cellpadding=0 width=$table_width> ~;
%tyll = ("MAIN","23",
"ADD" ,"24",
"LOGIN" ,"25",
"SEARCH" ,"26",
"SEARCHRESULTS" ,"27",
"RESPONSE" ,"28",
"VIEWRESPONSE","29",
"EDIT" ,"30" );
##### $pagetype
@lay_data = sort(@lay_data);
foreach $line(@lay_data)
{
@flss = split (/\|/, $line);
$flss[7] =~ s/\#//gi;
for ($xx = 0; $xx < 50; $xx++)
{
$flss[$xx] =~ s/PIPEPIPE/|/g;
}
if (($flss[3] eq "yes") && ( $flss[$tyll{$pagetype}] eq "yes") && ($flss[2] ne "NONE") ) # 23 is MAIN
{
if ($flss[2] eq "IMAGE")
{
print qq~ <tr><td align =$flss[4] ><img src="http://$flss[12]"> ~; print qq~ </td></tr> ~;
}
elsif ($flss[2] eq "VIEWING")
{
print qq~ <tr><td align =$flss[4] > ~;
print "<u>" if ($flss[11] eq "yes");
print "<b>" if ($flss[9] eq "yes");
print "<i>" if ($flss[10] eq "yes");
$num1 = 30; $num2 = 35;
print qq~ <font face="$flss[5]" size="$flss[6]" color="$flss[7]">$flss[17]$num1$flss[18]$num2$flss[19]</font> ~;
print "</i>" if ($flss[10] eq "yes");
print "</b>" if ($flss[9] eq "yes");
print "</u>" if ($flss[11] eq "yes"); print qq~ </td></tr> ~;
}
elsif ($flss[2] eq "TEXT")
{
print qq~ <tr><td align =$flss[4] > ~;
print "<u>" if ($flss[11] eq "yes");
print "<b>" if ($flss[9] eq "yes");
print "<i>" if ($flss[10] eq "yes");
print qq~ <font face="$flss[5]" size="$flss[6]" color="$flss[7]">$flss[8]</font> ~;
print "</i>" if ($flss[10] eq "yes");
print "</b>" if ($flss[9] eq "yes");
print "</u>" if ($flss[11] eq "yes"); print qq~ </td></tr> ~;
}
elsif ($flss[2] eq "NUMMENU")
{
print qq~ <tr><td align =$flss[4] > ~;
print "<u>" if ($flss[11] eq "yes");
print "<b>" if ($flss[9] eq "yes");
print "<i>" if ($flss[10] eq "yes");
print qq~ <font face="$flss[5]" size="$flss[6]">$flss[38] <a href="">2</a> <a href="">3</a> <a href="">4</a>
<a href="">5</a> $flss[39]</font> ~;
print "</i>" if ($flss[10] eq "yes");
print "</b>" if ($flss[9] eq "yes");
print "</u>" if ($flss[11] eq "yes"); print qq~ </td></tr> ~;
}
elsif ($flss[2] eq "MENU")
{
$mtype="$pagetype"; #demo
&menus;
}
elsif ($flss[2] eq "HTML")
{
print qq~ <tr><td>$flss[22]</td></tr> ~;
}
elsif ($flss[2] eq "TABLES")
{
$guess = "indeed";
print qq~ <tr><td align=$alignment> ~;
if (($pagetype eq "MAIN")||($pagetype eq "SEARCHRESULTS") ||($pagetype eq "VIEWRESPONSE")){
$count=1;
&main_table_results;
$count=2;
&main_table_results; }
elsif (($pagetype eq "ADD") ||($pagetype eq "RESPONSE")||($pagetype eq "EDIT") ){
&load_addpage; #demo works
}
elsif ($pagetype eq "LOGIN"){
&userloginbody;
}
elsif ($pagetype eq "SEARCH"){ #demo
&searchform;
}
print qq~ </td></tr> ~;

}

elsif ($flss[2] eq "TOTAL")
{
print qq~ <tr><td align =$flss[4] > ~;
print "<u>" if ($flss[11] eq "yes");
print "<b>" if ($flss[9] eq "yes");
print "<i>" if ($flss[10] eq "yes");
$num = 300;
print qq~ <font face="$flss[5]" size="$flss[6]" color="$flss[7]">$flss[13]$num$flss[14]</font> ~;
print "</i>" if ($flss[10] eq "yes");
print "</b>" if ($flss[9] eq "yes");
print "</u>" if ($flss[11] eq "yes"); print qq~ </td></tr> ~;
}
}
}
print qq~ </table></td></tr></table><a name="sample"></a>
~;
}
sub view_to_edit_page_layout
{
&seek_cook;
$pagetype = $FORM{'pagetype'};
$pagetype = "MAIN" if ($FORM{'pagetype'} eq "");
open(USER_FILE,"$layout_name");
@layout_data = <USER_FILE>;
close(USER_FILE);
$field = $FORM{'field'};
foreach $row (@layout_data)
{
@la = split (/\|/, $row);
if ($field eq "$la[1]")
{
for ($x = 0; $x < 40; $x++)
{
$la[$x] =~ s/PIPEPIPE/\|/gi;
}
last;
}
}
$checkactive = "checked" if ($la[3] eq "yes");

%types = ("IMAGE", "Image","TEXT", "Text", "TOTAL", "Total messages",
"MENU", "Link Menu", "TABLES", "Messages", "HTML", "Html", "VIEWING", "Viewing messages",
"NONE", "Unused", "NUMMENU", "Number menu");
@skeys = sort{$types{$a} cmp $types{$b}} keys %types;
&content;
print qq~
<HTML><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>Edit Layout</title>
~;
print qq~
</head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600">
~;
print qq~
<script LANGUAGE="JavaScript">
<!--
function urlMenu(that) {
theURL = that.options[that.selectedIndex].value;
if (theURL) {
window.location = "$guesturl?book=$book&action=view_to_edit_page_layout&fieldtypetemp=" + theURL + "&field=$la[1]&vat=$varurl";
}
}
//-->
</SCRIPT>
<form METHOD="POST" action="$guesturl" >
<input type=hidden name="book" value="$book">
<INPUT TYPE="hidden" NAME="action" VALUE="edit_page_layout">
<INPUT TYPE="hidden" NAME="1" VALUE="$la[1]">
<INPUT TYPE="hidden" NAME="pagetype" VALUE="$pagetype">
<center><font face=Arial>
<B>Page Layout Editor</B> </font> $cgifont <br>
<a href="$guesturl?book=$book&action=control_panel&vat=$varurl">Control Panel</a> -
<a href="$guesturl?book=$book&action=view_page_layout&vat=$varurl&pagetype=$pagetype">Layout Manager</a><p>
<table border=0>
<tr><td>$cgifont<b>Section Type:</b> </td> <td>$cgifont<select name ="2" ONCHANGE="urlMenu(this);">~;

foreach $row (@skeys)
{
print qq~ <option value="$row" ~;
$temptype = $la[2];
$temptype =$FORM{'fieldtypetemp'} if ($FORM{'fieldtypetemp'});
print "selected" if ($row eq "$temptype");
print ">$types{$row}</option>\n";
}
print qq~ </select></td></tr>~;
$checkactive = "checked" if ($la[3] eq "yes");
unless ($temptype eq "NONE")
{
print qq~
<tr><td>$cgifont<b>Active?:</b> </td> <td>$cgifont<input type="checkbox" name="3" value="yes" $checkactive> </td></tr>
~;
}
if ($temptype eq "IMAGE")
{
&routines_for_layout_align;
&routines_for_layout_imageurl;
}
elsif ($temptype eq "TEXT")
{
print qq~ <tr><td>$cgifont<b>Text:</b> </td> <td>$cgifont<input name="8" type=text size=50 value="$la[8]"> </td></tr>
~;
&routines_for_layout_align;
&routines_for_layout_font;
}
elsif ($temptype eq "NUMMENU")
{
print qq~ <tr><td>$cgifont<b>Previous:</b> </td> <td>$cgifont<input name="38" type=text size=10 value="$la[38]"> </td></tr>
<tr><td>$cgifont<b>Next:</b> </td> <td>$cgifont<input name="39" type=text size=10 value="$la[39]"> </td></tr>
~;
&routines_for_layout_align;
&routines_for_layout_font;
}
elsif ($temptype eq "TOTAL")
{
&routines_for_layout_align;
&routines_for_layout_font;
print qq~
<tr><td colspan=2 align=left>$cgifont<b>Single:</b> <input type=text name="15" size=20 value="$la[15]"> 1
<input type=text name="16" size=20 value="$la[16]"></td></tr>
<tr><td colspan=2 align=left>$cgifont<b>Multiple:</b> <input type=text name="13" size=20 value="$la[13]"> 56
<input type=text name="14" size=20 value="$la[14]"></td></tr> ~;
}
elsif ($temptype eq "MENU")
{
print qq~<tr><td colspan=2 align=center>$cgifont Menu preferences are controlled via the <a href="$guesturl?book=$book&action=view_menuprefs&vat=$varurl">Menu Manager</a></td></tr> ~;
}
elsif ($temptype eq "TABLES")
{
print qq~<tr><td colspan=2 align=center>$cgifont Layout of messages controlled via the <a href="$guesturl?book=$book&action=view_layoutprefs&vat=$varurl">Message Layout Manager</a></td></tr> ~;
}
elsif ($temptype eq "HTML")
{
&routines_for_layout_imagehtml;
}
elsif ($temptype eq "VIEWING")
{
&routines_for_layout_align;
&routines_for_layout_font;
print qq~
<tr><td colspan=2 align=left>$cgifont<b>Single:</b> <input type=text name="20" size=20 value="$la[20]"> 1
<input type=text name="21" size=20 value="$la[21]"></td></tr>
<tr><td colspan=2 align=left>$cgifont<b>Multiple:</b> <input type=text name="17" size=20 value="$la[17]"> 1
<input type=text name="18" size=20 value="$la[18]">
5 <input type=text name="19" size=20 value="$la[19]"></td></tr> ~;
}
elsif ($temptype eq "NONE")
{
print qq~<tr><td colspan=2 align=center>$cgifont This field is currently unused</td></tr> ~;
}
print qq~ </table><input type=submit value="Make Changes"></form>~;
}
sub edit_page_layout
{
&seek_cook;
$pagetype = $FORM{'pagetype'};
$pagetype = "MAIN" if ($FORM{'pagetype'} eq "");
open(USER_FIL,"$layout_name");
@layout_dat = <USER_FIL>;
close(USER_FIL);
open(USER_FIL,">$layout_name");
foreach $row (@layout_dat)
{
@fs = split (/\|/, $row);
if($fs[1] eq $FORM{'1'})
{
for ($x = 0; $x < 50; $x++)
{
if (!$FORM{$x})
{
$detail = $fs[$x];
if (($x ==3) || ($x ==10) ||($x ==11) ||($x ==9))
{
$detail = "no";
}
}
else
{
$detail = $FORM{$x};
}
$detail =~ s/\|/PIPEPIPE/gi;
$detail =~ s/\r\n/ /g;
$detail =~ s/\r/ /g;
$detail =~ s/\n/ /g;
$detail =~ s/\s+/ /g;

if ($x ==12)
{
$detail =~ s/^http:\/\///g;
}

print USER_FIL "$detail|";
}
print USER_FIL "\n";
}
else
{
print USER_FIL "$row";
}
}
close(USER_FIL);
&content;
&main_headera;
print qq~ <META http-equiv="refresh" content="0; URL=$guesturl?book=$book&action=view_page_layout&vat=$varurl&pagetype=$pagetype"> ~;
&main_headerb;
print qq~
<center>
~;
&inter_footer;
#&view_to_edit_a_field;
exit;
}
sub routines_for_layout_align
{
$checkalignl = "checked" if ($la[4] eq "left");
$checkalignc = "checked" if ($la[4] eq "center");
$checkalignr = "checked" if ($la[4] eq "right");
print qq~
<tr><td>$cgifont<b>Alignment:</b> </td>
<td>$cgifont
left <input type="radio" name="4" value="left" $checkalignl> - center <input type="radio" name="4" value="center" $checkalignc> - right <input type="radio" name="4" value="right" $checkalignr>
</td></tr> ~;
}
sub routines_for_layout_imageurl
{
print qq~
<tr><td>$cgifont<b>Image url:</b> </td> <td>$cgifont http://<input name="12" type=text size=40 value="$la[12]"> </td></tr>
~;
}
sub routines_for_layout_imagehtml
{
print qq~
<tr><td>$cgifont<b>Html:</b> </td> <td>$cgifont <textarea name="22" rows = 10 cols = 30>$la[22]</textarea> </td></tr>
~;
}

sub routines_for_layout_font
{
$checkunderline = "checked" if ($la[11] eq "yes");
$checkbold = "checked" if ($la[9] eq "yes");
$checkitalic = "checked" if ($la[10] eq "yes");
print qq~
<tr><td>$cgifont<b>Font Type:</b> </td> <td>$cgifont<input name="5" type=text size=10 value="$la[5]"> </td></tr>
<tr><td>$cgifont<b>Font Size:</b> </td> <td>$cgifont<input name="6" type=text size=10 value="$la[6]"> </td></tr>~;
if ($temptype ne "NUMMENU"){
print qq~ <tr><td>$cgifont<b>Font Color:</b> </td>
<td>$cgifont<SELECT name="7" onChange="forms[0].b7.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?~;
&newoptions;
print qq~</SELECT> <INPUT TYPE="TEXT" NAME="b7" VALUE="$la[7]" SIZE=7 MAXLENGTH=7>~;
}
else{
print qq~ <tr><td colspan=2>$cgifont
Colors in the number menu are set in the Color/Images Manager<br>
and/or the CSS setting in the Standard Preferences Manager.  </td></tr>
~;
}

print qq~
<tr><td>$cgifont<b>Underline:</b> </td> <td>$cgifont<input type="checkbox" name="11" value="yes" $checkunderline> </td></tr>
<tr><td>$cgifont<b>Bold:</b> </td> <td>$cgifont<input type="checkbox" name="9" value="yes" $checkbold> </td></tr>
<tr><td>$cgifont<b>Italic:</b> </td> <td>$cgifont<input type="checkbox" name="10" value="yes" $checkitalic> </td></tr>
~;
}


sub routine_for_layout_numbermenu
{
$count = 1;
$grouped = 0;
$no_displayed = int($no_displayed); # fix any funny numbers entered by user
# fix any numbers entered less than one
if ($no_displayed <1)
{
$no_displayed = 1;
}
$start_number = $FORM{'start_number'};
$new_start_number = ($start_number + $no_displayed);
$old_start_number = ($start_number - $no_displayed);
$startplus = $start_number +1;
unless ($number_of_messages <($no_displayed+1))
{
print qq~ <tr><td width=$table_width align=center> ~;
}
unless ($old_start_number < 0)
{
print qq~ <font face= "$textfontface" size=$textfontsize> $left_bracket<a href="$guesturl?book=$book&start_number=$old_start_number&vat=$varurl~;
print "&action=view_to_edit" if ($action eq "view_to_edit");
print qq~">$TXT_previous</a>$right_bracket </font> ~;
}
&show_number_menu unless ($number_of_messages <($no_displayed+1));
unless ($new_start_number > ($number_of_messages -1 ))
{
print qq~ <font face= "$textfontface" size=$textfontsize> $left_bracket<a href="$guesturl?book=$book&start_number=$new_start_numbe&vat=$varurlr~;
print "&action=view_to_edit" if ($action eq "view_to_edit");
print qq~">$TXT_next</a>$right_bracket </font><br> ~;
}
unless ($number_of_messages <($no_displayed+1))
{
print qq~ </td></tr> ~;
}
}

sub overlayup
{
my $min = "50000001";
my $max = "50000020";
&seek_cook;
open(USER_FILE,"$layout_name");
@layout_data = <USER_FILE>;
close(USER_FILE);
$field = $FORM{'field'};
foreach $row (@layout_data)
{
@layoutfields = split (/\|/, $row);
$current = $layoutfields[0] if ($field eq "$layoutfields[1]");
}
$one_up = $current - 1;
if ($one_up < $min)
{
&view_page_layout;
exit;
}
open(USER_FILE,">$layout_name");
foreach $row (@layout_data)
{
@fs = split (/\|/, $row);
if ($fs[0] eq $current)
{
print USER_FILE "$one_up|$fs[1]|$fs[2]|$fs[3]|$fs[4]|$fs[5]|$fs[6]|$fs[7]|$fs[8]|$fs[9]|$fs[10]|$fs[11]|$fs[12]|$fs[13]|$fs[14]|$fs[15]|$fs[16]|$fs[17]|$fs[18]|$fs[19]|$fs[20]|$fs[21]|$fs[22]|$fs[23]|$fs[24]|$fs[25]|$fs[26]|$fs[27]|$fs[28]|$fs[29]|$fs[30]|$fs[31]|$fs[32]|$fs[33]|$fs[34]|$fs[35]|$fs[36]|$fs[37]|$fs[38]|$fs[39]|$fs[40]|$fs[41]|$fs[42]|$fs[43]|$fs[44]|$fs[45]|$fs[46]|$fs[47]|$fs[48]|$fs[49]|\n";
}
elsif ($fs[0] eq $one_up)
{
print USER_FILE "$current|$fs[1]|$fs[2]|$fs[3]|$fs[4]|$fs[5]|$fs[6]|$fs[7]|$fs[8]|$fs[9]|$fs[10]|$fs[11]|$fs[12]|$fs[13]|$fs[14]|$fs[15]|$fs[16]|$fs[17]|$fs[18]|$fs[19]|$fs[20]|$fs[21]|$fs[22]|$fs[23]|$fs[24]|$fs[25]|$fs[26]|$fs[27]|$fs[28]|$fs[29]|$fs[30]|$fs[31]|$fs[32]|$fs[33]|$fs[34]|$fs[35]|$fs[36]|$fs[37]|$fs[38]|$fs[39]|$fs[40]|$fs[41]|$fs[42]|$fs[43]|$fs[44]|$fs[45]|$fs[46]|$fs[47]|$fs[48]|$fs[49]|\n";
}
else
{
print USER_FILE "$row";
}
}
close(USER_FILE);
&view_page_layout;
}
sub overlaydown
{
my $min = "50000001";
my $max = "50000020";
&seek_cook;
open(USER_FILE,"$layout_name");
@layout_data = <USER_FILE>;
close(USER_FILE);
$field = $FORM{'field'};
foreach $row (@layout_data)
{
@layoutfields = split (/\|/, $row);
$current = $layoutfields[0] if ($field eq "$layoutfields[1]");
}
$one_up = $current + 1;
if ($one_up > $max)
{
&view_page_layout;
exit;
}
open(USER_FILE,">$layout_name");
foreach $row (@layout_data)
{
@fs = split (/\|/, $row);
if ($fs[0] eq $current)
{
print USER_FILE "$one_up|$fs[1]|$fs[2]|$fs[3]|$fs[4]|$fs[5]|$fs[6]|$fs[7]|$fs[8]|$fs[9]|$fs[10]|$fs[11]|$fs[12]|$fs[13]|$fs[14]|$fs[15]|$fs[16]|$fs[17]|$fs[18]|$fs[19]|$fs[20]|$fs[21]|$fs[22]|$fs[23]|$fs[24]|$fs[25]|$fs[26]|$fs[27]|$fs[28]|$fs[29]|$fs[30]|$fs[31]|$fs[32]|$fs[33]|$fs[34]|$fs[35]|$fs[36]|$fs[37]|$fs[38]|$fs[39]|$fs[40]|$fs[41]|$fs[42]|$fs[43]|$fs[44]|$fs[45]|$fs[46]|$fs[47]|$fs[48]|$fs[49]|\n";
}
elsif ($fs[0] eq $one_up)
{
print USER_FILE "$current|$fs[1]|$fs[2]|$fs[3]|$fs[4]|$fs[5]|$fs[6]|$fs[7]|$fs[8]|$fs[9]|$fs[10]|$fs[11]|$fs[12]|$fs[13]|$fs[14]|$fs[15]|$fs[16]|$fs[17]|$fs[18]|$fs[19]|$fs[20]|$fs[21]|$fs[22]|$fs[23]|$fs[24]|$fs[25]|$fs[26]|$fs[27]|$fs[28]|$fs[29]|$fs[30]|$fs[31]|$fs[32]|$fs[33]|$fs[34]|$fs[35]|$fs[36]|$fs[37]|$fs[38]|$fs[39]|$fs[40]|$fs[41]|$fs[42]|$fs[43]|$fs[44]|$fs[45]|$fs[46]|$fs[47]|$fs[48]|$fs[49]|\n";
}
else
{
print USER_FILE "$row";
}
}
close(USER_FILE);
&view_page_layout;
}
sub load_page
{
%tyll = ("MAIN","23",
"ADD" ,"24",
"LOGIN" ,"25",
"SEARCH" ,"26",
"SEARCHRESULTS" ,"27",
"RESPONSE" ,"28" ,
"VIEWRESPONSE" ,"29",
"EDIT" ,"30"
);
open(USER_FILEWWW,"$layout_name");
@lay_data = <USER_FILEWWW>;
close(USER_FILEWWW);
@lay_data = sort(@lay_data);
#$pagetype = $FORM{'pagetype'};
$pagetype = "MAIN" if ($pagetype eq "");
@data_ordered = @datalist if ($action eq "view_followup_edit");
if (($pagetype eq "EDIT")||($action eq "view_followup_edit")||($action eq "view_to_undo") ){ # message manager
print qq~
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td width=100% align=center><font face=Arial size=1> ~;
######
$count = 1;
$grouped = 0;
$no_displayed = 20; # fix any funny numbers entered by user
# fix any numbers entered less than one
if ($no_displayed <1) { $no_displayed = 1; }
$start_number = $FORM{'start_number'};
$new_start_number = ($start_number + $no_displayed);
$old_start_number = ($start_number - $no_displayed);
$startplus = $start_number +1;
unless ($old_start_number < 0)
{
print qq~ <a href="$guesturl?book=$book&start_number=$old_start_number&vat=$varurl~;
if ($action eq "view_to_edit")
{
print qq~&action=view_to_edit ~;
}
if ($action eq "view_to_undo")
{
print qq~&action=view_to_undo ~;
}
print qq~"><<<</a> ~;
}
&show_number_menu unless ($number_of_messages <($no_displayed+1));

unless ($new_start_number > ($number_of_messages -1 )){
print qq~ <a href="$guesturl?book=$book&start_number=$new_start_number&vat=$varurl~;
print "&action=view_to_edit" if ($action eq "view_to_edit"); print "&action=view_to_undo" if ($action eq "view_to_undo");
print qq~">>>></a> ~;
}
############

foreach $row (@data_ordered){
@fields = split (/\|/, $row);
$grouped++;
if (($grouped > ($start_number)) && ($grouped < ($start_number + $no_displayed + 1))){
&main_table_results;
} # end if number is right
} # end for each row
print qq~ </td></tr></table></td></tr></table></td></tr></table> ~;
}

else ########### one of the public pages
{
foreach $line(@lay_data)
{
@flss = split (/\|/, $line);
$flss[7] =~ s/\#//gi;
for (my $xx = 0; $xx < 50; $xx++)
{
$flss[$xx] =~ s/PIPEPIPE/|/g;
}
if (($flss[3] eq "yes") && ( $flss[$tyll{$pagetype}] eq "yes") && ($flss[2] ne "NONE") )
{
if ($flss[2] eq "IMAGE")
{
print qq~ <tr><td align =$flss[4] ><img src="http://$flss[12]"> ~; print qq~ </td></tr> ~;
}
elsif ($flss[2] eq "VIEWING")
{
print qq~ <tr><td align =$flss[4] > ~;
print "<u>" if ($flss[11] eq "yes");
print "<b>" if ($flss[9] eq "yes");
print "<i>" if ($flss[10] eq "yes");
print qq~ <font face="$flss[5]" size="$flss[6]" color="$flss[7]">~;
if (($action ne "view_to_edit") && ($action ne "view_to_undo")) {
if ($new_start_number < $number_of_messages) {
print qq~ $flss[17]$startplus$flss[18]$new_start_number$flss[19]</font> ~;
}
else {
if ($startplus == $number_of_messages){
print qq~ $flss[20]$startplus$flss[21]</font> ~;
}
else {
print qq~ $flss[17]$startplus$flss[18]$number_of_messages$flss[19] ~;
}
}
}
print qq~ </font> ~;
print "</i>" if ($flss[10] eq "yes");
print "</b>" if ($flss[9] eq "yes");
print "</u>" if ($flss[11] eq "yes"); print qq~ </font></td></tr> ~;
}
elsif ($flss[2] eq "TEXT")
{
print qq~ <tr><td align =$flss[4] > ~;
print "<u>" if ($flss[11] eq "yes");
print "<b>" if ($flss[9] eq "yes");
print "<i>" if ($flss[10] eq "yes");
print qq~ <font face="$flss[5]" size="$flss[6]" color="$flss[7]">$flss[8]</font> ~;
print "</i>" if ($flss[10] eq "yes");
print "</b>" if ($flss[9] eq "yes");
print "</u>" if ($flss[11] eq "yes"); print qq~ </font></td></tr> ~;
}
elsif ($flss[2] eq "NUMMENU")
{
unless ($number_of_messages <($no_displayed+1))
{
print qq~ <tr><td align =$flss[4] > ~;
print "<u>" if ($flss[11] eq "yes");
print "<b>" if ($flss[9] eq "yes");
print "<i>" if ($flss[10] eq "yes");
print qq~ <font face="$flss[5]" size="$flss[6]">$flss[30] ~;
$count = 1;
$grouped = 0;
$no_displayed = int($no_displayed); # fix any funny numbers entered by user
# fix any numbers entered less than one
if ($no_displayed <1) { $no_displayed = 1; }
$start_number = $FORM{'start_number'};
$new_start_number = ($start_number + $no_displayed);
$old_start_number = ($start_number - $no_displayed);
$startplus = $start_number +1;
unless ($old_start_number < 0)
{
print qq~ <a href="$guesturl?book=$book&start_number=$old_start_number&vat=$varurl~;
if ($action eq "view_to_edit")
{
print qq~ &action=view_to_edit ~;
}
print qq~">$flss[38]</a> ~;
}
&show_number_menu unless ($number_of_messages <($no_displayed+1));
unless ($new_start_number > ($number_of_messages -1 ))
{
print qq~ <a href="$guesturl?book=$book&start_number=$new_start_number&vat=$varurl~;
print "&action=view_to_edit" if ($action eq "view_to_edit");
print qq~">$flss[39]</a> ~;
}

print "</i>" if ($flss[10] eq "yes");
print "</b>" if ($flss[9] eq "yes");
print "</u>" if ($flss[11] eq "yes"); print qq~ </font></td></tr> ~;
}
}
elsif ($flss[2] eq "MENU") {
$mtype="$pagetype";
&menus;
}
elsif ($flss[2] eq "HTML") {
print qq~ <tr><td>$flss[22]</td></tr> ~;
}
elsif ($flss[2] eq "TABLES") {
print qq~ <tr><td align="$alignment"> ~;
if ($pagetype eq "MAIN"){
foreach $row (@data_ordered){
@fields = split (/\|/, $row);
$grouped++;
if (($grouped > ($start_number)) && ($grouped < ($start_number + $no_displayed + 1))){
&main_table_results;
} # end if number is right
} # end for each row
}
elsif ($pagetype eq "VIEWRESPONSE"){
foreach $row (@datalist){
@fields = split (/\|/, $row);
#$grouped++;
#if (($grouped > ($start_number)) && ($grouped < ($start_number + $no_displayed + 1))){
&main_table_results;
#} # end if number is right
} # end for each row

}
elsif (($pagetype eq "ADD")||($pagetype eq "RESPONSE")) {
&load_addpage;
}
elsif ($pagetype eq "LOGIN"){
&userloginbody;
}
elsif ($pagetype eq "SEARCHRESULTS")
{
foreach $row (@hits){
@fields = split (/\|/, $row);
&main_table_results;
}
}
elsif ($pagetype eq "SEARCH"){
&searchform;
}

print qq~ </td></tr> ~;
}

elsif ($flss[2] eq "TOTAL")
{
# &no_of_messages_display
print qq~ <tr><td align =$flss[4] > ~;
print "<u>" if ($flss[11] eq "yes");
print "<b>" if ($flss[9] eq "yes");
print "<i>" if ($flss[10] eq "yes");
print qq~ <font face="$flss[5]" size="$flss[6]" color="$flss[7]"> ~;
if ($number_of_messages == 1)
{
print qq~
$flss[15]$number_of_messages$flss[16]
~;
}
else
{
print qq~
$flss[13]$number_of_messages$flss[14]
~;
}
print "</i>" if ($flss[10] eq "yes");
print "</b>" if ($flss[9] eq "yes");
print "</u>" if ($flss[11] eq "yes"); print qq~ </font></td></tr> ~;
}
}
}
} # end of else one of main pages?
}
sub view_addlayoutprefs
{
&seek_cook;
 if ($mastermanagemessagesonly eq "yes"){
  &content;
 print qq~ <font face=Arial size=2>Access to this section is currently restricted.
 <a href="javascript:history.go(-1)">Back</a></font>   ~;
 exit;
   }
open(USER_FILE,"$field_names");
@layout_data = <USER_FILE>;
close(USER_FILE);

foreach $lrow (@layout_data)
{
@lrow = split (/\|/, $lrow);
$sortable_field = $lrow[36];
unshift (@lrow, $sortable_field);
$lnew_row = join ("\|", @lrow);
push (@new_rows, $lnew_row);
}
@datalist = ();
@sorted_rows = sort (@new_rows);
foreach $sorted_row (@sorted_rows)
{
@row = split (/\|/, $sorted_row);
$sorted_field = shift (@row);
$old_but_sorted_row = join ("\|", @row);
push (@data_ordered, $old_but_sorted_row);
}
@layout_data = @data_ordered;
&content;
print qq~
<HTML><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>$title</title>
~;
print qq~
</head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600">
~;
print qq~
<center><table cellpadding = 1 cellspacing = 0 width=800><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>

<tr><td width=100% colspan=14 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook $cptext Add Message/Response Layout Manager</b></td></tr>
<tr><td colspan=10 align="center">$cgifont ~;
&linkjump; print qq~
- <a href="#sample">Sample</a> </td></tr></form>
</table></td></tr></table> </td></tr></table>
<table cellpadding = 1 cellspacing = 0 width=800><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=0 bgcolor = $mainbak>
~;
$bbod = "Header";
$kk = 0;
foreach $row (@layout_data)
{
@layoutfields = split (/\|/, $row);
$kk++;
$co = "red";
$co = "blue" if ($layoutfields[21] eq "yes");
#next if ($layoutfields[2] eq "date") ;
#next if ($layoutfields[21] ne "yes") ;
print qq~ <tr valign=top><td>$cgifont$kk </td><td><font face=Arial size=2 color=$co>~;

if ($layoutfields[2] eq "date")
{
$pub = "";
print "<i>Date</i>";;
}
elsif ($layoutfields[2] eq "ADD RESPONSE")
{
$pub = "";
print "<i>Add Response</i>";
}
elsif ($layoutfields[2] eq "EDIT")
{
$pub = "";
print "<i>Edit Message</i>";
}
elsif ($layoutfields[2] eq "VIEW RESPONSES")
{
print "<i>View Responses</i>"; $pub = "";
}
elsif ($layoutfields[2] eq "PRIVATE_OPTION")
{
print qq~<i>Private message </i> (<a href="#help_private">help</a>) ~;
}
else
{
print "$layoutfields[1]";
}
print qq~</td>
<td><font face=Arial size=2 color=$co>~;
if ($layoutfields[2] eq "date")
{
print "<i>Message Date</i>";
}
elsif ($layoutfields[2] eq "EDIT")
{
print "<i>Edit Message</i>";
}
elsif ($layoutfields[2] eq "ADD RESPONSE")
{
print "<i>Add Response</i>";
}
elsif ($layoutfields[2] eq "PRIVATE_OPTION")
{
print "<i>Private message</i>";
}
elsif ($layoutfields[2] eq "VIEW RESPONSES")
{
print "<i>View Responses</i>";
}
else
{
print "$layoutfields[2]";
}
print qq~</td>
<td >
~;
unless ($kk == 1)
{
print qq~ <font face=Arial size=2 color=$co><a href="$guesturl?book=$book&action=move_up&field=$layoutfields[12]&addmove=yes&vat=$varurl">Up</a> ~;
}
print qq~ </td><td >~;
unless ($kk == 20)
{
print qq~ <font face=Arial size=2 color=$co> <a href="$guesturl?book=$book&action=move_down&field=$layoutfields[12]&addmove=yes&vat=$varurl">Down</a> ~;
}
print qq~
</td> ~;
if (($layoutfields[2] eq "VIEW RESPONSES") || ($layoutfields[2] eq "date")|| ($layoutfields[2] eq "EDIT") || ($layoutfields[2] eq "ADD RESPONSE")){
print qq~ <td><font face=Arial size=2 color=black><i>(<b>not</b> shown in Add page)</i></font</td>~;
}
elsif ($layoutfields[2] eq "PRIVATE_OPTION") {
print qq~ <td><font face=Arial size=2 color=black><i>(<b>only</b> shown in Add page)</i></font</td>~;
}
elsif ($layoutfields[50] eq "yes") {
print qq~ <td><font face=Arial size=2 color=black><i>(currently only available to webmaster)</i></font</td>~;
}


print qq~ </tr> ~;
}
print qq~ </table></td></tr></table> </td></tr></table>
~;
$guess = "indeed";
&load_addpage;
my $mess = "disabled";
$mess = "enabled" if ($allow_private_messages eq "yes");
print qq~ <a name="sample"></a>
<p> </center><div align=left><hr size=1>
<b>NOTE: Private messages are currently $mess</b>. The PRIVATE MESSAGE option box will only appear if you have allowed guests to add private messages via the
<a href="$guesturl?book=$book&action=view_prefs&vat=$varurl">Standard Preferences Manager.</a><p>
<a name="help_private"></a>
~;
exit;
}

sub load_addpage
{
open(USER_FILEWWW,"$field_names");
@file_data = <USER_FILEWWW>;
close(USER_FILEWWW);
if ($table_width =~ /\%/)
{
$table_width_per = $table_width;
$table_width_per =~ s/\%//gi;
$table_width_per = $table_width_per/3;
$table_width_per = ($table_width_per . "%");
$col1 = $table_width_per;
}
else
{
$col1 = ($table_width/3);
}
$whatever = "no_preview";
if ($guess eq "indeed"){
print qq~ <center><FORM ACTION="" METHOD="POST"  > ~;}
else {
print qq~ <center><FORM ACTION="$guesturl" METHOD="POST" ENCTYPE="multipart/form-data"  onSubmit="if (this.submitted) return false; this.submitted = true; return true">
<input type=hidden name="book" value="$book"> ~;}
if (($action eq "add_followup1") || ($action eq "cpadd_followup1"))
{
$ref = $FORM{'ref'};
print qq~ <input type=hidden name=action value="add_followup2"> <input type=hidden name=ref value="$ref">
~;
if ($action eq "cpadd_followup1")
{
print qq~ <input type=hidden name=moveme value="moveme"> ~; # to take cp add response back to cp
}
}
else
{
print qq~ <input type=hidden name=newaction value="$whatever"> ~;
}
print qq~ <table width="95%"><tr><td ~;
############################
if ($usebackgroundimage eq "yes")
{
print qq~ background = "$backgroundimage" ~;
}
else
{
print qq~ BGCOLOR="$backcolor" ~;
}
print qq~ > <center><table border=0 width=$table_width ~;
if ($trans_add ne "yes")
{
print qq~ BGCOLOR="$addcolor" ~;
if ($usebackgroundimageadd eq "yes")
{
print qq~ background = "$backgroundimageadd" ~;
}
}
###############################
print qq~ > ~;
@new_rows = ();
@data_ordered = ();
foreach $lrow (@file_data)
{
@lrow = split (/\|/, $lrow);
$sortable_field = $lrow[36];
unshift (@lrow, $sortable_field);
$lnew_row = join ("\|", @lrow);
push (@new_rows, $lnew_row);
}
@datalist = ();
@sorted_rows = sort (@new_rows);
foreach $sorted_row (@sorted_rows)
{
@row = split (/\|/, $sorted_row);
$sorted_field = shift (@row);
$old_but_sorted_row = join ("\|", @row);
push (@data_ordered, $old_but_sorted_row);
}





@layout_datac = @data_ordered;
foreach $rowss (@layout_datac)
{
@fieldsq = split (/\|/, $rowss);
next if (
($fieldsq[21] ne "yes")
|| ($fieldsq[2] eq "date")
|| ($fieldsq[2] eq "ADD RESPONSE")
|| ($fieldsq[2] eq "VIEW RESPONSES")
|| ($fieldsq[2] eq "EDIT")
|| (($allow_private_messages ne "yes")&& ($fieldsq[2] eq "PRIVATE_OPTION") )
|| (($fieldsq[50] eq "yes") && ( $COOK{$cooknamelocal} ne $active_string  ) )


 );



if ($fieldsq[20] eq "yes"){
$req = $TXT_required; }
else{
$req = "";}
if ($fieldsq[2] eq "PRIVATE_OPTION"){
$fieldsq[1] = $fieldsq[18];
}
if (($fieldsq[49] ne "yes") &&($fieldsq[48])){
$fieldsq[1] = $fieldsq[48];
}


if ($fieldsq[2] ne "TABLE"){
print qq~ <tr valign=top><td width="$col1">
<font face="$textfontface" size=$textfontsize color="$addtext"><B> $fieldsq[1] </b> $req</td>
<td><font face="$textfontface" size=$textfontsize color="$addtext"> ~;
 }



if (($fieldsq[2] eq "TEXT") || ($fieldsq[2] eq "EMAIL") || ($fieldsq[2] eq "URL") )
{
print qq~ <INPUT TYPE="text" maxlength = "$fieldsq[4]" NAME="$fieldsq[12]" SIZE="$fieldsq[3]" class="$fieldsq[65]"> ~;
}
elsif ($fieldsq[2] eq "TEXTAREA")
{
print qq~ <TEXTAREA wrap="virtual" NAME="$fieldsq[12]" ROWS="$fieldsq[6]" COLS="$fieldsq[5]"  class="$fieldsq[65]"></TEXTAREA> ~;
}
elsif ($fieldsq[2] eq "CHECK")
{
print qq~ <input type="checkbox" name="$fieldsq[12]" value="$fieldsq[10]"  class="$fieldsq[65]"> ~;
}
elsif (($fieldsq[2] eq "IMAGE") || ($fieldsq[2] eq "FILE"))
{
print qq~ <INPUT NAME="$fieldsq[12]" TYPE="file" > ~;
}
elsif ($fieldsq[2] eq "PRIVATE_OPTION")
{
print qq~ <input type="checkbox" name="private_message_check" value="yes"  class="$fieldsq[65]"> $fieldsq[17] ~;
}
elsif ($fieldsq[2] eq "TABLE")
{

print qq~ <tr valign=top><td colspan=2> ~;

@tablerows = split (/\//, $fieldsq[54]);
@tablecols = split (/\//, $fieldsq[53]);
print qq~ <table class="$fieldsq[65]"><tr><td><font face="$textfontface" size=$textfontsize color="$addtext">  <B> $fieldsq[1] </b></font></td>
~;

$colnotemp = 0;
$rownotemp = 0;


foreach $tablecols (@tablecols)
{
$op = $tablecols;
$op =~ s/\s+/ /gi;
print qq~ <td><font face="$textfontface" size=$textfontsize color="$addtext"><b>$op</b></td>~;
}
print qq~ </tr>  ~;

 foreach $tablerows (@tablerows)   ###### ####
{
$oprow = $tablerows;
$oprow =~ s/\s+/ /gi;
print qq~ <tr><td><font face="$textfontface" size=$textfontsize color="$addtext"><b>$oprow</b></td>~;

    foreach $tablecols (@tablecols)   ############
      {
       print qq~ <td><input type="text" size="$fieldsq[3]" name="$fieldsq[12]"></td>  ~;

        $colnotemp++;
      }
print qq~ </tr>  ~;

 $rownotemp++;

}


 print qq~ </table>
~;
}
elsif ($fieldsq[2] eq "SELECT")
{
print qq~ <SELECT NAME="$fieldsq[12]" size="$fieldsq[7]"  class="$fieldsq[65]"> ~;
@optionsq = split (/\//, $fieldsq[8]);
foreach $optionq (@optionsq)
{
$op = $optionq;
$op =~ s/\s+//gi;

print qq~ <option value="$optionq" ~;
print "selected" if ($optionq eq $fieldsq[9]);
print qq~ >$optionq</option>
~;
}
print qq~ </select>~;
}
elsif ($fieldsq[2] eq "RADIO")
{
@optionsq = split (/\//, $fieldsq[8]);
foreach $optionq (@optionsq)
{
$op = $optionq;
$op =~ s/\s+//gi;
print qq~<input type="radio" name="$fieldsq[12]" value="$optionq" ~;
print "checked" if ($optionq eq $fieldsq[9]);
print qq~  class="$fieldsq[65]"> $optionq ~;
print "<br>" if ($fieldsq[11] eq "v"); }
}
print qq~ </td></tr> ~;
}

 $TXT_type_letters_only = "Enter the underlined numbers:" if $TXT_type_letters_only eq "";
 $secretcode = rand(9999999999);

 ####################################################

print qq~ <tr valign=top><td width=200><font face="$textfontface" size=$textfontsize><B>$TXT_type_letters_only</B><br> ~;
$ran = rand(100000000);
print "<table cellspacing=0 cellpadding=0><tr>";
for ($x = 0; $x < 200; $x++){
$y = int(rand(10));
next if $y == 10;
next if $FOUND{$y} eq "yes";
push (@bnums, $y);
$FOUND{$y} = "yes";
$totalnums++;

if ($use_own_captcha eq "yes"){
$captcha_url =~ s/\/$//gi;
$captcha_url =~ s/http\:\/\///gi;
$catpcha_image_url = $captcha_url;
}
else{
$catpcha_image_url = "www.active-scripts.net/a";
}
print qq~<td><img src="http://$catpcha_image_url/$y.gif"></td>~;
last if $totalnums >9;
}
$a = int(rand(10));
$b = int(rand(10));
while ($a == $b){
$b = int(rand(10));
}
open(CFILE,">>$cap");
flock(CFILE,2);
print CFILE "$ran|$bnums[$a]|$bnums[$b]|$var|$capmessage|$message|$varurl|$secretcode||||||\n";
print qq~ </tr><tr>  ~;
for ($x = 0; $x < 10; $x++){
if (($x == $a) || ($x == $b)) {
print qq~  <td><img src="http://$catpcha_image_url/aut.gif"></td> ~;
}
else{
print qq~ <td><img src="http://$catpcha_image_url/abt.gif"></td> ~;
}
}
print qq~  </tr>~;
close CFILE;
print "</table>     " ;
print qq~</font>
</td><td width=400>
<select name=capa class=textfield><option value="">-</option>~;
 for ($x = 0; $x < 10; $x++){
 print qq~ <option value="$x">$x</option>  ~;
 }
print qq~</select>
<select name=capb class=textfield><option value="">-</option>~;
 for ($x = 0; $x < 10; $x++){
 print qq~ <option value="$x">$x</option>  ~;
 }
print qq~</select>~;
print qq~</td><tr>
<tr><td colspan=2 align=center>$previewline</td></tr> ~;

 ######################################################

print qq~   <input type=hidden name=secret value="$secretcode">
<tr><td colspan=2> <font face="$textfontface" size=$textfontsize color="$text">
<INPUT TYPE="submit" VALUE="$TXT_continue"></td></tr>
</table></td></tr></table></form>
~;
}
sub licc{
$organe23 = $lic;
}
sub guest_to_power
{
&seek_cook;
unless (-e "$gbook_data_name"){
 &content;
  print "Can't find guestbook data file. Make sure it is in the correct directory.";
 exit;
}

&copy_file($powerbook_data_name, $gtp_backup_name ); # create backup of current data
&copy_file($gbook_data_name, $powerbook_data_name );
&content;
&load_data_and_count;
open(USER_FIL,"$powerbook_data_name");
@data = <USER_FIL>;
close (USER_FIL);
open(USER_FIL,">$powerbook_data_name");
foreach $row (@data)
{
$row =~ s/\n/|||||||||||\n/gi;
print USER_FIL "$row";

}
close (USER_FIL);
open(USER_FIL,"$powerbook_data_name");
@data = <USER_FIL>;
close (USER_FIL);
open(USER_FIL,">$powerbook_data_name");

foreach $row (@data)
  {
@fields = split (/\|/, $row);
     for (my $x = 0; $x < 42; $x++){

        if ($x == 20){

        print USER_FIL "$fields[6]|";
        }
        else {

        print USER_FIL "$fields[$x]|";

        }

     }
     print USER_FIL "\n";
  }
close (USER_FIL);
print "Done";
exit;
}



sub view_request_license
{
&content;
print qq~
<HTML><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>Active PowerBook</title>
</head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600" onLoad="document.forms[0].password.focus()">
~;
print qq~ <center> <FORM ACTION="http://www.active-scripts.net/cgi-bin/lic2.cgi" METHOD="POST">
<INPUT TYPE="hidden" NAME="vartime2" VALUE="$vartime2">

<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook</b></td></tr>
<tr><td width=100% align=center> $cgifont Please enter details.<p>You first need to purchase a license via
<a href="https://secure.element5.com/shareit/checkout.html?productid=211204">share-it</a>.<br>
Then you should submit the details below. Active-Scripts.net will email you your license number within 24 hours.<br>


 <table>
 <tr><td align=right>$cgifont Email address</td><td><INPUT TYPE="text" NAME="email" SIZE="20" MAXLENGTH="80"></td></tr>
     <tr><td align=right>$cgifont Shareit order number</td><td><INPUT TYPE="text" NAME="shareit" SIZE="20" MAXLENGTH="80"></td></tr>
     <tr><td align=right>$cgifont Your PowerBook url</td><td><INPUT TYPE="text" NAME="web" SIZE="20" MAXLENGTH="80"></td></tr>
     </table><br>
<INPUT TYPE="submit" VALUE="Submit license number request">
</FORM>
</font>
</td></tr>
</table></td></tr></table></td></tr></table>
~;
&inter_footer;
}

sub linkjump
{
print qq~<form method=post action="$guesturl">
<input type=hidden name="book" value="$book">
<INPUT TYPE="hidden" NAME="action" VALUE="lin"> ~;
$newt = $title;
$newt = "PowerBook" if ($title eq "");
print qq~<SELECT name=link size=1 onchange="this.form.submit();">
<OPTION selected VALUE="">$cptext Select</OPTION>
<OPTION VALUE="reload">$cptext $newt</OPTION> ~;
print qq~
<OPTION VALUE ="control_panel">$cptext CONTROL PANEL</OPTION>~;

if ($book ne "")
{
 if ($mastercplink eq "yes")
 {
  print qq~ <OPTION VALUE ="cpfromchild">MASTER CONTROL PANEL</OPTION>    ~;

 }


}

print qq~
<OPTION VALUE ="view_to_edit">$cptext Message Manager</OPTION>
<OPTION VALUE ="view_to_undo">$cptext Recycle Bin</OPTION>
<OPTION VALUE ="view_backups">$cptext Backup Manager</OPTION>
<OPTION VALUE ="view_prefs">$cptext Standard Preferences Manager</OPTION>
<OPTION VALUE ="view_colprefs">$cptext Color/Images Manager</OPTION>
<OPTION VALUE ="view_page_layout">$cptext Page Layout Manager</OPTION>
<OPTION VALUE ="view_layoutprefs">$cptext Field Editor/Message Layout Manager</OPTION>
<OPTION VALUE ="view_addlayoutprefs">$cptext Add/Respond Page Layout Manager</OPTION>
<OPTION VALUE ="view_searchprefs">$cptext Search Preferences Manager</OPTION>
<OPTION VALUE ="view_menuprefs">$cptext Menu Manager</OPTION>
<OPTION VALUE ="view_langprefs">$cptext Language Preferences Manager</OPTION>
<OPTION VALUE ="view_dateprefs">$cptext Date Format Manager</OPTION>
<OPTION VALUE ="view_access">$cptext Access Manager</OPTION>
<OPTION VALUE ="view_change_password">$cptext Password Manager</OPTION> ~;
if ($book eq ""){
print qq~<OPTION VALUE ="view_servers">SERVER MANAGER</OPTION> ~;
}

print qq~</SELECT> ~;



}

sub agg
{
 unless ($vartime1 == $lic)
{
my $togo = ( ((60*60*24*7) - ($varurl - $vartime2 )) /(60*60));
$togo = int($togo);
&cpheader;
print qq~
<tr><td bgcolor = $titlebak>$fwhite<b>License info</b></td></tr>
<tr valign=top>
<td width=100%>
$minitab1
Enter license number
$minitab2
<input type=text name="lic" size=20></b> ($togo hours left)
$minitab3
</td>
</tr>
</table></td></tr></table></td></tr></table> ~;
}


}

sub enter_license
{
&content;
print qq~
<HTML><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$TXT_main_language"><title>Active PowerBook</title>
</head>
<body bgcolor=#ffffff text="#000000" link="#000000" vlink="#000000" alink="#996600" onLoad="document.forms[0].password.focus()">
~;
print qq~ <center> <FORM ACTION="$guesturl" METHOD="POST">
<INPUT TYPE="hidden" NAME="action" VALUE="update_license">
<table cellpadding = 1 cellspacing = 0 width=700><tr><td bgcolor = #ffffff>
<table cellpadding = 1 cellspacing = 0 width=100%><tr><td bgcolor = $bordoutline>
<table cellpadding = 2 cellspacing = 0 width=100% border=1 bgcolor = $mainbak>
<tr><td width=100% colspan=1 align=center bgcolor = $titlebak>
$cptitlefont <b>Active PowerBook</b></td></tr>
<tr><td width=100% align=center> $cgifont Please enter license number.<br>


 <p> <INPUT TYPE="text" NAME="license" SIZE="20" MAXLENGTH="80"><br>

<INPUT TYPE="submit" VALUE="Submit license">
</FORM>
</font>
</td></tr>
</table></td></tr></table></td></tr></table>
~;
&inter_footer;
}

sub update_license {

  open(PERMS,">$htmlssin");

print PERMS "$FORM{'license'}";
close(PERMS);



&content;
print qq~ <html><head><title></title><META http-equiv="refresh" content="0; URL=$guesturl?book=&action=control_panel&vat=$varurl"> </head>
<body bgcolor=#ffffff> ~;
exit;

}

sub tempwipe
{

if (($temptype eq "ADD RESPONSE")||($temptype eq "VIEW RESPONSES")||($temptype eq "EDIT")||($temptype eq "PRIVATE_OPTION")){
print qq~
<tr><td>$cgifont<b>Override PowerBook link color?:</b> </td>
<td>$cgifont<input type=checkbox name="37" value=yes $y37><input name="37h" type=hidden value="active"> </td></tr>
<tr><td>$cgifont<b>Override color:</b> </td> <td>
<SELECT name="24" onChange="forms[1].b24.value=options[selectedIndex].value">
<OPTION value="" selected> Select New Color?
~;
&newoptions;
print qq~
</SELECT> <INPUT TYPE="TEXT" NAME="b24" VALUE="$la[24]" SIZE=7 MAXLENGTH=7>
</td></tr>
~; }

}

# sub lrgeet
#{
#unlink "$active_name";
#&content;
#print "Done";

#}
