952ea41c19a68abe1233b8085b0ea434e57eebd7
[squirrelmail.git] / monostochastic.php
1 <?php
2
3 /**
4 * monostochastic.php
5 * Name: Monostochastic
6 * Date: October 20, 2001
7 * Comment: Generates random two-color frames, featuring either
8 * a dark or light background.
9 *
10 * @author Jorey Bump
11 * @copyright &copy; 2000-2007 The SquirrelMail Project Team
12 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 * @version $Id$
14 * @package squirrelmail
15 * @subpackage themes
16 */
17
18 /** Prevent direct script loading */
19 if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) {
20 die();
21 }
22
23 /** load sq_mt_randomize() */
24 include_once(SM_PATH . 'functions/strings.php');
25
26 /** seed the random number generator */
27 sq_mt_randomize();
28
29 /** light(1) or dark(0) background toggle **/
30 $bg = mt_rand(0,1);
31
32 /** range delimiter **/
33 $bgrd = $bg * 128;
34
35 /** background **/
36 $cmin_b = 0 + $bgrd;
37 $cmax_b = 127 + $bgrd;
38
39 /** generate random color **/
40 $rb = mt_rand($cmin_b,$cmax_b);
41 $gb = mt_rand($cmin_b,$cmax_b);
42 $bb = mt_rand($cmin_b,$cmax_b);
43
44 /** text **/
45 $cmin_t = 128 - $bgrd;
46 $cmax_t = 255 - $bgrd;
47
48 /** generate random color **/
49 $rt = mt_rand($cmin_t,$cmax_t);
50 $gt = mt_rand($cmin_t,$cmax_t);
51 $bt = mt_rand($cmin_t,$cmax_t);
52
53 /** set array element as hex string with hashmark (for HTML output) **/
54 for ($i = 0; $i <= 15; $i++) {
55 if ($i == 0 or $i == 3 or $i == 4 or $i == 5 or $i == 9 or $i == 10 or $i == 12) {
56 $color[$i] = sprintf('#%02X%02X%02X',$rb,$gb,$bb);
57 } else {
58 $color[$i] = sprintf('#%02X%02X%02X',$rt,$gt,$bt);
59 }
60 }