From 368fb159d726f8af0efccbcde03e1064be0db32d Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Thu, 17 Jul 2003 21:04:17 +0000 Subject: [PATCH] Template cache clearing git-svn-id: file:///svn/phpbb/trunk@4276 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_styles.php | 248 ++++++++++++++++++++++++++----------- 1 file changed, 177 insertions(+), 71 deletions(-) diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php index b14c06cdee..69fc9a2076 100644 --- a/phpBB/adm/admin_styles.php +++ b/phpBB/adm/admin_styles.php @@ -288,13 +288,11 @@ switch ($mode) FROM ' . STYLES_TABLE; $result = $db->sql_query($sql); - if ($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { - do - { - $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; + $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; - $stylevis = (!$row['style_active']) ? 'activate' : 'deactivate'; + $stylevis = (!$row['style_active']) ? 'activate' : 'deactivate'; ?> @@ -307,12 +305,9 @@ switch ($mode) sql_fetchrow($result)); } $db->sql_freeresult($result); - ?> Create new style: @@ -526,11 +521,9 @@ switch ($mode) FROM ' . STYLES_IMAGE_TABLE; $result = $db->sql_query($sql); - if ($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { - do - { - $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; + $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; ?> @@ -541,12 +534,9 @@ switch ($mode) sql_fetchrow($result)); } $db->sql_freeresult($result); - ?> Create new imageset: @@ -564,8 +554,176 @@ switch ($mode) case 'templates': + $template_id = (isset($_REQUEST['id'])) ? $_REQUEST['id'] : false; + + $tpllist = array( + 'misc' => array( + 'confirm_body.html', 'faq_body.html', 'index_body.html', 'message_body.html', 'viewonline_body.html', + ), + 'includes' => array( + 'overall_footer.html', 'overall_header.html', 'simple_footer.html', 'simple_header.html', 'searchbox.html', 'jumpbox.html', + ), + 'forum' => array( + 'viewforum_body.html', 'viewforum_subforum.html', + ), + 'topic' => array( + 'viewtopic_attach_body.html', 'viewtopic_body.html', 'viewtopic_print.html', + ), + 'group' => array( + 'gcp_body.html', 'gcp_pending_info.html', 'gcp_user_body.html', + ), + 'user' => array( + 'ucp_agreement.html', 'ucp_footer.html', 'ucp_header.html', 'ucp_main.html', 'ucp_pm_body.html', 'ucp_pm_popup.html', 'ucp_pm_preview.html', 'ucp_pm_read.html', 'ucp_prefs.html', 'ucp_profile.html', 'ucp_register.html', 'ucp_remind.html', + ), + 'profile' => array( + 'memberlist_body.html', 'memberlist_email.html', 'memberlist_im.html', 'memberlist_view.html', + ), + 'mod' => array( + 'mcp_forum.html', 'mcp_foruminfo.html', 'mcp_front.html', 'mcp_header.html', 'mcp_jumpbox.html', 'mcp_move.html', 'mcp_post.html', 'mcp_queue.html', 'mcp_reports.html', 'mcp_topic.html', 'mcp_viewlogs.html', 'report_body.html', + ), + 'search' => array( + 'search_body.html', 'search_results_posts.html', 'search_results_topics.html', + ), + 'posting' => array( + 'posting_attach_body.html', 'posting_body.html', 'posting_poll_body.html', 'posting_preview.html', 'posting_smilies.html', 'posting_topic_review.html', + ), + 'login' => array( + 'login_body.html', 'login_forum.html', + ), + 'custom' => array(), + ); + + // Lights, Camera ... switch ($action) { + case 'cache': + + $sql = 'SELECT * + FROM ' . STYLES_TPL_TABLE . " + WHERE template_id = $template_id"; + $result = $db->sql_query($sql); + + if (!(extract($db->sql_fetchrow($result)))) + { + trigger_error($user->lang['NO_TEMPLATE']); + } + $db->sql_freeresult($result); + + + if (!($dp = @opendir($phpbb_root_path . 'cache'))) + { + trigger_error($user->lang['ERR_TPLCACHE_READ']); + } + + $cache_prefix = 'tpl_' . $template_path; + + + // User wants to delete one or more files ... + if ($_POST['update'] && !empty($_POST['delete'])) + { + foreach ($_POST['delete'] as $file) + { + if (file_exists($phpbb_root_path . 'cache/' . $cache_prefix . '_' . $file . '.html.' . $phpEx) && is_file($phpbb_root_path . 'cache/' . $cache_prefix . '_' . $file . '.html.' . $phpEx)) + { + unlink($phpbb_root_path . 'cache/' . $cache_prefix . '_' . $file . '.html.' . $phpEx); + } + } + + add_log('admin', 'LOG_CLEAR_TPLCACHE', $template_name); + trigger_error($user->lang['TEMPLATE_CACHE_CLEARED']); + } + + + $tplcache_ary = array(); + while ($file = readdir($dp)) + { + if (is_file($phpbb_root_path . 'cache/' . $file) && strstr($file, $cache_prefix)) + { + $filename = preg_replace('#^' . $cache_prefix . '_(.*?)\.html\.' . $phpEx . '$#i', '\1', $file); + $tplcache_ary[$filename]['cache'] = filemtime($phpbb_root_path . 'cache/' . $file); + $tplcache_ary[$filename]['size'] = filesize($phpbb_root_path . 'cache/' . $file); + $tplcache_ary[$filename]['src'] = filemtime($phpbb_root_path . 'styles/templates/' . $template_path . '/' . $filename . '.html'); + } + } + closedir($dp); + + + // Output the page + adm_page_header($user->lang['TEMPLATE_CACHE']); + +?> + + + +

