West Virginia Personal Care Provider Directory

This list provides the name, office location and other contact information for Medicaid personal care provider agencies. Many of the agencies serve more than one county. Please feel free to contact the M-WIN Program at 304-293-4692 if you need assistance in locating a personal care provider near you.

Back to M-WIN

#!/usr/bin/perl $version="2.41r"; #open(STDERR,">&STDOUT"); #Use to find cause of errors. #********* BEGIN BODY******************** $uploadsdir='/home/cedwvu/programs/mwin/pcp/uploads/'; #Must end with a / $uploadsURL='http://www.cedwvu.org/programs/mwin/pcp/uploads/'; #Must end with a / $password="5HqwcGv6"; $logdir='/home/cedwvu/programs/mwin/pcp/logs/'; #Must end with a / $logfile="${logdir}pcpdirectory_data.log"; $fieldnames="${logdir}pcpdirectory_fields.log"; $members="${logdir}pcpdirectory_members.log"; $reportdata="${logdir}pcpdirectory_report.log"; $code='8363'; $vendor='WT'; &readparse; #BEGIN { $UnixCrypt::OVERRIDE_BUILTIN = 1 } #use UnixCrypt; if ($user_data{cgifunction} eq "exportset") { print "Content-type: text/plain\n\n"; } else { print "Content-type: text/html\n\n"; } if ((!(-e $logdir))&&(length($logdir)>0)) {&error("Could not find logs directory $logdir")}; &getReportInfo; &user if ($user_data{cgifunction} eq "user"); &add if ($user_data{cgifunction} =~/^(Add|Hinzufügen|Ajouter|Aggiungi|Agregar|Toevoegen|Incluir)$/); &adminsearch if ($user_data{cgifunction} eq "Search/modify"); &maintenance if ($user_data{cgifunction} eq "maintenance"); &delete if $user_data{cgifunction} eq "delete"; &modify if $user_data{cgifunction} eq "modify"; &admin if $user_data{cgifunction} eq "admin"; &usersearch if $user_data{cgifunction} =~/^(Search|Suchen|Chercher|Cerca|Buscar|Zoeken|Pesquisar)$/; &import if $user_data{cgifunction} eq "Import data"; &import2 if $user_data{cgifunction} eq "import2"; &export if $user_data{cgifunction} eq "Export data"; &export2 if $user_data{cgifunction} eq "export2"; &cache if $user_data{cgifunction} eq "cache"; &fieldmod if $user_data{cgifunction} eq "Modify fields"; &deleteField if $user_data{cgifunction} eq "deleteField"; &insertField if $user_data{cgifunction} eq "insertField"; &renameField if $user_data{cgifunction} eq "renameField"; &nextprev if $user_data{cgifunction} =~ /^(Next Page|Nächste Seite|Page suivante|Pagina Successiva|Página Siguiente|Volgende pagina|Próxima Página)$/; &nextprev if $user_data{cgifunction} =~ /^(Previous Page|Vorherige Seite|Page précédente|Pagina Precedente|Página Anterior|Vorige pagina|Página Anterior)$/; &members if $user_data{cgifunction} eq "Members"; &addmember if $user_data{cgifunction} eq "Add Member"; &deletemember if $user_data{cgifunction} eq "Delete Member"; &memberpage if $user_data{cgifunction} eq "memberpage"; &memberadd if $user_data{cgifunction} eq "add"; &reportpage if $user_data{cgifunction} eq "Customize Pages"; &modifyreport if $user_data{cgifunction} eq "Modify Pages"; &deleteset if $user_data{cgifunction} eq "deleteset"; &form if ($user_data{cgifunction} eq "form"); &sqlform if ($user_data{cgifunction} eq "sqlform"); &instantmember if ($user_data{cgifunction} eq "instantmember"); &exportset if ($user_data{cgifunction} eq "exportset"); &recordcount if ($user_data{cgifunction} eq "recordcount"); &replace if ($user_data{cgifunction} eq "replace"); &wtcart::configurecart if ($user_data{cgifunction} eq "Configure Shopping Cart"); &wtcart::saveCartSettings if ($user_data{cgifunction} eq "Save Cart Settings"); &wtcart::checkout if ($user_data{cgifunction} eq "checkout"); &wtcart::checkout2 if ($user_data{cgifunction} eq "checkout2"); &wtcart::checkout3 if ($user_data{cgifunction} eq "checkout3"); &wtcart::viewcart if ($user_data{cgifunction} eq "viewcart"); &wtcart::savecart if ($user_data{cgifunction} eq "savecart"); &wtcart::emptycart if ($user_data{cgifunction} eq "emptycart"); &wtcart::refreshcart if ($user_data{cgifunction} eq "refreshcart"); &wtcart::process if ($user_data{cgifunction} eq "process order"); &wtcart::retrieveOrders if ($user_data{cgifunction} eq "Retrieve Orders"); &wtcart::deleteOrders if ($user_data{cgifunction} eq "Delete Orders"); &error('There is no value for cgifunction') if $user_data{cgifunction} eq ""; sub error { print "$_[0]

\n"; die "$_[0] $!"; } #*****BEGIN INSTANTMEMBER SUBROUTINE sub instantmember { &error("Instant Member disabled by admin") if $allowInstantMember!=1; if ($user_data{username} eq "admin") { print ""; exit; }; &putlock; open(FILE,"<$members"); @members=; close FILE; &removelock; foreach (@members) { ($user,$pass)=split(/::/); if ($user_data{username} eq $user) { print ""; exit; }; }; $pass=crypt($user_data{password},7); $line="$user_data{username}::$pass\n"; &putlock; open(FILE,">>$members"); print FILE ("$line"); close FILE; &removelock; &memberpage; }; #****END INSTANTMEMBER SUBROUTINE sub form { if ($usersearch!=1) { if ($membersCanSearch) { &memberpass; } else { &checkpass; }; }; &wtcart::resultPageScript if $useCart; &language; pop(@value); $id=$user_data{fid}; if ($formTemplateOn != 1) { print " FORM DATA 0) {print " BACKGROUND=\"$background\""}; print "> $reportHeader

"; }; open(FIELDS,"<$fieldnames") or &error("Could not open $fieldnames"); @fieldsData=; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; shift(@fields); shift(@types); chomp(@fields); &putlock; #place a lock file in the uploads dir to prevent simultanious writing. open(READLOG,"<$logfile") or &error("Could not open $logfile"); @entrydata = ; close READLOG; chomp(@entrydata); &removelock; #remove lock file foreach $entry (@entrydata) { @parsed = split(/::/,$entry); if ($parsed[0] eq $id) {@data = @parsed}; }; $num = @fields; $id=shift(@data); $owner=pop(@data); if ($formTemplateOn != 1) { for ($i=0;$i<$num;$i++) { # $data[$i]=~s/\"/'"'/g; $data[$i]=~s/^([0-9a-zA-Z_\-\.\~]+\@[0-9a-zA-Z_\-\.\~]+\.[0-9a-zA-Z_\-\.\~]+)/$1<\/A>/; if ($data[$i]=~/^([^ ]+\.(gif|jpg))$/i) { $data[$i]=""; } else { &gettype($types[$i+1]); if ($type ne "upload") { $data[$i]=~s/^(http[^ ]+)/$1<\/A>/; } else { @filenameparts=split('_',$data[$i]); $filename=@filenameparts[$#filenameparts]; $data[$i]=~s/^(http[^ \<\>]+)/$filename<\/A>/g; } }; if ($data[$i] eq "") {$data[$i]=' '}; print "\n"; }; print "
$fields[$i]$data[$i]
"; }; &template if $formTemplateOn==1; if ($useCart) { print qq(
); print qq(
); unless ($formTemplateOn) { print qq(
\n); print &wtcart::addButton("cart1"); print qq(
); } } &wtcart::footer_cart_buttons if $useCart; print "

Back to Search Results \ \; " if length($user_data{query})>0; if ((length($user_data{cgilanguage})>0)&&($searchPage=~/cgifunction=user$/)) { $searchPage.="\&language=$user_data{cgilanguage}"; } print "\ \;\ \;$searchagain\n" if $searchAgain; print "\ \;\ \;$returntohomepage\n" if $returnToHomepage; #print "

$poweredbywebteacher"; }; #*******END FORM SUBROUTINE****** #BEGIN TEMPLATE sub template { $uploadcount=1; @escape=(); foreach (@data) { $tempescape=escape($_); push(@escape,$tempescape); if (!$templateNoSubstitute) { &gettype($types[$uploadcount]); s/^([0-9a-zA-Z_\-\.\~]+\@[0-9a-zA-Z_\-\.\~]+\.[0-9a-zA-Z_\-\.\~]+)/$1<\/A>/g; if ($_!~/\.(gif|jpg)$/) { if ($type eq "upload") { @filenameparts=split('_',$_); $filename=@filenameparts[$#filenameparts]; $_=~s/^(http[^ \<\>]+)/$filename<\/A>/g; } else { s/^(http[^ ]+)/$1<\/A>/g; }; }; s/^([^ ]+\.(gif|jpg))$/\/g; $uploadcount++; }; }; $dateCreated=&getDate($id); $formTemplate=~s/(\$if[^\}]*\})/&getIf($1)/ge; $formTemplate=~s/\$data\[([0-9]+)\]/$data[$1]/g; $formTemplate=~s/\$escape\[([0-9]+)\]/$escape[$1]/g; $formTemplate=~s/\$fields\[([0-9]+)\]/$fields[$1]/g; $formTemplate=~s/\$id/$id/g; $formTemplate=~s/\$datecreated/$dateCreated/g; $formTemplate=~s/\$membername/$owner/g; if ($useCart) { $tmp=&wtcart::addButton("cart1"); $formTemplate=~s/\$addbutton/

