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