From 3fd953a4eb0bdb96a95689367dfd86a6222a0c99 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 4 May 2018 06:46:46 -0700 Subject: [PATCH] Move code to generate Source from console into Monitor Object --- web/includes/Monitor.php | 28 ++++++++++++++++++++++++++++ web/skins/classic/views/console.php | 28 ++-------------------------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php index 823491aa4..bde545594 100644 --- a/web/includes/Monitor.php +++ b/web/includes/Monitor.php @@ -467,5 +467,33 @@ private $control_fields = array( } return $this->{'Storage'}; } + + public function Source( ) { + $source = ''; + if ( $this->{'Type'} == 'Local' ) { + $source = $this->{'Device'}.' ('.$this->{'Channel'}.')'; + } elseif ( $this->{'Type'} == 'Remote' ) { + $source = preg_replace( '/^.*@/', '', $this->{'Host'} ); + if ( $this->{'Port'} != '80' and $this->{'Port'} != '554' ) { + $source .= ':'.$this->{'Port'}; + } + } elseif ( $this->{'Type'} == 'File' || $this->{'Type'} == 'cURL' ) { + $source = preg_replace( '/^.*\//', '', $this->{'Path'} ); + } elseif ( $this->{'Type'} == 'Ffmpeg' || $this->{'Type'} == 'Libvlc' || $this->{'Type'} == 'WebSite' ) { + $url_parts = parse_url( $this->{'Path'} ); + unset($url_parts['user']); + unset($url_parts['pass']); + unset($url_parts['scheme']); + unset($url_parts['query']); + unset($url_parts['path']); + if ( isset($url_parts['port']) and ( $url_parts['port'] == '80' or $url_parts['port'] == '554' ) ) + unset($url_parts['port']); + $source = unparse_url($url_parts); + } + if ( $source == '' ) { + $source = 'Monitor ' . $this->{'Id'}; + } + return $source; + } // end function Source } // end class Monitor ?> diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index dd49c28fc..119a223eb 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -304,31 +304,7 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) { Name(); ?> '. makePopupLink( '?view=monitor&mid='.$monitor['Id'], 'zmMonitor'.$monitor['Id'], 'monitor', ''.$source.'', canEdit( 'Monitors' ) ).''; + echo ''. makePopupLink( '?view=monitor&mid='.$monitor['Id'], 'zmMonitor'.$monitor['Id'], 'monitor', ''.$Monitor->Source().'', canEdit('Monitors') ).''; if ( $show_storage_areas ) { ?> Name(); } ?> @@ -342,7 +318,7 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) { - +