squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

darkness.php
Go to the documentation of this file.
1 <?php
2 
17 require_once(SM_PATH . 'functions/strings.php');
18 
19  // Note: The text distance is actually pre-squared
20  // Background range is from 24-64, all three colors are the same
21  // Text range is from 196 to 255
25  $TextAdjust = 0.95;
26 
27 function IsUnique($Distance, $r, $g, $b, $usedArray)
28 {
29  foreach ($usedArray as $data) {
30  $a = abs($data[0] - $r);
31  $b = abs($data[1] - $g);
32  $c = abs($data[2] - $b);
33  $newDistance = $a * $a + $b * $b + $c * $c;
34  if ($newDistance < $Distance)
35  return false;
36  }
37  return true;
38 }
39 
40 
41 // Extra spiffy page fade if left frame
42 // Always tremble background
43 // This might make people go insane. Yes! *Victory dance!*
45  if (defined('PAGE_NAME') && PAGE_NAME=='left_main') {
46  echo '<meta http-equiv="Page-Enter" content="' .
47  'blendTrans(Duration=2.0)" />' . "\n";
48  }
49 
50 ?><script type="text/javascript">
51 darkness_color = 0;
52 darkness_dir = +1;
53 darkness_hex = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
54  'a', 'b', 'c', 'd', 'e', 'f');
55 function DarknessTremble() {
56  if (darkness_color >= 32 || darkness_color <= 0)
57  darkness_dir = - darkness_dir;
58  darkness_color += darkness_dir;
59  if (darkness_color < 0)
60  darkness_color = 0;
61  bigDigit = Math.floor(darkness_color / 16);
62  littleDigit = darkness_color - (bigDigit * 16);
63  Color = darkness_hex[bigDigit] + darkness_hex[littleDigit];
64  document.bgColor='#' + Color + Color + Color;
65  setTimeout('DarknessTremble()', 5000);
66 }
67 setTimeout('DarknessTremble()', 10000);
68 </script>
69 <?php
70 }
71 
73 $squirrelmail_plugin_hooks['generic_header']['theme_darkness'] =
74  'Darkness_HeaderPlugin';
75 
78 
79 $color[3] = '#000000';
80 $color[4] = '#000000';
81 $used = array(0);
83 $Left = array(0, 5, 9, 10, 12);
84 while (count($Left) > 0) {
85  // Some background colors
86  $r = mt_rand(24,64);
87  $unique = true;
88  foreach ($used as $col) {
89  if (abs($r - $col) < $targetDistance)
90  $unique = false;
91  }
92  if ($unique) {
93  $i = array_shift($Left);
94  $color[$i] = sprintf('#%02X%02X%02X',$r,$r, $r);
95  $used[] = $r;
97  } else {
99  }
100 }
101 
102 // Set the error color to some shade of red
103 $r = mt_rand(196, 255);
104 $g = mt_rand(144, ($r * .8));
105 $color[2] = sprintf('#%02X%02X%02X', $r, $g, $g);
106 $used = array(array($r, $g, $g));
107 
108 // Set normal text colors
109 $cmin = 196;
110 $cmax = 255;
111 foreach (array(6, 8) as $i) {
113  $r = mt_rand($cmin,$cmax);
114  $g = mt_rand($cmin,$cmax);
115  $b = mt_rand($cmin,$cmax);
116  $color[$i] = sprintf('#%02X%02X%02X',$r,$g,$b);
117  $used[] = array($r, $g, $b);
118 }
119 
120 $Left = array(1, 7, 11, 13, 14, 15);
122 while (count($Left) > 0) {
123  // Text colors -- Try to keep the colors distinct
124  $cmin = 196;
125  $cmax = 255;
126 
128  $r = mt_rand($cmin,$cmax);
129  $g = mt_rand($cmin,$cmax);
130  $b = mt_rand($cmin,$cmax);
131 
132  if (IsUnique($targetDistance, $r, $g, $b, $used)) {
133  $i = array_shift($Left);
134  $color[$i] = sprintf('#%02X%02X%02X',$r,$g,$b);
135  $used[] = array($r, $g, $b);
137  } else {
139  }
140 }
$TextAdjust
$TextAdjust
Definition: darkness.php:25
PAGE_NAME
const PAGE_NAME
Definition: options.php:17
$targetDistance
$targetDistance
Definition: darkness.php:82
$Left
$Left
Definition: darkness.php:83
$squirrelmail_plugin_hooks
global $squirrelmail_plugin_hooks
Definition: darkness.php:72
$BackgroundTargetDistance
$BackgroundTargetDistance
Definition: darkness.php:22
IsUnique
IsUnique($Distance, $r, $g, $b, $usedArray)
Definition: darkness.php:27
sprintf
powered by Systran sprintf(_("Number of supported language pairs: %s"), '36').' '
Definition: options.php:107
$TextTargetDistance
$TextTargetDistance
Definition: darkness.php:24
$used
$used
Definition: darkness.php:81
$cmax
$cmax
Definition: darkness.php:110
$BackgroundAdjust
$BackgroundAdjust
Definition: darkness.php:23
$g
$g
Definition: darkness.php:104
$r
while(count($Left) > 0) $r
Definition: darkness.php:103
$data
$data
Definition: mailto.php:83
SM_PATH
const SM_PATH
Definition: decrypt_headers.php:16
Darkness_HeaderPlugin
Darkness_HeaderPlugin()
Definition: darkness.php:44
$color
$color[3]
Definition: darkness.php:79
sq_mt_randomize
sq_mt_randomize()
Definition: strings.php:522
$cmin
$cmin
Definition: darkness.php:109