A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

randompassword - Stikked
From amir_christ, 11 Years ago, written in PHP.
Embed
  1. <?php
  2.  
  3.   function generatePassword ($length = 8)
  4.   {
  5.  
  6.     // start with a blank password
  7.     $password = "";
  8.  
  9.     // define possible characters - any character in this string can be
  10.     // picked for use in the password, so if you want to put vowels back in
  11.     // or add special characters such as exclamation marks, this is where
  12.     // you should do it
  13.     $possible = "2346789bcdfghjkmnpqrtvwxyzBCDFGHJKLMNPQRTVWXYZ";
  14.  
  15.     // we refer to the length of $possible a few times, so let's grab it now
  16.     $maxlength = strlen($possible);
  17.  
  18.     // check for length overflow and truncate if necessary
  19.     if ($length > $maxlength) {
  20.       $length = $maxlength;
  21.     }
  22.        
  23.     // set up a counter for how many characters are in the password so far
  24.     $i = 0;
  25.    
  26.     // add random characters to $password until $length is reached
  27.     while ($i < $length) {
  28.  
  29.       // pick a random character from the possible ones
  30.       $char = substr($possible, mt_rand(0, $maxlength-1), 1);
  31.        
  32.       // have we already used this character in $password?
  33.       if (!strstr($password, $char)) {
  34.         // no, so it's OK to add it onto the end of whatever we've already got...
  35.         $password .= $char;
  36.         // ... and increase the counter by one
  37.         $i++;
  38.       }
  39.  
  40.     }
  41.  
  42.     // done!
  43.     return $password;
  44.  
  45.   }
  46.  
  47. ?>