topical media & game development
portal-classes-core.search.php
<?PHP
class Search {
var found_ids;
function Search(&this->core = &this->core->Db->connectDb();
}
function checkVariables() {
if(isset(_GET['s'] != "") {
return true;
}
return false;
}
function getSearchWords(searchwords = explode(' ',searchwords as word != "") {
word);
}
}
return searchstring = found_ids;
searchstring, '"...</h1>';
this->getSearchWords(searchstring = implode(" ", results[] = searchstring,results[] = searchstring,results[] = searchwords);
//echo '<pre>',var_dump(
return results;
}
function titleSearch(searchwords) {
global query = 'select content_id,content_title,content_binary FROM content WHERE MATCH (content_title) AGAINST (\'';
searchstring.'"';
foreach(word) {
word;
}
query,'</pre>';
this->core->Db->getPlainQueryResult(result) {
//echo('invalid query, ignoring...<br />');
}
else {
while(result, MYSQL_NUM)) {
if(in_array(found_ids)) {
//echo 'found duplicate search result with ID ',
}
else {
results[] = found_ids[] = results[0]);
//echo '</pre>';
mysql_free_result(results;
}
function textSearch(searchwords) {
global query = 'select content_id,content_title,content_binary FROM content WHERE MATCH (content_binary) AGAINST (\'';
searchstring.'"';
foreach(word) {
word;
}
query,'</pre>';
this->core->Db->getPlainQueryResult(result) {
//echo('invalid query, ignoring...<br />');
}
else {
while(result, MYSQL_NUM)) {
if(in_array(found_ids)) {
//echo 'found duplicate search result with ID ',
}
else {
results[] = found_ids[] = results);
//echo '</pre>';
mysql_free_result(results;
}
function keywordSearch(found_ids;
searchwords[0].'\'';
if(count(searchwords);
foreach(word) {
word.'\'';
}
}
query,'</pre>';
this->core->Db->getPlainQueryResult(result) {
//echo('invalid query, ignoring...<br />');
}
else {
while(result, MYSQL_NUM)) {
if(in_array(found_ids)) {
//echo 'found duplicate search result with ID ',
}
else {
results[] = found_ids[] = results['fullstring_keywords']);
//echo '</pre>';
mysql_free_result(results;
}
function doAdvancedSearch() {
sortby_options = array("relevance" => "Relevance", "datedes" => "Date (newest first)", "dateasc" => "Date (oldest first)");
foreach(search_field) {
if(isset(search_field]) && !empty(search_field])) {
//echo "found ",
$$search_field = _GET[search_fields_used[] = beforedd) && isset(beforeyyyy)) {
if(!beforedd,beforeyyyy)) {
//echo "Invalid 'before' date; ignored...<br />";
}
else beforeyyyy."-".beforedd;
}
if(isset(aftermm) && isset(this->checkValidDate(aftermm,afterdate = aftermm."-".query = title,keywords,beforedate,sortby);
//echo '<pre>',
// maak verbinding en voer query uit
result = query);
if(!row = mysql_fetch_array(results[] = results);
//echo '</pre>';
mysql_free_result(results;
}
function checkValidDate(m,d) && strlen(m) && strlen(y) && strlen(m,y) >= mktime(0,0,0,1,1,1970) && mktime(0,0,0,d,title,keywords,beforedate,sortby) {
title)) {
this->getSearchWords(searchstring = implode(" ", query .= 'MATCH content_title AGAINST (\'';
searchstring.'"';
foreach(word) {
word;
}
title) && isset(query .= '
';
if(query .= 'AND ';
}
else {
description)) {
this->getSearchWords(searchstring = implode(" ", query .= 'MATCH content_binary AGAINST (\'';
searchstring.'"';
foreach(word) {
word;
}
description) && isset(query .= '
';
if(query .= 'AND ';
}
else {
keywords)) {
keywords);
searchwords[0].'\'';
if(count(searchwords);
foreach(word) {
word.'\'';
}
}
beforedate)) {
beforedate.' 00:00:00\' ';
}
if(isset(query .= 'AND content_date_added > \''.sortby)) {
if(query .= 'ORDER BY content_date_added DESC';
}
elseif(query .= 'ORDER BY content_date_added';
}
}
//echo '<pre>',
return query;
}
}
?>
(C) A. Eliëns
2/9/2007
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.