![]() |
|
|
#1 |
|
Архивный участник
Join Date: Apr 2005
Posts: 196
|
since i still dont have a server running, i need you guys to test this script of mine
change as you wish, but plz leave the copyright ^_^ oh and of course report any bug to me (i guess there will be many as always) heres the scripts: password.php: [php:1:4a8c9bfe1a]<? require "./pcfg.php"; mssql_connect($dbhost,$dbuser,$dbpass) OR die('Cant establish database connection.'); mssql_select_db("lin2db"); if($_POST['change']) { //change PW if(!$_POST['accountname']) $error.=" You typed in an incorrect Account Name."; if(!$_POST['newpass'] || !$_POST['oldpass']) $error.=" You typed in an incorrect Password."; if($_POST['newpass'] != $_POST['newpass2']) $error.=" Your Password does not match your retype."; $query=mssql_query("SELECT account, password FROM user_auth WHERE account = '".$_POST['accountname']."' AND password = '".encrypt($_POST['oldpass'])."'"); if(!mssql_num_rows($query)) $error.=" Password doesn't match the account."; if(!$error) { //change PW mssql_query("UPDATE user_auth SET password = '".encrypt($_POST[newpass])."' WHERE account = '".$_POST['accountname']."' AND password = '".encrypt($_POST['oldpass'])."'"); echo"Password successfully changed."; } else echo $error." <a href=\"javascript:history.back();\">try again</a>"; } else { //view form echo"<form action=password.php method=post>"; echo"<input type=text name=accountname>Your Accountname "; echo"<input type=password name=oldpass>Your Current Password "; echo"<input type=password name=newpass>New Password "; echo"<input type=password name=newpass2>Retype New Password "; echo"<input type=submit name=change value=\"[change]\">"; echo"</form>"; } #[C] by Riane!!!11# ?>[/php:1:4a8c9bfe1a] pcfg.php [php:1:4a8c9bfe1a]<? $dbhost="localhost"; //server hostname / IP $dbuser="sa"; //MSSQL username $dbpassword=""; //MSSQL password $encrypted=1; //1 if passwords are encrypted, 0 if not //do not change after this line\\ function encrypt($str) { global $encrypted; if($encrypted==1) return encrypt2($str); } function encrypt2($str) { $key = array(); $dst = array(); $i = 0; $nBytes = strlen($str); while ($i < $nBytes){ $i++; $key[$i] = ord(substr($str, $i - 1, 1)); $dst[$i] = $key[$i]; } $rslt = $key[1] + $key[2]*256 + $key[3]*65536 + $key[4]*16777216; $one = $rslt * 213119 + 2529077; $one = $one - intval($one/ 4294967296) * 4294967296; $rslt = $key[5] + $key[6]*256 + $key[7]*65536 + $key[8]*16777216; $two = $rslt * 213247 + 2529089; $two = $two - intval($two/ 4294967296) * 4294967296; $rslt = $key[9] + $key[10]*256 + $key[11]*65536 + $key[12]*16777216; $three = $rslt * 213203 + 2529589; $three = $three - intval($three/ 4294967296) * 4294967296; $rslt = $key[13] + $key[14]*256 + $key[15]*65536 + $key[16]*16777216; $four = $rslt * 213821 + 2529997; $four = $four - intval($four/ 4294967296) * 4294967296; $key[4] = intval($one/16777216); $key[3] = intval(($one - $key[4] * 16777216) / 65535); $key[2] = intval(($one - $key[4] * 16777216 - $key[3] * 65536) / 256); $key[1] = intval(($one - $key[4] * 16777216 - $key[3] * 65536 - $key[2] * 256)); $key[8] = intval($two/16777216); $key[7] = intval(($two - $key[8] * 16777216) / 65535); $key[6] = intval(($two - $key[8] * 16777216 - $key[7] * 65536) / 256); $key[5] = intval(($two - $key[8] * 16777216 - $key[7] * 65536 - $key[6] * 256)); $key[12] = intval($three/16777216); $key[11] = intval(($three - $key[12] * 16777216) / 65535); $key[10] = intval(($three - $key[12] * 16777216 - $key[11] * 65536) / 256); $key[9] = intval(($three - $key[12] * 16777216 - $key[11] * 65536 - $key[10] * 256)); $key[16] = intval($four/16777216); $key[15] = intval(($four - $key[16] * 16777216) / 65535); $key[14] = intval(($four - $key[16] * 16777216 - $key[15] * 65536) / 256); $key[13] = intval(($four - $key[16] * 16777216 - $key[15] * 65536 - $key[14] * 256)); $dst[1] = $dst[1] ^ $key[1]; $i=1; while ($i<16){ $i++; $dst[$i] = $dst[$i] ^ $dst[$i-1] ^ $key[$i]; } $i=0; while ($i<16){ $i++; if ($dst[$i] == 0) { $dst[$i] = 102; } } $encrypt = "0x"; $i=0; while ($i<16){ $i++; if ($dst[$i] < 16) { $encrypt = $encrypt . "0" . dechex($dst[$i]); } else { $encrypt = $encrypt . dechex($dst[$i]); } } return $encrypt; } #[C] by Riane!!!11# ?>[/php:1:4a8c9bfe1a] |
|
|
|
|