diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php index 2a64960104..f2b0149366 100644 --- a/phpBB/adm/admin_styles.php +++ b/phpBB/adm/admin_styles.php @@ -73,7 +73,10 @@ else $error = $cfg = $stylecfg = array(); $tmp_path = ''; -$safe_mode = (@ini_get('safe_mode') && @strtolower(ini_get('safe_mode')) == 'on') ? true : false; +$safe_mode = (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on') ? true : false; +$file_uploads = (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false; + + // Generate list of archive types inc. regexp | match $archive_types = '.tar'; @@ -89,6 +92,7 @@ foreach (array('tar.gz' => 'zlib', 'tar.bz2' => 'bz2', 'zip' => 'zlib') as $type } + // -------------------- // Start program proper // -------------------- @@ -103,18 +107,14 @@ if ($id) export($mode, $id); break; - case 'refresh': - break; - case 'add': case 'install': case 'details': +// install($mode, $action, $id); break; case 'delete': - break; - - case 'preview': + remove($mode, $id); break; } } @@ -147,85 +147,6 @@ switch ($mode) $db->sql_query($sql); break; - case 'delete': - if ($id) - { - $new_style_id = (!empty($_POST['newid'])) ? intval($_POST['newid']) : false; - - $sql = 'SELECT style_name - FROM ' . STYLES_TABLE . " - WHERE style_id = $id"; - $result = $db->sql_query($sql); - - if (!extract($db->sql_fetchrow($result))) - { - trigger_error($user->lang['NO_STYLE']); - } - - // Get list of other styles - $sql = 'SELECT style_id, style_name - FROM ' . STYLES_TABLE . " - WHERE style_id <> $id - ORDER BY style_id"; - $result = $db->sql_query($sql); - - $options = ''; - if (!($row = $db->sql_fetchrow($result))) - { - trigger_error($user->lang['ONLY_STYLE']); - } - - do - { - $options .= ''; - } - while ($row = $db->sql_fetchrow($result)); - - if ($update && $new_style_id) - { - $sql = 'DELETE FROM ' . STYLES_TABLE . " - WHERE style_id = $id"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . STYLES_TABLE . " - SET style_id = $new_style_id - WHERE style_id = $id"; - $db->sql_query($sql); - - add_log('admin', 'LOG_DELETE_STYLE', $style_name); - trigger_error($user->lang['STYLE_DELETED']); - } - - // Output list of themes - adm_page_header($user->lang['DELETE_STYLE']); - -?> -
lang['DELETE_STYLE_EXPLAIN']; ?>
- - -sql_query($sql); - - if (!(extract($db->sql_fetchrow($result)))) - { - trigger_error($user->lang['NO_TEMPLATE']); - } - $db->sql_freeresult($result); - - if ($template_storedb) - { - $sql = 'DELETE FROM ' . STYLES_TPLDATA_TABLE . " - WHERE template_id = $template_id"; - $db->sql_query($sql); - } - - remove('template', $template_id, $template_name, $template_path, $template_storedb); - } - break; - case 'add': case 'details': case 'install': @@ -1483,7 +1373,7 @@ function viewsource(url) } // Front page - front('template', array('cache', 'details', 'refresh', 'export', 'delete', 'preview')); + frontend('template', array('cache', 'details', 'refresh', 'export', 'delete', 'preview')); break; @@ -1981,38 +1871,16 @@ function csspreview() adm_page_footer(); break; - - case 'preview': - break; - case 'add': case 'details': case 'install': details('theme', $mode, $action, $id); exit; break; - - case 'delete': - if ($id) - { - $sql = 'SELECT theme_id, theme_name, theme_path, theme_storedb - FROM ' . STYLES_CSS_TABLE . " - WHERE theme_id = $id"; - $result = $db->sql_query($sql); - - if (!(extract($db->sql_fetchrow($result)))) - { - trigger_error($user->lang['NO_THEME']); - } - $db->sql_freeresult($result); - - remove('theme', $id, $theme_name, $theme_path, $theme_storedb); - } - break; } // Front page - front('theme', array('details', 'refresh', 'export', 'delete', 'preview')); + frontend('theme', array('details', 'refresh', 'export', 'delete', 'preview')); break; @@ -2157,26 +2025,6 @@ function csspreview() adm_page_footer(); break; - - - case 'delete': - if ($id) - { - $sql = 'SELECT imageset_id, imageset_name, imageset_path - FROM ' . STYLES_IMAGE_TABLE . " - WHERE imageset_id = $id"; - $result = $db->sql_query($sql); - - if (!(extract($db->sql_fetchrow($result)))) - { - trigger_error($user->lang['NO_IMAGESET']); - } - $db->sql_freeresult($result); - - remove('imageset', $id, $imageset_name, $imageset_path); - } - break; - case 'add': case 'details': case 'install': @@ -2185,20 +2033,18 @@ function csspreview() break; } - // Front page - front('imageset', array('details', 'delete', 'export')); + frontend('imageset', array('details', 'delete', 'export')); break; } - exit; // --------- // FUNCTIONS // -function front($type, $options) +function frontend($type, $options) { global $phpbb_root_path, $phpEx, $SID, $config, $db, $user, $mode; @@ -2337,31 +2183,52 @@ function front($type, $options) } -//function remove($type, $id) -function remove($type, $id, $name, $path, $storedb = false) +function remove($type, $id) { global $phpbb_root_path, $SID, $config, $db, $user, $mode, $action; + $new_id = (!empty($_POST['newid'])) ? intval($_POST['newid']) : false; + $deletefs = (!empty($_POST['deletefs'])) ? true : false; + $update = (isset($_POST['update'])) ? true : false; + switch ($type) { case 'style': + $table = STYLES_TABLE; + $sql_select = 'style_name'; break; case 'template': $table = STYLES_TPL_TABLE; + $sql_select = 'template_name, template_path, template_storedb'; break; case 'theme': $table = STYLES_CSS_TABLE; + $sql_select = 'theme_name, theme_path, theme_storedb'; break; case 'imageset': $table = STYLES_IMAGE_TABLE; + $sql_select = 'imageset_name, imageset_path'; break; } $l_prefix = strtoupper($type); + $sql = "SELECT $sql_select + FROM $table + WHERE {$type}_id = $id"; + $result = $db->sql_query($sql); + + if (!extract($db->sql_fetchrow($result))) + { + trigger_error($user->lang['NO_' . $l_prefix]); + } + + $path = ($type != 'style') ? ${$type . '_path'} : ''; + $storedb = (isset(${$type . '_storedb'})) ? ${$type . '_storedb'} : false; + $sql = "SELECT {$type}_id, {$type}_name FROM $table WHERE {$type}_id <> $id @@ -2386,40 +2253,50 @@ function remove($type, $id, $name, $path, $storedb = false) WHERE {$type}_id = $id"; $db->sql_query($sql); - $sql = "UPDATE $table - SET {$type}_id = " . intval($_POST['newid']) . " - WHERE {$type}_id = $id"; - $db->sql_query($sql); - $onfs = 0; - if (!empty($_POST['deletefs']) && is_writeable("{$phpbb_root_path}styles/$path/{$type}")) + if ($type == 'style') { - $filelist = filelist("{$phpbb_root_path}styles/$path/{$type}", '', '*'); - krsort($filelist); - - foreach ($filelist as $subpath => $file_ary) - { - $subpath = "{$phpbb_root_path}styles/$path/{$type}$subpath"; - foreach ($file_ary as $file) - { -/* if (!@unlink("$subpath/$file")) - { - $onfs = 1; - }*/ - } - -/* if (!@rmdir($subpath)) - { - $onfs = 1; - }*/ - } + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_style = $new_id + WHERE user_style = $id"; + $db->sql_query($sql); } else { - $onfs = (file_exists("{$phpbb_root_path}styles/$path/{$type}") && !is_writeable("{$phpbb_root_path}styles/$path/{$type}")) ? 1 : 0; + $sql = "UPDATE $table + SET {$type}_id = $new_id + WHERE {$type}_id = $id"; + $db->sql_query($sql); + + if ($deletefs && is_writeable("{$phpbb_root_path}styles/$path/{$type}")) + { + $filelist = filelist("{$phpbb_root_path}styles/$path/{$type}", '', '*'); + krsort($filelist); + + foreach ($filelist as $subpath => $file_ary) + { + $subpath = "{$phpbb_root_path}styles/$path/{$type}$subpath"; + foreach ($file_ary as $file) + { +/* if (!@unlink("$subpath$file")) + { + $onfs = 1; + } +*/ } + +/* if (!@rmdir($subpath)) + { + $onfs = 1; + } +*/ } + } + else + { + $onfs = (file_exists("{$phpbb_root_path}styles/$path/{$type}")) ? 1 : 0; + } } - add_log('admin', 'LOG_DELETE_' . $l_prefix, $name); + add_log('admin', 'LOG_DELETE_' . $l_prefix, ${$type . '_name'}); $message = ($onfs) ? $l_prefix . '_DELETED_FS' : $l_prefix . '_DELETED'; trigger_error($user->lang[$message]); } @@ -2432,22 +2309,22 @@ function remove($type, $id, $name, $path, $storedb = false)lang['DELETE_' . $l_prefix . '_EXPLAIN']; ?>
-