-
Notifications
You must be signed in to change notification settings - Fork 40
/
users.php
216 lines (165 loc) · 6.91 KB
/
users.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>plexWatch</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- css -->
<link href="css/plexwatch.css" rel="stylesheet">
<link href="css/plexwatch-tables.css" rel="stylesheet">
<link href="css/font-awesome.min.css" rel="stylesheet" >
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
.sidebar-nav {
padding: 9px 0;
}
</style>
<!-- touch icons -->
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="apple-touch-icon" href="images/icon_iphone.png">
<link rel="apple-touch-icon" sizes="72x72" href="images/icon_ipad.png">
<link rel="apple-touch-icon" sizes="114x114" href="images/[email protected]">
<link rel="apple-touch-icon" sizes="144x144" href="images/[email protected]">
</head>
<body>
<div class="container">
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<a href="index.php"><div class="logo hidden-phone"></div></a>
<ul class="nav">
<li><a href="index.php"><i class="icon-2x icon-home icon-white" data-toggle="tooltip" data-placement="bottom" title="Home" id="home"></i></a></li>
<li><a href="history.php"><i class="icon-2x icon-calendar icon-white" data-toggle="tooltip" data-placement="bottom" title="History" id="history"></i></a></li>
<li><a href="stats.php"><i class="icon-2x icon-tasks icon-white" data-toggle="tooltip" data-placement="bottom" title="Stats" id="stats"></i></a></li>
<li class="active"><a href="users.php"><i class="icon-2x icon-group icon-white" data-toggle="tooltip" data-placement="bottom" title="Users" id="users"></i></a></li>
<li><a href="charts.php"><i class="icon-2x icon-bar-chart icon-white" data-toggle="tooltip" data-placement="bottom" title="Charts" id="charts"></i></a></li>
<li><a href="settings.php"><i class="icon-2x icon-wrench icon-white" data-toggle="tooltip" data-placement="bottom" title="Settings" id="settings"></i></a></li>
</ul>
</div>
</div>
</div>
<div class="clear"></div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div class='wellheader'>
<div class="dashboard-wellheader-no-chevron">
<h2><i class="icon-large icon-group icon-white"></i> Users</h2>
</div>
</div>
<?php
$guisettingsFile = "config/config.php";
if (file_exists($guisettingsFile)) {
require_once(dirname(__FILE__) . '/config/config.php');
}else{
header("Location: settings.php");
}
if ($plexWatch['https'] == 'yes') {
$plexWatchPmsUrl = "https://".$plexWatch['pmsIp'].":".$plexWatch['pmsHttpsPort']."";
}else if ($plexWatch['https'] == 'no') {
$plexWatchPmsUrl = "http://".$plexWatch['pmsIp'].":".$plexWatch['pmsHttpPort']."";
}
if (!empty($plexWatch['myPlexAuthToken'])) {
$myPlexAuthToken = $plexWatch['myPlexAuthToken'];
}else{
$myPlexAuthToken = '';
}
date_default_timezone_set(@date_default_timezone_get());
$db = dbconnect();
if ($plexWatch['userHistoryGrouping'] == "yes") {
$plexWatchDbTable = "grouped";
}else if ($plexWatch['userHistoryGrouping'] == "no") {
$plexWatchDbTable = "processed";
}
$users = $db->query("SELECT COUNT(title) as plays, user, time, SUM(time) as timeTotal, SUM(stopped) as stoppedTotal, SUM(paused_counter) as paused_counterTotal, platform, ip_address, xml FROM ".$plexWatchDbTable." GROUP BY user ORDER BY user COLLATE NOCASE") or die ("Failed to access plexWatch database. Please check your settings.");
echo "<div class='wellbg'>";
echo "<table id='usersTable' class='display'>";
echo "<thead>";
echo "<tr>";
echo "<th align='right'></th>";
echo "<th align='left'>User </th>";
echo "<th align='left'>Last Seen </th>";
echo "<th align='left'>Last Known IP </th>";
echo "<th align='left'>Total Plays</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
// Run through each feed item
while ($user = $users->fetchArray()) {
$userXml = simplexml_load_string($user['xml']) ;
echo "<tr>";
echo "<td align='right' width='40px'>";
if (empty($userXml->User['thumb'])) {
echo "<div class='users-poster-face'><a href='user.php?user=".$user['user']."'><img src='images/gravatar-default-80x80.png' /></a></div>";
}else{
echo "<div class='users-poster-face'><a href='user.php?user=".$user['user']."'><img src='".$userXml->User['thumb']."' onerror=\"this.src='images/gravatar-default-80x80.png'\" /></a></div>";
}
echo "</td>";
echo "<td>";
echo "<div class='users-name'><a href='user.php?user=".$user['user']."'> ".FriendlyName($user['user'],$user['platform'])."</a> </div>";
echo "</td>";
require_once(dirname(__FILE__) . '/includes/timeago.php');
$lastSeenTime = $user['time'];
echo "<td>".TimeAgo($lastSeenTime)."</td>";
echo "<td>".$user['ip_address']."</td>";
echo "<td>".$user['plays']."</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
?>
</div>
</div>
</div><!--/.fluid-row-->
<footer>
</footer>
</div><!--/.fluid-container-->
<!-- javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/jquery-2.0.3.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/jquery.dataTables.js"></script>
<script src="js/jquery.dataTables.plugin.bootstrap_pagination.js"></script>
<script>
$(document).ready(function() {
var oTable = $('#usersTable').dataTable( {
"bPaginate": false,
"bLengthChange": true,
"bFilter": false,
"bSort": false,
"bInfo": true,
"bAutoWidth": true,
"aaSorting": [[ 0, "asc" ]],
"bStateSave": false,
"bSortClasses": true,
"sPaginationType": "bootstrap"
} );
} );
</script>
<script>
$(document).ready(function() {
$('#home').tooltip();
});
$(document).ready(function() {
$('#history').tooltip();
});
$(document).ready(function() {
$('#users').tooltip();
});
$(document).ready(function() {
$('#charts').tooltip();
});
$(document).ready(function() {
$('#settings').tooltip();
});
$(document).ready(function() {
$('#stats').tooltip();
});
</script>
</body>
</html>