#!/usr/bin/perl # use CGI; $query = new CGI; #STEP A================================ #A1. The following lines get and process data passed #through the URL, do not modify $stringpassed=$ENV{'QUERY_STRING'}; #A2. Replace all plusses with spaces for data passed via URL $stringpassed=~s/\+/ /g; #STEP B================================ #You MUST modify each of the variables in this this section #B1. REQUIRED: The location of the data file on your server. This must #be the PATH to your data file, not the URL of your data file! $data="D:/Domains/specialists-in-seating.co.uk/wwwroot/data/news.txt"; #B1b. REQUIRED: The location of your temporary data file on your server. #Must be the PATH to your temporary data data file, not the URL. Use a file #extension other than .tmp to avoid possible conflicts within script $tempdata="D:/Domains/specialists-in-seating.co.uk/wwwroot/data/newstemp.txt"; #B2. REQUIRED: The URL of this script file in your cgi-bin directory. #You can provide the full URL, beginning with http:// (or, you can #simply use the filename, i.e. "database.cgi") $thisurl="news.pl"; #B3. OPTIONAL: You can format the opening and closing HTML #of your results page in a separate file that can be written in #regular HTML and saved on your server. If your script can't #find this file and open it, the default result screen is displayed #instead. For ease of configuration, place it in the same directory #as your data file. Note: this file must have three plusses +++ #where you want your search results inserted. #Note, you are providing a full or relative server PATH here. A #URL will not work. $openinghtml="D:/Domains/specialists-in-seating.co.uk/wwwroot/Templates/news.htm"; #B4. REQUIRED TO ADD, DELETE, OR MODIFY. See #important information in the help files about adding additional #Security features to your script. #Change password to any combination of letters (A-Z, a-z) and #numbers 0-1. USE ONLY LETTERS AND NUMBERS $adminpassword="000"; #B5. URL to send users to after posting, editing, or getting errors. #This is usually the main page for this section of your site $forwardingURL="../index.htm"; #B50. Please provide the path to the directory where #your upload images will go. Depending on server configuration, #you may need to chmod 777 this directory, to make it writeable. #The path you are providing below should end with a forwardslash. #This feature is inherently INSECURE and opens a wide range of #SECURITY issues, many of them very serious. You are highly encouraged #to direct all uploads to a nonpublic directory and then move them #to a public directory only after you have evaluated the files. #Use at your own risk. This feature may not be compatible with #your server. NEVER ALLOW UPLOADS INTO (or subdirectory of) #YOUR CGI-BIN DIRECTORY! Please note that you are providing #a full or relative system PATH. A URL will not work here. $Imageuploadpath="../news/"; #B51. Please provide the URL to the directory where your #your uploaded images will be located. Note that this must be a #full URL beginning with http:// for the directory only! Forwardslash #at end of the URL is required $ImageuploadURL="../news/"; #B52. Please specify the largest file for the image upload #that you are willing to permit. This value is in KB, so use numbers #like 50 for 50KB. Never set the number above 100 $Imagemaxz="500"; #B53. Do you want to allow images to be changed while in edit #mode? Select Y for Yes or N for No $allowimageuploadonedit="Y"; #B54. Do you want to delete the images when you delete the #corresponding record. Select Y for Yes or N for No $deleteonimagerecorddelete="Y"; #B54. Please provide the full or relative path to your counter #file for the Autoincrement field. You must provide full path and file #information. You should give the file a .txt extension $counterfile="../clientcounter/news.txt"; #B55. Do you want to update the Unix Timestamp when the record #is edited too? Select Yes to update the Timestamp when editing, Select No to keep #the time that was initially stamped when the record was added $timestampupdate="Yes"; #STEP C================================ #C1. Maximum number of matching records to display per page $maximumpage=25; #C2. Maximum total number of records to display per search, #for stylistic reasons, should be multiple of above number $maximum=250; @variablenames = $query->param; foreach $variable (@variablenames){ $value=$query->param($variable); $tempapprove{$variable}="$value";} #STEP D================================ #You should not need to modify this section at all #D1. Check to see if opening html file is on server if (-e "$openinghtml"){ #D2. If so, open it and write opening and closing text to different strings #to be used throughout the script $problem="Can't open template file. Make sure you are referencing the file and not just a directory."; open(OPENING, "$openinghtml") || &security; @wholefile=; close(OPENING); $fulltemplate=join("\n",@wholefile); ($templatestart,$templateend)=split(/\+\+\+/,$fulltemplate);} else{ #D3. If template file not found, use this for now $templatestart="$templatetitle"; $templateend="";} $delimiter="\t"; #D6. Get Password Entered by User $checkpassword=$query->param('checkpassword'); #D7. Figure out what action user wants to take. $actiontotake=$query->param('actiontotake'); $linenumberpass=$query->param('linenumberpass'); #D8. If user wants to delete record, and has already #verified password, then go to the makechange subroutine if ($actiontotake eq "Delete Record"){ $recordaction="Deleted"; &makechange; exit;} #D9. If user wants to edit record, and has already #verified password, then go to the makechange subroutine if ($actiontotake eq "Edit Record"){ $recordaction="Edited"; &makechange; exit;} #D10. If user wants to edit record, to go subroutine to verify if ($actiontotake eq "Edit"){ &edit; exit;} #D11. If user wants to delete record, to go subroutine to verify if ($actiontotake eq "Delete"){ &delete; exit;} #D12. If user wants to add record, go to add subroutine if ($actiontotake eq "Add"){ &addrecord; exit;} #D13. If user wants to add record to temporary file if ($actiontotake eq "Addtemp"){ &addtemp; exit;} #D14. If owner wants to evaluate records in temp file if ($actiontotake eq "Scrolltemp"){ &scrolltemp; exit;} #D15. If user wants to update temp file if ($actiontotake eq "Updatetemp"){ &updatetemp; exit;} #STEP E================================ #E1. Get the data passed from user $Category=$query->param('Category'); $Categorywork=lc($Category); #E1b. The line below chops characters that cause problems in Perl word searches $Categorywork=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Categorywork eq "select"){ $Categorywork=""; $Category="";} $Categorypass="$Category"; #E1. Get the data passed from user $Title=$query->param('Title'); $Titlework=lc($Title); #E1b. The line below chops characters that cause problems in Perl word searches $Titlework=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Titlework eq "select"){ $Titlework=""; $Title="";} $Titlepass="$Title"; #E1. Get the data passed from user $Introduction=$query->param('Introduction'); $Introductionwork=lc($Introduction); #E1b. The line below chops characters that cause problems in Perl word searches $Introductionwork=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Introductionwork eq "select"){ $Introductionwork=""; $Introduction="";} $Introductionpass="$Introduction"; #E1. Get the data passed from user $Article=$query->param('Article'); $Articlework=lc($Article); #E1b. The line below chops characters that cause problems in Perl word searches $Articlework=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Articlework eq "select"){ $Articlework=""; $Article="";} $Articlepass="$Article"; #E1. Get the data passed from user $Date=$query->param('Date'); $Datework=lc($Date); #E1b. The line below chops characters that cause problems in Perl word searches $Datework=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Datework eq "select"){ $Datework=""; $Date="";} $Datepass="$Date"; #E1. Get the data passed from user $Month=$query->param('Month'); $Monthwork=lc($Month); #E1b. The line below chops characters that cause problems in Perl word searches $Monthwork=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Monthwork eq "select"){ $Monthwork=""; $Month="";} $Monthpass="$Month"; #E1. Get the data passed from user $Year=$query->param('Year'); $Yearwork=lc($Year); #E1b. The line below chops characters that cause problems in Perl word searches $Yearwork=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Yearwork eq "select"){ $Yearwork=""; $Year="";} $Yearpass="$Year"; #E1. Get the data passed from user $Date_Added=$query->param('Date_Added'); $Date_Addedwork=lc($Date_Added); #E1b. The line below chops characters that cause problems in Perl word searches $Date_Addedwork=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Date_Addedwork eq "select"){ $Date_Addedwork=""; $Date_Added="";} $Date_Addedpass="$Date_Added"; #E1. Get the data passed from user $Date_Time_Added=$query->param('Date_Time_Added'); $Date_Time_Addedwork=lc($Date_Time_Added); #E1b. The line below chops characters that cause problems in Perl word searches $Date_Time_Addedwork=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Date_Time_Addedwork eq "select"){ $Date_Time_Addedwork=""; $Date_Time_Added="";} $Date_Time_Addedpass="$Date_Time_Added"; #E1. Get the data passed from user $Autoincrement=$query->param('Autoincrement'); $Autoincrementwork=lc($Autoincrement); #E1b. The line below chops characters that cause problems in Perl word searches $Autoincrementwork=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Autoincrementwork eq "select"){ $Autoincrementwork=""; $Autoincrement="";} $Autoincrementpass="$Autoincrement"; #E1. Get the data passed from user $Extra1=$query->param('Extra1'); $Extra1work=lc($Extra1); #E1b. The line below chops characters that cause problems in Perl word searches $Extra1work=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Extra1work eq "select"){ $Extra1work=""; $Extra1="";} $Extra1pass="$Extra1"; #E1. Get the data passed from user $Extra2=$query->param('Extra2'); $Extra2work=lc($Extra2); #E1b. The line below chops characters that cause problems in Perl word searches $Extra2work=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Extra2work eq "select"){ $Extra2work=""; $Extra2="";} $Extra2pass="$Extra2"; #E1. Get the data passed from user $Extra3=$query->param('Extra3'); $Extra3work=lc($Extra3); #E1b. The line below chops characters that cause problems in Perl word searches $Extra3work=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Extra3work eq "select"){ $Extra3work=""; $Extra3="";} $Extra3pass="$Extra3"; #E1. Get the data passed from user $Extra4=$query->param('Extra4'); $Extra4work=lc($Extra4); #E1b. The line below chops characters that cause problems in Perl word searches $Extra4work=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Extra4work eq "select"){ $Extra4work=""; $Extra4="";} $Extra4pass="$Extra4"; #E1. Get the data passed from user $Extra5=$query->param('Extra5'); $Extra5work=lc($Extra5); #E1b. The line below chops characters that cause problems in Perl word searches $Extra5work=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Extra5work eq "select"){ $Extra5work=""; $Extra5="";} $Extra5pass="$Extra5"; #E1. Get the data passed from user $Extra6=$query->param('Extra6'); $Extra6work=lc($Extra6); #E1b. The line below chops characters that cause problems in Perl word searches $Extra6work=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Extra6work eq "select"){ $Extra6work=""; $Extra6="";} $Extra6pass="$Extra6"; #E1. Get the data passed from user $Extra7=$query->param('Extra7'); $Extra7work=lc($Extra7); #E1b. The line below chops characters that cause problems in Perl word searches $Extra7work=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Extra7work eq "select"){ $Extra7work=""; $Extra7="";} $Extra7pass="$Extra7"; #E1. Get the data passed from user $Extra8=$query->param('Extra8'); $Extra8work=lc($Extra8); #E1b. The line below chops characters that cause problems in Perl word searches $Extra8work=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Extra8work eq "select"){ $Extra8work=""; $Extra8="";} $Extra8pass="$Extra8"; #E1. Get the data passed from user $Extra9=$query->param('Extra9'); $Extra9work=lc($Extra9); #E1b. The line below chops characters that cause problems in Perl word searches $Extra9work=~tr/[a-zA-Z0-9 \.\,\?\@\-]/ /cd; if ($Extra9work eq "select"){ $Extra9work=""; $Extra9="";} $Extra9pass="$Extra9"; #E6. Get number of records already displayed $startitem=$query->param('startitem'); #E7. Figure the last record to display on this page $enditem=$startitem+$maximumpage; #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Categorywork=~tr/[ÈÉÊËéêëè]/e/; #$Categorywork=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Categorywork=~tr/[çÇ]/c/; #$Categorywork=~tr/[ìíîïÍÎÏÌ]/i/; #$Categorywork=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Categorywork=~tr/[ÙÚÛÜùúûü]/u/; ($Categoryone, $Categorytwo, $Categorythree, $Categoryfour, $Categoryfive, $Categorysix, $Categoryseven)=split(/ /, $Categorywork); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Titlework=~tr/[ÈÉÊËéêëè]/e/; #$Titlework=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Titlework=~tr/[çÇ]/c/; #$Titlework=~tr/[ìíîïÍÎÏÌ]/i/; #$Titlework=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Titlework=~tr/[ÙÚÛÜùúûü]/u/; ($Titleone, $Titletwo, $Titlethree, $Titlefour, $Titlefive, $Titlesix, $Titleseven)=split(/ /, $Titlework); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Introductionwork=~tr/[ÈÉÊËéêëè]/e/; #$Introductionwork=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Introductionwork=~tr/[çÇ]/c/; #$Introductionwork=~tr/[ìíîïÍÎÏÌ]/i/; #$Introductionwork=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Introductionwork=~tr/[ÙÚÛÜùúûü]/u/; ($Introductionone, $Introductiontwo, $Introductionthree, $Introductionfour, $Introductionfive, $Introductionsix, $Introductionseven)=split(/ /, $Introductionwork); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Articlework=~tr/[ÈÉÊËéêëè]/e/; #$Articlework=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Articlework=~tr/[çÇ]/c/; #$Articlework=~tr/[ìíîïÍÎÏÌ]/i/; #$Articlework=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Articlework=~tr/[ÙÚÛÜùúûü]/u/; ($Articleone, $Articletwo, $Articlethree, $Articlefour, $Articlefive, $Articlesix, $Articleseven)=split(/ /, $Articlework); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Datework=~tr/[ÈÉÊËéêëè]/e/; #$Datework=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Datework=~tr/[çÇ]/c/; #$Datework=~tr/[ìíîïÍÎÏÌ]/i/; #$Datework=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Datework=~tr/[ÙÚÛÜùúûü]/u/; ($Dateone, $Datetwo, $Datethree, $Datefour, $Datefive, $Datesix, $Dateseven)=split(/ /, $Datework); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Monthwork=~tr/[ÈÉÊËéêëè]/e/; #$Monthwork=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Monthwork=~tr/[çÇ]/c/; #$Monthwork=~tr/[ìíîïÍÎÏÌ]/i/; #$Monthwork=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Monthwork=~tr/[ÙÚÛÜùúûü]/u/; ($Monthone, $Monthtwo, $Monththree, $Monthfour, $Monthfive, $Monthsix, $Monthseven)=split(/ /, $Monthwork); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Yearwork=~tr/[ÈÉÊËéêëè]/e/; #$Yearwork=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Yearwork=~tr/[çÇ]/c/; #$Yearwork=~tr/[ìíîïÍÎÏÌ]/i/; #$Yearwork=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Yearwork=~tr/[ÙÚÛÜùúûü]/u/; ($Yearone, $Yeartwo, $Yearthree, $Yearfour, $Yearfive, $Yearsix, $Yearseven)=split(/ /, $Yearwork); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Date_Addedwork=~tr/[ÈÉÊËéêëè]/e/; #$Date_Addedwork=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Date_Addedwork=~tr/[çÇ]/c/; #$Date_Addedwork=~tr/[ìíîïÍÎÏÌ]/i/; #$Date_Addedwork=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Date_Addedwork=~tr/[ÙÚÛÜùúûü]/u/; ($Date_Addedone, $Date_Addedtwo, $Date_Addedthree, $Date_Addedfour, $Date_Addedfive, $Date_Addedsix, $Date_Addedseven)=split(/ /, $Date_Addedwork); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Date_Time_Addedwork=~tr/[ÈÉÊËéêëè]/e/; #$Date_Time_Addedwork=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Date_Time_Addedwork=~tr/[çÇ]/c/; #$Date_Time_Addedwork=~tr/[ìíîïÍÎÏÌ]/i/; #$Date_Time_Addedwork=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Date_Time_Addedwork=~tr/[ÙÚÛÜùúûü]/u/; ($Date_Time_Addedone, $Date_Time_Addedtwo, $Date_Time_Addedthree, $Date_Time_Addedfour, $Date_Time_Addedfive, $Date_Time_Addedsix, $Date_Time_Addedseven)=split(/ /, $Date_Time_Addedwork); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Autoincrementwork=~tr/[ÈÉÊËéêëè]/e/; #$Autoincrementwork=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Autoincrementwork=~tr/[çÇ]/c/; #$Autoincrementwork=~tr/[ìíîïÍÎÏÌ]/i/; #$Autoincrementwork=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Autoincrementwork=~tr/[ÙÚÛÜùúûü]/u/; ($Autoincrementone, $Autoincrementtwo, $Autoincrementthree, $Autoincrementfour, $Autoincrementfive, $Autoincrementsix, $Autoincrementseven)=split(/ /, $Autoincrementwork); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Extra1work=~tr/[ÈÉÊËéêëè]/e/; #$Extra1work=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Extra1work=~tr/[çÇ]/c/; #$Extra1work=~tr/[ìíîïÍÎÏÌ]/i/; #$Extra1work=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Extra1work=~tr/[ÙÚÛÜùúûü]/u/; ($Extra1one, $Extra1two, $Extra1three, $Extra1four, $Extra1five, $Extra1six, $Extra1seven)=split(/ /, $Extra1work); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Extra2work=~tr/[ÈÉÊËéêëè]/e/; #$Extra2work=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Extra2work=~tr/[çÇ]/c/; #$Extra2work=~tr/[ìíîïÍÎÏÌ]/i/; #$Extra2work=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Extra2work=~tr/[ÙÚÛÜùúûü]/u/; ($Extra2one, $Extra2two, $Extra2three, $Extra2four, $Extra2five, $Extra2six, $Extra2seven)=split(/ /, $Extra2work); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Extra3work=~tr/[ÈÉÊËéêëè]/e/; #$Extra3work=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Extra3work=~tr/[çÇ]/c/; #$Extra3work=~tr/[ìíîïÍÎÏÌ]/i/; #$Extra3work=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Extra3work=~tr/[ÙÚÛÜùúûü]/u/; ($Extra3one, $Extra3two, $Extra3three, $Extra3four, $Extra3five, $Extra3six, $Extra3seven)=split(/ /, $Extra3work); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Extra4work=~tr/[ÈÉÊËéêëè]/e/; #$Extra4work=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Extra4work=~tr/[çÇ]/c/; #$Extra4work=~tr/[ìíîïÍÎÏÌ]/i/; #$Extra4work=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Extra4work=~tr/[ÙÚÛÜùúûü]/u/; ($Extra4one, $Extra4two, $Extra4three, $Extra4four, $Extra4five, $Extra4six, $Extra4seven)=split(/ /, $Extra4work); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Extra5work=~tr/[ÈÉÊËéêëè]/e/; #$Extra5work=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Extra5work=~tr/[çÇ]/c/; #$Extra5work=~tr/[ìíîïÍÎÏÌ]/i/; #$Extra5work=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Extra5work=~tr/[ÙÚÛÜùúûü]/u/; ($Extra5one, $Extra5two, $Extra5three, $Extra5four, $Extra5five, $Extra5six, $Extra5seven)=split(/ /, $Extra5work); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Extra6work=~tr/[ÈÉÊËéêëè]/e/; #$Extra6work=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Extra6work=~tr/[çÇ]/c/; #$Extra6work=~tr/[ìíîïÍÎÏÌ]/i/; #$Extra6work=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Extra6work=~tr/[ÙÚÛÜùúûü]/u/; ($Extra6one, $Extra6two, $Extra6three, $Extra6four, $Extra6five, $Extra6six, $Extra6seven)=split(/ /, $Extra6work); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Extra7work=~tr/[ÈÉÊËéêëè]/e/; #$Extra7work=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Extra7work=~tr/[çÇ]/c/; #$Extra7work=~tr/[ìíîïÍÎÏÌ]/i/; #$Extra7work=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Extra7work=~tr/[ÙÚÛÜùúûü]/u/; ($Extra7one, $Extra7two, $Extra7three, $Extra7four, $Extra7five, $Extra7six, $Extra7seven)=split(/ /, $Extra7work); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Extra8work=~tr/[ÈÉÊËéêëè]/e/; #$Extra8work=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Extra8work=~tr/[çÇ]/c/; #$Extra8work=~tr/[ìíîïÍÎÏÌ]/i/; #$Extra8work=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Extra8work=~tr/[ÙÚÛÜùúûü]/u/; ($Extra8one, $Extra8two, $Extra8three, $Extra8four, $Extra8five, $Extra8six, $Extra8seven)=split(/ /, $Extra8work); #F4a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$Extra9work=~tr/[ÈÉÊËéêëè]/e/; #$Extra9work=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$Extra9work=~tr/[çÇ]/c/; #$Extra9work=~tr/[ìíîïÍÎÏÌ]/i/; #$Extra9work=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$Extra9work=~tr/[ÙÚÛÜùúûü]/u/; ($Extra9one, $Extra9two, $Extra9three, $Extra9four, $Extra9five, $Extra9six, $Extra9seven)=split(/ /, $Extra9work); #STEP G================================ #Do not modify this section #G1. Open datafile and write contents to an array, if can't open report the problem at the security subroutine $problem="You do not have a file to search on the server. Please ADD test records before trying to search your test data file."; open (FILE, "$data") || &security; @all=; close (FILE); #G2. The line below is required, do not modify print "Content-type: text/html\n\n"; #G3. Display HTML Header print "$templatestart\n"; #G5. Show words user searched for print "Please check our news page regularly for details of what is new at Specialists in Seating.

