كود PHP:
//************************************** // // Name: ^ A Registration Password Trick // // Description:Ever wonder how when you // registered online somewhere, on the next // page where your username and password ar // e confirmed, only the first few chars of // the p-word are shown and the rest of it // are asterisks to keep from prying eyes. // <b>Please Rate</b> // By: Darryl Porter // // Inputs:This script processes the user // name/password registered by the end user // . // // Assumes:uses two functions--strlen() // and substr()--and a "while loop." the st // rlen() function returns the length of an // ything that can be stored in a variable. // The second, substr(), takes a part of an // ything that is stored in a variable. Exa // mple: $foo = Hello World; $foofoo = substr($foo, 0, 7); $foofoo == Hello Wor // //This code is copyrighted and has // limited warranties.Please see http:// // www.Planet-Source-Code.com/vb/scripts/Sh // owCode.asp?txtCodeId=738&lngWId=8 //for details. //************************************** // $length = strlen($password); //Gets the length of the Password $sub_password = substr($password, 0, 4); //(Comment for the code above)This takes // the original passwords and cuts it lengt // h. //First, I plug-in the original variable // . Then, the number at the beginning of t // he string. //The second number controls how much of // the password will be revealed. //Remember that PHP starts counting at 0 // . $length2 = strlen($sub_password); //This gets the length of the password a // fter is has been cut echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">"; echo "<html><head><title>$title</title></head>"; echo "<br><br>"; echo "<div align=\"center\">Welcome $username your password is $sub_password"; while($length2 < $length) { print("*"); $length2++; } echo ", all but the first four are hidden for your security.</div>"; //(Comment for the code above)This is a // simple While Loop--While the length of t // he original //password is greater than the length of // the cut password //there will be "*" printed out. This is // to reveal the //first few characters of the password a // fter registration, and the last few //are replaced for security.