<?php
// +----------------------------------------------------------------------+
// | Fantastic File Database |
// +----------------------------------------------------------------------+
// | By Tony Baird |
// | Copyright (c) 2003 Fantastic Scripts |
// | http://fscripts.com |
// +----------------------------------------------------------------------+
// | Fantastic File Database Can be modified freely as long as copyright |
// | is intact and this is left at the top of every source file |
// +----------------------------------------------------------------------+
// | search.php |
// | Date Started: March 8, 2003 |
// | Last Modified: March 8, 2003 |
// +----------------------------------------------------------------------+
Class Search {
//*************************************************/
// Just seing what we are doing
//*************************************************/
function Search() {
global $tpl,$mysql,$online,$ffdb;
if ($_REQUEST['action']=="search") {
$this->SearchForm();
}elseif (isset($_REQUEST['search'])) {
$this->SearchResults();
} else {
$ffdb->Error("Well you did something stupid to get this error :P");
}
}
//*************************************************/
// Displays our wonderful stats!
//*************************************************/
function SearchForm() {
global $tpl,$mysql,$online,$ffdb,$online,$CONFIG;
$tpl->LoadTemplate("search_form","templates/$online->skin/search_form.tpl");
$tpl->ParseTemplate("search_form",$search_form_array,"No");
$tpl->PrintTemplate("search_form");
}
function SearchResults() {
global $tpl,$mysql,$online,$ffdb,$online,$CONFIG;
if (isset($_REQUEST['page'])) {
$page=$_REQUEST['page'];
} else {
$page=1;
}
$ffdb->DivideData("SELECT * FROM ffdb_files WHERE file_name LIKE '%".$_REQUEST['filename']."%'",$page,$CONFIG['files_per_page']);
$ffdb->MakePages("<a href=\"filedb.php?page={eachpage}&action=search\">{eachpage}</a> ","<b>({page})</b> ","<a href=\"filedb.php?page=1&action=search\">« First Page</a> ","<a href=\"filedb.php?page={eachpage}&action=search\">Last Page »</a>",$page,$ffdb->num_pages);
// Loading Our Templates
if ($ffdb->hasdata !="No") {
$tpl->LoadTemplate("file_list","templates/$online->skin/file_list.tpl");
$tpl->LoadTemplate("file_list_top","templates/$online->skin/file_list_top.tpl");
$tpl->LoadTemplate("file_list_bottom","templates/$online->skin/file_list_bottom.tpl");
$mysql->Query("SELECT * FROM ffdb_files WHERE file_name LIKE '%".$_REQUEST['filename']."%' LIMIT $ffdb->data_bottom,$ffdb->data_top");
// Setting up the Sub Category List
while ($show_file=mysql_fetch_array($mysql->result_id)) {
$ffdb->strip_array($show_file);
$date_added=date($CONFIG[date_format],$show_file[date_added]);
if ($show_file[num_ratings]==0) {
$rating=0;
} else {
$rating=round($show_file[total_ratings]/$show_file[num_ratings],2);
}
$file_list_array = array(
'file_name'=> $show_file[file_name],
'date_added'=> $date_added,
'downloads' => $show_file[downloads],
'file_description' => $show_file[file_description],
'rating' => $rating,
'file_id' => $show_file[file_id],
);
$tpl->ParseTemplate("file_list",$file_list_array,"Yes");
}
$tpl->ParseTemplate("file_list_top",$file_list_array_top,"Yes");
$file_list_bottom_array = array(
'pages'=> $ffdb->pages
);
$tpl->ParseTemplate("file_list_bottom",$file_list_bottom_array,"Yes");
$tpl->ParseTemplate("file_list_top",$file_list_top_array,"Yes");
$tpl->PrintTemplate("file_list_top");
$tpl->PrintTemplate("file_list");
$tpl->PrintTemplate("file_list_bottom");
} else {
$ffdb->Error("Nothing met your search criteria");
}
}
}
?>