3 /***************************************************************************
6 * copyright : (C) 2003, 2004 CyberAlien
7 * support : http://www.phpbbstyles.com
12 * project revision : 51
13 * last modified : 25 Aug 2004 11:51:48
15 ***************************************************************************/
17 /***************************************************************************
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
24 ***************************************************************************/
26 define('IN_PHPBB', 1);
27 $phpbb_root_path = "./../";
28 $no_page_header = true;
29 require($phpbb_root_path . 'extension.inc');
30 require('./pagestart.' . $phpEx);
32 // check if mod is installed
33 if(empty($template->xs_version) || $template->xs_version !== 5)
35 message_die(GENERAL_ERROR, 'eXtreme Styles mod is not installed. You forgot to upload includes/template.php');
38 define('IN_XS', true);
39 include_once('xs_include.' . $phpEx);
41 $template->assign_block_vars('nav_left',array('ITEM' => '» <a href="' . append_sid('xs_config.'.$phpEx) . '">' . $lang['xs_configuration'] . '</a>'));
43 $lang['xs_config_updated_explain'] = str_replace('{URL}', append_sid('xs_config.'.$phpEx), $lang['xs_config_updated_explain']);
44 $lang['xs_config_title'] = str_replace('{VERSION}', $template->xs_versiontxt, $lang['xs_config_title']);
45 $lang['xs_config_warning_explain'] = str_replace('{URL}', append_sid('xs_chmod.'.$phpEx), $lang['xs_config_warning_explain']);
46 $lang['xs_config_back'] = str_replace('{URL}', append_sid('xs_config.'.$phpEx), $lang['xs_config_back']);
49 // Updating configuration
51 if(isset($HTTP_POST_VARS['submit']) && !defined('DEMO_MODE'))
53 $vars = array('xs_use_cache', 'xs_auto_compile', 'xs_auto_recompile', 'xs_php', 'xs_def_template', 'xs_check_switches', 'xs_warn_includes', 'xs_add_comments', 'xs_ftp_host', 'xs_ftp_login', 'xs_ftp_path', 'xs_shownav');
54 // checking navigation config
56 for($i=0; $i<XS_SHOWNAV_MAX; $i++)
59 if($i != XS_SHOWNAV_DOWNLOAD && !empty($HTTP_POST_VARS['shownav_' . $i])) // downloads feature is disabled
64 if($shownav !== $board_config['xs_shownav'])
66 $template->assign_block_vars('left_refresh', array(
67 'ACTION' => append_sid('index.' . $phpEx . '?pane=left')
70 $HTTP_POST_VARS['xs_shownav'] = $shownav;
71 // checking submitted data
73 foreach($vars as $var)
75 $new[$var] = stripslashes(trim($HTTP_POST_VARS[$var]));
76 if(($var == 'xs_auto_recompile') && !$new['xs_auto_compile'])
80 if($board_config[$var] !== $new[$var])
82 $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . xs_sql($new[$var]) . "' WHERE config_name = '{$var}'";
83 if( !$db->sql_query($sql) )
85 xs_error(str_replace('{VAR}', $var, $lang['xs_config_sql_error']) . '<br /><br />' . $lang['xs_config_back'], __LINE__, __FILE__);
87 $board_config[$var] = $new[$var];
88 if($var === 'xs_check_switches')
96 $board_config['xs_template_time'] = time() + 10; // set time 10 seconds in future in case if some tpl file would be compiled right now with current settings
97 $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $board_config['xs_template_time'] . "' WHERE config_name = 'xs_template_time'";
98 if( !$db->sql_query($sql) )
100 xs_error(str_replace('{VAR}', 'xs_template_time', $lang['xs_config_sql_error']) . '<br /><br />' . $lang['xs_config_back'], __LINE__, __FILE__);
103 $template->assign_block_vars('switch_updated', array());
104 $template->load_config($template->root, false);
107 // check ftp configuration
108 $xs_ftp_host = $board_config['xs_ftp_host'];
109 if(empty($xs_ftp_host) && !empty($HTTP_SERVER_VARS['HTTP_HOST']))
111 $str = $HTTP_SERVER_VARS['HTTP_HOST'];
112 $template->assign_vars(array(
113 'HOST_GUESS' => str_replace(array('{HOST}', '{CLICK}'), array($str, 'document.config.xs_ftp_host.value=\''.$str.'\''), $lang['xs_ftp_host_guess'])
117 $xs_ftp_login = $board_config['xs_ftp_login'];
118 if(empty($xs_ftp_login))
120 if(substr($dir, 0, 6) === '/home/')
122 $str = substr($dir, 6);
123 $pos = strpos($str, '/');
126 $str = substr($str, 0, $pos);
127 $template->assign_vars(array(
128 'LOGIN_GUESS' => str_replace(array('{LOGIN}', '{CLICK}'), array($str, 'document.config.xs_ftp_login.value=\''.$str.'\''), $lang['xs_ftp_login_guess'])
133 $xs_ftp_path = $board_config['xs_ftp_path'];
134 if(empty($xs_ftp_path))
136 if(substr($dir, 0, 6) === '/home/');
137 $str = substr($dir, 6);
138 $pos = strpos($str, '/');
141 $str = substr($str, $pos + 1);
142 $pos = strrpos($str, 'admin');
145 $str = substr($str, 0, $pos-1);
146 $template->assign_vars(array(
147 'PATH_GUESS' => str_replace(array('{PATH}', '{CLICK}'), array($str, 'document.config.xs_ftp_path.value=\''.$str.'\''), $lang['xs_ftp_path_guess'])
153 $template->assign_vars(array(
154 'XS_USE_CACHE_0' => $board_config['xs_use_cache'] ? '' : ' checked="checked"',
155 'XS_USE_CACHE_1' => $board_config['xs_use_cache'] ? ' checked="checked"' : '',
156 'XS_AUTO_COMPILE_0' => $board_config['xs_auto_compile'] ? '' : ' checked="checked"',
157 'XS_AUTO_COMPILE_1' => $board_config['xs_auto_compile'] ? ' checked="checked"' : '',
158 'XS_AUTO_RECOMPILE_0' => $board_config['xs_auto_recompile'] ? '' : ' checked="checked"',
159 'XS_AUTO_RECOMPILE_1' => $board_config['xs_auto_recompile'] ? ' checked="checked"' : '',
160 'XS_PHP' => htmlspecialchars($board_config['xs_php']),
161 'XS_DEF_TEMPLATE' => htmlspecialchars($board_config['xs_def_template']),
162 'XS_CHECK_SWITCHES_0' => !$board_config['xs_check_switches'] ? ' checked="checked"' : '', // no check
163 'XS_CHECK_SWITCHES_1' => $board_config['xs_check_switches'] == 1 ? ' checked="checked"' : '', // smart check
164 'XS_CHECK_SWITCHES_2' => $board_config['xs_check_switches'] == 2 ? ' checked="checked"' : '', // simple check
165 'XS_WARN_INCLUDES_0' => $board_config['xs_warn_includes'] ? '' : ' checked="checked"',
166 'XS_WARN_INCLUDES_1' => $board_config['xs_warn_includes'] ? ' checked="checked"' : '',
167 'XS_ADD_COMMENTS_0' => $board_config['xs_add_comments'] ? '' : ' checked="checked"',
168 'XS_ADD_COMMENTS_1' => $board_config['xs_add_comments'] ? ' checked="checked"' : '',
169 'XS_FTP_HOST' => defined('DEMO_MODE') ? '' : $xs_ftp_host,
170 'XS_FTP_LOGIN' => defined('DEMO_MODE') ? '' : $xs_ftp_login,
171 'XS_FTP_PATH' => defined('DEMO_MODE') ? '' : $xs_ftp_path,
172 'FORM_ACTION' => append_sid('xs_config.' . $phpEx),
175 for($i=0; $i<XS_SHOWNAV_MAX; $i++)
178 if($i != XS_SHOWNAV_DOWNLOAD) // downloads feature is disabled
180 $template->assign_block_vars('shownav', array(
182 'LABEL' => $lang['xs_config_shownav'][$i],
183 'CHECKED' => (($board_config['xs_shownav'] & $num) > 0) ? 'checked="checked"' : ''
189 $tpl_filename = $template->make_filename('_xs_test.tpl');
190 $cache_filename = $template->make_filename_cache($tpl_filename);
192 if(!xs_check_cache($cache_filename))
194 $template->assign_block_vars('switch_xs_warning', array());
196 @unlink($cache_filename);
198 $template->assign_vars(array(
199 'XS_DEBUG_HDR1' => sprintf($lang['xs_check_hdr'], '_xs_test.tpl'),
200 'XS_DEBUG_FILENAME1' => $tpl_filename,
201 'XS_DEBUG_FILENAME2' => $cache_filename,
202 'XS_DEBUG_DATA' => $debug_data,
205 $template->set_filenames(array('body' => XS_TPL_PATH . 'config.tpl'));
206 $template->pparse('body');