public function index()
 {
     // Set title
     $this->title = _('Search');
     if ($this->FOGCore->getSetting('FOG_DATA_RETURNED') > 0 && $this->getClass('LocationManager')->count() > $this->FOGCore->getSetting('FOG_DATA_RETURNED') && $_REQUEST['sub'] != 'list') {
         $this->FOGCore->redirect(sprintf('%s?node=%s&sub=search', $_SERVER['PHP_SELF'], $this->node));
     }
     // Find data
     $Locations = $this->getClass('LocationManager')->find();
     // Row data
     foreach ((array) $Locations as $Location) {
         $StorageGroup = new StorageGroup($Location->get('storageGroupID'));
         $this->data[] = array('id' => $Location->get('id'), 'name' => $Location->get('name'), 'storageNode' => $Location->get('storageNodeID') ? $this->getClass('StorageNode', $Location->get('storageNodeID'))->get('name') : 'Not Set', 'storageGroup' => $StorageGroup->get('name'), 'tftp' => $Location->get('tftp') ? _('Yes') : _('No'));
     }
     // Hook
     $this->HookManager->event[] = 'LOCATION_DATA';
     $this->HookManager->processEvent('LOCATION_DATA', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes));
     // Output
     $this->render();
 }
 public function multicast_post()
 {
     try {
         // Error Checking
         if (!trim($_REQUEST['name'])) {
             throw new Exception(_('Please input a session name'));
         }
         if (!$_REQUEST['image']) {
             throw new Exception(_('Please choose an image'));
         }
         if ($this->getClass('MulticastSessionsManager')->exists(trim($_REQUEST['name']))) {
             throw new Exception(_('Session with that name already exists'));
         }
         if ($this->getClass('HostManager')->exists(trim($_REQUEST['name']))) {
             throw new Exception(_('Session name cannot be the same as an existing hostname'));
         }
         if (is_numeric($_REQUEST['timeout']) && $_REQUEST['timeout'] > 0) {
             $this->FOGCore->setSetting('FOG_UDPCAST_MAXWAIT', $_REQUEST['timeout']);
         }
         $countmc = $this->getClass('MulticastSessionsManager')->count(array('stateID' => array(0, 1, 2, 3)));
         $countmctot = $this->FOGCore->getSetting('FOG_MULTICAST_MAX_SESSIONS');
         $Image = new Image($_REQUEST['image']);
         $StorageGroup = new StorageGroup($Image->getStorageGroup());
         $StorageNode = $StorageGroup->getMasterStorageNode();
         if ($countmc >= $countmctot) {
             throw new Exception(_('Please wait until a slot is open<br/>There are currently ' . $countmc . ' tasks in queue<br/>Your server only allows ' . $countmctot));
         }
         $MulticastSession = new MulticastSessions(array('name' => trim($_REQUEST['name']), 'port' => $this->FOGCore->getSetting('FOG_UDPCAST_STARTINGPORT'), 'image' => $Image->get('id'), 'stateID' => 0, 'sessclients' => $_REQUEST['count'], 'isDD' => $Image->get('imageTypeID'), 'starttime' => $this->formatTime('now', 'Y-m-d H:i:s'), 'interface' => $StorageNode->get('interface'), 'logpath' => $Image->get('path')));
         if (!$MulticastSession->save()) {
             $this->FOGCore->setMessage(_('Failed to create Session'));
         }
         // Sets a new port number so you can create multiple Multicast Tasks.
         $randomnumber = mt_rand(24576, 32766) * 2;
         while ($randomnumber == $MulticastSession->get('port')) {
             $randomnumber = mt_rand(24576, 32766) * 2;
         }
         $this->FOGCore->setSetting('FOG_UDPCAST_STARTINGPORT', $randomnumber);
         $this->FOGCore->setMessage(_('Multicast session created') . '<br />' . $MulticastSession->get('name') . ' has been started on port ' . $MulticastSession->get('port'));
     } catch (Exception $e) {
         $this->FOGCore->setMessage($e->getMessage());
     }
     $this->FOGCore->redirect('?node=' . $this->node . '&sub=multicast');
 }
 public function add_storage_group_post()
 {
     // Hook
     $this->HookManager->processEvent('STORAGE_GROUP_ADD_POST');
     // POST
     try {
         // Error checking
         if (empty($_REQUEST['name'])) {
             throw new Exception($this->foglang['SGNameReq']);
         }
         if ($this->getClass('StorageGroupManager')->exists($_REQUEST['name'])) {
             throw new Exception($this->foglang['SGExist']);
         }
         // Create new Object
         $StorageGroup = new StorageGroup(array('name' => $_REQUEST['name'], 'description' => $_REQUEST['description']));
         // Save
         if ($StorageGroup->save()) {
             // Hook
             $this->HookManager->processEvent('STORAGE_GROUP_ADD_POST_SUCCESS', array('StorageGroup' => &$StorageGroup));
             // Log History event
             $this->FOGCore->logHistory(sprintf('%s: ID: %s, Name: %s', $this->foglang['SGCreated'], $StorageGroup->get('id'), $StorageGroup->get('name')));
             // Set session message
             $this->FOGCore->setMessage($this->foglang['SGCreated']);
             // Redirect to new entry
             $this->FOGCore->redirect(sprintf('?node=%s&sub=edit-storage-group&%s=%s', $_REQUEST['node'], $this->id, $StorageGroup->get('id')));
         } else {
             throw new Exception($this->foglang['DBupfailed']);
         }
     } catch (Exception $e) {
         // Hook
         $this->HookManager->processEvent('STORAGE_GROUP_ADD_POST_FAIL', array('StorageGroup' => &$StorageGroup));
         // Log History event
         $this->FOGCore->logHistory(sprintf('%s add failed: Name: %s, Error: %s', $this->foglang['SG'], $_REQUEST['name'], $e->getMessage()));
         // Set session message
         $this->FOGCore->setMessage($e->getMessage());
         // Redirect to new entry
         $this->FOGCore->redirect($this->formAction);
     }
 }
