Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
36 kaklik 1
<?php
2
 
3
/*************************************************************
4
*  TorrentFlux - PHP Torrent Manager
5
*  www.torrentflux.com
6
**************************************************************/
7
/*
8
    This file is part of TorrentFlux.
9
 
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.
14
 
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.
19
 
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
23
*/
24
 
25
include_once("config.php");
26
include_once("functions.php");
27
include_once("searchEngines/SearchEngineBase.php");
28
 
29
    // Go get the if this is a search request. go get the data and produce output.
30
 
31
    $hideSeedless = getRequestVar('hideSeedless');
32
    if(!empty($hideSeedless))
33
    {
34
       $_SESSION['hideSeedless'] = $hideSeedless;
35
    }
36
 
37
    if (!isset($_SESSION['hideSeedless']))
38
    {
39
        $_SESSION['hideSeedless'] = 'no';
40
    }
41
 
42
    $hideSeedless = $_SESSION['hideSeedless'];
43
 
44
    $pg = getRequestVar('pg');
45
 
46
    $searchEngine = getRequestVar('searchEngine');
47
    if (empty($searchEngine)) $searchEngine = $cfg["searchEngine"];
48
 
49
    $searchterm = getRequestVar('searchterm');
50
    if(empty($searchterm))
51
        $searchterm = getRequestVar('query');
52
 
53
    $searchterm = str_replace(" ", "+",$searchterm);
54
 
55
    // Check to see if there was a searchterm.
56
    // if not set the get latest flag.
57
    if (strlen($searchterm) == 0)
58
    {
59
        if (! array_key_exists("LATEST",$_REQUEST))
60
        {
61
            $_REQUEST["LATEST"] = "1";
62
        }
63
    }
64
 
65
    DisplayHead("TorrentSearch "._SEARCH);
66
 
67
    echo "<style>.tinyRow {font-size:2px;height:2px;}</style>";
68
 
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>&nbsp;";
76
    echo buildSearchEngineDDL($searchEngine);
77
    echo "&nbsp;<input type=\"Submit\" value=\""._SEARCH."\">&nbsp;&nbsp;";
78
    echo "\n<script language=\"JavaScript\">\n";
79
    echo "      function getLatest()\n";
80
    echo "      {\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";
85
    echo "      }\n";
86
    echo "</script>\n";
87
 
88
    echo "&nbsp;&nbsp;<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>";
89
 
90
    echo "</form>";
91
    echo "* Click on Torrent Links to add them to the Torrent Download List";
92
    echo "</td>";
93
 
94
    echo "</td><td bgcolor=\"".$cfg["table_header_bg"]."\" align=right valign=top>Visit: &nbsp; &nbsp;".buildSearchEngineLinks($searchEngine). "</td></tr>";
95
 
96
    if (is_file('searchEngines/'.$searchEngine.'Engine.php'))
97
    {
98
        include_once('searchEngines/'.$searchEngine.'Engine.php');
99
        $sEngine = new SearchEngine(serialize($cfg));
100
        if ($sEngine->initialized)
101
        {
102
            echo "<div align=center valign=top>";
103
 
104
            $mainStart = true;
105
 
106
            $catLinks = '';
107
            $tmpCatLinks = '';
108
            $tmpLen = 0;
109
            foreach ($sEngine->getMainCategories() as $mainId => $mainName)
110
            {
111
                if (strlen($tmpCatLinks) >= 500 && $mainStart == false)
112
                {
113
                    $catLinks .= $tmpCatLinks . "<br>";
114
                    $tmpCatLinks = '';
115
                    $mainStart = true;
116
                }
117
                if ($mainStart == false) $tmpCatLinks .= " | ";
118
                $tmpCatLinks .=  "<a href=\"torrentSearch.php?searchEngine=".$searchEngine."&mainGenre=".$mainId."\">".$mainName."</a>";
119
                $mainStart = false;
120
            }
121
 
122
            echo $catLinks . $tmpCatLinks;
123
 
124
            if ($mainStart == false)
125
            {
126
                echo "<br><br>";
127
            }
128
            echo "</div>";
129
            echo "</td></tr>";
130
 
131
            $mainGenre = getRequestVar('mainGenre');
132
 
133
            if (!empty($mainGenre) && !array_key_exists("subGenre",$_REQUEST))
134
            {
135
 
136
                $subCats = $sEngine->getSubCategories($mainGenre);
137
                if (count($subCats) > 0)
138
                {
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."\">";
142
 
143
                    $mainGenreName = $sEngine->GetMainCatName($mainGenre);
144
 
145
                    echo "Category: <b>".$mainGenreName."</a></b> -> ";
146
                    echo "<select name=subGenre>";
147
 
148
                    foreach ($subCats as $subId => $subName)
149
                    {
150
                        echo "<option value=".$subId.">".$subName."</option>\n";
151
                    }
152
                    echo "</select> ";
153
                    echo "<input type=submit value='Show Latest'>";
154
                    echo "</form>\n";
155
                }
156
                else
157
                {
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();
162
                }
163
            }
164
            else
165
            {
166
                echo "</td></tr></table></div>";
167
 
168
                if (array_key_exists("LATEST",$_REQUEST) && $_REQUEST["LATEST"] == "1")
169
                {
170
                    echo $sEngine->getLatest();
171
                }
172
                else
173
                {
174
                   echo $sEngine->performSearch($searchterm);
175
                }
176
            }
177
        }
178
        else
179
        {
180
            // there was an error connecting
181
            echo "</td></tr>";
182
            echo "<tr><td><br><br><div align=center><strong>".$sEngine->msg."</strong></div><br><br></td></tr>";
183
            echo "</table></div>";
184
        }
185
    }
186
    else
187
    {
188
        // there was an error connecting
189
        echo "</td></tr>";
190
        echo "<tr><td><br><br><div align=center><strong>Search Engine not installed.</strong></div><br><br></td></tr>";
191
        echo "</table></div>";
192
    }
193
 
194
    DisplayFoot();
195
 
196
?>