Skip to content
This repository has been archived by the owner on Aug 28, 2022. It is now read-only.

Commit

Permalink
Added dashboard, new icons, and fixed some CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
demonrik committed Sep 22, 2018
1 parent 4cd0d5a commit ebabd28
Show file tree
Hide file tree
Showing 34 changed files with 294 additions and 27 deletions.
149 changes: 149 additions & 0 deletions app/dashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<?php
require_once("TinyAjaxBehavior.php");
require_once("vars.php");
require_once("includes/dvrui_hdhrjson.php");
require_once("includes/dvrui_rules.php");
require_once("includes/dvrui_recordings.php");
require_once("includes/dvrui_upcoming.php");


function openDashboardPage() {
// prep
ob_start();
$tab = new TinyAjaxBehavior();

//create output
$htmlStr = buildDashboard();

//get data
$result = ob_get_contents();
ob_end_clean();

//display
$tab->add(TabInnerHtml::getBehavior("dashboard_box", $htmlStr));

return $tab->getString();
}

function buildDashboard() {
$dashboard = '';

$hdhr = new DVRUI_HDHRjson();
$hdhrRules = new DVRUI_Rules($hdhr);
$hdhrRules->processAllRules();
$hdhrRecordings = new DVRUI_Recordings($hdhr);
$hdhrRecordings->processAllRecordings($hdhr);
$hdhrRecordings->sortRecordings('DD');


$hardware = file_get_contents('style/dashboard_hardware.html');
$hardware = str_replace('<!-- dvrui_hdhrlist_data -->',getDashboardHardware($hdhr),$hardware);
$recent = file_get_contents('style/dashboard_recent.html');
$recent = str_replace('<!-- dvr_recent_recordings_list -->',getRecentRecordings($hdhr,$hdhrRecordings),$recent);
$soon = file_get_contents('style/dashboard_upcoming.html');
$soon = str_replace('<!-- dvr_soon_list -->',getSoon($hdhr,$hdhrRecordings,$hdhrRules),$soon);

$dashboard .= $hardware;
$dashboard .= $recent;
$dashboard .= $soon;

return $dashboard;
}

function getDashboardHardware($hdhr) {
// Discover HDHR Devices
$devices = $hdhr->device_count();
$hdhr_data = '';
for ($i=0; $i < $devices; $i++) {
$hdhrEntry = file_get_contents('style/hdhrlist_entry.html');
$hdhr_device_data = "<a href=" . $hdhr->get_device_baseurl($i) . ">" . $hdhr->get_device_id($i) . "</a>";
$hdhr_lineup_data = "<a href=" . $hdhr->get_device_lineup($i) . ">" . $hdhr->get_device_channels($i) . " Channels</a>";
$hdhrEntry = str_replace('<!--hdhr_device-->',$hdhr_device_data,$hdhrEntry);
$hdhrEntry = str_replace('<!--hdhr_channels-->',$hdhr_lineup_data,$hdhrEntry);
$hdhrEntry = str_replace('<!--hdhr_model-->',$hdhr->get_device_model($i),$hdhrEntry);
$hdhrEntry = str_replace('<!--hdhr_tuners-->',$hdhr->get_device_tuners($i) . ' tuners',$hdhrEntry);
$hdhrEntry = str_replace('<!--hdhr_firmware-->',$hdhr->get_device_firmware($i),$hdhrEntry);
$hdhrEntry = str_replace('<!--hdhr_legacy-->',$hdhr->get_device_legacy($i),$hdhrEntry);
$hdhrEntry = str_replace('<!--hdhr_image-->',$hdhr->get_device_image($i),$hdhrEntry);
$hdhr_data .= $hdhrEntry ;
}
$engines = $hdhr->engine_count();
for ($i=0; $i < $engines; $i++) {
$engineEntry = file_get_contents('style/recordenginelist_entry.html');
$engineEntry = str_replace('<!--rec_image-->',$hdhr->get_engine_image($i),$engineEntry);
$engineEntry = str_replace('<!--rec_name-->',$hdhr->get_engine_name($i),$engineEntry);
$engineEntry = str_replace('<!--rec_version-->',$hdhr->get_engine_version($i),$engineEntry);
$engineEntry = str_replace('<!--rec_freespace-->',$hdhr->get_engine_space($i),$engineEntry);
$engine_discover_data = "<a href=" . $hdhr->get_engine_discoverURL($i) . ">" . $hdhr->get_engine_local_ip($i) . "</a>";
$engineEntry = str_replace('<!--rec_localip-->',$engine_discover_data,$engineEntry);
$engine_storage_data = "<a href=" . $hdhr->get_engine_storage_url($i) . ">" . $hdhr->get_engine_storage_id($i) . "</a>";
$engineEntry = str_replace('<!--rec_storageid-->',$engine_storage_data,$engineEntry);
$hdhr_data .= $engineEntry;
}
return $hdhr_data;
}

