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 14840 2020-01-07 07:42:38Z pdontthink $
  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.    if (defined('PAGE_NAME'&& PAGE_NAME=='left_main'{
  47.       echo '<meta http-equiv="Page-Enter" content="' .
  48.          'blendTrans(Duration=2.0)" />' "\n";
  49.    }
  50.  
  51. ?><script type="text/javascript">
  52. darkness_color = 0;
  53. darkness_dir = +1;
  54. darkness_hex = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
  55.    'a', 'b', 'c', 'd', 'e', 'f');
  56. function DarknessTremble() {
  57.    if (darkness_color >= 32 || darkness_color <= 0)
  58.       darkness_dir = - darkness_dir;
  59.    darkness_color += darkness_dir;
  60.    if (darkness_color < 0)
  61.       darkness_color = 0;
  62.    bigDigit = Math.floor(darkness_color / 16);
  63.    littleDigit = darkness_color - (bigDigit * 16);
  64.    Color = darkness_hex[bigDigit] + darkness_hex[littleDigit];
  65.    document.bgColor='#' + Color + Color + Color;
  66.    setTimeout('DarknessTremble()', 5000);
  67. }
  68. setTimeout('DarknessTremble()', 10000);
  69. </script>
  70. <?php
  71. }
  72.  
  73. global $squirrelmail_plugin_hooks;
  74. $squirrelmail_plugin_hooks['generic_header']['theme_darkness'=
  75.     'Darkness_HeaderPlugin';
  76.  
  77. /** seed the random number generator **/
  78.  
  79. $color[3'#000000';
  80. $color[4'#000000';
  81. $used array(0);
  82. $targetDistance $BackgroundTargetDistance;
  83. $Left array(0591012);
  84. while (count($Left0{
  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[$isprintf('#%02X%02X%02X',$r,$r$r);
  95.         $used[$r;
  96.         $targetDistance $BackgroundTargetDistance;
  97.     else {
  98.         $targetDistance -= $BackgroundAdjust;
  99.     }
  100. }
  101.  
  102. // Set the error color to some shade of red
  103. $r mt_rand(196255);
  104. $g mt_rand(144($r .8));
  105. $color[2sprintf('#%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(68as $i{
  112.     /** generate random color **/
  113.     $r mt_rand($cmin,$cmax);
  114.     $g mt_rand($cmin,$cmax);
  115.     $b mt_rand($cmin,$cmax);
  116.     $color[$isprintf('#%02X%02X%02X',$r,$g,$b);
  117.     $used[array($r$g$b);
  118. }
  119.  
  120. $Left array(1711131415);
  121. $targetDistance $TextTargetDistance;
  122. while (count($Left0{
  123.     // Text colors -- Try to keep the colors distinct
  124.     $cmin 196;
  125.     $cmax 255;
  126.  
  127.     /** generate random color **/
  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[$isprintf('#%02X%02X%02X',$r,$g,$b);
  135.         $used[array($r$g$b);
  136.         $targetDistance $TextTargetDistance;
  137.     else {
  138.         $targetDistance *= $TextAdjust;
  139.     }
  140. }

Documentation generated on Mon, 13 Jan 2020 04:24:26 +0100 by phpDocumentor 1.4.3