$tmp<\/FORM>/g; } print ($formTemplate); }; #END TEMPLATE # URL-encode data sub escape { shift() if ref($_[0]) || $_[0] eq $DefaultClass; my $toencode = shift; return undef unless defined($toencode); $toencode=~s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg; return $toencode; } # unescape URL-encoded data sub unescape { shift() if ref($_[0]); my $todecode = shift; return undef unless defined($todecode); $todecode =~ tr/+/ /; # pluses become spaces $todecode =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge; return $todecode; } #******BEGIN DELETE SET SUBROUTINE******* sub deleteset { &memberpass; &putlock; #place a lock file in the uploads dir to prevent simultanious writing. open(READLOG,"<$logfile") or &error("Could not open $logfile"); @entries = ; close READLOG; &removelock; #remove lock file foreach $line (@entries) { @data=split(/::/,$line); $len=@data; $owner=$data[$len-1]; chop($owner); $id=$_; if (($user_data{foundset}!~$data[0])||(($userid ne "admin")&&($userid ne $owner))) { push(@result,$line); } else { $uploadpath="${uploadsdir}${data[0]}"; unlink <$uploadpath*>; }; }; &putlock; #place a lock file in the uploads dir to prevent simultanious writing. open(PUTLOG, ">$logfile") or &error("Content-type: text/html\n\n

Could not open the file $logfile

If you have moved the file, you can correct this by changing lines 10 and 11 of the webdata_[database name].cgi script to show the absolute path to the file.

This cgi error was "); print PUTLOG (@result); close PUTLOG; &removelock; #remove lock file @value=(); if ($userid eq "admin") {&admin} else {&memberpage}; }; #******END DELETE SET SUBROUTINE********* #******BEGIN RECORD COUNT SUBROUTINE ****** sub recordcount { &putlock; #place a lock file in the uploads dir to prevent simultanious writing. open(READLOG,"<$logfile") or &error("Could not open $logfile"); @entries = ; close READLOG; &removelock; #remove lock file print $#entries+1; } #******END RECORD COUNT SUBROUTINE ****** #******BEGIN EXPORT SET SUBROUTINE ****** sub exportset { &memberpass; &putlock; #place a lock file in the uploads dir to prevent simultanious writing. open(READLOG,"<$logfile") or &error("Could not open $logfile"); @entries = ; close READLOG; &removelock; #remove lock file chomp(@entries); if ($user_data{delimiter} eq "comma") { $delimiter=','; } elsif ($user_data{delimiter} eq "tab"){ $delimiter="\t"; } else { $delimiter="\|"; }; $d2=$delimiter; $d2="\\|" if $d2 eq "\|"; foreach $line (@entries) { # $line=~s/,/\[COMMA\]/g if $delimiter eq ','; @data=split(/::/,$line); $len=@data; $owner=$data[$len-1]; if ($user_data{foundset}=~/$data[0]/) { $id=shift(@data); $dateCreated=&getDate($id); unshift(@data,$id,$dateCreated) if $user_data{includeID}; pop(@data) if !$user_data{includeID}; foreach (@data) { if (/$d2/) { $_=~s/\"/\"\"/g; $_="\"$_\""; } } $delimiter="\|" if $delimiter eq "\\\|"; $newline=join($delimiter,@data); push(@result,"$newline\n"); }; }; print (@result); } #******END EXPORT SET SUBROUTINE ******** #******BEGIN MODIFY REPORT.LOG FILE******* sub modifyreport { &checkpass; open(FILE,">$reportdata") or &error("Could not open $reportdata"); $user_data{header}=~s/\r?\n/::/g; $user_data{header}=~s/\<\;/; close FIELDS; @fields=(); @types=(); foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; shift(@fields); chomp(@fields); $i=0; foreach (@fields) { $fieldname=$_; $fieldname=~s/ //g; $boxname="${fieldname}_required"; if ($user_data{$boxname} eq "on") { push (@requiredfields,$i); } $i++; } $reqfields=join(',',@requiredfields); #chop($user_data{seqnums}); print FILE ("$user_data{color}\n$user_data{header}\n$user_data{seqnums}\n$user_data{sort}\n"); print FILE ("$user_data{order}\n$user_data{numrows}\n$form\n"); print FILE ("$user_data{searchHeader}\n$user_data{searchInfo}\n$user_data{viewButtonLabel}\n"); print FILE ("$searchTemplateOn\n$user_data{searchTemplate}\n"); print FILE ("$formTemplateOn\n$user_data{formTemplate}\n$user_data{searchPage}\n$user_data{limitAdminColumns}\n"); print FILE ("$allowInstantMember\n$europeanDates\n$user_data{sort2}\n$user_data{order2}\n$user_data{reportFooter}\n"); print FILE ("$user_data{headerColor}\n$user_data{rowColor1}\n$user_data{rowColor2}\n$user_data{formSeqnums}\n"); print FILE ("$hideBorder\n$user_data{tableFont}\n$usesql\n$user_data{dsn}\n$user_data{tablename}\n"); print FILE ("$user_data{primarykey}\n$useradd\n$usersearch\n$user_data{homepage}\n$user_data{memberpage}\n"); print FILE ("$membersCanSearch\n$membersCanAdd\n$searchbox\n$user_data{background}\n$user_data{viewButtonImage}\n"); print FILE ("$user_data{email}\n$user_data{sendmail}\n$user_data{language}\n$user_data{textcolor}\n$user_data{linkcolor}\n"); print FILE ("$user_data{vlinkcolor}\n$reqfields\n$templateNoSubstitute\n$limitMembers\n$limitMemberSearch\n"); print FILE ("$disableFileLocking\n$user_data{registereddb}\n$showCriteria\n$maintenanceTemplateOn\n"); print FILE ("$user_data{maintenanceTemplate}\n$gotoPage\n$nextprevButtons\n$searchAgain\n$returnToHomepage\n"); print FILE ("$user_data{reportPageFooter}\n$user_data{searchlog}\n$useCart\n$user_data{thankYouPage}\n"); close FILE; &wtcart::retainSettings if $useCart; &reportpage; }; #******END MODIFY REPORT.LOG FILE******* sub getReportInfo{ @reportData=(); open(FILE,"<$reportdata") or &error("Could not open $reportdata"); @reportData=; close FILE; chomp(@reportData); $reportColor=$reportData[0]; $reportHeader=$reportData[1]; $reportHeader=~s/::/\n/g; $reportSequence=$reportData[2]; @sequence=split(/:/,$reportSequence); $reportSort=$reportData[3]; $reportOrder=$reportData[4]; $reportLines=$reportData[5]; $reportLines=15 if $reportLines eq ""; $reportForm=$reportData[6]; $searchHeader=$reportData[7]; $searchHeader=~s/::/\n/g; $searchInfo=$reportData[8]; $viewButtonLabel=$reportData[9]; $searchTemplateOn=$reportData[10]; $searchTemplate=$reportData[11]; $searchTemplate=~s/::/\n/g; $formTemplateOn=$reportData[12]; $formTemplate=$reportData[13]; $formTemplate=~s/::/\n/g; $searchPage=$reportData[14]; $searchPageBox=$searchPage; if (length($searchPage)==0) {$searchPage="${cgilocation}?cgifunction=user"}; $limitAdminColumns=$reportData[15]; $allowInstantMember=$reportData[16]; $europeanDates=$reportData[17]; $reportSort2=$reportData[18]; $reportOrder2=$reportData[19]; $reportFooter=$reportData[20]; $reportFooter=~s/::/\n/g; $headerColor=$reportData[21]; $rowColor1=$reportData[22]; $rowColor2=$reportData[23]; $searchFormSequence=$reportData[24]; @SFsequence=split(':',$searchFormSequence); $hideBorder=$reportData[25]; $tableFont=$reportData[26]; $usesql=$reportData[27]; $dsn=$reportData[28]; $tablename=$reportData[29]; $primarykey=$reportData[30]; $useradd=$reportData[31]; $usersearch=$reportData[32]; $homepage=$reportData[33]; $memberpage=$reportData[34]; $membersCanSearch=$reportData[35]; $membersCanAdd=$reportData[36]; $searchbox=$reportData[37]; $background=$reportData[38]; $viewButtonImage=$reportData[39]; $email=$reportData[40]; $sendmail=$reportData[41]; $language=$reportData[42]; $textcolor=$reportData[43]; $linkcolor=$reportData[44]; $vlinkcolor=$reportData[45]; $reqfields=$reportData[46]; $templateNoSubstitute=$reportData[47]; $limitMembers=$reportData[48]; $limitMemberSearch=$reportData[49]; $disableFileLocking=$reportData[50]; $registereddb=$reportData[51]; $showCriteria=$reportData[52]; $maintenanceTemplateOn=$reportData[53]; $maintenanceTemplate=$reportData[54]; $maintenanceTemplate=~s/::/\n/g; $gotoPage=$reportData[55]; $nextprevButtons=$reportData[56]; $searchAgain=$reportData[57]; $returnToHomepage=$reportData[58]; $reportPageFooter=$reportData[59]; $reportPageFooter=~s/::/\n/g; $searchlog=$reportData[60]; $useCart=$reportData[61]; $thankYouPage=$reportData[62]; &wtcart::getcartdata if $hascart; } #*******BEGIN REPORT PAGE SUBROUTINE******** sub reportpage { &checkpass; &getReportInfo; open(FIELDS,"<$fieldnames") or &error("Could not open $fieldnames"); @fieldsData=; close FIELDS; @fields=(); @types=(); foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; shift(@fields); chomp(@fields); $len=@fields; $reportHeader=~s/Webdata Preferences

Preferences for the user search page and search results

Return to Administration Page
Test your modifications on the User Search Page
Scroll to bottom of page
Choose a language:
This changes the buttons and instructions on the user search page only.

Page Colors:
Enter a standard color or hex triplet, and/or a background image.
This will apply to all 3 pages, the initial search page, the search results table, and the 'view button' form.

\<\;BODY BGCOLOR= \"\"
BACKGROUND= \"\"
TEXT=\"\"
LINK=\"\"
VLINK=\"\"\>\;

Header for search page:
This will go at the top of the search input form that users come to first.
Enter any header text and/or images using HTML code:

Include default search instructions on Search Page?
Allow visitors to ADD to the database?
Allow visitors to SEARCH the database?

Which fields should appear on the user search page:
Click the fields in the left box in the sequence you wish
to display them in the user search page.
You may leave out fields which you wish to hide from users

Avaliable fieldsFields on search page

Use only a single search box for entire record.

