} // Turn on warnings error_reporting($errlevel); if (empty($arrLayout)) { require_once "default-mobileconfig.php"; } if (empty($_GET["a"])) { $_GET["a"] = "l"; } $action = $_GET["a"]; if (!empty($_GET["bc"])) { $breadcrumb = $_GET["bc"]; } else { $breadcrumb = ""; } $params = getParameters($_GET); if (empty($_GET["w"])) { $_GET["w"] = "wXBMCLibrary"; } $widget = $_GET["w"]; if (empty($params['href'])) { $params['href'] = "index.php?w=" . $widget; } ?> <html> <head> <title>Media Front Page - Mobile</title> <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"> <link href="mobile.css" rel="stylesheet" type="text/css" /> <meta name="viewport" content="initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" /> <script type="text/javascript" charset="utf-8">
} } else { error_log('[SWX] Warning: No referring URL received from Flash. Cross-domain will not be supported on this call regardless of allowDomain setting.'); } } // Check if the className is supplied as a GET var. If so, // we'll use those. Using GET is useful for debugging. //if (isset($_GET['serviceClass'])) // (array_key_exists('serviceClass', $_GET)) if ($_SERVER['REQUEST_METHOD'] === 'GET') { // GET //error_log('[SWX] INFO Using GET.'); getParameters($_GET); } else { // POST //error_log('[SWX] INFO Using POST.'); getParameters($_POST); } // Security: Check that only allowed characters are present in the URL. require_once 'lib/Validate.php'; $v = new Validate(); /* $options = array ( 'domain_check' => false, 'allow_schemes' => array ( 'http', 'https', 'file' ), 'strict' => '' ); */
<?php //**BEGIN DATABASE CONNECTIE**// $db = mysqli_connect("localhost", "root", "", "layar_project"); if (mysqli_connect_errno()) { echo "Fout bij verbinden met database: " . mysqli_connect_error(); } //Array van namen van de benodigde parameters voor de getPOI request $parameternamen = array('layerName', 'lat', 'lon', 'radius', 'userId'); //Array voor de op te vragen parameters uit de getPOI request URL $parameters = array(); //Paramaters array opvullen, met de waarden uit de getPOI request URL, via de getParameters functie $parameters = getParameters($parameternamen); //**PARAMETERS UIT URL LEZEN**// function getParameters($parameternamen) { $parametersArray = array(); try { foreach ($parameternamen as $parameternaam) { if (isset($_GET[$parameternaam])) { $parametersArray[$parameternaam] = $_GET[$parameternaam]; } else { throw new Exception($parameternaam . ' parameter is niet meegegeven met de getPOI request.'); } } return $parametersArray; } catch (Exception $e) { echo 'Fout: ' . $e->getMessage(); } } //**POI'S EN VERBRUIK VAN DATABASE HALEN (wordt opgeroepen bij opbouw JSON response)**//
unset($urlArr[count($urlArr) - 1]); } } } else { // http://localhost/ $module_name = $DEFAULT_MODULE; $view_name = $DEFAULT_VIEW; $profile = BizSystem::getUserProfile(); if ($profile['roleStartpage'][0]) { $DEFAULT_URL = APP_INDEX . $profile['roleStartpage'][0]; } header("Location: {$DEFAULT_URL}"); } $TARGET_VIEW = $module_name . ".view." . $view_name; $_GET['view'] = $_REQUEST['view'] = $TARGET_VIEW; $PARAM_MAPPING = getParameters($urlArr); if (isset($PARAM_MAPPING)) { foreach ($PARAM_MAPPING as $param => $value) { //if (isset($_GET[$param])) $_GET[$param] = $_REQUEST[$param] = $value; } } include dirname(__FILE__) . '/controller.php'; function getViewName($url_path) { if (preg_match_all("/([a-z]*)_?/si", $url_path, $match)) { $view_name = ""; $match = $match[1]; foreach ($match as $part) { if ($part) { $part = ucwords($part);
} } } $musicDB->close(); if (Play() == false) { $Continue = false; } Send("ACTION Ds/Playlist 1 IdArray"); if ($DEBUG > 0) { //LogWrite($data); //print_r($State); } $DataHandled = true; } } elseif (strpos($data, "Volume") !== false) { $D = getParameters($data); // Here things happens - we execute the actions sent from the // application, by issuing a number of ACTIONs. if (strpos($data, "Volume Set ") !== false) { //Volume Set \"(\d+)\" $value = $D[0]; if ($value > $State['MAX_VOLUME']) { $value = $State['MAX_VOLUME']; } if ($value != $State['Volume'] && $value != "") { LogWrite("VolumeSet: " . $value); if (Send("ACTION Ds/Volume 1 SetVolume \"" . $value . "\"") == false) { $Continue = false; } $State['Volume'] = $value; }
/** * execute * * Executes the run() method which is inside all application controllers * * @return void * @link */ function execute() { global $Load, $ZP; $applicationController = FALSE; $match = FALSE; $special = FALSE; $params = array(); if (file_exists("www/config/routes.php")) { include "www/config/routes.php"; if (is_array($routes)) { $application = segment(0, isLang()); foreach ($routes as $route) { $pattern = $route["pattern"]; $match = preg_match($pattern, $application); if ($match) { $application = $route["application"]; $applicationController = $route["controller"]; $method = $route["method"]; $params = $route["params"]; break; } } } } if (!$match) { if (!segment(0)) { $application = get("defaultApplication"); } elseif (segment(0) and !segment(1)) { $application = isLang() ? get("defaultApplication") : segment(0); } else { $application = segment(0, isLang()); $applicationController = segment(1, isLang()); if (isController($applicationController, $application)) { $Controller = getController($applicationController, $application); $controllerFile = getController($applicationController, $application, TRUE); $method = segment(2, isLang()); if (!isMethod($method, $Controller)) { if (isMethod("index", $Controller)) { $method = "index"; $special = TRUE; } else { getException("Method \"{$method}\" doesn't exists"); } } } else { $applicationController = FALSE; $Controller = getController(NULL, $application); $controllerFile = getController(NULL, $application, TRUE); $method = segment(1, isLang()); if (!isMethod($method, $Controller)) { if (isMethod("index", $Controller)) { $method = "index"; $special = TRUE; } else { getException("Method \"{$method}\" doesn't exists"); } } } if ($applicationController) { if (segments() >= 3) { $j = isLang() ? 4 : 3; $j = $special ? $j - 1 : $j; for ($i = 0; $i < segments(); $i++) { if (segment($j) or segment($j) === 0) { $params[$i] = segment($j); $j++; } } } } else { $count = $special ? 1 : 2; if (segments() > $count) { $j = isLang() ? 3 : 2; $j = $special ? $j - 1 : $j; for ($i = 0; $i < segments(); $i++) { if (segment($j) or segment($j) === 0) { $params[$i] = segment($j); $j++; } } } } } } if (get("webSituation") !== "Active" and !SESSION("ZanUserID") and $application !== "cpanel") { die(get("webMessage")); } $Load->app($application); $controllerFile = $applicationController ? getController($applicationController, $application, TRUE) : getController(NULL, $application, TRUE); if (!$controllerFile) { getException("The application \"{$application}\" doesn't exists"); } $Controller = isset($Controller) ? $Controller : getController(NULL, $application); if (isset($method) and count($params) > 0) { if (isMethod($method, $Controller)) { try { $Reflection = new ReflectionMethod($Controller, $method); if (!$Reflection->isPublic()) { throw new RuntimeException("The called method is not public.", 100); } call_user_func_array(array($Controller, $method), $params); } catch (RuntimeException $e) { getException($e); } } else { if (isController($controllerFile, TRUE)) { if (isset($method) and count($params) > 0) { if (isMethod($method, $Controller)) { try { $Reflection = new ReflectionMethod($Controller, $method); if (!$Reflection->isPublic()) { throw new RuntimeException("The called method is not public.", 100); } call_user_func_array(array($Controller, $method), $params); } catch (RuntimeException $e) { getException($e); } } } } else { if (method_exists($Controller, "index")) { try { $reflection = new ReflectionMethod($Controller, "index"); if (!$reflection->isPublic()) { throw new RuntimeException("The called method is not public.", 100); } elseif ($Reflection->getNumberOfRequiredParameters() > 0 and count($params) === 0) { throw new RuntimeException("The called method need required parameters (" . getParameters($Reflection->getParameters()) . ").", 200); } call_user_func_array(array($Controller, "index"), $params); } catch (RuntimeException $e) { getException($e); } } else { getException("Method index doesn't exists"); } } } } elseif (isset($method)) { if (isMethod($method, $Controller)) { try { $Reflection = new ReflectionMethod($Controller, $method); if (!$Reflection->isPublic()) { throw new RuntimeException("The called method is not public.", 100); } elseif ($Reflection->getNumberOfRequiredParameters() > 0 and count($params) === 0) { throw new RuntimeException("The called method need required parameters (" . getParameters($Reflection->getParameters()) . ").", 200); } $Controller->{$method}(); } catch (RuntimeException $e) { getException($e); } } else { if (isMethod("index", $Controller)) { call_user_func_array(array($Controller, "index"), $params); } else { getException("Method \"index\" doesn't exists"); } } } else { if (isMethod("index", $Controller)) { try { $Reflection = new ReflectionMethod($Controller, "index"); if (!$Reflection->isPublic()) { throw new RuntimeException("The called method is not public.", 100); } elseif ($Reflection->getNumberOfRequiredParameters() > 0 and count($params) === 0) { throw new RuntimeException("The called method need required parameters (" . getParameters($Reflection->getParameters()) . ").", 200); } call_user_func_array(array($Controller, "index"), $params); } catch (RuntimeException $e) { getException($e); } } else { getException("Method \"index\" doesn't exists"); } } }
$playerList = array(); // Create an array to hold all the map data imported from the data source // and an integer to quickly keep track of the number of maps inside $allMaps = array(); $numOfMaps = 0; // Create an array to use if we're searching for a certain string in map names $filteredMaps = array(); // We also need an array to hold the index values of maps from $allMaps we want // to display on the current page based on viewing mode and sort order $displayedMaps = array(); // Lastly, a global map container used by the printThisMap_...() functions $thisMap = new mapclass(); // Set up the current environment setDefaultValues(); getPreferences(); getParameters(); getRealtimeServerStatus(); // Load all map data from the data source if ($prefs["DATA_LOCATION"] === "mysql") { getMapDetails_mysql(); } else { getMapDetails_text(); } // Grab only the records we need for displaying the current page populateMapsForPage(); // Determine which template file we use based on the arguments passed // in the URL and insert our template file here-- it does the rest // of the work for us. switch ($params["mode"]) { case "single": // only one map to display
require_once dirname(__FILE__) . '/locallib.php'; global $DB; $api = json_decode(json_encode(simplexml_load_file(dirname(__FILE__) . '/ws/broad-ecos-api.xml', null, LIBXML_NOCDATA)), TRUE); $context = loadTokenInfo($_SERVER); if ($context !== null) { // @todo Verificar URI do cliente! $pathInfo = $_SERVER['PATH_INFO']; $requestMethod = $_SERVER['REQUEST_METHOD']; foreach ($api['resourse'] as $resource) { if (!array_key_exists('method', $resource)) { continue; } $matches = pathMatch($resource, $pathInfo); if ($resource['method'] == $requestMethod && $matches['match']) { validateScopes($resource, $context); $params = getParameters($resource, $_REQUEST); $data = null; try { $type = $resource['type']; $data = call_user_func_array('broadecos_ws_type_' . $type, array($resource, $context, $params, $matches['params'])); if (!is_array($data) && !is_object($data)) { throw new NotFoundException(); } } catch (BroadEcosAPIException $e) { http_response_code($e->getStatusCode()); die($e->getMessage()); } header('Content-Type: application/json'); echo json_encode($data); die; }
echo "Error: Operation '{$operation_name}' not registered in batchtool.ini.\n"; return; } if (!is_readable("extension/batchtool/operations/{$operation_name}.php")) { echo "Error: Operation '{$operation_name}' not found in extension/batchtool/operations/.\n"; return; } require_once "extension/batchtool/operations/{$operation_name}.php"; $classname = "{$operation_name}Operation"; $op_obj = new $classname(); $op_objects[] =& $op_obj; if (!$op_obj instanceof BatchToolOperation) { echo "Class {$classname} does not extend BatchToolOperation as it should.\n"; return; } $result = $op_obj->setParameters(getParameters($parm_array)); if ($result !== true) { echo "Error: Operation '{$operation_name}' have faulty parameters: {$result}.\n"; echo $op_obj->getHelpText(); return; } if (isset($options['help'])) { echo $op_obj->getHelpText(); } unset($op_obj); } // If help requested, exit program here if (isset($options['help'])) { return; } // Check that filters and operations exist
public function processMessage($message) { LogWrite("LinnDSClientSocket::processMessage - {$message}"); $DataHandled = false; if ($DEBUG > 1) { LogWrite($message); } if (strpos($message, "Jukebox") !== false) { // Here things happens - we execute the actions sent from the // application, by issuing a number of ACTIONs. $D = getParameters($message); if (strpos($message, "Jukebox PlayNow ") !== false) { //Jukebox PlayNow \"(\d+)\" \"(\d+)\" $JukeBoxPlay = $D[0]; $JukeBoxTrack = $D[1]; LogWrite("JukeBoxPlayNow: " . $JukeBoxPlay . ", " . $JukeBoxTrack); if ($this->listeningSocket->getLPECListeningSocket()->CallClients('SelectPlaylist') == false) { $Continue = false; } if ($this->listeningSocket->getLPECListeningSocket()->CallClients('Stop') == false) { $Continue = false; } $musicDB = new MusicDB(); if ($this->listeningSocket->getLPECListeningSocket()->CallClients1('DeleteAll', $musicDB) == false) { $Continue = false; } if ($this->listeningSocket->getLPECListeningSocket()->CallClients4('InsertDIDL_list', $musicDB, $JukeBoxPlay, $JukeBoxTrack, 0) == false) { $Continue = false; } $musicDB->close(); //Send("ACTION Ds/Jukebox 3 SetCurrentPreset \"" . $JukeBoxPlay . "\""); if ($this->listeningSocket->getLPECListeningSocket()->CallClients('Play') == false) { $Continue = false; } if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Playlist 1 IdArray") == false) { $Continue = false; } $DataHandled = true; } elseif (strpos($message, "Jukebox PlayNext ") !== false) { //Jukebox PlayNext \"(\d+)\" \"(\d+)\" $JukeBoxPlay = $D[0]; $JukeBoxTrack = $D[1]; LogWrite("JukeBoxPlayNext: " . $JukeBoxPlay . ", " . $JukeBoxTrack); if ($this->listeningSocket->getLPECListeningSocket()->CallClients('SelectPlaylist') == false) { $Continue = false; } $musicDB = new MusicDB(); if ($this->listeningSocket->getLPECListeningSocket()->CallClients4('InsertDIDL_list', $musicDB, $JukeBoxPlay, $JukeBoxTrack, $this->getState()->getState('Id')) == false) { $Continue = false; } $musicDB->close(); if ($this->listeningSocket->getLPECListeningSocket()->CallClients('Play') == false) { $Continue = false; } if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Playlist 1 IdArray") == false) { $Continue = false; } if ($DEBUG > 0) { //LogWrite($message); //print_r($State); } $DataHandled = true; } elseif (strpos($message, "Jukebox PlayLater ") !== false) { //Jukebox PlayLater \"(\d+)\" \"(\d+)\" $JukeBoxPlay = $D[0]; $JukeBoxTrack = $D[1]; LogWrite("JukeBoxPlayLater: " . $JukeBoxPlay . ", " . $JukeBoxTrack); if ($this->listeningSocket->getLPECListeningSocket()->CallClients('SelectPlaylist') == false) { $Continue = false; } $musicDB = new MusicDB(); if ($this->listeningSocket->getLPECListeningSocket()->CallClients4('InsertDIDL_list', $musicDB, $JukeBoxPlay, $JukeBoxTrack, end($this->getState()->getState('IdArray'))) == false) { $Continue = false; } $musicDB->close(); if ($this->listeningSocket->getLPECListeningSocket()->CallClients('Play') == false) { $Continue = false; } $this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Playlist 1 IdArray"); if ($DEBUG > 0) { //LogWrite($message); //print_r($State); } $DataHandled = true; } elseif (strpos($message, "Jukebox PlayRandomTracks ") !== false) { //Jukebox PlayRandomTracks \"(\d+)\" \"(\d+)\" $JukeBoxFirstAlbum = $D[0]; $JukeBoxLastAlbum = $D[1]; LogWrite("JukeBoxPlayRandomTracks: " . $JukeBoxFirstAlbum . ", " . $JukeBoxLastAlbum); if ($this->listeningSocket->getLPECListeningSocket()->CallClients('SelectPlaylist') == false) { $Continue = false; } $musicDB = new MusicDB(); if ($this->getState()->getState('TransportState') == "Stopped") { if ($this->listeningSocket->getLPECListeningSocket()->CallClients1('DeleteAll', $musicDB) == false) { $Continue = false; } } for ($i = 0; $i < 50; $i++) { $RandomPreset = rand($JukeBoxFirstAlbum, $JukeBoxLastAlbum); $RandomTrack = rand(1, $musicDB->NumberOfTracks($RandomPreset)); if ($i == 0) { if ($this->listeningSocket->getLPECListeningSocket()->CallClients4('InsertDIDL_list', $musicDB, $RandomPreset, $RandomTrack, end($this->getState()->getState('IdArray'))) == false) { $Continue = false; } } else { if ($this->listeningSocket->getLPECListeningSocket()->CallClients4('InsertDIDL_list', $musicDB, $RandomPreset, $RandomTrack, "%NewId%") == false) { $Continue = false; } } } $musicDB->close(); if ($this->listeningSocket->getLPECListeningSocket()->CallClients('Play') == false) { $Continue = false; } $this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Playlist 1 IdArray"); if ($DEBUG > 0) { //LogWrite($message); //print_r($State); } $DataHandled = true; } } elseif (strpos($message, "Volume") !== false) { $D = getParameters($message); // Here things happens - we execute the actions sent from the // application, by issuing a number of ACTIONs. if (strpos($message, "Volume Set ") !== false) { //Volume Set \"(\d+)\" $value = $D[0]; if ($value > $this->getState()->getState('MAX_VOLUME')) { $value = $this->getState()->getState('MAX_VOLUME'); } if ($value != $this->getState()->getState('Volume') && $value != "") { LogWrite("VolumeSet: " . $value); if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Volume 1 SetVolume \"" . $value . "\"") == false) { $Continue = false; } $this->getState()->setState('Volume', $value); } $DataHandled = true; } elseif (strpos($message, "Volume Incr5") !== false) { //Volume Incr5 if ($this->getState()->getState('Volume') < $this->getState()->getState('MAX_VOLUME') - 5) { LogWrite("VolumeIncr5: "); $value = $this->getState()->getState('Volume'); $value = $value + 5; if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Volume 1 VolumeInc") == false) { $Continue = false; } if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Volume 1 VolumeInc") == false) { $Continue = false; } if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Volume 1 VolumeInc") == false) { $Continue = false; } if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Volume 1 VolumeInc") == false) { $Continue = false; } if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Volume 1 VolumeInc") == false) { $Continue = false; } $this->getState()->setState('Volume', $value); } else { LogWrite("VolumeIncr: IGNORED MAX_VOLUME REACHED"); } $DataHandled = true; } elseif (strpos($message, "Volume Incr") !== false) { //Volume Incr if ($this->getState()->getState('Volume') < $this->getState()->getState('MAX_VOLUME')) { LogWrite("VolumeIncr: "); $value = $this->getState()->getState('Volume'); $value = $value + 1; if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Volume 1 VolumeInc") == false) { $Continue = false; } $this->getState()->setState('Volume', $value); } else { LogWrite("VolumeIncr: IGNORED MAX_VOLUME REACHED"); } $DataHandled = true; } elseif (strpos($message, "Volume Decr5") !== false) { //Volume Decr5 LogWrite("VolumeDecr: "); $value = $this->getState()->getState('Volume'); $value = $value - 5; if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Volume 1 VolumeDec") == false) { $Continue = false; } if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Volume 1 VolumeDec") == false) { $Continue = false; } if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Volume 1 VolumeDec") == false) { $Continue = false; } if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Volume 1 VolumeDec") == false) { $Continue = false; } if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Volume 1 VolumeDec") == false) { $Continue = false; } $this->getState()->setState('Volume', $value); $DataHandled = true; } elseif (strpos($message, "Volume Decr") !== false) { //Volume Decr LogWrite("VolumeDecr: "); $value = $this->getState()->getState('Volume'); $value = $value - 1; if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Volume 1 VolumeDec") == false) { $Continue = false; } $this->getState()->setState('Volume', $value); $DataHandled = true; } elseif (strpos($message, "Volume Reset") !== false) { //Volume Reset LogWrite("VolumeReset: "); $value = 30; LogWrite("VolumeSet: " . $value); if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Volume 1 SetVolume \"" . $value . "\"") == false) { $Continue = false; } $this->getState()->setState('Volume', $value); $DataHandled = true; } } elseif (strpos($message, "Control") !== false) { // Here things happens - we execute the actions sent from the // application, by issuing a number of ACTIONs. if (strpos($message, "Control Play") !== false) { //Control Play if ($this->getState()->getState('TransportState') === "Stopped" || $this->getState()->getState('TransportState') === "Paused") { LogWrite("ControlPlay: "); if ($this->listeningSocket->getLPECListeningSocket()->CallClients('Play') == false) { $Continue = false; } } $DataHandled = true; } elseif (strpos($message, "Control Pause") !== false) { //Control Pause if ($this->getState()->getState('TransportState') !== "Paused") { LogWrite("ControlPause: "); if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Playlist 1 Pause") == false) { $Continue = false; } } else { LogWrite("ControlPause - restart: "); if ($this->listeningSocket->getLPECListeningSocket()->CallClients('Play') == false) { $Continue = false; } } $DataHandled = true; } elseif (strpos($message, "Control Stop") !== false) { //Control Stop if ($this->getState()->getState('TransportState') !== "Stopped") { LogWrite("ControlStop: "); if ($this->listeningSocket->getLPECListeningSocket()->CallClients('Stop') == false) { $Continue = false; } } $DataHandled = true; } elseif (strpos($message, "Control Next") !== false) { //Control Next if ($this->getState()->getState('TransportState') != "Stopped") { LogWrite("ControlNext: "); if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Playlist 1 Next") == false) { $Continue = false; } } $DataHandled = true; } elseif (strpos($message, "Control Previous") !== false) { //Control Previous if ($this->getState()->getState('TransportState') != "Stopped") { LogWrite("ControlPrevious: "); if ($this->listeningSocket->getLPECListeningSocket()->Send("ACTION Ds/Playlist 1 Previous") == false) { $Continue = false; } } $DataHandled = true; } } elseif (strpos($message, "Source") !== false) { // Here things happens - we execute the actions sent from the // application, by issuing a number of ACTIONs. if (strpos($message, "Source Off") !== false) { //Source Off if ($this->getState()->getState('Standby') == "false") { if ($this->listeningSocket->getLPECListeningSocket()->Send('ACTION Ds/Product 1 SetStandby "true"') == false) { $Continue = false; } $this->getState()->setState('Standby', true); } $DataHandled = true; } else { if ($this->getState()->getState('Standby') == "true") { if ($this->listeningSocket->getLPECListeningSocket()->Send('ACTION Ds/Product 1 SetStandby "false"') == false) { $Continue = false; } $this->getState()->setState('Standby', true); } if (strpos($message, "Source Playlist") !== false) { //Source Playlist if ($this->getState()->getState('SourceIndex') != $this->getState()->getStateArray('SourceName', 'Playlist')) { if ($this->listeningSocket->getLPECListeningSocket()->Send('ACTION Ds/Product 1 SetSourceIndex "' . $this->getState()->getStateArray('SourceName', 'Playlist') . '"') == false) { $Continue = false; } } if ($this->listeningSocket->getLPECListeningSocket()->CallClients('Play') == false) { $Continue = false; } $DataHandled = true; } elseif (strpos($message, "Source TV") !== false) { //Source TV if ($this->getState()->getState('SourceIndex') != $this->getState()->getStateArray('SourceName', 'TV')) { if ($this->listeningSocket->getLPECListeningSocket()->Send('ACTION Ds/Product 1 SetSourceIndex "' . $this->getState()->getStateArray('SourceName', 'TV') . '"') == false) { $Continue = false; } } $DataHandled = true; } elseif (strpos($message, "Source Radio") !== false) { //Source Radio if ($this->getState()->getState('SourceIndex') != $this->getState()->getStateArray('SourceName', 'Radio')) { if ($this->listeningSocket->getLPECListeningSocket()->Send('ACTION Ds/Product 1 SetSourceIndex "' . $this - getState()->getStateArray('SourceName', 'Radio') . '"') == false) { $Continue = false; } } $DataHandled = true; } elseif (strpos($message, "Source NetAux") !== false) { //Source NetAux if ($this->getState()->getState('SourceIndex') != $this->getState()->getStateArray('SourceName', 'Net Aux')) { if ($this->listeningSocket->getLPECListeningSocket()->Send('ACTION Ds/Product 1 SetSourceIndex "' . $this->getState()->getStateArray('SourceName', 'Net Aux') . '"') == false) { $Continue = false; } } $DataHandled = true; } } } elseif (strpos($message, "State") !== false) { LogWrite("HTState: " . $this->getState()->dump()); $seri = $this->getState()->Serialize(); LogWrite("Serialized: " . $seri); $this->Send($seri); $DataHandled = true; } return $DataHandled; }
public function processMessage($message) { LogWrite("LPECClientSocket::processMessage - {$message}"); $DataHandled = false; if ($DEBUG > 1) { LogWrite($message); } if (strpos($message, "ALIVE Ds") !== false) { $this->Send("SUBSCRIBE Ds/Product"); $DataHandled = true; } elseif (strpos($message, "ALIVE") !== false) { LogWrite("ALIVE ignored : " . $message); $DataHandled = true; } elseif (strpos($message, "ERROR") !== false) { LogWrite("ERROR ignored : " . $message); $DataHandled = true; } elseif (strpos($message, "SUBSCRIBE") !== false) { // SUBSCRIBE are sent by Linn when a SUBSCRIBE finishes, thus // we send the possible next command (Send) after removing // previous command. // We record the Number to Subscribe action in the array to // help do less work with the events. $front = array_shift($this->Queue); if ($DEBUG > 1) { LogWrite("Command: " . $front . " -> " . $message); } $S1 = substr($front, 10); $S2 = substr($message, 10); $this->SubscribeType[$S1] = $S2; $this->Send(""); $DataHandled = true; } elseif (strpos($message, "RESPONSE") !== false) { // RESPONSE are sent by Linn when an ACTION finishes, thus we // send the possible next command (Send) after removing // previous command. $front = array_shift($this->Queue); if ($DEBUG > 0) { LogWrite("Command: " . $front . " -> " . $message); } if (strpos($front, "ACTION Ds/Product 1 Source ") !== false) { //ACTION Ds/Product 1 Source \"(\d+)\" //RESPONSE \"([[:ascii:]]+?)\" \"([[:ascii:]]+?)\" \"([[:ascii:]]+?)\" \"([[:ascii:]]+?)\" $F = getParameters($front); $D = getParameters($message); //$State['Source_SystemName'][$F[0]] = $D[0]; //$State['Source_Type'][$F[0]] = $D[1]; //$State['Source_Name'][$F[0]] = $D[2]; //$State['Source_Visible'][$F[0]] = $D[3]; $this->getState()->setStateArray('SourceName', $D[2], $F[0]); if ($D[1] == "Playlist") { // We have the Playlist service. subscribe... $this->Send("SUBSCRIBE Ds/Playlist"); //$this->Send("SUBSCRIBE Ds/Jukebox"); } elseif ($D[1] == "Radio") { // We have the Radio service. subscribe... //$this->Send("SUBSCRIBE Ds/Radio"); } } elseif (strpos($front, "ACTION Ds/Playlist 1 Read ") !== false) { //ACTION Ds/Playlist 1 Read \"(\d+)\" //RESPONSE \"([[:ascii:]]+?)\" \"([[:ascii:]]+?)\" $F = getParameters($front); $D = getParameters($message); $this->getState()->setStateArray('PlaylistURLs', $F[0], $D[0]); $this->getState()->setStateArray('PlaylistXMLs', $F[0], $D[1]); $musicDB = new MusicDB(); $musicDB->UpdateQueue($F[0], -1, -1, $D[0], $D[1]); $musicDB->close(); } elseif (strpos($front, "ACTION Ds/Playlist 1 Insert ") !== false) { //ACTION Ds/Playlist 1 Insert \"(\d+)\" \"([[:ascii:]]+?)\" \"([[:ascii:]]+?)\" //RESPONSE \"([[:ascii:]]+?)\" $F = getParameters($front); $D = getParameters($message); $this->getState()->setState('NewId', $D[0]); $this->getState()->setStateArray('PlaylistURLs', $D[0], $F[1]); $this->getState()->setStateArray('PlaylistXMLs', $D[0], $F[2]); $musicDB = new MusicDB(); $musicDB->UpdateQueue($D[0], -1, -1, $F[1], $F[2]); $musicDB->close(); } elseif (strpos($front, "ACTION Ds/Playlist 1 IdArray") !== false) { //ACTION Ds/Playlist 1 IdArray //RESPONSE \"([[:ascii:]]+?)\" \"([[:ascii:]]+?)\" $F = getParameters($front); $D = getParameters($message); $this->getState()->setState('IdArray_Token', $D[0]); $this->getState()->setState('IdArray_base64', $D[1]); $this->getState()->setState('IdArray', unpack("N*", base64_decode($D[1]))); $musicDB = new MusicDB(); $this->CheckPlaylist($musicDB); $musicDB->close(); } $this->Send(""); $DataHandled = true; } elseif (strpos($message, "EVENT ") !== false) { // EVENTs are sent by Your linn - those that were subscribed // to. We think the below ones are interesting.... $E = getEvent($message); if (strpos($message, "EVENT " . $this->SubscribeType['Ds/Product']) !== false) { if (strpos($message, "SourceIndex ") !== false) { $this->getState()->setState('SourceIndex', $E[SourceIndex]); } if (strpos($message, "ProductModel ") !== false) { $this->getState()->setState('ProductModel', $E[ProductModel]); } if (strpos($message, "ProductName ") !== false) { $this->getState()->setState('ProductName', $E[ProductName]); } if (strpos($message, "ProductRoom ") !== false) { $this->getState()->setState('ProductRoom', $E[ProductRoom]); } if (strpos($message, "ProductType ") !== false) { $this->getState()->setState('ProductType', $E[ProductType]); } if (strpos($message, "Standby ") !== false) { $this->getState()->setState('Standby', $E[Standby]); $musicDB = new MusicDB(); $musicDB->SetState("Standby", $E[Standby]); $musicDB->close(); } if (strpos($message, "ProductUrl ") !== false) { $this->getState()->setState('ProductUrl', $E[ProductUrl]); } if (strpos($message, "Attributes ") !== false) { $this->getState()->setState('Attributes', $E[Attributes]); if (strpos($E[Attributes], "Volume") !== false) { $this->Send("SUBSCRIBE Ds/Volume"); } if (strpos($E[Attributes], "Info") !== false) { //$this->Send("SUBSCRIBE Ds/Info"); } if (strpos($E[Attributes], "Time") !== false) { //$this->Send("SUBSCRIBE Ds/Time"); } } if (strpos($message, "SourceCount ") !== false) { for ($i = 0; $i < $E[SourceCount]; $i++) { $this->Send("ACTION Ds/Product 1 Source \"" . $i . "\""); } } $DataHandled = true; } elseif (strpos($message, "EVENT " . $this->SubscribeType['Ds/Playlist']) !== false) { if (strpos($message, "TransportState ") !== false) { $this->getState()->setState('TransportState', $E[TransportState]); $musicDB = new MusicDB(); $musicDB->SetState("TransportState", $E[TransportState]); $musicDB->close(); } if (strpos($message, "Id ") !== false) { $this->getState()->setState('Id', $E[Id]); $musicDB = new MusicDB(); $musicDB->SetState("LinnId", $E[Id]); $musicDB->close(); } if (strpos($message, "IdArray ") !== false) { $this->getState()->setState('IdArray_base64', $E[IdArray]); $this->getState()->setState('IdArray', unpack("N*", base64_decode($E[IdArray]))); $musicDB = new MusicDB(); $this->CheckPlaylist($musicDB); $musicDB->close(); } if (strpos($message, "Shuffle ") !== false) { $this->getState()->setState('Shuffle', $E[Shuffle]); } if (strpos($message, "Repeat ") !== false) { $this->getState()->setState('Repeat', $E[Repeat]); } if (strpos($message, "TrackDuration ") !== false) { $this->getState()->setState('TrackDuration', $E[TrackDuration]); } if (strpos($message, "TrackCodecName ") !== false) { $this->getState()->setState('TrackCodecName', $E[TrackCodecName]); } if (strpos($message, "TrackSampleRate ") !== false) { $this->getState()->setState('TrackSampleRate', $E[TrackSampleRate]); } if (strpos($message, "TrackBitRate ") !== false) { $this->getState()->setState('TrackBitRate', $E[TrackBitRate]); } if (strpos($message, "TrackLossless ") !== false) { $this->getState()->setState('TrackLossless', $E[TrackLossless]); } $DataHandled = true; } elseif (strpos($message, "EVENT " . $this->SubscribeType['Ds/Volume']) !== false) { if (strpos($message, "Volume ") !== false) { LogWrite("Event Volume"); $this->getState()->setState('Volume', $E[Volume]); $musicDB = new MusicDB(); $musicDB->SetState("Volume", $E[Volume]); $musicDB->close(); } if (strpos($message, "Mute ") !== false) { $this->getState()->setState('Mute', $E[Mute]); $musicDB = new MusicDB(); $musicDB->SetState("Mute", $E[Mute]); $musicDB->close(); } $DataHandled = true; } elseif (strpos($message, "EVENT " . $this->SubscribeType['Ds/Jukebox']) !== false) { if (strpos($message, "CurrentPreset ") !== false) { $this->getState()->setState('CurrentPreset', $E[CurrentPreset]); } if (strpos($message, "CurrentBookmark ") !== false) { $this->getState()->setState('CurrentBookmark', $E[CurrentBookmark]); } $DataHandled = true; } else { LogWrite("UNKNOWN : " . $message); $DataHandled = true; } } return $DataHandled; }
{ # implements GET method for person # Example: GET /staffapi/person/13 echo "Getting person: " . $id; } function deletePerson($id) { # implements DELETE method for person # Example: DELETE /staffapi/person/13 echo "Deleting person: " . $id; } # Main # ---- $resource = getResource(); $request_method = getMethod(); $parameters = getParameters(); # Redirect to appropriate handlers. if ($resource[0] == "staffapi") { if ($request_method == "POST" && $resource[1] == "person") { postPerson($parameters); } else { if ($request_method == "GET" && $resource[1] == "persons") { getPersons(); } else { if ($request_method == "GET" && $resource[1] == "person") { getPerson($resource[2]); } else { if ($request_method == "DELETE" && $resource[1] == "person") { deletePerson($resource[2]); } else { http_response_code(405);