3
/*************************************************************
4
* TorrentFlux - PHP Torrent Manager
6
**************************************************************/
8
This file is part of TorrentFlux.
10
TorrentFlux is free software; you can redistribute it and/or modify
11
it under the terms of the GNU General Public License as published by
12
the Free Software Foundation; either version 2 of the License, or
13
(at your option) any later version.
15
TorrentFlux is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with TorrentFlux; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
include_once("config.php");
26
include_once("functions.php");
27
include_once("searchEngines/SearchEngineBase.php");
29
// Go get the if this is a search request. go get the data and produce output.
31
$hideSeedless = getRequestVar('hideSeedless');
32
if(!empty($hideSeedless))
34
$_SESSION['hideSeedless'] = $hideSeedless;
37
if (!isset($_SESSION['hideSeedless']))
39
$_SESSION['hideSeedless'] = 'no';
42
$hideSeedless = $_SESSION['hideSeedless'];
44
$pg = getRequestVar('pg');
46
$searchEngine = getRequestVar('searchEngine');
47
if (empty($searchEngine)) $searchEngine = $cfg["searchEngine"];
49
$searchterm = getRequestVar('searchterm');
50
if(empty($searchterm))
51
$searchterm = getRequestVar('query');
53
$searchterm = str_replace(" ", "+",$searchterm);
55
// Check to see if there was a searchterm.
56
// if not set the get latest flag.
57
if (strlen($searchterm) == 0)
59
if (! array_key_exists("LATEST",$_REQUEST))
61
$_REQUEST["LATEST"] = "1";
65
DisplayHead("TorrentSearch "._SEARCH);
67
echo "<style>.tinyRow {font-size:2px;height:2px;}</style>";
69
// Display the search box
70
echo "<a name=\"top\"></a><div align=\"center\">";
71
echo "<table border=1 cellspacing=0 width=\"760\" cellpadding=5><tr>";
72
echo "<td bgcolor=\"".$cfg["table_header_bg"]."\">";
73
echo "<form id=\"searchForm\" name=\"searchForm\" action=\"torrentSearch.php\" method=\"get\">";
74
echo _SEARCH." Torrents:<br>";
75
echo "<input type=\"text\" name=\"searchterm\" value=\"".str_replace("+", " ",$searchterm)."\" size=30 maxlength=50> ";
76
echo buildSearchEngineDDL($searchEngine);
77
echo " <input type=\"Submit\" value=\""._SEARCH."\"> ";
78
echo "\n<script language=\"JavaScript\">\n";
79
echo " function getLatest()\n";
81
echo " var selectedItem = document.searchForm.searchEngine.selectedIndex;\n";
82
echo " document.searchForm.searchterm.value = '';\n";
83
echo " document.location.href = 'torrentSearch.php?searchEngine='+document.searchForm.searchEngine.options[selectedItem].value+'&LATEST=1';\n";
84
echo " return true;\n";
88
echo " <a href=\"#\" onclick=\"javascript:getLatest()\");\"><img src=\"images/properties.png\" width=18 height=13 title=\"Show Latest Torrents\" align=\"absmiddle\" border=0>Show Latest Torrents</a>";
91
echo "* Click on Torrent Links to add them to the Torrent Download List";
94
echo "</td><td bgcolor=\"".$cfg["table_header_bg"]."\" align=right valign=top>Visit: ".buildSearchEngineLinks($searchEngine). "</td></tr>";
96
if (is_file('searchEngines/'.$searchEngine.'Engine.php'))
98
include_once('searchEngines/'.$searchEngine.'Engine.php');
99
$sEngine = new SearchEngine(serialize($cfg));
100
if ($sEngine->initialized)
102
echo "<div align=center valign=top>";
109
foreach ($sEngine->getMainCategories() as $mainId => $mainName)
111
if (strlen($tmpCatLinks) >= 500 && $mainStart == false)
113
$catLinks .= $tmpCatLinks . "<br>";
117
if ($mainStart == false) $tmpCatLinks .= " | ";
118
$tmpCatLinks .= "<a href=\"torrentSearch.php?searchEngine=".$searchEngine."&mainGenre=".$mainId."\">".$mainName."</a>";
122
echo $catLinks . $tmpCatLinks;
124
if ($mainStart == false)
131
$mainGenre = getRequestVar('mainGenre');
133
if (!empty($mainGenre) && !array_key_exists("subGenre",$_REQUEST))
136
$subCats = $sEngine->getSubCategories($mainGenre);
137
if (count($subCats) > 0)
139
echo "<tr bgcolor=\"".$cfg["table_header_bg"]."\">";
140
echo "<td colspan=6><form method=get id=\"subLatest\" name=\"subLatest\" action=torrentSearch.php?>";
141
echo "<input type=hidden name=\"searchEngine\" value=\"".$searchEngine."\">";
143
$mainGenreName = $sEngine->GetMainCatName($mainGenre);
145
echo "Category: <b>".$mainGenreName."</a></b> -> ";
146
echo "<select name=subGenre>";
148
foreach ($subCats as $subId => $subName)
150
echo "<option value=".$subId.">".$subName."</option>\n";
153
echo "<input type=submit value='Show Latest'>";
158
echo "</td></tr></table></div>";
159
// Set the Sub to equal the main for groups that don't have subs.
160
$_REQUEST["subGenre"] = $mainGenre;
161
echo $sEngine->getLatest();
166
echo "</td></tr></table></div>";
168
if (array_key_exists("LATEST",$_REQUEST) && $_REQUEST["LATEST"] == "1")
170
echo $sEngine->getLatest();
174
echo $sEngine->performSearch($searchterm);
180
// there was an error connecting
182
echo "<tr><td><br><br><div align=center><strong>".$sEngine->msg."</strong></div><br><br></td></tr>";
183
echo "</table></div>";
188
// there was an error connecting
190
echo "<tr><td><br><br><div align=center><strong>Search Engine not installed.</strong></div><br><br></td></tr>";
191
echo "</table></div>";