forked from sicalpath/tjupt
-
Notifications
You must be signed in to change notification settings - Fork 2
/
opensearch.php
59 lines (58 loc) · 2.69 KB
/
opensearch.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
require "include/bittorrent.php";
dbconn();
global $BASEURL, $datefounded, $SITENAME, $SITEEMAIL, $SLOGAN;
function data_url($file, $mime)
{
$contents = file_get_contents($file);
$base64 = base64_encode($contents);
return ('data:' . $mime . ';base64,' . $base64);
}
$url = get_protocol_prefix() . $BASEURL;
$year = substr($datefounded, 0, 4);
$yearfounded = ($year ? $year : 2007);
$attribution = "Copyright (c) " . $SITENAME . " " . (date("Y") != $yearfounded ? $yearfounded . "-" : "") . date("Y") . ", all rights reserved";
header("Content-type: text/xml");
$Cache->new_page('opensearch_description', 86400);
if (!$Cache->get_page()) {
$Cache->add_whole_row();
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName><?php echo $SITENAME ?> Torrents</ShortName>
<Description>Search Torrents at <?php echo $SITENAME ?> - <?php echo htmlspecialchars($SLOGAN) ?>.</Description>
<Url type="text/html"
rel="results"
pageOffset="0"
template="<?php echo $url ?>/torrents.php?search={searchTerms}&page={startPage?}"/>
<Url type="application/rss+xml"
rel="results"
indexOffset="0"
template="<?php echo $url ?>/torrentrss.php?search={searchTerms}&rows={count?}&startindex={startIndex?}"/>
<Url type="application/opensearchdescription+xml"
rel="self"
template="<?php echo $url ?>/opensearch.php"/>
<Url type="application/x-suggestions+json"
rel="suggestions"
template="<?php echo $url ?>/searchsuggest.php?q={searchTerms}"/>
<Contact><?php echo $SITEEMAIL ?></Contact>
<Tags>Torrents <?php echo PROJECTNAME ?></Tags>
<LongName><?php echo $SITENAME ?> Torrents Search</LongName>
<Image height="32" width="32" type="image/x-icon"><?php echo data_url('favicon.ico', 'image/x-icon') ?></Image>
<Image height="32" width="32" type="image/x-icon"><?php echo $url ?>/favicon.ico</Image>
<moz:SearchForm><?php echo $url ?>/torrents.php</moz:SearchForm>
<Query role="example" searchTerms="batman"/>
<Developer><?php echo $SITENAME ?> Staff</Developer>
<Attribution><?php echo $attribution ?></Attribution>
<SyndicationRight>limited</SyndicationRight>
<Language>*</Language>
<InputEncoding>UTF-8</InputEncoding>
<OutputEncoding>UTF-8</OutputEncoding>
</OpenSearchDescription>
<?php
$Cache->end_whole_row();
$Cache->cache_page();
}
echo $Cache->next_row();
?>