include('incutfcleanup.php');
include('pg_utf_connect.php');
// open database connection
foreach ($_REQUEST as $key => $value){
$$key = $value;
echo $key . " " . $value . "
";
}
$ABUSE=false;
$whozzat=$_COOKIE["rbname"];
print "Hello $whozzat
";
print_r($_COOKIE);
if($whozzat != "")
$ABUSE=false;
?>
Rantburg Search
Home
if($ABUSE==true){ ?>
Temporarily closed due to abuse. Please check back later.
}else{ ?>
if(isset($q)){
$terms = $q;
$terms = search_split_terms($terms);
$terms_db = search_db_escape_terms($terms);
$terms_rx = search_rx_escape_terms($terms);
$parts = array();
$snurble=array();
if(!isset($N))
$N=1;
foreach($terms_db as $term_db){
$parts[] = "lower(rquote) LIKE '%" . strtolower($term_db) . "%'";
}
foreach($terms_db as $term_db){
$snurble[] = $term_db;
}
foreach($terms_db as $term_db){
$murble[] = "".$term_db. "";
}
$sparts = implode(' AND ', $parts);
//print $q;
$sstring= urlencode($q);
$sql = "select count(*) as T from tbltwar where ($sparts) ";
$result = pg_query($sql) or die ("Error in query: $sql. " . pg_last_error());
$row = pg_fetch_object($result);
$totalrex=$row->T;
if($totalrex < 100){
$showrex=$totalrex;
$sql = "SELECT * FROM tbltwar WHERE ($sparts) order by rdate desc ";
}else{
$showrex=100;
$limitz=$N * $showrex;
$offset=($N-1)*$showrex;
//$sql = "SELECT * FROM tbltwar WHERE ($sparts) order by rdate desc limit $limitz offset $offset";
$sql = "SELECT * FROM tbltwar WHERE ($sparts) order by rdate desc limit 100";
//print $sql;
}
echo $sql;
$rows = array();
$result = pg_query($sql) or die ("Error in query: $sql. " . pg_last_error());
print "$totalrex records were returned. Showing $showrex.";
for($i=1;$i < $totalrex/$showrex;$i++){
if($N==$i){
print " $i";
}else{
print " $i";
}
}
if (($totalrex % $showrex) != 0){
if($N==$i){
print " $i";
}else{
print " $i";
}
}
print " ";
while($row = pg_fetch_object($result)){
print "\n";
print "
\n";
}
}
}
?>
pg_close($pg_connect);
function search_sort_results($a, $b){
$ax = $a[$score];
$bx = $b[$score];
if ($ax == $bx){ return 0; }
return ($ax > $bx) ? -1 : 1;
}
function search_html_escape_terms($terms){
$out = array();
foreach($terms as $term){
if (preg_match("/\s|,/", $term)){
$out[] = '"'.HtmlSpecialChars($term).'"';
}else{
$out[] = HtmlSpecialChars($term);
}
}
return $out;
}
function search_pretty_terms($terms_html){
if (count($terms_html) == 1){
return array_pop($terms_html);
}
$last = array_pop($terms_html);
return implode(', ', $terms_html)." and $last";
}
function search_rx_escape_terms($terms){
$out = array();
foreach($terms as $term){
$out[] = '\b'.preg_quote($term, '/').'\b';
}
return $out;
}
function search_split_terms($terms){
$terms = preg_replace("/\"(.*?)\"/e", "search_transform_term('\$1')", $terms);
$terms = preg_split("/\s+|,/", $terms);
$out = array();
foreach($terms as $term){
$term = preg_replace("/\{WHITESPACE-([0-9]+)\}/e", "chr(\$1)", $term);
$term = preg_replace("/\{COMMA\}/", ",", $term);
$out[] = $term;
}
return $out;
}
function search_transform_term($term){
$term = preg_replace("/(\s)/e", "'{WHITESPACE-'.ord('\$1').'}'", $term);
$term = preg_replace("/,/", "{COMMA}", $term);
return $term;
}
function search_escape_rlike($string){
return preg_replace("/([.\[\]*^\$])/", '\\\$1', $string);
}
function search_db_escape_terms($terms){
$out = array();
foreach($terms as $term){
//$out[] = '[[:<:]]'.AddSlashes(search_escape_rlike($term)).'[[:>:]]';
$out[] = AddSlashes(search_escape_rlike($term));
}
return $out;
}
?>