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.
";
};
&template if $formTemplateOn==1;
if ($useCart) {
print qq();
unless ($formTemplateOn) {
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/ 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 "";
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 "
";
};
#*******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 "
";
print "* " if ($reqfields=~/(^|\,)$_($|\,)/)&&($useradd);
print "$field
";
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 "
";
print "Enter each option with a comma in-between. " if $useradd;
print "
\n";
};
if ($type eq "price-variance") {
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 "
";
};
#*******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 "
$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= "
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= "
$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 "
ID
" if !$maintenanceTemplateOn;
print "";
print "$id
\n" if !$maintenanceTemplateOn;
$dateCreated=&getDate($id);
print "
Date Created
$dateCreated
\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 "