\n"; #STEP H================================ #H1. Read each line of the data file, compare with search words foreach $line (@all){ $line=~s/\n//g; $loopsaround++; $checkleng=length($line); if ($checkleng<2){next}; $linetemp1=lc($line); #H1a. Support for European characters. Uncomment and replace with your #character set in brackets for all non-English Characters. See help files. #$linetemp1=~tr/[ÈÉÊËéêëè]/e/; #$linetemp1=~tr/[ÀÁÂÃÄÅÆàáâãäåæ]/a/; #$linetemp1=~tr/[çÇ]/c/; #$linetemp1=~tr/[ìíîïÍÎÏÌ]/i/; #$linetemp1=~tr/[ÒÓÔÕÖòóôõöô]/o/; #$linetemp1=~tr/[ÙÚÛÜùúûü]/u/; ($Category,$Title,$Introduction,$Image_Upload_1,$Image_Upload_2,$Article,$Date,$Month,$Year,$Date_Added,$Date_Time_Added,$Autoincrement,$Unix_Timestamp,$Extra1,$Extra2,$Extra3,$Extra4,$Extra5,$Extra6,$Extra7,$Extra8,$Extra9,$skipthisfield)=split (/$delimiter/,$linetemp1); #H9. This line specifies the fields to sort results by #See help databases for patches to allow various kinds of sorts $line="$Year$Month$Date$delimiter$loopsaround$delimiter$line"; #H9.5 This line removes stray leading spaces before sorting your results $line=~s/^ +//; $increcount=0; #H12. Look for matches in field named Category if (($Category =~/\b$Categoryone/ && $Category =~/\b$Categorytwo/ && $Category =~/\b$Categorythree/ && $Category =~/\b$Categoryfour/ && $Category =~/\b$Categoryfive/ && $Category=~/\b$Categorysix/ && $Category=~/\b$Categoryseven/) || !$Categorywork) { $increcount++;} #H12. Look for matches in field named Title if (($Title =~/\b$Titleone/ && $Title =~/\b$Titletwo/ && $Title =~/\b$Titlethree/ && $Title =~/\b$Titlefour/ && $Title =~/\b$Titlefive/ && $Title=~/\b$Titlesix/ && $Title=~/\b$Titleseven/) || !$Titlework) { $increcount++;} #H12. Look for matches in field named Introduction if (($Introduction =~/\b$Introductionone/ && $Introduction =~/\b$Introductiontwo/ && $Introduction =~/\b$Introductionthree/ && $Introduction =~/\b$Introductionfour/ && $Introduction =~/\b$Introductionfive/ && $Introduction=~/\b$Introductionsix/ && $Introduction=~/\b$Introductionseven/) || !$Introductionwork) { $increcount++;} #H12. Look for matches in field named Article if (($Article =~/\b$Articleone/ && $Article =~/\b$Articletwo/ && $Article =~/\b$Articlethree/ && $Article =~/\b$Articlefour/ && $Article =~/\b$Articlefive/ && $Article=~/\b$Articlesix/ && $Article=~/\b$Articleseven/) || !$Articlework) { $increcount++;} #H12. Look for matches in field named Date if (($Date =~/\b$Dateone/ && $Date =~/\b$Datetwo/ && $Date =~/\b$Datethree/ && $Date =~/\b$Datefour/ && $Date =~/\b$Datefive/ && $Date=~/\b$Datesix/ && $Date=~/\b$Dateseven/) || !$Datework) { $increcount++;} #H12. Look for matches in field named Month if (($Month =~/\b$Monthone/ && $Month =~/\b$Monthtwo/ && $Month =~/\b$Monththree/ && $Month =~/\b$Monthfour/ && $Month =~/\b$Monthfive/ && $Month=~/\b$Monthsix/ && $Month=~/\b$Monthseven/) || !$Monthwork) { $increcount++;} #H12. Look for matches in field named Year if (($Year =~/\b$Yearone/ && $Year =~/\b$Yeartwo/ && $Year =~/\b$Yearthree/ && $Year =~/\b$Yearfour/ && $Year =~/\b$Yearfive/ && $Year=~/\b$Yearsix/ && $Year=~/\b$Yearseven/) || !$Yearwork) { $increcount++;} #H12. Look for matches in field named Date_Added if (($Date_Added =~/\b$Date_Addedone/ && $Date_Added =~/\b$Date_Addedtwo/ && $Date_Added =~/\b$Date_Addedthree/ && $Date_Added =~/\b$Date_Addedfour/ && $Date_Added =~/\b$Date_Addedfive/ && $Date_Added=~/\b$Date_Addedsix/ && $Date_Added=~/\b$Date_Addedseven/) || !$Date_Addedwork) { $increcount++;} #H12. Look for matches in field named Date_Time_Added if (($Date_Time_Added =~/\b$Date_Time_Addedone/ && $Date_Time_Added =~/\b$Date_Time_Addedtwo/ && $Date_Time_Added =~/\b$Date_Time_Addedthree/ && $Date_Time_Added =~/\b$Date_Time_Addedfour/ && $Date_Time_Added =~/\b$Date_Time_Addedfive/ && $Date_Time_Added=~/\b$Date_Time_Addedsix/ && $Date_Time_Added=~/\b$Date_Time_Addedseven/) || !$Date_Time_Addedwork) { $increcount++;} #H12. Look for matches in field named Autoincrement if (($Autoincrement =~/\b$Autoincrementone/ && $Autoincrement =~/\b$Autoincrementtwo/ && $Autoincrement =~/\b$Autoincrementthree/ && $Autoincrement =~/\b$Autoincrementfour/ && $Autoincrement =~/\b$Autoincrementfive/ && $Autoincrement=~/\b$Autoincrementsix/ && $Autoincrement=~/\b$Autoincrementseven/) || !$Autoincrementwork) { $increcount++;} #H12. Look for matches in field named Extra1 if (($Extra1 =~/\b$Extra1one/ && $Extra1 =~/\b$Extra1two/ && $Extra1 =~/\b$Extra1three/ && $Extra1 =~/\b$Extra1four/ && $Extra1 =~/\b$Extra1five/ && $Extra1=~/\b$Extra1six/ && $Extra1=~/\b$Extra1seven/) || !$Extra1work) { $increcount++;} #H12. Look for matches in field named Extra2 if (($Extra2 =~/\b$Extra2one/ && $Extra2 =~/\b$Extra2two/ && $Extra2 =~/\b$Extra2three/ && $Extra2 =~/\b$Extra2four/ && $Extra2 =~/\b$Extra2five/ && $Extra2=~/\b$Extra2six/ && $Extra2=~/\b$Extra2seven/) || !$Extra2work) { $increcount++;} #H12. Look for matches in field named Extra3 if (($Extra3 =~/\b$Extra3one/ && $Extra3 =~/\b$Extra3two/ && $Extra3 =~/\b$Extra3three/ && $Extra3 =~/\b$Extra3four/ && $Extra3 =~/\b$Extra3five/ && $Extra3=~/\b$Extra3six/ && $Extra3=~/\b$Extra3seven/) || !$Extra3work) { $increcount++;} #H12. Look for matches in field named Extra4 if (($Extra4 =~/\b$Extra4one/ && $Extra4 =~/\b$Extra4two/ && $Extra4 =~/\b$Extra4three/ && $Extra4 =~/\b$Extra4four/ && $Extra4 =~/\b$Extra4five/ && $Extra4=~/\b$Extra4six/ && $Extra4=~/\b$Extra4seven/) || !$Extra4work) { $increcount++;} #H12. Look for matches in field named Extra5 if (($Extra5 =~/\b$Extra5one/ && $Extra5 =~/\b$Extra5two/ && $Extra5 =~/\b$Extra5three/ && $Extra5 =~/\b$Extra5four/ && $Extra5 =~/\b$Extra5five/ && $Extra5=~/\b$Extra5six/ && $Extra5=~/\b$Extra5seven/) || !$Extra5work) { $increcount++;} #H12. Look for matches in field named Extra6 if (($Extra6 =~/\b$Extra6one/ && $Extra6 =~/\b$Extra6two/ && $Extra6 =~/\b$Extra6three/ && $Extra6 =~/\b$Extra6four/ && $Extra6 =~/\b$Extra6five/ && $Extra6=~/\b$Extra6six/ && $Extra6=~/\b$Extra6seven/) || !$Extra6work) { $increcount++;} #H12. Look for matches in field named Extra7 if (($Extra7 =~/\b$Extra7one/ && $Extra7 =~/\b$Extra7two/ && $Extra7 =~/\b$Extra7three/ && $Extra7 =~/\b$Extra7four/ && $Extra7 =~/\b$Extra7five/ && $Extra7=~/\b$Extra7six/ && $Extra7=~/\b$Extra7seven/) || !$Extra7work) { $increcount++;} #H12. Look for matches in field named Extra8 if (($Extra8 =~/\b$Extra8one/ && $Extra8 =~/\b$Extra8two/ && $Extra8 =~/\b$Extra8three/ && $Extra8 =~/\b$Extra8four/ && $Extra8 =~/\b$Extra8five/ && $Extra8=~/\b$Extra8six/ && $Extra8=~/\b$Extra8seven/) || !$Extra8work) { $increcount++;} #H12. Look for matches in field named Extra9 if (($Extra9 =~/\b$Extra9one/ && $Extra9 =~/\b$Extra9two/ && $Extra9 =~/\b$Extra9three/ && $Extra9 =~/\b$Extra9four/ && $Extra9 =~/\b$Extra9five/ && $Extra9=~/\b$Extra9six/ && $Extra9=~/\b$Extra9seven/) || !$Extra9work) { $increcount++;} if ($line=~/markedtoedit/ && $actiontotake eq "markedtoedit"){ $line=~s/markedtoedit//g; push (@keepers2,$line);} $line=~s/markedtoedit//g; if ($increcount==19){ push (@keepers,$line);}} #STEP J================================ if ($actiontotake eq "markedtoedit"){ @keepers=@keepers2;} #J1. Sort matches stored in array. #@keepers=sort(@keepers); @keepers=reverse(sort(@keepers)); #J2. Get and display number of matches found $length1=@keepers; #J3. If the number of matches is less than enditem, adjust if ($length1<$enditem){ $enditem=$length1; $displaystat="Y";} #J4. The first field about to display $disstart=$startitem+1; #J5. Show user total number of matches found #if ($length1){ #print "There are currently $length1 news stories (displaying $disstart to $enditem)

