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