-
Notifications
You must be signed in to change notification settings - Fork 0
/
extra.php
41 lines (36 loc) · 1.37 KB
/
extra.php
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
<?php
// For SGIP:
// http://djazz.mine.nu/apps/sgip/
header("content-type: text/plain");
header("Access-Control-Allow-Origin: *");
set_time_limit(3);
$ip = $_GET['ip'];
$port = isset($_GET['port'])? intval($_GET['port']) : 10052;
$password = isset($_GET['pswd'])? $_GET['pswd'] : '';
function echoPacket($title, $pack) {
$len = strlen($pack);
echo "<!-- Echo of packet $title - START -->\n<table border=\"1\">\n";
echo "<tr>\n<td> </td>"; //Offsets
for ($i = 0; $i < $len; $i++) echo "<td>".$i."</td>";
echo "\n</tr>\n";
echo "<tr>\n<td>$title (txt):</td>\n"; //echo in text form
for ($i = 0; $i < $len; $i++) echo "<td>".$pack[$i]."</td>";
echo "\n</tr>\n";
echo "<tr>\n<td>$title (hex):</td>\n"; //Echo in hex form
for ($i = 0; $i < $len; $i++) echo "<td>".strtoupper(str_pad(dechex(ord($pack[$i])), 2, "0", STR_PAD_LEFT))."</td>";
echo "\n</tr>\n";
echo "<tr>\n<td>$title (dec):</td>\n"; //Echo in decimal form
for ($i = 0; $i < $len; $i++) echo "<td>".str_pad(ord($pack[$i]),2,"0",STR_PAD_LEFT)."</td>";
echo "\n</tr>\n";
echo "</table>\n<!-- Echo of packet $title - END -->\n";
}
$result = array();
$result['error'] = 0;
$tcp = @fsockopen("localhost", 8007, $errno, $errstr, 10);
if(!$tcp) {
$result['error'] = 5;
echo json_encode($result);
exit;
}
fwrite($tcp, json_encode(array("ip" => $ip, "port" => $port, "password" => $password)));
echo fread($tcp, 1024*1000);