First attempt at converting $color themes to CSS stylesheets. Seems to work pretty...
[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 /** 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__) ) {
19 die();
20 }
21
22 /** load required functions */
23 include_once(SM_PATH . 'functions/global.php');
24 include_once(SM_PATH . 'functions/strings.php');
25
26 /** Initialize the random number generator */
27 sq_mt_randomize();
28
29 global $theme;
30
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'];
36 }
37 }
38 if (count($good_themes) == 0) {
39 $good_themes[] = '../themes/default.php';
40 }
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');
48 } else {
49 // get random theme stored in session
50 sqgetGlobalVar('random_theme_good_theme',$random_theme_good_theme);
51 }
52
53 @include_once (SM_PATH . $random_theme_good_theme);