Пример #4
0
require_once '../commons/base.inc.php';
try {
    // Send the dmi information.
    if ($_REQUEST['action'] == 'dmi') {
        print $FOGCore->getSetting('FOG_PLUGIN_CAPONE_DMI');
    } else {
        if ($_REQUEST['action'] == 'imagelookup' && $_REQUEST['key'] != null) {
            $key = trim(base64_decode(trim($_REQUEST['key'])));
            // Find the key association
            $Capones = $FOGCore->getClass('CaponeManager')->find();
            if ($FOGCore->getClass('CaponeManager')->count() > 0) {
                foreach ($Capones as $Capone) {
                    if (stristr($key, $Capone->get('key'))) {
                        $Image = new Image($Capone->get('imageID'));
                        $OS = new OS($Capone->get('osID'));
                        $StorageGroup = new StorageGroup($Image->get('storageGroupID'));
                        $StorageNode = $StorageGroup->getMasterStorageNode();
                        switch ($Image->get('imageTypeID')) {
                            case 1:
                                $imgType = 'n';
                                break;
                            case 2:
                                $imgType = 'mps';
                                break;
                            case 3:
                                $imgType = 'mpa';
                                break;
                            case 4:
                                $imgType = 'dd';
                                break;
                        }
Пример #5
0
	public function __construct($show){			
		$WebServer = $GLOBALS['WebServer'];
		$MythRokuDir = $GLOBALS['MythRokuDir'];
		$RokuDisplayType = $GLOBALS['RokuDisplayType'];
		$BitRate = $GLOBALS['BitRate'];
						
		$this->media = new media(
			array(
				'streamFormat'=>new streamFormat(array('content'=>'mp4'))
				, 'streamQuality'=>new streamQuality(array('content'=>$RokuDisplayType))
				, 'streamBitrate'=>new streamBitrate(array('content'=>$BitRate))
				, 'streamUrl'=>new streamUrl()
			)
		);
		if(1==0){ //dummy to make editing easier - RSH
		}elseif(is_a($show,'Weather')){
			//handles Weather current conditions, forecast items, and alerts schemae
			
			$ShowLength = $show->Delay;
			$title = "$show->Location";
			$title .= empty($show->Temperature) ? "" : ", $show->Temperature";
			$title .= empty($show->Description) ? "" : ", $show->Description";
			$subtitle = empty($show->Message) ? $show->Conditions : $show->Message;
			$subtitle .= empty($show->WindDirection) ? "" : ", $show->WindDirection";
			$subtitle .= empty($show->WindSpeed) ? "" : "@$show->WindSpeed";
			$subtitle .= empty($show->WindGust) ? "" : ", G$show->WindGust";
			$subtitle .= empty($show->Humidity) ? "" : ", hum $show->Humidity";
			$subtitle .= empty($show->Clouds) ? "" : ", vis $show->Clouds mi.";
			$genre = empty($show->Until) ? $show->Temperature : $show->Until;
			$synopsis = "$subtitle $show->Source";

			$this->title = new title(array('content'=>$title)); 
			$this->contentQuality = new contentQuality(array('content'=>$RokuDisplayType));
			$this->subtitle = new subtitle(array('content'=>$subtitle));
			$this->addToAttributes('sdImg', "$show->Icon");
			$this->addToAttributes('hdImg', "$show->Icon");
			$this->contentId = new contentId(array('content'=>$show->Location));
			//$this->contentType = new contentType(array('content'=>'TV'));
			//$this->media->streamUrl->setContent("$streamUrl "); //yes the space is required
			
			$this->synopsis = new synopsis(array('content'=>$synopsis));
			$this->genres = new genres(array('content'=>$genre));
			$this->runtime = new runtime(array('content'=>$ShowLength));
						
			$this->date = new date(array('content'=>$show->AsOf));
			$this->tvormov = new tvormov(array('content'=>'weather'));
		}elseif(is_a($show,'Program')){
			/// MythTV Program schema
			
			$ShowLength = convert_datetime($show->EndTime) - convert_datetime($show->StartTime);
			if($show->isScheduled){
				$imgUrl = "$WebServer/$MythRokuDir/images/oval_green.png";
			} elseif($show->isRecording){
				$imgUrl = "$WebServer/$MythRokuDir/images/oval_blue.png";
				$show->Category = 'NOW RECORDING!';
			} elseif($show->hasJob) {
				$imgUrl = "$WebServer/$MythRokuDir/images/oval_orange.png";
				$show->Category = 'NOW PROCESSING A JOB!';
			} elseif($show->isConflict) {
				$imgUrl = "$WebServer/$MythRokuDir/images/oval_red.png";
				$show->Category = 'SCHEDULE CONFLICT!';
			} else {
				$imgUrl = "$WebServer/$MythRokuDir/images/oval_grey.png";
			}
			
			$this->title = new title(array('content'=>normalizeHtml($show->Title))); 
			$this->contentQuality = new contentQuality(array('content'=>$RokuDisplayType));
			$this->subtitle = new subtitle(array('content'=>normalizeHtml($show->SubTitle)));
			$this->addToAttributes('sdImg', $imgUrl);
			$this->addToAttributes('hdImg', $imgUrl);
			$this->contentId = new contentId(array('content'=>$show->ProgramId));
			//$this->contentType = new contentType(array('content'=>'TV'));
			//$this->media->streamUrl->setContent("$streamUrl "); //yes the space is required
			$this->synopsis = new synopsis(array('content'=>normalizeHtml($show->Description)));
			$this->genres = new genres(array('content'=>normalizeHtml($show->Category)));
			$this->runtime = new runtime(array('content'=>$ShowLength));
			if(!is_a($show, 'ProgramTpl)'))
				$this->date = new date(array('content'=>date("F j, Y, g:i a", convert_datetime($show->StartTime))));
			else
				$this->date = new date(array('content'=>$show->StartTime));
			$this->tvormov = new tvormov(array('content'=>'upcoming'));
		}elseif(is_a($show,'Guide')){
			//handles Pilots/Premieres schema
			
			$ShowLength = convert_datetime($show->endtime) - convert_datetime($show->starttime);
			$ImgType = ($show->subtitle == 'Pilot' ? "rectangle" : "oval");
			if($show->recstatus == -1){
				$imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_blue.png";
				$show->category .= ' (WILL RECORD)';
			} elseif($show->recstatus == 10 || $show->recstatus == 7){ //inactive or conflict
				$imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_purple.png";
				$show->category .= ' (' . $show->getStatusName( $show->recstatus ) . ')';
			} elseif($show->last && $show->first){
				$imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_red.png";
				if(!empty($show->recstatus) && $show->recstatus != 10 && $show->recstatus != 7) { 
					$imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_grey.png";
					$show->category .= ' (' . $show->getStatusName( $show->recstatus ) . ')';
				} else {
					$show->category .= ' (ONLY CHANCE)';
				}
			} elseif($show->last) {
				$imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_orange.png";
				if(!empty($show->recstatus) && $show->recstatus != 10 && $show->recstatus != 7) { 
					$imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_grey.png";
					$show->category .= ' (' . $show->getStatusName( $show->recstatus ) . ')';
				} else {
					$show->category .= ' (LAST CHANCE)';
				}				
			} else {
				if(!empty($show->recstatus)) {
					$imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_grey.png";
					$show->category .= ' (' . $show->getStatusName( $show->recstatus ) . ')';
				} else {
					$imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_green.png";
				}
			}
			
			$this->title = new title(array('content'=>normalizeHtml($show->station.' '.$show->title)));
			$this->contentQuality = new contentQuality(array('content'=>$RokuDisplayType));
			$this->subtitle = new subtitle(array('content'=>normalizeHtml($show->subtitle)));
			$this->addToAttributes('sdImg', $imgUrl);
			$this->addToAttributes('hdImg', $imgUrl);
			$this->contentId = new contentId(array('content'=>$show->programid));
			//$this->contentType = new contentType(array('content'=>'TV'));
			//$this->media->streamUrl->setContent("$streamUrl "); //yes the space is required
			$this->synopsis = new synopsis(array('content'=>normalizeHtml($show->description)));
			$this->genres = new genres(array('content'=>normalizeHtml($show->category)));
			$this->runtime = new runtime(array('content'=>$ShowLength));
			$this->date = new date(array('content'=>date("F j, Y, g:i a", convert_datetime($show->starttime))));
			$this->tvormov = new tvormov(array('content'=>'new'));			
		}elseif(is_a($show,'Recorded')){
			/// TV from Recorded table
			
			$ShowLength = convert_datetime($show->endtime) - convert_datetime($show->starttime);
	    	$streamfile  = $show->storagegroups->dirname . $show->basename;
	
	    	$parms = array('image'=>$streamfile);
	    	$streamUrl = "$WebServer/$MythRokuDir/imageSvc.php?"
	    		.http_build_query($parms);
	
	    	$parms = array('preview'=>str_pad($show->chanid, 6, "_", STR_PAD_LEFT).rawurlencode($show->starttime));
	    	$imgUrl = "$WebServer/$MythRokuDir/imageSvc.php?" 
	    		.http_build_query($parms);			
						
			$this->title = new title(array('content'=>normalizeHtml($show->title))); 
			$this->contentQuality = new contentQuality(array('content'=>$RokuDisplayType));
			$this->subtitle = new subtitle(array('content'=>normalizeHtml($show->subtitle)));
			$this->addToAttributes('sdImg', $imgUrl);
			$this->addToAttributes('hdImg', $imgUrl);
			$this->contentId = new contentId(array('content'=>$show->basename));
			$this->contentType = new contentType(array('content'=>'TV'));
			$this->media->streamUrl->setContent("$streamUrl "); //yes the space is required
			$this->synopsis = new synopsis(array('content'=>normalizeHtml($show->description)));
			$this->genres = new genres(array('content'=>normalizeHtml($show->category.' ('.$show->programid.' '.$show->airdate.')')));
			$this->runtime = new runtime(array('content'=>$ShowLength));
			$this->date = new date(array('content'=>date("F j, Y, g:i a", convert_datetime($show->starttime))));
			$this->programid = new programid(array('content'=>$show->programid));
			$this->airdate = new airdate(array('content'=>$show->airdate));
			$this->tvormov = new tvormov(array('content'=>'tv'));
			$this->delcommand = new delcommand(array('content'=>"$WebServer/mythroku/mythtv_tv_del.php?basename=$show->basename"));
		}elseif(is_a($show,'VideoMetadata')){
			/// Video from VideoMetadata table
			
			$videos = StorageGroup::first( array('conditions' => array('groupname = ?', 'Videos')) );	    	
	    	$streamfile = $videos->dirname . $show->filename;
	    	
	    	$parms = array('image'=>$streamfile);
	    	$streamUrl = "$WebServer/$MythRokuDir/imageSvc.php?"
	    		.http_build_query($parms);
	    	
			// http://www.mythtv.org/wiki/Video_Library#Metadata_Grabber_Troubleshooting
			// http://www.mythtv.org/wiki/MythVideo_File_Parsing#Filenames
//			if(!empty($show->screenshot)){
				$screenart = StorageGroup::first( array('conditions' => array('groupname = ?', 'Screenshots')) );
				$imgfile = !empty($screenart) && !empty($show->screenshot) ? $screenart->dirname . $show->screenshot : "images/oval_grey.png";
//			}elseif(!empty($show->fanart)){
//				$fanart = StorageGroup::first( array('conditions' => array('groupname = ?', 'Fanart')) );
//				$imgfile = $fanart->dirname . $show->fanart;
//			}else{
//				$coverart = StorageGroup::first( array('conditions' => array('groupname = ?', 'Coverart')) );
//				$imgfile = $coverart->dirname . $show->coverfile;
//			}
			//TODO coverart and fanart are 5-10X sizeof screenshots.  videometadata doesn't contain screenshots for movies.  create screenshots and update db
	    	$parms = array('image'=>$imgfile);
	    	$imgUrl = "$WebServer/$MythRokuDir/imageSvc.php?" 
	    		.http_build_query($parms);			
	    		    	
	    	//TODO lookup genres for item::genres.  can be an array?	 			
	    	$category = VideoCategory::first( array('conditions' => array('intid = ?', $show->category)) );    	

			$this->title = new title(array('content'=>normalizeHtml($show->title))); 
			$this->contentQuality = new contentQuality(array('content'=>$RokuDisplayType));
			$this->subtitle = new subtitle(array('content'=>normalizeHtml($show->subtitle)));
			$this->addToAttributes('sdImg', $imgUrl);
			$this->addToAttributes('hdImg', $imgUrl);
			$this->contentId = new contentId(array('content'=>$show->filename));
			$this->contentType = new contentType(array('content'=>'Movie'));
			$this->media->streamUrl->setContent("$streamUrl "); //yes the space is required
			$this->synopsis = new synopsis(array('content'=>normalizeHtml($show->plot)));
			$season = '(S'.$show->season.'E'.$show->episode.' '.(new DateTime($show->starttime))->format('Y-m-d').')';
			$this->genres = new genres(array('content'=>normalizeHtml(empty($category->category) ? '':$category->category).' '.$season));
			$this->runtime = new runtime(array('content'=>$show->length * 60));
			$this->date = new date(array('content'=>date("Y-m-d", convert_datetime($show->starttime))));
			$this->programid = new programid(
				array('content'=>
						sprintf("%02d", $show->season)
						.'.'
						.sprintf("%03d",$show->episode)
				)
			);
			$this->tvormov = new tvormov(array('content'=>'movie'));
			$this->starrating = new starrating(array('content'=>$show->userrating * 10));
		}else{
			parent::__construct($show);
		}				
	}