Per last commit, fix other places using msg message file extension - change to eml
[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-2007 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 include_once(SM_PATH . 'functions/strings.php');
24
25 /** Initialize the random number generator */
26 sq_mt_randomize();
27
28 global $theme;
29
30 if (!sqsession_is_registered('random_theme_good_theme')) {
31 $good_themes = array();
32 foreach ($theme as $data) {
33 if (substr($data['PATH'], -18) != '/themes/random.php') {
34 $good_themes[] = $data['PATH'];
35 }
36 }
37 if (count($good_themes) == 0) {
38 $good_themes[] = '../themes/default.php';
39 }
40 $which = mt_rand(0, count($good_themes));
41 $random_theme_good_theme = $good_themes[$which];
42 // remove current sm_path from theme name
43 $path=preg_quote(SM_PATH,'/');
44 $random_theme_good_theme=preg_replace("/^$path/",'',$random_theme_good_theme);
45 // store it in session
46 sqsession_register($random_theme_good_theme, 'random_theme_good_theme');
47 } else {
48 // get random theme stored in session
49 sqgetGlobalVar('random_theme_good_theme',$random_theme_good_theme);
50 }
51
52 @include_once (SM_PATH . $random_theme_good_theme);