Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
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  
Old 02.02.2006, 07:48   #2
RumanticK
Архивный участник
 
Join Date: Feb 2006
Posts: 66
Default Top-clans

Get clan-rating
Code:
mscdb();
$lin2db = "lin2db";
$lin2world = "lin2world";
mssql_select_db($lin2world);
$nns="GMs,DEVs,Admins";
$dns=explode(",",$nns);

$query="SELECT pledge.pledge_id as clanid, user_data.char_name as ruler, user_data.Lev as rulerlvl, pledge.name as clanname, pledge.skill_level as clanlvl FROM pledge INNER JOIN user_data ON pledge.ruler_id=user_data.char_id ORDER BY clanlvl DESC";
$result = mssql_query($query) or die;
$rc=0;
$mb.="<table border=1 cellspacing=0 cellpadding=3 align=center>\n";
$mb.="<tr><th>#</th><th>Clan name</th><th>Clan
level</th><th>Clan leader
(level)</th><th>Num
members</th><th>AVG level
</th></tr>";

while (($row = mssql_fetch_array($result)) && ($rc<100)) {
 $puttotop=1;
 if (in_array($row['clanname'],$dns)) $puttotop=0;
 if ($puttotop==1) {
 $query="SELECT char_id, Lev FROM user_data WHERE pledge_id=".$row['clanid'];
 $plres = mssql_query($query) or exit;
 $plcount=0;
 $pllev=0;
 while ($plrow = mssql_fetch_array($plres)) {
 $plcount++;
 $pllev+=$plrow[Lev];
 }
 $pllev=$pllev/$plcount;
 $pledge['ruler'][$row['clanid']]=$row['ruler'];
 $pledge['rulerlvl'][$row['clanid']]=$row['rulerlvl'];
 $pledge['clanname'][$row['clanid']]=$row['clanname'];
 $pledge['avglvl'][$row['clanid']]=$pllev;
 $pledge['count'][$row['clanid']]=$plcount;
 $pledge['clanlvl'][$row['clanid']]=$row['clanlvl'];
 $pledge['rating'][$row['clanid']]=$pledge['clanlvl'][$row['clanid']]*1000000+((int) ($pledge['avglvl'][$row['clanid']]*10000))+$pledge['count'][$row['clanid']];
 }
}
 arsort($pledge['rating']);
 reset($pledge['rating']);
 while (list($plid, $ratingclan)=each($pledge['rating'])) {
 $rc++;
 $mb.="<tr><td align=center>".$rc."</td><td align=center>".($pledge['clanname'][$plid])."</td><td align=center>".($pledge['clanlvl'][$plid])."</td><td align=center>".($pledge['ruler'][$plid])."(".($pledge['rulerlvl'][$plid]).")</td>";
 $mb.="<td align=center>".($pledge['count'][$plid])."</td><td align=center>".(((int) ($pledge['avglvl'][$plid]*100))/100)."</td></tr>";
}
$mb.="</table>";
echo $mb;
RumanticK is offline  
Old 26.04.2006, 01:18   #3
darkstaown
Архивный участник
 
Join Date: Apr 2006
Posts: 23
Default

nice share =)

:P
darkstaown is offline  
Old 26.04.2006, 09:11   #4
Zeran
Архивный участник
 
Join Date: Mar 2006
Posts: 97
Default

very nice
10x for shr
Zeran is offline  
Old 27.04.2006, 02:43   #5
angelicmercer
Архивный участник
 
Join Date: Apr 2006
Posts: 42
Default

Nice share =)
angelicmercer is offline  
Old 28.04.2006, 12:30   #6
Zeran
Архивный участник
 
Join Date: Mar 2006
Posts: 97
Default

So how about GM acc?How to do GM acc from normal acc...???
Zeran is offline  
Old 28.04.2006, 12:30   #7
Zeran
Архивный участник
 
Join Date: Mar 2006
Posts: 97
Default

So how about GM acc?How to do GM acc from normal acc...???
Zeran is offline  
 


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 17:00.