...

View Full Version : PLEASE help. CGI problem



ajei
09-08-2002, 08:53 AM
okay...i'd like to use this search engine script from cgibiz.com
http://www.cgibiz.com/where.shtml
but their install instructions are not completed or something
it doesn't tell you anything about using the .ini file which contians all the variables and deffinitions....as well as the actual where.cgi script..it calls for the .ini file but only quotes it as "where.ini"?? (shouldn't my URL be preceeding it)
anyways...the script doesn't run and I was hoping someone here could help me out....i would really appreciate it as i have been struggling with this for a week or so...
what can i say, im a noob :)

ajei
09-08-2002, 10:02 PM
btw, here is the where.cgi script...
( i know its lots, but im mainly concerned about the points where it calls on other files....i think)
#!/usr/bin/perl
################################################################
# DO NOT ALTER ANYTHING BELOW #
################################################################

################################################################
# TITLE: Where #
# VERSION: 1.11 #
# CREATED ON: March 13, 2000 #
# LAST UPDATED: December 31, 2000 #
# E-MAIL: support@cgibiz.com #
# WEB SITE: http://www.cgibiz.com #
################################################################
# COPYRIGHT (C) 2000 ARVYDAS STRAUSAS. ALL RIGHTS RESERVED #
################################################################
# Copyright Notice #
# ---------------- #
# This script can be freely used and distributed, but any #
# modification of it without the written consent of Arvydas #
# Strausas is strictly prohibited. Copying any of the code #
# contained within this script and claiming it as your own is #
# also prohibited. You may not remove any of these header #
# notices. By using this code you agree to indemnify author #
# from any liability that might arise from it's use. #
################################################################