function getRecentRecordings($hdhr, $hdhrRecordings) {

$numRecordings = $hdhrRecordings->getRecordingCount();
if ($numRecordings > 10) {
$numRecordings = 10;
}

$recordingsData = '';
for ($i=0; $i < $numRecordings; $i++) {
$recordingsEntry = file_get_contents('style/recordings_entry.html');
$recordingsEntry = str_replace('<!-- dvr_recordings_id -->',$hdhrRecordings->getRecordingID($i),$recordingsEntry);
$recordingsEntry = str_replace('<!-- dvr_series_id -->',$hdhrRecordings->getSeriesID($i),$recordingsEntry);
$recordingsEntry = str_replace('<!-- dvr_recordings_image -->',$hdhrRecordings->getRecordingImage($i),$recordingsEntry);
$recordingsEntry = str_replace('<!-- dvr_recordings_episode -->',$hdhrRecordings->getEpisodeNumber($i),$recordingsEntry);
$recordingsEntry = str_replace('<!-- dvr_recordings_show -->',$hdhrRecordings->getEpisodeTitle($i),$recordingsEntry);
$recordingsEntry = str_replace('<!-- dvr_recordings_title -->',$hdhrRecordings->getTitle($i),$recordingsEntry);
$recordingsEntry = str_replace('<!-- dvr_recordings_play -->',$hdhrRecordings->get_PlayURL($i),$recordingsEntry);
$recordingsEntry = str_replace('<!-- dvr_recordings_recstart -->',$hdhrRecordings->getRecordStartTime($i),$recordingsEntry);
$recordingsEntry = str_replace('<!-- dvr_recordings_start -->',$hdhrRecordings->getStartTime($i),$recordingsEntry);
$recordingsEntry = str_replace('<!-- dvr_recordings_originaldate -->',$hdhrRecordings->getOriginalAirDate($i),$recordingsEntry);
$recordingsEntry = str_replace('<!-- dvr_recordings_repeat -->',$hdhrRecordings->isRepeat($i),$recordingsEntry);
$recordingsEntry = str_replace('<!-- dvr_recordings_chname -->',$hdhrRecordings->getChannelName($i),$recordingsEntry);
$recordingsEntry = str_replace('<!-- dvr_recordings_chnumber -->',$hdhrRecordings->getChannelNumber($i),$recordingsEntry);
$recordingsEntry = str_replace('<!-- dvr_recordings_chaffiliate -->',$hdhrRecordings->getChannelAffiliate($i),$recordingsEntry);
$recordingsData .= $recordingsEntry;
}

return $recordingsData;
}

