#!/usr/bin/perl -w ################################################################ # DO NOT EDIT ANYTHING BELOW # ################################################################ ################################################################ # TITLE: Popularity # # VERSION: 1.1 # # CREATED ON: March 11, 2000 # # LAST UPDATED: June 10, 2000 # # E-MAIL: scripts@cgilabs.cjb.net # # WEB SITE: http://cgilabs.cjb.net # ################################################################ # 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;use Socket;require"popularity.ini";print"Content-type: text/html\n\n";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;$params{$key}=$value;}$params{"version"}="Powered by Popularity 1.1";my$url=$params{"url"};$url=~s/http:\/\///os;my$template="form";my@report;my$i;my$s;if($url){require LWP::UserAgent;require HTTP::Request;my$ur;my$popularity;my$content;for($i=0;$i<@ini::engines;$i+=3){$ur=$ini::engines[$i+1];$ur=~s/\$url/$url/gs;if($content=http_request($ur)){if($ini::engines[$i]=~/hotbot/ios){my$j=index($content," than ");my$k;my$l;if($j>0){$k=rindex($content,">",$j)+1;$l=index($content,"<",$j);}else{$j=index($content," matches ");$j=index($content," Matches ")if$j<0;$k=rindex($content,">",$j)+1;$l=$j;}$popularity=substr($content,$k,$l-$k);}else{$content=~/([0123456789,]+) $ini::engines[$i + 2]/;$popularity=$1;}if(length($popularity)<32){my@ar=($ini::engines[$i],$ur,$popularity);push(@report,\@ar);}}}my@ar=("","itop.cjb.net","");push(@report,\@ar);$template="report";}open(TEMPLATE,"$ini::templates_dir/$template.html")or error("$ini::templates_dir/$template.html");while(defined($s=