\n"; #} else { #print "Your search found zero records, please try again.

\n";} #STEP K================================ #K1. Do some HTML formatting before showing results print "\n"; #K4. Keep track of results processed on this page foreach $line (@keepers){ #K5. Delete stray hard returns $line=~s/\n//g; #K6. Keep track of records displayed $countline1++; #K7. Decide whether or not this record goes on this page if ($countline1>$startitem && $countline1<=$enditem){ #K8. Open each line of sorted array for displaying ($sortfield,$loopsaround,$Category,$Title,$Introduction,$Image_Upload_1,$Image_Upload_2,$Article,$Date,$Month,$Year,$Date_Added,$Date_Time_Added,$Autoincrement,$Unix_Timestamp,$Extra1,$Extra2,$Extra3,$Extra4,$Extra5,$Extra6,$Extra7,$Extra8,$Extra9,$skipthisfield)=split (/$delimiter/,$line); #K15. Formatting for field Category. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Category){ #print "\n";} #K15. Formatting for field Title. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements if ($Title){ print "\n";} #K15. Formatting for field Introduction. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements if ($Introduction){ print "\n";} #K15. Formatting for field Image_Upload_1. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Image_Upload_1){ #print "\n";} #K15. Formatting for field Image_Upload_2. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Image_Upload_2){ #print "\n";} #K15. Formatting for field Article. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Article){ #print "\n";} #K15. Formatting for field Date. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Date){ #print "\n";} #K15. Formatting for field Month. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Month){ #print "\n";} #K15. Formatting for field Year. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Year){ #print "\n";} #K15. Formatting for field Date_Added. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Date_Added){ #print "\n";} #K15. Formatting for field Date_Time_Added. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Date_Time_Added){ #print "\n";} #K15. Formatting for field Autoincrement. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Autoincrement){ #print "\n";} #K15. Formatting for field Unix_Timestamp. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Unix_Timestamp){ #print "\n";} #K15. Formatting for field Extra1. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Extra1){ #print "\n";} #K15. Formatting for field Extra2. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Extra2){ #print "\n";} #K15. Formatting for field Extra3. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Extra3){ #print "\n";} #K15. Formatting for field Extra4. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Extra4){ #print "\n";} #K15. Formatting for field Extra5. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Extra5){ #print "\n";} #K15. Formatting for field Extra6. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Extra6){ #print "\n";} #K15. Formatting for field Extra7. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Extra7){ #print "\n";} #K15. Formatting for field Extra8. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Extra8){ #print "\n";} #K15. Formatting for field Extra9. If you add any HTML, make sure you #put a backslash in front of all quote marks inside print statements #if ($Extra9){ #print "\n";} #K11. Check passwords before showing edit and delete buttons if ($adminpassword eq $checkpassword){ print "\n";} print "\n"; #print "\n"; #STEP L================================ #L1. If total displayed equals maximum you set, then exit if ($countline1 == $maximum && $maximum){ $problem2="Your search was terminated at $maximum records, please be more specific in your search"; last;} #L2. If script just got to last match then exit program if ($length1 == $countline1){ last;} #L3. If script is at the end of a page then show NEXT button if ($countline1 == $enditem && $displaystat ne "Y" && $maximum>$countline1){ $stopit="Y"; last; } }} print "
Category:$Category
$Title
$Introduction
Image Upload 1:$Image_Upload_1
Image Upload 2:$Image_Upload_2
Article:$Article
Date:$Date
Month:$Month
Year:$Year
 Date Added: $Date/$Month/$Year