lang['TEMPLATE_CACHE']; ?>

+ +

lang['TEMPLATE_CACHE_EXPLAIN']; ?>

+ +
"> + + + + + + + + $times_ary) + { + $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; + +?> + + + + + + + + + + + + + + + +
lang['CACHE_FILENAME']; ?>lang['CACHE_FILESIZE']; ?>lang['CACHE_CACHED']; ?>lang['CACHE_CREATED']; ?>lang['MARK']; ?>
format_date($times_ary['cache']); ?>format_date($times_ary['src']); ?>
lang['NO_CACHED_TPL_FILES']; ?>
+ + + + + +
lang['MARK_ALL']; ?> :: lang['UNMARK_ALL']; ?>
+ array( - 'confirm_body.html', 'faq_body.html', 'index_body.html', 'message_body.html', 'viewonline_body.html', - ), - 'includes' => array( - 'overall_footer.html', 'overall_header.html', 'simple_footer.html', 'simple_header.html', 'searchbox.html', 'jumpbox.html', - ), - 'forum' => array( - 'viewforum_body.html', 'viewforum_subforum.html', - ), - 'topic' => array( - 'viewtopic_attach_body.html', 'viewtopic_body.html', 'viewtopic_print.html', - ), - 'group' => array( - 'gcp_body.html', 'gcp_pending_info.html', 'gcp_user_body.html', - ), - 'user' => array( - 'ucp_agreement.html', 'ucp_footer.html', 'ucp_header.html', 'ucp_main.html', 'ucp_pm_body.html', 'ucp_pm_popup.html', 'ucp_pm_preview.html', 'ucp_pm_read.html', 'ucp_prefs.html', 'ucp_profile.html', 'ucp_register.html', 'ucp_remind.html', - ), - 'profile' => array( - 'memberlist_body.html', 'memberlist_email.html', 'memberlist_im.html', 'memberlist_view.html', - ), - 'mod' => array( - 'mcp_forum.html', 'mcp_foruminfo.html', 'mcp_front.html', 'mcp_header.html', 'mcp_jumpbox.html', 'mcp_move.html', 'mcp_post.html', 'mcp_queue.html', 'mcp_reports.html', 'mcp_topic.html', 'mcp_viewlogs.html', 'report_body.html', - ), - 'search' => array( - 'search_body.html', 'search_results_posts.html', 'search_results_topics.html', - ), - 'posting' => array( - 'posting_attach_body.html', 'posting_body.html', 'posting_poll_body.html', 'posting_preview.html', 'posting_smilies.html', 'posting_topic_review.html', - ), - 'login' => array( - 'login_body.html', 'login_forum.html', - ), - 'custom' => array(), - ); - $tpldata = ''; if ($template_id) { @@ -798,11 +917,9 @@ switch ($mode) FROM ' . STYLES_TPL_TABLE; $result = $db->sql_query($sql); - if ($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { - do - { - $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; + $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; ?> @@ -816,15 +933,9 @@ switch ($mode) sql_fetchrow($result)); - } - else - { } $db->sql_freeresult($result); - ?> Create new template: @@ -1560,11 +1671,9 @@ function csspreview() FROM ' . STYLES_CSS_TABLE; $result = $db->sql_query($sql); - if ($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { - do - { - $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; + $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; ?> @@ -1582,12 +1691,9 @@ function csspreview() sql_fetchrow($result)); } $db->sql_freeresult($result); - ?> Create new theme: