@@ -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,125 +178,125 @@ 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 | - global $mime_types; |
|
281 | - |
|
282 | - $def = 'video/mpeg'; |
|
283 | - |
|
284 | - if (!isset($filename)) |
|
285 | - return ($def); |
|
286 | - $dot = strrpos($filename, '.'); |
|
287 | - if (false === $dot) |
|
288 | - return ($def); |
|
289 | - $ext = strtolower(substr($filename, ($dot + 1))); |
|
290 | - if (array_key_exists($ext, $mime_types)) { |
|
291 | - return ($mime_types[$ext]); |
|
292 | - } elseif (function_exists('finfo_open')) { |
|
293 | - $finfo = finfo_open(FILEINFO_MIME); |
|
294 | - $mimetype = finfo_file($finfo, $filename); |
|
295 | - finfo_close($finfo); |
|
296 | - return ($mimetype); |
|
297 | - } |
|
298 | - |
|
299 | - return ($def); |
|
280 | + global $mime_types; |
|
281 | + |
|
282 | + $def = 'video/mpeg'; |
|
283 | + |
|
284 | + if (!isset($filename)) |
|
285 | + return ($def); |
|
286 | + $dot = strrpos($filename, '.'); |
|
287 | + if (false === $dot) |
|
288 | + return ($def); |
|
289 | + $ext = strtolower(substr($filename, ($dot + 1))); |
|
290 | + if (array_key_exists($ext, $mime_types)) { |
|
291 | + return ($mime_types[$ext]); |
|
292 | + } elseif (function_exists('finfo_open')) { |
|
293 | + $finfo = finfo_open(FILEINFO_MIME); |
|
294 | + $mimetype = finfo_file($finfo, $filename); |
|
295 | + finfo_close($finfo); |
|
296 | + return ($mimetype); |
|
297 | + } |
|
298 | + |
|
299 | + return ($def); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /* Format: |
@@ -304,241 +304,241 @@ discard block |
||
304 | 304 | * 1: 2004-05-08T10:00:00 |
305 | 305 | * */ |
306 | 306 | function upnp_date($timedate, $format) { |
307 | - $res = date('Y-m-d', $timedate); |
|
307 | + $res = date('Y-m-d', $timedate); |
|
308 | 308 | |
309 | - if (1 === $format) { |
|
310 | - $res = $res.'T'.date('H:i:s', $timedate); |
|
311 | - } |
|
309 | + if (1 === $format) { |
|
310 | + $res = $res.'T'.date('H:i:s', $timedate); |
|
311 | + } |
|
312 | 312 | |
313 | - return ($res); |
|
313 | + return ($res); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | |
317 | 317 | /* ContentDirectory funcs */ |
318 | 318 | |
319 | 319 | function GetSearchCapabilities() { |
320 | - // 'upnp:class'; /* dc:title,upnp:class,upnp:artist */ |
|
321 | - //$SearchCaps = 'dc:creator,dc:date,dc:title,upnp:album,upnp:actor,upnp:artist,upnp:class,upnp:genre,@id,@parentID,@refID'; |
|
322 | - $SearchCaps = 'dc:title'; |
|
320 | + // 'upnp:class'; /* dc:title,upnp:class,upnp:artist */ |
|
321 | + //$SearchCaps = 'dc:creator,dc:date,dc:title,upnp:album,upnp:actor,upnp:artist,upnp:class,upnp:genre,@id,@parentID,@refID'; |
|
322 | + $SearchCaps = 'dc:title'; |
|
323 | 323 | |
324 | - return ($SearchCaps); |
|
324 | + return ($SearchCaps); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | |
328 | 328 | function GetSortCapabilities() { |
329 | - $SortCaps = 'dc:title'; |
|
330 | - /* dc:title,upnp:genre,upnp:album,dc:creator,res@size, |
|
329 | + $SortCaps = 'dc:title'; |
|
330 | + /* dc:title,upnp:genre,upnp:album,dc:creator,res@size, |
|
331 | 331 | * res@duration,res@bitrate,dc:publisher, |
332 | 332 | * upnp:originalTrackNumber,dc:date,upnp:producer,upnp:rating, |
333 | 333 | * upnp:actor,upnp:director,dc:description |
334 | 334 | */ |
335 | 335 | |
336 | - return ($SortCaps); |
|
336 | + return ($SortCaps); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | |
340 | 340 | function GetSortExtensionCapabilities() { |
341 | - $SortExtensionCaps = ''; |
|
341 | + $SortExtensionCaps = ''; |
|
342 | 342 | |
343 | - return ($SortExtensionCaps); |
|
343 | + return ($SortExtensionCaps); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
347 | 347 | function GetFeatureList() { |
348 | - $FeatureList = ''; |
|
348 | + $FeatureList = ''; |
|
349 | 349 | |
350 | - return ($FeatureList); |
|
350 | + return ($FeatureList); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | |
354 | 354 | function GetSystemUpdateID() { |
355 | - $Id = '1'; |
|
355 | + $Id = '1'; |
|
356 | 356 | |
357 | - return ($Id); |
|
357 | + return ($Id); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
361 | 361 | function GetServiceResetToken() { |
362 | - $ResetToken = '1'; |
|
362 | + $ResetToken = '1'; |
|
363 | 363 | |
364 | - return ($ResetToken); |
|
364 | + return ($ResetToken); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | |
368 | 368 | function Browse($ObjectID, $BrowseFlag, $Filter, $StartingIndex, |
369 | 369 | $RequestedCount, $SortCriteria) { |
370 | - global $basedir, $baseurl, $baseurlpatch; |
|
371 | - $Result = '<DIDL-Lite'. |
|
372 | - ' xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"'. |
|
373 | - ' xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"'. |
|
374 | - ' xmlns:dc="http://purl.org/dc/elements/1.1/"'. |
|
375 | - ' xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"'. |
|
376 | - ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
|
377 | - ' xsi:schemaLocation="'. |
|
378 | - 'urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/ http://www.upnp.org/schemas/av/didl-lite.xsd '. |
|
379 | - 'urn:schemas-upnp-org:metadata-1-0/upnp/ http://www.upnp.org/schemas/av/upnp.xsd">'; |
|
380 | - $ParentID = '-1'; |
|
381 | - $NumberReturned = 0; |
|
382 | - $TotalMatches = 0; |
|
383 | - $UpdateID = 1; |
|
384 | - |
|
385 | - /* Check input param. */ |
|
386 | - if (isset($ObjectID)) { |
|
387 | - if ((1 === strlen($ObjectID) || |
|
388 | - (3 === strlen($ObjectID) && '_T' === substr($ObjectID, 1, 2)) || |
|
389 | - (3 === strlen($ObjectID) && '_D' === substr($ObjectID, 1, 2)) || |
|
390 | - (3 === strlen($ObjectID) && '_L' === substr($ObjectID, 1, 2))) && ( |
|
391 | - '0' === substr($ObjectID, 0, 1) || |
|
392 | - 'A' === substr($ObjectID, 0, 1) || |
|
393 | - 'I' === substr($ObjectID, 0, 1) || |
|
394 | - 'V' === substr($ObjectID, 0, 1) || |
|
395 | - 'P' === substr($ObjectID, 0, 1) || |
|
396 | - 'T' === substr($ObjectID, 0, 1))) { /* V, I, A, P, T - from X_GetFeatureList() */ |
|
397 | - $ObjectID = '0'; |
|
398 | - $dir = ''; |
|
399 | - } else { |
|
400 | - $dir = rawurldecode(xml_decode($ObjectID)); |
|
401 | - if ('/' !== substr($dir, -1, 1)) { |
|
402 | - $dir = $dir.'/'; |
|
403 | - } |
|
404 | - /* Sec check: .. in path */ |
|
405 | - $dotdotdir = ''; |
|
406 | - $dirnames = explode('/', $dir); |
|
407 | - for ($di = 0; $di < sizeof($dirnames); $di++) { |
|
408 | - if ('.' === $dirnames[$di]) |
|
409 | - continue; |
|
410 | - if ('..' === $dirnames[$di]) { |
|
411 | - $dir = ''; |
|
412 | - break; |
|
413 | - } |
|
414 | - if ((sizeof($dirnames) - 1) > $di) { |
|
415 | - $dotdotdir = $dotdotdir.$dirnames[$di].'/'; |
|
416 | - } |
|
417 | - } |
|
418 | - $dir = $dotdotdir; |
|
419 | - if ('/' === substr($dir, 0, 1) /*|| !is_dir($basedir.$dir)*/) { |
|
420 | - $dir = ''; |
|
421 | - } |
|
422 | - /* Remove tail slash from file name. */ |
|
423 | - if (!is_dir($basedir.$dir) && |
|
424 | - '/' === substr($dir, -1, 1)) { |
|
425 | - $dir = substr($dir, 0, -1); |
|
426 | - } |
|
427 | - } |
|
428 | - } else { |
|
429 | - $ObjectID = '0'; |
|
430 | - $dir = ''; |
|
431 | - } |
|
432 | - |
|
433 | - if ('BrowseMetadata' === $BrowseFlag) { |
|
434 | - $filename = $basedir.$dir; |
|
435 | - /* Is file/dir exist? */ |
|
436 | - $stat = stat($filename); |
|
437 | - if (false === $stat) { /* No such file/dir. */ |
|
438 | - return (array('Result' => '', |
|
439 | - 'NumberReturned' => 0, |
|
440 | - 'TotalMatches' => 0, |
|
441 | - 'UpdateID' => $UpdateID)); |
|
442 | - } |
|
443 | - |
|
444 | - /* Collect data. */ |
|
445 | - if (is_writable($filename)) { |
|
446 | - $WriteStatus = 'WRITABLE'; |
|
447 | - $Restricted = '0'; |
|
448 | - } else { |
|
449 | - $WriteStatus = 'NOT_WRITABLE'; |
|
450 | - $Restricted = '1'; |
|
451 | - } |
|
452 | - $basefilename = basename($dir); |
|
453 | - if ('0' === $ObjectID) { |
|
454 | - $title = 'root'; |
|
455 | - $ParentID = '-1'; |
|
456 | - } else { |
|
457 | - $title = xml_encode($basefilename); |
|
458 | - $ParentID = upnp_url_encode(dirname($dir)); |
|
459 | - } |
|
460 | - |
|
461 | - if (is_dir($filename)) { /* Dir. */ |
|
462 | - $StorageTotal = disk_total_space($filename); |
|
463 | - $StorageFree = disk_free_space($filename); |
|
464 | - $StorageUsed = ($StorageTotal - $StorageFree); |
|
465 | - $ChildCount = (count(scandir($filename)) - 2); |
|
466 | - $Result = $Result. |
|
467 | - "<container id=\"$ObjectID\" parentID=\"$ParentID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
468 | - "<dc:title>$title</dc:title>". |
|
469 | - '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
470 | - "<upnp:storageTotal>$StorageTotal</upnp:storageTotal>". |
|
471 | - "<upnp:storageFree>$StorageFree</upnp:storageFree>". |
|
472 | - "<upnp:storageUsed>$StorageUsed</upnp:storageUsed>". |
|
473 | - "<upnp:writeStatus>$WriteStatus</upnp:writeStatus>"; |
|
474 | - if ('0' === $ObjectID) { |
|
475 | - $Result = $Result. |
|
476 | - '<upnp:searchClass includeDerived="1">object.item.audioItem</upnp:searchClass>'. |
|
477 | - '<upnp:searchClass includeDerived="1">object.item.imageItem</upnp:searchClass>'. |
|
478 | - '<upnp:searchClass includeDerived="1">object.item.videoItem</upnp:searchClass>'; |
|
479 | - } |
|
480 | - $Result = $Result.'</container>'; |
|
481 | - } else { /* File or playlist. */ |
|
482 | - $iclass = upnp_get_class($basefilename, 'object.item.videoItem'); |
|
483 | - if ('object.container.storageFolder' === $iclass) { /* Play list as folder! */ |
|
484 | - $ChildCount = m3u_calc_items_count($filename); |
|
485 | - $Result = $Result. |
|
486 | - "<container id=\"$ObjectID\" parentID=\"$ParentID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
487 | - "<dc:title>$title</dc:title>". |
|
488 | - '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
489 | - '</container>'; |
|
490 | - } else { |
|
491 | - $date = upnp_date(filectime($filename), 1); |
|
492 | - $size = filesize($filename); |
|
493 | - $mimetype = upnp_mime_content_type($filename); |
|
494 | - $Result = $Result. |
|
495 | - "<item id=\"$ObjectID\" parentID=\"$ParentID\" restricted=\"$Restricted\">". |
|
496 | - "<dc:title>$title</dc:title>". |
|
497 | - "<dc:date>$date</dc:date>". |
|
498 | - "<upnp:class>$iclass</upnp:class>". |
|
499 | - "<res size=\"$size\" protocolInfo=\"http-get:*:$mimetype:*\">$ObjectID</res>". |
|
500 | - '</item>'; |
|
501 | - } |
|
502 | - } |
|
503 | - $Result = $Result.'</DIDL-Lite>'; |
|
504 | - return (array('Result' => $Result, |
|
505 | - 'NumberReturned' => 1, |
|
506 | - 'TotalMatches' => 1, |
|
507 | - 'UpdateID' => $UpdateID)); |
|
508 | - } |
|
509 | - |
|
510 | - if (!isset($StartingIndex)) { |
|
511 | - $StartingIndex = 0; |
|
512 | - } |
|
513 | - if (!isset($RequestedCount)) { |
|
514 | - $RequestedCount = 0; |
|
515 | - } |
|
516 | - |
|
517 | - if (!is_dir($basedir.$dir)) { /* Play list file? */ |
|
518 | - /* Open the file. */ |
|
519 | - $filename = $basedir.$dir; |
|
520 | - $fd = fopen($filename, 'r'); |
|
521 | - if (false === $fd) { |
|
522 | - return (array('Result' => '', |
|
523 | - 'NumberReturned' => 0, |
|
524 | - 'TotalMatches' => 0, |
|
525 | - 'UpdateID' => $UpdateID)); |
|
526 | - } |
|
527 | - $date = upnp_date(filectime($filename), 1); |
|
528 | - if (is_writable($filename)) { |
|
529 | - $Restricted = '0'; |
|
530 | - } else { |
|
531 | - $Restricted = '1'; |
|
532 | - } |
|
533 | - |
|
534 | - //$logo_url_path = 'http://iptvremote.ru/channels/android/160/'; |
|
535 | - //$logo_url_path = 'http://172.16.0.254/download/tmp/image/'; |
|
536 | - while (!feof($fd)) { /* Read the file line by line... */ |
|
537 | - $buffer = trim(fgets($fd)); |
|
538 | - //if($buffer === false) |
|
539 | - // break; |
|
540 | - if (false === strpos($buffer, '#EXTINF:')) { /* Skip empty/bad lines. */ |
|
541 | - /*if (false !== strpos($buffer, '#EXTM3U')) { |
|
370 | + global $basedir, $baseurl, $baseurlpatch; |
|
371 | + $Result = '<DIDL-Lite'. |
|
372 | + ' xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"'. |
|
373 | + ' xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"'. |
|
374 | + ' xmlns:dc="http://purl.org/dc/elements/1.1/"'. |
|
375 | + ' xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"'. |
|
376 | + ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
|
377 | + ' xsi:schemaLocation="'. |
|
378 | + 'urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/ http://www.upnp.org/schemas/av/didl-lite.xsd '. |
|
379 | + 'urn:schemas-upnp-org:metadata-1-0/upnp/ http://www.upnp.org/schemas/av/upnp.xsd">'; |
|
380 | + $ParentID = '-1'; |
|
381 | + $NumberReturned = 0; |
|
382 | + $TotalMatches = 0; |
|
383 | + $UpdateID = 1; |
|
384 | + |
|
385 | + /* Check input param. */ |
|
386 | + if (isset($ObjectID)) { |
|
387 | + if ((1 === strlen($ObjectID) || |
|
388 | + (3 === strlen($ObjectID) && '_T' === substr($ObjectID, 1, 2)) || |
|
389 | + (3 === strlen($ObjectID) && '_D' === substr($ObjectID, 1, 2)) || |
|
390 | + (3 === strlen($ObjectID) && '_L' === substr($ObjectID, 1, 2))) && ( |
|
391 | + '0' === substr($ObjectID, 0, 1) || |
|
392 | + 'A' === substr($ObjectID, 0, 1) || |
|
393 | + 'I' === substr($ObjectID, 0, 1) || |
|
394 | + 'V' === substr($ObjectID, 0, 1) || |
|
395 | + 'P' === substr($ObjectID, 0, 1) || |
|
396 | + 'T' === substr($ObjectID, 0, 1))) { /* V, I, A, P, T - from X_GetFeatureList() */ |
|
397 | + $ObjectID = '0'; |
|
398 | + $dir = ''; |
|
399 | + } else { |
|
400 | + $dir = rawurldecode(xml_decode($ObjectID)); |
|
401 | + if ('/' !== substr($dir, -1, 1)) { |
|
402 | + $dir = $dir.'/'; |
|
403 | + } |
|
404 | + /* Sec check: .. in path */ |
|
405 | + $dotdotdir = ''; |
|
406 | + $dirnames = explode('/', $dir); |
|
407 | + for ($di = 0; $di < sizeof($dirnames); $di++) { |
|
408 | + if ('.' === $dirnames[$di]) |
|
409 | + continue; |
|
410 | + if ('..' === $dirnames[$di]) { |
|
411 | + $dir = ''; |
|
412 | + break; |
|
413 | + } |
|
414 | + if ((sizeof($dirnames) - 1) > $di) { |
|
415 | + $dotdotdir = $dotdotdir.$dirnames[$di].'/'; |
|
416 | + } |
|
417 | + } |
|
418 | + $dir = $dotdotdir; |
|
419 | + if ('/' === substr($dir, 0, 1) /*|| !is_dir($basedir.$dir)*/) { |
|
420 | + $dir = ''; |
|
421 | + } |
|
422 | + /* Remove tail slash from file name. */ |
|
423 | + if (!is_dir($basedir.$dir) && |
|
424 | + '/' === substr($dir, -1, 1)) { |
|
425 | + $dir = substr($dir, 0, -1); |
|
426 | + } |
|
427 | + } |
|
428 | + } else { |
|
429 | + $ObjectID = '0'; |
|
430 | + $dir = ''; |
|
431 | + } |
|
432 | + |
|
433 | + if ('BrowseMetadata' === $BrowseFlag) { |
|
434 | + $filename = $basedir.$dir; |
|
435 | + /* Is file/dir exist? */ |
|
436 | + $stat = stat($filename); |
|
437 | + if (false === $stat) { /* No such file/dir. */ |
|
438 | + return (array('Result' => '', |
|
439 | + 'NumberReturned' => 0, |
|
440 | + 'TotalMatches' => 0, |
|
441 | + 'UpdateID' => $UpdateID)); |
|
442 | + } |
|
443 | + |
|
444 | + /* Collect data. */ |
|
445 | + if (is_writable($filename)) { |
|
446 | + $WriteStatus = 'WRITABLE'; |
|
447 | + $Restricted = '0'; |
|
448 | + } else { |
|
449 | + $WriteStatus = 'NOT_WRITABLE'; |
|
450 | + $Restricted = '1'; |
|
451 | + } |
|
452 | + $basefilename = basename($dir); |
|
453 | + if ('0' === $ObjectID) { |
|
454 | + $title = 'root'; |
|
455 | + $ParentID = '-1'; |
|
456 | + } else { |
|
457 | + $title = xml_encode($basefilename); |
|
458 | + $ParentID = upnp_url_encode(dirname($dir)); |
|
459 | + } |
|
460 | + |
|
461 | + if (is_dir($filename)) { /* Dir. */ |
|
462 | + $StorageTotal = disk_total_space($filename); |
|
463 | + $StorageFree = disk_free_space($filename); |
|
464 | + $StorageUsed = ($StorageTotal - $StorageFree); |
|
465 | + $ChildCount = (count(scandir($filename)) - 2); |
|
466 | + $Result = $Result. |
|
467 | + "<container id=\"$ObjectID\" parentID=\"$ParentID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
468 | + "<dc:title>$title</dc:title>". |
|
469 | + '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
470 | + "<upnp:storageTotal>$StorageTotal</upnp:storageTotal>". |
|
471 | + "<upnp:storageFree>$StorageFree</upnp:storageFree>". |
|
472 | + "<upnp:storageUsed>$StorageUsed</upnp:storageUsed>". |
|
473 | + "<upnp:writeStatus>$WriteStatus</upnp:writeStatus>"; |
|
474 | + if ('0' === $ObjectID) { |
|
475 | + $Result = $Result. |
|
476 | + '<upnp:searchClass includeDerived="1">object.item.audioItem</upnp:searchClass>'. |
|
477 | + '<upnp:searchClass includeDerived="1">object.item.imageItem</upnp:searchClass>'. |
|
478 | + '<upnp:searchClass includeDerived="1">object.item.videoItem</upnp:searchClass>'; |
|
479 | + } |
|
480 | + $Result = $Result.'</container>'; |
|
481 | + } else { /* File or playlist. */ |
|
482 | + $iclass = upnp_get_class($basefilename, 'object.item.videoItem'); |
|
483 | + if ('object.container.storageFolder' === $iclass) { /* Play list as folder! */ |
|
484 | + $ChildCount = m3u_calc_items_count($filename); |
|
485 | + $Result = $Result. |
|
486 | + "<container id=\"$ObjectID\" parentID=\"$ParentID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
487 | + "<dc:title>$title</dc:title>". |
|
488 | + '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
489 | + '</container>'; |
|
490 | + } else { |
|
491 | + $date = upnp_date(filectime($filename), 1); |
|
492 | + $size = filesize($filename); |
|
493 | + $mimetype = upnp_mime_content_type($filename); |
|
494 | + $Result = $Result. |
|
495 | + "<item id=\"$ObjectID\" parentID=\"$ParentID\" restricted=\"$Restricted\">". |
|
496 | + "<dc:title>$title</dc:title>". |
|
497 | + "<dc:date>$date</dc:date>". |
|
498 | + "<upnp:class>$iclass</upnp:class>". |
|
499 | + "<res size=\"$size\" protocolInfo=\"http-get:*:$mimetype:*\">$ObjectID</res>". |
|
500 | + '</item>'; |
|
501 | + } |
|
502 | + } |
|
503 | + $Result = $Result.'</DIDL-Lite>'; |
|
504 | + return (array('Result' => $Result, |
|
505 | + 'NumberReturned' => 1, |
|
506 | + 'TotalMatches' => 1, |
|
507 | + 'UpdateID' => $UpdateID)); |
|
508 | + } |
|
509 | + |
|
510 | + if (!isset($StartingIndex)) { |
|
511 | + $StartingIndex = 0; |
|
512 | + } |
|
513 | + if (!isset($RequestedCount)) { |
|
514 | + $RequestedCount = 0; |
|
515 | + } |
|
516 | + |
|
517 | + if (!is_dir($basedir.$dir)) { /* Play list file? */ |
|
518 | + /* Open the file. */ |
|
519 | + $filename = $basedir.$dir; |
|
520 | + $fd = fopen($filename, 'r'); |
|
521 | + if (false === $fd) { |
|
522 | + return (array('Result' => '', |
|
523 | + 'NumberReturned' => 0, |
|
524 | + 'TotalMatches' => 0, |
|
525 | + 'UpdateID' => $UpdateID)); |
|
526 | + } |
|
527 | + $date = upnp_date(filectime($filename), 1); |
|
528 | + if (is_writable($filename)) { |
|
529 | + $Restricted = '0'; |
|
530 | + } else { |
|
531 | + $Restricted = '1'; |
|
532 | + } |
|
533 | + |
|
534 | + //$logo_url_path = 'http://iptvremote.ru/channels/android/160/'; |
|
535 | + //$logo_url_path = 'http://172.16.0.254/download/tmp/image/'; |
|
536 | + while (!feof($fd)) { /* Read the file line by line... */ |
|
537 | + $buffer = trim(fgets($fd)); |
|
538 | + //if($buffer === false) |
|
539 | + // break; |
|
540 | + if (false === strpos($buffer, '#EXTINF:')) { /* Skip empty/bad lines. */ |
|
541 | + /*if (false !== strpos($buffer, '#EXTM3U')) { |
|
542 | 542 | $logo_url_path = get_named_val('url-tvg-logo', $buffer); |
543 | 543 | if (null !== $logo_url_path) { |
544 | 544 | if ('/' !== substr($logo_url_path, -1, 1)) |
@@ -548,186 +548,186 @@ discard block |
||
548 | 548 | $logo_url_path = 'http://172.16.0.254/download/tmp/image/'; |
549 | 549 | } |
550 | 550 | }*/ |
551 | - continue; |
|
552 | - } |
|
553 | - $entry = trim(fgets($fd)); |
|
554 | - if (false === strpos($entry, '://')) |
|
555 | - continue; |
|
556 | - /* Ok, item matched and may be returned. */ |
|
557 | - $TotalMatches++; |
|
558 | - if (0 < $StartingIndex && |
|
559 | - $TotalMatches < $StartingIndex) |
|
560 | - continue; /* Skip first items. */ |
|
561 | - if (0 < $RequestedCount && |
|
562 | - $NumberReturned >= $RequestedCount) |
|
563 | - continue; /* Do not add more than requested. */ |
|
564 | - $NumberReturned++; |
|
565 | - /* Add item to result. */ |
|
566 | - $title = xml_encode(trim(substr($buffer, (strpos($buffer, ',') + 1)))); |
|
567 | - //$en_entry = upnp_url_encode($entry); |
|
568 | - $en_entry = xml_encode($entry); |
|
569 | - $iclass = upnp_get_class($entry, 'object.item.videoItem.videoBroadcast'); |
|
570 | - $mimetype = 'video/mpeg'; |
|
571 | - if ('object.container.storageFolder' === $iclass) { /* Play list as folder! */ |
|
572 | - $Result = $Result. |
|
573 | - "<container id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\">". |
|
574 | - "<dc:title>$title</dc:title>". |
|
575 | - '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
576 | - '</container>'; |
|
577 | - } else { |
|
578 | - //$logo = get_named_val("tvg-logo", $buffer); |
|
579 | - //if (null === $logo) { |
|
580 | - // $logo = trim(substr($buffer, (strpos($buffer, ',') + 1))); |
|
581 | - //} |
|
582 | - //$icon_url = upnp_url_encode($logo_url_path . mb_convert_case($logo, MB_CASE_LOWER, "UTF-8") . '.png'); |
|
583 | - $Result = $Result. |
|
584 | - "<item id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\">". |
|
585 | - "<dc:title>$title</dc:title>". |
|
586 | - "<dc:date>$date</dc:date>". |
|
587 | - //"<upnp:albumArtURI dlna:profileID=\"JPEG_TN\" xmlns:dlna=\"urn:schemas-dlna-org:metadata-1-0\">$icon_url</upnp:albumArtURI>" . |
|
588 | - //"<upnp:icon>$icon_url</upnp:icon>" . |
|
589 | - "<upnp:class>$iclass</upnp:class>". |
|
590 | - "<res protocolInfo=\"http-get:*:$mimetype:*\">$en_entry</res>". |
|
591 | - '</item>'; |
|
592 | - } |
|
593 | - } |
|
594 | - fclose($fd); |
|
595 | - |
|
596 | - $Result = $Result.'</DIDL-Lite>'; |
|
597 | - return (array('Result' => $Result, |
|
598 | - 'NumberReturned' => $NumberReturned, |
|
599 | - 'TotalMatches' => $TotalMatches, |
|
600 | - 'UpdateID' => $UpdateID)); |
|
601 | - } |
|
602 | - |
|
603 | - /* Scan directory and add to play list.*/ |
|
604 | - $entries = scandir($basedir.$dir); |
|
605 | - /* Add dirs to play list. */ |
|
606 | - foreach ($entries as $entry) { |
|
607 | - $filename = $basedir.$dir.$entry; |
|
608 | - if ('.' === substr($entry, 0, 1) || |
|
609 | - !is_dir($filename)) /* Skip files. */ |
|
610 | - continue; |
|
611 | - /* Ok, item matched and may be returned. */ |
|
612 | - $TotalMatches++; |
|
613 | - if (0 < $StartingIndex && |
|
614 | - $TotalMatches < $StartingIndex) |
|
615 | - continue; /* Skip first items. */ |
|
616 | - if (0 < $RequestedCount && |
|
617 | - $NumberReturned >= $RequestedCount) |
|
618 | - continue; /* Do not add more than requested. */ |
|
619 | - $NumberReturned++; |
|
620 | - /* Add item to result. */ |
|
621 | - if (is_writable($filename)) { |
|
622 | - $Restricted = '0'; |
|
623 | - } else { |
|
624 | - $Restricted = '1'; |
|
625 | - } |
|
626 | - $title = xml_encode($entry); |
|
627 | - $en_entry = upnp_url_encode($dir.$entry); |
|
628 | - $ChildCount = (count(scandir($filename)) - 2); |
|
629 | - $Result = $Result. |
|
630 | - "<container id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
631 | - "<dc:title>$title</dc:title>". |
|
632 | - '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
633 | - '</container>'; |
|
634 | - } |
|
635 | - /* Add files to play list. */ |
|
636 | - foreach ($entries as $entry) { |
|
637 | - $filename = $basedir.$dir.$entry; |
|
638 | - if (is_dir($filename)) /* Skip dirs. */ |
|
639 | - continue; |
|
640 | - $iclass = upnp_get_class($entry, null); |
|
641 | - if (null === $iclass) /* Skip unsupported file type. */ |
|
642 | - continue; |
|
643 | - /* Ok, item matched and may be returned. */ |
|
644 | - $TotalMatches++; |
|
645 | - if (0 < $StartingIndex && |
|
646 | - $TotalMatches < $StartingIndex) |
|
647 | - continue; /* Skip first items. */ |
|
648 | - if (0 < $RequestedCount && |
|
649 | - $NumberReturned >= $RequestedCount) |
|
650 | - continue; /* Do not add more than requested. */ |
|
651 | - $NumberReturned++; |
|
652 | - /* Add item to result. */ |
|
653 | - if (is_writable($filename)) { |
|
654 | - $Restricted = '0'; |
|
655 | - } else { |
|
656 | - $Restricted = '1'; |
|
657 | - } |
|
658 | - $title = xml_encode($entry); |
|
659 | - $en_entry = upnp_url_encode($dir.$entry); |
|
660 | - if ('object.container.storageFolder' === $iclass) { /* Play list as folder! */ |
|
661 | - $ChildCount = m3u_calc_items_count($filename); |
|
662 | - $Result = $Result. |
|
663 | - "<container id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
664 | - "<dc:title>$title</dc:title>". |
|
665 | - '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
666 | - '</container>'; |
|
667 | - } else { |
|
668 | - $date = upnp_date(filectime($filename), 1); |
|
669 | - $size = filesize($filename); |
|
670 | - $mimetype = upnp_mime_content_type($filename); |
|
671 | - $res_info_ex = ''; |
|
672 | - $Result = $Result. |
|
673 | - "<item id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\">". |
|
674 | - "<dc:title>$title</dc:title>". |
|
675 | - "<dc:date>$date</dc:date>". |
|
676 | - "<upnp:class>$iclass</upnp:class>"; |
|
677 | - if ('object.item.imageItem' === substr($iclass, 0, 21)) { |
|
678 | - $Result = $Result. |
|
679 | - "<upnp:albumArtURI>$baseurlpatch$en_entry</upnp:albumArtURI>". |
|
680 | - "<upnp:icon>$baseurlpatch$en_entry</upnp:icon>"; |
|
681 | - $img_info = getimagesize($filename); |
|
682 | - if (false !== $img_info) { |
|
683 | - $res_info_ex = ' resolution="'.$img_info[0].'x'.$img_info[1].'"'; |
|
684 | - } |
|
685 | - } |
|
686 | - $Result = $Result. |
|
687 | - "<res size=\"$size\"$res_info_ex protocolInfo=\"http-get:*:$mimetype:*\">$baseurlpatch$en_entry</res>". |
|
688 | - '</item>'; |
|
689 | - } |
|
690 | - } |
|
691 | - |
|
692 | - $Result = $Result.'</DIDL-Lite>'; |
|
693 | - return (array('Result' => $Result, |
|
694 | - 'NumberReturned' => $NumberReturned, |
|
695 | - 'TotalMatches' => $TotalMatches, |
|
696 | - 'UpdateID' => $UpdateID)); |
|
551 | + continue; |
|
552 | + } |
|
553 | + $entry = trim(fgets($fd)); |
|
554 | + if (false === strpos($entry, '://')) |
|
555 | + continue; |
|
556 | + /* Ok, item matched and may be returned. */ |
|
557 | + $TotalMatches++; |
|
558 | + if (0 < $StartingIndex && |
|
559 | + $TotalMatches < $StartingIndex) |
|
560 | + continue; /* Skip first items. */ |
|
561 | + if (0 < $RequestedCount && |
|
562 | + $NumberReturned >= $RequestedCount) |
|
563 | + continue; /* Do not add more than requested. */ |
|
564 | + $NumberReturned++; |
|
565 | + /* Add item to result. */ |
|
566 | + $title = xml_encode(trim(substr($buffer, (strpos($buffer, ',') + 1)))); |
|
567 | + //$en_entry = upnp_url_encode($entry); |
|
568 | + $en_entry = xml_encode($entry); |
|
569 | + $iclass = upnp_get_class($entry, 'object.item.videoItem.videoBroadcast'); |
|
570 | + $mimetype = 'video/mpeg'; |
|
571 | + if ('object.container.storageFolder' === $iclass) { /* Play list as folder! */ |
|
572 | + $Result = $Result. |
|
573 | + "<container id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\">". |
|
574 | + "<dc:title>$title</dc:title>". |
|
575 | + '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
576 | + '</container>'; |
|
577 | + } else { |
|
578 | + //$logo = get_named_val("tvg-logo", $buffer); |
|
579 | + //if (null === $logo) { |
|
580 | + // $logo = trim(substr($buffer, (strpos($buffer, ',') + 1))); |
|
581 | + //} |
|
582 | + //$icon_url = upnp_url_encode($logo_url_path . mb_convert_case($logo, MB_CASE_LOWER, "UTF-8") . '.png'); |
|
583 | + $Result = $Result. |
|
584 | + "<item id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\">". |
|
585 | + "<dc:title>$title</dc:title>". |
|
586 | + "<dc:date>$date</dc:date>". |
|
587 | + //"<upnp:albumArtURI dlna:profileID=\"JPEG_TN\" xmlns:dlna=\"urn:schemas-dlna-org:metadata-1-0\">$icon_url</upnp:albumArtURI>" . |
|
588 | + //"<upnp:icon>$icon_url</upnp:icon>" . |
|
589 | + "<upnp:class>$iclass</upnp:class>". |
|
590 | + "<res protocolInfo=\"http-get:*:$mimetype:*\">$en_entry</res>". |
|
591 | + '</item>'; |
|
592 | + } |
|
593 | + } |
|
594 | + fclose($fd); |
|
595 | + |
|
596 | + $Result = $Result.'</DIDL-Lite>'; |
|
597 | + return (array('Result' => $Result, |
|
598 | + 'NumberReturned' => $NumberReturned, |
|
599 | + 'TotalMatches' => $TotalMatches, |
|
600 | + 'UpdateID' => $UpdateID)); |
|
601 | + } |
|
602 | + |
|
603 | + /* Scan directory and add to play list.*/ |
|
604 | + $entries = scandir($basedir.$dir); |
|
605 | + /* Add dirs to play list. */ |
|
606 | + foreach ($entries as $entry) { |
|
607 | + $filename = $basedir.$dir.$entry; |
|
608 | + if ('.' === substr($entry, 0, 1) || |
|
609 | + !is_dir($filename)) /* Skip files. */ |
|
610 | + continue; |
|
611 | + /* Ok, item matched and may be returned. */ |
|
612 | + $TotalMatches++; |
|
613 | + if (0 < $StartingIndex && |
|
614 | + $TotalMatches < $StartingIndex) |
|
615 | + continue; /* Skip first items. */ |
|
616 | + if (0 < $RequestedCount && |
|
617 | + $NumberReturned >= $RequestedCount) |
|
618 | + continue; /* Do not add more than requested. */ |
|
619 | + $NumberReturned++; |
|
620 | + /* Add item to result. */ |
|
621 | + if (is_writable($filename)) { |
|
622 | + $Restricted = '0'; |
|
623 | + } else { |
|
624 | + $Restricted = '1'; |
|
625 | + } |
|
626 | + $title = xml_encode($entry); |
|
627 | + $en_entry = upnp_url_encode($dir.$entry); |
|
628 | + $ChildCount = (count(scandir($filename)) - 2); |
|
629 | + $Result = $Result. |
|
630 | + "<container id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
631 | + "<dc:title>$title</dc:title>". |
|
632 | + '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
633 | + '</container>'; |
|
634 | + } |
|
635 | + /* Add files to play list. */ |
|
636 | + foreach ($entries as $entry) { |
|
637 | + $filename = $basedir.$dir.$entry; |
|
638 | + if (is_dir($filename)) /* Skip dirs. */ |
|
639 | + continue; |
|
640 | + $iclass = upnp_get_class($entry, null); |
|
641 | + if (null === $iclass) /* Skip unsupported file type. */ |
|
642 | + continue; |
|
643 | + /* Ok, item matched and may be returned. */ |
|
644 | + $TotalMatches++; |
|
645 | + if (0 < $StartingIndex && |
|
646 | + $TotalMatches < $StartingIndex) |
|
647 | + continue; /* Skip first items. */ |
|
648 | + if (0 < $RequestedCount && |
|
649 | + $NumberReturned >= $RequestedCount) |
|
650 | + continue; /* Do not add more than requested. */ |
|
651 | + $NumberReturned++; |
|
652 | + /* Add item to result. */ |
|
653 | + if (is_writable($filename)) { |
|
654 | + $Restricted = '0'; |
|
655 | + } else { |
|
656 | + $Restricted = '1'; |
|
657 | + } |
|
658 | + $title = xml_encode($entry); |
|
659 | + $en_entry = upnp_url_encode($dir.$entry); |
|
660 | + if ('object.container.storageFolder' === $iclass) { /* Play list as folder! */ |
|
661 | + $ChildCount = m3u_calc_items_count($filename); |
|
662 | + $Result = $Result. |
|
663 | + "<container id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\" searchable=\"1\" childCount=\"$ChildCount\">". |
|
664 | + "<dc:title>$title</dc:title>". |
|
665 | + '<upnp:class>object.container.storageFolder</upnp:class>'. |
|
666 | + '</container>'; |
|
667 | + } else { |
|
668 | + $date = upnp_date(filectime($filename), 1); |
|
669 | + $size = filesize($filename); |
|
670 | + $mimetype = upnp_mime_content_type($filename); |
|
671 | + $res_info_ex = ''; |
|
672 | + $Result = $Result. |
|
673 | + "<item id=\"$en_entry\" parentID=\"$ObjectID\" restricted=\"$Restricted\">". |
|
674 | + "<dc:title>$title</dc:title>". |
|
675 | + "<dc:date>$date</dc:date>". |
|
676 | + "<upnp:class>$iclass</upnp:class>"; |
|
677 | + if ('object.item.imageItem' === substr($iclass, 0, 21)) { |
|
678 | + $Result = $Result. |
|
679 | + "<upnp:albumArtURI>$baseurlpatch$en_entry</upnp:albumArtURI>". |
|
680 | + "<upnp:icon>$baseurlpatch$en_entry</upnp:icon>"; |
|
681 | + $img_info = getimagesize($filename); |
|
682 | + if (false !== $img_info) { |
|
683 | + $res_info_ex = ' resolution="'.$img_info[0].'x'.$img_info[1].'"'; |
|
684 | + } |
|
685 | + } |
|
686 | + $Result = $Result. |
|
687 | + "<res size=\"$size\"$res_info_ex protocolInfo=\"http-get:*:$mimetype:*\">$baseurlpatch$en_entry</res>". |
|
688 | + '</item>'; |
|
689 | + } |
|
690 | + } |
|
691 | + |
|
692 | + $Result = $Result.'</DIDL-Lite>'; |
|
693 | + return (array('Result' => $Result, |
|
694 | + 'NumberReturned' => $NumberReturned, |
|
695 | + 'TotalMatches' => $TotalMatches, |
|
696 | + 'UpdateID' => $UpdateID)); |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | |
700 | 700 | function Search($ContainerID, $SearchCriteria, $Filter, $StartingIndex, |
701 | 701 | $RequestedCount, $SortCriteria) { |
702 | - global $basedir, $baseurl, $baseurlpatch; |
|
703 | - $Result = '<DIDL-Lite'. |
|
704 | - ' xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"'. |
|
705 | - ' xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"'. |
|
706 | - ' xmlns:dc="http://purl.org/dc/elements/1.1/"'. |
|
707 | - ' xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"'. |
|
708 | - ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
|
709 | - ' xsi:schemaLocation="'. |
|
710 | - 'urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/ http://www.upnp.org/schemas/av/didl-lite.xsd '. |
|
711 | - 'urn:schemas-upnp-org:metadata-1-0/upnp/ http://www.upnp.org/schemas/av/upnp.xsd">'; |
|
712 | - $NumberReturned = 0; |
|
713 | - $TotalMatches = 0; |
|
714 | - $UpdateID = 1; |
|
715 | - |
|
716 | - $Result = $Result.'</DIDL-Lite>'; |
|
717 | - |
|
718 | - return (array('Result' => $Result, |
|
719 | - 'NumberReturned' => $NumberReturned, |
|
720 | - 'TotalMatches' => $TotalMatches, |
|
721 | - 'UpdateID' => $UpdateID)); |
|
702 | + global $basedir, $baseurl, $baseurlpatch; |
|
703 | + $Result = '<DIDL-Lite'. |
|
704 | + ' xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"'. |
|
705 | + ' xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"'. |
|
706 | + ' xmlns:dc="http://purl.org/dc/elements/1.1/"'. |
|
707 | + ' xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"'. |
|
708 | + ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
|
709 | + ' xsi:schemaLocation="'. |
|
710 | + 'urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/ http://www.upnp.org/schemas/av/didl-lite.xsd '. |
|
711 | + 'urn:schemas-upnp-org:metadata-1-0/upnp/ http://www.upnp.org/schemas/av/upnp.xsd">'; |
|
712 | + $NumberReturned = 0; |
|
713 | + $TotalMatches = 0; |
|
714 | + $UpdateID = 1; |
|
715 | + |
|
716 | + $Result = $Result.'</DIDL-Lite>'; |
|
717 | + |
|
718 | + return (array('Result' => $Result, |
|
719 | + 'NumberReturned' => $NumberReturned, |
|
720 | + 'TotalMatches' => $TotalMatches, |
|
721 | + 'UpdateID' => $UpdateID)); |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | |
725 | 725 | function CreateObject($ContainerID, $Elements) { |
726 | - $ObjectID = ''; |
|
727 | - $Result = ''; |
|
726 | + $ObjectID = ''; |
|
727 | + $Result = ''; |
|
728 | 728 | |
729 | - return (array('ObjectID' => $ObjectID, |
|
730 | - 'Result' => $Result)); |
|
729 | + return (array('ObjectID' => $ObjectID, |
|
730 | + 'Result' => $Result)); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | |
@@ -745,27 +745,27 @@ discard block |
||
745 | 745 | |
746 | 746 | /* Samsung private. */ |
747 | 747 | function X_GetFeatureList() { |
748 | - $FeatureList = |
|
749 | - '<?xml version="1.0" encoding="UTF-8"?>'. |
|
750 | - '<Features'. |
|
751 | - ' xmlns="urn:schemas-upnp-org:av:avs"'. |
|
752 | - ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
|
753 | - ' xmlns:sec="http://www.sec.co.kr/dlna"'. |
|
754 | - ' xsi:schemaLocation="urn:schemas-upnp-org:av:avs http://www.upnp.org/schemas/av/avs.xsd">'. |
|
755 | - '<Feature name="samsung.com_BASICVIEW" version="1">'. |
|
756 | - '<container id="A" type="object.item.audioItem"/>'. |
|
757 | - '<container id="I" type="object.item.imageItem"/>'. |
|
758 | - '<container id="V" type="object.item.videoItem"/>'. |
|
759 | - '<container id="P" type="object.item.playlistItem"/>'. |
|
760 | - '<container id="T" type="object.item.textItem"/>'. |
|
761 | - '</Feature>'. |
|
762 | - '</Features>'; |
|
763 | - |
|
764 | - return ($FeatureList); |
|
748 | + $FeatureList = |
|
749 | + '<?xml version="1.0" encoding="UTF-8"?>'. |
|
750 | + '<Features'. |
|
751 | + ' xmlns="urn:schemas-upnp-org:av:avs"'. |
|
752 | + ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
|
753 | + ' xmlns:sec="http://www.sec.co.kr/dlna"'. |
|
754 | + ' xsi:schemaLocation="urn:schemas-upnp-org:av:avs http://www.upnp.org/schemas/av/avs.xsd">'. |
|
755 | + '<Feature name="samsung.com_BASICVIEW" version="1">'. |
|
756 | + '<container id="A" type="object.item.audioItem"/>'. |
|
757 | + '<container id="I" type="object.item.imageItem"/>'. |
|
758 | + '<container id="V" type="object.item.videoItem"/>'. |
|
759 | + '<container id="P" type="object.item.playlistItem"/>'. |
|
760 | + '<container id="T" type="object.item.textItem"/>'. |
|
761 | + '</Feature>'. |
|
762 | + '</Features>'; |
|
763 | + |
|
764 | + return ($FeatureList); |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | function X_SetBookmark($CategoryType, $RID, $ObjectID, $PosSecond) { |
768 | - /* Return: |
|
768 | + /* Return: |
|
769 | 769 | * <sec:dcmInfo>BM=number of seconds</sec:dcmInfo> |
770 | 770 | * <upnp:lastPlaybackPosition>HH:MM:SS</upnp:lastPlaybackPosition> |
771 | 771 | */ |
@@ -777,27 +777,27 @@ discard block |
||
777 | 777 | |
778 | 778 | $request_body = @file_get_contents('php://input'); |
779 | 779 | try { |
780 | - $server->addFunction(array('GetSearchCapabilities', |
|
781 | - 'GetSortCapabilities', |
|
782 | - 'GetSortExtensionCapabilities', |
|
783 | - 'GetFeatureList', |
|
784 | - 'GetSystemUpdateID', |
|
785 | - 'GetServiceResetToken', |
|
786 | - 'Browse', |
|
787 | - 'Search', |
|
788 | - 'CreateObject', |
|
789 | - 'DestroyObject', |
|
790 | - 'UpdateObject', |
|
791 | - 'MoveObject', |
|
792 | - 'X_GetFeatureList', |
|
793 | - 'X_SetBookmark' |
|
794 | - )); |
|
795 | - ob_start(); |
|
796 | - $server->handle($request_body); |
|
797 | - $soapXml = ob_get_clean(); |
|
780 | + $server->addFunction(array('GetSearchCapabilities', |
|
781 | + 'GetSortCapabilities', |
|
782 | + 'GetSortExtensionCapabilities', |
|
783 | + 'GetFeatureList', |
|
784 | + 'GetSystemUpdateID', |
|
785 | + 'GetServiceResetToken', |
|
786 | + 'Browse', |
|
787 | + 'Search', |
|
788 | + 'CreateObject', |
|
789 | + 'DestroyObject', |
|
790 | + 'UpdateObject', |
|
791 | + 'MoveObject', |
|
792 | + 'X_GetFeatureList', |
|
793 | + 'X_SetBookmark' |
|
794 | + )); |
|
795 | + ob_start(); |
|
796 | + $server->handle($request_body); |
|
797 | + $soapXml = ob_get_clean(); |
|
798 | 798 | } catch (Exception $e) { |
799 | - $server->fault($e->getCode(), $e->getMessage()); |
|
800 | - throw $e; |
|
799 | + $server->fault($e->getCode(), $e->getMessage()); |
|
800 | + throw $e; |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | |
@@ -805,44 +805,44 @@ discard block |
||
805 | 805 | |
806 | 806 | |
807 | 807 | function get_resp_tag_name($sxml) { |
808 | - $tag_st = strpos($sxml, '<SOAP-ENV:Body><SOAP-ENV:'); |
|
809 | - if (false === $tag_st) |
|
810 | - return (false); |
|
811 | - $tag_st += 25; |
|
812 | - $tag_end = strpos($sxml, '>', $tag_st); |
|
813 | - if (false === $tag_end) |
|
814 | - return (false); |
|
815 | - return (substr($sxml, $tag_st, ($tag_end - $tag_st))); |
|
808 | + $tag_st = strpos($sxml, '<SOAP-ENV:Body><SOAP-ENV:'); |
|
809 | + if (false === $tag_st) |
|
810 | + return (false); |
|
811 | + $tag_st += 25; |
|
812 | + $tag_end = strpos($sxml, '>', $tag_st); |
|
813 | + if (false === $tag_end) |
|
814 | + return (false); |
|
815 | + return (substr($sxml, $tag_st, ($tag_end - $tag_st))); |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | function get_tag_ns($req, $tag) { |
819 | - $rreq = strrev($req); |
|
820 | - $ns_st = strpos($rreq, strrev(":$tag>")); |
|
821 | - if (false === $ns_st) |
|
822 | - return (false); |
|
823 | - $ns_st += (strlen($tag) + 2); |
|
824 | - $ns_end = strpos($rreq, '/<', $ns_st); |
|
825 | - if (false === $ns_end) |
|
826 | - return (false); |
|
827 | - return (strrev(substr($rreq, $ns_st, ($ns_end - $ns_st)))); |
|
819 | + $rreq = strrev($req); |
|
820 | + $ns_st = strpos($rreq, strrev(":$tag>")); |
|
821 | + if (false === $ns_st) |
|
822 | + return (false); |
|
823 | + $ns_st += (strlen($tag) + 2); |
|
824 | + $ns_end = strpos($rreq, '/<', $ns_st); |
|
825 | + if (false === $ns_end) |
|
826 | + return (false); |
|
827 | + return (strrev(substr($rreq, $ns_st, ($ns_end - $ns_st)))); |
|
828 | 828 | } |
829 | 829 | |
830 | 830 | function tag_ns_replace($req, $sxml, $tag, $ns = false) { |
831 | - if (false === $tag) |
|
832 | - return ($sxml); |
|
833 | - if (false === $ns) |
|
834 | - $ns = get_tag_ns($req, $tag); |
|
835 | - if (false === $ns) |
|
836 | - return ($sxml); |
|
837 | - while ($tag_st = strpos($sxml, "<SOAP-ENV:$tag")) { |
|
838 | - $tag_end = strpos($sxml, '>', $tag_st); |
|
839 | - if (false === $tag_end) |
|
840 | - return ($sxml); |
|
841 | - $old_tag_data = substr($sxml, $tag_st, ($tag_end - $tag_st)); |
|
842 | - $new_tag_data = str_replace('SOAP-ENV', $ns, $old_tag_data); |
|
843 | - $sxml = str_replace($old_tag_data, $new_tag_data, $sxml); |
|
844 | - } |
|
845 | - return (str_replace("</SOAP-ENV:$tag>", "</$ns:$tag>", $sxml)); |
|
831 | + if (false === $tag) |
|
832 | + return ($sxml); |
|
833 | + if (false === $ns) |
|
834 | + $ns = get_tag_ns($req, $tag); |
|
835 | + if (false === $ns) |
|
836 | + return ($sxml); |
|
837 | + while ($tag_st = strpos($sxml, "<SOAP-ENV:$tag")) { |
|
838 | + $tag_end = strpos($sxml, '>', $tag_st); |
|
839 | + if (false === $tag_end) |
|
840 | + return ($sxml); |
|
841 | + $old_tag_data = substr($sxml, $tag_st, ($tag_end - $tag_st)); |
|
842 | + $new_tag_data = str_replace('SOAP-ENV', $ns, $old_tag_data); |
|
843 | + $sxml = str_replace($old_tag_data, $new_tag_data, $sxml); |
|
844 | + } |
|
845 | + return (str_replace("</SOAP-ENV:$tag>", "</$ns:$tag>", $sxml)); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 |