#!/usr/bin/perl use strict; =pod ---------------------------------------------------------------------------------------------------------------------------- These are the parameters in use in this script: c = catalogue key (ie. storekey) p = page number to display (or rather, "from product number", based upon 15 products per page) s = search terms sc= sub-category level (Can only be 1, 2 or 3, relating to fields SUBCAT1/2/3) ??? (related to old MC stuff?) obsolete? scn = sub-category name tc = top category (ie. our categories) ---------------------------------------------------------------------------------------------------------------------------- =cut use lib qw(/var/www/sites/ubuyne/cgi-perl/modules/); use PW2_Search; # Our main search package use PW2_Functions; # Variety of functions (PW_Functions.pm) use PW2_PrintBits; # Various Print functions, and HTML bits &main_process; exit; # -------------------------------------------------------------------------------------------------------------------------- sub main_process { undef my %FORM; &process_form_any2(\%FORM); my $catkey =$FORM{'c'}; # The store/catalogue to be searched (ie. the storekey) my $terms =$FORM{'s'}; # The search term my $page =$FORM{'p'}; # The page number to display my $subcat =$FORM{'scn'}; # The category name my $maxprice =$FORM{'mp'}; # Maximum price my $shorty =$FORM{'shorty'}; # Determines if the search comes from a shortened url, such as https://price-wizard.com/@Timberland $subcat=~s/&:/&/g; # Need to do this because the form cleaning routine will switch semi-colons for colons if ($maxprice gt '') { if ($maxprice=~m/([^0-9.])/g) { $maxprice=substr($maxprice,0,index($maxprice,$1)); # Ignore anything after first non-digit or point, if not a number } my $fp=(index($maxprice,'.')); if ($fp>0) { $maxprice=substr($maxprice,0,$fp+2); # We only want a max of two digits after the decimal place } } $catkey =~tr/a-zA-Z0-9//cd; # remove all non-letters and non-numbers $catkey =~tr/a-z/A-Z/; # uppercase it &numbers_only(\$page); # remove all non-numbers &numbers_only(\$maxprice, \'F'); # remove all non-numbers, except the decimal place if ($page>=1000000){$page=100000}; # If we ever get more than a million products we'll need to amend this line, but for # now it will suffice in preventing abuse and attempted overflows etc if ($maxprice>1000){$maxprice=1000}; # Should only be up to 1000 if (length($terms)>100){$terms=substr($terms,0,100)}; # Max length of 100 characters $terms=~s/\s+/ /g; # Remove all double spaces my $original_terms = $terms; # the un-adulterated search terms, as entered (other than the couple of checks above) my $content_ref =''; my $catname =''; my $storename =''; my $subtitle =''; if (length($catkey)!=4){$catkey=''}; if (lc($catkey)eq'none'){$catkey=''}; &get_results(\$content_ref,\$storename,\$subtitle,\$catkey,\$terms,\$page,\$subcat); if ($shorty==1){ $content_ref=~s//$original_terms/; } else{ $content_ref=~s///; }; &print_myheader(); # Print the content/type header my $title = ''; my $metadesc=''; my $metabits =($original_terms gt'')?' for '.ucfirst($original_terms):''; if ($subtitle gt''){ $title=join('',$subtitle,' - Product Search Results',$metabits,' from ',$storename); $metadesc=join('',$subtitle,'. Product search results',$metabits,' from ',$subtitle,' at Price-Wizard.'); } elsif ($original_terms gt''){ $title=join('',ucfirst($original_terms), ' at Price-Wizard.com - Product Search Results for ',ucfirst($original_terms)); $metadesc=join('',ucfirst($original_terms),' - Product search results',$metabits,' at Price-Wizard. Find other ',ucfirst($original_terms),' products.'); } else{ $title='Price-Wizard.com Search Results - Search for Thousands of Quality Products at Price-Wizard'; } my $bannerkey=$catkey; # We can also display a particular store's banner for given search terms (e.g. display cadb banner if "chocolates" searched for) if ($bannerkey eq''){&check_special_terms(\$bannerkey,\$terms);}; # If we have no particular store we're searching, then check for special terms &html_top_of_page(-title=>\$title,-catkey=>\$catkey,-terms=>\$original_terms,-maxprice=>\$maxprice,-bannerkey=>\$bannerkey,-metadesc=>\$metadesc); print '
'; print $content_ref if (defined $content_ref); # Avoid errors by using the "defined" check print '
'; &print_footer(\0); # Print the copyright message and bar }1; # -------------------------------------------------------------------------------------------------------------------------- sub check_special_terms{ my $bannerkey =shift; # Reference my $terms =shift; # " if (lc($$terms)=~/chocolates/){$$bannerkey='cadb';return;}; }1; # --------------------------------------------------------------------------------------------------------------------------