Enter a URL for the \"Return to Homepage\" link.

If you would like use a customized search page:
1. Choose SAVE-AS on the default search page. Choose a name for the search page.
2. If you use a cgi-bin, edit the ACTION in the <FORM> tag to read \"/cgi-bin/$cgilocation\"
3. Customize the saved file and upload it.
4. Enter the name or URL of the new search page here.

"; $SearchPageBox=$searchPage; if ($searchPageBox eq "${cgilocation}?cgifunction=user") {$searchPageBox=""}; print "

If you would like to use a custom page for members:
1. Choose SAVE-AS on the default members page which comes up after a member logs in.
2. If you use a cgi-bin, edit the ACTION in the <FORM> tag to read \"/cgi-bin/$cgilocation\"
3. Remove the first line which contains a script to set the cookie.
4. Customize the saved file and upload it.
5. Enter the name or URL of the new members page here.


Allow members to SEARCH the database?
\ \;\ \;Restrict member searches to only their own records?
Allow members to ADD TO and MODIFY the database?
\ \;\ \;Limit members to 1 record each?
Note: You must use the members login page every time you wish to test a member feature so that the member cookie will replace the admin cookie. Likewise, you must use the admin login page again to reset the admin cookie before you return here or perform any other admin function. "; #*********** BEGIN ODBC ******************** #print " #


#Use an ODBC Database instead of Webdata's datafile. #
#You must have the Win32::ODBC module to use this option.
#DSN Name
#Table Name
#Primary Key #"; #************ END ODBC ********************** #************ BEGIN REQUIRED FIELDS ********* print "


\n"; print "Required Fields
The selected fields will be required on any page from which a record may be added.
\n"; $cols=0; $count=0; print "

"; foreach (@fields) { $fieldname=$_; $fieldname=~s/ //g; print "" if $cols==0; print ""; print "\n"; $cols++; if ($cols==5) { $cols=0; print "\n"; } $count++; } print "
$_
"; #************ END REQUIRED FIELDS *********** print "


Header for results page:
This will go at the top of the search results table.
Enter any header text and/or images using HTML code:

Display Search Criteria:
Keep a log of user searches
Enter the name or path to a file in which you would like to store visitor's search criteria.
You may need to create this file manually and change its permissions so that the script can write to it.

Hide Table Border:

Font information
Enter the attributes to go within a <FONT> tag for each table cell. Do not use quotes.
For example:
SIZE=3 FACE=Arial COLOR=green
<\;FONT >\;

Table Colors:
You may choose what color the header row of the table will be, and choose two alternating colors for the table itself. If you do
not wish to alternate, simply enter the same color for color1 and color2. Enter any standard color or hex code.

Header row: \ \; Table row color 1: \ \; Table row color 2:

Sub Footer for results page:
This will go at the bottom of the search results table, immediatly after the data, and before the navigation controls.
Enter any header text and/or images using HTML code:

Show \"Go to page: 1 2 3 ...\" navigation:
Show \"Next Page/Previous Page\" buttons:
Show \"Search Again\" link:
Show \"Return to Homepage\" link:

Footer for entire results page:
This will go at the very bottom of the search results page, after the navigation controls. Enter any header text and/or images using HTML code:

Sequence of Fields:
Click the fields in the left box in the sequence you wish
to display them in the user search results table.
You may leave out fields which you wish to hide from users

Avaliable fieldsReport Columns (left to right)

Display the Administration search results using only the above columns:

"; print ""; print "
"; print ""; print "
Sort by:
Choose the field by which you wish to sort first (primary sort)
Sort Sequence:
Sort by 2:
If 2 or more of the above values are the same,
choose the field to sort by next (secondary sort)
Sort Sequence:

\n"; print "Number of results per page

Include \"view\" button?
Label for view button:
Enter an image to use instead of the view button

The view button appears next to each record in the user search results. It displays the current record in a columnar form.


Use European Dates (dd/mm/yy)?

Allow 'Instant Member' page?

Use Shopping Cart? "; unless ($hascart) { print qq( The Shopping Cart module is available from http://www.webteacher.com/webdata/epowercart.html); } print "

Disable file locking
The program creates a small file in the $uploadsdir directory while modifying the data.log file so that 2 simultanious processes will not conflict with each other. If you are having difficulty setting write permissions to the $uploadsdir directory, you may disable this feature until you get it configured properly.


