67acb41b0bac0ba215b2cf3a29a91b3771c005a9
[squirrelmail.git] / themes / random.php
1 <?php
2
3 /**
4 * Name: Random Theme Every Login
5 * @author Tyler Akins
6 * Date: December 24, 2001
7 * Comment: Guess what this does!
8 *
9 * Copyright (c) 2000-2005 The SquirrelMail Project Team
10 * Licensed under the GNU GPL. For full terms see the file COPYING.
11 *
12 * $Id$
13 * @package squirrelmail
14 * @subpackage themes
15 */
16
17 /** Initialize the random number generator */
18 sq_mt_randomize();
19
20 require_once(SM_PATH . 'functions/global.php');
21
22 global $theme;
23
24 if (!sqsession_is_registered('random_theme_good_theme')) {
25 $good_themes = array();
26 foreach ($theme as $data) {
27 if (substr($data['PATH'], -18) != '/themes/random.php') {
28 $good_themes[] = $data['PATH'];
29 }
30 }
31 if (count($good_themes) == 0) {
32 $good_themes[] = '../themes/default.php';
33 }
34 $which = mt_rand(0, count($good_themes));
35 $random_theme_good_theme = $good_themes[$which];
36 // remove current sm_path from theme name
37 $path=preg_quote(SM_PATH,'/');
38 $random_theme_good_theme=preg_replace("/^$path/",'',$random_theme_good_theme);
39 // store it in session
40 sqsession_register($random_theme_good_theme, 'random_theme_good_theme');
41 } else {
42 // get random theme stored in session
43 sqgetGlobalVar('random_theme_good_theme',$random_theme_good_theme);
44 }
45
46 @include_once (SM_PATH . $random_theme_good_theme);
47
48 ?>