-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdlna4.php
More file actions
88 lines (72 loc) · 2.58 KB
/
Copy pathdlna4.php
File metadata and controls
88 lines (72 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
session_start();
$fp=fsockopen($_SESSION['hostname'], $_SESSION['port']);
if (array_key_exists('DLNA_Server', $_POST)){
// Sende Nachricht
$nachricht = '!1' . "NLSL" . $_POST["DLNA_Server"];
$kommando = "ISCP\x00\x00\x00\x10\x00\x00\x00" . chr(strlen($nachricht) + 1) . "\x01\x00\x00\x00" . $nachricht . "\x0D";
fwrite($fp, $kommando);
}
if (array_key_exists('xml_Eintrag', $_POST)){
$nachricht = '!1' . "NLSI" . sprintf("%'.05d\n", $_POST["xml_Eintrag"]+1);
$kommando = "ISCP\x00\x00\x00\x10\x00\x00\x00" . chr(strlen($nachricht) + 1) . "\x01\x00\x00\x00" . $nachricht . "\x0D";
fwrite($fp, $kommando);
echo 'XML-Eintrag '.$nachricht .' gewählt.<br>';
}
if (array_key_exists('zurueck', $_POST)){
$nachricht = '!1' . "NTCRETURN";
$kommando = "ISCP\x00\x00\x00\x10\x00\x00\x00" . chr(strlen($nachricht) + 1) . "\x01\x00\x00\x00" . $nachricht . "\x0D";
fwrite($fp, $kommando);
echo 'Zurück gewählt<br>';
}
if (!array_key_exists('Ebene', $_POST)){
$Ebene = 1;
}else{
$Ebene = $_POST["Ebene"];
}
echo "Aktuelle Ebene: " .$Ebene. "!<br>";
sleep(1);
// Sende Nachricht
$nachricht = '!1' . "NLAL00010" . $Ebene . "000000FF";
$kommando = "ISCP\x00\x00\x00\x10\x00\x00\x00" . chr(strlen($nachricht) + 1) . "\x01\x00\x00\x00" . $nachricht . "\x0D";
fwrite($fp, $kommando);
$raw = '';
$input = '';
$response = '';
$xmlstr = '';
$position = '';
// Lese Antwort
$oldtime = time();
stream_set_timeout($fp,10);
while (($xmlstr == '') and (time()-$oldtime)<5) {
$raw = '';
$input = '';
$oldtime2 = time();
while ((ord($input) != 0x1A) and ((time()-$oldtime2)<5)) {
$input = fread($fp, 1);
$raw .= $input;
}
$beginn = strpos($raw, "!1");
$response = substr($raw, $beginn+2, -1);
echo $response."<br>";
if (strpos($response, "NLAX") === 0) {
$xmlstr = substr($response, strpos($response, "<"));
}
}
if ($xmlstr != '') {
$xml_response = new SimpleXMLElement($xmlstr);
echo $xml_response->items['totalitems']. 'xml-Einträge empfangen.<br>';
echo '<form method="post">';
echo '<p>Eintrag auswählen:</p><select name="xml_Eintrag" size="1">';
for ($i=0; $i<$xml_response->items['totalitems']; $i++) {
echo '<option value ="' . $i . '">'. $xml_response->items->item[$i]['title'] . '</option>\n';
}
echo '</select>';
echo '<input type="hidden" name="Ebene" value="'.strval($Ebene+1).'">';
echo '<button type="submit" name="action">Wähle</button></form>';
}
if ($Ebene > 1){
echo '<form method="post"><input type="submit" name="zurueck" class="button" value="Eine Ebene höher" /><input type="hidden" name="Ebene" value="'.strval($Ebene-1).'"></form>';
}
fclose($fp);
?>