Date Time Added:$Date_Time_Added
Autoincrement:$Autoincrement
Unix Timestamp:$Unix_Timestamp
Extra1:$Extra1
Extra2:$Extra2
Extra3:$Extra3
Extra4:$Extra4
Extra5:$Extra5
Extra6:$Extra6
Extra7:$Extra7
Extra8:$Extra8
Extra9:$Extra9

  
\n"; #L4. Display NEXT MATCHES button if ($stopit eq "Y"){ print "

\n"; #L5. Pass hidden variables so script will know how to display next page print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; } #L6. Show problems print "

$problem2\n"; #L8. If opening.htm was found, show its closing html codes print "$templateend\n"; exit; #STEP M================================ sub security{ #M1. This is the subroutine that reports all problems print "Content-type: text/html\n\n"; print "$templatestart\n"; print "

Data Error

\n"; print "Please correct the following error:

$problem
\n"; print "$templateend\n"; exit; } #STEP N================================ sub edit{ #N1. Open data file and read it $problem="Can't open data file to read from it at edit subroutine"; open (FILE,"$data") || &security; @all=; close (FILE); #N2. Read each line of the data file foreach $line (@all){ $line=~s/\n//g; ($copyCategory,$copyTitle,$copyIntroduction,$copyImage_Upload_1,$copyImage_Upload_2,$copyArticle,$copyDate,$copyMonth,$copyYear,$copyDate_Added,$copyDate_Time_Added,$copyAutoincrement,$copyUnix_Timestamp,$copyExtra1,$copyExtra2,$copyExtra3,$copyExtra4,$copyExtra5,$copyExtra6,$copyExtra7,$copyExtra8,$copyExtra9,$skipthisfield)=split (/$delimiter/,$line); $keepcount++; #N3. Find the line user wants to modify if ($keepcount==$linenumberpass){ $linetokeep=$line; $linetokeep=~s/markedtoedit//g; last; } } #N4. Check password sent via hidden field if ($adminpassword ne $checkpassword){ $problem="Your password does not match the master password and appears to have been changed since logging onto this record."; &security;} #N6. Split matching line into its respective variables ($Category,$Title,$Introduction,$Image_Upload_1,$Image_Upload_2,$Article,$Date,$Month,$Year,$Date_Added,$Date_Time_Added,$Autoincrement,$Unix_Timestamp,$Extra1,$Extra2,$Extra3,$Extra4,$Extra5,$Extra6,$Extra7,$Extra8,$Extra9,$skipthisfield)=split (/$delimiter/,$linetokeep); #Required Header, do not delete print "Content-type: text/html\n\n"; #N8. If can't find opening html, display default header print "$templatestart\n"; print "

