PHP Archiv

Das PHP Script Verzeichnis

Tag Archives: Code

Mit diesem Script kann man ein Zufallspasswort erstellen function random_password($length, $characters=’abcdefgh1234567890′){ if ($characters == “){ return “; } $chars_length = strlen($characters)-1; mt_srand((double)microtime()*1000000); $pwd = “; while(strlen($pwd) < $length){ $rand_char = mt_rand(0, $chars_length); $pwd .= $characters[$rand_char]; } return $pwd; }[/php] Quelle: Jonas John

Mit den folgenden Zeilen kann man einen Zufallsstring mit PHP erstellen function RandomString($len){ $randstr = “; srand((double)microtime()*1000000); for($i=0;$i<$len;$i++){ $n = rand(48,120); while (($n >= 58 && $n <= 64) || ($n >= 91 && $n <= 96)){ $n = rand(48,120); } $randstr .= chr($n); } return $randstr; } [/php] Quelle: Jonas John

Dateigröße in einem lesbaren Format anzeigen // A much better and accurate version can be found // in Aidan’s PHP Repository: // http://aidanlister.com/repos/v/function.size_readable.php /** * Returns a human readable filesize * * @author wesman20 (php.net) * @author Jonas John * @version 0.3 * @link http://www.jonasjohn.de/snippets/php/readable-filesize.htm */ function HumanReadableFilesize($size) { // Adapted from: http://www.php.net/manual/en/function.filesize.php $mod = […]