4 * Name: Random Theme Every Login
5 * Date: December 24, 2001
6 * Comment: Guess what this does!
9 * @copyright © 2000-2006 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @package squirrelmail
16 /** Prevent direct script loading */
17 if ((isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__
) ||
18 (isset($HTTP_SERVER_SERVER['SCRIPT_FILENAME']) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__
) ) {
22 /** load required functions */
23 include_once(SM_PATH
. 'functions/global.php');
24 include_once(SM_PATH
. 'functions/strings.php');
26 /** Initialize the random number generator */
31 if (!sqsession_is_registered('random_theme_good_theme')) {
32 $good_themes = array();
33 foreach ($theme as $data) {
34 if (substr($data['PATH'], -18) != '/themes/random.php') {
35 $good_themes[] = $data['PATH'];
38 if (count($good_themes) == 0) {
39 $good_themes[] = '../themes/default.php';
41 $which = mt_rand(0, count($good_themes));
42 $random_theme_good_theme = $good_themes[$which];
43 // remove current sm_path from theme name
44 $path=preg_quote(SM_PATH
,'/');
45 $random_theme_good_theme=preg_replace("/^$path/",'',$random_theme_good_theme);
46 // store it in session
47 sqsession_register($random_theme_good_theme, 'random_theme_good_theme');
49 // get random theme stored in session
50 sqgetGlobalVar('random_theme_good_theme',$random_theme_good_theme);
53 @include_once
(SM_PATH
. $random_theme_good_theme);