$dc = mssql_query("exec WZ_DISCONNECT_MEMB $user_auth_id");
function ascii2hex($ascii)
{
$hex = '';
for ($i = 0; $i < strlen($ascii); $i++)
{
$byte = strtoupper(dechex(ord($ascii{$i})));
$byte = str_repeat('0', 2 - strlen($byte)).$byte;
$hex .= $byte." ";
}
$hex = str_replace(" ", "", $hex);
return $hex;
}
function hex2ascii($hex)
{
$ascii = '';
$hex = str_replace(" ", "", $hex);
for ($i = 0; $i < strlen($hex); $i = $i + 2) {
$ascii .= chr(hexdec(substr($hex, $i, 2)));
}
return ($ascii);
}
function dc_user($host, $port, $user)
{
$mystring = "C11405";
$mystring .= ascii2hex($user);
$zeros = strlen($mystring);
for ($i; $i <= 39 - $zeros; $i++){
$mystring .= "0";
}
$packet = hex2ascii($mystring);
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (!$x = @socket_connect($socket, $host, $port))
{
echo msg('0','Vyskytla sa neočakávaná chyba, akciu opakuj neskôr prosím.');
}
else
{
socket_write($socket, $packet, strlen($packet));
socket_close($socket);
}
}
dc_user("SRVIP", "56972", $user_auth_id);