documenting one more get var
[squirrelmail.git] / themes / random.php
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 &copy; 2000-2006 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 /** Initialize the random number generator */
17 sq_mt_randomize();
18
19 require_once(SM_PATH . 'functions/global.php');
20
21 global $theme;
22
23 if (!sqsession_is_registered('random_theme_good_theme')) {
24 $good_themes = array();
25 foreach ($theme as $data) {
26 if (substr($data['PATH'], -18) != '/themes/random.php') {
27 $good_themes[] = $data['PATH'];
28 }
29 }
30 if (count($good_themes) == 0) {
31 $good_themes[] = '../themes/default.php';
32 }
33 $which = mt_rand(0, count($good_themes));
34 $random_theme_good_theme = $good_themes[$which];
35 // remove current sm_path from theme name
36 $path=preg_quote(SM_PATH,'/');
37 $random_theme_good_theme=preg_replace("/^$path/",'',$random_theme_good_theme);
38 // store it in session
39 sqsession_register($random_theme_good_theme, 'random_theme_good_theme');
40 } else {
41 // get random theme stored in session
42 sqgetGlobalVar('random_theme_good_theme',$random_theme_good_theme);
43 }
44
45 @include_once (SM_PATH . $random_theme_good_theme);
46
47 ?>