Edit this Record

\n"; if ($allowimageuploadonedit || $allowtextuploadonedit){ $allowupload="ENCTYPE=\"multipart/form-data\""; $filetext="FILE";} else{ $filetext="TEXT";} print "

\n"; #print "\n"; print "\n"; print "\n"; $showdelete=""; #if ($Image_Upload_1){ #$showdelete="
Type Delete above to remove this image, leave completely blank to keep the current image."; #} print "\n"; if ($Image_Upload_1){ print "\n"; } $Article=~s/
/\n/g; $Article=~s/
/\n/g; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; #N10. Pass values to next screen print "
Category:
Title:
Introduction:
Image Upload 1:$showdelete
Image Upload 1
Default Value
$Image_Upload_1 Check here to delete
Article:
Date:
Month:
Year:
Date Time Added:$Date_Time_Added
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "

\n"; print "$templateend\n"; exit; } #STEP O================================ sub delete{ #O1. Open data file and read it $problem="Can't open data file to read from it at delete subroutine"; open (FILE,"$data") || &security; @all=; close (FILE); #O2. Read each line of the file foreach $line (@all){ $line=~s/\n//g; ($copyCategory,$copyTitle,$copyIntroduction,$copyImage_Upload_1,$copyImage_Upload_2,$copyArticle,$copyDate,$copyMonth,$copyYear,$copyDate_Added,$copyDate_Time_Added,$copyAutoincrement,$copyUnix_Timestamp,$copyExtra1,$copyExtra2,$copyExtra3,$copyExtra4,$copyExtra5,$copyExtra6,$copyExtra7,$copyExtra8,$copyExtra9,$skipthisfield)=split (/$delimiter/,$line); $keepcount++; #O3. Find line to delete if ($keepcount==$linenumberpass){ $linetokeep=$line; $linetokeep=~s/markedtoedit//g; last; } } ($Category,$Title,$Introduction,$Image_Upload_1,$Image_Upload_2,$Article,$Date,$Month,$Year,$Date_Added,$Date_Time_Added,$Autoincrement,$Unix_Timestamp,$Extra1,$Extra2,$Extra3,$Extra4,$Extra5,$Extra6,$Extra7,$Extra8,$Extra9,$skipthisfield)=split (/$delimiter/,$linetokeep); #O4. Check password sent via hidden field if ($adminpassword ne $checkpassword){ $problem="Your password does not match the master password."; &security;} #O6. Requred Header, do not delete print "Content-type: text/html\n\n"; print "$templatestart\n"; print "

