SHOW:
|
|
- or go back to the newest paste.
1 | <? | |
2 | ||
3 | $myip = $hostIP; //Doesn't seem to be really used | |
4 | $mymac = "00-0c-29-3e-b1-4f"; //Used for the access control/validation, but not after that AFAIK | |
5 | $appstring = "PHP..samsung"; //What the iPhone app reports | |
6 | $tvappstring = "PHP.UE40D8005.samsung"; //Might need changing to match your TV type | |
7 | $remotename = "PHP Remote"; //What gets reported when it asks for permission/also shows in General->Wireless Remote Control menu | |
8 | ||
9 | ||
10 | $sock = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp')); | |
11 | - | $result = socket_connect($sock, $tvip, '55000'); |
11 | + | $result = socket_connect($sock, $tvip, '55000'); |
12 | if( $result === false) | |
13 | die ("Could not create socket: <br />"); | |
14 | ||
15 | ||
16 | ||
17 | - | $ipencoded = base64_encode($myip); |
17 | + | $ipencoded = base64_encode($myip); |
18 | - | $macencoded = base64_encode($mymac); |
18 | + | $macencoded = base64_encode($mymac); |
19 | - | $messagepart1 = chr(0x64) . chr(0x00) . chr(strlen($ipencoded)) . chr(0x00) . $ipencoded . chr(strlen($macencoded)) . chr(0x00) . $macencoded . |
19 | + | $messagepart1 = chr(0x64) . chr(0x00) . chr(strlen($ipencoded)) . chr(0x00) . $ipencoded . chr(strlen($macencoded)) . chr(0x00) . $macencoded . chr(strlen(base64_encode($remotename))) . chr(0x00) . base64_encode($remotename); |
20 | - | chr(strlen(base64_encode($remotename))) . chr(0x00) . base64_encode($remotename); |
20 | + | |
21 | $part1 = chr(0x00) . chr(strlen($appstring)) . chr(0x00) . $appstring . chr(strlen($messagepart1)) . chr(0x00) . $messagepart1; | |
22 | ||
23 | socket_write($sock, $part1, strlen($part1)); | |
24 | echo $part1; | |
25 | echo "\n"; | |
26 | ||
27 | $messagepart2 = chr(0xc8) . chr(0x00); | |
28 | $part2 = chr(0x00) . chr(strlen($appstring)) . chr(0x00) . $appstring . chr(strlen($messagepart2)) . chr(0x00) . $messagepart2; | |
29 | socket_write($sock, $part2, strlen($part2)); | |
30 | echo $part2; | |
31 | echo "<br />"; | |
32 | ||
33 | ||
34 | $key = "KEY_INFO"; | |
35 | - | $key = "KEY_INFO"; |
35 | + | $messagepart3 = chr(0x00) . chr(0x00) . chr(0x00) . chr(strlen(base64_encode($key))) . chr(0x00) . base64_encode($key); |
36 | - | $messagepart3 = chr(0x00) . chr(0x00) . chr(0x00) . chr(strlen(base64_encode($key))) . chr(0x00) . base64_encode($key); |
36 | + | $part3 = chr(0x00) . chr(strlen($tvappstring)) . chr(0x00) . $tvappstring . chr(strlen($messagepart3)) . chr(0x00) . $messagepart3; |
37 | - | $part3 = chr(0x00) . chr(strlen($tvappstring)) . chr(0x00) . $tvappstring . chr(strlen($messagepart3)) . chr(0x00) . $messagepart3; |
37 | + | socket_write($sock,$part3,strlen($part3)); |
38 | - | socket_write($sock,$part3,strlen($part3)); |
38 | + | echo $part3; |
39 | - | echo $part3; |
39 | + | |
40 | - | echo "<br />"; |
40 | + | |
41 | socket_close($sock); | |
42 | ||
43 | echo "<br /><br />"; | |
44 | ?> |