forked from Niels-Be/TVShowManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
180 lines (166 loc) · 8.15 KB
/
index.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
<?php
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Pragma: no-cache'); // HTTP 1.0.
header('Expires: 0'); // Proxies.
require('config.inc.php');
require('functions.inc.php');
session_start();
@$db = new mysqli($mysql_host, $mysql_user, $mysql_pw, $mysql_db) or die($db->error);
$user = 0;
$name = '';
if(isset($_SESSION['userid'])) {
$user = $_SESSION['userid'];
$name = $_SESSION['username'];
} elseif(isset($_COOKIE['usertoken'])) {
$res = login2($_COOKIE['usertoken']);
if($res['msg'] == 'OK') {
$user = $_SESSION['userid'];
$name = $_SESSION['username'];
}
}
?>
<!DOCTYPE html>
<html ng-app="TVShowManager">
<head>
<title>TV Show Manager</title>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="style.css">
<script type="text/javascript">
var userid, username, usershows = [];
<?php if($user != 0) {
echo "userid = $user;";
echo "username = '$name';";
echo 'usershows = '.json_encode(getUserShows()).';';
} ?>
</script>
</head>
<body ng-controller="GlobalController">
<div class="container">
<div class="panel panel-default">
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<span class="navbar-brand">TV Show Manager</span>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li ng-if="!user.loggedin">
<a href="#" ng-click="openLogin()">Login or Register</a>
<script type="text/ng-template" id="loginModal.html">
<div class="modal-header">
<h3 class="modal-title">Login</h3>
</div>
<div class="modal-body">
<form ng-submit="user_login(login_username, login_password, login_stay)">
<div ng-if="success" class="alert alert-success" role="alert">{{success}}</div>
<div ng-if="error" class="alert alert-danger" role="alert">{{error}}</div>
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" ng-model="login_username" id="username" placeholder="Username">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" ng-model="login_password" id="password" placeholder="Password">
</div>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="login_stay"> Remember Me
</label>
</div>
<input type="submit" style="display: none"/>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="user_login(login_username, login_password, login_stay)">Login</button>
<button class="btn btn-warning" ng-click="user_register(login_username, login_password)">Register</button>
<button class="btn btn-danger" ng-click="closeLogin()">Cancel</button>
</div>
</script>
</li>
<li ng-if="user.loggedin"><a href="#" ng-click="user_logout();">Logout</a></li>
</ul>
<ul ng-if="user.loggedin" class="nav nav-justified">
<li><a class="navbar-brand" style="float: none; padding-top: 15px;">{{user.name}}</a></li>
</ul>
</div>
</nav>
<div class="panel-body">
<?php if(isset($res['msg']) && $res['msg'] != 'OK') echo '<div class="alert alert-danger">'.$res['msg'].'</div>'; ?>
<div class="navbar navbar-default">
<form class="navbar-form navbar-left" role="search">
<div class="form-group" uib-dropdown is-open="search.open" ng-class="{'has-error': new_error}">
<input type="text" ng-model="new_name" ng-change="show_search(new_name)" ng-focus="show_search(new_name)" class="form-control" placeholder="Add new TV Show">
<div class="dropdown-menu" ng-init="search.results={name:'jorge', year:'2'}">
<table class="table table-default">
<tr><th>Name</th><th>Year</th></tr>
<tr ng-repeat="show in search.results | limitTo:5">
<td><a popover-placement="right" uib-popover-template="'popoverImgTemplate.html'" popover-title="{{show.name}}" popover-trigger="mouseenter" ng-click="show_add(show.imdb_id, show.name)" href="#">{{show.name}}</a></td>
<!-- TODO: Add popup for image on mouse over -->
<td>{{show.year}}</td>
</tr>
</table>
</div>
</div>
<button ng-click="show_add()" class="btn btn-success"><span class="glyphicon glyphicon-plus"></span> Add</button>
</form>
</div>
<script id="popoverImgTemplate.html" type="text/ng-template">
<img src={{show.img}} class="img-responsive">
</script>
<div class="panel panel-default">
<table class="table table-default" style="table-layout: fixed">
<tr>
<th style="width: 24px">
<a style="color: #333;" href="#" ng-click="show_predicate='favourite';show_reverse=!show_reverse;">
<span class="glyphicon glyphicon-star{{show_reverse?'':'-empty'}}"></span>
</a>
</th>
<th style="width: 30%">
<a style="color: #333;" href="#" ng-click="show_predicate='name';show_reverse=!show_reverse;">Name</a>
<small ng-if="show_predicate=='name'" class="glyphicon glyphicon-chevron-{{show_reverse?'down':'up'}}"></small>
</th>
<th style="width: 15%">Last Episode</th>
<th style="width: 15%">
<a style="color: #333;" href="#" ng-click="show_predicate='status';show_reverse=!show_reverse;">Status</a>
<small ng-if="show_predicate=='status'" class="glyphicon glyphicon-chevron-{{show_reverse?'down':'up'}}"></small>
</th>
<th style="width: 35%">Next Episode</th>
<th style="width: 96px"></th>
</tr>
<tr ng-repeat="show in shows | orderBy:get_show_predicate():show_reverse" class="{{show.class}}">
<td><a href="#" ng-click="show.setFavourite()">
<span style="color: #333;" class="glyphicon glyphicon-star{{show.favourite?'':'-empty'}}"></span></a>
</td>
<td>{{show.name}}</td>
<td>
{{show.last_ep}}
<button ng-if="!show.disabled" ng-disabled="show.first" ng-mousedown="show_start_dec(show)" class="btn btn-xs btn-primary"><span class="glyphicon glyphicon-chevron-left"></span></button>
<button ng-if="!show.disabled" ng-disabled="show.ended" ng-mousedown="show_start_inc(show)" class="btn btn-xs btn-primary"><span class="glyphicon glyphicon-chevron-right"></span></button>
</td>
<td>{{show.status}}</td>
<td>{{show.next_ep}}</td>
<td>
<button tooltip="Refresh" ng-click="show.refresh(true)" class="btn btn-xs btn-primary"><span class="glyphicon glyphicon-refresh {{show.loading?'gly-spin':''}}"></span></button>
<button tooltip="Enable" ng-if="show.done" ng-disabled="show.ended" ng-click="show.activate()" class="btn btn-xs btn-success"><span class="glyphicon glyphicon-new-window"></span></button>
<button tooltip="Disable" ng-if="!show.done" ng-disabled="show.ended" ng-click="show.activate()" class="btn btn-xs btn-success"><span class="glyphicon glyphicon-check"></span></button>
<button tooltip="Delete" ng-click="show_delete(show)" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span></button>
</td>
</tr>
</table>
</div>
</div>
<div class="panel-footer">
<div style="position: absolute;">© WaeCo-Soft 2015</div>
<div style="text-align: center;">Powerd by <a href="http://thetvdb.com/">TheTVDB.com</a></div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-resource.min.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.0.3.js"></script>
<script src="app.js"></script>
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script> -->
</body>
</html>