Delete this Record?

\n"; ($Category,$Title,$Introduction,$Image_Upload_1,$Image_Upload_2,$Article,$Date,$Month,$Year,$Date_Added,$Date_Time_Added,$Autoincrement,$Unix_Timestamp,$Extra1,$Extra2,$Extra3,$Extra4,$Extra5,$Extra6,$Extra7,$Extra8,$Extra9,$skipthisfield)=split (/$delimiter/,$linetokeep); #O7. Show validation HTML print "

\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if ($deleteonimagerecorddelete=~/y/i && $Image_Upload_1){ print "\n";} print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
Category: $Category
Title: $Title
Introduction: $Introduction
Image_Upload_1: $Image_Upload_1
Article: $Article
Date: $Date
Month: $Month
Year: $Year
Date_Time_Added: $Date_Time_Added

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

\n"; #If opening.htm was not found, show default closing html codes print "$templateend\n"; exit; } #STEP P================================ sub makechange{ #P1. For each variable, translate it, remove any delimiters that #user may have accidentally included, replace hard returns with #HTML line breaks, and delete all carriage returns #Go to get variable subroutine and make sure add preferences apply if ($recordaction eq "Edited"){ &getvariables;} #P2. This step either replaces or empties the existing line if ($recordaction eq "Deleted"){ $Image_Upload_1=$query->param('Image_Upload_1'); if ($Image_Upload_1 && $deleteonimagerecorddelete=~/y/i){ unlink("$Imageuploadpath$Image_Upload_1");} $Image_Upload_2=$query->param('Image_Upload_2'); if ($Image_Upload_2 && $deleteonimagerecorddelete=~/y/i){ unlink("$Imageuploadpath$Image_Upload_2");} $replacementline="";} else{ $replacementline="$Category$delimiter$Title$delimiter$Introduction$delimiter$Image_Upload_1$delimiter$Image_Upload_2$delimiter$Article$delimiter$Date$delimiter$Month$delimiter$Year$delimiter$Date_Added$delimiter$Date_Time_Added$delimiter$Autoincrement$delimiter$Unix_Timestamp$delimiter$Extra1$delimiter$Extra2$delimiter$Extra3$delimiter$Extra4$delimiter$Extra5$delimiter$Extra6$delimiter$Extra7$delimiter$Extra8$delimiter$Extra9";} $problem="Can't open data file to read from it"; open (FILE,"$data") || &security; @all=; close (FILE); $linenumberpass--; $all[$linenumberpass]=$replacementline; $problem="Can't open temporary file. You need to chmod 777 the directory your data file is in. See the help files under Permissions for Class B Scripts."; #P6. Write the entire changed file to a temporary file open (FILE2,">$data.tmp") || &security; foreach $line (@all){ $line=~s/\n//g; print FILE2 "$line\n";} close(FILE2); #P7. Rename the temp file to your master data file $problem="Can't rename file after making change"; rename("$data.tmp", "$data") || &security; print "Content-type: text/html\n\n"; #P8. If can't find opening html, display default header print "$templatestart\n"; print "Your record has been $recordaction. Please click here to continue.\n"; close (FILE); #If opening.htm was not found, show default closing html codes print "$templateend\n"; exit; } #STEP Q================================ #This subroutine adds records to your database sub addrecord{ #Q1. Check password if ($adminpassword ne $checkpassword && $adminpassword){ $problem="The password you entered does not match your administration password. Please press BACK on your browser to fix this problem."; &security;} &getvariables; $replacementline="$Category$delimiter$Title$delimiter$Introduction$delimiter$Image_Upload_1$delimiter$Image_Upload_2$delimiter$Article$delimiter$Date$delimiter$Month$delimiter$Year$delimiter$Date_Added$delimiter$Date_Time_Added$delimiter$Autoincrement$delimiter$Unix_Timestamp$delimiter$Extra1$delimiter$Extra2$delimiter$Extra3$delimiter$Extra4$delimiter$Extra5$delimiter$Extra6$delimiter$Extra7$delimiter$Extra8$delimiter$Extra9"; #Q3. Write the new record to the bottom of the data file $problem="Can't write to the data file. Please verify its location and change its permissions to 777."; open (FILE2,">>$data") || &security; print FILE2 "$replacementline\n"; close(FILE2); print "Content-type: text/html\n\n"; #Q4. If can't find opening html, display default header print "$templatestart\n"; print "Your record has been added. Please click here to continue.\n"; #If opening.htm was not found, show default closing html codes print "$templateend\n"; exit; } #STEP R================================ sub getvariables{ #R1. This step checks your variables before adding/editing them $Category=$query->param('Category'); $Title=$query->param('Title'); $Introduction=$query->param('Introduction'); $Image_Upload_1=$query->param('Image_Upload_1'); $Image_Upload_2=$query->param('Image_Upload_2'); $Article=$query->param('Article'); $Date=$query->param('Date'); $Month=$query->param('Month'); $Year=$query->param('Year'); $Date_Added=$query->param('Date_Added'); $Date_Time_Added=$query->param('Date_Time_Added'); $Autoincrement=$query->param('Autoincrement'); $Unix_Timestamp=$query->param('Unix_Timestamp'); $Extra1=$query->param('Extra1'); $Extra2=$query->param('Extra2'); $Extra3=$query->param('Extra3'); $Extra4=$query->param('Extra4'); $Extra5=$query->param('Extra5'); $Extra6=$query->param('Extra6'); $Extra7=$query->param('Extra7'); $Extra8=$query->param('Extra8'); $Extra9=$query->param('Extra9'); #R3. Replace hard returns with
, cut carriage returns $Category=~s/\n/
/g; $Category=~s/\r//g; if ($Category eq "Select"){ $Category="";} #R3. Replace hard returns with
, cut carriage returns $Title=~s/\n/
/g; $Title=~s/\r//g; if ($Title eq "Select"){ $Title="";} #R3. Replace hard returns with
, cut carriage returns $Introduction=~s/\n/
/g; $Introduction=~s/\r//g; if ($Introduction eq "Select"){ $Introduction="";} #R3. Replace hard returns with
, cut carriage returns $Image_Upload_1=~s/\n/
/g; $Image_Upload_1=~s/\r//g; if ($Image_Upload_1 eq "Select"){ $Image_Upload_1="";} #R3. Replace hard returns with
, cut carriage returns $Image_Upload_2=~s/\n/
/g; $Image_Upload_2=~s/\r//g; if ($Image_Upload_2 eq "Select"){ $Image_Upload_2="";} #R3. Replace hard returns with
, cut carriage returns $Article=~s/\n/
/g; $Article=~s/\r//g; if ($Article eq "Select"){ $Article="";} #R3. Replace hard returns with
, cut carriage returns $Date=~s/\n/
/g; $Date=~s/\r//g; if ($Date eq "Select"){ $Date="";} #R3. Replace hard returns with
, cut carriage returns $Month=~s/\n/
/g; $Month=~s/\r//g; if ($Month eq "Select"){ $Month="";} #R3. Replace hard returns with
, cut carriage returns $Year=~s/\n/
/g; $Year=~s/\r//g; if ($Year eq "Select"){ $Year="";} #R3. Replace hard returns with
, cut carriage returns $Date_Added=~s/\n/
/g; $Date_Added=~s/\r//g; if ($Date_Added eq "Select"){ $Date_Added="";} #R3. Replace hard returns with
, cut carriage returns $Date_Time_Added=~s/\n/
/g; $Date_Time_Added=~s/\r//g; if ($Date_Time_Added eq "Select"){ $Date_Time_Added="";} #R3. Replace hard returns with
, cut carriage returns $Autoincrement=~s/\n/
/g; $Autoincrement=~s/\r//g; if ($Autoincrement eq "Select"){ $Autoincrement="";} #R3. Replace hard returns with
, cut carriage returns $Unix_Timestamp=~s/\n/
/g; $Unix_Timestamp=~s/\r//g; if ($Unix_Timestamp eq "Select"){ $Unix_Timestamp="";} #R3. Replace hard returns with
, cut carriage returns $Extra1=~s/\n/
/g; $Extra1=~s/\r//g; if ($Extra1 eq "Select"){ $Extra1="";} #R3. Replace hard returns with
, cut carriage returns $Extra2=~s/\n/
/g; $Extra2=~s/\r//g; if ($Extra2 eq "Select"){ $Extra2="";} #R3. Replace hard returns with
, cut carriage returns $Extra3=~s/\n/
/g; $Extra3=~s/\r//g; if ($Extra3 eq "Select"){ $Extra3="";} #R3. Replace hard returns with
, cut carriage returns $Extra4=~s/\n/
/g; $Extra4=~s/\r//g; if ($Extra4 eq "Select"){ $Extra4="";} #R3. Replace hard returns with
, cut carriage returns $Extra5=~s/\n/
/g; $Extra5=~s/\r//g; if ($Extra5 eq "Select"){ $Extra5="";} #R3. Replace hard returns with
, cut carriage returns $Extra6=~s/\n/
/g; $Extra6=~s/\r//g; if ($Extra6 eq "Select"){ $Extra6="";} #R3. Replace hard returns with
, cut carriage returns $Extra7=~s/\n/
/g; $Extra7=~s/\r//g; if ($Extra7 eq "Select"){ $Extra7="";} #R3. Replace hard returns with
, cut carriage returns $Extra8=~s/\n/
/g; $Extra8=~s/\r//g; if ($Extra8 eq "Select"){ $Extra8="";} #R3. Replace hard returns with
, cut carriage returns $Extra9=~s/\n/
/g; $Extra9=~s/\r//g; if ($Extra9 eq "Select"){ $Extra9="";} if (($Image_Upload_1=~/\\/ || $Image_Upload_1=~/\:/) && $Image_Upload_1 !~/delete/i){ $containsimageImage_Upload_1=1; #Get Unix time. Will constitute file name if (!$tstamp){ $tstamp=time;} else{ $tstamp++;} @splitparts=split(/\./,$Image_Upload_1); $parts=@splitparts; $parts--; $extension=lc($splitparts[$parts]); if ($extension!~/gif|jpg|jpeg/i){ $problem="You are attempting to upload a file with an incorrect extension .$splitparts[$parts]. For security reasons, only image files .gif, .jpg, or .jpeg extensions can be uploaded."; &security; } if ($Image_Upload_1=~/\.cgi|\.pl|\.exe/i){ $problem="You are attempting to upload a file that could be hazardous to the server. Please make sure that you upload only files with .gif, .jpg, or .jpeg extensions. .pl or .cgi can't make up any part of the filename you are uploading."; &security; } $Imagemaximum=$Imagemaxz*1024; $size=-1024; $problem="Can't write the image to the directory . Make sure that you have set the permissions for this directory so that it is writeable and that you have specified a valid directory path."; open (OUTFILE,">$Imageuploadpath$tstamp.$extension") || &security; while ($bytesread=read($Image_Upload_1,$buffer,1024)) { $size=$size+1024; if ($size>$Imagemaximum){ $problem="You are attempting to upload a file that is too large. Please decrease the size of the image and try again."; close(OUTFILE); unlink("$Imageuploadpath$tstamp.$extension"); &security; } #On Windows servers, uncomment the following line #binmode(OUTFILE); print OUTFILE $buffer;} close(OUTFILE); $Image_Upload_1checksize=-s "$Imageuploadpath$tstamp.$extension"; if ($Image_Upload_1checksize<5){ $problem="Unable to upload the image in field $Image_Upload_1. Your server configuration may not be compatible with this feature or your browser was not able to find the file that you pointed it to."; $imageerror=1; } if ($imageerror){ unlink("$Imageuploadpath$tstamp.$extension"); &security;} $Image_Upload_1="$tstamp.$extension"; } $Image_Upload_1delete=$query->param('Image_Upload_1b'); if (!$Image_Upload_1 && $Image_Upload_1delete){ unlink("$Imageuploadpath$Image_Upload_1delete"); } elsif (!$containsimageImage_Upload_1 && $actiontotake=~/edit/i){ $Image_Upload_1=$query->param('Image_Upload_1bb');} if (($Image_Upload_2=~/\\/ || $Image_Upload_2=~/\:/) && $Image_Upload_2 !~/delete/i){ $containsimageImage_Upload_2=1; #Get Unix time. Will constitute file name if (!$tstamp){ $tstamp=time;} else{ $tstamp++;} @splitparts=split(/\./,$Image_Upload_2); $parts=@splitparts; $parts--; $extension=lc($splitparts[$parts]); if ($extension!~/gif|jpg|jpeg/i){ $problem="You are attempting to upload a file with an incorrect extension .$splitparts[$parts]. For security reasons, only image files .gif, .jpg, or .jpeg extensions can be uploaded."; &security; } if ($Image_Upload_2=~/\.cgi|\.pl|\.exe/i){ $problem="You are attempting to upload a file that could be hazardous to the server. Please make sure that you upload only files with .gif, .jpg, or .jpeg extensions. .pl or .cgi can't make up any part of the filename you are uploading."; &security; } $Imagemaximum=$Imagemaxz*1024; $size=-1024; $problem="Can't write the image to the directory . Make sure that you have set the permissions for this directory so that it is writeable and that you have specified a valid directory path."; open (OUTFILE,">$Imageuploadpath$tstamp.$extension") || &security; while ($bytesread=read($Image_Upload_2,$buffer,1024)) { $size=$size+1024; if ($size>$Imagemaximum){ $problem="You are attempting to upload a file that is too large. Please decrease the size of the image and try again."; close(OUTFILE); unlink("$Imageuploadpath$tstamp.$extension"); &security; } #On Windows servers, uncomment the following line #binmode(OUTFILE); print OUTFILE $buffer;} close(OUTFILE); $Image_Upload_2checksize=-s "$Imageuploadpath$tstamp.$extension"; if ($Image_Upload_2checksize<5){ $problem="Unable to upload the image in field $Image_Upload_2. Your server configuration may not be compatible with this feature or your browser was not able to find the file that you pointed it to."; $imageerror=1; } if ($imageerror){ unlink("$Imageuploadpath$tstamp.$extension"); &security;} $Image_Upload_2="$tstamp.$extension"; } $Image_Upload_2delete=$query->param('Image_Upload_2b'); if (!$Image_Upload_2 && $Image_Upload_2delete){ unlink("$Imageuploadpath$Image_Upload_2delete"); } elsif (!$containsimageImage_Upload_2 && $actiontotake=~/edit/i){ $Image_Upload_2=$query->param('Image_Upload_2bb');} if ($actiontotake!~/edit/i || !$Date_Added){ #Formatting for Unix Date Added Stamp ($secstamp,$minstamp,$hourstamp,$mdaystamp,$monthstamp,$yearstamp,$wdaystamp,$dayofyearstamp,$isdst1stamp) = localtime(time); $monthstamp++; $yearstamp=1900+$yearstamp; if (length($monthstamp)==1){ $monthstamp="0$monthstamp";} if (length($mdaystamp)==1){ $mdaystamp="0$mdaystamp";} $Date_Added="$mdaystamp/$monthstamp/$yearstamp";} if ($actiontotake!~/edit/i || !$Date_Time_Added){ #Formatting for Unix Date and Time Added Stamp ($secstamp,$minstamp,$hourstamp,$mdaystamp,$monthstamp,$yearstamp,$wdaystamp,$dayofyearstamp,$isdst1stamp) = localtime(time); $monthstamp++; $yearstamp=1900+$yearstamp; if (length($monthstamp)==1){ $monthstamp="0$monthstamp";} if (length($mdaystamp)==1){ $mdaystamp="0$mdaystamp";} if (length($minstamp)==1){ $minstamp="0$minstamp";} if (length($hourstamp)==1){ $hourstamp="0$hourstamp";} if (length($secstamp)==1){ $secstamp="0$secstamp";} $Date_Time_Added="$mdaystamp/$monthstamp/$yearstamp $hourstamp:$minstamp:$secstamp";} if ($actiontotake!~/edit/i || !$Autoincrement){ $count=0; $problem="Unable to open or create the counter file at $counterfile, please check the path to the file."; open (COUNTER, "$counterfile") || open (COUNTER, ">>$counterfile") || &security; $count=; close(COUNTER); if ($count=~ /\n$/) { chop($count); } $count++; $problem="Unable to write to counter file at $counterfile. Please check the path to the file and make sure that it is chmod 766 or 777."; open (COUNTER,">$counterfile") || &error; print COUNTER "$count"; close (COUNTER); #Make all numbers six digit for proper sorting if (length($count)==1){ $Autoincrement="00000$count";} if (length($count)==2){ $Autoincrement="0000$count";} if (length($count)==3){ $Autoincrement="000$count";} if (length($count)==4){ $Autoincrement="00$count";} if (length($count)==5){ $Autoincrement="0$count";} } if ((!$Unix_Timestamp) || ($timestampupdate=~/yes/i && $actiontotake eq "Edit Record")){ #Formatting for Unix Timestamp $Unix_Timestamp=time; if (length($Unix_Timestamp)==9){ $Unix_Timestamp="0$Unix_Timestamp";}} } #STEP S================================ sub addtemp{ #S1. This subroutine adds records to your temporary file for approval #S2. Check variable sent &getvariables; #S3. Randomize in preparation for random generator srand(); #S4. Get IP address of person posting record $ipstamp=$ENV{'REMOTE_ADDR'}; #S5. Generate a large random number to serve as key $randnumb=int(rand(9999999)); $replacementline="$ipstamp&&temp$randnumb(\+\+)$Category$delimiter$Title$delimiter$Introduction$delimiter$Image_Upload_1$delimiter$Image_Upload_2$delimiter$Article$delimiter$Date$delimiter$Month$delimiter$Year$delimiter$Date_Added$delimiter$Date_Time_Added$delimiter$Autoincrement$delimiter$Unix_Timestamp$delimiter$Extra1$delimiter$Extra2$delimiter$Extra3$delimiter$Extra4$delimiter$Extra5$delimiter$Extra6$delimiter$Extra7$delimiter$Extra8$delimiter$Extra9"; #S6. Write the temp record to the bottom of the $problem="Can't write to the data file. Please verify its location and change its permissions to 777."; open (FILE2,">>$tempdata") || &security; print FILE2 "$replacementline\n"; close(FILE2); print "Content-type: text/html\n\n"; print "$templatestart\n"; #S7. Acknowledge that record has been posted print "Your record has been sent for evaluation. Please click here to continue.\n"; print "$templateend\n"; exit; } #STEP T================================ sub scrolltemp{ #T1. This step is your interface with the temp file #T2. Check password if ($adminpassword ne $checkpassword && $adminpassword){ $problem="The password you entered does not match your administration password. Please press BACK on your browser to fix this problem."; &security;} #T3. Check to make sure that the data file can be opened. $problem="Unable to open your temporary data file. It either contains no records, or the path to it is incorrect."; open (FILE, "$tempdata") || &security; @all=; close (FILE); print "Content-type: text/html\n\n"; #T4. Start showing contents of data file print "$templatestart\n"; print "

