Advertisement
janus57

themeswitcher.php

Feb 21st, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.86 KB | None | 0 0
  1. <?php
  2. /*##################################################
  3.  *                               themeswitcher.php
  4.  *                            -------------------
  5.  *   begin                : November 16, 2008
  6.  *   copyright          : (C) 2008 Viarre Régis
  7.  *   email                : crowkait@phpboost.com
  8.  *
  9.  *
  10. ###################################################
  11.  *
  12.  *   This program is free software; you can redistribute it and/or modify
  13.  *   it under the terms of the GNU General Public License as published by
  14.  *   the Free Software Foundation; either version 2 of the License, or
  15.  *   (at your option) any later version.
  16.  *
  17.  * This program is distributed in the hope that it will be useful,
  18.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20.  * GNU General Public License for more details.
  21.  *
  22.  * You should have received a copy of the GNU General Public License
  23.  * along with this program; if not, write to the Free Software
  24.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  25.  *
  26. ###################################################*/
  27.  
  28. function menu_themeswitcher_themeswitcher($position, $block)
  29. {
  30.    global $CONFIG, $THEME_CONFIG, $User, $LANG, $Session;
  31.  
  32.     $switchtheme = !empty($_GET['switchtheme']) ? urldecode($_GET['switchtheme']) : '';
  33.     if (!empty($switchtheme))
  34.     {
  35.         if ($User->check_level(MEMBER_LEVEL))
  36.         {
  37.             $Session->csrf_get_protect();
  38.         }
  39.        
  40.         if (preg_match('`[ a-z0-9_-]{3,20}`i', $switchtheme) && strpos($switchtheme, '\'') === false)
  41.         {
  42.             $User->update_user_theme($switchtheme); //Mise à jour du thème du membre.
  43.             if (QUERY_STRING != '')
  44.                 redirect(trim(HOST . SCRIPT . '?' . preg_replace('`switchtheme=[^&]+`', '', QUERY_STRING), '?'));
  45.             else
  46.                 redirect(HOST . SCRIPT);
  47.         }
  48.     }
  49.    
  50.     $tpl = new Template('menus/themeswitcher/themeswitcher.tpl');
  51.     import('core/menu_service');
  52.     MenuService::assign_positions_conditions($tpl, $block);
  53.    
  54.     $utheme = get_utheme();
  55.     foreach($THEME_CONFIG as $theme => $array_info)
  56.     {
  57.         if ($User->check_level($array_info['secure']) && $theme != 'default')
  58.         {
  59.             $selected = ($utheme == $theme) ? ' selected="selected"' : '';
  60.             $info_theme = @parse_ini_file(PATH_TO_ROOT . '/templates/' . $theme . '/config/' . get_ulang() . '/config.ini');
  61.             $tpl->assign_block_vars('themes', array(
  62.                 'NAME' => $info_theme['name'],
  63.                 'IDNAME' => $theme,
  64.                 'SELECTED' => $selected
  65.             ));
  66.         }
  67.     }
  68.    
  69.     $tpl->assign_vars(array(
  70.         'DEFAULT_THEME' => $CONFIG['theme'],
  71.         'L_SWITCHTHEME' => 'Changer le thème',
  72.         'L_DEFAULT_THEME' => 'Thème par défaut',
  73.         'L_SUBMIT' => $LANG['submit']
  74.     ));
  75.    
  76.     return $tpl->parse(TEMPLATE_STRING_MODE);
  77. }
  78.  
  79. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement