2000-05-18 19:52:00 +00:00
< ?
2000-06-07 08:50:12 +00:00
include " functions.inc " ;
include " theme.inc " ;
2000-05-18 19:52:00 +00:00
2000-06-07 08:50:12 +00:00
$theme -> header ();
2000-05-18 19:52:00 +00:00
2000-06-07 08:50:12 +00:00
$terms = stripslashes ( $terms );
2000-05-18 19:52:00 +00:00
2000-07-02 11:21:00 +00:00
$output .= " <TABLE WIDTH= \" 100% \" BORDER= \" 0 \" > \n " ;
$output .= " <TR VALIGN= \" center \" > \n " ;
$output .= " <TD COLSPAN=3> \n " ;
$output .= " <FORM ACTION= \" " . basename ( $GLOBALS [ PHP_SELF ]) . " \" METHOD= \" POST \" > \n " ;
$output .= " <INPUT SIZE= \" 50 \" VALUE= \" $terms\ " NAME = \ " terms \" TYPE= \" text \" ><BR> \n " ;
2000-06-07 08:50:12 +00:00
### category:
2000-07-02 11:21:00 +00:00
$output .= " <SELECT NAME= \" category \" > \n " ;
if ( $category != " " ) $output .= " <OPTION VALUE= \" $category\ " > $category </ OPTION > \n " ;
$output .= " <OPTION VALUE= \" \" >All categories</OPTION> \n " ;
2000-06-07 08:50:12 +00:00
for ( $i = 0 ; $i < sizeof ( $categories ); $i ++ ) {
2000-07-02 11:21:00 +00:00
$output .= " <OPTION VALUE= \" $categories[$i] \" > $categories[$i] </OPTION> \n " ;
2000-06-07 08:50:12 +00:00
}
2000-07-02 11:21:00 +00:00
$output .= " </SELECT> \n " ;
2000-06-07 08:50:12 +00:00
### order:
2000-07-02 11:21:00 +00:00
$output .= " <SELECT NAME= \" order \" > \n " ;
2000-06-07 08:50:12 +00:00
if ( $order == " Oldest first " ) {
2000-07-02 11:21:00 +00:00
$output .= " <OPTION VALUE= \" Oldest first \" >Oldest first</OPTION> \n " ;
$output .= " <OPTION VALUE= \" Newest first \" >Newest first</OPTION> \n " ;
2000-06-07 08:50:12 +00:00
}
else {
2000-07-02 11:21:00 +00:00
$output .= " <OPTION VALUE= \" Newest first \" >Newest first</OPTION> \n " ;
$output .= " <OPTION VALUE= \" Oldest first \" >Oldest first</OPTION> \n " ;
2000-06-07 08:50:12 +00:00
}
2000-07-02 11:21:00 +00:00
$output .= " </SELECT> \n " ;
2000-06-07 08:50:12 +00:00
2000-07-02 11:21:00 +00:00
$output .= " <INPUT TYPE= \" submit \" VALUE= \" Search \" > \n " ;
$output .= " </TD> \n " ;
$output .= " </TR> \n " ;
$output .= " <TR> \n " ;
$output .= " <TD> \n " ;
2000-06-07 08:50:12 +00:00
### Compose query:
2000-06-25 16:11:47 +00:00
$query = " SELECT DISTINCT s.id, s.subject, u.userid, s.timestamp FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.status = 2 " ;
2000-06-07 08:50:12 +00:00
if ( $terms != " " ) $query .= " AND (s.subject LIKE '% $terms %' OR s.abstract LIKE '% $terms %' OR s.comments LIKE '% $terms %') " ;
if ( $category != " " ) $query .= " AND s.category = ' $category ' " ;
2000-07-02 11:21:00 +00:00
if ( $author != " " ) $query .= " AND u.userid = ' $author ' " ;
2000-06-22 09:16:31 +00:00
if ( $order == " Oldest first " ) $query .= " ORDER BY s.timestamp ASC " ;
else $query .= " ORDER BY s.timestamp DESC " ;
2000-05-18 19:52:00 +00:00
2000-06-07 08:50:12 +00:00
### Perform query:
2000-06-22 09:16:31 +00:00
$result = db_query ( " $query " );
2000-05-18 19:52:00 +00:00
2000-06-07 08:50:12 +00:00
### Display search results:
2000-07-02 11:21:00 +00:00
$output .= " <HR> \n " ;
2000-06-22 09:16:31 +00:00
while ( $entry = db_fetch_object ( $result )) {
2000-06-07 08:50:12 +00:00
$num ++ ;
2000-05-18 19:52:00 +00:00
2000-06-07 08:50:12 +00:00
if ( $user ) {
2000-06-22 09:16:31 +00:00
$link = " <A HREF= \" article.php?id= $entry->id " ;
2000-06-07 08:50:12 +00:00
if ( isset ( $user -> umode )) { $link .= " &mode= $user->umode " ; } else { $link .= " &mode=threaded " ; }
if ( isset ( $user -> uorder )) { $link .= " &order= $user->uorder " ; } else { $link .= " &order=0 " ; }
if ( isset ( $user -> thold )) { $link .= " &thold= $user->thold " ; } else { $link .= " &thold=0 " ; }
2000-06-22 09:16:31 +00:00
$link .= " \" > $entry->subject </A> " ;
2000-06-07 08:50:12 +00:00
}
else {
2000-06-22 09:16:31 +00:00
$link = " <A HREF= \" article.php?id= $entry->id &mode=threaded&order=1&thold=0 \" > $entry->subject </A> " ;
2000-06-07 08:50:12 +00:00
}
2000-07-02 11:21:00 +00:00
$output .= " <P> $num ) <B> $link </B><BR><SMALL>by <B><A HREF= \" account.php?op=info&uname= $entry->userid\ " > $entry -> userid </ A ></ B > , posted on " . date( " l , F d , Y - H : i A " , $entry->timestamp ) . " .</ SMALL ></ P > \n " ;
2000-06-07 08:50:12 +00:00
}
2000-05-18 19:52:00 +00:00
2000-07-02 11:21:00 +00:00
if ( $num == 0 ) $output .= " <P>Your search did <B>not</B> match any articles in our database: <UL><LI>Try using fewer words.</LI><LI>Try using more general keywords.</LI><LI>Try using different keywords.</LI></UL></P> \n " ;
else $output .= " <P><B> $num </B> results matched your search query.</P> \n " ;
2000-06-07 08:50:12 +00:00
2000-07-02 11:21:00 +00:00
$output .= " </TD> \n " ;
$output .= " </TR> \n " ;
$output .= " </TABLE> \n " ;
2000-05-18 19:52:00 +00:00
2000-06-07 08:50:12 +00:00
$theme -> box ( " Search " , $output );
2000-05-18 19:52:00 +00:00
$theme -> footer ();
?>