-
Notifications
You must be signed in to change notification settings - Fork 0
/
ListMovie.php
159 lines (144 loc) · 5.12 KB
/
ListMovie.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
<?php
session_start();
include "Settings.php";
$sql_stmt = false;
$row_count = 0;
$first = true;
function Rating_32($rating, $votes)
{
$arr_bgc = array("#63BE7B","#85C87D","#A8D27F","#CBDC81","#EDE683","#FFDD82","#FDC07C","#FCA377","#FA8671","#F8696B");
$txt_vot = number_format($votes,0,",",".");
print "<div class=\"cRating\">";
print " <img src=\"images/rating.png\" class=\"cRatingIcon\" title=\"$txt_vot\" style=\"background-color: ".$arr_bgc[round($rating)].";\">\n";
print " <div title=\"$txt_vot\" class=\"cRatingText\">".number_format($rating,1,",",".")."</div>\n";
print "</div>\n";
}
if (isset($_POST['idGenre']))
{
$sql_stmt = 'SELECT * FROM movie_view JOIN genre_link ON genre_link.media_id = movie_view.idMovie WHERE genre_link.genre_id='.$_POST['idGenre'].' ORDER BY c02 LIMIT '.$SQL_LIMIT.' OFFSET 0';
}
elseif (isset($_POST['idTag']))
{
$sql_stmt = 'SELECT * FROM movie_view JOIN tag_link ON tag_link.media_id = movie_view.idMovie WHERE tag_link.tag_id='.$_POST['idTag'].' ORDER BY c02 LIMIT '.$SQL_LIMIT.' OFFSET 0';
}
elseif (isset($_POST['cXTitle']))
{
$sql_stmt = 'SELECT * FROM movie_view WHERE c02 LIKE \''.$_POST['cXTitle'].'%\' ORDER BY c02 LIMIT '.$SQL_LIMIT.' OFFSET 0';
}
elseif (isset($_POST['idRating']))
{
$sql_stmt = 'SELECT * FROM movie_view WHERE rating LIKE \''.$_POST['idRating'].'%\' ORDER BY c02 LIMIT '.$SQL_LIMIT.' OFFSET 0';
}
elseif (isset($_POST['idMovie']))
{
$sql_stmt = 'SELECT * FROM movie_view WHERE idMovie IN ('.$_POST['idMovie'].') ORDER BY c02 LIMIT '.$SQL_LIMIT.' OFFSET 0';
}
elseif (isset($_POST['cXDate']) && (strcasecmp($_POST['cXDate'],'Played') == 0))
{
$sql_stmt = 'SELECT * FROM movie_view ORDER BY lastPlayed DESC LIMIT '.$SQL_LIMIT.' OFFSET 0';
}
elseif (isset($_POST['cXDate']) && (strcasecmp($_POST['cXDate'],'Added') == 0))
{
$sql_stmt = 'SELECT * FROM movie_view ORDER BY dateAdded DESC LIMIT '.$SQL_LIMIT.' OFFSET 0';
}
elseif (isset($_POST['next']))
{
$arr = explode(' ', $_SESSION['SQL_STMT']);
for ($i=0; $i<count($arr); $i++)
{
if (0 == strcasecmp($arr[$i], 'LIMIT'))
{
$LIMIT = $arr[$i+1];
}
if (0 == strcasecmp($arr[$i], 'OFFSET'))
{
$arr[$i+1] += $LIMIT;
}
}
$sql_stmt = implode(' ', $arr);
$first = false;
}
$_SESSION['SQL_STMT'] = $sql_stmt;
#DEBUG#
print '<script>console.log("'.$sql_stmt.'")</script>';
if ($sql_stmt)
{
$db = new SQLite3($SQL_MOVIE);
$res = $db->query($sql_stmt);
if ($first) print '<div id="movieLibraryContainer" class="contentContainer">';
while($row = $res->fetchArray(SQLITE3_ASSOC))
{
$row_count++;
$title = $row['c00'];
if (strlen($title) > 26)
{
$title = substr($title, 0, 23)."...";
}
# $first = strpos($row['c08'],"preview=");
$first = strpos($row['c08'],'aspect="poster" preview=');
if ($first === false)
{
$cover = "images/DefaultVideo.png";
}
else
{
# $first+=8;
$first+=24;
$last = strpos($row['c08'],">",$first);
if ($last === false)
{
$cover = substr($row['c08'], $first);
}
else
{
$cover = substr($row['c08'], $first, $last-$first);
}
}
if ($row['lastPlayed']) print '<div class="divTST cPlayed">';
else print '<div class="divTST">';
$cover = str_replace('/w500/','/w185/',$cover);
print '<div class="moviePoster" data-id="'.$row['idMovie'].'">';
print "<img class=\"cover\" alt=\"".$title."\" src=".$cover.">";
# if ($row['lastPlayed']) print '<div class="movieIcon"><img class="cInfo" src="images/status_2.png" title="'.$row['lastPlayed'].'"></div>';
print '<div class="movieIcon">';
Rating_32($row['rating'], $row['votes']);
if (stripos($row['strFileName'], "3D" ))
{
print '<img class="cInfo" src="images/3D.png">';
}
if ($row['lastPlayed']) print '<img class="cInfo" src="images/status_2.png" title="'.$row['lastPlayed'].'">';
print '</div>';
print '<div class="desc">'.$title.'</div>';
print '</div>'; # moviePoster
print '<div class="movieDetail">';
# echo '<B>'.$row['c00'].' ('.$row['c07'].')</B>';
echo '<B>'.$row['c00'].' ('.substr($row['premiered'],0,4).')</B>';
echo '<TABLE>';
# echo '<TR><TD>Rating:</TD><TD>'.substr($row['c05'],0,3).'</TD></TR>'; # imdbRating
echo '<TR><TD>Rating:</TD><TD>'.substr($row['rating'],0,3).' ('.number_format($row['votes']).')</TD></TR>'; # imdbRating
echo '<TR><TD>Genre:</TD><TD>'.$row['c14'].'</TD></TR>'; # genres
echo '<TR><TD>Director:</TD><TD>'.$row['c15'].'</TD></TR>';
$str_actors = '';
$sql_stmt = 'SELECT name FROM actor JOIN actor_link ON actor.actor_id = actor_link.actor_id WHERE actor_link.media_id = '.$row['idMovie'].' ORDER BY actor_link.cast_order LIMIT 4';
$res2 = $db->query($sql_stmt);
while($row2 = $res2->fetchArray(SQLITE3_ASSOC))
{
if (empty($str_actors)) $str_actors = $row2['name'];
else $str_actors .= ', '.$row2['name'];
}
echo '<TR><TD>Actors:</TD><TD>'.$str_actors.'</TD></TR>';
echo '</TABLE>';
echo $row['c01']; # overview
print '</div>'; # movieDetail
print '</div>'; # divTST
}
if ($row_count == $SQL_LIMIT)
{
echo '<div class="divTST" id="nextMovie">';
echo '<img class="cover" src="images/nextVideo.png" height="278" width="185">';
echo '</div>';
}
if ($first) print "</div>"; # contentContainer
$db->close();
}
?>