random.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Name: Random Theme Every Login
  4. * Date: December 24, 2001
  5. * Comment: Guess what this does!
  6. *
  7. * @author Tyler Akins
  8. * @copyright &copy; 2000-2007 The SquirrelMail Project Team
  9. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10. * @version $Id$
  11. * @package squirrelmail
  12. * @subpackage themes
  13. */
  14. /** Prevent direct script loading */
  15. if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) {
  16. die();
  17. }
  18. /** load required functions */
  19. include_once(SM_PATH . 'functions/global.php');
  20. global $theme;
  21. if (!sqsession_is_registered('random_theme_good_theme')) {
  22. $good_themes = array();
  23. foreach ($theme as $data) {
  24. if (substr($data['PATH'], -18) != '/themes/random.php') {
  25. $good_themes[] = $data['PATH'];
  26. }
  27. }
  28. if (count($good_themes) == 0) {
  29. $good_themes[] = '../themes/default.php';
  30. }
  31. $which = mt_rand(0, count($good_themes));
  32. $random_theme_good_theme = $good_themes[$which];
  33. // remove current sm_path from theme name
  34. $path=preg_quote(SM_PATH,'/');
  35. $random_theme_good_theme=preg_replace("/^$path/",'',$random_theme_good_theme);
  36. // store it in session
  37. sqsession_register($random_theme_good_theme, 'random_theme_good_theme');
  38. } else {
  39. // get random theme stored in session
  40. sqgetGlobalVar('random_theme_good_theme',$random_theme_good_theme);
  41. }
  42. @include_once (SM_PATH . $random_theme_good_theme);