-
Notifications
You must be signed in to change notification settings - Fork 13
/
tvshow.php
161 lines (145 loc) · 5.64 KB
/
tvshow.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
150
151
152
153
154
155
156
157
158
159
160
161
<?php
require_once("./config.php");
require_once("./functions.php");
defineSecurityHeaders();
sessionStartSecurely();
require_once("./db.php");
if(ENABLE_AUTHENTICATION){
if(!isAuthenticated()){
header("Location: login.php");
exit;
}
}
// Clean GET vars for filter
$title = (isset($_GET["title"]) && !empty($_GET["title"])) ? substr($db->quote(trim(strval($_GET["title"]))),1,-1) : "";
$genre = (isset($_GET["genre"]) && !empty($_GET["genre"])) ? substr($db->quote(trim(strval($_GET["genre"]))),1,-1) : "";
$studio = (isset($_GET["studio"]) && !empty($_GET["studio"])) ? substr($db->quote(trim(strval($_GET["studio"]))),1,-1) : "";
$offset = (isset($_GET["offset"]) && trim(strval($_GET["offset"])) != "" && intval($_GET["offset"]) >= 0) ? intval($_GET["offset"]) : 0;
// Compute SQL filters
$filters = array();
if(!empty($title)){
$filters[] = "(c00 LIKE '%" . $title . "%' OR c01 LIKE '%" . $title . "%')";
}
if(!empty($genre)){
$filters[] = "c08 LIKE '%" . $genre . "%'";
}
if(!empty($studio)){
$filters[] = "c14 LIKE '%" . $studio . "%'";
}
if(count($filters) > 0){
$sql = "SELECT
" . NAX_TVSHOW_VIEW . ".idShow,
" . NAX_TVSHOW_VIEW . ".c00 AS tvshowTitle,
" . NAX_TVSHOW_VIEW . ".c01 AS tvshowSynopsis,
" . NAX_TVSHOW_VIEW . ".totalCount,
" . NAX_TVSHOW_VIEW . ".watchedcount,
ExtractValue(c06,'/thumb[@season=\"-1\"]') AS thumb,
ExtractValue(c11,'/fanart/@url') AS fanartURL,
ExtractValue(c11,'/fanart/thumb[position()=1]/@preview') AS fanartValue
FROM " . NAX_TVSHOW_VIEW . " WHERE ";
$multi = false;
foreach($filters as $filter){
if($multi)
$sql .= "AND";
$sql .= " " . $filter . " ";
$multi = true;
}
$sql .= "ORDER BY c00 ASC LIMIT $offset," . DEFAULT_ENTRIES_DISPLAY . ";";
} else {
$sql = "SELECT
" . NAX_TVSHOW_VIEW . ".idShow,
" . NAX_TVSHOW_VIEW . ".c00 AS tvshowTitle,
" . NAX_TVSHOW_VIEW . ".c01 AS tvshowSynopsis,
" . NAX_TVSHOW_VIEW . ".totalCount,
" . NAX_TVSHOW_VIEW . ".watchedcount,
ExtractValue(c06,'/thumb[position()=1]') AS thumb,
ExtractValue(c11,'/fanart/@url') AS fanartURL,
ExtractValue(c11,'/fanart/thumb[position()=1]/@preview') AS fanartValue,
ExtractValue(c11,'/fanart/thumb[position()=1]') AS fanartURL2
FROM " . NAX_TVSHOW_VIEW . " ORDER BY dateAdded DESC LIMIT $offset," . DEFAULT_ENTRIES_DISPLAY . ";";
}
if(isset($_GET["id"]) && isset($_GET["action"]) && ($_GET["action"] === "toWatched" || $_GET["action"] === "toUnwatched")){
$id = intval($_GET["id"]);
$toStatus = strval($_GET["action"]);
if($id > 0)
changeStatusEpisode($id, $toStatus);
exit;
}
if(isset($_GET["id"]) && isset($_GET["action"]) && $_GET["action"] == "detail"){
$id = intval($_GET["id"]);
if($id > 0)
getDetailsEntryTvShow($id);
exit;
}
if(isset($_GET["offset"])){
$offset = intval($_GET["offset"]);
if($offset < 0)
$offset = 0;
sleep(1);
getEntriesTvShow($sql);
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma-directive" content="no-cache" />
<meta http-equiv="Cache-Directive" content="no-cache" />
<meta name="robots" content="noindex,follow" />
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />
<title>KodiWebPortal <?php echo KODI_WEB_PORTAL_VERSION; ?></title>
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="https://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<a href="index.php" alt="<?php echo LOGO_MOVIES_LABEL; ?>" title="<?php echo LOGO_MOVIES_LABEL; ?>"><img class="image-nav" src="./images/cinema-logo.png" style="margin-top:30px;" /></a>
<a href="tvshow.php" alt="<?php echo LOGO_TVSHOWS_LABEL; ?>" title="<?php echo LOGO_TVSHOWS_LABEL; ?>"><img class="image-nav image-nav-move" src="./images/tvshow-logo.png" style="margin-top:160px;" /></a>
<div id="opacity"></div>
<div id="search">
<form action="" method="GET">
<?php
$stmt = $db->query("SELECT DISTINCT COUNT(*) FROM " . NAX_TVSHOW_VIEW . ";");
$count = $stmt->fetch();
echo "<b>[ " . $count[0] . " " . TVSHOWS_LABEL . " ]</b> - ";
?>
<label for="title"><?php echo TITLE_LABEL; ?></label>
<input id="title" type="text" name="title" placeholder="Vikings" value="<?php echo htmlentities(stripcslashes($title)); ?>" />
<label for="genre"><?php echo GENRE_LABEL; ?></label>
<select id="genre" name="genre">
<option value="">*</option>
<?php
$gs = getAllGenres("tvshow");
foreach($gs as $g){
if(stripcslashes($genre) == $g)
echo "<option value='" . $g . "' selected>" . $g . "</option>";
else
echo "<option value='" . $g . "'>" . $g . "</option>";
}
?>
</select>
<label for="studio"><?php echo STUDIO_LABEL; ?></label>
<select id="studio" name="studio">
<option value="">*</option>
<?php
$ss = getAllStudios();
foreach($ss as $s){
if(stripcslashes($studio) == $s)
echo "<option value='" . $s . "' selected>" . $s . "</option>";
else
echo "<option value='" . $s . "'>" . $s . "</option>";
}
?>
</select>
<input type="submit" value="<?php echo SEARCH_LABEL; ?>" />
<input type="button" onclick="document.location=document.location.href.replace(document.location.search, '');" value="<?php echo RESET_LABEL; ?>" />
<a href="index.php?action=logout"><img src="./images/logout.png" title="<?php echo LOGOUT_LABEL; ?>" alt="<?php echo LOGOUT_LABEL; ?>" style="float:right;" /></a>
</form>
</div>
<div id="entries">
<script type="text/javascript">getEntries();</script>
</div>
</body>
</html>