3 /***************************************************************************
\r
6 * copyright : (C) 2003 - 2005 CyberAlien
\r
7 * support : http://www.phpbbstyles.com
\r
11 * file revision : 72
\r
12 * project revision : 78
\r
13 * last modified : 05 Dec 2005 13:54:54
\r
15 ***************************************************************************/
\r
17 /***************************************************************************
\r
19 * This program is free software; you can redistribute it and/or modify
\r
20 * it under the terms of the GNU General Public License as published by
\r
21 * the Free Software Foundation; either version 2 of the License, or
\r
22 * (at your option) any later version.
\r
24 ***************************************************************************/
\r
26 define('IN_PHPBB', 1);
\r
27 $phpbb_root_path = "./../";
\r
28 $no_page_header = true;
\r
29 require($phpbb_root_path . 'extension.inc');
\r
30 require('./pagestart.' . $phpEx);
\r
32 // check if mod is installed
\r
33 if(empty($template->xs_version) || $template->xs_version !== 8)
\r
35 message_die(GENERAL_ERROR, isset($lang['xs_error_not_installed']) ? $lang['xs_error_not_installed'] : 'eXtreme Styles mod is not installed. You forgot to upload includes/template.php');
\r
38 define('IN_XS', true);
\r
39 include_once('xs_include.' . $phpEx);
\r
41 $template->assign_block_vars('nav_left',array('ITEM' => '» <a href="' . append_sid('xs_config.'.$phpEx) . '">' . $lang['xs_configuration'] . '</a>'));
\r
43 $lang['xs_config_updated_explain'] = str_replace('{URL}', append_sid('xs_config.'.$phpEx), $lang['xs_config_updated_explain']);
\r
44 $lang['xs_config_title'] = str_replace('{VERSION}', $template->xs_versiontxt, $lang['xs_config_title']);
\r
45 $lang['xs_config_warning_explain'] = str_replace('{URL}', append_sid('xs_chmod.'.$phpEx), $lang['xs_config_warning_explain']);
\r
46 $lang['xs_config_back'] = str_replace('{URL}', append_sid('xs_config.'.$phpEx), $lang['xs_config_back']);
\r
49 // Updating configuration
\r
51 if(isset($HTTP_POST_VARS['submit']) && !defined('DEMO_MODE'))
\r
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');
\r
54 // checking navigation config
\r
56 for($i=0; $i<XS_SHOWNAV_MAX; $i++)
\r
59 if($i != XS_SHOWNAV_DOWNLOAD && !empty($HTTP_POST_VARS['shownav_' . $i])) // downloads feature is disabled
\r
64 if($shownav !== $board_config['xs_shownav'])
\r
66 $template->assign_block_vars('left_refresh', array(
\r
67 'ACTION' => append_sid('index.' . $phpEx . '?pane=left')
\r
70 $HTTP_POST_VARS['xs_shownav'] = $shownav;
\r
71 // checking submitted data
\r
72 $update_time = false;
\r
73 foreach($vars as $var)
\r
75 $new[$var] = stripslashes(trim($HTTP_POST_VARS[$var]));
\r
76 if(($var == 'xs_auto_recompile') && !$new['xs_auto_compile'])
\r
80 if($board_config[$var] !== $new[$var])
\r
82 $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . xs_sql($new[$var]) . "' WHERE config_name = '{$var}'";
\r
83 if( !$db->sql_query($sql) )
\r
85 xs_error(str_replace('{VAR}', $var, $lang['xs_config_sql_error']) . '<br /><br />' . $lang['xs_config_back'], __LINE__, __FILE__);
\r
87 $board_config[$var] = $new[$var];
\r
88 if($var === 'xs_check_switches')
\r
90 $update_time = true;
\r
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
\r
97 $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $board_config['xs_template_time'] . "' WHERE config_name = 'xs_template_time'";
\r
98 if( !$db->sql_query($sql) )
\r
100 xs_error(str_replace('{VAR}', 'xs_template_time', $lang['xs_config_sql_error']) . '<br /><br />' . $lang['xs_config_back'], __LINE__, __FILE__);
\r
103 // update config cache
\r
104 if(defined('XS_MODS_CATEGORY_HIERARCHY210'))
\r
106 if ( !empty($config) )
\r
108 $config->read(true);
\r
111 $template->assign_block_vars('switch_updated', array());
\r
112 $template->load_config($template->root, false);
\r
115 // check ftp configuration
\r
116 $xs_ftp_host = $board_config['xs_ftp_host'];
\r
117 if(empty($xs_ftp_host) && !empty($HTTP_SERVER_VARS['HTTP_HOST']))
\r
119 $str = $HTTP_SERVER_VARS['HTTP_HOST'];
\r
120 $template->assign_vars(array(
\r
121 'HOST_GUESS' => str_replace(array('{HOST}', '{CLICK}'), array($str, 'document.config.xs_ftp_host.value=\''.$str.'\''), $lang['xs_ftp_host_guess'])
\r
125 $xs_ftp_login = $board_config['xs_ftp_login'];
\r
126 if(empty($xs_ftp_login))
\r
128 if(substr($dir, 0, 6) === '/home/')
\r
130 $str = substr($dir, 6);
\r
131 $pos = strpos($str, '/');
\r
134 $str = substr($str, 0, $pos);
\r
135 $template->assign_vars(array(
\r
136 'LOGIN_GUESS' => str_replace(array('{LOGIN}', '{CLICK}'), array($str, 'document.config.xs_ftp_login.value=\''.$str.'\''), $lang['xs_ftp_login_guess'])
\r
141 $xs_ftp_path = $board_config['xs_ftp_path'];
\r
142 if(empty($xs_ftp_path))
\r
144 if(substr($dir, 0, 6) === '/home/');
\r
145 $str = substr($dir, 6);
\r
146 $pos = strpos($str, '/');
\r
149 $str = substr($str, $pos + 1);
\r
150 $pos = strrpos($str, 'admin');
\r
153 $str = substr($str, 0, $pos-1);
\r
154 $template->assign_vars(array(
\r
155 'PATH_GUESS' => str_replace(array('{PATH}', '{CLICK}'), array($str, 'document.config.xs_ftp_path.value=\''.$str.'\''), $lang['xs_ftp_path_guess'])
\r
161 $template->assign_vars(array(
\r
162 'XS_USE_CACHE_0' => $board_config['xs_use_cache'] ? '' : ' checked="checked"',
\r
163 'XS_USE_CACHE_1' => $board_config['xs_use_cache'] ? ' checked="checked"' : '',
\r
164 'XS_AUTO_COMPILE_0' => $board_config['xs_auto_compile'] ? '' : ' checked="checked"',
\r
165 'XS_AUTO_COMPILE_1' => $board_config['xs_auto_compile'] ? ' checked="checked"' : '',
\r
166 'XS_AUTO_RECOMPILE_0' => $board_config['xs_auto_recompile'] ? '' : ' checked="checked"',
\r
167 'XS_AUTO_RECOMPILE_1' => $board_config['xs_auto_recompile'] ? ' checked="checked"' : '',
\r
168 'XS_PHP' => htmlspecialchars($board_config['xs_php']),
\r
169 'XS_DEF_TEMPLATE' => htmlspecialchars($board_config['xs_def_template']),
\r
170 'XS_CHECK_SWITCHES_0' => !$board_config['xs_check_switches'] ? ' checked="checked"' : '', // no check
\r
171 'XS_CHECK_SWITCHES_1' => $board_config['xs_check_switches'] == 1 ? ' checked="checked"' : '', // smart check
\r
172 'XS_CHECK_SWITCHES_2' => $board_config['xs_check_switches'] == 2 ? ' checked="checked"' : '', // simple check
\r
173 'XS_WARN_INCLUDES_0' => $board_config['xs_warn_includes'] ? '' : ' checked="checked"',
\r
174 'XS_WARN_INCLUDES_1' => $board_config['xs_warn_includes'] ? ' checked="checked"' : '',
\r
175 'XS_ADD_COMMENTS_0' => $board_config['xs_add_comments'] ? '' : ' checked="checked"',
\r
176 'XS_ADD_COMMENTS_1' => $board_config['xs_add_comments'] ? ' checked="checked"' : '',
\r
177 'XS_FTP_HOST' => defined('DEMO_MODE') ? '' : $xs_ftp_host,
\r
178 'XS_FTP_LOGIN' => defined('DEMO_MODE') ? '' : $xs_ftp_login,
\r
179 'XS_FTP_PATH' => defined('DEMO_MODE') ? '' : $xs_ftp_path,
\r
180 'FORM_ACTION' => append_sid('xs_config.' . $phpEx),
\r
183 for($i=0; $i<XS_SHOWNAV_MAX; $i++)
\r
186 if($i != XS_SHOWNAV_DOWNLOAD) // downloads feature is disabled
\r
188 $template->assign_block_vars('shownav', array(
\r
190 'LABEL' => $lang['xs_config_shownav'][$i],
\r
191 'CHECKED' => (($board_config['xs_shownav'] & $num) > 0) ? 'checked="checked"' : ''
\r
197 $tpl_filename = $template->make_filename('_xs_test.tpl');
\r
198 $cache_filename = $template->make_filename_cache($tpl_filename);
\r
200 if(!xs_check_cache($cache_filename))
\r
202 $template->assign_block_vars('switch_xs_warning', array());
\r
204 @unlink($cache_filename);
\r
205 $debug_data = $str;
\r
206 $template->assign_vars(array(
\r
207 'XS_DEBUG_HDR1' => sprintf($lang['xs_check_hdr'], '_xs_test.tpl'),
\r
208 'XS_DEBUG_FILENAME1' => $tpl_filename,
\r
209 'XS_DEBUG_FILENAME2' => $cache_filename,
\r
210 'XS_DEBUG_DATA' => $debug_data,
\r
213 $template->set_filenames(array('body' => XS_TPL_PATH . 'config.tpl'));
\r
214 $template->pparse('body');
\r