All pastes #973680 Raw Edit

Stuff

public diff v1 · immutable
·published 2008-04-06 07:07 UTC
rendered paste body
Only in noobfarm/include: config.phpdiff -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 .= '&amp;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 <span class="sort">Date</span>      {if $smarty.session.sort_order eq 'DESC'}-      in <a class="sort" href="?sort_order=asc">Ascending</a> order <span style="color: #000000">||</span> +      in <a class="sort" href="?sort_order=asc{$search_query_url}">Ascending</a> order <span style="color: #000000">||</span>      {elseif $smarty.session.sort_order eq 'ASC'}-      in <a class="sort" href="?sort_order=desc">Descending</a> order <span style="color: #000000">||</span> +      in <a class="sort" href="?sort_order=desc{$search_query_url}">Descending</a> order <span style="color: #000000">||</span>     {/if}     <select name="count" onchange="window.location.href=this.options[this.selectedIndex].value;">     <option value="selected"># of quotes per page</option>-    <option label="20" value="?count_per_page=20">20 quotes</option>-    <option label="40" value="?count_per_page=40">40 quotes</option>-    <option label="60" value="?count_per_page=60">60 quotes</option>+    <option label="20" value="?count_per_page=20{$search_query_url}">20 quotes</option>+    <option label="40" value="?count_per_page=40{$search_query_url}">40 quotes</option>+    <option label="60" value="?count_per_page=60{$search_query_url}">60 quotes</option>    </select>+   <form action="?" method="get" style="display:inline;"><input type="text" name="query" size="15" value="Search" onclick="if(this.value=='Search')this.value='';"/></form>    </div>    </div>@@ -51,7 +52,7 @@   <div class="grey_bar">    Jump to page: -   <select name="selPageIndex2" onchange="changePage(this.options[this.selectedIndex].value)">+   <select name="selPageIndex2" onchange="changePage(this.options[this.selectedIndex].value, '{$search_query_url}')">    <option>Pages...</option>    {php} Only in noobfarm: templates_c