Resources Directory of FREE hosting - CGI Tutorial - HTML Tutorial Check out sites using our scripts
Scripts Home - Listing - Demos - Discussions - Download - FAQ - User Policy
Links
Add Link - Step 1

Choose the Main Category for the link you wish to add

#!/usr/bin/perl print "Content-type: text/html"."\n\n"; ###################################### # # # ReadCSVPlus v1.0 # # Copyright 2000 by Mutasem Abudahab # # mutasem@abudahab.com # # http://ezscripting.com # # # # Last modified on July 23, 2000 # # # ###################################### # # Copyright Notice: # Copyright 2000 Mutasem R. Abudahab. All Rights Reserved. # # This code may be used and modified by anyone so long as this header and # copyright information remains intact. By using this code you agree to # indemnify Mutasem R. Abudahab from any liability that might arise from its # use. You must obtain written consent before selling or redistributing # this code. #------------------- Start working on the script --------------------# # Replace "data.csv" with the full path to your csv database file $csv_file_path="../data/category.csv"; # Replace "template.html" with the full path to your HTML template. $html_template_path="../includes/drop_category.html"; # Replace "http://www.domain.com/images/new.gif" with the URL to the graphic # image that will be displayed next to a record, when ReadCSVPlus marks it as # new $new_image_file="../images/new.gif"; # Replace this value with the number of days related to <<#local_date>> after # which the script will stop displaying the 'new' image graphic. $new_compare_dat="1"; # Replace this value with the number of random records the script will display # when you query for a random display (display=random). $num_random=1; # Replace this value with the message the script will display, when it finds # no matches to a query $no_matches_found="sorry, no category found"; #-------------- DO NOT CHANGE ANYTHING UNDER THIS LINE --------------# $nv=0; $qs=$ENV{'QUERY_STRING'}; if($sort_field=&pick_up("sort_a",$qs)){ $sort_a="yes"; } if($s_field=&pick_up("sort_d",$qs)){ $sort_d="yes"; } if($sort_d eq "yes"){ $sort_field=$s_field; } @csv_lines=&modify_CSV($csv_file_path); $lcl=@csv_lines; @headers=split(",",$csv_lines[0]); foreach $one (@headers){ $one=&search_prepare($one); } $l_headers=@headers; for($l=0;$l<=($l_headers-1);$l=$l+1){ if($headers[$l]=~/^$sort_field$/){ $sort_location=$l+1; } if(($headers[$l]=~/^#date_local$/)||($headers[$l]=~/^#date_local$/)){ $date_location=$l+1; } if($headers[$l]=~/^\#_approved$/){ $valid_location=$l+1; } } if((($sort_a eq "yes")||($sort_d eq "yes"))&&($sort_location < 1)){ &produce_error( "Cannot locate the requested sort field in CSV file header." ); } if($rec_range=&pick_up("rec_range",$qs)){ if($rec_range=~/^\((\d+)\)\((\d+)-(\d+)\)(.+)/){ $page=$1; $rec_start=$2; $rec_end=$3; $recs=$4; @matched_lines=split(" ",$recs); foreach $match (@matched_lines){ if($match=~/\D/){ &produce_error( "unpropper form found in rec_range in URL." ); } } goto PARTIAL; } else{ &produce_error( "unpropper form found in rec_range in URL." ); } } if($display=&pick_up("display",$qs)){ if($display eq "random"){ $display="random"; goto PREPARE; } elsif($display eq "all"){ $display="all"; goto PREPARE; } else{ &produce_error( "undefined display mode requested." ); } } @conditions=split("&",$qs); $l_conditions=@conditions; $absolute=$l_conditions; foreach $one (@conditions){ $one=~s/%([\dA-Fa-f][\dA-Fa-f])/pack("C",hex($1))/eg; $one=~tr/+/ /; } for($l=1;$l<=(@csv_lines-1);$l=$l+1){ @line_entries=split(",",$csv_lines[$l]); foreach $entry (@line_entries){ $entry=&search_prepare($entry); $entry=&sweep_spaces($entry); } CHECK_CONDITIONS: foreach $rule (@conditions){ if($rule=~/[^=<>!]<[^=<>!]/){ ($var,$val)=split("<",$rule); &error_if_nonnumiric; &error_if_meta; $var=&sweep_spaces($var); $val=&sweep_spaces($val); for($p=0;$p<=($l_headers-1);$p=$p+1){ if($var=~/^$headers[$p]$/){ if($line_entries[$p] < $val){ $c_match=$c_match+1; next CHECK_CONDITIONS; } } } } elsif($rule=~/[^=<>!]>[^=<>!]/){ ($var,$val)=split(">",$rule); &error_if_nonnumiric; &error_if_meta; $var=&sweep_spaces($var); $val=&sweep_spaces($val); for($p=0;$p<=($l_headers-1);$p=$p+1){ if($var=~/^$headers[$p]$/){ if($line_entries[$p] > $val){ $c_match=$c_match+1; next CHECK_CONDITIONS; } } } } elsif($rule=~/[^=<>!]>[^=<>!]/){ ($var,$val)=split(">",$rule); &error_if_nonnumiric; &error_if_meta; $var=&sweep_spaces($var); $val=&sweep_spaces($val); for($p=0;$p<=($l_headers-1);$p=$p+1){ if($var=~/^$headers[$p]$/){ if($line_entries[$p] > $val){ print $line_entries[$p]."
"; $c_match=$c_match+1; next CHECK_CONDITIONS; } } } } elsif(($rule=~/[^=<>!](>=)[^=<>!]/)||($rule=~/[^=<>!](=>)[^=<>!]/)){ ($var,$val)=split($+,$rule); &error_if_nonnumiric; &error_if_meta; $var=&sweep_spaces($var); $val=&sweep_spaces($val); for($p=0;$p<=($l_headers-1);$p=$p+1){ if($var=~/^$headers[$p]$/){ if($line_entries[$p] >= $val){ print $line_entries[$p]."
"; $c_match=$c_match+1; next CHECK_CONDITIONS; } } } } elsif(($rule=~/[^=<>!](<=)[^=<>!]/)||($rule=~/[^=<>!](=<)[^=<>!]/)){ ($var,$val)=split($+,$rule); &error_if_nonnumiric; &error_if_meta; $var=&sweep_spaces($var); $val=&sweep_spaces($val); for($p=0;$p<=($l_headers-1);$p=$p+1){ if($var=~/^$headers[$p]$/){ if($line_entries[$p] <= $val){ print $line_entries[$p]."
"; $c_match=$c_match+1; next CHECK_CONDITIONS; } } } } elsif($rule=~/[^=<>!]!![^=<>!]/){ ($var,$val)=split("!!",$rule); &error_if_nonnumiric; &error_if_meta; $var=&sweep_spaces($var); $val=&sweep_spaces($val); for($p=0;$p<=($l_headers-1);$p=$p+1){ if($var=~/^$headers[$p]$/){ if($line_entries[$p] != $val){ $c_match=$c_match+1; next CHECK_CONDITIONS; } } } } elsif(($rule=~/[^=<>!](!=)[^=<>!]/)||($rule=~/[^=<>!](=!)[^=<>!]/)){ ($var,$val)=split($+,$rule); &error_if_meta; $var=&sweep_spaces($var); $val=&sweep_spaces($val); if($val=~/^".+"$/){ $val=~s/^"//; $val=~s/"$//; for($p=0;$p<=($l_headers-1);$p=$p+1){ if($var=~/^$headers[$p]$/){ if($line_entries[$p] !~ /^$val$/i){ $c_match=$c_match+1; next CHECK_CONDITIONS; } } } } #end of the new if exact else{ for($p=0;$p<=($l_headers-1);$p=$p+1){ if($var=~/^$headers[$p]$/){ if($line_entries[$p] !~ /$val/i){ $c_match=$c_match+1; next CHECK_CONDITIONS; } } } } } elsif(($rule=~/[^=<>!]=[^=<>!]/)||($rule=~/[^=<>!]=$/)){ ($var,$val)=split("=",$rule); &error_if_meta; if($val !~/\S/){ $c_match=$c_match+1; next CHECK_CONDITIONS; } $var=&sweep_spaces($var); $val=&sweep_spaces($val); if($val=~/^".+"$/){ $val=~s/^"//; $val=~s/"$//; for($p=0;$p<=($l_headers-1);$p=$p+1){ if($var=~/^$headers[$p]$/){ if($line_entries[$p] =~ /^$val$/i){ $c_match=$c_match+1; next CHECK_CONDITIONS; } } } } else{ for($p=0;$p<=($l_headers-1);$p=$p+1){ if($var=~/^$headers[$p]$/){ if($line_entries[$p] =~ /$val/i){ $c_match=$c_match+1; next CHECK_CONDITIONS; } } } } } else{ &produce_error( "Unreadable request found in your query.", "Please, check the syntax of your query." ); } } if($c_match == $absolute){ $matched_lines[$num]=$l; if($sort_location != 0){ $sort_values[$num]=$line_entries[$sort_location-1]; } if($date_location != 0){ $date_values[$num]=$line_entries[$date_location-1]; $date_values[$num]=&sweep_spaces($date_values[$num]); if($date_values[$num]!~/\d{1,2}[,-\/\\]\d{1,2}[,-\/\\]\d{4}/){ $date_values[$num]="not dated"; } } $num=$num+1; } $c_match=0; } PREPARE: $lcsv=@csv_lines-1; if($display eq "all"){ @matched_lines=(1..$lcsv); } if($display eq "random"){ srand; if($num_random < 1){ &produce_error( "cannot display less than 1 random records." ); } if($num_random > $lcsv){ $num_random=$lcsv; } @matched_lines=(); $num=0; $l=1; REDO: for($l;$l<=$num_random;$l=$l+1){ $record_n=int(rand($lcsv))+1; $matched_lines[$num]=$record_n; for($u=0;$u<=($num-1);$u=$u+1){ if($matched_lines[$num] == $matched_lines[$u]){ goto REDO; } } $num=$num+1; } } $lml=@matched_lines; if(($sort_a eq "yes")||($sort_d eq "yes")){ &sort_results; } SHOW: if(open(HTML,$html_template_path)){ @html_lines=; close(HTML); $html=join("",@html_lines); unless($html=~/(.*)