Notify admin of all new records
E-mail address
Path to Sendmail
On Unix, sendmail is frequently at /usr/lib/sendmail
On Windows, enter the path to Blat, which can be downloaded for free from http://gepasi.dbs.aber.ac.uk/softw/Blat.html
Thank You page: Create your own HTML page to be displayed after a user or member has submitted a new record to the database. If you include the word \$showdata in the page, it will be replaced with a list of the values the person has just added. \$data[#] and other keywords described in the template instructions below will also work.
Filename of \"Thank You\" page:

Template for first search results screen

Instead of the default table, you can enter your own HTML code in the box below. The code you enter will be displayed once for every record that matches the user\'s search criteria. Using the keys below, substitute \$data[0] where you would like the value contained in the first field to appear, \$data[1] for the value contained in the second field, etc. Type the word \$viewbutton to place the view button in the search results. Type \$id to include the record ID number. Type \$datecreated to include the date the record was added to the database. Type \$membername to display the record\'s owner. If you are creating a link to another cgi script, use \$escape[#] instead of \$data[#]. This will automatically convert \"three, at \$2.25/each\" into \"three%2C%20at%20%242.25%2Feach\", which is the format cgi scripts expect in the URL. If you use the shopping cart, type \$addbutton where the \"Add to cart\" button should go.
Conditional Display: The following syntax:
  \$if (\$data[#]) {my text}
will only display \"my text\" if there is a value in the \$data[#] field. If \$data[#] is empty, nothing will be displayed.
  \$if (!\$data[#]) {my text}
will have the oppositte effect. \"my text\" will only display if \$data[0] is empty or equal to zero.

Type this:To display the value for this: Type this:To display the value for this: "; $numfields=@fields; for($i=0;$i<$numfields;$i++) { print "
\$data[$i]$fields[$i]"; $i++; last if $i==$numfields; print "\$data[$i]$fields[$i]\n"; } print "

Do not convert URLs, e-mail addresses, and images in templates
If this box is unchecked, URLs and e-mail addresses will appear as links and images will be displayed automatically. Check this box if you wish to override the default substitutions. This is necessary, for example, to define the text inside a link or specify the alignment of an image.

Use this template instead of the search results table?
Search Template


Template for form view, when the \'view\' button is clicked

Instead of the default form, you can enter your own HTML code in the box below. Substitute \$data[0] where you would like the value contained in the first field to appear, \$data[1] for the value contained in the second field, etc.
Use this template instead of the default form when the 'view' button is clicked?
Form Template

Members Maintenance Page Template
The maintenance page appears when a member selects a record to be modified or deleted. If \"Limit Members to 1 Record Each\" is checked, this is the first page the member will come to.
Type \$field[#] to display an editable box for a selected field. Type \$data[#] to display the value of a field as text, in a non-editable format.
Use this template instead of the default Maintenance Page?

"; if ($user_data{qtfield}) {print " If you have registered another webdata_[database name].pl file in the same directory as this one is in, enter its filename here to register this database

"}; print "
Return to Administration Page

"; print " Test your modifications on the User Search Page




\ \;"; print qq( ); }; #*******END REPORT PAGE SUBROUTINE********** #********BEGIN MEMBERADD SUBROUTINE************** sub memberadd { &memberpass; open(FIELDS,"<$fieldnames") or &error("Could not open $fieldnames"); @fieldsData=; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; chomp(@fields); @value=(); $body="The following record has been added to the $cgilocation database.\n\n"; $value[0]=time(); $fcount=1; shift(@fields); $missingReqs=0; $isEmpty=1; foreach $fname (@fields) { $value[$fcount]=$user_data{$fname}; $reqnum=$fcount-1; if ((length($user_data{$fname})==0)&&($reqfields=~/(^|\,)$reqnum($|\,)/)) { $reqerror.="$fname is a required field.

"; $missingReqs=1; } if (length($user_data{$fname})>0) {$isEmpty=0}; $body.="$fname\: $user_data{$fname}\n"; &gettype($types[$fcount]); #UPLOAD IF IT IS AN UPLOAD FIELD if (($type eq "upload")&&(length($user_data{$fname})>0)) { if ($user_data{$fname}=~/([^\\\/\:]+$)/) {$INfilename=lc($1)}; $INfilename=~s/[^a-zA-Z0-9\_\.]//g; if ($INfilename=~/\.([a-zA-Z0-9]+)$/) {$extension=$1}; if ($typeexts!~/,*${extension},*/i) { &error("Only the following filetypes are allowed. $typeexts"); } $OUTfilename="${value[0]}_${fname}_${INfilename}"; $value[$fcount]="${uploadsURL}$OUTfilename"; $uploadsize=0; @filecontents=(); while ($bytesread=read($user_data{$fname},$buffer,1024)) { $uploadsize+=length($buffer); push(@filecontents,$buffer); } if ($uploadsize>$typesize*1000) { &error("upload size = $uploadsize bytes.

The upload can only be a maximum of ${typesize}KB") }; open (OUTFILE,">${uploadsdir}${OUTfilename}") or &error("Could not open ${uploadsdir}$OUTfilename for writing"); binmode(OUTFILE); print OUTFILE (@filecontents); close OUTFILE; close ($user_data{$fname}); } #END UPLOAD $fcount++; }; $body.="\nSUBMITTED BY: $userid\n"; if ($isEmpty) {$reqerror.="No data was submitted

"}; if (($missingReqs)||($isEmpty)) { &bodytag; print "Your record was not added for the following reasons:

\n"; print "$reqerror"; print qq(Return to previous page); exit; } #pop(@value); #** Remove cgifunction from @value array ** #if ($user_data{pagenum}>0) {pop(@value)}; #** remove pagenum from @value array foreach (@value) { $_=~s/\r/\n/g; $_=~s/\n\n/\n/g; $_=~s/\n/
/g; }; #******* Remove delimiter characters and leading spaces********* foreach $item (@value) { $item=~s/^( *)//g; # remove leading spaces from entries $item=~s/:/\:\;/g; # replace delimiting character from entries }; #****Check to see if entry is already used**** &putlock; #place a lock file in the uploads dir to prevent simultanious writing. open(READLOG,"<$logfile"); @entries = ; close READLOG; &removelock; #remove lock file $unique="true"; $line = $entries[$#entries]; @data = split(/::/,$line); chomp(@data); shift(@data); $comp1=join('::',@data); @data=(@value,$userid); chomp(@data); shift(@data); $comp2=join('::',@data); if ($comp1 eq $comp2) { $unique="false"; }; #********Add values to $logfile file******************* if($unique eq "true") { &putlock; #place a lock file in the uploads dir to prevent simultanious writing. push(@value,"$userid"); open(LOGFILE,">>$logfile") or &error("Could not open $logfile"); $line=join("::",@value); print LOGFILE ("$line\n"); close(LOGFILE); &removelock; #remove lock file. } else { print ""; print "That entry matches the previous entry exactly. It is probably a duplicate entry. Submission cancelled."; exit; }; #****RETURN TO MAINTENANCE SCREEN**** &thankYouPage; if (length($email)>0) { if ($^O=~/win/i) { open (MAIL,">${uploadsdir}mail.txt"); print MAIL ("$body\n"); close MAIL; $tmp=`$sendmail ${uploadsdir}mail.txt -s \"New Record Added to Database\" -t $email -q`; } else { open (MAIL,"|$sendmail -t") or &error("Could not open $sendmail"); print MAIL ("To: $email\nFrom: $email\n"); print MAIL ("Subject:New Record Added to Database\n$body\n"); close MAIL; } } }; #*********END MEMBER ADD SUBROUTINE******************** #********BEGIN LIMIT MEMBERS SUBROUTINE sub limitMem { &putlock; #place a lock file in the uploads dir to prevent simultanious writing. open (FILE,"<$logfile") or &error("Could not open $logfile"); @entries=; close FILE; &removelock; #remove lock file chomp(@entries); $isListed=grep(/::$userid$/,@entries); if (!$isListed) { open(FIELDS,"<$fieldnames") or &error("Could not open $fieldnames"); @fields=; close FIELDS; $numfields=@fields; $dummyline=time(); for ($i=0;$i<$numfields;$i++) { $dummyline.="::"; } $dummyline.=$userid; push(@entries,$dummyline); &putlock; #place a lock file in the uploads dir to prevent simultanious writing. open (FILE,">$logfile") or &error("Could not open $logfile"); foreach (@entries) { print FILE "$_\n"; } close FILE; &removelock; chomp(@entries); }; foreach(@entries) { if (/::$userid$/) { @data=split('::'); %user_data=(); @value=(); $user_data{part}=$data[0]; $value[0]=$user_data{part}; $value[1]="maintenance"; } } &maintenance; } #********END LIMIT MEMBERS SUBROUTINE #****BEGIN MEMBER PAGE SUBROUTINE sub memberpage { &memberpass; print ""; if ($limitMembers) { &limitMem; exit; } if (length($memberpage)>0) { print "\n"; print ""; exit; } @fields=(); @types=(); open(FIELDS,"<$fieldnames") or &error ("Could not open $fieldnames"); @fieldsData=; close FIELDS; $usemulti=0; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); $usemulti=1 if $type=~/upload/; }; shift(@fields); shift(@types); print " Members Admin Page

Members Administration Page

"; if (length($reqfields)>0) { print "* indicates required fields
"; } print "
"; print "\n"; $ftcount=0; foreach $field (@fields) { &gettype($types[$ftcount]); chop($field); print ""; if ($type eq "text") { print "\n"; }; if ($type eq "checkbox") { print "\n"; }; if ($type eq "list") { print "\n"; }; if ($type eq "comment") { print "\n"; }; if ($type eq "upload") { print "\n"; }; if ($type eq "variance") { print "\n"; }; if ($type eq "price-variance") { print "\n"; }; $ftcount++; }; print "
Date Created (Date is added automatically, use for Search/modify only)
"; print "* " if $reqfields=~/(^|\,)$ftcount($|\,)/; print "$field
"; if ($membersCanAdd) { print "Enter each option with a comma in-between.
" }; print "
"; if ($membersCanAdd) { print "Alternate option and price with a comma in-between.
for example: small,9.95,medium,12.95,large,15.95,X-large,18.95

" }; print "
"; print "" if $membersCanAdd; print " " if $membersCanAdd; print " "; print "
Search the entire database. " if $membersCanSearch; print "
Upload a delimited text file. " if $membersCanAdd; print "
\n"; if ($membersCanAdd) { print "

Click \'Add\' to add a record to the database.

To modify or delete a record: Search for the record, then click on the record in the search results window.

"; } if ($membersCanSearch) { print "

Enter your search criteria in the form, then click \"Search\" to search the entire database. Leave the form blank to show all records.

"; } print " Return to home page
Log out "; print qq( ); }; #****END MEMBER PAGE SUBROUTINE #*****BEGIN ADD MEMBER SUBROUTINE sub addmember { if ($value[0] eq "admin") { print ""; &members; exit; }; &putlock; open(FILE,"<$members") or &error("Could not open $members"); @members=; close FILE; &removelock; foreach (@members) { ($user,$pass)=split(/::/); if ($value[0] eq $user) { print ""; &members; exit; }; }; $pass=crypt($value[1],7); $line="$value[0]::$pass\n"; &putlock; open(FILE,">>$members") or &error("Could not open $members"); print FILE ("$line"); close FILE; &removelock; &members; }; #****END ADD MEMBER SUBROUTINE #*****BEGIN DELETE MEMBER SUBROUTINE sub deletemember { &putlock; open(FILE,"<$members") or &error("Could not open $members"); @oldlist=; close FILE; &removelock; foreach (@oldlist) { ($user,$pass)=split(/::/); if ($user ne $user_data{member}) {push(@newlist,$_)}; }; &putlock; open(FILE,">$members") or &error("Could not open $members"); print FILE (@newlist); close FILE; &removelock; &members; }; #****END DELETE MEMBER SUBROUTINE #****BEGIN ADD/REMOVE MEMBERS SUBROUTINE sub members { &checkpass; print "\n

Members

\n"; &putlock; open(FILE,"<$members"); @members=; close FILE; &removelock; @tmp=(); foreach (@members) { push (@tmp,$_) if /^.+::/; } @members=@tmp; $len=@members; $len=15 if $len>15; if ($len==0) { print "No members have been created yet\n"; } else { print "
\n"; print "
"; print "\n"; print "
"; }; print "
Add A Member
User Name
Password

Return to Administration Page "; }; #****END ADD/REMOVE MEMBERS SUBROUTINE #*******BEGIN NEXTPREV SUBROUTINE***** # THIS SUBROUTINE REPLACES THE PAGENUM CRITERIA, THEN # RUNS THE USERSEARCH ROUTINE sub nextprev { if ($user_data{cgifunction} =~ /^(Next Page|Nächste Seite|Page suivante|Pagina Successiva|Página Siguiente|Volgende pagina|Próxima Página)$/) {$n=1} else {$n=-1}; $p=$user_data{pagenum}+$n; $q=$user_data{query}; $replace="pagenum=$p"; $find="pagenum=$user_data{pagenum}"; $q=~s/$find/$replace/; #EMPTY VALUE AND USER_DATA ARRAYS BEFORE RUNNING READPARSE @value=(); %user_data=(); &readparse($q); &usersearch if ($user_data{cgifunction} =~/^(Search|Suchen|Chercher|Cerca|Buscar|Zoeken|Pesquisar)$/); &adminsearch if ($user_data{cgifunction} eq "Search/modify"); }; #*******END NEXTPREV SUBROUTINE******* #*******BEGIN RENAMEFIELD SUBROUTINE*** sub renameField { &checkpass; $select = $value[0]; $select++; $value[1]=~s/ *, */,/g if $value[1]=~/::list/; #remove spaces around comma open(FIELDS,"<$fieldnames"); @fields=; close FIELDS; $newfield="$value[1]\n"; $fields[$select]=$newfield; open(RESULT,">$fieldnames"); print RESULT (@fields); close RESULT; #****RETURN TO FIELD MODIFY SCREEN**** @value=(); &fieldmod; }; #*******END RENAME FIELD SUBROUTINE**** #*******BEGIN INSERTFIELD SUBROUTINE**** sub insertField { &checkpass; $select = $value[0]; $select++; $value[1]=~s/ *, */,/g if $value[1]=~/::list/; #remove spaces around comma open(FIELDS,"<$fieldnames"); @fields=; close FIELDS; $numfields=@fields; $newfield="$fields[$select]$value[1]\n"; $fields[$select]=$newfield; open(RESULT,">$fieldnames"); print RESULT (@fields); close RESULT; &putlock; #place a lock file in the uploads dir to prevent simultanious writing. open(RECORDS,"<$logfile"); @records = ; close RECORDS; &removelock; #remove lock file foreach (@records) { chop($_); @linedata=split(/::/,$_); $newdata="$linedata[$select]::"; $linedata[$select]=$newdata; $newline=join('::',@linedata); $_="$newline\n"; }; open(RECORDS,">$logfile"); print RECORDS (@records); close RECORDS; #***RESET PREFERENCES**** foreach (@sequence) {if ($_>$select-1) {$_++}}; foreach (@SFsequence) {if ($_>$select-1) {$_++}}; push(@sequence,$select); push(@SFsequence,$select); $reportData[2]=join(':',@sequence); $reportData[24]=join(':',@SFsequence); for ($i=$#fields;$i>=$select;$i--) { $num=$i+1; $searchTemplate=~s/\$data\[$i\]/\$data\[$num\]/g; $formTemplate=~s/\$data\[$i\]/\$data\[$num\]/g; } $searchTemplate=~s/\n/::/g; $formTemplate=~s/\n/::/g; $reportData[11]=$searchTemplate; $reportData[13]=$formTemplate; open (REPORT,">$reportdata") or &error("Could not open $reportdata for writing"); foreach (@reportData) { print REPORT ("$_\n"); }; close REPORT; #****RETURN TO FIELD MODIFY SCREEN**** @value=(); &fieldmod($select); }; #*******END INSERTFIELD SUBROUTINE****** #*******BEGIN DELETEFIELD SUBROUTINE**** sub deleteField { &checkpass; $select = $value[0]; $select++; open(FIELDS,"<$fieldnames") or &error("Could not open $fieldnames"); @fields=; close FIELDS; foreach $field (@fields) { if ($field ne $fields[$select]) { push(@result,$field); } } open(FIELDS,">$fieldnames") or &error("Could not open $fieldnames"); print FIELDS (@result); close FIELDS; &putlock; #place a lock file in the uploads dir to prevent simultanious writing. open(RECORDS,"<$logfile") or &error("Could not open $logfile"); @records=; close RECORDS; &removelock; #remove lock file foreach $record (@records) { chop($record); @linedata=split(/::/,$record); push(@deleteset,$linedata[0]); @newline=(""); $count=0; foreach $item (@linedata) { if ($count != $select) { push(@newline,$item); }; $count++; }; shift(@newline); $record = join('::',@newline)."\n"; }; open(RECORDS,">$logfile") or &error("Could not open $logfile"); print RECORDS (@records); close RECORDS; #DELETE IMAGES ($fieldname,$type)=split(/::/,$fields[$select]); chomp($fieldname); if ($type=~/upload/) { foreach $value (@deleteset) { $uploadpath="${uploadsdir}${value}_$fieldname"; unlink <$uploadpath*>; } } #END DELETE IMAGES #***RESET PREFERENCES**** @result=(); foreach (@sequence) { if ($_==$select) {$_=-1} if ($_>$select-1) {$_--} if ($_!=-1) {push(@result,$_)}; }; @sequence=@result; @result=(); foreach (@SFsequence) { if ($_==$select) {$_=-1} if ($_>$select-1) {$_--} if ($_!=-1) {push(@result,$_)}; }; @SFsequence=@result; $reportData[2]=join(':',@sequence); $reportData[24]=join(':',@SFsequence); $num=$select-1; $searchTemplate=~s/\$data\[$num\]/XXXX/g; $formTemplate=~s/\$data\[$num\]/XXXX/g; for ($i=$select;$i<$#fields;$i++) { $num=$i-1; $searchTemplate=~s/\$data\[$i\]/\$data\[$num\]/g; $formTemplate=~s/\$data\[$i\]/\$data\[$num\]/g; } $searchTemplate=~s/\n/::/g; $formTemplate=~s/\n/::/g; $reportData[11]=$searchTemplate; $reportData[13]=$formTemplate; open (REPORT,">$reportdata") or &error("Could not open $reportdata for writing"); foreach (@reportData) { print REPORT ("$_\n"); }; close REPORT; #****RETURN TO FIELD MODIFY SCREEN**** @value=(); &fieldmod; }; #*******END DELETEFIELD SUBROUTINE****** #*******BEGIN FIELDMOD SUBROUTINE******** sub fieldmod { &checkpass; if (length($_[0])>0) { $select=$_[0]; } else { $select=-1; } open(FIELDS,"<$fieldnames") or &error("Could not open $fieldnames"); @fields=; close FIELDS; shift(@fields); $num=@fields; $num++; print "

$var

"; print " Webdata Modify Fields

Modify Field List



Remember, whenever you add or remove fields, you need to change your field selections on the 'customize pages' screen.

To create a text box: Click Insert or Redefine field. Enter the field\'s name in the first prompt box. Enter the word \"text\" in the second prompt box. Enter the SIZE in number of characters for the new text box.

To create a checkbox: Click Insert or Redefine field. Enter the field\'s name in the first prompt box. Enter the word \"checkbox\" in the second prompt box. That's it.

To create a selection list: Click Insert or Redefine field. Enter the field\'s name in the first prompt box. Enter the word \"list\" in the second prompt box. In the third prompt box, enter the list of values, seperated by a comma without spaces around the comma. For example.
Fire Engine Red,Lemon Yellow,Medium Blue,Salmon,Crimson,Ash White

To create a textarea box for comments: Click Insert or Redefine field. Enter the field\'s name in the first prompt box. Enter the word \"comment\" in the second prompt box. In the third box, enter the number of rows high you wish to make your comment box. It will have a width of 60 characters.

To create an upload field with the option to upload with a web browser, enter the word \"upload\" in the second prompt box. In the third box, for security, enter the maximum size in Kilobytes for uploaded pictures or files. You must have the CGI.pm module to use this feature"; if ($useCart) { print "

SHOPPING CART USERS: There are 2 additional field types for use with the shopping cart module: variance and price-variance. A variance field will allow you to enter a list of options into that field, and the options will appear in a select list on the search results screen. For example, you could create a variance field named \"colors\", then, enter \"red,green,gold\" into the field, and the user will be able to choose from those three colors at checkout.

A price-variance field is similar to a variance field, however you may enter the price of each option. For example, you could have a field for \"Size\" and enter \"Small,4.95,Medium,7.50,Large,9.95,X-Large,12.25\" into the text box when you add the record. The user will see a list of sizes, with the price next to each one. The price which the user chooses will be the amount added to the shopping cart. If a price-variance field exists and is not empty, the price variance field will always override the \"price\" field declared in the Shopping Cart Setup Screen."; } print "

Return to Administration Page

To insert a field at the top of the list, do not select anything.
Click here to clear the selection

"; }; #*******END FIELDMOD SUBROUTINE********** #*******BEGIN USER SUBROUTINE************* sub user { &language; open(FIELDS,"<$fieldnames") or &error("Could not open $fieldnames"); @fieldsData=; close FIELDS; $usemulti=0; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); $usemulti=1 if (($type=~/upload/)&&($useradd)); }; shift(@fields); shift(@types); if ($searchPage ne "${cgilocation}?cgifunction=user") { print "\n"; print ""; exit; }; print " Database Search\n"; &bodytag; print "$searchHeader"; print "$instructions" if $searchInfo; if ((length($reqfields)>0)&&($useradd)) { print "

* $indicatesRequiredFields
"; } print "\n"; if (length($user_data{cgilanguage})>0) { print "\n"; } if ($searchbox) { print "Enter your search words
Show records containing of the search words. "; } else { print "

"; $ftcount=0; foreach (@SFsequence) { $field=$fields[$_]; &gettype($types[$_]); chop($field); print ""; if ($type eq "text") { print "\n"; }; if ($type eq "checkbox") { print "\n"; }; if ($type eq "list") { print "\n"; }; if ($type eq "comment") { print "\n"; }; if ($type eq "upload") { print "\n"; }; if ($type eq "variance") { print "\n"; }; if ($type eq "price-variance") { print "\n"; }; $ftcount++; }; print "
"; print "* " if ($reqfields=~/(^|\,)$_($|\,)/)&&($useradd); print "$field
"; print "Enter each option with a comma in-between.
" if $useradd; print "
"; if ($useradd) { print "Alternate option and price with a comma in-between.
for example: small,9.95,medium,12.95,large,15.95,X-large,18.95

"; }; print "

"; if (($usersearch)&&(!$useradd)) { print ""; print " "; } elsif ((!$usersearch)&&($useradd)) { print ""; print " "; } elsif (($usersearch)&&($useradd)) { print " "; print " "; }; print ""; } #END OF SEARCHBOX IF-ELSE print " "; }; #*******END USER SUBROUTINE*************** #******BEGIN BODYTAG SUBROUTINE******** sub bodytag { print "0; print " BACKGROUND=\"$background\"" if length($background)>0; print " TEXT=\"$textcolor\"" if length($textcolor)>0; print " LINK=\"$linkcolor\"" if length($linkcolor)>0; print " VLINK=\"$vlinkcolor\"" if length($vlinkcolor)>0; print ">\n"; } #******END BODYTAG SUBROUTINE #********BEGIN ADD SUBROUTINE************** sub add { &checkpass if $useradd!=1; &language; open(FIELDS,"<$fieldnames") or &error("Could not open $fieldnames"); @fieldsData=; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; @value=(); $body="The following record has been added to the $cgilocation database.\n\n"; $value[0]=time(); $fcount=1; chomp(@fields); shift(@fields); $missingReqs=0; $isEmpty=1; foreach $fname (@fields) { $value[$fcount]=$user_data{$fname}; $reqnum=$fcount-1; if ((length($user_data{$fname})==0)&&($reqfields=~/(^|\,)$reqnum($|\,)/)) { $reqerror.="$fname is a required field.

"; $missingReqs=1; } if (length($user_data{$fname})>0) {$isEmpty=0}; $body.="$fname\: $user_data{$fname}\n"; &gettype($types[$fcount]); #UPLOAD IF IT IS AN UPLOAD FIELD if (($type eq "upload")&&(length($user_data{$fname})>0)&&(!$missingReqs)) { if ($user_data{$fname}=~/([^\\\/\:]+$)/) {$INfilename=lc($1)}; $INfilename=~s/[^a-zA-Z0-9\_\.]//g; if ($INfilename=~/\.([a-zA-Z0-9]+)$/) {$extension=$1}; if ($typeexts!~/,*${extension},*/i) { &error("Only the following filetypes are allowed. $typeexts"); } $OUTfilename="${value[0]}_${fname}_${INfilename}"; $value[$fcount]="${uploadsURL}$OUTfilename"; $uploadsize=0; @filecontents=(); while ($bytesread=read($user_data{$fname},$buffer,1024)) { $uploadsize+=length($buffer); push(@filecontents,$buffer); } if ($uploadsize>$typesize*1000) { &error("upload size = $uploadsize bytes.

The upload can only be a maximum of ${typesize}KB") }; open (OUTFILE,">${uploadsdir}${OUTfilename}") or &error("Could not open ${uploadsdir}$OUTfilename for writing"); binmode(OUTFILE); print OUTFILE (@filecontents); close OUTFILE; close ($user_data{$fname}); } #END UPLOAD $fcount++; }; if ($isEmpty) {$reqerror.="No data was submitted

"}; if (($missingReqs)||($isEmpty)) { &bodytag; print "Your record was not added for the following reasons:

\n"; print "$reqerror"; print qq(Return to previous page); exit; } #pop(@value); #** Remove cgifunction from @value array ** #if ($user_data{pagenum}>0) {pop(@value)}; #** remove pagenum from @value array foreach (@value) { $_=~s/\r/\n/g; $_=~s/\n\n/\n/g; $_=~s/\n/
/g; }; #******* Remove delimiter characters and leading spaces********* foreach $item (@value) { $item=~s/^( *)//g; # remove leading spaces from entries $item=~s/:/\:\;/g; # replace delimiting character from entries }; #****Check to see if entry is already used**** &putlock; #place a lock file in the uploads dir to prevent simultanious writing. open(READLOG,"<$logfile"); @entries = ; close READLOG; &removelock; #remove lock file $unique="true"; $line = $entries[$#entries]; @data = split(/::/,$line); $lastID=shift(@data); pop(@data); $comp1=join('::',@data); @data=@value; shift(@data); $comp2=join('::',@data); if ($comp1 eq $comp2) { $unique="false"; }; if ($lastID >= $value[0]) { $value[0] = int($lastID) + 1; } #********Add values to $logfile file******************* if($unique eq "true") { &putlock; #place a lock file in the uploads dir to prevent simultanious writing. push(@value,"admin"); open(LOGFILE,">>$logfile") or &error("Could not open $logfile"); $line=join("::",@value); print LOGFILE ("$line\n"); close(LOGFILE); &removelock; #remove lock file. } else { print ""; print "That entry matches the previous entry exactly. It is probably a duplicate entry. Submission cancelled."; exit; }; #****RETURN TO MAINTENANCE SCREEN**** &thankYouPage; if (length($email)>0) { if ($^O=~/win/i) { open (MAIL,">${uploadsdir}mail.txt"); print MAIL ("$body\n"); close MAIL; $tmp=`$sendmail ${uploadsdir}mail.txt -s \"New Record Added to Database\" -t $email -q`; } else { open (MAIL,"|$sendmail -t") or &error("Could not open $sendmail"); print MAIL ("To: $email\nFrom: $email\n"); print MAIL ("Subject:New Record Added to Database\n$body\n"); close MAIL; } } }; #*********END ADD SUBROUTINE******************** #*********BEGIN THANK YOU PAGE****************** sub thankYouPage { &language; @tmp=split("\n",$body); shift(@tmp); shift(@tmp); if ($tmp[$#tmp - 1]=~/^SUBMITTED BY/) { pop(@tmp); pop(@tmp) } $showdata=join("
\n",@tmp); print "Database Entry Added"; &bodytag; if (!length($thankYouPage)) { print "

$addresponse

"; print "$returntoprevious

"; print "

$showdata"; } else { $entirePage=""; open (THANK,"<$thankYouPage") or &error("Could not open $thankYouPage"); while () {$entirePage.="$_"}; close THANK; $entirePage=~s/\$showdata/$showdata/g; $entirePage=~s/(\$if[^\}]*\})/&getIf($1)/ge; $entirePage=~s/\$data\[([0-9]+)\]/$value[$1 + 1]/g; $entirePage=~s/\$escape\[([0-9]+)\]/&escape($value[$1 + 1])/ge; $entirePage=~s/\$id/$value[0]/g; $entirePage=~s/\$datecreated/&getDate($value[0])/ge; $entirePage=~s/\$membername/$value[$#value]/g; print "$entirePage"; } } #*********END THANK YOU PAGE****************** #**********BEGIN SEARCH SUBROUTINE****************** sub adminsearch { &memberpass; print " Webdata Admin Search \n

Administration Search Page

"; &putlock; #place a lock file in the uploads dir to prevent simultanious writing. open(LOGFILE,"<$logfile") or &error("Could not open $logfile"); @entries = ; close (LOGFILE); chomp(@entries); &removelock; #remove lock file print "\n"; print "
\n"; open(FIELDS,"<$fieldnames") or &error("Could not open $fieldnames"); @fieldsData=; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; $fcount=1; @value=(); shift(@fields); @fieldnames=@fields; chomp(@fieldnames); foreach (@fields) { chop($_) if (/\n$/); $value[$fcount]=$user_data{$_}; $fcount++; }; if ($userid ne "admin") {push(@value,"^$userid\$")}; shift(@value); unshift(@value,$user_data{date_created}); $header= ""; if ($limitAdminColumns!=1) { foreach $field (@fields) { $header .= ""; }; } else { foreach (@sequence) { $header .= ""; }; }; print "$header\n"; #***** BEGIN STEPPING THROUGH ALL THE DATA LINES***** #***** PARSE THE DATA ***************** foreach $line (@entries) { @fields = split(/::/,$line); $ID = shift(@fields); $dateCreated=&getDate($ID); unshift(@fields,$dateCreated); # *** IF LINE MATCHES PATTERN *********** $display="true"; $numPairs=@fields; if (length($user_data{record_owned_by})) { $display="false" if $fields[$#_] ne $user_data{record_owned_by}; } for ($i=0;$i<$numPairs;$i++) { next unless $value[$i]; if ($value[$i]=~/[0-9][0-9]?\/[0-9][0-9]?\/[0-9][0-9]+/) { $_=$value[$i]; @temp=m/([0-9][0-9]?\/[0-9][0-9]?\/[0-9][0-9]+)/g; $temp[0]=&datetonum($temp[0]); $temp[1]=&datetonum($temp[1]); if (/^([><=]+)/) {$temp3=$1}; $criteria=$temp3.$temp[0]; if (/^between/i) {$criteria="between $temp[0] and $temp[1]"}; if ($fields[$i]=~/[0-9][0-9]?\/[0-9][0-9]?\/[0-9][0-9]+/) { $dataval=&datetonum($fields[$i]); } else { $display="false"; }; } else { $dataval=$fields[$i]; $criteria=$value[$i]; }; $_=$dataval; $criteria=~s/ or /\|/gi; if (($criteria=~/^(\"|\').*(\"|\')$/)&&($1 eq $2)) { $criteria=~s/^./\^/; $criteria=~s/.$/\$/; } if ($criteria=~/^\*.*\*$/) { $criteria=~s/^\*//; $criteria=~s/\*$//; } if ($criteria=~/\*$/) { $criteria="^".$criteria; $criteria=~s/\*$//; } if ($criteria=~/^\*/) { $criteria.="\$"; $criteria=~s/^\*//; } #remove currency and commas if (/^[\d\£\$\,\.]+$/) { $_=~s/[\£\$\,]//g; $criteria=~s/[\£\$\,]//g unless $criteria=~/\$$/; } if ($criteria!~/^\/.*\/$/) { #escape regexp characters unless criteria has / / $criteria=~s/([\*\+\?\.\/\(\)])/\\$1/g; } else { $criteria=~s/^\///; $criteria=~s/\/$//; } $firstchar=substr($criteria,0,1); $combo="false"; if (!((/$criteria/i)||($criteria eq "")|| ($firstchar eq '<')||($firstchar eq '>')|| ($criteria=~/ and /i))) { $display="false"; }; if ((substr($criteria,0,2) eq '<=')&&($_ > substr($criteria,2,99))) { $combo="true"; $display="false"; }; if ((substr($criteria,0,2) eq '>=')&&($_ < substr($criteria,2,99))) { $combo="true"; $display="false"; }; if (($combo ne "true")&&(substr($criteria,1,1) ne '=')) { if ((substr($criteria,0,1) eq '<')&&($_ >= substr($criteria,1,99))) { $display="false"; }; if ((substr($criteria,0,1) eq '>')&&($_ <= substr($criteria,1,99))) { $display="false"; }; if ($criteria=~/^between.* and /i) { $andpos = index($criteria,'and'); if ($andpos<8) {$display="false";}; $val1 = substr($criteria,7,$andpos); $val2 = substr($criteria,$andpos+4,99); if (($_<$val1)||($_>$val2)) { $display="false"; }; }; if (($criteria=~/ and /i)&&(!($criteria=~/^between/i))) { @cdata=split(/ and /i,$criteria); foreach $citem (@cdata) { if(!(/$citem/i)) {$display="false";}; }; }; }; }; #***** DISPLAY THE LINE **************** shift(@fields); if (!$user_data{pagenum}) { $user_data{pagenum}=1; $querystring=~s/cgifunction/pagenum=1\&cgifunction/; }; $pagenum=$user_data{pagenum}; $min=($pagenum-1)*20; $max=$pagenum*20; if ($display eq "true") { $count++; if (($count>$min)&&($count<=$max)) { print "\n"; print ""; print ""; if ($limitAdminColumns!=1) { foreach $n (@fields) { print ""; }; } else { foreach (@sequence) { $n=$fields[$_]; print ""; }; }; }; push(@foundset,$ID); }; print ""; }; print "\n
DeleteDate
Created
$field$fields[$_]
$dateCreated"; if ($n eq "") {$n = ' ';}; $n=~s/[\r\n]/
/g; print "$n
"; if ($n eq "") {$n = ' ';}; $n=~s/[\r\n]/
/g; print "$n
\n"; $foundsetstring=join(':',@foundset); print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; if ($count>0) { print "

Click on an entry to modify it.


EXPORT:
Export all $count records to browser as a delimited file.
Include ID, Date, and Owner (leave unchecked to import the data later)? \ \;
This will create a plain text file. Choose Save-As from the File menu to save."; if ($userid eq "admin") { print "
REPLACE VALUES:
In the $count found records only, replace the contents of \nwith
You may use \$data[#] to insert values of other fields.
See the instructions for using templates on the \"Customize Pages\" screen for details

"; } print "
"; #BEGIN NEXT/PREV BUTTONS $min++; if ($max>$count) {$max=$count}; print " "; if ($min>1) {print "
"}; if ($max<$count) {print "
"}; print ""; #END NEXT/PREV BUTTONS } else { print "No records were found

"; }; #CREATE LINKS TO ANY PAGENUMBER print "
Go to page\:"; $numpages=int($count/20); $myquery=$querystring; if ($count/20>$numpages) {$numpages++;}; for ($i=1;$i<=$numpages;$i++) { $myquery=~s/pagenum=[0-9]*/pagenum=$i/; print "$i "; }; print "
Return to Administration Page\n"; print "

Return to home page\n"; }; #*********END OF ADMINSEARCH SUBROUTINE************ #*********BEGIN REPLACE SUBROUTINE***************** sub replace { &memberpass; &putlock; open(FIELDS,"<$fieldnames") or &error("Could not open $fieldnames"); @fieldsData=; close FIELDS; my $fcount=0; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); if ($field eq $user_data{replace_field}) { $fieldNum=$fcount; last; } $fcount++; }; chomp(@fields); open(FILE,"<$logfile") or &error("Could not open $logfile"); @lines=; close FILE; chomp(@lines); foreach (@lines) { @data=split('::'); next unless $user_data{foundset}=~/(^|:)$data[0](:|$)/; next unless ($data[$#data] eq $userid) or ($userid eq "admin"); $replace_val=$user_data{replace_val}; $replace_val=~s/\$data\[(\d+)\]/$data[$1+1]/g; $replace_val=~s/\$escape\[([0-9]+)\]/&escape($data[$1+1])/ge; $replace_val=~s/\$fields\[([0-9]+)\]/$fields[$1+1]/g; $replace_val=~s/\$id/$data[0]/g; $replace_val=~s/\$datecreated/&getDate($data[0])/ge; $replace_val=~s/\$membername/$data[$#data]/g; $data[$fieldNum]=$replace_val; $_=join('::',@data); $count++; } open(FILE,">$logfile") or &error("Could not open $logfile"); foreach (@lines) { print FILE "$_\n"; } close FILE; &removelock; print qq( ); if ($userid eq "admin") { &admin; } else { &memberpage; } } #*********END REPLACE SUBROUTINE******************* #*********BEGIN ISMATCH ROUTINE***************** sub isMatch { # *** IF LINE MATCHES PATTERN *********** my $display="true"; my @data=(@_); my $id=$data[0]; my $dataval,$criteria; shift(@data); #**Remove hidden key from view** my $owner=pop(@data); #**Remove membername from view** chomp($owner); if (($limitMemberSearch)&&($owner ne $userid)) { return 0; } my $numPairs=@fields; $numPairs=1 if ($searchbox)&&(exists($user_data{all_search})); for ($i=0;$i<$numPairs;$i++) { unless ($user_data{all_search}) {next unless $value[$i]}; if ($value[$i]=~/[0-9][0-9]?\/[0-9][0-9]?\/[0-9][0-9]+/) { $_=$value[$i]; my @temp=m/([0-9][0-9]?\/[0-9][0-9]?\/[0-9][0-9]+)/g; $temp[0]=&datetonum($temp[0]); $temp[1]=&datetonum($temp[1]); if (/^([><=]+)/) {$temp3=$1}; $criteria=$temp3.$temp[0]; if (/^between/i) {$criteria="between $temp[0] and $temp[1]"}; if ($data[$i]=~/[0-9][0-9]?\/[0-9][0-9]?\/[0-9][0-9]+/) { $dataval=&datetonum($data[$i]); } else { return 0; }; } else { $dataval=$data[$i]; $criteria=$value[$i]; }; $_=$dataval; #*** BEGIN SINGLE BOX *** if (($searchbox)&&(exists($user_data{all_search}))) { $_=join('::',@data); $criteria=$user_data{all_search}; if (!exists($user_data{allany})) { $user_data{allany}=" and "; } $criteria=~s/ /$user_data{allany}/g; } #*** END SINGLE BOX $criteria=~s/ or /\|/gi; if (($criteria=~/^(\"|\').*(\"|\')$/)&&($1 eq $2)) { $criteria=~s/^./\^/; $criteria=~s/.$/\$/; } if ($criteria=~/^\*.*\*$/) { $criteria=~s/^\*//; $criteria=~s/\*$//; } if ($criteria=~/\*$/) { $criteria="^".$criteria; $criteria=~s/\*$//; } if ($criteria=~/^\*/) { $criteria.="\$"; $criteria=~s/^\*//; } #remove currency and commas if (/^[\d\£\$\,\.]+$/) { $_=~s/[\£\$\,]//g; $criteria=~s/[\£\$\,]//g unless $criteria=~/\$$/; } if ($criteria!~/^\/.*\/$/) { #escape regexp characters unless criteria has / / $criteria=~s/([\*\+\?\.\/\(\)])/\\$1/g; } else { $criteria=~s/^\///; $criteria=~s/\/$//; } my $firstchar=substr($criteria,0,1); my $combo="false"; if (!((/$criteria/i)||($criteria eq "")|| ($firstchar eq '<')||($firstchar eq '>')|| ($criteria=~/ and /i))) { return 0; }; if ((substr($criteria,0,2) eq '<=')&&($_ > substr($criteria,2,99))) { $combo="true"; return 0; }; if ((substr($criteria,0,2) eq '>=')&&($_ < substr($criteria,2,99))) { $combo="true"; return 0; }; if (($combo ne "true")&&(substr($criteria,1,1) ne '=')) { if ((substr($criteria,0,1) eq '<')&&($_ >= substr($criteria,1,99))) { return 0; }; if ((substr($criteria,0,1) eq '>')&&($_ <= substr($criteria,1,99))) { return 0; }; if ($criteria=~/^between.* and /i) { my $andpos = index($criteria,'and'); if ($andpos<8) {return 0;}; my $val1 = substr($criteria,7,$andpos); my $val2 = substr($criteria,$andpos+4,99); if (($_<$val1)||($_>$val2)) { return 0; }; }; if (($criteria=~/ and /i)&&(!($criteria=~/^between/i))) { my @cdata=split(/ and /i,$criteria); foreach $citem (@cdata) { if(!(/$citem/i)) {return 0;}; }; }; }; }; return 1; } #*********END ISMATCH ROUTINE***************** #*********BEGIN GETIF ROUTINE***************** sub getIf { if ($_[0]=~/\(([^\)]*)\)[^\{]*\{([^\}]*)\}/) { my $condition=$1; my $text=$2; $condition=~s/\$data\[(\d+)\]/$data[$1]/g; if ($condition!~/^\!/) { if ($condition) {return "$text"} else {return ""}; } else { $condition=~s/^\!//; unless ($condition) {return "$text"} else {return ""}; } } } #*********END GETIF ROUTINE***************** #**********BEGIN USERSEARCH SUBROUTINE****************** #*****Same as Search except the results**************** #*****Do not link to maintenance *************** # sub usersearch { if ($usersearch!=1) { if ($membersCanSearch) { &memberpass; } else { &checkpass; }; }; &language; if ($usesql==1) {&sqlsearch;exit;} $alt=0; pop(@value); #** Remove cgifunction from @value array ** pop(@value); #** Remove pagnum from @value array ** shift(@value); #remove ID from @value array ** print &wtcart::resultPageScript if $useCart; #&bodytag; print "$reportHeader\n"; #print and save search criteria while (($k,$v)=each(%user_data)) { if (($k!~/^(cgifunction|cgilanguage|pagenum|x|y|anyall|cgisort|cgisortorder)$/i)&& (length($v)>0)) { $usercriteria.="$k=$v "; }; }; if (length($searchlog)) { unless (-e $searchlog) {&error("Could not locate $searchlog")}; &putlock; open (SEARCHES,">>$searchlog") or &error("could not write to $searchlog. Check the file\'s permissions."); @t=(localtime(time()));$t[4]++;$t[5]+=1900; print SEARCHES ("$t[4]/$t[3]/$t[5] $t[2]:$t[1]:$t[0]\t"); print SEARCHES ("$ENV{REMOTE_ADDR}\t"); print SEARCHES ("$usercriteria\n"); close SEARCHES; &removelock; } print "
$usercriteria
\n" if $showCriteria; if (!$user_data{pagenum}) { $user_data{pagenum}=1; $querystring=~s/cgifunction/pagenum=1\&cgifunction/; }; $pagenum=$user_data{pagenum}; if ($searchTemplateOn) { print "\n"; } else { $cellpadding=""; if ($hideBorder==1) {$Border=0; $cellpadding=" CELLPADDING=5 CELLSPACING=0 "} else {$Border=1}; print "

\n"; } open(FIELDS,"<$fieldnames") or &error("Could not open $fieldnames"); @fieldsData=; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); }; shift(@fields); shift(@types); #POPULATE @VALUE INDEPENDENT OF SEQUENCE $fcount=0; foreach (@fields) { chop($_); $value[$fcount]=$user_data{$_}; $fcount++; }; #PARSE/SORT ROUTINE if ($user_data{cgisort}) { $reportSort=$user_data{cgisort}; $reportOrder=$user_data{cgisortorder}; } #...populate sorting array $sortcount=0; $textsort=0; $totalBytes=0; open(LOGFILE,"<$logfile") or &error("Could not open $logfile"); while () { $byteCount{$sortcount}=$totalBytes; $totalBytes+=length($_); $line=$_; my @data=split(/::/,$line); unless (&isMatch(@data)) {next}; push(@entries,$line); $val=lc($data[$reportSort]); if ($val=~/^[0-9][0-9]?\/[0-9][0-9]?\/[0-9][0-9]*$/) {$val=&datetonum($val)}; if ($val=~/[a-zA-Z]/) {$textsort=1;$val=~s/[^a-zA-Z0-9]//g}; if ($val=~/^[\d\£\$\,\. ]+$/) {$val=~s/[\£\$\, ]//g}; $sortarray{$sortcount}=$val; $val2=lc($data[$reportSort2]); if ($val2=~/^[0-9][0-9]?\/[0-9][0-9]?\/[0-9][0-9]*$/) {$val2=&datetonum($val2)}; if ($val2=~/[a-zA-Z]/) {$textsort2=1;$val2=~s/[^a-zA-Z0-9]//g}; if ($val2=~/^[\d\£\$\,\. ]+$/) {$val2=~s/[\£\$\, ]//g}; $sortarray2{$sortcount}=$val2; $sortcount++; } if ($reportOrder==1) {$bottom="\$a";$top="\$b"} else {$top="\$a";$bottom="\$b"}; if ($textsort) {$oper="cmp"} else {$oper="<=>"}; if ($reportOrder2==1) {$bottom2="\$a";$top2="\$b"} else {$top2="\$a";$bottom2="\$b"}; if ($textsort2) {$oper2="cmp"} else {$oper2="<=>"}; eval('@sortarray=sort { $sortarray{'.$top.'} '.$oper.' $sortarray{'.$bottom.'} or $sortarray2{'.$top2.'} '.$oper2.' $sortarray2{'.$bottom2.'} } keys %sortarray;'); undef %sortarray; undef %sortarray2; undef $line; undef $val; undef $val2; undef @data; undef $totalBytes; undef $top; undef $oper; undef $bottom; undef $top2; undef $oper2; undef $bottom2; $date=0; $numfound=$#sortarray+1; $min=($pagenum-1)*$reportLines; $max=$pagenum*$reportLines; if ($max>$numfound) {$max=$numfound}; #begin header if ($numfound>0) { $header= "0; $header.= ">"; if ($reportForm==1) {$header.="";}; foreach (@sequence) { &gettype($types[$_]); if ($type!~/variance/) { $sortquery=$querystring; $sortnum=$_+1; $sortquery=~s/pagenum=\d*//g; $sortquery.="\&pagenum=1"; $sortquery=~s/\&?cgisort=\d*//g; $sortquery=~s/\&?cgisortorder=\d//g; $sortquery.="\&cgisort=$sortnum"; if ($user_data{cgisort}==$sortnum) { $newsort=abs($user_data{cgisortorder}-1); } else { $newsort=0; } $sortquery.="\&cgisortorder=$newsort"; $sortquery=~s/\&\&+/\&/; $header .= qq(); } else { push(@varaincefields,$fields[$_]); } }; $header.="" if $useCart; $header.=""; print "$header\n" if !$searchTemplateOn; } #end header for ($count=$min;$count<$max;$count++) { #***** DISPLAY THE LINE **************** # seek LOGFILE,$byteCount{$sortarray[$count]},0; $line=$entries[$sortarray[$count]]; @data=split('::',$line); chomp(@data); $id=$data[0]; shift(@data); #**Remove hidden key from view** $owner=pop(@data); #**Remove membername from view** chomp($owner); if (!$searchTemplateOn) { #ALTERNATE TABLE COLORS if ($alt==0) { $alt=1; print "\n0; print ">"; } else { $alt=0; print "\n0; print ">"; } if ($reportForm==1) { if (length($viewButtonImage)>0) { print ""; } else { print ""; if (length($user_data{cgilanguage})>0) { print "\n"; } print ""; }; }; #***** BEGIN DISPLAY DATA LOOP ******* foreach (@sequence) { $n=$data[$_]; $n=~s/\r/
/g; if ($n eq "") {$n=' ';}; $n=~s/^([0-9a-zA-Z_\-\.\~]+\@[0-9a-zA-Z_\-\.\~]+\.[0-9a-zA-Z_\-\.\~]+)/$1<\/A>/g; if ($n=~/^([^ ]+\.(gif|jpg))$/i) { $n="" } else { &gettype($types[$_]); if ($type eq "upload") { @filenameparts=split('_',$n); shift(@filenameparts); shift(@filenameparts); $filename=join('_',@filenameparts); $n=~s/^(http[^ \<\>]+)/$filename<\/A>/g; } else { $n=~s/^(http[^ \<\>]+)/$1<\/A>/g; } }; unless ($type=~/variance/) { print ""; }; }; } else { @escape=(); foreach (@data) { $tempescape=escape($_); push(@escape,$tempescape); } #BEGIN SEARCHTEMPLATE SUBSTITUTION if (!$templateNoSubstitute) { $uploadcount=1; foreach (@data) { &gettype($types[$uploadcount]); s/^([0-9a-zA-Z_\-\.\~]+\@[0-9a-zA-Z_\-\.\~]+\.[0-9a-zA-Z_\-\.\~]+)/$1<\/A>/g; if ($_!~/\.(gif|jpg)$/) { if ($type eq "upload") { @filenameparts=split('_',$_); $filename=@filenameparts[$#filenameparts]; $_=~s/^(http[^ \<\>]+)/$filename<\/A>/g; } else { s/^(http[^ ]+)/$1<\/A>/g; }; }; s/^([^ ]+\.(gif|jpg))$/\/g; $uploadcount++; }; }; $dateCreated=&getDate($id); $template=$searchTemplate; $template=~s/(\$if[^\}]*\})/&getIf($1)/ge; $template=~s/\$fields\[(\d+)\]/$fields[$1]/g; $template=~s/\$data\[(\d+)\]/$data[$1]/g; $template=~s/\$escape\[(\d+)\]/$escape[$1]/g; if (length($viewButtonImage)>0) { $template=~s/\$viewbutton/<\/A>/; } else { $template=~s/\$viewbutton/\
<\/form>/; } $template=~s/\$id/$id/g; $template=~s/\$datecreated/$dateCreated/g; $template=~s/\$membername/$owner/g; if ($useCart) { $tmp=&wtcart::addButton("cart$count"); $template=~s/\$addbutton/$tmp<\/FORM>/g; } print ($template); } #***** END DISPLAY DATA LOOP ********* if (($useCart)&&(!$searchTemplateOn)) { print "
"; } print "" if !$searchTemplateOn; }; if (!$searchTemplateOn) { print "\n
$fields[$_]Options - Qty - Cart
"; print "
$n"; print &wtcart::addButton("cart".$count); print "
\n"; } $count=$#sortarray+1; close (LOGFILE); print "$reportFooter\n"; if ($count>0) { print " "; if (length($user_data{cgilanguage})>0) { print "\n"; } print " \n"; $min++; if ($max>$count) {$max=$count}; print " "; if ($nextprevButtons) { if ($min>1) {print "
"; if (length($user_data{cgilanguage})>0) { print "\n"; } print "
";}; if ($max<$count) {print "
"; if (length($user_data{cgilanguage})>0) { print "\n"; } print "
"}; }; #CREATE LINKS TO ANY PAGENUMBER if ($gotoPage) { print "$gotopage\: "; $numpages=int($count/$reportLines); $myquery=$querystring; if ($count/$reportLines>$numpages) {$numpages++;}; for ($i=1;$i<=$numpages;$i++) { if ($pagenum==$i) { print "$i "; } else { if ($numpages>50) { $difference=abs($i-$pagenum); if ( ($difference<=5) or ($i==1) or ($i==$numpages) or (($i/10==int($i/10)) and ($difference<=50)) or (($i/100==int($i/100)) and ($difference<=500)) or (($i/1000==int($i/1000)) and ($difference<=5000)) or ($i/10000==int($i/10000)) ) { $myquery=~s/pagenum=[0-9]*/pagenum=$i/; if ($difference<=5) { $sizetag=qq(); $sizetag2=qq(); } else { $sizetag="";$sizetag2=""; } print "
${sizetag}${i}$sizetag2 "; } } else { $myquery=~s/pagenum=[0-9]*/pagenum=$i/; print "${sizetag}${i}$sizetag2 "; } } } }; } else { print "$noresultswerefound

"; }; if ((length($user_data{cgilanguage})>0)&&($searchPage=~/cgifunction=user$/)) { $searchPage.="\&cgilanguage=$user_data{cgilanguage}"; } print "$searchagain\n" if $searchAgain; print "$returntohomepage\n" if $returnToHomepage; print ""; &wtcart::footer_cart_buttons if $useCart; print "\n
$reportPageFooter
\n"; #print "

$poweredbywebteacher"; }; #*********END OF USERSEARCH SUBROUTINE************ #*********BEGIN MAINTENANCE SUBROUTINE******** sub maintenance { &memberpass; pop(@value); $maintenanceTemplateOn=(($maintenanceTemplateOn)&&($userid ne "admin")); &putlock; #place a lock file in the uploads dir to prevent simultanious writing. open(READLOG,"<$logfile") or &error("Could not open $logfile"); @entries = ; close READLOG; &removelock; #remove lock file foreach $line (@entries) { @data = split(/::/,$line); if ($data[0] eq $value[0]) { @fields=(); @types=(); open(FIELDS,"<$fieldnames") or &error("Could not open $fieldnames"); @fieldsData=; close FIELDS; foreach (@fieldsData) { ($field,$type)=split(/::/); push(@fields,"$field\n"); push(@types,"$type"); $usemulti=1 if $type=~/upload/; }; shift(@fields); shift(@types); print " Modify or delete record\n"; &bodytag; print "

Maintenance Page

"; print "" if !$maintenanceTemplateOn; $num = @fields; $id=$data[0]; $owner=$data[$#_]; print "\n" if !$maintenanceTemplateOn; $dateCreated=&getDate($id); print "\n" if !$maintenanceTemplateOn; shift(@data); $ftcount=0; $hiddenfields=""; foreach $field (@fields) { $data[$ftcount]=~s/\"/\"\;/g; &gettype($types[$ftcount]); chop($field); $pf=&printField($type,$field,$data[$ftcount]); if (!$maintenanceTemplateOn) { print "\n"; } else { if ($maintenanceTemplate!~/\$field\[$ftcount\]/) { $hiddenfields.="\n"; } $maintenanceTemplate=~s/(\$if[^\}]*\})/&getIf($1)/ge; $maintenanceTemplate=~s/\$field\[$ftcount\]/$pf/g; $maintenanceTemplate=~s/\$data\[$ftcount\]/$data[$ftcount]/g; $maintenanceTemplate=~s/\$id/$id/g; $maintenanceTemplate=~s/\$datecreated/$dateCreated/g; $maintenanceTemplate=~s/\$membername/$owner/g; } $ftcount++; }; print "$maintenanceTemplate\n$hiddenfields

" if $maintenanceTemplateOn; if ($userid eq "admin") { print "

\n"; } if (!$maintenanceTemplateOn) {print "
ID" if !$maintenanceTemplateOn; print ""; print "$id
Date Created$dateCreated
$field"; print "$pf"; print "
Owned By"; &putlock; open(FILE,"<$members"); @members=; close FILE; &removelock; chomp($owner); print qq(); print "
"} else {print "
"}; print " You must click \"modify\" to save your changes.
"; print "