From 0db32b3f93a4b9eb4b7a8a89ac9858f5e58f5260 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Sun, 20 Jul 2003 17:26:13 +0000 Subject: [PATCH] Delete theme ... be careful! Doesn't currently do any checks to ensure it's not the only theme, or to alter any styles using this theme ... git-svn-id: file:///svn/phpbb/trunk@4296 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_styles.php | 144 +++++++++++++++++++++++++++++++------ 1 file changed, 123 insertions(+), 21 deletions(-) diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php index 3f2495ae66..95397c8928 100644 --- a/phpBB/adm/admin_styles.php +++ b/phpBB/adm/admin_styles.php @@ -447,12 +447,15 @@ switch ($mode) $imagesetlist = filelist($phpbb_root_path . 'styles/imagesets/' . $imageset_path); $imagesetlist_options = ''; - foreach ($imagesetlist as $img) + foreach ($imagesetlist as $path => $img_ary) { - $img = substr($img['path'], 1) . (($img['path'] != '') ? '/' : '') . $img['file']; + foreach ($img_ary as $img) + { + $img = substr($path, 1) . (($path != '') ? '/' : '') . $img; - $selected = (preg_match('#' . preg_quote($img) . '$#', $background_image)) ? ' selected="selected"' : ''; - $imagesetlist_options .= ''; + $selected = (preg_match('#' . preg_quote($img) . '$#', $background_image)) ? ' selected="selected"' : ''; + $imagesetlist_options .= ''; + } } $imagesetlist_options = '' . $imagesetlist_options; unset($imagesetlist); @@ -1199,21 +1202,21 @@ function viewsource(url) $filelist = filelist($phpbb_root_path . 'styles/themes/' . $row['theme_path'], '', '*'); // Copy every file, bar CVS and the original stylesheet - foreach ($filelist as $file_ary) + foreach ($filelist as $path => $file_ary) { - $path = $file_ary['path']; - $file = $file_ary['file']; - - if (strstr($path, 'CVS') || $file == $row['theme_path'] . '.css') + foreach ($file_ary as $file) { - continue; - } + if (strstr($path, 'CVS') || $file == $row['theme_path'] . '.css') + { + continue; + } - if (!file_exists("{$phpbb_root_path}styles/themes/$theme_path/$path")) - { - @mkdir("{$phpbb_root_path}styles/themes/$theme_path/$path"); + if (!file_exists("{$phpbb_root_path}styles/themes/$theme_path/$path")) + { + @mkdir("{$phpbb_root_path}styles/themes/$theme_path/$path"); + } + @copy("{$phpbb_root_path}styles/themes/" . $row['theme_path'] . "/$path/$file", "{$phpbb_root_path}styles/themes/$theme_path/$path/$file"); } - @copy("{$phpbb_root_path}styles/themes/" . $row['theme_path'] . "/$path/$file", "{$phpbb_root_path}styles/themes/$theme_path/$path/$file"); } unset($filelist); } @@ -1607,12 +1610,15 @@ function viewsource(url) $imglist = filelist($phpbb_root_path . 'styles/themes'); $bg_imglist = ''; - foreach ($imglist as $img) + foreach ($imglist as $path => $img_ary) { - $img = substr($img['path'], 1) . (($img['path'] != '') ? '/' : '') . $img['file']; + foreach ($img_ary as $img) + { + $img = substr($path, 1) . (($path != '') ? '/' : '') . $img; - $selected = (preg_match('#' . preg_quote($img) . '$#', $background_image)) ? ' selected="selected"' : ''; - $bg_imglist .= ''; + $selected = (preg_match('#' . preg_quote($img) . '$#', $background_image)) ? ' selected="selected"' : ''; + $bg_imglist .= ''; + } } $bg_imglist = '' . $bg_imglist; unset($imglist); @@ -1841,6 +1847,98 @@ function csspreview() break; case 'delete': + + if ($theme_id) + { + $sql = 'SELECT * + FROM ' . STYLES_CSS_TABLE . " + WHERE theme_id = $theme_id"; + $result = $db->sql_query($sql); + + if (!(extract($db->sql_fetchrow($result)))) + { + trigger_error($user->lang['NO_THEME']); + } + $db->sql_freeresult($result); + + if (isset($_POST['update'])) + { + $sql = 'DELETE FROM ' . STYLES_CSS_TABLE . ' + WHERE theme_id = ' . $theme_id; + $db->sql_query($sql); + + $onfs = 0; + if (!empty($_POST['deletefs']) && is_writeable("{$phpbb_root_path}styles/themes/$theme_path")) + { + $filelist = filelist("{$phpbb_root_path}styles/themes/$theme_path", '', '*'); + krsort($filelist); + + foreach ($filelist as $path => $img_ary) + { + $path = "{$phpbb_root_path}styles/themes/$theme_path$path"; + foreach ($img_ary as $img) + { + if (!@unlink("$path/$img")) + { + $onfs = 1; + } + } + if (!@rmdir($path)) + { + $onfs = 1; + } + } + } + else + { + $onfs = (file_exists("{$phpbb_root_path}styles/themes/$theme_path") && !is_writeable("{$phpbb_root_path}styles/themes/$theme_path")) ? 1 : 0; + } + + add_log('admin', 'LOG_DELETE_THEME', $theme_name); + $message = ($onfs) ? 'THEME_DELETED_FS' : 'THEME_DELETED'; + trigger_error($user->lang[$message]); + } + + // Output list of themes + adm_page_header($user->lang['DELETE_THEME']); + +?> +

lang['DELETE_THEME']; ?>

+ +

lang['DELETE_THEME_EXPLAIN']; ?>

+ +
"> + + + + + + + + + + + + + + + +
lang['DELETE_THEME']; ?> +
lang['THEME_NAME']; ?>:
Delete from filesystem: Yes   No
  
+close(); $ext = 'zip'; + $mimetype = 'zip'; break; case 'tar': $ext = 'tar'; + $mimetype = 'x-tar'; break; case 'gz': @@ -1914,6 +2014,7 @@ function csspreview() break; } $ext = 'tar.gz'; + $mimetype = 'x-gzip'; break; case 'bz2': @@ -1923,6 +2024,7 @@ function csspreview() break; } $ext = 'tar.bz2'; + $mimetype = 'x-bzip2'; break; default: @@ -1934,8 +2036,8 @@ function csspreview() if (empty($_POST['store'])) { - header("Pragma: no-cache"); - header("Content-Type: application/zip; name=\"theme_$theme_path.$ext\""); + header('Pragma: no-cache'); + header("Content-Type: application/$mimetype; name=\"theme_$theme_path.$ext\""); header("Content-disposition: attachment; filename=theme_$theme_path.$ext"); echo implode('', file("{$phpbb_root_path}store/theme_$theme_path.$ext"));