Source for file darkness.php

Documentation is available at darkness.php

  1. <?php
  2.  
  3. /**
  4.  * Theme Name:   'Darkness'
  5.  * Like black?
  6.  *
  7.  * @author Tyler Akins
  8.  * @copyright &copy; 2001-2006 The SquirrelMail Project Team
  9.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.  * @version $Id: darkness.php,v 1.19 2006/07/15 12:01:31 tokul Exp $
  11.  * @package squirrelmail
  12.  * @subpackage themes
  13.  */
  14.  
  15. /**
  16.  * Load up the usual suspects.. */
  17.  
  18. require_once(SM_PATH 'functions/strings.php');
  19.  
  20.    // Note:  The text distance is actually pre-squared
  21.    // Background range is from 24-64, all three colors are the same
  22.    // Text range is from 196 to 255
  23.       $BackgroundTargetDistance 12;
  24.    $BackgroundAdjust 1;
  25.    $TextTargetDistance 65536;
  26.    $TextAdjust 0.95;
  27.  
  28. function IsUnique($Distance$r$g$b$usedArray)
  29. {
  30.    foreach ($usedArray as $data{
  31.       $a abs($data[0$r);
  32.       $b abs($data[1$g);
  33.       $c abs($data[2$b);
  34.       $newDistance $a $a $b $b $c $c;
  35.       if ($newDistance $Distance)
  36.          return false;
  37.    }
  38.    return true;
  39. }
  40.  
  41.  
  42. // Extra spiffy page fade if left frame
  43. // Always tremble background
  44. // This might make people go insane.  Yes!  *Victory dance!*
  45. function Darkness_HeaderPlugin({
  46.    global $PHP_SELF;
  47.  
  48.    if (substr($PHP_SELF-18== '/src/left_main.php'{
  49.       echo '<meta http-equiv="Page-Enter" content="' .
  50.          'blendTrans(Duration=2.0)" />' "\n";
  51.    }
  52.  
  53. ?><script type="text/javascript">
  54. darkness_color = 0;
  55. darkness_dir = +1;
  56. darkness_hex = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
  57.    'a', 'b', 'c', 'd', 'e', 'f');
  58. function DarknessTremble() {
  59.    if (darkness_color >= 32 || darkness_color <= 0)
  60.       darkness_dir = - darkness_dir;
  61.    darkness_color += darkness_dir;
  62.    if (darkness_color < 0)
  63.       darkness_color = 0;
  64.    bigDigit = Math.floor(darkness_color / 16);
  65.    littleDigit = darkness_color - (bigDigit * 16);
  66.    Color = darkness_hex[bigDigit] + darkness_hex[littleDigit];
  67.    document.bgColor='#' + Color + Color + Color;
  68.    setTimeout('DarknessTremble()', 5000);
  69. }
  70. setTimeout('DarknessTremble()', 10000);
  71. </script>
  72. <?php
  73. }
  74.  
  75. global $squirrelmail_plugin_hooks;
  76. $squirrelmail_plugin_hooks['generic_header']['theme_darkness'=
  77.     'Darkness_HeaderPlugin';
  78.  
  79. /** seed the random number generator **/
  80.  
  81. $color[3'#000000';
  82. $color[4'#000000';
  83. $used array(0);
  84. $targetDistance $BackgroundTargetDistance;
  85. $Left array(0591012);
  86. while (count($Left0{
  87.     // Some background colors
  88.         $r mt_rand(24,64);
  89.     $unique true;
  90.     foreach ($used as $col{
  91.         if (abs($r $col$targetDistance)
  92.             $unique false;
  93.     }
  94.     if ($unique{
  95.         $i array_shift($Left);
  96.         $color[$isprintf('#%02X%02X%02X',$r,$r$r);
  97.         $used[$r;
  98.         $targetDistance $BackgroundTargetDistance;
  99.     else {
  100.         $targetDistance -= $BackgroundAdjust;
  101.     }
  102. }
  103.  
  104. // Set the error color to some shade of red
  105. $r mt_rand(196255);
  106. $g mt_rand(144($r .8));
  107. $color[2sprintf('#%02X%02X%02X'$r$g$g);
  108. $used array(array($r$g$g));
  109.  
  110. // Set normal text colors
  111. $cmin 196;
  112. $cmax 255;
  113. foreach (array(68as $i{
  114.     /** generate random color **/
  115.     $r mt_rand($cmin,$cmax);
  116.     $g mt_rand($cmin,$cmax);
  117.     $b mt_rand($cmin,$cmax);
  118.     $color[$isprintf('#%02X%02X%02X',$r,$g,$b);
  119.     $used[array($r$g$b);
  120. }
  121.  
  122. $Left array(1711131415);
  123. $targetDistance $TextTargetDistance;
  124. while (count($Left0{
  125.     // Text colors -- Try to keep the colors distinct
  126.         $cmin 196;
  127.     $cmax 255;
  128.  
  129.     /** generate random color **/
  130.     $r mt_rand($cmin,$cmax);
  131.     $g mt_rand($cmin,$cmax);
  132.     $b mt_rand($cmin,$cmax);
  133.  
  134.     if (IsUnique($targetDistance$r$g$b$used)) {
  135.         $i array_shift($Left);
  136.         $color[$isprintf('#%02X%02X%02X',$r,$g,$b);
  137.         $used[array($r$g$b);
  138.         $targetDistance $TextTargetDistance;
  139.     else {
  140.         $targetDistance *= $TextAdjust;
  141.     }
  142. }

Documentation generated on Sat, 07 Oct 2006 16:10:18 +0300 by phpDocumentor 1.3.0RC6