07-12-2015, 00:32:36
Hallo,
wenn jemand Probleme mit der Sprachausgabe hat, die PHPSonos.inc.php wurde zur Lösung geändert.
Dies wurde am Ende des Scripts verändert:
function getHeaderData($header) {
$headerParts = preg_split("/\n/", $header);
$headerData = array();
foreach($headerParts as $headerPart) {
$key_value = explode(':',$headerPart);
$headerData[trim($key_value[0])] = (isset($key_value[1]) ? trim($key_value[1]): "");
}
return $headerData;
}
private function sendPacket( $content )
{
$fp = fsockopen($this->address, 1400 /* Port */, $errno, $errstr, 10);
if (!$fp)
throw new Exception("Error opening socket: ".$errstr." (".$errno.")");
fputs ($fp, $content);
$ret = "";
while (!feof($fp)) {
$ret.= fgetss($fp,12; // filters xml answer
}
fclose($fp);
if(strpos($ret, "200 OK") === false) {
IPS_LogMessage ( "sendPacket", $ret);
throw new Exception("Error sending command: ".$ret);
}
// TAG_DEBUG_DEEP sendpacketdebug
//echo "sendPacketDebug: "; //DEBUG
// IPS_LogMessage("WHOLE",$ret);
$parts = preg_split("/\r\n\r\n/", $ret); // split to header und body
$header = $parts[0];
$headerData = $this->getHeaderData($header);
if (isset($headerData["TRANSFER-ENCODING"]) && $headerData["TRANSFER-ENCODING"] === "chunked") {
$chunked = true;
}
else {
$chunked = false;
}
$body = $parts[1];
$array = preg_split("/\r\n/", $body); // split to header und body
if (count($array) > 0) {
$index = count($array) - 1;
}
else {
$index = null;
}
for ($i=0; $i < count($array); $i++) {
if (strpos($array[$i], '<DIDL') !== false) {
$index = $i;
}
else {
if (!ctype_xdigit(trim($array[$i]))) { // is not hex
$array[$index] .= $array[$i];
}
}
}
if ($index !== null) {
$returnContent = $array[$index];
}
else {
$returnContent = $body;
}
return $returnContent;
}
}
wenn jemand Probleme mit der Sprachausgabe hat, die PHPSonos.inc.php wurde zur Lösung geändert.
Dies wurde am Ende des Scripts verändert:
function getHeaderData($header) {
$headerParts = preg_split("/\n/", $header);
$headerData = array();
foreach($headerParts as $headerPart) {
$key_value = explode(':',$headerPart);
$headerData[trim($key_value[0])] = (isset($key_value[1]) ? trim($key_value[1]): "");
}
return $headerData;
}
private function sendPacket( $content )
{
$fp = fsockopen($this->address, 1400 /* Port */, $errno, $errstr, 10);
if (!$fp)
throw new Exception("Error opening socket: ".$errstr." (".$errno.")");
fputs ($fp, $content);
$ret = "";
while (!feof($fp)) {
$ret.= fgetss($fp,12; // filters xml answer
}
fclose($fp);
if(strpos($ret, "200 OK") === false) {
IPS_LogMessage ( "sendPacket", $ret);
throw new Exception("Error sending command: ".$ret);
}
// TAG_DEBUG_DEEP sendpacketdebug
//echo "sendPacketDebug: "; //DEBUG
// IPS_LogMessage("WHOLE",$ret);
$parts = preg_split("/\r\n\r\n/", $ret); // split to header und body
$header = $parts[0];
$headerData = $this->getHeaderData($header);
if (isset($headerData["TRANSFER-ENCODING"]) && $headerData["TRANSFER-ENCODING"] === "chunked") {
$chunked = true;
}
else {
$chunked = false;
}
$body = $parts[1];
$array = preg_split("/\r\n/", $body); // split to header und body
if (count($array) > 0) {
$index = count($array) - 1;
}
else {
$index = null;
}
for ($i=0; $i < count($array); $i++) {
if (strpos($array[$i], '<DIDL') !== false) {
$index = $i;
}
else {
if (!ctype_xdigit(trim($array[$i]))) { // is not hex
$array[$index] .= $array[$i];
}
}
}
if ($index !== null) {
$returnContent = $array[$index];
}
else {
$returnContent = $body;
}
return $returnContent;
}
}