@@ -49,107 +49,107 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | /* File types. */ |
| 51 | 51 | $file_class = array( |
| 52 | - 'm3u' => 'object.container.storageFolder', |
|
| 53 | - 'xspf' => 'object.container.storageFolder', |
|
| 54 | - 'xml' => 'object.container.storageFolder', |
|
| 55 | - |
|
| 56 | - 'bmp' => 'object.item.imageItem.photo', |
|
| 57 | - 'gif' => 'object.item.imageItem.photo', |
|
| 58 | - 'ico' => 'object.item.imageItem.photo', |
|
| 59 | - 'png' => 'object.item.imageItem.photo', |
|
| 60 | - 'jpe' => 'object.item.imageItem.photo', |
|
| 61 | - 'jpg' => 'object.item.imageItem.photo', |
|
| 62 | - 'jpeg' => 'object.item.imageItem.photo', |
|
| 63 | - 'tif' => 'object.item.imageItem.photo', |
|
| 64 | - 'tiff' => 'object.item.imageItem.photo', |
|
| 65 | - 'svg' => 'object.item.imageItem.photo', |
|
| 66 | - 'svgz' => 'object.item.imageItem.photo', |
|
| 67 | - |
|
| 68 | - 'flac' => 'object.item.audioItem.musicTrack', |
|
| 69 | - 'mp3' => 'object.item.audioItem.musicTrack', |
|
| 70 | - 'wav' => 'object.item.audioItem.musicTrack', |
|
| 71 | - 'wma' => 'object.item.audioItem.musicTrack', |
|
| 72 | - |
|
| 73 | - 'flv' => 'object.item.videoItem', |
|
| 74 | - 'f4v' => 'object.item.videoItem', |
|
| 75 | - '3g2' => 'object.item.videoItem', |
|
| 76 | - '3gp' => 'object.item.videoItem', |
|
| 77 | - '3gp2' => 'object.item.videoItem', |
|
| 78 | - '3gpp' => 'object.item.videoItem', |
|
| 79 | - 'asf' => 'object.item.videoItem', |
|
| 80 | - 'asx' => 'object.item.videoItem', |
|
| 81 | - 'avi' => 'object.item.videoItem.movie', |
|
| 82 | - 'dat' => 'object.item.videoItem', |
|
| 83 | - 'iso' => 'object.item.videoItem', |
|
| 84 | - 'm2t' => 'object.item.videoItem', |
|
| 85 | - 'm2ts' => 'object.item.videoItem', |
|
| 86 | - 'm2v' => 'object.item.videoItem', |
|
| 87 | - 'm4v' => 'object.item.videoItem', |
|
| 88 | - 'mp2v' => 'object.item.videoItem', |
|
| 89 | - 'mp4' => 'object.item.videoItem', |
|
| 90 | - 'mp4v' => 'object.item.videoItem', |
|
| 91 | - 'mpe' => 'object.item.videoItem', |
|
| 92 | - 'mpeg' => 'object.item.videoItem', |
|
| 93 | - 'mpg' => 'object.item.videoItem', |
|
| 94 | - 'mod' => 'object.item.videoItem', |
|
| 95 | - 'mov' => 'object.item.videoItem', |
|
| 96 | - 'mkv' => 'object.item.videoItem.videoBroadcast', |
|
| 97 | - 'mts' => 'object.item.videoItem', |
|
| 98 | - 'ogg' => 'object.item.videoItem', |
|
| 99 | - 'swf' => 'object.item.videoItem', |
|
| 100 | - 'vob' => 'object.item.videoItem', |
|
| 101 | - 'ts' => 'object.item.videoItem', |
|
| 102 | - 'webm' => 'object.item.videoItem', |
|
| 103 | - 'wm' => 'object.item.videoItem', |
|
| 104 | - 'wmv' => 'object.item.videoItem', |
|
| 105 | - 'wmx' => 'object.item.videoItem', |
|
| 52 | + 'm3u' => 'object.container.storageFolder', |
|
| 53 | + 'xspf' => 'object.container.storageFolder', |
|
| 54 | + 'xml' => 'object.container.storageFolder', |
|
| 55 | + |
|
| 56 | + 'bmp' => 'object.item.imageItem.photo', |
|
| 57 | + 'gif' => 'object.item.imageItem.photo', |
|
| 58 | + 'ico' => 'object.item.imageItem.photo', |
|
| 59 | + 'png' => 'object.item.imageItem.photo', |
|
| 60 | + 'jpe' => 'object.item.imageItem.photo', |
|
| 61 | + 'jpg' => 'object.item.imageItem.photo', |
|
| 62 | + 'jpeg' => 'object.item.imageItem.photo', |
|
| 63 | + 'tif' => 'object.item.imageItem.photo', |
|
| 64 | + 'tiff' => 'object.item.imageItem.photo', |
|
| 65 | + 'svg' => 'object.item.imageItem.photo', |
|
| 66 | + 'svgz' => 'object.item.imageItem.photo', |
|
| 67 | + |
|
| 68 | + 'flac' => 'object.item.audioItem.musicTrack', |
|
| 69 | + 'mp3' => 'object.item.audioItem.musicTrack', |
|
| 70 | + 'wav' => 'object.item.audioItem.musicTrack', |
|
| 71 | + 'wma' => 'object.item.audioItem.musicTrack', |
|
| 72 | + |
|
| 73 | + 'flv' => 'object.item.videoItem', |
|
| 74 | + 'f4v' => 'object.item.videoItem', |
|
| 75 | + '3g2' => 'object.item.videoItem', |
|
| 76 | + '3gp' => 'object.item.videoItem', |
|
| 77 | + '3gp2' => 'object.item.videoItem', |
|
| 78 | + '3gpp' => 'object.item.videoItem', |
|
| 79 | + 'asf' => 'object.item.videoItem', |
|
| 80 | + 'asx' => 'object.item.videoItem', |
|
| 81 | + 'avi' => 'object.item.videoItem.movie', |
|
| 82 | + 'dat' => 'object.item.videoItem', |
|
| 83 | + 'iso' => 'object.item.videoItem', |
|
| 84 | + 'm2t' => 'object.item.videoItem', |
|
| 85 | + 'm2ts' => 'object.item.videoItem', |
|
| 86 | + 'm2v' => 'object.item.videoItem', |
|
| 87 | + 'm4v' => 'object.item.videoItem', |
|
| 88 | + 'mp2v' => 'object.item.videoItem', |
|
| 89 | + 'mp4' => 'object.item.videoItem', |
|
| 90 | + 'mp4v' => 'object.item.videoItem', |
|
| 91 | + 'mpe' => 'object.item.videoItem', |
|
| 92 | + 'mpeg' => 'object.item.videoItem', |
|
| 93 | + 'mpg' => 'object.item.videoItem', |
|
| 94 | + 'mod' => 'object.item.videoItem', |
|
| 95 | + 'mov' => 'object.item.videoItem', |
|
| 96 | + 'mkv' => 'object.item.videoItem.videoBroadcast', |
|
| 97 | + 'mts' => 'object.item.videoItem', |
|
| 98 | + 'ogg' => 'object.item.videoItem', |
|
| 99 | + 'swf' => 'object.item.videoItem', |
|
| 100 | + 'vob' => 'object.item.videoItem', |
|
| 101 | + 'ts' => 'object.item.videoItem', |
|
| 102 | + 'webm' => 'object.item.videoItem', |
|
| 103 | + 'wm' => 'object.item.videoItem', |
|
| 104 | + 'wmv' => 'object.item.videoItem', |
|
| 105 | + 'wmx' => 'object.item.videoItem', |
|
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | 108 | /* MIME types. */ |
| 109 | 109 | $mime_types = array( |
| 110 | - 'txt' => 'text/plain', |
|
| 111 | - 'htm' => 'text/html', |
|
| 112 | - 'html' => 'text/html', |
|
| 113 | - 'php' => 'text/html', |
|
| 114 | - 'css' => 'text/css', |
|
| 115 | - 'js' => 'application/javascript', |
|
| 116 | - 'json' => 'application/json', |
|
| 117 | - 'xml' => 'application/xml', |
|
| 118 | - 'swf' => 'application/x-shockwave-flash', |
|
| 119 | - |
|
| 120 | - /* Images. */ |
|
| 121 | - 'png' => 'image/png', |
|
| 122 | - 'jpe' => 'image/jpeg', |
|
| 123 | - 'jpeg' => 'image/jpeg', |
|
| 124 | - 'jpg' => 'image/jpeg', |
|
| 125 | - 'gif' => 'image/gif', |
|
| 126 | - 'bmp' => 'image/bmp', |
|
| 127 | - 'ico' => 'image/vnd.microsoft.icon', |
|
| 128 | - 'tiff' => 'image/tiff', |
|
| 129 | - 'tif' => 'image/tiff', |
|
| 130 | - 'svg' => 'image/svg+xml', |
|
| 131 | - 'svgz' => 'image/svg+xml', |
|
| 132 | - |
|
| 133 | - /* Audio. */ |
|
| 134 | - 'flac' => 'audio/ogg', |
|
| 135 | - 'mp3' => 'audio/mpeg', |
|
| 136 | - 'wav' => 'audio/vnd.wave', |
|
| 137 | - 'wma' => 'audio/x-ms-wma', |
|
| 138 | - |
|
| 139 | - /* Video. */ |
|
| 140 | - '3gp' => 'video/3gpp', |
|
| 141 | - '3gpp' => 'video/3gpp', |
|
| 142 | - '3g2' => 'video/3gpp2', |
|
| 143 | - '3gpp2' => 'video/3gpp2', |
|
| 144 | - 'flv' => 'video/x-flv', |
|
| 145 | - 'qt' => 'video/quicktime', |
|
| 146 | - 'ogg' => 'video/ogg', |
|
| 147 | - 'mov' => 'video/mpeg', |
|
| 148 | - 'mp4' => 'video/mp4', |
|
| 149 | - 'mkv' => 'video/x-mkv', |
|
| 150 | - 'm2ts' => 'video/MP2T', |
|
| 151 | - 'ts' => 'video/MP2T', |
|
| 152 | - 'webm' => 'video/webm', |
|
| 110 | + 'txt' => 'text/plain', |
|
| 111 | + 'htm' => 'text/html', |
|
| 112 | + 'html' => 'text/html', |
|
| 113 | + 'php' => 'text/html', |
|
| 114 | + 'css' => 'text/css', |
|
| 115 | + 'js' => 'application/javascript', |
|
| 116 | + 'json' => 'application/json', |
|
| 117 | + 'xml' => 'application/xml', |
|
| 118 | + 'swf' => 'application/x-shockwave-flash', |
|
| 119 | + |
|
| 120 | + /* Images. */ |
|
| 121 | + 'png' => 'image/png', |
|
| 122 | + 'jpe' => 'image/jpeg', |
|
| 123 | + 'jpeg' => 'image/jpeg', |
|
| 124 | + 'jpg' => 'image/jpeg', |
|
| 125 | + 'gif' => 'image/gif', |
|
| 126 | + 'bmp' => 'image/bmp', |
|
| 127 | + 'ico' => 'image/vnd.microsoft.icon', |
|
| 128 | + 'tiff' => 'image/tiff', |
|
| 129 | + 'tif' => 'image/tiff', |
|
| 130 | + 'svg' => 'image/svg+xml', |
|
| 131 | + 'svgz' => 'image/svg+xml', |
|
| 132 | + |
|
| 133 | + /* Audio. */ |
|
| 134 | + 'flac' => 'audio/ogg', |
|
| 135 | + 'mp3' => 'audio/mpeg', |
|
| 136 | + 'wav' => 'audio/vnd.wave', |
|
| 137 | + 'wma' => 'audio/x-ms-wma', |
|
| 138 | + |
|
| 139 | + /* Video. */ |
|
| 140 | + '3gp' => 'video/3gpp', |
|
| 141 | + '3gpp' => 'video/3gpp', |
|
| 142 | + '3g2' => 'video/3gpp2', |
|
| 143 | + '3gpp2' => 'video/3gpp2', |
|
| 144 | + 'flv' => 'video/x-flv', |
|
| 145 | + 'qt' => 'video/quicktime', |
|
| 146 | + 'ogg' => 'video/ogg', |
|
| 147 | + 'mov' => 'video/mpeg', |
|
| 148 | + 'mp4' => 'video/mp4', |
|
| 149 | + 'mkv' => 'video/x-mkv', |
|
| 150 | + 'm2ts' => 'video/MP2T', |
|
| 151 | + 'ts' => 'video/MP2T', |
|
| 152 | + 'webm' => 'video/webm', |
|
| 153 | 153 | ); |
| 154 | 154 | |
| 155 | 155 | |
@@ -159,18 +159,18 @@ discard block |
||
| 159 | 159 | $http_hdr_soapact = $_SERVER['HTTP_SOAPACTION']; |
| 160 | 160 | $soap_shemas = strpos($http_hdr_soapact, 'urn:schemas-upnp-org:service:ContentDirectory:'); |
| 161 | 161 | if (false === $soap_shemas) |
| 162 | - return (500); |
|
| 162 | + return (500); |
|
| 163 | 163 | $soap_service_ver = substr($http_hdr_soapact, ($soap_shemas + 46), 1); |
| 164 | 164 | $soap_service_func = substr($http_hdr_soapact, ($soap_shemas + 48), -1); |
| 165 | 165 | |
| 166 | 166 | |
| 167 | 167 | if (substr($basedir, -1, 1) !== '/') { |
| 168 | - $basedir = $basedir.'/'; |
|
| 168 | + $basedir = $basedir.'/'; |
|
| 169 | 169 | } |
| 170 | 170 | $baseurl = implode('/', array_map('rawurlencode', explode('/', $baseurl))); |
| 171 | 171 | $baseurlpatch = 'http://'.$_SERVER['HTTP_HOST'].$baseurl; |
| 172 | 172 | if ('/' !== substr($baseurlpatch, -1, 1)) { |
| 173 | - $baseurlpatch = $baseurlpatch.'/'; |
|
| 173 | + $baseurlpatch = $baseurlpatch.'/'; |
|
| 174 | 174 | } |
| 175 | 175 | /** |
| 176 | 176 | * Apply workaround for the libxml PHP bugs: |
@@ -178,124 +178,124 @@ discard block |
||
| 178 | 178 | * @link https://bugs.php.net/bug.php?id=64938 |
| 179 | 179 | */ |
| 180 | 180 | if (function_exists('libxml_disable_entity_loader')) { |
| 181 | - libxml_disable_entity_loader(false); |
|
| 181 | + libxml_disable_entity_loader(false); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | # $server = new SoapServer(null, array('uri' => "urn:schemas-upnp-org:service:ContentDirectory:3")); |
| 185 | 185 | $server = new SoapServer(dirname(__FILE__)."/../descr/ContentDirectory.wdsl", |
| 186 | - array('cache_wsdl' => WSDL_CACHE_MEMORY, |
|
| 187 | - 'soap_version' => SOAP_1_2, |
|
| 188 | - 'trace' => true |
|
| 189 | - )); |
|
| 186 | + array('cache_wsdl' => WSDL_CACHE_MEMORY, |
|
| 187 | + 'soap_version' => SOAP_1_2, |
|
| 188 | + 'trace' => true |
|
| 189 | + )); |
|
| 190 | 190 | |
| 191 | 191 | |
| 192 | 192 | function xml_encode($string) { |
| 193 | 193 | |
| 194 | - return (str_replace( |
|
| 195 | - array("&", "<", ">", /*'"',*/ "'"), |
|
| 196 | - array("&", "<", ">", /*""",*/ "'"), |
|
| 197 | - $string)); |
|
| 194 | + return (str_replace( |
|
| 195 | + array("&", "<", ">", /*'"',*/ "'"), |
|
| 196 | + array("&", "<", ">", /*""",*/ "'"), |
|
| 197 | + $string)); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | function xml_decode($string) { |
| 201 | 201 | |
| 202 | - return (str_replace( |
|
| 203 | - array("&", "<", ">", """, "'"), |
|
| 204 | - array("&", "<", ">", '"', "'"), |
|
| 205 | - $string)); |
|
| 202 | + return (str_replace( |
|
| 203 | + array("&", "<", ">", """, "'"), |
|
| 204 | + array("&", "<", ">", '"', "'"), |
|
| 205 | + $string)); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | |
| 209 | 209 | function upnp_url_encode($url) { |
| 210 | 210 | |
| 211 | - if ('http://' !== substr($url, 0, 7) || |
|
| 212 | - false === ($url_path_off = strrpos($url, '/', 8))) |
|
| 213 | - return (implode('/', array_map('rawurlencode', explode('/', $url)))); |
|
| 214 | - //return (xml_encode(implode('/', array_map('rawurlencode', explode('/', $url))))); |
|
| 215 | - //return (xml_encode($url)); |
|
| 216 | - //return ('<![CDATA[' . xml_encode($url) . ']]'); |
|
| 217 | - |
|
| 218 | - return (substr($url, 0, $url_path_off).implode('/', array_map('rawurlencode', explode('/', substr($url, $url_path_off))))); |
|
| 219 | - //return (substr($url, 0, $url_path_off) . xml_encode(implode('/', array_map('rawurlencode', explode('/', substr($url, $url_path_off)))))); |
|
| 220 | - //return (substr($url, 0, $url_path_off) . xml_encode(substr($url, $url_path_off))); |
|
| 221 | - //return ('<![CDATA[$url]]'); |
|
| 211 | + if ('http://' !== substr($url, 0, 7) || |
|
| 212 | + false === ($url_path_off = strrpos($url, '/', 8))) |
|
| 213 | + return (implode('/', array_map('rawurlencode', explode('/', $url)))); |
|
| 214 | + //return (xml_encode(implode('/', array_map('rawurlencode', explode('/', $url))))); |
|
| 215 | + //return (xml_encode($url)); |
|
| 216 | + //return ('<![CDATA[' . xml_encode($url) . ']]'); |
|
| 217 | + |
|
| 218 | + return (substr($url, 0, $url_path_off).implode('/', array_map('rawurlencode', explode('/', substr($url, $url_path_off))))); |
|
| 219 | + //return (substr($url, 0, $url_path_off) . xml_encode(implode('/', array_map('rawurlencode', explode('/', substr($url, $url_path_off)))))); |
|
| 220 | + //return (substr($url, 0, $url_path_off) . xml_encode(substr($url, $url_path_off))); |
|
| 221 | + //return ('<![CDATA[$url]]'); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | |
| 225 | 225 | function upnp_get_class($file, $def) { |
| 226 | - global $file_class; |
|
| 227 | - |
|
| 228 | - if (!isset($file)) |
|
| 229 | - return ($def); |
|
| 230 | - $dot = strrpos($file, '.'); |
|
| 231 | - if (false === $dot) |
|
| 232 | - return ($def); |
|
| 233 | - $ext = strtolower(substr($file, ($dot + 1))); |
|
| 234 | - if (isset($file_class[$ext])) /* Skip unsupported file type. */ |
|
| 235 | - return ($file_class[$ext]); |
|
| 236 | - |
|
| 237 | - return ($def); |
|
| 226 | + global $file_class; |
|
| 227 | + |
|
| 228 | + if (!isset($file)) |
|
| 229 | + return ($def); |
|
| 230 | + $dot = strrpos($file, '.'); |
|
| 231 | + if (false === $dot) |
|
| 232 | + return ($def); |
|
| 233 | + $ext = strtolower(substr($file, ($dot + 1))); |
|
| 234 | + if (isset($file_class[$ext])) /* Skip unsupported file type. */ |
|
| 235 | + return ($file_class[$ext]); |
|
| 236 | + |
|
| 237 | + return ($def); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | |
| 241 | 241 | function get_named_val($name, $buf) { /* ...val_name="value"... */ |
| 242 | 242 | |
| 243 | - $st_off = strpos($buf, $name); |
|
| 244 | - if (false === $st_off) |
|
| 245 | - return (null); |
|
| 246 | - $st_off += strlen($name); |
|
| 247 | - if ('="' !== substr($buf, $st_off, 2)) |
|
| 248 | - return (null); |
|
| 249 | - $st_off += 2; |
|
| 250 | - $en_off = strpos($buf, '"', $st_off); |
|
| 251 | - if (false === $en_off) |
|
| 252 | - return (null); |
|
| 253 | - |
|
| 254 | - return (substr($buf, $st_off, ($en_off - $st_off))); |
|
| 243 | + $st_off = strpos($buf, $name); |
|
| 244 | + if (false === $st_off) |
|
| 245 | + return (null); |
|
| 246 | + $st_off += strlen($name); |
|
| 247 | + if ('="' !== substr($buf, $st_off, 2)) |
|
| 248 | + return (null); |
|
| 249 | + $st_off += 2; |
|
| 250 | + $en_off = strpos($buf, '"', $st_off); |
|
| 251 | + if (false === $en_off) |
|
| 252 | + return (null); |
|
| 253 | + |
|
| 254 | + return (substr($buf, $st_off, ($en_off - $st_off))); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | |
| 258 | 258 | function m3u_calc_items_count($filename) { |
| 259 | 259 | |
| 260 | - $items_count = 0; |
|
| 261 | - $fd = fopen($filename, 'r'); |
|
| 262 | - if (false === $fd) |
|
| 263 | - return ($items_count); |
|
| 264 | - while (!feof($fd)) { /* Read the file line by line... */ |
|
| 265 | - $buffer = trim(fgets($fd)); |
|
| 266 | - if (false === strpos($buffer, '#EXTINF:')) /* Skip empty/bad lines. */ |
|
| 267 | - continue; |
|
| 268 | - $entry = trim(fgets($fd)); |
|
| 269 | - if (false === strpos($entry, '://')) |
|
| 270 | - continue; |
|
| 271 | - $items_count++; |
|
| 272 | - } |
|
| 273 | - fclose($fd); |
|
| 274 | - |
|
| 275 | - return ($items_count); |
|
| 260 | + $items_count = 0; |
|
| 261 | + $fd = fopen($filename, 'r'); |
|
| 262 | + if (false === $fd) |
|
| 263 | + return ($items_count); |
|
| 264 | + while (!feof($fd)) { /* Read the file line by line... */ |
|
| 265 | + $buffer = trim(fgets($fd)); |
|
| 266 | + if (false === strpos($buffer, '#EXTINF:')) /* Skip empty/bad lines. */ |
|
| 267 | + continue; |
|
| 268 | + $entry = trim(fgets($fd)); |
|
| 269 | + if (false === strpos($entry, '://')) |
|
| 270 | + continue; |
|
| 271 | + $items_count++; |
|
| 272 | + } |
|
| 273 | + fclose($fd); |
|
| 274 | + |
|
| 275 | + return ($items_count); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | |
| 279 | 279 | function upnp_mime_content_type($filename) { |
| 280 | 280 | |
| 281 | - $def = 'video/mpeg'; |
|
| 282 | - |
|
| 283 | - if (!isset($filename)) |
|
| 284 | - return ($def); |
|
| 285 | - $dot = strrpos($filename, '.'); |
|
| 286 | - if (false === $dot) |
|
| 287 | - return ($def); |
|
| 288 | - $ext = strtolower(substr($filename, ($dot + 1))); |
|
| 289 | - if (array_key_exists($ext, $mime_types)) { |
|
| 290 | - return ($mime_types[$ext]); |
|
| 291 | - } elseif (function_exists('finfo_open')) { |
|
| 292 | - $finfo = finfo_open(FILEINFO_MIME); |
|
| 293 | - $mimetype = finfo_file($finfo, $filename); |
|
| 294 | - finfo_close($finfo); |
|
| 295 | - return ($mimetype); |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - return ($def); |
|
| 281 | + $def = 'video/mpeg'; |
|
| 282 | + |
|
| 283 | + if (!isset($filename)) |
|
| 284 | + return ($def); |
|
| 285 | + $dot = strrpos($filename, '.'); |
|
| 286 | + if (false === $dot) |
|
| 287 | + return ($def); |
|
| 288 | + $ext = strtolower(substr($filename, ($dot + 1))); |
|
| 289 | + if (array_key_exists($ext, $mime_types)) { |
|
| 290 | + return ($mime_types[$ext]); |
|
| 291 | + } elseif (function_exists('finfo_open')) { |
|
| 292 | + $finfo = finfo_open(FILEINFO_MIME); |
|
| 293 | + $mimetype = finfo_file($finfo, $filename); |
|
| 294 | + finfo_close($finfo); |
|
| 295 | + return ($mimetype); |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + return ($def); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /* Format: |
@@ -303,241 +303,241 @@ discard block |
||
| 303 | 303 | * 1: 2004-05-08T10:00:00 |
| 304 | 304 | * */ |
| 305 | 305 | function upnp_date($timedate, $format) { |
| 306 | - $res = date('Y-m-d', $timedate); |
|
| 306 | + $res = date('Y-m-d', $timedate); |
|
| 307 | 307 | |
| 308 | - if (1 === $format) { |
|
| 309 | - $res = $res.'T'.date('H:i:s', $timedate); |
|
| 310 | - } |
|
| 308 | + if (1 === $format) { |
|
| 309 | + $res = $res.'T'.date('H:i:s', $timedate); |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - return ($res); |
|
| 312 | + return ($res); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | |
| 316 | 316 | /* ContentDirectory funcs */ |
| 317 | 317 | |
| 318 | 318 | function GetSearchCapabilities() { |
| 319 | - // 'upnp:class'; /* dc:title,upnp:class,upnp:artist */ |
|
| 320 | - //$SearchCaps = 'dc:creator,dc:date,dc:title,upnp:album,upnp:actor,upnp:artist,upnp:class,upnp:genre,@id,@parentID,@refID'; |
|
| 321 | - $SearchCaps = 'dc:title'; |
|
| 319 | + // 'upnp:class'; /* dc:title,upnp:class,upnp:artist */ |
|
| 320 | + //$SearchCaps = 'dc:creator,dc:date,dc:title,upnp:album,upnp:actor,upnp:artist,upnp:class,upnp:genre,@id,@parentID,@refID'; |
|
| 321 | + $SearchCaps = 'dc:title'; |
|
| 322 | 322 | |
| 323 | - return ($SearchCaps); |
|
| 323 | + return ($SearchCaps); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
| 327 | 327 | function GetSortCapabilities() { |
| 328 | - $SortCaps = 'dc:title'; |
|
| 329 | - /* dc:title,upnp:genre,upnp:album,dc:creator,res@size, |
|
| 328 | + $SortCaps = 'dc:title'; |
|
| 329 | + /* dc:title,upnp:genre,upnp:album,dc:creator,res@size, |
|
| 330 | 330 | * res@duration,res@bitrate,dc:publisher, |
| 331 | 331 | * upnp:originalTrackNumber,dc:date,upnp:producer,upnp:rating, |
| 332 | 332 | * upnp:actor,upnp:director,dc:description |
| 333 | 333 | */ |
| 334 | 334 | |
| 335 | - return ($SortCaps); |
|
| 335 | + return ($SortCaps); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | |
| 339 | 339 | function GetSortExtensionCapabilities() { |
| 340 | - $SortExtensionCaps = ''; |
|
| 340 | + $SortExtensionCaps = ''; |
|
| 341 | 341 | |
| 342 | - return ($SortExtensionCaps); |
|
| 342 | + return ($SortExtensionCaps); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | |
| 346 | 346 | function GetFeatureList() { |
| 347 | - $FeatureList = ''; |
|
| 347 | + $FeatureList = ''; |
|
| 348 | 348 | |
| 349 | - return ($FeatureList); |
|
| 349 | + return ($FeatureList); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | |
| 353 | 353 | function GetSystemUpdateID() { |
| 354 | - $Id = '1'; |
|
| 354 | + $Id = '1'; |
|
| 355 | 355 | |
| 356 | - return ($Id); |
|
| 356 | + return ($Id); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | |
| 360 | 360 | function GetServiceResetToken() { |
| 361 | - $ResetToken = '1'; |
|
| 361 | + $ResetToken = '1'; |
|
| 362 | 362 | |
| 363 | - return ($ResetToken); |
|
| 363 | + return ($ResetToken); |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | |
| 367 | 367 | function Browse($ObjectID, $BrowseFlag, $Filter, $StartingIndex, |
| 368 | 368 | $RequestedCount, $SortCriteria) { |
| 369 | - global $basedir, $baseurl, $baseurlpatch; |
|
| 370 | - $Result = '<DIDL-Lite'. |
|
| 371 | - ' xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"'. |
|
| 372 | - ' xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"'. |
|
| 373 | - ' xmlns:dc="http://purl.org/dc/elements/1.1/"'. |
|
| 374 | - ' xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"'. |
|
| 375 | - ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
|
| 376 | - ' xsi:schemaLocation="'. |
|
| 377 | - 'urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/ http://www.upnp.org/schemas/av/didl-lite.xsd '. |
|
| 378 | - 'urn:schemas-upnp-org:metadata-1-0/upnp/ http://www.upnp.org/schemas/av/upnp.xsd">'; |
|
| 379 | - $ParentID = '-1'; |
|
| 380 | - $NumberReturned = 0; |
|
| 381 | - $TotalMatches = 0; |
|
| 382 | - $UpdateID = 1; |
|
| 383 | - |
|
| 384 | - /* Check input param. */ |
|
| 385 | - if (isset($ObjectID)) { |
|
| 386 | - if ((1 === strlen($ObjectID) || |
|
| 387 | - (3 === strlen($ObjectID) && '_T' === substr($ObjectID, 1, 2)) || |
|
| 388 | - (3 === strlen($ObjectID) && '_D' === substr($ObjectID, 1, 2)) || |
|
| 389 | - (3 === strlen($ObjectID) && '_L' === substr($ObjectID, 1, 2))) && ( |
|
| 390 | - '0' === substr($ObjectID, 0, 1) || |
|
| 391 | - 'A' === substr($ObjectID, 0, 1) || |
|
| 392 | - 'I' === substr($ObjectID, 0, 1) || |
|
| 393 | - 'V' === substr($ObjectID, 0, 1) || |
|
| 394 | - 'P' === substr($ObjectID, 0, 1) || |
|
| 395 | - 'T' === substr($ObjectID, 0, 1))) { /* V, I, A, P, T - from X_GetFeatureList() */ |
|
| 396 | - $ObjectID = '0'; |
|
| 397 | - $dir = ''; |
|
| 398 | - } else { |
|
| 399 | - $dir = rawurldecode(xml_decode($ObjectID)); |
|
| 400 | - if ('/' !== substr($dir, -1, 1)) { |
|
| 401 | - $dir = $dir.'/'; |
|
| 402 | - } |
|
| 403 | - /* Sec check: .. in path */ |
|
| 404 | - $dotdotdir = ''; |
|
| 405 | - $dirnames = explode('/', $dir); |
|
| 406 | - for ($di = 0; $di < sizeof($dirnames); $di++) { |
|
| 407 | - if ('.' === $dirnames[$di]) |
|
| 408 | - continue; |
|
| 409 | - if ('..' === $dirnames[$di]) { |
|
| 410 | - $dir = ''; |
|
| 411 | - break; |
|
| 412 | - } |
|
| 413 | - if ((sizeof($dirnames) - 1) > $di) { |
|
| 414 | - $dotdotdir = $dotdotdir.$dirnames[$di].'/'; |
|
| 415 | - } |
|
| 416 | - } |
|
| 417 | - $dir = $dotdotdir; |
|
| 418 | - if ('/' === substr($dir, 0, 1) /*|| !is_dir($basedir.$dir)*/) { |
|
| 419 | - $dir = ''; |
|
| 420 | - } |
|
| 421 | - /* Remove tail slash from file name. */ |
|
| 422 | - if (!is_dir($basedir.$dir) && |
|
| 423 | - '/' === substr($dir, -1, 1)) { |
|
| 424 | - $dir = substr($dir, 0, -1); |
|
| 425 | - } |
|
| 426 | - } |
|
| 427 | - } else { |
|
| 428 | - $ObjectID = '0'; |
|
| 429 | - $dir = ''; |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - if ('BrowseMetadata' === $BrowseFlag) { |
|
| 433 | - $filename = $basedir.$dir; |
|
| 434 | - /* Is file/dir exist? */ |
|
| 435 | - $stat = stat($filename); |
|
| 436 | - if (false === $stat) { /* No such file/dir. */ |
|
| 437 | - return (array('Result' => '', |
|
| 438 | - 'NumberReturned' => 0, |
|
| 439 | - 'TotalMatches' => 0, |
|
| 440 | - 'UpdateID' => $UpdateID)); |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - /* Collect data. */ |
|
| 444 | - if (is_writable($filename)) { |
|
| 445 | - $WriteStatus = 'WRITABLE'; |
|
| 446 | - $Restricted = '0'; |
|
| 447 | - } else { |
|
| 448 | - $WriteStatus = 'NOT_WRITABLE'; |
|
| 449 | - $Restricted = '1'; |
|
| 450 | - } |
|
| 451 | - $basefilename = basename($dir); |
|
| 452 | - if ('0' === $ObjectID) { |
|
| 453 | - $title = 'root'; |
|
| 454 | - $ParentID = '-1'; |
|
| 455 | - } else { |
|
| 456 | - $title = xml_encode($basefilename); |
|
| 457 | - $ParentID = upnp_url_encode(dirname($dir)); |
|
| 458 | - } |
|
| 459 | - |
|
| 460 | - if (is_dir($filename)) { /* Dir. */ |
|
| 461 | - $StorageTotal = disk_total_space($filename); |
|
| 462 | - $StorageFree = disk_free_space($filename); |
|
| 463 | - $StorageUsed = ($StorageTotal - $StorageFree); |
|
| 464 | - $ChildCount = (count(scandir($filename)) - 2); |
|
| 465 | - $Result = $Result. |
|
| 466 | - "<container id=\"$ObjectID\" parentID=\"$ParentID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
| 467 | - "<dc:title>$title</dc:title>". |
|
| 468 | - '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
| 469 | - "<upnp:storageTotal>$StorageTotal</upnp:storageTotal>". |
|
| 470 | - "<upnp:storageFree>$StorageFree</upnp:storageFree>". |
|
| 471 | - "<upnp:storageUsed>$StorageUsed</upnp:storageUsed>". |
|
| 472 | - "<upnp:writeStatus>$WriteStatus</upnp:writeStatus>"; |
|
| 473 | - if ('0' === $ObjectID) { |
|
| 474 | - $Result = $Result. |
|
| 475 | - '<upnp:searchClass includeDerived="1">object.item.audioItem</upnp:searchClass>'. |
|
| 476 | - '<upnp:searchClass includeDerived="1">object.item.imageItem</upnp:searchClass>'. |
|
| 477 | - '<upnp:searchClass includeDerived="1">object.item.videoItem</upnp:searchClass>'; |
|
| 478 | - } |
|
| 479 | - $Result = $Result.'</container>'; |
|
| 480 | - } else { /* File or playlist. */ |
|
| 481 | - $iclass = upnp_get_class($basefilename, 'object.item.videoItem'); |
|
| 482 | - if ('object.container.storageFolder' === $iclass) { /* Play list as folder! */ |
|
| 483 | - $ChildCount = m3u_calc_items_count($filename); |
|
| 484 | - $Result = $Result. |
|
| 485 | - "<container id=\"$ObjectID\" parentID=\"$ParentID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
| 486 | - "<dc:title>$title</dc:title>". |
|
| 487 | - '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
| 488 | - '</container>'; |
|
| 489 | - } else { |
|
| 490 | - $date = upnp_date(filectime($filename), 1); |
|
| 491 | - $size = filesize($filename); |
|
| 492 | - $mimetype = upnp_mime_content_type($filename); |
|
| 493 | - $Result = $Result. |
|
| 494 | - "<item id=\"$ObjectID\" parentID=\"$ParentID\" restricted=\"$Restricted\">". |
|
| 495 | - "<dc:title>$title</dc:title>". |
|
| 496 | - "<dc:date>$date</dc:date>". |
|
| 497 | - "<upnp:class>$iclass</upnp:class>". |
|
| 498 | - "<res size=\"$size\" protocolInfo=\"http-get:*:$mimetype:*\">$ObjectID</res>". |
|
| 499 | - '</item>'; |
|
| 500 | - } |
|
| 501 | - } |
|
| 502 | - $Result = $Result.'</DIDL-Lite>'; |
|
| 503 | - return (array('Result' => $Result, |
|
| 504 | - 'NumberReturned' => 1, |
|
| 505 | - 'TotalMatches' => 1, |
|
| 506 | - 'UpdateID' => $UpdateID)); |
|
| 507 | - } |
|
| 508 | - |
|
| 509 | - if (!isset($StartingIndex)) { |
|
| 510 | - $StartingIndex = 0; |
|
| 511 | - } |
|
| 512 | - if (!isset($RequestedCount)) { |
|
| 513 | - $RequestedCount = 0; |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - if (!is_dir($basedir.$dir)) { /* Play list file? */ |
|
| 517 | - /* Open the file. */ |
|
| 518 | - $filename = $basedir.$dir; |
|
| 519 | - $fd = fopen($filename, 'r'); |
|
| 520 | - if (false === $fd) { |
|
| 521 | - return (array('Result' => '', |
|
| 522 | - 'NumberReturned' => 0, |
|
| 523 | - 'TotalMatches' => 0, |
|
| 524 | - 'UpdateID' => $UpdateID)); |
|
| 525 | - } |
|
| 526 | - $date = upnp_date(filectime($filename), 1); |
|
| 527 | - if (is_writable($filename)) { |
|
| 528 | - $Restricted = '0'; |
|
| 529 | - } else { |
|
| 530 | - $Restricted = '1'; |
|
| 531 | - } |
|
| 532 | - |
|
| 533 | - //$logo_url_path = 'http://iptvremote.ru/channels/android/160/'; |
|
| 534 | - //$logo_url_path = 'http://172.16.0.254/download/tmp/image/'; |
|
| 535 | - while (!feof($fd)) { /* Read the file line by line... */ |
|
| 536 | - $buffer = trim(fgets($fd)); |
|
| 537 | - //if($buffer === false) |
|
| 538 | - // break; |
|
| 539 | - if (false === strpos($buffer, '#EXTINF:')) { /* Skip empty/bad lines. */ |
|
| 540 | - /*if (false !== strpos($buffer, '#EXTM3U')) { |
|
| 369 | + global $basedir, $baseurl, $baseurlpatch; |
|
| 370 | + $Result = '<DIDL-Lite'. |
|
| 371 | + ' xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"'. |
|
| 372 | + ' xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"'. |
|
| 373 | + ' xmlns:dc="http://purl.org/dc/elements/1.1/"'. |
|
| 374 | + ' xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"'. |
|
| 375 | + ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
|
| 376 | + ' xsi:schemaLocation="'. |
|
| 377 | + 'urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/ http://www.upnp.org/schemas/av/didl-lite.xsd '. |
|
| 378 | + 'urn:schemas-upnp-org:metadata-1-0/upnp/ http://www.upnp.org/schemas/av/upnp.xsd">'; |
|
| 379 | + $ParentID = '-1'; |
|
| 380 | + $NumberReturned = 0; |
|
| 381 | + $TotalMatches = 0; |
|
| 382 | + $UpdateID = 1; |
|
| 383 | + |
|
| 384 | + /* Check input param. */ |
|
| 385 | + if (isset($ObjectID)) { |
|
| 386 | + if ((1 === strlen($ObjectID) || |
|
| 387 | + (3 === strlen($ObjectID) && '_T' === substr($ObjectID, 1, 2)) || |
|
| 388 | + (3 === strlen($ObjectID) && '_D' === substr($ObjectID, 1, 2)) || |
|
| 389 | + (3 === strlen($ObjectID) && '_L' === substr($ObjectID, 1, 2))) && ( |
|
| 390 | + '0' === substr($ObjectID, 0, 1) || |
|
| 391 | + 'A' === substr($ObjectID, 0, 1) || |
|
| 392 | + 'I' === substr($ObjectID, 0, 1) || |
|
| 393 | + 'V' === substr($ObjectID, 0, 1) || |
|
| 394 | + 'P' === substr($ObjectID, 0, 1) || |
|
| 395 | + 'T' === substr($ObjectID, 0, 1))) { /* V, I, A, P, T - from X_GetFeatureList() */ |
|
| 396 | + $ObjectID = '0'; |
|
| 397 | + $dir = ''; |
|
| 398 | + } else { |
|
| 399 | + $dir = rawurldecode(xml_decode($ObjectID)); |
|
| 400 | + if ('/' !== substr($dir, -1, 1)) { |
|
| 401 | + $dir = $dir.'/'; |
|
| 402 | + } |
|
| 403 | + /* Sec check: .. in path */ |
|
| 404 | + $dotdotdir = ''; |
|
| 405 | + $dirnames = explode('/', $dir); |
|
| 406 | + for ($di = 0; $di < sizeof($dirnames); $di++) { |
|
| 407 | + if ('.' === $dirnames[$di]) |
|
| 408 | + continue; |
|
| 409 | + if ('..' === $dirnames[$di]) { |
|
| 410 | + $dir = ''; |
|
| 411 | + break; |
|
| 412 | + } |
|
| 413 | + if ((sizeof($dirnames) - 1) > $di) { |
|
| 414 | + $dotdotdir = $dotdotdir.$dirnames[$di].'/'; |
|
| 415 | + } |
|
| 416 | + } |
|
| 417 | + $dir = $dotdotdir; |
|
| 418 | + if ('/' === substr($dir, 0, 1) /*|| !is_dir($basedir.$dir)*/) { |
|
| 419 | + $dir = ''; |
|
| 420 | + } |
|
| 421 | + /* Remove tail slash from file name. */ |
|
| 422 | + if (!is_dir($basedir.$dir) && |
|
| 423 | + '/' === substr($dir, -1, 1)) { |
|
| 424 | + $dir = substr($dir, 0, -1); |
|
| 425 | + } |
|
| 426 | + } |
|
| 427 | + } else { |
|
| 428 | + $ObjectID = '0'; |
|
| 429 | + $dir = ''; |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + if ('BrowseMetadata' === $BrowseFlag) { |
|
| 433 | + $filename = $basedir.$dir; |
|
| 434 | + /* Is file/dir exist? */ |
|
| 435 | + $stat = stat($filename); |
|
| 436 | + if (false === $stat) { /* No such file/dir. */ |
|
| 437 | + return (array('Result' => '', |
|
| 438 | + 'NumberReturned' => 0, |
|
| 439 | + 'TotalMatches' => 0, |
|
| 440 | + 'UpdateID' => $UpdateID)); |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + /* Collect data. */ |
|
| 444 | + if (is_writable($filename)) { |
|
| 445 | + $WriteStatus = 'WRITABLE'; |
|
| 446 | + $Restricted = '0'; |
|
| 447 | + } else { |
|
| 448 | + $WriteStatus = 'NOT_WRITABLE'; |
|
| 449 | + $Restricted = '1'; |
|
| 450 | + } |
|
| 451 | + $basefilename = basename($dir); |
|
| 452 | + if ('0' === $ObjectID) { |
|
| 453 | + $title = 'root'; |
|
| 454 | + $ParentID = '-1'; |
|
| 455 | + } else { |
|
| 456 | + $title = xml_encode($basefilename); |
|
| 457 | + $ParentID = upnp_url_encode(dirname($dir)); |
|
| 458 | + } |
|
| 459 | + |
|
| 460 | + if (is_dir($filename)) { /* Dir. */ |
|
| 461 | + $StorageTotal = disk_total_space($filename); |
|
| 462 | + $StorageFree = disk_free_space($filename); |
|
| 463 | + $StorageUsed = ($StorageTotal - $StorageFree); |
|
| 464 | + $ChildCount = (count(scandir($filename)) - 2); |
|
| 465 | + $Result = $Result. |
|
| 466 | + "<container id=\"$ObjectID\" parentID=\"$ParentID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
| 467 | + "<dc:title>$title</dc:title>". |
|
| 468 | + '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
| 469 | + "<upnp:storageTotal>$StorageTotal</upnp:storageTotal>". |
|
| 470 | + "<upnp:storageFree>$StorageFree</upnp:storageFree>". |
|
| 471 | + "<upnp:storageUsed>$StorageUsed</upnp:storageUsed>". |
|
| 472 | + "<upnp:writeStatus>$WriteStatus</upnp:writeStatus>"; |
|
| 473 | + if ('0' === $ObjectID) { |
|
| 474 | + $Result = $Result. |
|
| 475 | + '<upnp:searchClass includeDerived="1">object.item.audioItem</upnp:searchClass>'. |
|
| 476 | + '<upnp:searchClass includeDerived="1">object.item.imageItem</upnp:searchClass>'. |
|
| 477 | + '<upnp:searchClass includeDerived="1">object.item.videoItem</upnp:searchClass>'; |
|
| 478 | + } |
|
| 479 | + $Result = $Result.'</container>'; |
|
| 480 | + } else { /* File or playlist. */ |
|
| 481 | + $iclass = upnp_get_class($basefilename, 'object.item.videoItem'); |
|
| 482 | + if ('object.container.storageFolder' === $iclass) { /* Play list as folder! */ |
|
| 483 | + $ChildCount = m3u_calc_items_count($filename); |
|
| 484 | + $Result = $Result. |
|
| 485 | + "<container id=\"$ObjectID\" parentID=\"$ParentID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
| 486 | + "<dc:title>$title</dc:title>". |
|
| 487 | + '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
| 488 | + '</container>'; |
|
| 489 | + } else { |
|
| 490 | + $date = upnp_date(filectime($filename), 1); |
|
| 491 | + $size = filesize($filename); |
|
| 492 | + $mimetype = upnp_mime_content_type($filename); |
|
| 493 | + $Result = $Result. |
|
| 494 | + "<item id=\"$ObjectID\" parentID=\"$ParentID\" restricted=\"$Restricted\">". |
|
| 495 | + "<dc:title>$title</dc:title>". |
|
| 496 | + "<dc:date>$date</dc:date>". |
|
| 497 | + "<upnp:class>$iclass</upnp:class>". |
|
| 498 | + "<res size=\"$size\" protocolInfo=\"http-get:*:$mimetype:*\">$ObjectID</res>". |
|
| 499 | + '</item>'; |
|
| 500 | + } |
|
| 501 | + } |
|
| 502 | + $Result = $Result.'</DIDL-Lite>'; |
|
| 503 | + return (array('Result' => $Result, |
|
| 504 | + 'NumberReturned' => 1, |
|
| 505 | + 'TotalMatches' => 1, |
|
| 506 | + 'UpdateID' => $UpdateID)); |
|
| 507 | + } |
|
| 508 | + |
|
| 509 | + if (!isset($StartingIndex)) { |
|
| 510 | + $StartingIndex = 0; |
|
| 511 | + } |
|
| 512 | + if (!isset($RequestedCount)) { |
|
| 513 | + $RequestedCount = 0; |
|
| 514 | + } |
|
| 515 | + |
|
| 516 | + if (!is_dir($basedir.$dir)) { /* Play list file? */ |
|
| 517 | + /* Open the file. */ |
|
| 518 | + $filename = $basedir.$dir; |
|
| 519 | + $fd = fopen($filename, 'r'); |
|
| 520 | + if (false === $fd) { |
|
| 521 | + return (array('Result' => '', |
|
| 522 | + 'NumberReturned' => 0, |
|
| 523 | + 'TotalMatches' => 0, |
|
| 524 | + 'UpdateID' => $UpdateID)); |
|
| 525 | + } |
|
| 526 | + $date = upnp_date(filectime($filename), 1); |
|
| 527 | + if (is_writable($filename)) { |
|
| 528 | + $Restricted = '0'; |
|
| 529 | + } else { |
|
| 530 | + $Restricted = '1'; |
|
| 531 | + } |
|
| 532 | + |
|
| 533 | + //$logo_url_path = 'http://iptvremote.ru/channels/android/160/'; |
|
| 534 | + //$logo_url_path = 'http://172.16.0.254/download/tmp/image/'; |
|
| 535 | + while (!feof($fd)) { /* Read the file line by line... */ |
|
| 536 | + $buffer = trim(fgets($fd)); |
|
| 537 | + //if($buffer === false) |
|
| 538 | + // break; |
|
| 539 | + if (false === strpos($buffer, '#EXTINF:')) { /* Skip empty/bad lines. */ |
|
| 540 | + /*if (false !== strpos($buffer, '#EXTM3U')) { |
|
| 541 | 541 | $logo_url_path = get_named_val('url-tvg-logo', $buffer); |
| 542 | 542 | if (null !== $logo_url_path) { |
| 543 | 543 | if ('/' !== substr($logo_url_path, -1, 1)) |
@@ -547,186 +547,186 @@ discard block |
||
| 547 | 547 | $logo_url_path = 'http://172.16.0.254/download/tmp/image/'; |
| 548 | 548 | } |
| 549 | 549 | }*/ |
| 550 | - continue; |
|
| 551 | - } |
|
| 552 | - $entry = trim(fgets($fd)); |
|
| 553 | - if (false === strpos($entry, '://')) |
|
| 554 | - continue; |
|
| 555 | - /* Ok, item matched and may be returned. */ |
|
| 556 | - $TotalMatches++; |
|
| 557 | - if (0 < $StartingIndex && |
|
| 558 | - $TotalMatches < $StartingIndex) |
|
| 559 | - continue; /* Skip first items. */ |
|
| 560 | - if (0 < $RequestedCount && |
|
| 561 | - $NumberReturned >= $RequestedCount) |
|
| 562 | - continue; /* Do not add more than requested. */ |
|
| 563 | - $NumberReturned++; |
|
| 564 | - /* Add item to result. */ |
|
| 565 | - $title = xml_encode(trim(substr($buffer, (strpos($buffer, ',') + 1)))); |
|
| 566 | - //$en_entry = upnp_url_encode($entry); |
|
| 567 | - $en_entry = xml_encode($entry); |
|
| 568 | - $iclass = upnp_get_class($entry, 'object.item.videoItem.videoBroadcast'); |
|
| 569 | - $mimetype = 'video/mpeg'; |
|
| 570 | - if ('object.container.storageFolder' === $iclass) { /* Play list as folder! */ |
|
| 571 | - $Result = $Result. |
|
| 572 | - "<container id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\">". |
|
| 573 | - "<dc:title>$title</dc:title>". |
|
| 574 | - '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
| 575 | - '</container>'; |
|
| 576 | - } else { |
|
| 577 | - //$logo = get_named_val("tvg-logo", $buffer); |
|
| 578 | - //if (null === $logo) { |
|
| 579 | - // $logo = trim(substr($buffer, (strpos($buffer, ',') + 1))); |
|
| 580 | - //} |
|
| 581 | - //$icon_url = upnp_url_encode($logo_url_path . mb_convert_case($logo, MB_CASE_LOWER, "UTF-8") . '.png'); |
|
| 582 | - $Result = $Result. |
|
| 583 | - "<item id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\">". |
|
| 584 | - "<dc:title>$title</dc:title>". |
|
| 585 | - "<dc:date>$date</dc:date>". |
|
| 586 | - //"<upnp:albumArtURI dlna:profileID=\"JPEG_TN\" xmlns:dlna=\"urn:schemas-dlna-org:metadata-1-0\">$icon_url</upnp:albumArtURI>" . |
|
| 587 | - //"<upnp:icon>$icon_url</upnp:icon>" . |
|
| 588 | - "<upnp:class>$iclass</upnp:class>". |
|
| 589 | - "<res protocolInfo=\"http-get:*:$mimetype:*\">$en_entry</res>". |
|
| 590 | - '</item>'; |
|
| 591 | - } |
|
| 592 | - } |
|
| 593 | - fclose($fd); |
|
| 594 | - |
|
| 595 | - $Result = $Result.'</DIDL-Lite>'; |
|
| 596 | - return (array('Result' => $Result, |
|
| 597 | - 'NumberReturned' => $NumberReturned, |
|
| 598 | - 'TotalMatches' => $TotalMatches, |
|
| 599 | - 'UpdateID' => $UpdateID)); |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - /* Scan directory and add to play list.*/ |
|
| 603 | - $entries = scandir($basedir.$dir); |
|
| 604 | - /* Add dirs to play list. */ |
|
| 605 | - foreach ($entries as $entry) { |
|
| 606 | - $filename = $basedir.$dir.$entry; |
|
| 607 | - if ('.' === substr($entry, 0, 1) || |
|
| 608 | - !is_dir($filename)) /* Skip files. */ |
|
| 609 | - continue; |
|
| 610 | - /* Ok, item matched and may be returned. */ |
|
| 611 | - $TotalMatches++; |
|
| 612 | - if (0 < $StartingIndex && |
|
| 613 | - $TotalMatches < $StartingIndex) |
|
| 614 | - continue; /* Skip first items. */ |
|
| 615 | - if (0 < $RequestedCount && |
|
| 616 | - $NumberReturned >= $RequestedCount) |
|
| 617 | - continue; /* Do not add more than requested. */ |
|
| 618 | - $NumberReturned++; |
|
| 619 | - /* Add item to result. */ |
|
| 620 | - if (is_writable($filename)) { |
|
| 621 | - $Restricted = '0'; |
|
| 622 | - } else { |
|
| 623 | - $Restricted = '1'; |
|
| 624 | - } |
|
| 625 | - $title = xml_encode($entry); |
|
| 626 | - $en_entry = upnp_url_encode($dir.$entry); |
|
| 627 | - $ChildCount = (count(scandir($filename)) - 2); |
|
| 628 | - $Result = $Result. |
|
| 629 | - "<container id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
| 630 | - "<dc:title>$title</dc:title>". |
|
| 631 | - '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
| 632 | - '</container>'; |
|
| 633 | - } |
|
| 634 | - /* Add files to play list. */ |
|
| 635 | - foreach ($entries as $entry) { |
|
| 636 | - $filename = $basedir.$dir.$entry; |
|
| 637 | - if (is_dir($filename)) /* Skip dirs. */ |
|
| 638 | - continue; |
|
| 639 | - $iclass = upnp_get_class($entry, null); |
|
| 640 | - if (null === $iclass) /* Skip unsupported file type. */ |
|
| 641 | - continue; |
|
| 642 | - /* Ok, item matched and may be returned. */ |
|
| 643 | - $TotalMatches++; |
|
| 644 | - if (0 < $StartingIndex && |
|
| 645 | - $TotalMatches < $StartingIndex) |
|
| 646 | - continue; /* Skip first items. */ |
|
| 647 | - if (0 < $RequestedCount && |
|
| 648 | - $NumberReturned >= $RequestedCount) |
|
| 649 | - continue; /* Do not add more than requested. */ |
|
| 650 | - $NumberReturned++; |
|
| 651 | - /* Add item to result. */ |
|
| 652 | - if (is_writable($filename)) { |
|
| 653 | - $Restricted = '0'; |
|
| 654 | - } else { |
|
| 655 | - $Restricted = '1'; |
|
| 656 | - } |
|
| 657 | - $title = xml_encode($entry); |
|
| 658 | - $en_entry = upnp_url_encode($dir.$entry); |
|
| 659 | - if ('object.container.storageFolder' === $iclass) { /* Play list as folder! */ |
|
| 660 | - $ChildCount = m3u_calc_items_count($filename); |
|
| 661 | - $Result = $Result. |
|
| 662 | - "<container id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
| 663 | - "<dc:title>$title</dc:title>". |
|
| 664 | - '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
| 665 | - '</container>'; |
|
| 666 | - } else { |
|
| 667 | - $date = upnp_date(filectime($filename), 1); |
|
| 668 | - $size = filesize($filename); |
|
| 669 | - $mimetype = upnp_mime_content_type($filename); |
|
| 670 | - $res_info_ex = ''; |
|
| 671 | - $Result = $Result. |
|
| 672 | - "<item id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\">". |
|
| 673 | - "<dc:title>$title</dc:title>". |
|
| 674 | - "<dc:date>$date</dc:date>". |
|
| 675 | - "<upnp:class>$iclass</upnp:class>"; |
|
| 676 | - if ('object.item.imageItem' === substr($iclass, 0, 21)) { |
|
| 677 | - $Result = $Result. |
|
| 678 | - "<upnp:albumArtURI>$baseurlpatch$en_entry</upnp:albumArtURI>". |
|
| 679 | - "<upnp:icon>$baseurlpatch$en_entry</upnp:icon>"; |
|
| 680 | - $img_info = getimagesize($filename); |
|
| 681 | - if (false !== $img_info) { |
|
| 682 | - $res_info_ex = ' resolution="'.$img_info[0].'x'.$img_info[1].'"'; |
|
| 683 | - } |
|
| 684 | - } |
|
| 685 | - $Result = $Result. |
|
| 686 | - "<res size=\"$size\"$res_info_ex protocolInfo=\"http-get:*:$mimetype:*\">$baseurlpatch$en_entry</res>". |
|
| 687 | - '</item>'; |
|
| 688 | - } |
|
| 689 | - } |
|
| 690 | - |
|
| 691 | - $Result = $Result.'</DIDL-Lite>'; |
|
| 692 | - return (array('Result' => $Result, |
|
| 693 | - 'NumberReturned' => $NumberReturned, |
|
| 694 | - 'TotalMatches' => $TotalMatches, |
|
| 695 | - 'UpdateID' => $UpdateID)); |
|
| 550 | + continue; |
|
| 551 | + } |
|
| 552 | + $entry = trim(fgets($fd)); |
|
| 553 | + if (false === strpos($entry, '://')) |
|
| 554 | + continue; |
|
| 555 | + /* Ok, item matched and may be returned. */ |
|
| 556 | + $TotalMatches++; |
|
| 557 | + if (0 < $StartingIndex && |
|
| 558 | + $TotalMatches < $StartingIndex) |
|
| 559 | + continue; /* Skip first items. */ |
|
| 560 | + if (0 < $RequestedCount && |
|
| 561 | + $NumberReturned >= $RequestedCount) |
|
| 562 | + continue; /* Do not add more than requested. */ |
|
| 563 | + $NumberReturned++; |
|
| 564 | + /* Add item to result. */ |
|
| 565 | + $title = xml_encode(trim(substr($buffer, (strpos($buffer, ',') + 1)))); |
|
| 566 | + //$en_entry = upnp_url_encode($entry); |
|
| 567 | + $en_entry = xml_encode($entry); |
|
| 568 | + $iclass = upnp_get_class($entry, 'object.item.videoItem.videoBroadcast'); |
|
| 569 | + $mimetype = 'video/mpeg'; |
|
| 570 | + if ('object.container.storageFolder' === $iclass) { /* Play list as folder! */ |
|
| 571 | + $Result = $Result. |
|
| 572 | + "<container id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\">". |
|
| 573 | + "<dc:title>$title</dc:title>". |
|
| 574 | + '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
| 575 | + '</container>'; |
|
| 576 | + } else { |
|
| 577 | + //$logo = get_named_val("tvg-logo", $buffer); |
|
| 578 | + //if (null === $logo) { |
|
| 579 | + // $logo = trim(substr($buffer, (strpos($buffer, ',') + 1))); |
|
| 580 | + //} |
|
| 581 | + //$icon_url = upnp_url_encode($logo_url_path . mb_convert_case($logo, MB_CASE_LOWER, "UTF-8") . '.png'); |
|
| 582 | + $Result = $Result. |
|
| 583 | + "<item id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\">". |
|
| 584 | + "<dc:title>$title</dc:title>". |
|
| 585 | + "<dc:date>$date</dc:date>". |
|
| 586 | + //"<upnp:albumArtURI dlna:profileID=\"JPEG_TN\" xmlns:dlna=\"urn:schemas-dlna-org:metadata-1-0\">$icon_url</upnp:albumArtURI>" . |
|
| 587 | + //"<upnp:icon>$icon_url</upnp:icon>" . |
|
| 588 | + "<upnp:class>$iclass</upnp:class>". |
|
| 589 | + "<res protocolInfo=\"http-get:*:$mimetype:*\">$en_entry</res>". |
|
| 590 | + '</item>'; |
|
| 591 | + } |
|
| 592 | + } |
|
| 593 | + fclose($fd); |
|
| 594 | + |
|
| 595 | + $Result = $Result.'</DIDL-Lite>'; |
|
| 596 | + return (array('Result' => $Result, |
|
| 597 | + 'NumberReturned' => $NumberReturned, |
|
| 598 | + 'TotalMatches' => $TotalMatches, |
|
| 599 | + 'UpdateID' => $UpdateID)); |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + /* Scan directory and add to play list.*/ |
|
| 603 | + $entries = scandir($basedir.$dir); |
|
| 604 | + /* Add dirs to play list. */ |
|
| 605 | + foreach ($entries as $entry) { |
|
| 606 | + $filename = $basedir.$dir.$entry; |
|
| 607 | + if ('.' === substr($entry, 0, 1) || |
|
| 608 | + !is_dir($filename)) /* Skip files. */ |
|
| 609 | + continue; |
|
| 610 | + /* Ok, item matched and may be returned. */ |
|
| 611 | + $TotalMatches++; |
|
| 612 | + if (0 < $StartingIndex && |
|
| 613 | + $TotalMatches < $StartingIndex) |
|
| 614 | + continue; /* Skip first items. */ |
|
| 615 | + if (0 < $RequestedCount && |
|
| 616 | + $NumberReturned >= $RequestedCount) |
|
| 617 | + continue; /* Do not add more than requested. */ |
|
| 618 | + $NumberReturned++; |
|
| 619 | + /* Add item to result. */ |
|
| 620 | + if (is_writable($filename)) { |
|
| 621 | + $Restricted = '0'; |
|
| 622 | + } else { |
|
| 623 | + $Restricted = '1'; |
|
| 624 | + } |
|
| 625 | + $title = xml_encode($entry); |
|
| 626 | + $en_entry = upnp_url_encode($dir.$entry); |
|
| 627 | + $ChildCount = (count(scandir($filename)) - 2); |
|
| 628 | + $Result = $Result. |
|
| 629 | + "<container id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
| 630 | + "<dc:title>$title</dc:title>". |
|
| 631 | + '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
| 632 | + '</container>'; |
|
| 633 | + } |
|
| 634 | + /* Add files to play list. */ |
|
| 635 | + foreach ($entries as $entry) { |
|
| 636 | + $filename = $basedir.$dir.$entry; |
|
| 637 | + if (is_dir($filename)) /* Skip dirs. */ |
|
| 638 | + continue; |
|
| 639 | + $iclass = upnp_get_class($entry, null); |
|
| 640 | + if (null === $iclass) /* Skip unsupported file type. */ |
|
| 641 | + continue; |
|
| 642 | + /* Ok, item matched and may be returned. */ |
|
| 643 | + $TotalMatches++; |
|
| 644 | + if (0 < $StartingIndex && |
|
| 645 | + $TotalMatches < $StartingIndex) |
|
| 646 | + continue; /* Skip first items. */ |
|
| 647 | + if (0 < $RequestedCount && |
|
| 648 | + $NumberReturned >= $RequestedCount) |
|
| 649 | + continue; /* Do not add more than requested. */ |
|
| 650 | + $NumberReturned++; |
|
| 651 | + /* Add item to result. */ |
|
| 652 | + if (is_writable($filename)) { |
|
| 653 | + $Restricted = '0'; |
|
| 654 | + } else { |
|
| 655 | + $Restricted = '1'; |
|
| 656 | + } |
|
| 657 | + $title = xml_encode($entry); |
|
| 658 | + $en_entry = upnp_url_encode($dir.$entry); |
|
| 659 | + if ('object.container.storageFolder' === $iclass) { /* Play list as folder! */ |
|
| 660 | + $ChildCount = m3u_calc_items_count($filename); |
|
| 661 | + $Result = $Result. |
|
| 662 | + "<container id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
| 663 | + "<dc:title>$title</dc:title>". |
|
| 664 | + '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
| 665 | + '</container>'; |
|
| 666 | + } else { |
|
| 667 | + $date = upnp_date(filectime($filename), 1); |
|
| 668 | + $size = filesize($filename); |
|
| 669 | + $mimetype = upnp_mime_content_type($filename); |
|
| 670 | + $res_info_ex = ''; |
|
| 671 | + $Result = $Result. |
|
| 672 | + "<item id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\">". |
|
| 673 | + "<dc:title>$title</dc:title>". |
|
| 674 | + "<dc:date>$date</dc:date>". |
|
| 675 | + "<upnp:class>$iclass</upnp:class>"; |
|
| 676 | + if ('object.item.imageItem' === substr($iclass, 0, 21)) { |
|
| 677 | + $Result = $Result. |
|
| 678 | + "<upnp:albumArtURI>$baseurlpatch$en_entry</upnp:albumArtURI>". |
|
| 679 | + "<upnp:icon>$baseurlpatch$en_entry</upnp:icon>"; |
|
| 680 | + $img_info = getimagesize($filename); |
|
| 681 | + if (false !== $img_info) { |
|
| 682 | + $res_info_ex = ' resolution="'.$img_info[0].'x'.$img_info[1].'"'; |
|
| 683 | + } |
|
| 684 | + } |
|
| 685 | + $Result = $Result. |
|
| 686 | + "<res size=\"$size\"$res_info_ex protocolInfo=\"http-get:*:$mimetype:*\">$baseurlpatch$en_entry</res>". |
|
| 687 | + '</item>'; |
|
| 688 | + } |
|
| 689 | + } |
|
| 690 | + |
|
| 691 | + $Result = $Result.'</DIDL-Lite>'; |
|
| 692 | + return (array('Result' => $Result, |
|
| 693 | + 'NumberReturned' => $NumberReturned, |
|
| 694 | + 'TotalMatches' => $TotalMatches, |
|
| 695 | + 'UpdateID' => $UpdateID)); |
|
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | |
| 699 | 699 | function Search($ContainerID, $SearchCriteria, $Filter, $StartingIndex, |
| 700 | 700 | $RequestedCount, $SortCriteria) { |
| 701 | - global $basedir, $baseurl, $baseurlpatch; |
|
| 702 | - $Result = '<DIDL-Lite'. |
|
| 703 | - ' xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"'. |
|
| 704 | - ' xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"'. |
|
| 705 | - ' xmlns:dc="http://purl.org/dc/elements/1.1/"'. |
|
| 706 | - ' xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"'. |
|
| 707 | - ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
|
| 708 | - ' xsi:schemaLocation="'. |
|
| 709 | - 'urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/ http://www.upnp.org/schemas/av/didl-lite.xsd '. |
|
| 710 | - 'urn:schemas-upnp-org:metadata-1-0/upnp/ http://www.upnp.org/schemas/av/upnp.xsd">'; |
|
| 711 | - $NumberReturned = 0; |
|
| 712 | - $TotalMatches = 0; |
|
| 713 | - $UpdateID = 1; |
|
| 714 | - |
|
| 715 | - $Result = $Result.'</DIDL-Lite>'; |
|
| 716 | - |
|
| 717 | - return (array('Result' => $Result, |
|
| 718 | - 'NumberReturned' => $NumberReturned, |
|
| 719 | - 'TotalMatches' => $TotalMatches, |
|
| 720 | - 'UpdateID' => $UpdateID)); |
|
| 701 | + global $basedir, $baseurl, $baseurlpatch; |
|
| 702 | + $Result = '<DIDL-Lite'. |
|
| 703 | + ' xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"'. |
|
| 704 | + ' xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"'. |
|
| 705 | + ' xmlns:dc="http://purl.org/dc/elements/1.1/"'. |
|
| 706 | + ' xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"'. |
|
| 707 | + ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
|
| 708 | + ' xsi:schemaLocation="'. |
|
| 709 | + 'urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/ http://www.upnp.org/schemas/av/didl-lite.xsd '. |
|
| 710 | + 'urn:schemas-upnp-org:metadata-1-0/upnp/ http://www.upnp.org/schemas/av/upnp.xsd">'; |
|
| 711 | + $NumberReturned = 0; |
|
| 712 | + $TotalMatches = 0; |
|
| 713 | + $UpdateID = 1; |
|
| 714 | + |
|
| 715 | + $Result = $Result.'</DIDL-Lite>'; |
|
| 716 | + |
|
| 717 | + return (array('Result' => $Result, |
|
| 718 | + 'NumberReturned' => $NumberReturned, |
|
| 719 | + 'TotalMatches' => $TotalMatches, |
|
| 720 | + 'UpdateID' => $UpdateID)); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | |
| 724 | 724 | function CreateObject($ContainerID, $Elements) { |
| 725 | - $ObjectID = ''; |
|
| 726 | - $Result = ''; |
|
| 725 | + $ObjectID = ''; |
|
| 726 | + $Result = ''; |
|
| 727 | 727 | |
| 728 | - return (array('ObjectID' => $ObjectID, |
|
| 729 | - 'Result' => $Result)); |
|
| 728 | + return (array('ObjectID' => $ObjectID, |
|
| 729 | + 'Result' => $Result)); |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | |
@@ -744,27 +744,27 @@ discard block |
||
| 744 | 744 | |
| 745 | 745 | /* Samsung private. */ |
| 746 | 746 | function X_GetFeatureList() { |
| 747 | - $FeatureList = |
|
| 748 | - '<?xml version="1.0" encoding="UTF-8"?>'. |
|
| 749 | - '<Features'. |
|
| 750 | - ' xmlns="urn:schemas-upnp-org:av:avs"'. |
|
| 751 | - ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
|
| 752 | - ' xmlns:sec="http://www.sec.co.kr/dlna"'. |
|
| 753 | - ' xsi:schemaLocation="urn:schemas-upnp-org:av:avs http://www.upnp.org/schemas/av/avs.xsd">'. |
|
| 754 | - '<Feature name="samsung.com_BASICVIEW" version="1">'. |
|
| 755 | - '<container id="A" type="object.item.audioItem"/>'. |
|
| 756 | - '<container id="I" type="object.item.imageItem"/>'. |
|
| 757 | - '<container id="V" type="object.item.videoItem"/>'. |
|
| 758 | - '<container id="P" type="object.item.playlistItem"/>'. |
|
| 759 | - '<container id="T" type="object.item.textItem"/>'. |
|
| 760 | - '</Feature>'. |
|
| 761 | - '</Features>'; |
|
| 762 | - |
|
| 763 | - return ($FeatureList); |
|
| 747 | + $FeatureList = |
|
| 748 | + '<?xml version="1.0" encoding="UTF-8"?>'. |
|
| 749 | + '<Features'. |
|
| 750 | + ' xmlns="urn:schemas-upnp-org:av:avs"'. |
|
| 751 | + ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
|
| 752 | + ' xmlns:sec="http://www.sec.co.kr/dlna"'. |
|
| 753 | + ' xsi:schemaLocation="urn:schemas-upnp-org:av:avs http://www.upnp.org/schemas/av/avs.xsd">'. |
|
| 754 | + '<Feature name="samsung.com_BASICVIEW" version="1">'. |
|
| 755 | + '<container id="A" type="object.item.audioItem"/>'. |
|
| 756 | + '<container id="I" type="object.item.imageItem"/>'. |
|
| 757 | + '<container id="V" type="object.item.videoItem"/>'. |
|
| 758 | + '<container id="P" type="object.item.playlistItem"/>'. |
|
| 759 | + '<container id="T" type="object.item.textItem"/>'. |
|
| 760 | + '</Feature>'. |
|
| 761 | + '</Features>'; |
|
| 762 | + |
|
| 763 | + return ($FeatureList); |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | function X_SetBookmark($CategoryType, $RID, $ObjectID, $PosSecond) { |
| 767 | - /* Return: |
|
| 767 | + /* Return: |
|
| 768 | 768 | * <sec:dcmInfo>BM=number of seconds</sec:dcmInfo> |
| 769 | 769 | * <upnp:lastPlaybackPosition>HH:MM:SS</upnp:lastPlaybackPosition> |
| 770 | 770 | */ |
@@ -776,27 +776,27 @@ discard block |
||
| 776 | 776 | |
| 777 | 777 | $request_body = @file_get_contents('php://input'); |
| 778 | 778 | try { |
| 779 | - $server->addFunction(array('GetSearchCapabilities', |
|
| 780 | - 'GetSortCapabilities', |
|
| 781 | - 'GetSortExtensionCapabilities', |
|
| 782 | - 'GetFeatureList', |
|
| 783 | - 'GetSystemUpdateID', |
|
| 784 | - 'GetServiceResetToken', |
|
| 785 | - 'Browse', |
|
| 786 | - 'Search', |
|
| 787 | - 'CreateObject', |
|
| 788 | - 'DestroyObject', |
|
| 789 | - 'UpdateObject', |
|
| 790 | - 'MoveObject', |
|
| 791 | - 'X_GetFeatureList', |
|
| 792 | - 'X_SetBookmark' |
|
| 793 | - )); |
|
| 794 | - ob_start(); |
|
| 795 | - $server->handle($request_body); |
|
| 796 | - $soapXml = ob_get_clean(); |
|
| 779 | + $server->addFunction(array('GetSearchCapabilities', |
|
| 780 | + 'GetSortCapabilities', |
|
| 781 | + 'GetSortExtensionCapabilities', |
|
| 782 | + 'GetFeatureList', |
|
| 783 | + 'GetSystemUpdateID', |
|
| 784 | + 'GetServiceResetToken', |
|
| 785 | + 'Browse', |
|
| 786 | + 'Search', |
|
| 787 | + 'CreateObject', |
|
| 788 | + 'DestroyObject', |
|
| 789 | + 'UpdateObject', |
|
| 790 | + 'MoveObject', |
|
| 791 | + 'X_GetFeatureList', |
|
| 792 | + 'X_SetBookmark' |
|
| 793 | + )); |
|
| 794 | + ob_start(); |
|
| 795 | + $server->handle($request_body); |
|
| 796 | + $soapXml = ob_get_clean(); |
|
| 797 | 797 | } catch (Exception $e) { |
| 798 | - $server->fault($e->getCode(), $e->getMessage()); |
|
| 799 | - throw $e; |
|
| 798 | + $server->fault($e->getCode(), $e->getMessage()); |
|
| 799 | + throw $e; |
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | |
@@ -804,44 +804,44 @@ discard block |
||
| 804 | 804 | |
| 805 | 805 | |
| 806 | 806 | function get_resp_tag_name($sxml) { |
| 807 | - $tag_st = strpos($sxml, '<SOAP-ENV:Body><SOAP-ENV:'); |
|
| 808 | - if (false === $tag_st) |
|
| 809 | - return (false); |
|
| 810 | - $tag_st += 25; |
|
| 811 | - $tag_end = strpos($sxml, '>', $tag_st); |
|
| 812 | - if (false === $tag_end) |
|
| 813 | - return (false); |
|
| 814 | - return (substr($sxml, $tag_st, ($tag_end - $tag_st))); |
|
| 807 | + $tag_st = strpos($sxml, '<SOAP-ENV:Body><SOAP-ENV:'); |
|
| 808 | + if (false === $tag_st) |
|
| 809 | + return (false); |
|
| 810 | + $tag_st += 25; |
|
| 811 | + $tag_end = strpos($sxml, '>', $tag_st); |
|
| 812 | + if (false === $tag_end) |
|
| 813 | + return (false); |
|
| 814 | + return (substr($sxml, $tag_st, ($tag_end - $tag_st))); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | function get_tag_ns($req, $tag) { |
| 818 | - $rreq = strrev($req); |
|
| 819 | - $ns_st = strpos($rreq, strrev(":$tag>")); |
|
| 820 | - if (false === $ns_st) |
|
| 821 | - return (false); |
|
| 822 | - $ns_st += (strlen($tag) + 2); |
|
| 823 | - $ns_end = strpos($rreq, '/<', $ns_st); |
|
| 824 | - if (false === $ns_end) |
|
| 825 | - return (false); |
|
| 826 | - return (strrev(substr($rreq, $ns_st, ($ns_end - $ns_st)))); |
|
| 818 | + $rreq = strrev($req); |
|
| 819 | + $ns_st = strpos($rreq, strrev(":$tag>")); |
|
| 820 | + if (false === $ns_st) |
|
| 821 | + return (false); |
|
| 822 | + $ns_st += (strlen($tag) + 2); |
|
| 823 | + $ns_end = strpos($rreq, '/<', $ns_st); |
|
| 824 | + if (false === $ns_end) |
|
| 825 | + return (false); |
|
| 826 | + return (strrev(substr($rreq, $ns_st, ($ns_end - $ns_st)))); |
|
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | function tag_ns_replace($req, $sxml, $tag, $ns = false) { |
| 830 | - if (false === $tag) |
|
| 831 | - return ($sxml); |
|
| 832 | - if (false === $ns) |
|
| 833 | - $ns = get_tag_ns($req, $tag); |
|
| 834 | - if (false === $ns) |
|
| 835 | - return ($sxml); |
|
| 836 | - while ($tag_st = strpos($sxml, "<SOAP-ENV:$tag")) { |
|
| 837 | - $tag_end = strpos($sxml, '>', $tag_st); |
|
| 838 | - if (false === $tag_end) |
|
| 839 | - return ($sxml); |
|
| 840 | - $old_tag_data = substr($sxml, $tag_st, ($tag_end - $tag_st)); |
|
| 841 | - $new_tag_data = str_replace('SOAP-ENV', $ns, $old_tag_data); |
|
| 842 | - $sxml = str_replace($old_tag_data, $new_tag_data, $sxml); |
|
| 843 | - } |
|
| 844 | - return (str_replace("</SOAP-ENV:$tag>", "</$ns:$tag>", $sxml)); |
|
| 830 | + if (false === $tag) |
|
| 831 | + return ($sxml); |
|
| 832 | + if (false === $ns) |
|
| 833 | + $ns = get_tag_ns($req, $tag); |
|
| 834 | + if (false === $ns) |
|
| 835 | + return ($sxml); |
|
| 836 | + while ($tag_st = strpos($sxml, "<SOAP-ENV:$tag")) { |
|
| 837 | + $tag_end = strpos($sxml, '>', $tag_st); |
|
| 838 | + if (false === $tag_end) |
|
| 839 | + return ($sxml); |
|
| 840 | + $old_tag_data = substr($sxml, $tag_st, ($tag_end - $tag_st)); |
|
| 841 | + $new_tag_data = str_replace('SOAP-ENV', $ns, $old_tag_data); |
|
| 842 | + $sxml = str_replace($old_tag_data, $new_tag_data, $sxml); |
|
| 843 | + } |
|
| 844 | + return (str_replace("</SOAP-ENV:$tag>", "</$ns:$tag>", $sxml)); |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | |
@@ -158,8 +158,9 @@ discard block |
||
| 158 | 158 | /* "urn:schemas-upnp-org:service:ContentDirectory:1#Browse" */ |
| 159 | 159 | $http_hdr_soapact = $_SERVER['HTTP_SOAPACTION']; |
| 160 | 160 | $soap_shemas = strpos($http_hdr_soapact, 'urn:schemas-upnp-org:service:ContentDirectory:'); |
| 161 | -if (false === $soap_shemas) |
|
| 161 | +if (false === $soap_shemas) { |
|
| 162 | 162 | return (500); |
| 163 | +} |
|
| 163 | 164 | $soap_service_ver = substr($http_hdr_soapact, ($soap_shemas + 46), 1); |
| 164 | 165 | $soap_service_func = substr($http_hdr_soapact, ($soap_shemas + 48), -1); |
| 165 | 166 | |
@@ -209,8 +210,9 @@ discard block |
||
| 209 | 210 | function upnp_url_encode($url) { |
| 210 | 211 | |
| 211 | 212 | if ('http://' !== substr($url, 0, 7) || |
| 212 | - false === ($url_path_off = strrpos($url, '/', 8))) |
|
| 213 | - return (implode('/', array_map('rawurlencode', explode('/', $url)))); |
|
| 213 | + false === ($url_path_off = strrpos($url, '/', 8))) { |
|
| 214 | + return (implode('/', array_map('rawurlencode', explode('/', $url)))); |
|
| 215 | + } |
|
| 214 | 216 | //return (xml_encode(implode('/', array_map('rawurlencode', explode('/', $url))))); |
| 215 | 217 | //return (xml_encode($url)); |
| 216 | 218 | //return ('<![CDATA[' . xml_encode($url) . ']]'); |
@@ -225,14 +227,18 @@ discard block |
||
| 225 | 227 | function upnp_get_class($file, $def) { |
| 226 | 228 | global $file_class; |
| 227 | 229 | |
| 228 | - if (!isset($file)) |
|
| 229 | - return ($def); |
|
| 230 | + if (!isset($file)) { |
|
| 231 | + return ($def); |
|
| 232 | + } |
|
| 230 | 233 | $dot = strrpos($file, '.'); |
| 231 | - if (false === $dot) |
|
| 232 | - return ($def); |
|
| 234 | + if (false === $dot) { |
|
| 235 | + return ($def); |
|
| 236 | + } |
|
| 233 | 237 | $ext = strtolower(substr($file, ($dot + 1))); |
| 234 | - if (isset($file_class[$ext])) /* Skip unsupported file type. */ |
|
| 238 | + if (isset($file_class[$ext])) { |
|
| 239 | + /* Skip unsupported file type. */ |
|
| 235 | 240 | return ($file_class[$ext]); |
| 241 | + } |
|
| 236 | 242 | |
| 237 | 243 | return ($def); |
| 238 | 244 | } |
@@ -241,15 +247,18 @@ discard block |
||
| 241 | 247 | function get_named_val($name, $buf) { /* ...val_name="value"... */ |
| 242 | 248 | |
| 243 | 249 | $st_off = strpos($buf, $name); |
| 244 | - if (false === $st_off) |
|
| 245 | - return (null); |
|
| 250 | + if (false === $st_off) { |
|
| 251 | + return (null); |
|
| 252 | + } |
|
| 246 | 253 | $st_off += strlen($name); |
| 247 | - if ('="' !== substr($buf, $st_off, 2)) |
|
| 248 | - return (null); |
|
| 254 | + if ('="' !== substr($buf, $st_off, 2)) { |
|
| 255 | + return (null); |
|
| 256 | + } |
|
| 249 | 257 | $st_off += 2; |
| 250 | 258 | $en_off = strpos($buf, '"', $st_off); |
| 251 | - if (false === $en_off) |
|
| 252 | - return (null); |
|
| 259 | + if (false === $en_off) { |
|
| 260 | + return (null); |
|
| 261 | + } |
|
| 253 | 262 | |
| 254 | 263 | return (substr($buf, $st_off, ($en_off - $st_off))); |
| 255 | 264 | } |
@@ -259,15 +268,19 @@ discard block |
||
| 259 | 268 | |
| 260 | 269 | $items_count = 0; |
| 261 | 270 | $fd = fopen($filename, 'r'); |
| 262 | - if (false === $fd) |
|
| 263 | - return ($items_count); |
|
| 271 | + if (false === $fd) { |
|
| 272 | + return ($items_count); |
|
| 273 | + } |
|
| 264 | 274 | while (!feof($fd)) { /* Read the file line by line... */ |
| 265 | 275 | $buffer = trim(fgets($fd)); |
| 266 | - if (false === strpos($buffer, '#EXTINF:')) /* Skip empty/bad lines. */ |
|
| 276 | + if (false === strpos($buffer, '#EXTINF:')) { |
|
| 277 | + /* Skip empty/bad lines. */ |
|
| 267 | 278 | continue; |
| 279 | + } |
|
| 268 | 280 | $entry = trim(fgets($fd)); |
| 269 | - if (false === strpos($entry, '://')) |
|
| 270 | - continue; |
|
| 281 | + if (false === strpos($entry, '://')) { |
|
| 282 | + continue; |
|
| 283 | + } |
|
| 271 | 284 | $items_count++; |
| 272 | 285 | } |
| 273 | 286 | fclose($fd); |
@@ -280,11 +293,13 @@ discard block |
||
| 280 | 293 | |
| 281 | 294 | $def = 'video/mpeg'; |
| 282 | 295 | |
| 283 | - if (!isset($filename)) |
|
| 284 | - return ($def); |
|
| 296 | + if (!isset($filename)) { |
|
| 297 | + return ($def); |
|
| 298 | + } |
|
| 285 | 299 | $dot = strrpos($filename, '.'); |
| 286 | - if (false === $dot) |
|
| 287 | - return ($def); |
|
| 300 | + if (false === $dot) { |
|
| 301 | + return ($def); |
|
| 302 | + } |
|
| 288 | 303 | $ext = strtolower(substr($filename, ($dot + 1))); |
| 289 | 304 | if (array_key_exists($ext, $mime_types)) { |
| 290 | 305 | return ($mime_types[$ext]); |
@@ -404,8 +419,9 @@ discard block |
||
| 404 | 419 | $dotdotdir = ''; |
| 405 | 420 | $dirnames = explode('/', $dir); |
| 406 | 421 | for ($di = 0; $di < sizeof($dirnames); $di++) { |
| 407 | - if ('.' === $dirnames[$di]) |
|
| 408 | - continue; |
|
| 422 | + if ('.' === $dirnames[$di]) { |
|
| 423 | + continue; |
|
| 424 | + } |
|
| 409 | 425 | if ('..' === $dirnames[$di]) { |
| 410 | 426 | $dir = ''; |
| 411 | 427 | break; |
@@ -550,16 +566,21 @@ discard block |
||
| 550 | 566 | continue; |
| 551 | 567 | } |
| 552 | 568 | $entry = trim(fgets($fd)); |
| 553 | - if (false === strpos($entry, '://')) |
|
| 554 | - continue; |
|
| 569 | + if (false === strpos($entry, '://')) { |
|
| 570 | + continue; |
|
| 571 | + } |
|
| 555 | 572 | /* Ok, item matched and may be returned. */ |
| 556 | 573 | $TotalMatches++; |
| 557 | 574 | if (0 < $StartingIndex && |
| 558 | - $TotalMatches < $StartingIndex) |
|
| 559 | - continue; /* Skip first items. */ |
|
| 575 | + $TotalMatches < $StartingIndex) { |
|
| 576 | + continue; |
|
| 577 | + } |
|
| 578 | + /* Skip first items. */ |
|
| 560 | 579 | if (0 < $RequestedCount && |
| 561 | - $NumberReturned >= $RequestedCount) |
|
| 562 | - continue; /* Do not add more than requested. */ |
|
| 580 | + $NumberReturned >= $RequestedCount) { |
|
| 581 | + continue; |
|
| 582 | + } |
|
| 583 | + /* Do not add more than requested. */ |
|
| 563 | 584 | $NumberReturned++; |
| 564 | 585 | /* Add item to result. */ |
| 565 | 586 | $title = xml_encode(trim(substr($buffer, (strpos($buffer, ',') + 1)))); |
@@ -605,16 +626,22 @@ discard block |
||
| 605 | 626 | foreach ($entries as $entry) { |
| 606 | 627 | $filename = $basedir.$dir.$entry; |
| 607 | 628 | if ('.' === substr($entry, 0, 1) || |
| 608 | - !is_dir($filename)) /* Skip files. */ |
|
| 629 | + !is_dir($filename)) { |
|
| 630 | + /* Skip files. */ |
|
| 609 | 631 | continue; |
| 632 | + } |
|
| 610 | 633 | /* Ok, item matched and may be returned. */ |
| 611 | 634 | $TotalMatches++; |
| 612 | 635 | if (0 < $StartingIndex && |
| 613 | - $TotalMatches < $StartingIndex) |
|
| 614 | - continue; /* Skip first items. */ |
|
| 636 | + $TotalMatches < $StartingIndex) { |
|
| 637 | + continue; |
|
| 638 | + } |
|
| 639 | + /* Skip first items. */ |
|
| 615 | 640 | if (0 < $RequestedCount && |
| 616 | - $NumberReturned >= $RequestedCount) |
|
| 617 | - continue; /* Do not add more than requested. */ |
|
| 641 | + $NumberReturned >= $RequestedCount) { |
|
| 642 | + continue; |
|
| 643 | + } |
|
| 644 | + /* Do not add more than requested. */ |
|
| 618 | 645 | $NumberReturned++; |
| 619 | 646 | /* Add item to result. */ |
| 620 | 647 | if (is_writable($filename)) { |
@@ -634,19 +661,27 @@ discard block |
||
| 634 | 661 | /* Add files to play list. */ |
| 635 | 662 | foreach ($entries as $entry) { |
| 636 | 663 | $filename = $basedir.$dir.$entry; |
| 637 | - if (is_dir($filename)) /* Skip dirs. */ |
|
| 664 | + if (is_dir($filename)) { |
|
| 665 | + /* Skip dirs. */ |
|
| 638 | 666 | continue; |
| 667 | + } |
|
| 639 | 668 | $iclass = upnp_get_class($entry, null); |
| 640 | - if (null === $iclass) /* Skip unsupported file type. */ |
|
| 669 | + if (null === $iclass) { |
|
| 670 | + /* Skip unsupported file type. */ |
|
| 641 | 671 | continue; |
| 672 | + } |
|
| 642 | 673 | /* Ok, item matched and may be returned. */ |
| 643 | 674 | $TotalMatches++; |
| 644 | 675 | if (0 < $StartingIndex && |
| 645 | - $TotalMatches < $StartingIndex) |
|
| 646 | - continue; /* Skip first items. */ |
|
| 676 | + $TotalMatches < $StartingIndex) { |
|
| 677 | + continue; |
|
| 678 | + } |
|
| 679 | + /* Skip first items. */ |
|
| 647 | 680 | if (0 < $RequestedCount && |
| 648 | - $NumberReturned >= $RequestedCount) |
|
| 649 | - continue; /* Do not add more than requested. */ |
|
| 681 | + $NumberReturned >= $RequestedCount) { |
|
| 682 | + continue; |
|
| 683 | + } |
|
| 684 | + /* Do not add more than requested. */ |
|
| 650 | 685 | $NumberReturned++; |
| 651 | 686 | /* Add item to result. */ |
| 652 | 687 | if (is_writable($filename)) { |
@@ -805,38 +840,46 @@ discard block |
||
| 805 | 840 | |
| 806 | 841 | function get_resp_tag_name($sxml) { |
| 807 | 842 | $tag_st = strpos($sxml, '<SOAP-ENV:Body><SOAP-ENV:'); |
| 808 | - if (false === $tag_st) |
|
| 809 | - return (false); |
|
| 843 | + if (false === $tag_st) { |
|
| 844 | + return (false); |
|
| 845 | + } |
|
| 810 | 846 | $tag_st += 25; |
| 811 | 847 | $tag_end = strpos($sxml, '>', $tag_st); |
| 812 | - if (false === $tag_end) |
|
| 813 | - return (false); |
|
| 848 | + if (false === $tag_end) { |
|
| 849 | + return (false); |
|
| 850 | + } |
|
| 814 | 851 | return (substr($sxml, $tag_st, ($tag_end - $tag_st))); |
| 815 | 852 | } |
| 816 | 853 | |
| 817 | 854 | function get_tag_ns($req, $tag) { |
| 818 | 855 | $rreq = strrev($req); |
| 819 | 856 | $ns_st = strpos($rreq, strrev(":$tag>")); |
| 820 | - if (false === $ns_st) |
|
| 821 | - return (false); |
|
| 857 | + if (false === $ns_st) { |
|
| 858 | + return (false); |
|
| 859 | + } |
|
| 822 | 860 | $ns_st += (strlen($tag) + 2); |
| 823 | 861 | $ns_end = strpos($rreq, '/<', $ns_st); |
| 824 | - if (false === $ns_end) |
|
| 825 | - return (false); |
|
| 862 | + if (false === $ns_end) { |
|
| 863 | + return (false); |
|
| 864 | + } |
|
| 826 | 865 | return (strrev(substr($rreq, $ns_st, ($ns_end - $ns_st)))); |
| 827 | 866 | } |
| 828 | 867 | |
| 829 | 868 | function tag_ns_replace($req, $sxml, $tag, $ns = false) { |
| 830 | - if (false === $tag) |
|
| 831 | - return ($sxml); |
|
| 832 | - if (false === $ns) |
|
| 833 | - $ns = get_tag_ns($req, $tag); |
|
| 834 | - if (false === $ns) |
|
| 835 | - return ($sxml); |
|
| 869 | + if (false === $tag) { |
|
| 870 | + return ($sxml); |
|
| 871 | + } |
|
| 872 | + if (false === $ns) { |
|
| 873 | + $ns = get_tag_ns($req, $tag); |
|
| 874 | + } |
|
| 875 | + if (false === $ns) { |
|
| 876 | + return ($sxml); |
|
| 877 | + } |
|
| 836 | 878 | while ($tag_st = strpos($sxml, "<SOAP-ENV:$tag")) { |
| 837 | 879 | $tag_end = strpos($sxml, '>', $tag_st); |
| 838 | - if (false === $tag_end) |
|
| 839 | - return ($sxml); |
|
| 880 | + if (false === $tag_end) { |
|
| 881 | + return ($sxml); |
|
| 882 | + } |
|
| 840 | 883 | $old_tag_data = substr($sxml, $tag_st, ($tag_end - $tag_st)); |
| 841 | 884 | $new_tag_data = str_replace('SOAP-ENV', $ns, $old_tag_data); |
| 842 | 885 | $sxml = str_replace($old_tag_data, $new_tag_data, $sxml); |