fsf changes, meant to be rebased on upstream
[squirrelmail.git] / themes / random.php
CommitLineData
fc632e34 1<?php
fc632e34 2
d4f79d96 3/**
c4309fbd 4 * Name: Random Theme Every Login
c4309fbd 5 * Date: December 24, 2001
6 * Comment: Guess what this does!
d4f79d96 7 *
4b4abf93 8 * @author Tyler Akins
c997cbe6 9 * @copyright 2000-2021 The SquirrelMail Project Team
4b4abf93 10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @version $Id$
7ce971d0 12 * @package squirrelmail
c4309fbd 13 * @subpackage themes
d4f79d96 14 */
fc632e34 15
2c34672a 16/** Prevent direct script loading */
f627180c 17if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) {
2c34672a 18 die();
19}
20
21/** load required functions */
22include_once(SM_PATH . 'functions/global.php');
0b97a708 23
a4edbd9f 24global $theme;
eb548244 25
d7c82551 26if (!sqsession_is_registered('random_theme_good_theme')) {
d4f79d96 27 $good_themes = array();
28 foreach ($theme as $data) {
29 if (substr($data['PATH'], -18) != '/themes/random.php') {
fc632e34 30 $good_themes[] = $data['PATH'];
d4f79d96 31 }
32 }
8905fa13 33 if (count($good_themes) == 0) {
34 $good_themes[] = '../themes/default.php';
35 }
d4f79d96 36 $which = mt_rand(0, count($good_themes));
37 $random_theme_good_theme = $good_themes[$which];
e8927b2f 38 // remove current sm_path from theme name
39 $path=preg_quote(SM_PATH,'/');
40 $random_theme_good_theme=preg_replace("/^$path/",'',$random_theme_good_theme);
41 // store it in session
0b97a708 42 sqsession_register($random_theme_good_theme, 'random_theme_good_theme');
a4edbd9f 43} else {
44 // get random theme stored in session
45 sqgetGlobalVar('random_theme_good_theme',$random_theme_good_theme);
d4f79d96 46}
eb548244 47
e8927b2f 48@include_once (SM_PATH . $random_theme_good_theme);