PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/squirrelmail/themes/monostochastic.php

#
PHP | 54 lines | 23 code | 9 blank | 22 comment | 14 complexity | 8d83f104d3ce5500c1ff4178734e9b4c MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0
  1. <?php
  2. /**
  3. * monostochastic.php
  4. * Name: Monostochastic
  5. * Date: October 20, 2001
  6. * Comment: Generates random two-color frames, featuring either
  7. * a dark or light background.
  8. *
  9. * @author Jorey Bump
  10. * @copyright 2000-2012 The SquirrelMail Project Team
  11. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  12. * @version $Id: monostochastic.php 14249 2012-01-02 02:09:17Z pdontthink $
  13. * @package squirrelmail
  14. * @subpackage themes
  15. */
  16. /** Prevent direct script loading */
  17. if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) {
  18. die();
  19. }
  20. /** light(1) or dark(0) background toggle **/
  21. $bg = mt_rand(0,1);
  22. /** range delimiter **/
  23. $bgrd = $bg * 128;
  24. /** background **/
  25. $cmin_b = 0 + $bgrd;
  26. $cmax_b = 127 + $bgrd;
  27. /** generate random color **/
  28. $rb = mt_rand($cmin_b,$cmax_b);
  29. $gb = mt_rand($cmin_b,$cmax_b);
  30. $bb = mt_rand($cmin_b,$cmax_b);
  31. /** text **/
  32. $cmin_t = 128 - $bgrd;
  33. $cmax_t = 255 - $bgrd;
  34. /** generate random color **/
  35. $rt = mt_rand($cmin_t,$cmax_t);
  36. $gt = mt_rand($cmin_t,$cmax_t);
  37. $bt = mt_rand($cmin_t,$cmax_t);
  38. /** set array element as hex string with hashmark (for HTML output) **/
  39. for ($i = 0; $i <= 16; $i++) {
  40. if ($i == 0 or $i == 3 or $i == 4 or $i == 5 or $i == 9 or $i == 10 or $i == 12 or $i == 16) {
  41. $color[$i] = sprintf('#%02X%02X%02X',$rb,$gb,$bb);
  42. } else {
  43. $color[$i] = sprintf('#%02X%02X%02X',$rt,$gt,$bt);
  44. }
  45. }