/**
 * kind_of_blue.php
 * Name:    Kind of Blue
 * Date:    October 20, 2001
 * Comment: This theme generates random colors, featuring a
 *          light bluish background with dark text.
 *
 * @author Jorey Bump
 * @copyright © 2000-2007 The SquirrelMail Project Team
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @version $Id: kind_of_blue.php 12127 2007-01-13 20:07:24Z kink $
 * @package squirrelmail
 * @subpackage themes
 */
/** seed the random number generator */
sq_mt_randomize();
for ($i = 0; $i <= 15; $i++) {
    /* background/foreground toggle */
    if ($i == 0 or $i == 3 or $i == 4 or $i == 5 or $i == 9 or $i == 10 or $i == 12) {
        /* background */
        $b = mt_rand(248, 255);
        $r = mt_rand(180, 255);
        $g = mt_rand(178, $r);
    } else {
        /* text */
        $cmin = 0;
        $cmax = 128;
        /** generate random color **/
        $b = mt_rand($cmin, $cmax);
        $g = mt_rand($cmin, $cmax);
        $r = mt_rand($cmin, $cmax);
Example #2
0
/**
 * Generates a random string from the caracter set you pass in
 *
 * @param int size the size of the string to generate
 * @param string chars a string containing the characters to use
 * @param int flags a flag to add a specific set to the characters to use:
 *     Flags:
 *       1 = add lowercase a-z to $chars
 *       2 = add uppercase A-Z to $chars
 *       4 = add numbers 0-9 to $chars
 * @return string the random string
 */
function GenerateRandomString($size, $chars, $flags = 0)
{
    if ($flags & 0x1) {
        $chars .= 'abcdefghijklmnopqrstuvwxyz';
    }
    if ($flags & 0x2) {
        $chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    }
    if ($flags & 0x4) {
        $chars .= '0123456789';
    }
    if ($size < 1 || strlen($chars) < 1) {
        return '';
    }
    sq_mt_randomize();
    /* Initialize the random number generator */
    $String = '';
    $j = strlen($chars) - 1;
    while (strlen($String) < $size) {
        $String .= $chars[mt_rand(0, $j)];
    }
    return $String;
}