use integer;require"where.ini";my$query;my$key;my$value;my%params;if($ENV{"REQUEST_METHOD"}eq"GET"){$query=$ENV{"QUERY_STRING"};}else{read(STDIN,$query,$ENV{"CONTENT_LENGTH"});}foreach(split(/&/,$query)){($key,$value)=split(/=/);$value=~tr/+/ /;$value=~s/%(..)/pack("c", hex($1))/eg;trim($value);$params{$key}=$value;}my$cm=$params{"command"};my$ca=$params{"current_category"};my$now=time();$params{"version"}=de("Qpxfsfe!cz!=b!ubshfu>`cmbol!isfg>#iuuq;00xxx/dhjcj{/dpn#?Xifsf!2/22=0b?");$params{"encoded_current_category"}=encode($ca);$params{"current_category_file"}=get_category_file($ca);$params{"current_category_name"}=substr($ca,rindex($ca,"/")+1);if(!exists($params{"current_location"})){$params{"current_location"}=get_location($ca);}print"Content-type: text/html\n\n";if($cm eq"new"||$cm eq"add"){my$nm=remove_tags($params{"site_name"});$params{"site_url"}=~s/http:\/\///os;my$ur=$params{"site_url"};my$ds=remove_tags($params{"site_description"});if(length($nm)&&length($ur)&&length($ds)){show_template("add");generate_page("$nm\t$ur\t$ds\t$now\n");}else{show_template("new");}}elsif($cm eq"search"){my$qr="";my$fl;my$header;my$body;my$footer;my$page="";my@ar;set_searching_params();foreach(split(/\W+/,$params{"query"})){if(length($_)>2){$qr.="\\b$_|";}}chop($qr);open(TEMPLATE,"$ini::templates_dir/search.html");while(<TEMPLATE>){if(index($_,"<!-- begin group -->")>=0){while(index($_=<TEMPLATE>,"site_url")<0){$header.=$_;}$body=$_;while(index($_=<TEMPLATE>,"<!-- end group -->")<0){$footer.=$_;}foreach$ca($ca?($ca):get_categories()){set_category_params("",$ca);open(SITES,"$ini::data_dir/".get_category_file($ca).".txt");while(<SITES>){if(/$qr/is){$ar[0]=$header;$ar[0]=~s/\$(\w+)/$params{$1}/ges;$page.=$ar[0];do{if(/$qr/is){@ar=split(/\t/);set_site_params(@ar);$_=$body;s/\$(\w+)/$params{$1}/ges;$page.=$_;}}while(<SITES>);$ar[0]=$footer;$ar[0]=~s/\$(\w+)/$params{$1}/ges;$page.=$ar[0];}}close(SITES);}}else{s/\$(\w+)/$params{$1}/ges;$page.=$_;}}close(TEMPLATE);if($page=~/$params{"version"}/o){print($page);}}elsif($cm eq"refresh"){my$original_html_dir=$ini::html_dir;print "<html><body><ul>";foreach(get_categories()){$ini::html_dir=".";set_category_params("current_",$_);$ini::html_dir=$original_html_dir;generate_page();print"<li>$ini::html_dir/$params{'current_category_file'}.html";}print "</ul></body></html>";}sub de{my$s=$_[0];$s=~s/([\!-\~])/chr(ord($1) - 1)/eg;return$s;}sub encode{my$s=$_[0];$s=~s/([^a-zA-Z0-9_\-.])/sprintf("%%%02X", ord($1))/eg;return$s;}sub trim{$_[0]=~s/^\s+//o;$_[0]=~s/\s+$//o;}sub remove_tags{$_[0]=~s/</&lt;/go;$_[0]=~s/>/&gt;/go;return$_[0];}sub get_category_file{my$fl=lc($_[0]);$fl=~s/\W/_/gos;return$fl;}sub get_location{my$i;my$lo="";my@ar=split(/\//,$_[0]);for($i=0;$i<@ar;$i++){$lo.="<a href=\"$ini::html_dir/".get_category_file(join("/",@ar[0..$i])).".html\">$ar[$i]</a>".($i<@ar-1?$ini::category_separator:"");}return$lo;}sub get_categories{my$i;my@ar;my@categories;open(CATEGORIES,"$ini::data_dir/categories.txt");while(<CATEGORIES>){$i=rindex($_,"\t")+1;$ar[$i]=substr($_,$i,length($_)-$i-1);push(@categories,join("/",@ar[0..$i]));}close(CATEGORIES);return@categories;}sub get_subcategories{my$i=0;my$j;my@ar=split(/\//,$_[0]);open(CATEGORIES,"$ini::data_dir/categories.txt");while(<CATEGORIES>){if(index($_,$ar[$i])>=0){last if++$i==@ar;}}$i--;undef(@ar);while(<CATEGORIES>){$j=rindex($_,"\t");last if$j<$i;next if$j>$i;push(@ar,"$_[0]/".substr($_,$j+1,length($_)-$j-2));}close(CATEGORIES);return@ar;}sub set_category_params{$params{"$_[0]category"}=$_[1];$params{"encoded_$_[0]category"}=encode($_[1]);$params{"$_[0]category_file"}=get_category_file($_[1]);$params{"$_[0]category_name"}=substr($_[1],rindex($_[1],"/")+1);$params{"$_[0]location"}=get_location($_[1]);}sub set_site_params{$params{"site_name"}=$_[0];$params{"site_url"}=$_[1];$params{"encoded_site_url"}=encode($_[1]);$params{"site_description"}=$now-$_[3]>$ini::expire_after?$_[2]:"$_[2] <img src=\"$ini::new_image_path\">";}sub set_searching_params{my$qr=encode($params{"query"});$params{"goto"}="<a target=_blank href=\"http://service.bfast.com/bfast/click?bfmid=253985&bfsiteid=30333849&bfpage=search&Keywords=$qr\">GoTo.com</a><img width=1 height=1 src=\"http://service.bfast.com/bfast/serve?bfmid=253985&bfsiteid=30333849&bfpage=search\">";$params{"altavista"}="<a target=_blank href=\"http://service.bfast.com/bfast/click?siteid=30333855&bfmid=22218516&bfpage=search_smy&user=befree&pg=q&kl=XX&q=$qr\">AltaVista</a><img width=1 height=1 src=\"http://service.bfast.com/bfast/serve?siteid=30333855&bfmid=22218516&bfpage=search_small1\">";$params{"hotbot"}="<a target=_blank href=\"http://service.bfast.com/bfast/click?siteid=30333852&bfmid=5960107&bfpage=hotbot2&MT=$qr\">HotBot</a><img width=1 height=1 src=\"http://service.bfast.com/bfast/serve?bfmid=5960107&siteid=30333852&bfpage=hotbot2\">";$params{"ahha"}="<a target=_blank href=\"http://www.qksrv.net/interactive?pid=216739&aid=12236&url=http%3A%2F%2Fpartner.ah-ha.com%2F1001.asp&query=$qr\">ah-ha.com</a><img width=1 height=1 src=\"http://www.qksrv.net/image-216739-12236\">";}sub show_template{my$page="";open(TEMPLATE,"$ini::templates_dir/$_[0].html");while(<TEMPLATE>){s/\$(\w+)/$params{$1}/ges;$page.=$_;}close(TEMPLATE);if($page=~/$params{"version"}/o){print($page);}}sub generate_page{my$s;my$fl=$params{"current_category_file"};my$page="";my@ar;my@categories=get_subcategories($params{"current_category"});my@sites;$params{"query"}=lc($params{"current_category_name"});set_searching_params();open(SITES,">$ini::data_dir/$fl.txt")if!open(SITES,"+<$ini::data_dir/$fl.txt");@sites=$_[0]?sort(<SITES>,$_[0]):<SITES>;seek(SITES,0,0);print(SITES@sites);close(SITES);open(TEMPLATE,"$ini::templates_dir/page.html");while(defined($s=<TEMPLATE>)){if(index($s,"category_file")>=0){foreach(@categories){set_category_params("",$_);$_=$s;s/\$(\w+)/$params{$1}/ges;$page.=$_;}}elsif(index($s,"site_url")>=0){foreach(@sites){@ar=split(/\t/,$_);set_site_params(@ar);$_=$s;s/\$(\w+)/$params{$1}/ges;$page.=$_;}}else{$s=~s/\$(\w+)/$params{$1}/ges;$page.=$s;}}close(TEMPLATE);if($page=~/$params{"version"}/o){open(HTML,">$ini::html_dir/$fl.html");print(HTML$page);close(HTML);}}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum