|
|
|
ระบบสร้าง password แบบสุ่มที่ function random_password($len) มันไม่สร้าง password ให้ครับ |
|
|
|
|
|
|
|
ต้องวางฟังชั่นนี้ไว้ตรงไหนครับมันถึงจะสร้าง password ให้ครับ
Code (PHP)
<?php
function random_password( $len )
{
srand( ( double ) * 10000000 );
$chars = "abcdefghijklmnopqrstuvwxyz0123456789";
$ret_str = "";
$num = strlen( $chars );
$i = 0;
for ( ; $i < $len; ++$i )
{
$ret_str .= $chars[rand( ) % $num];
$ret_str .= "";
}
return $ret_str;
}
ob_start( );
if ( !isset( $_SESSION['logined'] ) )
{
header( "location:index.php" );
exit( );
}
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n\r\n</head>\r\n\r\n<body>\r\n\r\n";
$sss = $exp;
$aa = substr( $sss, 0, 2 );
$dd = substr( $sss, 3, 2 );
$bb = substr( $sss, 6, 4 );
switch ( $dd )
{
case "01" :
$printmonth = "Jan";
break;
case "02" :
$printmonth = "Feb";
break;
case "03" :
$printmonth = "Mar";
break;
case "04" :
$printmonth = "Apr";
break;
case "05" :
$printmonth = "May";
break;
case "06" :
$printmonth = "Jun";
break;
case "07" :
$printmonth = "Jul";
break;
case "08" :
$printmonth = "Aug";
break;
case "09" :
$printmonth = "Sep";
break;
case "10" :
$printmonth = "Oct";
break;
case "11" :
$printmonth = "Nov";
break;
case "12" :
$printmonth = "Dec";
}
$rrs = "{$aa} {$printmonth} {$bb} 00:00:00";
$resul = mysql_query( "DELETE FROM prints" );
$names = "";
$sur = "";
$i = 1;
echo "\r\n<table border=1 color=000000 width=400>\r\n<tr><td><b>ชื่อล็อกอิน</td><td><b>รหัสผ่าน</td><td><b>จำนวนวัน</td><td><b>ราคา</td></tr>";
while ( $i <= $num )
{
$users = random_password( $uu );
$pass = random_password( $pp );
if ( !( $result = mysql_query( "select * from ac_day_auto where user='{$users}'" ) ) )
{
exit( "Err Can not to result" );
}
$row = mysql_num_rows( $result );
if ( !( $results = mysql_query( "select * from radcheck where UserName='{$users}'" ) ) )
{
exit( "Err Can not to result" );
}
$rows = mysql_num_rows( $results );
if ( $row == "0" && $rows == "0" )
{
$sql = mysql_query( "INSERT INTO `ac_day_auto` ( `no` , `name` , `sur` , `user`, `pass` , `day` , `exp` , `sim` , `die`, `download`, `upload`, `price`) VALUES ('', '{$names}', '{$sur}','{$users}','{$pass}','{$day}','{$rrs}','{$sim}','{$die}','{$download}','{$upload}','{$price}')" );
$sql1 = mysql_query( "INSERT INTO `radcheck` ( `id` , `UserName` , `Attribute` , `op`, `Value`) VALUES ('', '{$users}', 'User-Password',':=','{$pass}')" );
$sql3 = mysql_query( "INSERT INTO `radcheck` ( `id` , `UserName` , `Attribute` , `op`, `Value`) VALUES ('', '{$users}', 'Simultaneous-Use',':=','{$sim}')" );
$sql4 = mysql_query( "INSERT INTO `radcheck` ( `id` , `UserName` , `Attribute` , `op`, `Value`) VALUES ('', '{$users}', 'Expiration',':=','{$rrs}')" );
$down = $download * 1000;
$sql5 = mysql_query( "INSERT INTO `radreply` ( `id` , `UserName` , `Attribute` , `op`, `Value`) VALUES ('', '{$users}', 'WISPr-Bandwidth-Max-Down',':=','{$down}')" );
$up = $upload * 1000;
$sql6 = mysql_query( "INSERT INTO `radreply` ( `id` , `UserName` , `Attribute` , `op`, `Value`) VALUES ('', '{$users}', 'WISPr-Bandwidth-Max-Up',':=','{$up}')" );
$diet = $die * 60;
$sql6 = mysql_query( "INSERT INTO `radreply` ( `id` , `UserName` , `Attribute` , `op`, `Value`) VALUES ('', '{$users}', 'Idle-Timeout',':=','{$diet}')" );
$sql7 = mysql_query( "INSERT INTO `radreply` ( `id` , `UserName` , `Attribute` , `op`, `Value`) VALUES ('', '{$users}', 'WISPr-Session-Terminate-Time',':=','c')" );
++$i;
echo "<tr><td>{$users}</td><td>{$pass}</td><td>{$day} วัน</td><td>{$price} บาท</td></tr>";
$sql8 = mysql_query( "INSERT INTO `prints` ( `no` , `doc`, `user`, `pass`, `times`, `prices`) VALUES ('', '<td width=25%><center>{$users}</td><td width=25%><center>{$pass}</td><td width=20%><center>{$price} บาท</td><td width=20%> <center>{$day} วัน</td>', '{$users}', '{$pass}', '{$day} วัน', '{$price} บาท')" );
$sql9 = mysql_query( "INSERT INTO `account` ( `username` , `password`, `encryption`, `status`, `type`, `use`) VALUES ('{$users}', '{$pass}', 'clear', '1', 'daya', '0')" );
}
}
echo "</table><a href=index2.php>กลับ</a> <a href=print.php target=_blank>พิมพ์รหัส</a> <a href=card.php target=_blank>พิมพ์บัตร</a>";
echo "</body>\r\n</html>\r\n";
?>
Tag : PHP
|
|
|
|
|
|
Date :
2011-10-23 08:56:20 |
By :
bigboy |
View :
1234 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
function random_password($len)
{
srand((double)microtime()*10000000);
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
$ret_str = "";
$num = strlen($chars);
for($i = 0; $i < $len; $i++)
{
$ret_str.= $chars[rand()%$num];
$ret_str.="";
}
return $ret_str;
}
// echo random_password(8);
$passw = random_password(7);
แค่นี้ก็ได้แล้วครับ
|
|
|
|
|
Date :
2011-10-23 19:01:07 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|