forked from MattsShack/Plex-Movie-Poster-Display
-
Notifications
You must be signed in to change notification settings - Fork 1
/
schedule.php
168 lines (165 loc) · 7.26 KB
/
schedule.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
<!DOCTYPE html>
<?php
$ch_file="";
include('./control.php');
include('./config.php');
$tvlocations = glob($pseudochannelTrim . "*", GLOB_ONLYDIR);
$boxes = '';
foreach ($tvlocations as $tvbox) {
if ($tvbox . "/" == $pseudochannelMaster) {
$boxname = $configClientName;
$boxes .= "<li><a href='schedule.php?tv=$boxname' class='gn-icon gn-icon-videos'>TV: $boxname</a></li>";
} else {
$boxname = explode("_", $tvbox);
$boxes .= "<li><a href='schedule.php?tv=$boxname[1]' class='gn-icon gn-icon-videos'>TV: $boxname[1]</a></li>";
}
}
?>
<html lang="en" class="no-js" style="height:100%">
<head>
<script
src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous">
</script>
<script>
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const tv = urlParams.get('tv');
if (tv != "null") {
topbar = "topbar.php?tv="+tv;
getdata = "getData.php?tv="+tv;
getclock = "getClock.php?tv="+tv;
} else {
topbar = "topbar.php";
getdata = "getData.php";
getclock = "getClock.php";
}
$(document).ready( function() {
$("#topbar").load(topbar);
$.getJSON(getdata,function(data) {
$.each(data, function(key,val) {
$('#'+key).html(val);
});
});
});
$(document).ready(
function() {
setInterval(function() {
$.getJSON(getdata,function(data) {
$.each(data, function(key, val) {
$('#'+key).html(val);
});
});
}, 60000);
});
$(document).ready(
function() {
setInterval(function() {
$.getJSON(getclock,function(data) {
$.each(data, function(key, val) {
$('#'+key).html(val);
});
});
}, 5000);
});
</script>
<style type="text/css">a {text-decoration: none}</style>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FakeTV Guide and Control</title>
<meta name="description" content="A page that works with Pseudo Channel and Plex to display now playing data and allow viewing and navigation of Pseudo Channel schedules" />
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" type="text/css" href="css/normalize.css" />
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<link rel="stylesheet" type="text/css" href="css/component.css" />
<link rel="apple-touch-icon" sizes="180x180" href="assets/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="assets/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="assets/favicon-16x16.png">
<link rel="manifest" href="assets/site.webmanifest">
<link rel="mask-icon" href="assets/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="assets/favicon.ico">
<meta name="msapplication-TileColor" content="#2b5797">
<meta name="msapplication-config" content="assets/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="js/classie.js"></script>
<script src="js/gnmenu.js"></script>
<script src="js/modernizr.custom.js"></script>
<script>
var query = window.location.search.substring(1)
if(query.length) {
if(window.history != undefined && window.history.pushState != undefined) {
window.history.pushState({}, document.title, window.location.pathname);
}
}
</script>
<script language="JavaScript">
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false );
xmlHttp.send( null );
return xmlHttp.responseText;
}
</script>
</head>
<body>
<?php
if (isset($_GET['ch'])) {
$id= "ch" . $_GET['ch'];
} else {
$id="rightnow";
}
if (isset($_GET['tv'])) {
$tv = $_GET['tv'];
if ($tv != "null") {
$plexClientName = $_GET['tv'];
$urlstring = "tv=" . $_GET['tv'] . "&";
$urlstring = $urlstring;
if ($_GET['tv'] != $configClientName) {
$pseudochannel = $pseudochannelTrim . "_" . $_GET['tv'] . "/";
$pseudochannel = trim($pseudochannel);
}
} else {
$tv = plexClientName;
$urlstring = "";
}
} else {
$tv = $plexClientName;
}
if (isset($_GET['time'])) {
$time = $_GET['time'];
} else {
$time = "0";
}
$dircontents=array();
//GET ALL PSEUDO CHANNEL DAILY SCHEDULE XML FILE LOCATIONS
$lsgrep = exec("find ". $pseudochannelMaster . "pseudo-channel_*/schedules | grep xml | tr '\n' ','"); //list the paths of all daily schedule xml files in as comma sparated
$dircontents = explode(",", $lsgrep); //write file locations into an array
$scheduleTable = "<table width='100%' max-width='100%' class='schedule-table'><thead><tr width='100%'><th width='4%' max-width='4%'> Ch. </th><th colspan='1' width='8%' max-width='8%' id=nowtime>Now</th><th colspan='1' width='8%' max-width='8%' id=timePlus15>+15</th><th colspan='1' width='8%' max-width='8%' id=timePlus30>+30</th><th colspan='1' width='8%' max-width='8%' id=timePlus45>+45</th><th colspan='1' max-width='8%' width='8%' id=timePlus60>+60</th><th colspan='1' width='8%' max-width='8%' id=timePlus75>+75</th><th colspan='1' max-width='8%' width='8%' id=timePlus90>+90</th><th colspan='1' width='8%' max-width='8%' id=timePlus105>+105</th><th colspan='1' max-width='8%' width='8%' id=timePlus120>+120</th><th colspan='1' width='8%' max-width='8%' id=timePlus135>+135</th><th colspan='1' max-width='8%' width='8%' id=timePlus150>+150</th><th colspan='1' width='8%' max-width='8%' id=timePlus165>+165</th></tr></thead><tbody>";
$nowPlayingDisplay = "<p style='color:yellow'>$plexClientName <span style='color:white' id='nowplaying' class='container'>Please Stand By</span></p>";
foreach ($dircontents as $xmlfile) { //do the following for each xml schedule file
$ch_file = str_replace($pseudochannelMaster . "pseudo-channel_", "ch", $xmlfile); //get channel number
$ch_file = str_replace("/schedules/pseudo_schedule.xml", "", $ch_file);
$ch_number = str_replace("ch", "", $ch_file);
$ch_row = "row" . $ch_number;
$ch_cell = "chan" . $ch_number;
if($xmlfile){
$xmldata = simplexml_load_file($xmlfile); //load the xml schedule file
}
if($xmldata){
$scheduleTable .= "<tr class='schedule-table' max-width='100%' min-width='100%' width='100%' id='$ch_row'></tr>";
}
}
$scheduleTable .= "</tbody></table>";
?>
<div class="container main-container">
<?php echo $nowPlayingDisplay;
echo $scheduleTable; ?>
</br><a href="schedule.php?action=updateweb&<?php echo $urlstring; ?>" style="color:white" href="">Update Channel Schedule Data →</a>
</div><!-- /container -->
<div id="topbar" name="topbar"></div>
</body>
</html>