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

Documentation generated on Mon, 13 Jan 2020 04:22:15 +0100 by phpDocumentor 1.4.3