-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
149 lines (124 loc) · 4.23 KB
/
search.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/************************
File: search.php
Date: 2015-01-26
Brief: Search engine routine file.
Legal notice:
Vikeep. Keep viki.com videos, yours.
Copyright (C) 2013 Victor Villarreal <mefhigoseth@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
************************/
include("inc/functions.inc.php");
include("inc/viki.inc.php");
include("inc/propaganda.inc.php");
?>
<!DOCTYPE html>
<html>
<? include('inc/header.inc.php'); ?>
<body>
<?php include('inc/navbar.inc.php'); ?>
<?php
$q = "";
if( isset($_POST['q']) ) {
$q = $_POST['q'];
}
else {
$q = $_GET['q'];
}
?>
<div class="container">
<!-- Start add banner -->
<?php
$propaganda = new propaganda();
$propaganda->printRandAdd();
?>
<!-- End add banner -->
<!-- SearchResults -->
<div class="page-header">
<h1>Search results <small>for <?php echo htmlentities($q); ?></small></h1>
</div>
<?php
if( !empty($q) ) {
$viki = new vikiAPI();
if( !isset($_GET['page']) ) {
$_GET['page'] = 1;
}
$_GET['page'] = (int) $_GET['page'];
$vikiSearch = $viki->search($q,$_GET['page']);
$count = count($vikiSearch['response']);
if( $count ){
for( $i=0;$i<$count;$i++) {
$id = $vikiSearch['response'][$i]['id'];
$title = $vikiSearch['response'][$i]['titles']['en'];
$poster = $vikiSearch['response'][$i]['images']['poster']['url'];
$episodes = $vikiSearch['response'][$i]['episodes']['count'];
$description = substr($vikiSearch['response'][$i]['descriptions']['en'],0,140);
if( !empty($episodes) ) {
echo "<div class='hero-unit text-center'>\r\n";
echo "<h1>".$title."</h1><span class='label label-info'>".$episodes." episodes</span>\r\n";
if( $vikiSearch['response'][$i]['flags']['on_air'] == 1 ) { echo "<span class='label label-success'>on-air</span>\r\n"; }
echo "<p><img src='".$poster."' alt='".$title."' class='img-polaroid' /></p>\r\n";
echo "<p><i>".$description." ...</i></p>";
if( $vikiSearch['response'][$i]['flags']['hosted'] == 1 ) {
echo "<p><a class='btn btn-large btn-primary text-left' href='series.php?serie=".$id."&utm_source=vikeep&utm_medium=series&utm_campaign=".$id."' title='View episodes for ".$title."'><i class='icon-eye-open icon-white'></i> Show episodes</a></p>\r\n";
}
else {
echo "<div class='alert alert-info'><h4>External</h4> This serie is not hosted at viki.com</div>\r\n";
}
echo "</div>\r\n";
}
}
?>
<!-- Start add banner -->
<?php
$propaganda = new propaganda();
$propaganda->printCurrAdd();
?>
<!-- End add banner -->
<?php
echo "<!-- Paging div -->\r\n";
echo "<ul class='pager'>\r\n";
if( $_GET['page']>1 ) {
echo "<li class='previous'>\r\n";
echo "<a href='?q=".$q."&page=".($_GET['page']-1)."'>← Previous</a>\r\n";
echo "</li>\r\n";
}
else {
echo "<li class='previous disabled'>\r\n";
echo "<a href='#'>← Previous</a>\r\n";
echo "</li>\r\n";
}
if($vikiSearch['more']) {
echo "<li class='next'>\r\n";
echo "<a href='?q=".$q."&page=".($_GET['page']+1)."'>Next →</a>\r\n";
echo "</li>\r\n";
}
else {
echo "<li class='next disabled'>\r\n";
echo "<a href='#'>Next →</a>\r\n";
echo "</li>\r\n";
}
echo "</ul>\r\n";
}
else {
echo "<p>No results.</p>";
}
}
else {
echo "<p>No results.</p>";
}
?>
</div>
<? include('inc/footer.inc.php'); ?>
</body>
</html>