Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела

Notices

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 01.02.2006, 10:41   #1
RumanticK
Архивный участник
 
Join Date: Feb 2006
Posts: 66
Default [SHARE] For beginners. Register new L2-account

Here is some functions, can be uset to register a new user on your L2-server
Code:
<? 
function s2b($s) {
for ($i=0; $i<strlen($s); $i++) $key[$i]=ord(substr($s,$i,1));
return $key;
}

function b2i($key, $i) {
return $key[$i] + $key[$i+1]*256 + $key[$i+2]*65536 + $key[$i+3]*16777216;
}

function msplit($w, &$a, &$b, &$c, &$d)
{
    $d = (int) ($w / hexdec(1000000));
    $c = (int) (($w - $d * hexdec(1000000)) / hexdec(10000));
    $b = (int) (($w - $d * hexdec(1000000) - $c * hexdec(10000)) / hexdec(100));
    $a = (int) ($w - $d * hexdec(1000000) - $c * hexdec(10000) - $b * hexdec(100));
}


function l2encode($pass)
{
$key=s2b($pass);
$dstbytes=s2b($pass);
	$one= b2i($key, 0) * 213119 + 2529077;
	$two = b2i($key, 4) * 213247 + 2529089;
	$three = b2i($key, 8) * 213203 + 2529589;
	$four = b2i($key, 12) * 213821 + 2529997;
	$one = $one - ((int) ($one / 4294967296))*4294967296;
	$two = $two - ((int) ($two / 4294967296))*4294967296;
	$three = $three - ((int) ($three / 4294967296))*4294967296;
	$four = $four - ((int) ($four / 4294967296))*4294967296;
msplit($one, $key[0], $key[1], $key[2], $key[3]);
msplit($two, $key[4], $key[5], $key[6], $key[7]);
msplit($three, $key[8], $key[9], $key[10], $key[11]);
msplit($four, $key[12], $key[13], $key[14], $key[15]);
	$dstbytes[0] = $dstbytes[0] ^ $key[0];

	for ($i=1; $i<=15; $i++) $dstbytes[$i] = $dstbytes[$i] ^ $dstbytes[$i-1] ^ $key[$i & 15];
	for ($i=0; $i<=15; $i++) if ($dstbytes[$i] == 0) $dstbytes[$i] = 0x66;

	$encrypt = "0x";
	for ($i=0; $i<=15; $i++)	if ($dstbytes[$i] < 0x10) {
			$encrypt .= "0" . dechex($dstbytes[$i]);
		} else {
			$encrypt .= dechex($dstbytes[$i]);
		}

	return $encrypt;
}

function createssn() {
$s=rand(1,9);
for ($i=1; $i<=12; $i++) $s.=rand(0,9);
return $s;
}
function regaccount($account,$password,$email,$qst1,$qst2,$asw1,$asw2) {
	$account=addslashes($account);
	$password=addslashes($password);
	$email=addslashes($email);
	$qst1=addslashes($qst1);
	$qst2=addslashes($qst2);
	$asw1=addslashes($asw1);
	$asw2=addslashes($asw2);
	$ssn = createssn();
		mscdb();
	$lin2db = "lin2db";
	$lin2world = "lin2world";
	@mssql_select_db($lin2db);

	$query = "select * from user_auth WHERE account='$account'";
	$result = mssql_query($query) or return 1;
	if ($row=mssql_fetch_row($result)) 
			{
			return 1;
			} 	else {
		$query = "INSERT INTO [ssn](ssn,name,email,job,phone,zip,addr_main,addr_etc,account_num) VALUES('".$ssn."','".$account."','".$email."',0,'telphone','123456','','',1)";
		$result = @mssql_query($query) or return 1;

		$query = "INSERT INTO [user_account](account,pay_stat) VALUES('".$account."',1)";
		$result = @mssql_query($query) or return 1;

		$query = "INSERT INTO [user_info](account,ssn,kind) VALUES('".$account."','".$ssn."',99)";
		$result = @mssql_query($query) or return 1;

		$query = "INSERT INTO [user_auth](account,password,quiz1,quiz2,answer1,answer2) VALUES('".$account."',".l2encode($password).",'".$qst1."','".$qst2."',".l2encode($asw1).",".l2encode($asw2).")";
		$result = @mssql_query($query) or return 1;
	}
return 0;
}

 ?>
RumanticK is offline  
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 18:23.