The source of password.php (click to demo the file) viewed times.

If I wrote this code, then it is licensed under the GPL. If someone else wrote it, then please ask them if you want to use the code.



Deprecated: Function eregi_replace() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 61

Deprecated: Function eregi_replace() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 67

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71

Deprecated: Function eregi() is deprecated in /home/multifor/public_html/sebflipper.com/code/index.php on line 71
<?php
/////////////////////////////////////////////////////////////////
// Random Password Generator  v1.0 - sebflipper Copyright 2004 //
//                http://www.sebflipper.com                    //
//                                                             //
//     This script is used to create a number of random        //
//            passwords based on the users input               //
/////////////////////////////////////////////////////////////////

/* string generatePassword(int)
 * - generates a random string based on the length passed as an argument
 * - maximum length: 32
 *
 * Usage:  To generate an 8 character random password, use this code:
 *
 *   var $password;
 *   $password = generatePassword(8);
 *   echo $password;
 */

    
function generatePassword($plength,$include_letters,$include_capitals,$include_numbers,$include_punctuation)
    {

        
// First we need to validate the argument that was given to this function
        // If need be, we will change it to a more appropriate value.
        
if(!is_numeric($plength) || $plength <= 0)
        {
            
$plength 8;
        }
        if(
$plength 32)
        {
            
$plength 32;
        }

        
// This is the array of allowable characters.
                
$chars "";

                if (
$include_letters == true) { $chars .= 'abcdefghijklmnopqrstuvwxyz'; }
                if (
$include_capitals == true) { $chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; }
                if (
$include_numbers == true) { $chars .= '0123456789'; }
                if (
$include_punctuation == true) { $chars .= '`¬£$%^&*()-_=+[{]};:@#~,<.>/?'; }

                
// If nothing selected just display 0's
                
if ($include_letters == false AND $include_capitals == false AND $include_numbers == false AND $include_punctuation == false) {
                    
$chars .= '0';
                }

        
// This is important:  we need to seed the random number generator
        
mt_srand(microtime() * 1000000);

        
// Now we simply generate a random string based on the length that was
        // requested in the function argument
        
for($i 0$i $plength$i++)
        {
            
$key mt_rand(0,strlen($chars)-1);
            
$pwd $pwd $chars{$key};
        }

        
// Finally to make it a bit more random, we switch some characters around
        
for($i 0$i $plength$i++)
        {
            
$key1 mt_rand(0,strlen($pwd)-1);
            
$key2 mt_rand(0,strlen($pwd)-1);

            
$tmp $pwd{$key1};
            
$pwd{$key1} = $pwd{$key2};
            
$pwd{$key2} = $tmp;
        }

        
// Convert into HTML
        
$pwd htmlentities($pwdENT_QUOTES);

        return 
$pwd;
    }
?>
<html>
<head>
<title>Random Password Generator</title>
<style type="text/css">
<!--
body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: small;
}
-->
</style>
</head>
<body>
<?php
if ($_POST["Submit"] == true) {
    echo 
"Your password(s):<hr><b>";
    for (
$i 1; ; $i++) {
       if (
$i $_POST["quantity"]) {
           break;
       }
           echo 
generatePassword($_POST["length"],$_POST["letters"],$_POST["capitals"],$_POST["numbers"],$_POST["punctuation"]) . " <hr> ";
    }
    echo 
"</b>";
}
else
{
?>
    <form name="password_form" method="post">
    <table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>Password Length:</td>
        <td><select name="length" size="1">
          <?php
            
for ($i 1; ; $i++) {
               if (
$i 32) {
                   break;
               }
               if (
$i == 8) {
                echo 
"<option value=$i selected>$i</option>\n";
               }
               else
               {
                echo 
"<option value=$i>$i</option>\n";
               }
            }
          
?>
        </select></td>
        </tr>
      <tr>
        <td>Include Letters:</td>
        <td>
          <input type="checkbox" name="letters" value="true" checked>
          (e.g. abcdef)    </td>
        </tr>
      <tr>
        <td>Include Capitals Letters:</td>
        <td>
          <input type="checkbox" name="capitals" value="true">
          (e.g. AbcDEf)    </td>
        </tr>
      <tr>
        <td>Include Numbers:</td>
        <td><input type="checkbox" name="numbers" value="true">
          (e.g. a9b8c7d)</td>
        </tr>
      <tr>
        <td>Include Punctuation:</td>
        <td><input type="checkbox" name="punctuation" value="true">
          (e.g. a!b*c_d)</td>
        </tr>
      <tr>
        <td>Quantity:</td>
        <td><select name="quantity" size="1">
          <?php
            
for ($i 1; ; $i++) {
               if (
$i 50) {
                   break;
               }
               echo 
"<option value=$i>$i</option>\n";
            }
          
?>
        </select></td>
        </tr>
    </table>
    <p>
      <input type="submit" name="Submit" value="Generate Passwords(s)">
      <input type="reset" name="Reset" value="Reset">
    </p>
    </form>
<?php
}
?>
</body>
</html>

If you want to have a look at the source code, chose a file from this list:

phpself.php
(Demo Script)
ip.txt
(Demo Script)
ip_monitor.php
(Demo Script)
perl_smtp_email.php
(Demo Script)
floor_time.php
(Demo Script)
title_case.php
(Demo Script)
unix_time.php
(Demo Script)
pad_test.php
(Demo Script)
convert_link.php
(Demo Script)
char_limit.php
(Demo Script)
cookies.php
(Demo Script)
smarty.php
(Demo Script)
phpinfo.php
(Demo Script)
htpasswd_maker.php
(Demo Script)
password.php
(Demo Script)
server_mon.php
(Demo Script)
url_verify.php
(Demo Script)
userdetails.php
(Demo Script)
email.php
(Demo Script)
time.php
(Demo Script)
html.php
(Demo Script)
birthday.php
(Demo Script)
md5_password.php
(Demo Script)
mysql_backup.php
(Demo Script)

To colour code your own PHP paste it here: