<?php
$host = "127.0.0.1";
$dbuuu = "sa"; // DB Login
$dbppp = "PASS"; // DB Pass
$datab = "MuOnline"; // DB Name
//
if (isset($_POST['dc_start'])){
$user=$_POST['acc'];
$pw=$_POST['pw'];
if (empty($user)){die("Please Enter Account");
}
if (empty($pw)){die("Please Enter Password");
}
$conn = mssql_connect($host,$dbuuu,$dbppp)
or die ("<h1>Cannot connect to database</h1>");
$selected=mssql_select_db($datab, $conn);
$sql_pw_check = mssql_query("SELECT memb__pwd FROM MEMB_INFO WHERE memb__pwd='$pw' and memb___id='$user' ");
$pw_check = mssql_num_rows($sql_pw_check);
mssql_close($conn);
if ($pw_check <= 0){ Die("incorrect password");
}
///////////////////////////////////////////////////////////////////////////
// Script to Disconnect a User from the Joinserver and //
///////////////////////////////////////////////////////////////////////////
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"; // Header packet. I used a packet sniffer to get this packet.It could be different for every gameserver.
$mystring .= ascii2hex($user); // Insert into the packet the username after you convert it to hex first.
$zeros = strlen($mystring);
for ($i;$i<=39-$zeros;$i++){
$mystring .="0"; // The packets must be 40 bits long so we fill the rest of the packet with zeros.
}
$packet = hex2ascii($mystring); // Convert the whole string to ascii
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (!$x = @socket_connect($socket, $host, $port)) // attempt to connect
{
echo "Can't connect to server.Maybe server is offline";
}
else
{
socket_write($socket, $packet, strlen($packet)); // Send the dc packet
socket_close($socket); // Close connection
print"<h1>Disconnect request sent</h1>";
}
/////////////////////////////////////////////////////////
// This will also delete the entry from the database //
/////////////////////////////////////////////////////////
$conn = mssql_connect($host,$dbuuu,$dbppp)
or die ("<h1>Cannot connect to database</h1>");
$selected=mssql_select_db($datab, $conn);
$sql = mssql_query("UPDATE MEMB_STAT Set ConnectStat = 0 where memb___id ='$user'");
mssql_close($conn);
/////////////////////////////////////////////////////////
}
dc_user("127.0.0.1", "55970", $user); // Run the function: Connect to port 55970 (Joinserver port) and dc the user. Where $user=username
}
else{ echo "
<table width="125" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>To Disconnect Your account from game please enter here your Account And Password
<td width="125" height="24"><form action="" method="post" name="form1" id="form1">
<label>
<INPUT maxLength=10 name=acc value="login">
</label>
</td>
</tr>
<tr>
<td><INPUT class=txt-simple type=password maxLength=10 name=pw value="pass"></td>
</tr>
<tr>
<td align="right">
<label>
<INPUT
type=hidden value=1 name=dc_start>
<input name="Submit" type="submit" id="Submit" value="Login" />
</label>
</form></td>
</tr>
</table>
";
}
?>