Only in noobfarm/include: config.php diff -ur noobfarm-1.1/index.php noobfarm/index.php --- noobfarm-1.1/index.php 2008-04-02 09:49:20.000000000 -0400 +++ noobfarm/index.php 2008-04-06 02:53:17.000000000 -0400 @@ -44,6 +44,8 @@ if(!isset($_SESSION['current_page'])) $_SESSION['current_page'] = '1'; if(!isset($_SESSION['count_per_page'])) $_SESSION['count_per_page'] = '20'; +$extra_url = ''; + // Are we looking at pending or approved quotes? if(isset($_GET['pending'])) { $approve = 0; @@ -53,8 +55,11 @@ // look to see if user wants to change anything if(isset($_GET['sort_type'])) { - if($_GET['sort_type'] == 'rating') $_SESSION['sort_type'] = 'rating'; - else $_SESSION['sort_type'] = 'date'; + if($_GET['sort_type'] == 'rating'){ + $_SESSION['sort_type'] = 'rating'; + } else { + $_SESSION['sort_type'] = 'date'; + } } if(isset($_GET['sort_order'])) { if($_GET['sort_order'] == 'asc') $_SESSION['sort_order'] = 'ASC'; @@ -70,28 +75,41 @@ $_SESSION['count_per_page'] = $_GET['count_per_page']; } -$sql = "SELECT id FROM " . $config['db']['tableprefix'] . "quotes WHERE approve=" . $approve; +$sql = "SELECT COUNT(*) FROM " . $config['db']['tableprefix'] . "quotes WHERE approve=1"; $recordSet = &$database->Execute($sql); if (!$recordSet) { die($database->ErrorMsg()); } -$num_quotes = $recordSet->RecordCount(); -unset($recordSet); +$total_quotes = $recordSet->FetchRow(); +$total_quotes = $total_quotes[0]; -$sql = "SELECT id FROM " . $config['db']['tableprefix'] . "quotes WHERE approve=0"; +$sql = "SELECT COUNT(*) FROM " . $config['db']['tableprefix'] . "quotes WHERE approve=0"; $recordSet = &$database->Execute($sql); if (!$recordSet) { die($database->ErrorMsg()); } -$num_inqueue = $recordSet->RecordCount(); +$num_inqueue = $recordSet->FetchRow(); +$num_inqueue = $num_inqueue[0]; unset($recordSet); -// calculate the number of pages to generate -$num_pages = ceil($num_quotes / $_SESSION['count_per_page']); +$sql = 'SELECT SQL_CALC_FOUND_ROWS id, quote, rating, date '; +$sql .= " FROM " . $config['db']['tableprefix'] . "quotes WHERE approve = " . $approve ; + +if (!empty($_GET['query'])){ + $query = $database->qstr($_GET['query'], get_magic_quotes_gpc()); + $sql .= " AND MATCH(quote) AGAINST($query IN BOOLEAN MODE) "; + + $sql .= " ORDER BY " . $_SESSION['sort_type'] . " " . $_SESSION['sort_order']; + + $query = get_magic_quotes_gpc() ? stripslashes($_GET['query']) : $_GET['query']; + $extra_url .= '&query=' . htmlspecialchars($query); +} else { + $sql .= " ORDER BY " . $_SESSION['sort_type'] . " " . $_SESSION['sort_order']; +} -$sql = "SELECT id, quote, rating, date FROM " . $config['db']['tableprefix'] . "quotes WHERE approve = " . $approve . " ORDER BY " . $_SESSION['sort_type'] . " " . $_SESSION['sort_order'] . " LIMIT " . $dest_page * $_SESSION['count_per_page'] . ", " . $_SESSION['count_per_page']; +$sql .= " LIMIT " . $dest_page * $_SESSION['count_per_page'] . ", " . $_SESSION['count_per_page']; $recordSet = &$database->Execute($sql); @@ -99,11 +117,20 @@ die($database->ErrorMsg()); } -// create link to the post id if it is an approved quote -if(isset($_GET['id']) && ctype_digit($_GET['id'])) { -header("location:viewquote.php?id=" . $_GET['id']); +//get the total quotes for the page count +$query = 'SELECT FOUND_ROWS()'; +$page_count = &$database->Execute($query); +$num_quotes = $page_count->FetchRow(); +$num_quotes = $num_quotes[0]; + +// calculate the number of pages to generate +$num_pages = ceil($num_quotes / $_SESSION['count_per_page']); +// create link to the post id if it is an approved quote +if(isset($_GET['id']) && ctype_digit($_GET['id'])) { + //read the HTTP RFC, the Location header must be a full URI + header('Location: ' . $config['url'] . 'viewquote.php?id=' . $_GET['id']); } // create new Smarty object @@ -113,12 +140,12 @@ $smarty->assign('template', $template); $smarty->assign('title', $title); $smarty->assign('logo', $logo); -$smarty->assign('num_quotes', $num_quotes); +$smarty->assign('num_quotes', $total_quotes); $smarty->assign('num_inqueue', $num_inqueue); $smarty->assign('version', $version); $smarty->assign('print_version', $print_version); $smarty->assign('show_feed', $show_feed); - +$smarty->assign('search_query_url', $extra_url); $smarty->display("{$template}/index.tpl"); ?> diff -ur noobfarm-1.1/scripts/scripts.js noobfarm/scripts/scripts.js --- noobfarm-1.1/scripts/scripts.js 2008-04-02 09:49:20.000000000 -0400 +++ noobfarm/scripts/scripts.js 2008-04-06 02:50:58.000000000 -0400 @@ -1,3 +1,3 @@ -function changePage(value) { - location.replace('?dest_page=' + value) +function changePage(value, extra) { + location.replace('?dest_page=' + value + extra) } diff -ur noobfarm-1.1/templates/default/index.tpl noobfarm/templates/default/index.tpl --- noobfarm-1.1/templates/default/index.tpl 2008-04-02 09:49:20.000000000 -0400 +++ noobfarm/templates/default/index.tpl 2008-04-06 02:47:28.000000000 -0400 @@ -33,17 +33,18 @@ Sort by Date {if $smarty.session.sort_order eq 'DESC'} - in Ascending order || + in Ascending order || {elseif $smarty.session.sort_order eq 'ASC'} - in Descending order || + in Descending order || {/if} +
@@ -51,7 +52,7 @@