mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2025-12-15 15:53:50 +00:00
Add files via upload
This commit is contained in:
155
adminConfig.php
Normal file
155
adminConfig.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<!DOCTYPE html>
|
||||
<?php
|
||||
session_start();
|
||||
include('./control.php');
|
||||
include('./config.php');
|
||||
$tvlocations = glob($pseudochannelTrim . "*", GLOB_ONLYDIR);
|
||||
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 = trim($tvbox, $pseudochannelTrim . "_");
|
||||
$boxes .= "<li><a href='schedule.php?tv=$boxname' class='gn-icon gn-icon-videos'>TV: $boxname</a></li>";
|
||||
}
|
||||
}
|
||||
$clientcount = 1;
|
||||
foreach ($clientsxml->Server as $key => $xmlarray) {
|
||||
$clientinfodump .= "<a class='dripdrop-title'>Plex Client #$clientcount</a></br><a class='dripdrop-header'>Name:</a></br><a href='schedule.php?tv=$xmlarray[name]' style='color:white'> $xmlarray[name] </a></br></br>";
|
||||
$clientinfodump .= "<a class='dripdrop-header'>Local IP Address:</a></br><a> $xmlarray[address] </a></br></br>";
|
||||
$clientinfodump .= "<a class='dripdrop-header'>Unique Identifier</a></br><a> $xmlarray[machineIdentifier] </a></br></br>";
|
||||
$clientcount = $clientcount + 1;
|
||||
}
|
||||
?>
|
||||
<html lang="en" class="no-js" style="height:100%">
|
||||
<head>
|
||||
<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="js/modernizr.custom.js"></script>
|
||||
<script type="text/javascript" src="assets/js/jquery-3.0.0.min.js"></script>
|
||||
<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(
|
||||
function() {
|
||||
setInterval(function() {
|
||||
$.getJSON('getData.php',function(data) {
|
||||
$.each(data, function(key, val) {
|
||||
$('#'+key).html(val);
|
||||
});
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
</script>
|
||||
<script language="JavaScript">
|
||||
function channel() {
|
||||
<?php $id="$ch_file"; ?>
|
||||
}
|
||||
setInterval(autorefresh_div, 3000);
|
||||
function httpGet(theUrl)
|
||||
{
|
||||
var xmlHttp = new XMLHttpRequest();
|
||||
xmlHttp.open( "GET", theUrl, false );
|
||||
xmlHttp.send( null );
|
||||
return xmlHttp.responseText;
|
||||
}
|
||||
</script>
|
||||
<?php if (!empty($_POST)) {
|
||||
$myfile = fopen("psConfig.php", "w") or die("Unable to open file!");
|
||||
$txt = "<?php //Pseudo Channel
|
||||
\$pseudochannel = '$_POST[pseudochannel]';
|
||||
\n//Display Type
|
||||
\$DisplayType = '$_POST[DisplayType]';
|
||||
?>
|
||||
";
|
||||
echo $txt;
|
||||
fwrite($myfile, $txt);
|
||||
fclose($myfile);
|
||||
$update = "1";
|
||||
|
||||
} ?>
|
||||
<?php include_once('config.php');
|
||||
if ($DisplayType == "half" || $_POST['DisplayType'] == "half") {
|
||||
$halfstatus = "checked";
|
||||
$fullstatus = "";
|
||||
} elseif ($DisplayType =="full" || $_POST['DisplayType'] == "full") {
|
||||
$halfstatus = "";
|
||||
$fullstatus = "checked";
|
||||
} else {
|
||||
$halfstatus = "";
|
||||
$fullstatus = "";
|
||||
}
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||
<div id="container">
|
||||
<div class="container" style="position:absolute;top:60px" scrolling="no"><h3 style="color:white" class="gn-icon gn-icon-cog">Settings</h3>
|
||||
<div class="container" name="schedulearea" type="text/html";>
|
||||
<form method="post">
|
||||
<div class="container" name="schedulearea" type="text/html";>
|
||||
<label style="padding-left:10px;padding-right:5px;color:white">Pseudo Channel Directory: </label></br>
|
||||
<input type="text" style="padding-right:50px" name="pseudochannel" value="<?php echo "$pseudochannelMaster"; ?>"></br></br>
|
||||
<label style="padding-left:10px;color:white">Status Screen Display Type:</label></br>
|
||||
<a style="padding-left:50px;color:white"><input type="radio" name="DisplayType" value="full" style="padding-left:20px" <?php echo "$fullstatus"; ?> >Full</input></a>
|
||||
<a style="padding-left:20px;color:white"><input type="radio" name="DisplayType" value="half" style="padding-left:20px" <?php echo "$halfstatus"; ?> >Half</input></a></div>
|
||||
<div style="padding-left:50px">
|
||||
<input class="btn btn-primary"type="submit" value="Save Changes" name='submit' />
|
||||
</div>
|
||||
<?php if($update == "1") {
|
||||
echo "<div class='alert alert-info' style='color:white;padding-left:50px'>Settings File Updated.</div>";
|
||||
} ?>
|
||||
</form>
|
||||
</div>
|
||||
<div class="dripdrop" style="color:white;padding-left:10px"></br>
|
||||
<a class="dripdrop-title">Plex Server Data</a></br></br>
|
||||
<a class="dripdrop-header">IP Address:</a></br>
|
||||
<a><?php echo $plexServer; ?></a></br></br>
|
||||
<a class="dripdrop-header">Web Port:</a></br>
|
||||
<a><?php echo $plexport; ?></a></br></br>
|
||||
<a class="dripdrop-header">Web Token:</a></br>
|
||||
<a><?php echo $plexToken; ?></a></br></br>
|
||||
<?php echo $clientinfodump; ?>
|
||||
</div>
|
||||
<ul id="gn-menu" class="gn-menu-main">
|
||||
<li class="gn-trigger">
|
||||
<a class="gn-icon gn-icon-menu"><span>Menu</span></a>
|
||||
<nav class="gn-menu-wrapper">
|
||||
<div class="gn-scroller">
|
||||
<ul class="gn-menu">
|
||||
<li><a href="index.php" class="gn-icon gn-icon-help">Home</a></li>
|
||||
<li><a href="adminConfig.php?<?php echo $urlstring; ?>" class="gn-icon gn-icon-cog">Settings</a></li>
|
||||
<?php echo $boxes; ?>
|
||||
</ul>
|
||||
</div><!-- /gn-scroller -->
|
||||
</nav>
|
||||
</li>
|
||||
<li><a class="codrops-icon" href="schedule.php?action=up?<?php echo $urlstring; ?>">Up</a></li>
|
||||
<li><a class="codrops-icon" href="schedule.php?action=down?<?php echo $urlstring; ?>">Down</a></li>
|
||||
<li><a class="codrops-icon" href="schedule.php?action=stop?<?php echo $urlstring; ?>">Stop</a></li>
|
||||
<li></li>
|
||||
</ul>
|
||||
</div><!-- /container -->
|
||||
<script src="js/classie.js"></script>
|
||||
<script src="js/gnmenu.js"></script>
|
||||
<script>
|
||||
new gnMenu( document.getElementById( 'gn-menu' ) );
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
64
config.php
Normal file
64
config.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
session_start();
|
||||
include('./psConfig.php');
|
||||
$get_plex_token = array();
|
||||
$plexServer_url = array();
|
||||
$getConfig = array();
|
||||
$clientsxml = array();
|
||||
$clientdata = array();
|
||||
//Pseudo Channel Config File
|
||||
$pseudoConfig = $pseudochannel . "pseudo_config.py";
|
||||
$getConfig = file_get_contents($pseudoConfig);
|
||||
$getConfig = explode("\n",$getConfig);
|
||||
|
||||
//Get Plex data from plex_token file in Pseudo Channel
|
||||
$plex_token = $pseudochannel . "plex_token.py";
|
||||
$get_token = file_get_contents($plex_token);
|
||||
$get_plex_token = explode("\n", $get_token);
|
||||
$baseurl = $get_plex_token['1'];
|
||||
$baseurl = str_replace("'","",$baseurl);
|
||||
$baseurl = str_replace("baseurl = ","",$baseurl);
|
||||
$plexServer_url = parse_url($baseurl);
|
||||
$plexServer = $plexServer_url['host'];
|
||||
$plexport = $plexServer_url['port'];
|
||||
$token = $get_plex_token['0'];
|
||||
$token = str_replace("'","",$token);
|
||||
$plexToken = str_replace("token = ","",$token);
|
||||
|
||||
//Get Client Name from Pseudo Channel Config
|
||||
$configClientName = $getConfig[40];
|
||||
$configClientName = trim($configClientName, 'plexClients = ["');
|
||||
$configClientName = str_replace('"]','',$configClientName);
|
||||
$configClientName = trim($configClientName);
|
||||
$pseudochannelMaster = $pseudochannel;
|
||||
$pseudochannelMaster = trim($pseudochannelMaster);
|
||||
$pseudochannelTrim = rtrim($pseudochannel,'/');
|
||||
$plexClientName = $configClientName;
|
||||
if (isset($_SESSION['tv'])) {
|
||||
$plexClientName = $_SESSION['tv'];
|
||||
$urlstring = "tv=" . $_SESSION['tv'] . "&";
|
||||
if ($_SESSION['tv'] != $configClientName) {
|
||||
$pseudochannel = $pseudochannelTrim . "_" . $_SESSION['tv'] . "/";
|
||||
$pseudochannel = trim($pseudochannel);
|
||||
}
|
||||
} else {
|
||||
$urlstring = "";
|
||||
}
|
||||
if (isset($_SESSION['size'])) {
|
||||
$DisplayType=$_SESSION['size'];
|
||||
} else {
|
||||
$_SESSION['size'] = $DisplayType;
|
||||
}
|
||||
//Get Other Plex Client Data from Plex API
|
||||
$clientsurl = "http://" . $plexServer . ":" . $plexport . "/clients?X-Plex-Token=" . $plexToken;
|
||||
$getclientsxml = file_get_contents($clientsurl);
|
||||
$clientsxml = simplexml_load_string($getclientsxml);
|
||||
foreach($clientsxml->Server as $key => $clientdata) {
|
||||
$clientname = $clientdata[name];
|
||||
if($clientname == $plexClientName) {
|
||||
$plexClientIP = $clientdata[address];
|
||||
$plexClient = trim($plexClientIP);
|
||||
$plexClientUID = $clientdata[machineIdentifier];
|
||||
}
|
||||
}
|
||||
?>
|
||||
67
control.php
Normal file
67
control.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
function Channel() {
|
||||
include('config.php');
|
||||
if(empty($_GET["tv"]) || $_GET["tv"] == $configClientName) {
|
||||
$ps = "$pseudochannelMaster";
|
||||
} else {
|
||||
$pseudochannel = substr($pseudochannel, 0, -1);
|
||||
$ps = "$pseudochannelTrim" . "_" . $_GET["tv"];
|
||||
}
|
||||
$channel_number = $_GET["num"];
|
||||
ob_start();
|
||||
echo exec("cd " . "$ps" . " && sudo /bin/bash manual.sh " . "$channel_number");
|
||||
ob_end_clean();
|
||||
}
|
||||
function stopAllChannels() {
|
||||
include('config.php');
|
||||
if(empty($_GET["tv"]) || $_GET["tv"] == $configClientName) {
|
||||
$ps = "$pseudochannelMaster";
|
||||
} else {
|
||||
$pseudochannel = substr($pseudochannel, 0, -1);
|
||||
$ps = "$pseudochannelTrim" . "_" . $_GET["tv"];
|
||||
}
|
||||
ob_start();
|
||||
echo exec("cd " . "$ps" . " && sudo /bin/bash stop-all-channels.sh");
|
||||
ob_end_clean();
|
||||
}
|
||||
function channel_down() {
|
||||
include('config.php');
|
||||
if(empty($_GET["tv"]) || $_GET["tv"] == $configClientName) {
|
||||
$ps = "$pseudochannelMaster";
|
||||
} else {
|
||||
$pseudochannel = substr($pseudochannel, 0, -1);
|
||||
$ps = "$pseudochannelTrim" . "_" . $_GET["tv"];
|
||||
}
|
||||
ob_start();
|
||||
echo exec("cd " . "$ps" . " && sudo /bin/bash channeldown.sh");
|
||||
ob_end_clean();
|
||||
}
|
||||
function channel_up() {
|
||||
include('config.php');
|
||||
if(empty($_GET["tv"]) || $_GET["tv"] == $configClientName) {
|
||||
$ps = "$pseudochannelMaster";
|
||||
} else {
|
||||
$pseudochannel = substr($pseudochannel, 0, -1);
|
||||
$ps = "$pseudochannelTrim" . "_" . $_GET["tv"];
|
||||
}
|
||||
ob_start();
|
||||
echo exec("cd " . "$ps" . " && sudo /bin/bash channelup.sh");
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
switch($_GET['action']) {
|
||||
case 'stop':
|
||||
stopAllChannels();
|
||||
break;
|
||||
case 'channel':
|
||||
Channel();
|
||||
break;
|
||||
case 'down':
|
||||
channel_down();
|
||||
break;
|
||||
case 'up':
|
||||
channel_up();
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
246
getData.php
Normal file
246
getData.php
Normal file
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
include 'config.php'; //Get variables from config
|
||||
include 'control.php';
|
||||
$results = Array();
|
||||
if (isset($_GET['tv'])) {
|
||||
$plexClientName = $_GET['tv'];
|
||||
}
|
||||
|
||||
//GET PLEX DATA
|
||||
$url = "http://" . $plexServer . ":" . $plexport . "/status/sessions?X-Plex-Token=" . $plexToken; #set plex server url
|
||||
$getxml = file_get_contents($url);
|
||||
$xml = simplexml_load_string($getxml) or die("feed not loading");
|
||||
|
||||
$time_style=NULL;
|
||||
$top_line=NULL;
|
||||
$middle_line=NULL;
|
||||
$bottom_line=NULL;
|
||||
$dircontents=array();
|
||||
$nowplaying=array();
|
||||
$xmldata=array();
|
||||
$chantable=array();
|
||||
$ps_boxes=array();
|
||||
|
||||
//SET TIME AND DATE
|
||||
$rightnow = time(); //time
|
||||
$date = date('H:i'); //also time
|
||||
$day = date('D F d'); //date
|
||||
$text_color='cyan';
|
||||
$text_color_alt='cyan';
|
||||
|
||||
//CHECK IF PSEUDO CHANNEL IS RUNNING AND ON WHAT CHANNEL
|
||||
$is_ps_running = "find " . $pseudochannel . " -name running.pid -type f -exec cat {} +";
|
||||
$ps_channel_id = "find " . $pseudochannel . " -name running.pid -type f";
|
||||
$pgrep = shell_exec($is_ps_running); //check if pseudo channel is running
|
||||
$pdir = shell_exec($ps_channel_id); //identify directory has the running.pid file
|
||||
$channel_number = str_replace($pseudochannel . "pseudo-channel_", "", $pdir); //strip the prefix of the directory name to get the channel number
|
||||
$channel_num = ltrim($channel_number, '0'); //strip the leading zero from single digit channel numbers
|
||||
$channel_num = str_replace("/running.pid", "", $channel_num); //strip running.pid filename from the variable
|
||||
$chnum = str_replace("/running.pid", "",$channel_number); //strip running.pid from the variable that keeps the leading zero
|
||||
$chnum = trim($chnum);
|
||||
|
||||
//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 a comma separated list
|
||||
$dircontents = explode(",", $lsgrep); //write file locations into an array
|
||||
|
||||
// LINE STYLE VARIABLES
|
||||
if ($DisplayType == 'half') {
|
||||
$time_style = "<p class='vcr-time-half'>";
|
||||
$top_line = "<p class='vcr-info-half-1'>";
|
||||
$middle_line = "<p class='vcr-info-half-2'>";
|
||||
$bottom_line = "<p class='vcr-info-half-3'>";
|
||||
$side_channel = "<p class='vcr-side-half'>Channel $channel_num</p>";
|
||||
|
||||
$position_half = "<img position: absolute; align: top; width='480' style='opacity:1;'>";
|
||||
}
|
||||
|
||||
if ($DisplayType == 'full') {
|
||||
foreach ($xml->Video as $playdata) {
|
||||
if($playdata->Player['title'] == $plexClientName) {
|
||||
$video_duration = (int)$playdata['duration'];
|
||||
if($playdata['type'] == "movie") {
|
||||
if ($video_duration < "1800000") { //COMMERCIAL
|
||||
$text_color='cyan';
|
||||
$text_color_alt='cyan';
|
||||
} else { //MOVIE
|
||||
$text_color='yellow';
|
||||
$text_color_alt='white';
|
||||
}
|
||||
} elseif($playdata['type'] == "show" || $playdata['parentTitle'] != "") { //TV SHOW
|
||||
$text_color='yellow';
|
||||
$text_color_alt='white';
|
||||
} else {
|
||||
$text_color='cyan';
|
||||
$text_color_alt='cyan';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# SET FULL OPTIONS
|
||||
$time_style = "<p class='vcr-time-full-idle' style='color: $text_color'>";
|
||||
$top_line = "<p class='vcr-info-full-1-idle' style=color: $text_color'>";
|
||||
$middle_line = "<p class='vcr-info-full-2-idle' style=color: $text_color_alt'>";
|
||||
$bottom_line = "<p class='vcr-info-full-3-idle' style=color: $text_color'>";
|
||||
$side_channel = "<p class='vcr-side-full' style='color: $text_color_alt'>Channel $channel_num</p>";
|
||||
|
||||
$position_play_full = "<img position: absolute; top: 20px; width='480' style='opacity:1;'>";
|
||||
$position_idle_full = "<img position: absolute; top: 0; src='/assets/vcr-play.jpg' width='480' style='opacity:1;'>";
|
||||
}
|
||||
|
||||
if(strcmp($channel_num," ")<=0){
|
||||
$channel_num=0;
|
||||
}
|
||||
|
||||
//If Nothing is Playing
|
||||
$text_color='cyan';
|
||||
$text_color_alt='cyan';
|
||||
if ($DisplayType == 'full') {
|
||||
$position=$position_idle_full;
|
||||
}
|
||||
if ($DisplayType == 'half') {
|
||||
$position=$position_half;
|
||||
}
|
||||
if ($pgrep >= 1) { //PSEUDO CHANNEL ON
|
||||
$top_section = $time_style . $date . "</p>" . $position;
|
||||
$middle_section = $top_line . "Channel $channel_num</p>";
|
||||
$bottom_section = $middle_line . "</p>";
|
||||
$nowplaying = "Channel $channel_num Standing By...";
|
||||
} else { //PSEUDO CHANNEL OFF
|
||||
$top_section = $time_style . $date . "</p>" . $position;
|
||||
$middle_section = $top_line . $day . "</p>";
|
||||
$bottom_section = "<p></p>";
|
||||
$nowplaying = "Please Stand By...";
|
||||
}
|
||||
|
||||
if ($xml['size'] != '0') { //IF PLAYING CONTENT
|
||||
foreach ($xml->Video as $clients) {
|
||||
if($clients->Player['title'] == $plexClientName) { //If the active client on plex matches the client in the config
|
||||
//IF PLAYING COMMERCIAL
|
||||
if($clients['type'] == "movie" && $clients['duration'] < 1800000) {
|
||||
#$text_color='cyan';
|
||||
#$text_color_alt='cyan';
|
||||
if ($DisplayType == 'full') {
|
||||
$position=$position_idle_full;
|
||||
}
|
||||
if ($DisplayType == 'half') {
|
||||
$position=$position_half;
|
||||
}
|
||||
$top_section = $time_style . $date . "</p>" . $position;
|
||||
$middle_section = $top_line . $clients['librarySectionTitle'] . "</p>";
|
||||
$bottom_section = "<p></p>";
|
||||
$title_clean = str_replace("_", " ", $clients['title']);
|
||||
$nowplaying = "<a href='schedule.php?$urlstring' style='color:white'>Now Playing: " . $title_clean . " on Channel ". $channel_num . "</a>";
|
||||
}
|
||||
//IF PLAYING MOVIE
|
||||
if($clients['type'] == "movie" && $clients['duration'] >= 1800000) {
|
||||
$text_color='yellow';
|
||||
$text_color_alt='white';
|
||||
if ($DisplayType == 'half') {
|
||||
$art = $clients['thumb'];
|
||||
$background_art = "<img position: fixed; margin-top: 10; top: 10px; src='http:\/\/$plexServer:$plexport$art' width='130';'>";
|
||||
$position=$position_half;
|
||||
}
|
||||
if ($DisplayType == 'full') {
|
||||
$art = $clients['art'];
|
||||
$background_art = "<img position: fixed; align: left; left: -100; top: 10px; margin-top: 10; src='http:\/\/$plexServer:$plexport$art'; width='480';>";
|
||||
$position=$position_play_full;
|
||||
}
|
||||
|
||||
$top_section = $background_art . $time_style . $date . $side_channel . "</p>" . $position;
|
||||
$middle_section = $top_line . $clients['title'] . $middle_line . $clients['year'] . "</p>";
|
||||
$bottom_section = $bottom_line . $clients['tagline'] . "</p>";
|
||||
$nowplaying = "<a href='schedule.php?$urlstring' style='color:white'>Now Playing: " . $clients['title'] . " (" . $clients['year'] . ")" . " on Channel ". $channel_num . "</a>";
|
||||
}
|
||||
//IF PLAYING TV SHOW
|
||||
if($clients['type'] == "show" || $clients['parentTitle'] != "") {
|
||||
if ($DisplayType == 'half') {
|
||||
$art = $clients['parentThumb'];
|
||||
$background_art = "<img position: fixed; align: left; left: -100; top: 10px; margin-top: 10; src='http:\/\/$plexServer:$plexport$art'; width='130';>";
|
||||
$position=$position_half;
|
||||
}
|
||||
if ($DisplayType == 'full') {
|
||||
$art = $clients['grandparentArt'];
|
||||
$background_art = "<img position: fixed; align: left; left: -100; top: 10px; margin-top: 10; src='http:\/\/$plexServer:$plexport$art'; width='480';>";
|
||||
$position=$position_play_full;
|
||||
$text_color='yellow';
|
||||
$text_color_alt='white';
|
||||
}
|
||||
$top_section = $background_art . $time_style . $date . "</p>" . $position;
|
||||
$middle_section = $top_line . $clients['grandparentTitle'] . "</p>" . $middle_line . $clients['parentTitle'] . ", Episode " . $clients['index'] . "</p>";
|
||||
$bottom_section = $bottom_line . $clients['title'] . "</p>" . $side_channel . "</p>";
|
||||
$nowplaying = "<a href='schedule.php?$urlstring' style='color:white'>Now Playing: " . $clients['grandparentTitle'] . " • " . $clients['parentTitle'] . ", Episode " . $clients['index'] . " • " . $clients['title'] . " on Channel ". $channel_num . "</a>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//BUILD DAILY SCHEDULE PAGES
|
||||
$doheader = "0";
|
||||
foreach ($dircontents as $xmlfile) { //do the following for each xml schedule file
|
||||
$xmldata = simplexml_load_file($xmlfile); //load the xml schedule file
|
||||
foreach($xmldata->time as $attributes) { //for each entry in the schedule, do the following
|
||||
$start_time_unix = strtotime($attributes['time-start']); //get the entry start time
|
||||
$start_time_human = date("H:i", $start_time_unix); //convert start time to readable format
|
||||
$duration_seconds = $attributes['duration']/1000; //get entry duration and convert to seconds
|
||||
$duration_seconds = $duration_seconds-1;
|
||||
$end_time_unix = $start_time_unix + $duration_seconds; //using start time and duration, calculate the end time
|
||||
$end_time_human = date("H:i", $end_time_unix); //end time in readable format
|
||||
$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);
|
||||
if ($doheader != "1") {
|
||||
$tableheader = "<table class='schedule-table'><tr><th> Channel </th><th>Time</th><th>Title</th></tr>";
|
||||
$chantableheader = "<table class='schedule-table'><tr><th colspan='2'>";
|
||||
$nowtable = $tableheader;
|
||||
$doheader = "1";
|
||||
}
|
||||
if ($chnum == $ch_number) {
|
||||
$channelplaying = "font-weight:bold;font-size:1.1em";
|
||||
} else {
|
||||
$channelplaying = "";
|
||||
}
|
||||
if ($rightnow >= $start_time_unix && $rightnow <= $end_time_unix) {
|
||||
$nowtable .= "<tr><td><a style='$channelplaying;display:block; width:100%' href='schedule.php?" . $urlstring . "ch=$ch_number'>" . $ch_number . "</a></td>";
|
||||
$nowtable .= "<td style='$channelplaying'>" . $start_time_human . " - " . $end_time_human . " </td>";
|
||||
$nowtable .= "<td style='$channelplaying;text-align:left'><a style='display:block;width:100%' href='?" . $urlstring . "action=channel&num=$ch_number'> ";
|
||||
if ($attributes['type'] == "TV Shows") {
|
||||
$nowtable .= $attributes['show-title'];
|
||||
$nowtable .= "</br> S" . $attributes['show-season'] . "E" . $attributes['show-episode'] . " - " . $attributes['title'] . "</td>";
|
||||
} elseif ($attributes['type'] == "Commercials") {
|
||||
$nowtable .= $attributes['type'] . "</td>";
|
||||
} else {
|
||||
$nowtable .= $attributes['title'] . "</a></td>";
|
||||
}
|
||||
}
|
||||
if ($results[$ch_file] == "") {
|
||||
$results[$ch_file] = $chantableheader . "<a href='schedule.php?" . $urlstring . "action=channel&num=$ch_number'>Channel " . $ch_number . "</a></th></tr><th>Time</th><th>Title</th></tr></tr>";
|
||||
}
|
||||
if ($rightnow >= $start_time_unix && $rightnow < $end_time_unix) {
|
||||
$isnowplaying = "font-weight:bold;font-size:1.2em";
|
||||
} else {
|
||||
$isnowplaying = "";
|
||||
}
|
||||
if ($attributes['type'] != "Commercials") {
|
||||
$results[$ch_file] .= "<tr>";
|
||||
$results[$ch_file] .= "<td style='$isnowplaying'>" . $start_time_human . " - " . $end_time_human . " </td>";
|
||||
$results[$ch_file] .= "<td style='$isnowplaying;text-align:left'> ";
|
||||
if ($attributes['type'] == "TV Shows") {
|
||||
$results[$ch_file] .= $attributes['show-title'];
|
||||
$results[$ch_file] .= "</br> S" . $attributes['show-season'] . "E" . $attributes['show-episode'] . " - " . $attributes['title'] . "</td>";
|
||||
} elseif ($attributes['type'] == "Commercials") {
|
||||
$results[$ch_file] .= $attributes['type'] . "</td>";
|
||||
} else {
|
||||
$results[$ch_file] .= $attributes['title'] . "</td>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$nowtable .= "</table>";
|
||||
$results[$ch_file] .= "</table>";
|
||||
$results['rightnow'] = $nowtable;
|
||||
$results['top'] = "$top_section";
|
||||
$results['middle'] = "$middle_section $bottom_section";
|
||||
$results['bottom'] = "<p></p>";
|
||||
$results['nowplaying'] = "$nowplaying";
|
||||
echo json_encode($results);
|
||||
?>
|
||||
151
index.php
Normal file
151
index.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<!DOCTYPE html>
|
||||
<?php
|
||||
session_start();
|
||||
include('./control.php');
|
||||
include('./config.php');
|
||||
$tvlocations = glob($pseudochannelTrim . "*", GLOB_ONLYDIR);
|
||||
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 = trim($tvbox, $pseudochannelTrim . "_");
|
||||
$boxes .= "<li><a href='schedule.php?tv=$boxname' class='gn-icon gn-icon-videos'>TV: $boxname</a></li>";
|
||||
}
|
||||
}
|
||||
$clientcount = 1;
|
||||
foreach ($clientsxml->Server as $key => $xmlarray) {
|
||||
$clientinfodump .= "<a class='dripdrop-title'>Plex Client #$clientcount</a></br><a class='dripdrop-header'>Name:</a></br><a href='schedule.php?tv=$xmlarray[name]' style='color:white'> $xmlarray[name] </a></br></br>";
|
||||
$clientinfodump .= "<a class='dripdrop-header'>Local IP Address:</a></br><a> $xmlarray[address] </a></br></br>";
|
||||
$clientinfodump .= "<a class='dripdrop-header'>Unique Identifier</a></br><a> $xmlarray[machineIdentifier] </a></br></br>";
|
||||
$clientcount = $clientcount + 1;
|
||||
}
|
||||
?>
|
||||
<html lang="en" class="no-js" style="height:100%">
|
||||
<head>
|
||||
<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="js/modernizr.custom.js"></script>
|
||||
<script type="text/javascript" src="assets/js/jquery-3.0.0.min.js"></script>
|
||||
<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(
|
||||
function() {
|
||||
setInterval(function() {
|
||||
$.getJSON('getData.php',function(data) {
|
||||
$.each(data, function(key, val) {
|
||||
$('#'+key).html(val);
|
||||
});
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
</script>
|
||||
<script language="JavaScript">
|
||||
function channel() {
|
||||
<?php $id="$ch_file"; ?>
|
||||
}
|
||||
setInterval(autorefresh_div, 3000);
|
||||
function httpGet(theUrl)
|
||||
{
|
||||
var xmlHttp = new XMLHttpRequest();
|
||||
xmlHttp.open( "GET", theUrl, false );
|
||||
xmlHttp.send( null );
|
||||
return xmlHttp.responseText;
|
||||
}
|
||||
</script>
|
||||
<?php if (!empty($_POST)) {
|
||||
$myfile = fopen("psConfig.php", "w") or die("Unable to open file!");
|
||||
$txt = "<?php //Pseudo Channel
|
||||
\$pseudochannel = '$_POST[pseudochannel]';
|
||||
\n//Display Type
|
||||
\$DisplayType = '$_POST[DisplayType]';
|
||||
?>
|
||||
";
|
||||
echo $txt;
|
||||
fwrite($myfile, $txt);
|
||||
fclose($myfile);
|
||||
$update = "1";
|
||||
|
||||
} ?>
|
||||
<?php include_once('config.php');
|
||||
if ($DisplayType == "half" || $_POST['DisplayType'] == "half") {
|
||||
$halfstatus = "checked";
|
||||
$fullstatus = "";
|
||||
} elseif ($DisplayType =="full" || $_POST['DisplayType'] == "full") {
|
||||
$halfstatus = "";
|
||||
$fullstatus = "checked";
|
||||
} else {
|
||||
$halfstatus = "";
|
||||
$fullstatus = "";
|
||||
}
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||
<div id="container">
|
||||
<div class="container" style="position:absolute;top:60px" scrolling="no"><h3 style="color:white" class="gn-icon gn-icon-earth">Pseudo Channel Web Interface</h3>
|
||||
<div class="container" name="schedulearea" type="text/html";>
|
||||
<div class="container" name="schedulearea" type="text/html";>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php if($update == "1") {
|
||||
echo "<div class='alert alert-info' style='color:white;padding-left:50px'>Settings File Updated.</div>";
|
||||
} ?>
|
||||
</form>
|
||||
</div></br></br></br></br></br></br>
|
||||
<div class="dripdrop-header" style="color:white;padding-left:10px">
|
||||
<p>Welcome to Pseudo Channel, your homebrew television network.</p></div>
|
||||
<div class="dripdrop-paragraph" style="color:white;padding-left:10px"><ul>
|
||||
<li>Use this web interface to control your Pseudo Channel instance.</li>
|
||||
<li>Click the menu icon in the top left to access the Now Playing pages.</li>
|
||||
<li>Use the buttons at the top of the page to flip through your channels or to turn it off.</li></ul>
|
||||
<p class="dripdrop-header">What is Pseudo Channel?</p>
|
||||
<ul><li>Pseudo Channel is a near-recreation of the classic broadcast television experience using your Plex Server as a base.</li>
|
||||
<li>Use Pseudo Channel to schedule shows and random movie blocks with user-defined commercials in between.</li></ul></div>
|
||||
<div class="dripdrop-header" style="color:white;padding-left:10px"><p><a style="color:white" href="https://discord.gg/aPaybPp">Join us on Discord</a></div>
|
||||
<div class="dripdrop-paragraph" style="color:white;padding-left:10px"><ul><li>Join the <u><a style="color:white" href="https://discord.gg/aPaybPp">FakeTV Discord Server</a></u> for operating help and ongoing development updates and discussion.</li></ul>
|
||||
</div>
|
||||
<div class="dripdrop" style="color:white;padding-left:10px"></br>
|
||||
<a class="dripdrop-header">Plex Server: </a><a><?php echo $plexServer; ?>:<?php echo $plexport; ?></a></br>
|
||||
<a class="dripdrop-header">Pseudo Channel: </a><a><?php echo $pseudochannelMaster; ?></a></div>
|
||||
<ul id="gn-menu" class="gn-menu-main">
|
||||
<li class="gn-trigger">
|
||||
<a class="gn-icon gn-icon-menu"><span>Menu</span></a>
|
||||
<nav class="gn-menu-wrapper">
|
||||
<div class="gn-scroller">
|
||||
<ul class="gn-menu">
|
||||
<li><a href="index.php" class="gn-icon gn-icon-help">Home</a></li>
|
||||
<li><a href="adminConfig.php?<?php echo $urlstring; ?>" class="gn-icon gn-icon-cog">Settings</a></li>
|
||||
<?php echo $boxes; ?>
|
||||
</ul>
|
||||
</div><!-- /gn-scroller -->
|
||||
</nav>
|
||||
</li>
|
||||
<li></li>
|
||||
</ul>
|
||||
</div><!-- /container -->
|
||||
<script src="js/classie.js"></script>
|
||||
<script src="js/gnmenu.js"></script>
|
||||
<script>
|
||||
new gnMenu( document.getElementById( 'gn-menu' ) );
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
7
psConfig.php
Normal file
7
psConfig.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php //Pseudo Channel
|
||||
$pseudochannel = '/home/pi/channels/';
|
||||
|
||||
//Display Type
|
||||
$DisplayType = 'half';
|
||||
?>
|
||||
|
||||
112
schedule.php
Normal file
112
schedule.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<!DOCTYPE html>
|
||||
<?php
|
||||
session_start();
|
||||
include('./control.php');
|
||||
include('./config.php');
|
||||
$tvlocations = glob($pseudochannelTrim . "*", GLOB_ONLYDIR);
|
||||
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 = trim($tvbox, $pseudochannelTrim . "_");
|
||||
$boxes .= "<li><a href='schedule.php?tv=$boxname' class='gn-icon gn-icon-videos'>TV: $boxname</a></li>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<html lang="en" class="no-js" style="height:100%">
|
||||
<head>
|
||||
<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="js/modernizr.custom.js"></script>
|
||||
<script type="text/javascript" src="assets/js/jquery-3.0.0.min.js"></script>
|
||||
<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(
|
||||
function() {
|
||||
setInterval(function() {
|
||||
$.getJSON('getData.php',function(data) {
|
||||
$.each(data, function(key, val) {
|
||||
$('#'+key).html(val);
|
||||
});
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
</script>
|
||||
<script language="JavaScript">
|
||||
function channel() {
|
||||
<?php $id="$ch_file"; ?>
|
||||
}
|
||||
setInterval(autorefresh_div, 3000);
|
||||
function httpGet(theUrl)
|
||||
{
|
||||
var xmlHttp = new XMLHttpRequest();
|
||||
xmlHttp.open( "GET", theUrl, false );
|
||||
xmlHttp.send( null );
|
||||
return xmlHttp.responseText;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p style="top:100px"><?php echo $plexClientName; ?></p>
|
||||
<?php
|
||||
if (isset($_GET['ch'])) {
|
||||
$id= "ch" . $_GET['ch'];
|
||||
} else {
|
||||
$id="rightnow";
|
||||
}
|
||||
if (isset($_GET['tv'])) {
|
||||
$_SESSION['tv'] = $_GET['tv'];
|
||||
$urlstring = "tv=" . $_GET['tv'] . "&";
|
||||
$_SESSION['urlstring'] = $urlstring;
|
||||
} else {
|
||||
$_SESSION['tv'] = $plexClientName;
|
||||
}
|
||||
?>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||
<div id="container">
|
||||
<div class="container" style="position:absolute;top:60px" scrolling="no"><p style="color:white" id="nowplaying" class="container">Please Stand By<? php echo $plexClientName; ?></p>
|
||||
<div id="<?php echo $id; ?>" class="container" name="schedulearea" type="text/html";></div>
|
||||
<ul id="gn-menu" class="gn-menu-main">
|
||||
<li class="gn-trigger">
|
||||
<a class="gn-icon gn-icon-menu"><span>Menu</span></a>
|
||||
<nav class="gn-menu-wrapper">
|
||||
<div class="gn-scroller">
|
||||
<ul class="gn-menu">
|
||||
<li><a href="index.php" class="gn-icon gn-icon-help">Home</a></li>
|
||||
<li><a href="adminConfig.php?<?php echo $urlstring;?>" class="gn-icon gn-icon-cog">Settings</a></li>
|
||||
<?php echo $boxes; ?>
|
||||
</ul>
|
||||
</div><!-- /gn-scroller -->
|
||||
</nav>
|
||||
</li>
|
||||
<li><a class="codrops-icon" href="schedule.php?action=up&<?php echo $urlstring; ?>">Up</a></li>
|
||||
<li><a class="codrops-icon" href="schedule.php?action=down&<?php echo $urlstring; ?>">Down</a></li>
|
||||
<li><a class="codrops-icon" href="schedule.php?action=stop&<?php echo $urlstring; ?>">Stop</a></li>
|
||||
<li></li>
|
||||
</ul>
|
||||
</div><!-- /container -->
|
||||
<script src="js/classie.js"></script>
|
||||
<script src="js/gnmenu.js"></script>
|
||||
<script>
|
||||
new gnMenu( document.getElementById( 'gn-menu' ) );
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
64
status.php
Normal file
64
status.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
|
||||
<script type="text/javascript" src="assets/js/jquery-3.0.0.min.js"></script>
|
||||
<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
|
||||
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="assets/css/PieBox.css">
|
||||
<link rel="stylesheet" href="css/tv.css">
|
||||
|
||||
<script>
|
||||
$(document).ready(
|
||||
function() {
|
||||
setInterval(function() {
|
||||
$.getJSON('getData.php',function(data) {
|
||||
$.each(data, function(key, val) {
|
||||
$('#'+key).html(val);
|
||||
});
|
||||
});
|
||||
}, 3000);
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
session_start();
|
||||
include('./config.php');
|
||||
if (isset($_GET['size'])) {
|
||||
$_SESSION['size'] = $_GET['size'];
|
||||
$DisplayType=$_GET['size'];
|
||||
} else {
|
||||
$_SESSION['size'] = $DisplayType;
|
||||
}
|
||||
if ($DisplayType == "half") {
|
||||
$vcr_time = "vcr-time-half";
|
||||
$vcr_info_1 = "vcr-info-half-1";
|
||||
$vcr_info_2 = "vcr-info-half-2";
|
||||
$vcr_info_3 = "vcr-info-half-3";
|
||||
$vcr_side = "vcr-side-half";
|
||||
} elseif ($DisplayType == "full") {
|
||||
$vcr_time = "vcr-time-full";
|
||||
$vcr_info_1 = "vcr-info-half-1-idle";
|
||||
$vcr_info_2 = "vcr-info-half-2-idle";
|
||||
$vcr_info_3 = "vcr-info-half-3-idle";
|
||||
$vcr_side = "vcr-side-full";
|
||||
}
|
||||
if (isset($_GET['tv'])) {
|
||||
$_SESSION['tv'] = $_GET['tv'];
|
||||
$urlstring = "tv=" . $_GET['tv'] . "&";
|
||||
$_SESSION['urlstring'] = $urlstring;
|
||||
} else {
|
||||
$_SESSION['tv'] = $plexClientName;
|
||||
}
|
||||
?>
|
||||
|
||||
</head>
|
||||
|
||||
<body class='vcr-body'>
|
||||
<div id="container" style="max-width:480">
|
||||
<div id="alert" align="left" scrolling="no"></div>
|
||||
<div id="top" align="left" scrolling="no"></div>
|
||||
<div id="middle" scrolling="no"></div>
|
||||
<div id="bottom" scrolling="no"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user