-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
83 lines (72 loc) · 2.2 KB
/
login.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
<?php
include_once 'page.php';
class LoginPage extends Page
{
public $users;
public function __construct()
{
$this->authRequired = false;
parent::__construct('Login');
$this->users = getUsersPublic();
$this->handleRequest();
}
private function handleRequest()
{
if (isset($_GET['id'])) {
$san_id = htmlspecialchars($_GET['id']);
$san_name = htmlspecialchars($_GET['name']);
$this->auth->login2(explode(",", $san_id), explode(",", $san_name));
header('Location: index.php');
die();
}
}
public function printContent()
{
global $api_url, $api_key;
if (!$api_url) {
?>
ERROR: $api_url not set in secrets.php<br />
<?
$error = true;
}
if (!$api_key) {
?>
ERROR: $api_key not set in secrets.php</br>
<?
$error = true;
}
if (count($this->users) == 0) {
?>
ERROR: No public users returned from Jellyfin</br>
<?
$error = true;
}
if ($error) {
exit;
}
if ($this->auth->IsAuthenticated()) {
?>
<p>User is currently set to:</p>
<?
foreach ($this->auth->userIDs as $userID) {
?><img src="<?=getImageURL($userID, new ImageParams(100, 100), null, 'Users') ?>" width="100" height="100" /><?php
}
}
?>
<p>Click on name to set user currently watching.</p>
<?
if (count($this->users) > 1) {
//if more than 1 user, display first 2 users together in order to watch shows together
?>
<p><a name='0' href="login.php?id=<?= $this->users[1]->Id ?>,<?= $this->users[0]->Id ?>&name=<?= $this->users[1]->Name ?>,<?= $this->users[0]->Name ?>"><?= $this->users[1]->Name ?>,<?= $this->users[0]->Name ?></a></p>
<?
}
foreach ($this->users as $user) {
?>
<p><a href="login.php?id=<?= $user->Id ?>&name=<?= $user->Name ?>"><?= $user->Name ?></a></p>
<?
}
}
}
$pageObj = new LoginPage();
$pageObj->render();