From da3ab149cab5590b26a39adcaa9d6cde10013744 Mon Sep 17 00:00:00 2001 From: Git Date: Wed, 8 Aug 2012 08:00:12 +0000 Subject: [PATCH] Empty commit --- classes/class_search.php | 11 ++-- classes/script_start.php | 81 +++++++++++++++------------- sections/ajax/browse.php | 17 +++--- sections/ajax/requests.php | 4 +- sections/requests/requests.php | 75 +++++++++++++++----------- sections/tools/managers/eb.php | 2 +- sections/tools/managers/eb_alter.php | 2 +- sections/tools/misc/countries.php | 2 +- sections/tools/tools.php | 5 +- sections/torrents/browse2.php | 48 ++++++++++------- sections/torrents/user.php | 2 +- static/styles/proton/style.css | 2 +- 12 files changed, 142 insertions(+), 109 deletions(-) diff --git a/classes/class_search.php b/classes/class_search.php index caa13096..79571f9c 100644 --- a/classes/class_search.php +++ b/classes/class_search.php @@ -68,7 +68,7 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(), send_irc('PRIVMSG '.LAB_CHAN.' :Search for "'.$Query.'" ('.str_replace("\n",'',print_r($this->Filters, true)).') failed: '.$this->GetLastError()); } - $this->TotalResults = $Result['total']; + $this->TotalResults = $Result['total_found']; $this->SearchTime = $Result['time']; if(empty($Result['matches'])) { @@ -136,11 +136,10 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(), return $Matches; } - function limit($Start, $Length, $MaxMatches=SPHINX_MATCHES_START) { - if(check_perms('site_search_many') && empty($_GET['limit_matches'])) { - $MaxMatches = 500000; - } - $this->SetLimits((int)$Start, (int)$Length, $MaxMatches, 0); + function limit($Start, $Length) { + $Start = (int)$Start; + $Length = (int)$Length; + $this->SetLimits($Start, $Length, $Start+$Length); } diff --git a/classes/script_start.php b/classes/script_start.php index 344836dc..e43fcd3b 100644 --- a/classes/script_start.php +++ b/classes/script_start.php @@ -922,74 +922,83 @@ function get_pages($StartPage,$TotalRecords,$ItemsPerPage,$ShowPages=11,$Anchor= $ShowPages: The number of page links that are shown. eg. If there are 20 pages that exist, but $ShowPages is only 11, only 11 links will be shown. //----------------------------------------------------------------------------*/ - $StartPage=ceil($StartPage); - if ($StartPage==0) { $StartPage=1; } + $StartPage = ceil($StartPage); $TotalPages = 0; - if ($TotalRecords>0) { - if ($StartPage>ceil($TotalRecords/$ItemsPerPage)) { $StartPage=ceil($TotalRecords/$ItemsPerPage); } + if ($TotalRecords > 0) { + $StartPage = min($StartPage, ceil($TotalRecords/$ItemsPerPage)); $ShowPages--; - $TotalPages=ceil($TotalRecords/$ItemsPerPage); + $TotalPages = ceil($TotalRecords/$ItemsPerPage); - if ($TotalPages>$ShowPages) { - $StartPosition=$StartPage-round($ShowPages/2); + if ($TotalPages > $ShowPages) { + $StartPosition = $StartPage-round($ShowPages/2); - if ($StartPosition<=0) { - $StartPosition=1; + if ($StartPosition <= 0) { + $StartPosition = 1; } else { - if ($StartPosition>=($TotalPages-$ShowPages)) { - $StartPosition=$TotalPages-$ShowPages; + if ($StartPosition >= ($TotalPages-$ShowPages)) { + $StartPosition = $TotalPages-$ShowPages; } } - $StopPage=$ShowPages+$StartPosition; + $StopPage = $ShowPages+$StartPosition; } else { - $StopPage=$TotalPages; - $StartPosition=1; + $StopPage = $TotalPages; + $StartPosition = 1; } - if ($StartPosition<1) { $StartPosition=1; } + $StartPosition = max($StartPosition, 1); $QueryString = get_url(array('page','post')); - if($QueryString != '') { $QueryString = '&'.$QueryString; } - + if ($QueryString != '') { + $QueryString = '&'.$QueryString; + } + $Pages = ''; - if ($StartPage>1) { - $Pages.='<< First '; - $Pages.='< Prev | '; + if ($StartPage > 1) { + $Pages .= '<< First '; + $Pages .= '< Prev | '; } //End change if (!$Mobile) { - for ($i=$StartPosition; $i<=$StopPage; $i++) { + for ($i = $StartPosition; $i <= $StopPage; $i++) { //if ($i!=$StartPage) { $Pages.=''; } - if ($i!=$StartPage) { $Pages.=''; } - $Pages.=""; - if($i*$ItemsPerPage>$TotalRecords) { - $Pages.=((($i-1)*$ItemsPerPage)+1).'-'.($TotalRecords); + if ($i != $StartPage) { + $Pages .= ''; + } + $Pages .= ""; + if($i*$ItemsPerPage > $TotalRecords) { + $Pages .= ((($i-1)*$ItemsPerPage)+1).'-'.($TotalRecords); } else { - $Pages.=((($i-1)*$ItemsPerPage)+1).'-'.($i*$ItemsPerPage); + $Pages .= ((($i-1)*$ItemsPerPage)+1).'-'.($i*$ItemsPerPage); } - $Pages.=""; - if ($i!=$StartPage) { $Pages.=''; } - if ($i<$StopPage) { $Pages.=" | "; } + $Pages .= ""; + if ($i != $StartPage) { + $Pages.=''; + } + if ($i < $StopPage) { + $Pages.=" | "; + } } } else { $Pages .= $StartPage; } - if ($StartPage<$TotalPages) { - $Pages.=' | Next > '; - $Pages.=' Last >>'; + if ($StartPage && $StartPage < $TotalPages) { + $Pages .= ' | Next > '; + $Pages .= ' Last >>'; } - + } - - if ($TotalPages>1) { return $Pages; } - + + if ($TotalPages > 1) { + return $Pages; + } + } function send_email($To,$Subject,$Body,$From='noreply',$ContentType='text/plain') { diff --git a/sections/ajax/browse.php b/sections/ajax/browse.php index a0627549..714f3963 100644 --- a/sections/ajax/browse.php +++ b/sections/ajax/browse.php @@ -230,17 +230,15 @@ function header_link($SortKey,$DefaultWay="desc") { } -if(!empty($_GET['page']) && is_number($_GET['page'])) { +if(!empty($_GET['page']) && is_number($_GET['page']) && $_GET['page'] > 0) { if(check_perms('site_search_many')) { $Page = $_GET['page']; } else { $Page = min(SPHINX_MAX_MATCHES/TORRENTS_PER_PAGE, $_GET['page']); } - $MaxMatches = min(SPHINX_MAX_MATCHES, SPHINX_MATCHES_START + SPHINX_MATCHES_STEP*floor(($Page-1)*TORRENTS_PER_PAGE/SPHINX_MATCHES_STEP)); - $SS->limit(($Page-1)*TORRENTS_PER_PAGE, TORRENTS_PER_PAGE, $MaxMatches); + $SS->limit(($Page-1)*TORRENTS_PER_PAGE, TORRENTS_PER_PAGE); } else { $Page = 1; - $MaxMatches = SPHINX_MATCHES_START; $SS->limit(0, TORRENTS_PER_PAGE); } @@ -259,7 +257,7 @@ function header_link($SortKey,$DefaultWay="desc") { } elseif($_GET['order_by'] == 'random') { $OrderBy = '@random'; $Way = SPH_SORT_EXTENDED; - $SS->limit(0, TORRENTS_PER_PAGE, TORRENTS_PER_PAGE); + $SS->limit(0, TORRENTS_PER_PAGE); } else { $OrderBy = $_GET['order_by']; } @@ -278,7 +276,11 @@ function header_link($SortKey,$DefaultWay="desc") { $SS->set_index(SPHINX_INDEX.' delta'); $Results = $SS->search($Query, '', 0, array(), '', ''); -$TorrentCount = $SS->TotalResults; +if(check_perms('site_search_many')) { + $TorrentCount = $SS->TotalResults; +} else { + $TorrentCount = min($SS->TotalResults, SPHINX_MAX_MATCHES); +} // These ones were not found in the cache, run SQL if(!empty($Results['notfound'])) { @@ -310,6 +312,7 @@ function header_link($SortKey,$DefaultWay="desc") { if(count($Results)==0) { + $DB->query("SELECT tags.Name, ((COUNT(tags.Name)-2)*(SUM(tt.PositiveVotes)-SUM(tt.NegativeVotes)))/(tags.Uses*0.8) AS Score @@ -327,12 +330,12 @@ function header_link($SortKey,$DefaultWay="desc") { GROUP BY tt.TagID ORDER BY Score DESC LIMIT 8"); - $JsonYouMightLike = array(); while(list($Tag)=$DB->next_record()) { $JsonYouMightLike[] = $Tag; } + print json_encode( array( diff --git a/sections/ajax/requests.php b/sections/ajax/requests.php index 75720545..0720b469 100644 --- a/sections/ajax/requests.php +++ b/sections/ajax/requests.php @@ -208,10 +208,10 @@ if(!empty($_GET['page']) && is_number($_GET['page'])) { $Page = min($_GET['page'], 50000/REQUESTS_PER_PAGE); - $SS->limit(($Page - 1) * REQUESTS_PER_PAGE, REQUESTS_PER_PAGE, 50000); + $SS->limit(($Page - 1) * REQUESTS_PER_PAGE, REQUESTS_PER_PAGE); } else { $Page = 1; - $SS->limit(0, REQUESTS_PER_PAGE, 50000); + $SS->limit(0, REQUESTS_PER_PAGE); } if(empty($_GET['order'])) { diff --git a/sections/requests/requests.php b/sections/requests/requests.php index cd2b9562..23103263 100644 --- a/sections/requests/requests.php +++ b/sections/requests/requests.php @@ -204,12 +204,12 @@ } } -if(!empty($_GET['page']) && is_number($_GET['page'])) { - $Page = min($_GET['page'], 50000/REQUESTS_PER_PAGE); - $SS->limit(($Page - 1) * REQUESTS_PER_PAGE, REQUESTS_PER_PAGE, 50000); +if(!empty($_GET['page']) && is_number($_GET['page']) && $_GET['page'] > 0) { + $Page = $_GET['page']; + $SS->limit(($Page - 1) * REQUESTS_PER_PAGE, REQUESTS_PER_PAGE); } else { $Page = 1; - $SS->limit(0, REQUESTS_PER_PAGE, 50000); + $SS->limit(0, REQUESTS_PER_PAGE); } if(empty($_GET['order'])) { @@ -267,35 +267,12 @@ $SS->set_index('requests requests_delta'); $SphinxResults = $SS->search($Query, '', 0, array(), '', ''); $NumResults = $SS->TotalResults; -//We don't use sphinxapi's default cache searcher, we use our own functions - -if(!empty($SphinxResults['notfound'])) { - $SQLResults = get_requests($SphinxResults['notfound']); - if(is_array($SQLResults['notfound'])) { - //Something wasn't found in the db, remove it from results - reset($SQLResults['notfound']); - foreach($SQLResults['notfound'] as $ID) { - unset($SQLResults['matches'][$ID]); - unset($SphinxResults['matches'][$ID]); - } - } - - // Merge SQL results with memcached results - foreach($SQLResults['matches'] as $ID => $SQLResult) { - $SphinxResults['matches'][$ID] = $SQLResult; - - //$Requests['matches'][$ID] = array_merge($Requests['matches'][$ID], $SQLResult); - //We ksort because depending on the filter modes, we're given our data in an unpredictable order - //ksort($Requests['matches'][$ID]); - } +if($NumResults && $NumResults < ($Page - 1) * REQUESTS_PER_PAGE + 1) { + $PageLinks = get_pages(0, $NumResults, REQUESTS_PER_PAGE); +} else { + $PageLinks = get_pages($Page, $NumResults, REQUESTS_PER_PAGE); } -$PageLinks = get_pages($Page, $NumResults, REQUESTS_PER_PAGE); - -$Requests = $SphinxResults['matches']; - -$CurrentURL = get_url(array('order', 'sort')); - show_header($Title, 'requests'); ?> @@ -450,10 +427,12 @@ - + + + + + + + $SQLResult) { + $SphinxResults['matches'][$ID] = $SQLResult; + + //$Requests['matches'][$ID] = array_merge($Requests['matches'][$ID], $SQLResult); + //We ksort because depending on the filter modes, we're given our data in an unpredictable order + //ksort($Requests['matches'][$ID]); + } + } + + $Requests = $SphinxResults['matches']; + + $CurrentURL = get_url(array('order', 'sort')); $Row = 'a'; $TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18 foreach ($Requests as $RequestID => $Request) { diff --git a/sections/tools/managers/eb.php b/sections/tools/managers/eb.php index 116ede12..375dced9 100644 --- a/sections/tools/managers/eb.php +++ b/sections/tools/managers/eb.php @@ -1,5 +1,5 @@ query("SELECT diff --git a/sections/tools/managers/eb_alter.php b/sections/tools/managers/eb_alter.php index aaf1fceb..770f3f72 100644 --- a/sections/tools/managers/eb_alter.php +++ b/sections/tools/managers/eb_alter.php @@ -1,5 +1,5 @@ - + + + @@ -47,6 +49,7 @@ + diff --git a/sections/torrents/browse2.php b/sections/torrents/browse2.php index ddea8464..ae718729 100644 --- a/sections/torrents/browse2.php +++ b/sections/torrents/browse2.php @@ -269,18 +269,15 @@ function header_link($SortKey,$DefaultWay="desc") { $SS->set_filter('categoryid', array_keys($_GET['filter_cat'])); } - -if(!empty($_GET['page']) && is_number($_GET['page'])) { +if(!empty($_GET['page']) && is_number($_GET['page']) && $_GET['page'] > 0) { if(check_perms('site_search_many')) { $Page = $_GET['page']; } else { $Page = min(SPHINX_MAX_MATCHES/TORRENTS_PER_PAGE, $_GET['page']); } - $MaxMatches = min(SPHINX_MAX_MATCHES, SPHINX_MATCHES_START + SPHINX_MATCHES_STEP*floor(($Page-1)*TORRENTS_PER_PAGE/SPHINX_MATCHES_STEP)); - $SS->limit(($Page-1)*TORRENTS_PER_PAGE, TORRENTS_PER_PAGE, $MaxMatches); + $SS->limit(($Page-1)*TORRENTS_PER_PAGE, TORRENTS_PER_PAGE); } else { $Page = 1; - $MaxMatches = SPHINX_MATCHES_START; $SS->limit(0, TORRENTS_PER_PAGE); } @@ -299,7 +296,7 @@ function header_link($SortKey,$DefaultWay="desc") { } elseif($_GET['order_by'] == 'random') { $OrderBy = '@random'; $Way = SPH_SORT_EXTENDED; - $SS->limit(0, TORRENTS_PER_PAGE, TORRENTS_PER_PAGE); + $SS->limit(0, TORRENTS_PER_PAGE); } else { $OrderBy = $_GET['order_by']; } @@ -318,8 +315,13 @@ function header_link($SortKey,$DefaultWay="desc") { $SS->set_index(SPHINX_INDEX.' delta'); $Results = $SS->search($Query, '', 0, array(), '', ''); -$TorrentCount = $SS->TotalResults; +if(check_perms('site_search_many')) { + $TorrentCount = $SS->TotalResults; + +} else { + $TorrentCount = min($SS->TotalResults, SPHINX_MAX_MATCHES); +} /* // If some were fetched from memcached, get their artists if(!empty($Results['matches'])) { // Fetch the artists for groups @@ -367,9 +369,6 @@ function header_link($SortKey,$DefaultWay="desc") { show_header('Browse Torrents','browse'); - // List of pages -$Pages=get_pages($Page,$TorrentCount,TORRENTS_PER_PAGE); - ?> @@ -553,12 +552,6 @@ function header_link($SortKey,$DefaultWay="desc") { - - - - - -
@@ -487,7 +466,39 @@ Nothing found!
+ The requested page contains no matches! +
Do not upload list
Vanity House additions
Email Blacklist
Manage freeleech tokens
Official Tags Manager
Tag Aliases
Registration Log
Invite Pool
Upscale Pool
User Flow
Limited search results: />
- Results + Results ?action=advanced'" />    @@ -639,8 +632,7 @@ function header_link($SortKey,$DefaultWay="desc") {
- -query("SELECT tags.Name, ((COUNT(tags.Name)-2)*(SUM(tt.PositiveVotes)-SUM(tt.NegativeVotes)))/(tags.Uses*0.8) AS Score @@ -668,10 +660,26 @@ function header_link($SortKey,$DefaultWay="desc") { show_footer();die(); } -$Bookmarks = all_bookmarks('torrent'); +if($TorrentCount < ($Page-1)*TORRENTS_PER_PAGE+1) { + $LastPage = ceil($TorrentCount/TORRENTS_PER_PAGE); + $Pages = get_pages(0, $TorrentCount, TORRENTS_PER_PAGE); +?> +
+

The requested page contains no matches.

+

You are requesting page , but the search returned only pages.

+
+ + + diff --git a/sections/torrents/user.php b/sections/torrents/user.php index f73c864e..a1900735 100644 --- a/sections/torrents/user.php +++ b/sections/torrents/user.php @@ -18,7 +18,7 @@ function header_link($SortKey,$DefaultWay="DESC") { if(!is_number($UserID)) { error(0); } -if(!empty($_GET['page']) && is_number($_GET['page'])) { +if(!empty($_GET['page']) && is_number($_GET['page']) && $_GET['page'] > 0) { $Page = $_GET['page']; $Limit = ($Page-1)*TORRENTS_PER_PAGE.', '.TORRENTS_PER_PAGE; } else { diff --git a/static/styles/proton/style.css b/static/styles/proton/style.css index 59a9e25c..fc100a93 100644 --- a/static/styles/proton/style.css +++ b/static/styles/proton/style.css @@ -481,7 +481,7 @@ ul#userinfo_username { } #torrents #content h2 { - margin: 10px 0 10px 0; + margin: 10px 0 10px 0 !important; } #content h2:first-child {