After many requests, we're pleased to make the original library pages available again.
EOM; echo "
"; $searchbox_type = "horizontal"; include('/var/www/virtual/psoug.org/htdocs/searchbox.htm'); echo "

 

"; print << 

EOM; include_once("footer.php"); exit; } $titlebar_text = "Search Results"; $page_title = $titlebar_text; $header_bar_text = $titlebar_text; include_once("/var/www/virtual/psoug.org/htdocs/header.php"); if($num_results==''){$num_results = 10;} // $querywords variable to come in from url if ($_REQUEST['querywords']) { $querywords_url = sanitize(4, 150, $_REQUEST['querywords']); } else { $querywords_url = "nothingwasenteredinthesearchquery"; } // search term may come in from Quick Search box... if ($_REQUEST['qwords']) { $querywords_url = sanitize(4, 150, $_REQUEST['qwords']); } if(strlen($querywords_url) < 4){ $querywords_url = "nothingwasenteredinthesearchquery"; $err_text = 'You need to enter a string of more than 3 letters to search for.
'; } /* // $querytype variable may come in from url if ($_POST['querytype']) { $querytype = sanitize(4, 150, $_POST['querytype']); } else { $querytype = sanitize(4, 150, $_GET['querytype']); } */ $querytype = sanitize(4, 150, $_REQUEST['querytype']); if ($querywords_url) { $querywords = explode(" ",$querywords_url); $sizeof_querywords = sizeof($querywords); if ($querytype == 'allwords') { // 'All Words' was selected for search for ($i = 0; $i < $sizeof_querywords; $i++) { $where_statement_snippets .= "(name LIKE '%$querywords[$i]%' OR "; $where_statement_snippets .= "description LIKE '%$querywords[$i]%' OR "; $where_statement_snippets .= "comment LIKE '%$querywords[$i]%' OR "; $where_statement_snippets .= "language LIKE '%$querywords[$i]%' OR "; $where_statement_snippets .= "snippet LIKE '%$querywords[$i]%')"; if ($i < $sizeof_querywords - 1) { $where_statement_snippets .= " AND "; } } } // if allwords if ($querytype == 'anywords') { // 'Any Words' was selected for search for ($i = 0; $i < $sizeof_querywords; $i++) { $where_statement_snippets .= "name LIKE '%$querywords[$i]%' OR "; $where_statement_snippets .= "description LIKE '%$querywords[$i]%' OR "; $where_statement_snippets .= "comment LIKE '%$querywords[$i]%' OR "; $where_statement_snippets .= "language LIKE '%$querywords[$i]%' OR "; $where_statement_snippets .= "snippet LIKE '%$querywords[$i]%'"; if ($i < $sizeof_querywords - 1) { $where_statement_snippets .= " OR "; } } } // if anywords if ($querytype == 'exactphrase') { // 'Exact Phrase' was selected for search $querywords = implode(" ",$querywords); $where_statement_snippets .= "name LIKE '%$querywords%' OR "; $where_statement_snippets .= "description LIKE '%$querywords%' OR "; $where_statement_snippets .= "comment LIKE '%$querywords%' OR "; $where_statement_snippets .= "language LIKE '%$querywords%' OR "; $where_statement_snippets .= "snippet LIKE '%$querywords%'"; } // if exactphrase } else { $querywords = ""; } // are we searching a specific category? - added LDM 3-2009 if($cat_id != '0'){ $where_statement_snippets .= " AND category_id = '$cat_id' "; } $redo_querywords = urlencode($querywords_url); $truncate_at = 150; // truncate size of description string $limit = $num_results; //print "X: SELECT sid FROM plibsnippets WHERE ".$where_statement_snippets." ORDER BY name DESC"; $numresults = mysql_query("SELECT sid FROM plibsnippets WHERE ".$where_statement_snippets." ORDER BY name DESC"); $numrows = mysql_num_rows($numresults); print <<
After many requests, we're pleased to make the original library pages available again.

Your search returned $numrows result(s)

EOM; // next determine if offset has been passed to script, if not use 0 if ($_GET['offset']) { $offset = sanitize(1, 5, $_GET['offset']); } else { $offset = "0"; } // get results if ($dbtype == "pgsql") { $result = mysql_query("SELECT sid,name,description,language,category_id,last_modified FROM ".$prefix."snippets WHERE ".$where_statement_snippets." ORDER BY name DESC limit ".$limit." offset ".$offset.""); } else { // assume mysql $result = mysql_query("SELECT sid,name,description,language,category_id,last_modified FROM ".$prefix."snippets WHERE ".$where_statement_snippets." ORDER BY name DESC limit ".$offset.",".$limit.""); } // now you can display the results returned function trace_categories($parent_id) { GLOBAL $built_menu,$prefix; // Recursive function to display parent categories $query = "SELECT cid,category_name,parent_id FROM ".$prefix."categories WHERE cid='$parent_id'"; $result = mysql_query($query); while ($r = mysql_fetch_array($result)) { $cid = $r["cid"]; $category_name = $r["category_name"]; $parent_id = $r["parent_id"]; if ($parent_id > 0) { // meaning it actually has a parent category $built_menu = " >> ".$category_name."".$built_menu; $again = trace_categories($parent_id); // run it again } else { $built_menu = "".$category_name."".$built_menu; } } return $built_menu; } $cnt = $offset; while ($r = mysql_fetch_array($result)) { $sid = $r["sid"]; $name = $r["name"]; $description = $r["description"]; $cnt++; if ($cnt%2 == 0) { $search_class = "searchalt2"; } else { $search_class = "searchalt1"; } if (strlen($description) > ($truncate_at + 3)) { $description = substr($description,0,$truncate_at)."..."; } $language = $r["language"]; $last_modified = $r['last_modified']; $category_id = $r["category_id"]; $query = mysql_query("SELECT category_name FROM ".$prefix."categories WHERE cid='".$category_id."'"); list($category_name) = mysql_fetch_array($query); $build_menu = trace_categories($category_id); if ($build_menu) { $build_menu = "CATEGORY: ".$build_menu; } else { $build_menu = "CATEGORY: UNCATEGORIZED"; } // prep the pretty url from the name $pname = ereg_replace(' ', '_', $name); $pname = preg_replace("/[^0-9a-zA-Z\_]/i",'', $pname); //$pname = ereg_replace('__', '_', $pname); $pname = $pname . '_' . $sid; $pname = ereg_replace('__', '_', $pname); echo "".$cnt.". $name
$description
$build_menu
LANGUAGE: ".$language."     Last Modified: ".$last_modified."


"; unset($build_menu,$built_menu); } echo "

 

"; // next we need to do the links to other results if ($offset > 0) { // bypass PREV link if offset is 0 $prevoffset = $offset - $limit; $PREVLINK = "[PREV] \n"; }else{ $PREVLINK = '[PREV]'; } if($numrows > 10){ print << $PREVLINK EOM; } // calculate number of pages needing links $pages = intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } if ($pages > 1) { for ($i=1; $i<=$pages; $i++) { // loop thru $newoffset = ($limit * ($i-1)); if ($newoffset == $offset) { print "$i   \n"; } else { print "$i  \n"; } } } // check to see if last page if($numrows-$offset > $limit){ // not last page so give NEXT link $newoffset=$offset+$limit; $NEXTLINK = "[NEXT]\n"; }else{ $NEXTLINK = '[NEXT]'; } if($numrows > 10){ print "$NEXTLINK"; } echo "

"; $searchbox_type = "horizontal"; include('/var/www/virtual/psoug.org/htdocs/searchbox.htm'); print << 

EOM; include_once("footer.php"); ?>