\n"; $checktemp=@all; if (!$checktemp){ print "Your temporary file contains no records for you to evaluate at this time. Please click here to continue.

\n"; print "$templateend\n"; exit;} print "KEY
A=Add to Database
D=Delete from Temp File
E=Add to Database but Mark for Editing
H=Hold in Temp File for Decision Later

\n"; print "\n"; print "\n"; foreach $line (@all){ $line=~s/\n//g; $checkleng=length($line); if ($checkleng<2){next}; ($indexvalues,$stringvalues)=split(/\(\+\+\)/,$line); ($ipaddress,$uniqueapproval)=split(/&&/,$indexvalues); ($Category,$Title,$Introduction,$Image_Upload_1,$Image_Upload_2,$Article,$Date,$Month,$Year,$Date_Added,$Date_Time_Added,$Autoincrement,$Unix_Timestamp,$Extra1,$Extra2,$Extra3,$Extra4,$Extra5,$Extra6,$Extra7,$Extra8,$Extra9,$skipthisfield)=split (/$delimiter/,$stringvalues); print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; $keeptrack2++; if ($keeptrack2>10){ last}; } print "
ADEHFieldContents
IP Address:$ipaddress
    Category:$Category
    Title:$Title
    Introduction:$Introduction
    Image Upload 1:$Image_Upload_1
    Image Upload 2:$Image_Upload_2
    Article:$Article
    Date:$Date
    Month:$Month
    Year:$Year
    Date Added:$Date_Added
    Date Time Added:$Date_Time_Added
    Autoincrement:$Autoincrement
    Unix Timestamp:$Unix_Timestamp
    Extra1:$Extra1
    Extra2:$Extra2
    Extra3:$Extra3
    Extra4:$Extra4
    Extra5:$Extra5
    Extra6:$Extra6
    Extra7:$Extra7
    Extra8:$Extra8
    Extra9:$Extra9