function getSoon($hdhr, $hdhrRecordings, $hdhrRules) {
$soonStr = '';

$upcoming = new DVRUI_Upcoming($hdhr,$hdhrRecordings);
$upcoming->initByRules($hdhrRules);
$numRules = $upcoming->getSeriesCount();
for ($i=0; $i < $numRules; $i++) {
$upcoming->processNext($i);
}

$upcoming->sortUpcomingByDate();
$numShows = $upcoming->getUpcomingCount();
if ($numShows > 10) {
$numShows = 10;
}

for ($i=0;$i < $numShows;$i++) {
$entry = file_get_contents('style/upcoming_entry.html');
$entry = str_replace('<!-- dvr_upcoming_title -->',$upcoming->getTitle($i),$entry);
$entry = str_replace('<!-- dvr_upcoming_episode -->',$upcoming->getEpNum($i) . ' : ' . $upcoming->getEpTitle($i),$entry);
$entry = str_replace('<!-- dvr_upcoming_original_airdate -->',$upcoming->getEpOriginalAirDate($i),$entry);
$entry = str_replace('<!-- dvr_upcoming_image -->',$upcoming->getEpImg($i),$entry);
$entry = str_replace('<!-- dvr_upcoming_start -->',$upcoming->getEpStart($i),$entry);
$entry = str_replace('<!-- dvr_upcoming_stop -->',$upcoming->getEpEnd($i),$entry);
$entry = str_replace('<!-- dvr_upcoming_channels -->',$upcoming->getEpChannelNum($i),$entry);
$entry = str_replace('<!-- dvr_upcoming_channel_name -->',$upcoming->getEpChannelName($i),$entry);
$soonStr .= $entry;
}


return $soonStr;
}

?>
Binary file added app/images/HDHR-DVR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/HDHR3-4DC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/HDHR3-CC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/HDHR3-US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/HDHR4-2US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/HDHR5-6CC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/HDHR5-US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/HDTC-2US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/TECH4-2US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/TECH4-8US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/TECH5-16DT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/TECH5-36CC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/no-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/includes/.dvrui_common.php.swp
Binary file not shown.
26 changes: 26 additions & 0 deletions app/includes/dvrui_common.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
define('NO_IMAGE','images/no-preview.png');

function file_get_contents_utf8($fn) {
$content = file_get_contents($fn);
Expand Down Expand Up @@ -58,4 +59,29 @@ function getURL($url){
return $content;

}

function URLExists($url) {
$exists = false;

if (!$exists && in_array('curl', get_loaded_extensions())) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
$response = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($response === 200) $exists = true;
curl_close($ch);
}
if (!$exists && function_exists('get_headers')) {
$headers = @get_headers($robots);
if ($headers) {
if (strpos($headers[0], '404') !== false) {
$exists = true;
}
}
}
return $exists;
}
?>
34 changes: 26 additions & 8 deletions app/includes/dvrui_hdhrjson.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function get_engine_local_ip($pos){
}

public function get_engine_image($pos) {
return "https://www.silicondust.com/wp-content/uploads/2016/03/dvr-logo.png";
return "./images/HDHR-DVR.png";
}

