- substr: documentation ( source)
- stripslashes: documentation ( source)
- chr: documentation ( source)
- fsockopen: documentation ( source)
- hexdec: documentation ( source)
- fclose: documentation ( source)
- fwrite: documentation ( source)
<?php
if (isset($_POST['id']))
$id=stripslashes($_POST['id']);
else
{
if (isset($_GET['id']))
$id=stripslashes($_GET['id']);
else
$id="";
}
if (isset($_POST['cmd']))
$cmd=stripslashes($_POST['cmd']);
else
{
if (isset($_GET['cmd']))
$cmd=stripslashes($_GET['cmd']);
else
$cmd=1;
}
function ahex2bin($s,$l)
{
for ($i = 0; $i < $l*2; $i += 2)
{
if($i < strlen($s))
$bin .= chr(hexdec(substr($s,$i,2)));
else
$bin .= chr(0);
}
return $bin;
}
$fp = fsockopen("udp://127.0.0.1", 80, $errno, $errstr);
if (!$fp)
{
$answer="ERROR: $errno - $errstr<br>";
}
else
{
$cmd = chr(0xfc).chr($cmd);
$cmd = $cmd.ahex2bin($id,6).chr(0).chr(0).chr(0).chr(0).$data;
if(fwrite($fp, $cmd)===FALSE)
$answer="ERROR: write<br>";
else
$answer="OK<br>";
fclose($fp);
}
echo $answer;
?>