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_cache.'.$phpEx) . '">' . $lang['xs_manage_cache'] . '</a>'));
\r
45 $skip_files = array(
\r
52 'attach_config.php',
\r
58 if(isset($HTTP_GET_VARS['clear']) && !defined('DEMO_MODE'))
\r
60 @set_time_limit(XS_MAX_TIMEOUT);
\r
61 $clear = $HTTP_GET_VARS['clear'];
\r
69 $match = XS_TPL_PREFIX . $clear . XS_SEPARATOR;
\r
71 $match_len = strlen($match);
\r
72 $style_len = strlen(STYLE_EXTENSION);
\r
73 $backup_len = strlen(XS_BACKUP_EXT);
\r
74 $dir = $template->cachedir;
\r
75 $res = @opendir($dir);
\r
78 $data = $lang['xs_cache_nowrite'];
\r
84 while(($file = readdir($res)) !== false)
\r
86 $len = strlen($file);
\r
87 // delete only files that match pattern, that aren't in exclusion list and that aren't downloaded styles.
\r
88 if(substr($file, 0, $match_len) === $match && !xs_in_array($file, $skip_files))
\r
89 if(substr($file, $len - $style_len) !== STYLE_EXTENSION && substr($file, $len - $backup_len) !== XS_BACKUP_EXT)
\r
91 $res2 = @unlink($dir . $file);
\r
94 $data .= str_replace('{FILE}', $file, $lang['xs_cache_log_deleted']) . "<br />\n";
\r
97 elseif(@is_file($dir . $file))
\r
99 $data .= str_replace('{FILE}', $file, $lang['xs_cache_log_nodelete']) . "<br />\n";
\r
105 if(!$num && !$num_error)
\r
109 $data .= str_replace('{TPL}', $clear, $lang['xs_cache_log_nothing']) . "<br />\n";
\r
113 $data .= $lang['xs_cache_log_nothing2'] . "<br />\n";
\r
118 $data .= str_replace('{NUM}', $num, $lang['xs_cache_log_count']) . "<br />\n";
\r
121 $data .= str_replace('{NUM}', $num_error, $lang['xs_cache_log_count2']) . "<br />\n";
\r
131 if(isset($HTTP_GET_VARS['compile']) && !defined('DEMO_MODE'))
\r
133 $tpl = $HTTP_GET_VARS['compile'];
\r
134 @set_time_limit(XS_MAX_TIMEOUT);
\r
139 $dir = $template->tpldir . $tpl . '/';
\r
140 compile_cache($dir, '', $tpl);
\r
144 $res = opendir('../templates');
\r
145 while(($file = readdir($res)) !== false)
\r
147 if($file !== '.' && $file !== '..' && is_dir('../templates/'.$file) && @file_exists('../templates/'.$file.'/overall_header.tpl'))
\r
149 compile_cache('../templates/'.$file.'/', '', $file);
\r
154 $data .= str_replace('{NUM}', $num_compiled, $lang['xs_cache_log_compiled']) . "<br />\n";
\r
155 $data .= str_replace('{NUM}', $num_errors, $lang['xs_cache_log_errors']) . "<br />\n";
\r
158 function compile_cache($dir, $subdir, $tpl)
\r
160 global $data, $template, $num_errors, $num_compiled, $lang;
\r
161 $str = $dir . $subdir;
\r
162 $res = @opendir($dir . $subdir);
\r
165 $data .= str_replace('{DIR}', $dir.$subdir, $lang['xs_cache_log_noaccess']) . "<br />\n";
\r
169 while(($file = readdir($res)) !== false)
\r
171 if(@is_dir($str . $file) && $file !== '.' && $file !== '..' && $file !== 'CVS')
\r
173 compile_cache($dir, $subdir . $file . '/', $tpl);
\r
175 elseif(substr($file, strlen($file) - 4) === '.tpl')
\r
177 $res2 = $template->precompile($tpl, $subdir . $file);
\r
180 $data .= str_replace('{FILE}', $dir.$subdir.$file, $lang['xs_cache_log_compiled2']) . "<br />\n";
\r
185 $data .= str_replace('{FILE}', $dir.$subdir.$file, $lang['xs_cache_log_nocompile']) . "<br />\n";
\r
194 // get list of installed styles
\r
196 $sql = 'SELECT themes_id, template_name, style_name FROM ' . THEMES_TABLE . ' ORDER BY template_name';
\r
197 if(!$result = $db->sql_query($sql))
\r
199 xs_error($lang['xs_no_style_info'], __LINE__, __FILE__);
\r
201 $style_rowset = $db->sql_fetchrowset($result);
\r
203 $template->set_filenames(array('body' => XS_TPL_PATH . 'cache.tpl'));
\r
207 $style_names = array();
\r
209 for($i=0; $i<count($style_rowset); $i++)
\r
211 $item = $style_rowset[$i];
\r
212 if($item['template_name'] === $prev_tpl)
\r
214 $style_names[] = htmlspecialchars($item['style_name']);
\r
220 $str = implode('<br />', $style_names);
\r
221 $str2 = urlencode($prev_tpl);
\r
222 $row_class = $xs_row_class[$j % 2];
\r
224 $template->assign_block_vars('styles', array(
\r
225 'ROW_CLASS' => $row_class,
\r
226 'TPL' => $prev_tpl,
\r
228 'U_CLEAR' => "xs_cache.{$phpEx}?clear={$str2}&sid={$userdata['session_id']}",
\r
229 'U_COMPILE' => "xs_cache.{$phpEx}?compile={$str2}&sid={$userdata['session_id']}",
\r
233 $prev_id = $item['themes_id'];
\r
234 $prev_tpl = $item['template_name'];
\r
235 $style_names = array(htmlspecialchars($item['style_name']));
\r
240 $str = implode('<br />', $style_names);
\r
241 $str2 = urlencode($prev_tpl);
\r
242 $row_class = $xs_row_class[$j % 2];
\r
244 $template->assign_block_vars('styles', array(
\r
245 'ROW_CLASS' => $row_class,
\r
246 'TPL' => $prev_tpl,
\r
248 'U_CLEAR' => "xs_cache.{$phpEx}?clear={$str2}&sid={$userdata['session_id']}",
\r
249 'U_COMPILE' => "xs_cache.{$phpEx}?compile={$str2}&sid={$userdata['session_id']}",
\r
254 $template->assign_vars(array(
\r
255 'U_CLEAR_ALL' => "xs_cache.{$phpEx}?clear=&sid={$userdata['session_id']}",
\r
256 'U_COMPILE_ALL' => "xs_cache.{$phpEx}?compile=&sid={$userdata['session_id']}",
\r
257 'RESULT' => '<br /><br />' . $data
\r
261 $template->pparse('body');
\r