public function get_engine_name($pos) {
Expand Down Expand Up @@ -229,20 +229,38 @@ public function get_device_image($pos) {
$device = $this->hdhrlist[$pos];
switch ($device[$this->hdhrkey_modelNum]) {
case 'HDTC-2US':
return 'https://www.silicondust.com/wordpress/wp-content/uploads/2016/04/extend-logo-2.png';
return './images/HDTC-2US.png';
case 'HDHR3-CC':
return 'https://www.silicondust.com/wordpress/wp-content/uploads/2016/04/prime-logo-2.png';
case 'HDHR3-EU':
return './images/HDHR3-CC.png';
case 'HDHR3-4DC':
return 'https://www.silicondust.com/wordpress/wp-content/uploads/2016/04/expand-logo-2.png';
return './images/HDHR3-4DC.png';
case 'HDHR3-EU':
case 'HDHR3-US':
case 'HDHR3-DT':
return './images/HDHOMERUN_LEGACY.png';
return './images/HDHR3-US.png';
case 'HDHR4-2US':
case 'HDHR4-2DT':
return 'https://www.silicondust.com/wordpress/wp-content/uploads/2016/04/connect-logo.png';
return './images/HDHR4-US.png';
case 'HDHR5-DT':
case 'HDHR5-2US':
case 'HDHR5-4DC':
case 'HDHR5-4DT':
case 'HDHR5-4US':
return './images/HDHR5-US.png';
case 'HDHR5-6CC':
return './images/HDHR5-6CC.png';
case 'TECH4-2DT':
case 'TECH4-2US':
return './images/TECH4-2US.png';
case 'TECH4-8US':
return './images/TECH4-8US.png';
case 'TECH5-36CC':
return './images/TECH5-36CC.png';
case 'TECH5-16DC':
case 'TECH5-16DT':
return './images/TECH5-16DT.png';
default:
return './images/HDHOMERUN_LEGACY.png';
return './images/HDHR5-US.png';
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/includes/dvrui_recordings.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private function processRecordingData($recording, $storageID) {
$channelNumber = '';
$channelAffiliate = '';
$episodeNumber = 'X';
$imageURL = '';
$imageURL = NO_IMAGE;
$episodeTitle = 'X';
$originalAirDate = '';
$recordStartTime = '';
Expand Down
4 changes: 2 additions & 2 deletions app/includes/dvrui_rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ private function processRule($rule) {
$recentOnly = 'X';
$airdate = '';
$synopsis = "";
$image = "";

$image = NO_IMAGE;
if (array_key_exists($this->recording_ImageURL,$rule)){
$image = $rule[$this->recording_ImageURL];
}
Expand Down
6 changes: 3 additions & 3 deletions app/includes/dvrui_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public function DVRUI_Search($hdhr, $searchStr) {
}
for ($i = 0; $i < count($search_info); $i++) {
$seriesID = $search_info[$i][$this->search_SeriesID];
$image = "";
$image = NO_IMAGE;
$title = $search_info[$i][$this->search_Title];
$originalAirDate = 0;
$recordingRule = 0;
if (array_key_exists($this->search_ImageURL,$search_info[$i])){
$image = $search_info[$i][$this->search_ImageURL];
if (array_key_exists($this->search_ImageURL,$search_info[$i])) {
$image = $search_info[$i][$this->search_ImageURL];
}
if (array_key_exists($this->search_Synopsis,$search_info[$i])){
$synopsis = $search_info[$i][$this->search_Synopsis];
Expand Down
4 changes: 2 additions & 2 deletions app/includes/dvrui_upcoming.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private function extractEpisodeInfo($episode){
$episodeNumber = '';
$episodeTitle = '';
$synopsis = '';
$imageURL = '';
$imageURL = NO_IMAGE;
$originalAirDate = '';
$startTime = '';
$endTime = '';
Expand Down Expand Up @@ -112,7 +112,7 @@ private function extractEpisodeInfo($episode){
if (array_key_exists($this->epData_Synopsis,$episode)){
$synopsis = $episode[$this->epData_Synopsis];
}
if (array_key_exists($this->epData_ImageURL,$episode)){
if (array_key_exists($this->epData_ImageURL,$episode)) {
$imageURL = $episode[$this->epData_ImageURL];
}
$this->upcoming_list[] = array(
Expand Down
18 changes: 14 additions & 4 deletions app/index.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?php

/*
// UNCOMMENT FOR DEBUGGING
/* opcache_reset();
opcache_reset();
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-dvrui.log");
error_log( "======= Debug Log START =========" );
*/
if (PHP_MAJOR_VERSION >= 7) {
error_log( "PHP > 7 detected" );
set_error_handler(function ($errno, $errstr) {
return strpos($errstr, 'Declaration of') === 0;
}, E_WARNING);
}

error_reporting(E_ALL & ~(E_DEPRECATED | E_STRICT));
define('TINYAJAX_PATH', '.');
Expand All @@ -19,12 +25,14 @@
require_once("theme.php");
require_once("upcoming.php");
require_once("search.php");
require_once("dashboard.php");
/* Prepare Ajax */
$ajax = new TinyAjax();
$ajax->setRequestType("POST"); // Change request-type from GET to POST
$ajax->showLoading(); // Show loading while callback is in progress

/* Export the PHP Interface */
$ajax->exportFunction("openDashboardPage","");
$ajax->exportFunction("openSeriesPage","");
$ajax->exportFunction("openRulesPage","seriesid");
$ajax->exportFunction("openRecordingsPage","seriesid");
Expand All @@ -47,8 +55,8 @@
$stylesheet = getTheme();

//Build navigation menu for pages
$pageTitles = array('Series', 'Recordings', 'Upcoming','Rules', 'Search','.');
$pageNames = array('series_page', 'recordings_page', 'upcoming_page', 'rules_page', 'search_page', 'settings_page');
$pageTitles = array('Dashboard', 'Series', 'Recordings', 'Upcoming','Rules', 'Search','.');
$pageNames = array('dashboard_page', 'series_page', 'recordings_page', 'upcoming_page', 'rules_page', 'search_page', 'settings_page');
$menu_data = file_get_contents('style/pagemenu.html');
$menuEntries = '';
for ($i=0; $i < count($pageNames); $i++) {
Expand All @@ -71,6 +79,7 @@
// --- Build Body ---
$indexPage = file_get_contents('style/index_page.html');

$dashboarddata = file_get_contents('style/dashboard.html');
$rulesdata = file_get_contents('style/rules.html');
$recordingsdata = file_get_contents('style/recordings.html');
$seriesdata = file_get_contents('style/series.html');
Expand All @@ -82,6 +91,7 @@
$indexPage = str_replace('[[UI-Version]]',$UIVersion,$indexPage);

$indexPage = str_replace('<!-- dvrui_pagemenu -->',$menu_data,$indexPage);
$indexPage = str_replace('<!-- dvrui_dashboard -->',$dashboarddata,$indexPage);
$indexPage = str_replace('<!-- dvrui_serieslist -->',$seriesdata,$indexPage);
$indexPage = str_replace('<!-- dvrui_recordingslist -->',$recordingsdata,$indexPage);
$indexPage = str_replace('<!-- dvrui_upcominglist -->',$updata,$indexPage);
Expand Down
9 changes: 7 additions & 2 deletions app/rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ function getRecordingRules($seriesid) {
$reccount = $hdhrRecordings->getRecordingCountBySeries($hdhrRules->getRuleSeriesID($i));
$rulesEntry = file_get_contents('style/rules_entry.html');
$rulesEntry = str_replace('<!-- dvr_rules_id -->',$hdhrRules->getRuleRecID($i) ,$rulesEntry);
$rulesEntry = str_replace('<!-- dvr_rules_image -->',$hdhrRules->getRuleImage($i),$rulesEntry);
if (URLExists($hdhrRules->getRuleImage($i))) {
$rulesEntry = str_replace('<!-- dvr_rules_image -->',$hdhrRules->getRuleImage($i),$rulesEntry);
} else {
$rulesEntry = str_replace('<!-- dvr_rules_image -->',NO_IMAGE,$rulesEntry);
}

$rulesEntry = str_replace('<!-- dvr_rules_priority -->',$hdhrRules->getRulePriority($i),$rulesEntry);
$rulesEntry = str_replace('<!-- dvr_rules_priorityPlus -->',$i-2,$rulesEntry);
$rulesEntry = str_replace('<!-- dvr_rules_priorityMinus -->',$i+1,$rulesEntry);
Expand All @@ -143,7 +148,7 @@ function getRecordingRules($seriesid) {
}

// get upcoming count
$upcoming = new DVRUI_Upcoming($hdhr);
$upcoming = new DVRUI_Upcoming($hdhr, NULL);
$upcoming->initBySeries($hdhrRules->getRuleSeriesID($i));
$upcomingcount = $upcoming->getUpcomingCount();

Expand Down
3 changes: 3 additions & 0 deletions app/scripts/hdhomerundvr_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ function openTab(evt, tabname) {
}

// load the page
if (tabname == 'dashboard_page') {
openDashboardPage();
}
if (tabname == 'series_page') {
openSeriesPage("");
}
Expand Down
4 changes: 4 additions & 0 deletions app/style/dashboard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div id="dashboard_content" class="dashboard_content">
<div id='dashboard_box'><!-- dvrui_dashboard_data --></div>
<BR/>
</div>
Loading

0 comments on commit ebabd28

Please sign in to comment.