#!/usr/bin/perl my $r = Apache->request; $r->content_type("text/html"); $r->send_http_header(); use DBI; use strict 'vars'; require 'ctime.pl'; use slashmod; my ($imagedir,$rootdir)=slashmod::config(); my $dbh; my ($allTopics,$allAuthors,$allSections); sub main { $dbh||=slashmod::dbconnect(); my %FORM=slashmod::getform(); $allTopics||=gettopics(); $allAuthors ||=getauthors(); $allSections ||=getsections(); slashmod::header("Slashdot.org:News for Nerds. Stuff that Matters.", 647); slashmod::titlebar("99%","Searching $FORM{query}"); if(not defined $FORM{min}) { $FORM{min}=0; } if(not defined $FORM{max}) { $FORM{max}=$FORM{min}+30; } my $t; if($FORM{topic} ne "") { $t=$FORM{topic}; } else {$t="slashdot";} my $c=$dbh->prepare("SELECT width,height,alttext,image FROM topics WHERE tid='$t'"); $c->execute(); my ($topicwidth, $topicheight, $topicalt, $topicimage)=$c->fetchrow; $c->finish(); print "\"$topicalt\"" if $topicimage; print "
"; print"

"; my $prev=$FORM{min}-30; if($prev >= 0) { print "

$FORM{min} previous matches...

"; } my $sqlquery="SELECT authors.aid,title,sid, date_format(time,\"W M D\@h:m\"), commentcount,url,section FROM stories, authors WHERE stories.aid=authors.aid "; if(defined $FORM{query}) { $sqlquery.="AND (title LIKE \"%$FORM{query}%\""; $sqlquery.="OR introtext LIKE \"%$FORM{query}%\")"; } if(length $FORM{author} > 1) { $sqlquery.="AND authors.aid=\"$FORM{author}\" "; } if(length $FORM{section} > 1) { $sqlquery.="AND section=\"$FORM{section}\" "; } if(length $FORM{topic} > 1) { $sqlquery.="AND tid=\"$FORM{topic}\" "; } $sqlquery.=" ORDER BY time DESC LIMIT $FORM{min},30 "; #print $sqlquery; my $cursor=$dbh->prepare($sqlquery); $cursor->execute; my ($aid, $title, $sid,$time,$x,$y,$commentcount,$url,$section,$totalCount); while(($aid, $title, $sid,$time,$commentcount,$url,$section,$totalCount) = $cursor->fetchrow) { print "$title by $aid on $time $commentcount
"; $x++; } $cursor->finish(); if($x < 1) { print "No Matches Found for your query"; } my $remaining=""; #my $remaining=$totalCount-$FORM{max}; #if($remaining > 0) { print "

$remaining matches left" unless $x<29; #} slashmod::writelog("search",$ENV{query}); slashmod::footer(); } sub getauthors { my ($r,$aid); my $cursor=$dbh->prepare("SELECT aid from authors WHERE seclev > 10"); $cursor->execute; while(($aid)=$cursor->fetchrow) { $r.="

Make your own free website on Tripod.com