\n"; if ($keeptrack2>=10){ print "

\n";} else{ print "\n";} print "$templateend\n"; exit; } #STEP U================================ sub updatetemp{ #U1. This step makes changes from temp file #U2. Check password if ($adminpassword ne $checkpassword && $adminpassword){ $problem="The password you entered does not match your administration password. Please press BACK on your browser to fix this problem."; &security;} $problem="Unable to open your temporary data file. It either contains no records, or the path to it is incorrect."; open (FILE, "$tempdata") || &security; @all=; close (FILE); foreach $line (@all){ $line=~s/\n//g; $checkleng=length($line); if ($checkleng<2){next}; ($indexvalues,$stringvalues)=split(/\(\+\+\)/,$line); ($ipaddress,$uniqueapproval)=split(/&&/,$indexvalues); ($Category,$Title,$Introduction,$Image_Upload_1,$Image_Upload_2,$Article,$Date,$Month,$Year,$Date_Added,$Date_Time_Added,$Autoincrement,$Unix_Timestamp,$Extra1,$Extra2,$Extra3,$Extra4,$Extra5,$Extra6,$Extra7,$Extra8,$Extra9,$skipthisfield)=split (/$delimiter/,$stringvalues); if ($tempapprove{$uniqueapproval} eq "A"){ push(@recordstoadd,$stringvalues);} elsif ($tempapprove{$uniqueapproval} eq "D"){ push(@recordstodelete,$stringvalues);} elsif ($tempapprove{$uniqueapproval} eq "E"){ push(@recordstoedit,$stringvalues);} else { push(@recordstohold,$line);} } $problem="Unable to open data file to add records. Check path to it and its permissions."; open (FILE, ">>$data") || &security; foreach $line (@recordstoadd){ $line=~s/\n//g; print FILE "$line\n";} close(FILE); $problem="Unable to open data file to records to edit. Check path to it and its permissions."; open (FILE, ">>$data") || &security; foreach $line (@recordstoedit){ $line=~s/\n//g; print FILE "markedtoedit$line\n";} close(FILE); $problem="Unable to open temporary file to refresh data. Check path to it and its permissions."; open (FILE, ">$tempdata") || &security; foreach $line (@recordstohold){ $line=~s/\n//g; print FILE "$line\n";} close(FILE); $checkhold=@recordstohold; if ($checkhold){ &scrolltemp;} print "Content-type: text/html\n\n"; print "$templatestart\n"; print "

Your actions have been taken. Please click here to continue.

\n"; print "$templateend\n"; exit; } #This is the last line of the script