/*******************************************************************************
*     MOD demo_theme :: version 1.0.2
*
*   ---------- Auteur --------------------------------------------------------
*   Auteur ::				Grummfy
*   Email ::				grummfy@yahoo.fr
*   Site Web ::				http://www.grummfy.com/
*
*   ---------- Mod -----------------------------------------------------------
*   Nom ::					demo_theme
*   Version ::				1.0.2
*   Compatible ::			FSB 1.0.2a
*
*   Description ::			Ce mods permet de creer une liste de
*	theme et ensuite de faire une dmonstration de ceux-ci
*
*   Temps d'installation ::	8 minutes
*   Requete ::				Oui
*   Cache ::				Non
*   Fichiers joins ::		1
*   Fichiers  modifier ::	3
*
*   ---------- Note ----------------------------------------------------------
*	Trs utile pour montrer vos crations...
*
*   ---------- Historique ----------------------------------------------------
*   Commenc ::               Le 13 / 01 / 2005
*   Dernire modification ::  Le 11 / 08 / 2005
*   Le 13 / 01 / 2005 ::
*		Premire version du mods
*   Le 31 / 01 / 2005 ::
*		correction d'un bug
*   Le 11 / 08 / 2005 ::
*		- Nouveau design
*		- Amlioration du code
*******************************************************************************/
#
# [1] ---------- ouvrir ---------------------------------------------------------
#
includes/header_forum.php

#
# [2] ---------- chercher -------------------------------------------------------
#
// Cette constante annonce que le header a t pars (utile pour la fonction info())
define('HEADER', TRUE);

#
# [3] ---------- avant, ajouter -------------------------------------------------
#
// mods :: demo_theme -----------------------------------------------------------
// ajout
if ( isset($HTTP_GET_VARS['theme'])&& !$config['annuler_theme'])
{
	if ($membre['membre_id'] != INVITE )
	{
		$sql = 'UPDATE ' . MEMBRES_TABLE . ' SET membre_theme = \'' . $HTTP_GET_VARS['theme'] . '/\' WHERE membre_id = \'' . $membre['membre_id'] . '\'';
		if ( ! $bdd->requete($sql) )
		{
			info($langue['er_titre'], sprintf($langue['er_update'], 'membres'), __LINE__, __FILE__, $sql);
		}
	}
	else
	{
		$sql = 'UPDATE ' . SESSIONS_TABLE . ' SET session_themes = \'' . $HTTP_GET_VARS['theme'] . '/\' WHERE session_sid = \'' . session_sid() . '\'';
		if ( ! $bdd->requete($sql) )
		{
			info($langue['er_titre'], sprintf($langue['er_update'], 'sessions'), __LINE__, __FILE__, $sql);
		}
	}
	$membre['membre_theme'] = $HTTP_GET_VARS['theme'] . '/';
	$tpl = new Tpl($racine . 'themes/' . $membre['membre_theme'], $racine . 'cache/cache_tpl/' . $membre['membre_theme']);
	include( $racine . 'themes/' . $membre['membre_theme'] . 'configuration_theme.php' );
}
// fin ajout
// mods :: demo_theme -----------------------------------------------------------

#
# [4] ---------- chercher -------------------------------------------------------
#
$tpl->pparse('header');

#
# [5] ---------- apres, ajouter -------------------------------------------------
#
// mods :: demo_theme -----------------------------------------------------------
// ajout
if (!$config['annuler_theme'])
{
	$liste_themes = array();
	if ( $dossier = opendir('./themes/') )
	{
		while ( $fichier = readdir($dossier) )
		{
			if ( $fichier != '.' && $fichier != '..' && $fichier != 'index.htm' )
			{
				$liste_themes[] = $fichier;
			}
		}
		closedir($dossier);
	}

	$tpl->set_filenames(array('style' => '../IceCold/style.tpl'));
	// pour viter tout bug au cas ou le champ serrait mal renseigner dans l'admin, on enlve dj le http://...
	$self_url = str_replace('http://' , '', $config['dommaine_site']);
	$self_url = str_replace($self_url . '/', \'', $HTTP_SERVER_VARS['HTTP_HOST'] . $HTTP_SERVER_VARS['PHP_SELF']);
	$url_themas = preg_replace('`((&|\?)theme=[[:alpha:]]*)*`i', '', $HTTP_SERVER_VARS['QUERY_STRING']);
	$url_themas = ($url_themas == '') ? '?theme=' : '?' . $url_themas . '&theme=';

	$url_themas = $racine . $self_url . $url_themas;
	unset($self_url);
	foreach ($liste_themes as $value)
	{
		$tpl->assign_block_vars('liste_style', array(
												'V_STYLE' => $value,
												'U_STYLE' => ajout_sid($url_themas . $value),
												)
											);
	}
	$tpl->assign_vars(array('L_LISTE_THEMES' => $langue['dmo_themes']));
	$tpl->pparse('style');
}
// fin ajout
// mods :: demo_theme -----------------------------------------------------------

#
# [6] ---------- ouvrir ---------------------------------------------------------
#
includes/fonctions_session.php

#
# [7] ---------- chercher -------------------------------------------------------
#
$sql = 'INSERT INTO ' . SESSIONS_TABLE . ' 
				(session_sid, membre_id, membre_ip, session_debut, session_temps, session_invisible) 
				VALUES (\'' . $sid . '\', \'' . $membre_id . '\', \'' . $membre_ip . '\', \'' . time() . '\', \'' . time() . '\', \'' . $membre_invisible . '\')';

#
# [8] ---------- remplacer par --------------------------------------------------
#
// mods :: demo_theme -----------------------------------------------------------
// ajout de ",session_themes" et de ",\'' . $config['theme_defaut'] . '\'"
$sql = 'INSERT INTO ' . SESSIONS_TABLE . ' 
				(session_sid, membre_id, membre_ip, session_debut, session_temps, session_invisible,session_themes) 
				VALUES (\'' . $sid . '\', \'' . $membre_id . '\', \'' . $membre_ip . '\', \'' . time() . '\', \'' . time() . '\', \'' . $membre_invisible . '\',\'' . $config['theme_defaut'] . '\')';
// fin ajout
// mods :: demo_theme -----------------------------------------------------------

#
# [9] ---------- chercher -------------------------------------------------------
#
	if ( $config['annuler_theme'] || $membre['membre_id'] == INVITE )
	{
		$membre['membre_theme'] = $config['theme_defaut'];
	}

#
# [10] ---------- remplacer par --------------------------------------------------
#
// mods :: demo_theme -----------------------------------------------------------
// del	if ( $config['annuler_theme'] || $membre['membre_id'] == INVITE )
// rempalcer par
	if ( $config['annuler_theme'] )
	{
		$membre['membre_theme'] = $config['theme_defaut'];
	}
	elseif ( $membre['membre_id'] == INVITE )
	{
		$membre['membre_theme'] = $membre['session_themes'];
	}
// fin
// mods :: demo_theme -----------------------------------------------------------

#
# [12] ---------- ouvrir ---------------------------------------------------------
#
langues/fr/langue_module.php

#
# [13] ---------- chercher -------------------------------------------------------
#
?>

#
# [14] ---------- avant, ajouter -------------------------------------------------
#
$langue['dmo_themes'] = 'Dmo des thmes';

#
# [15] ---------- copier ---------------------------------------------------------
#
"root/themes/IceCold/style.tpl" >> "themes/IceCold/style.tpl"

#
# [16] ---------- requete SQL ----------------------------------------------------
#
ALTER TABLE `fsb_sessions` ADD `session_themes` VARCHAR( 20 ) NOT NULL ;