diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php index 581e73cac0..da5c3850ae 100644 --- a/phpBB/adm/admin_styles.php +++ b/phpBB/adm/admin_styles.php @@ -344,10 +344,41 @@ switch ($mode) switch ($action) { + case 'export': + + if ($imageset_id) + { + $sql = 'SELECT * + FROM ' . STYLES_IMAGE_TABLE . " + WHERE imageset_id = $imageset_id"; + $result = $db->sql_query($sql); + + if (!(extract($db->sql_fetchrow($result)))) + { + trigger_error($user->lang['NO_IMAGESET']); + } + $db->sql_freeresult($result); + + $cfg = addslashes($imageset_name) . "\n"; + $cfg .= addslashes($imageset_copyright) . "\n"; + $cfg .= addslashes($config['version']) . "\n"; + + if ($css_storedb) + { + } + else + { + $files = array(array('src' => "styles/imagesets/$imageset_path/", 'prefix' => 'styles/imagesets/', 'exclude' => 'tpl.cfg')); + $data = array(array('src' => $cfg, 'prefix' => "$imageset_path/imgset.cfg")); + } + + export('imageset', $imageset_id, $imageset_name, $imageset_path, $files, $data); + } + break; + case 'add': case 'details': - adm_page_header($user->lang['EDIT_IMAGESET']); ?> @@ -611,7 +642,42 @@ switch ($mode) // Lights, Camera ... switch ($action) { + + + case 'export': + + if ($template_id) + { + $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); + + $cfg = addslashes($template_name) . "\n"; + $cfg .= addslashes($template_copyright) . "\n"; + $cfg .= addslashes($config['version']) . "\n"; + + if ($css_storedb) + { + } + else + { + $files = array(array('src' => "styles/templates/$template_path/", 'prefix' => 'styles/templates/', 'exclude' => 'tpl.cfg')); + $data = array(array('src' => $cfg, 'prefix' => "$template_path/tpl.cfg")); + } + + export('template', $template_id, $template_name, $template_path, $files, $data); + } + break; + case 'cache': + $sql = 'SELECT * FROM ' . STYLES_TPL_TABLE . " WHERE template_id = $template_id"; @@ -1741,10 +1807,10 @@ function csspreview() ' . implode('
', $error) . '
'; - } + if (sizeof($error) && !empty($_POST['update'])) + { + echo '' . implode('
', $error) . '
'; + } ?> @@ -1764,10 +1830,10 @@ function csspreview() ' . implode('
', $error) . '
'; - } + if (sizeof($error) && !empty($_POST['update'])) + { + echo '' . implode('
', $error) . '
'; + } ?> @@ -2008,8 +2074,6 @@ function csspreview() if ($theme_id) { - include($phpbb_root_path . 'includes/functions_compress.'.$phpEx); - $sql = 'SELECT * FROM ' . STYLES_CSS_TABLE . " WHERE theme_id = $theme_id"; @@ -2021,137 +2085,23 @@ function csspreview() } $db->sql_freeresult($result); + $cfg = addslashes($theme_name) . "\n"; + $cfg .= addslashes($theme_copyright) . "\n"; + $cfg .= addslashes($config['version']) . "\n"; - if (isset($_POST['update'])) + if ($css_storedb) { - $theme_config = addslashes($theme_name) . "\n"; - $theme_config .= addslashes($theme_copyright) . "\n"; - $theme_config .= addslashes($config['version']) . "\n"; - - switch ($_POST['format']) - { - case 'tar': - $ext = 'tar'; - $mimetype = 'x-tar'; - $compress = 'compress_tar'; - break; - - case 'zip': - if (!extension_loaded('zlib')) - { - trigger_error($user->lang['NO_SUPPORT_ZIP']); - } - $ext = 'zip'; - $mimetype = 'zip'; - $compress = 'compress_zip'; - break; - - case 'tar.gz': - if (!extension_loaded('zlib')) - { - trigger_error($user->lang['NO_SUPPORT_GZ']); - } - $ext = 'tar.gz'; - $mimetype = 'x-gzip'; - $compress = 'compress_tar'; - break; - - case 'tar.bz2': - if (!extension_loaded('bz2')) - { - trigger_error($user->lang['NO_SUPPORT_BZ2']); - } - $ext = 'tar.bz2'; - $mimetype = 'x-bzip2'; - $compress = 'compress_tar'; - break; - - default: - trigger_error($user->lang['NO_SUPPORT_ARCHIVE']); - } - - if (!($zip = new $compress('w', "{$phpbb_root_path}store/theme_$theme_path.$ext"))) - { - trigger_error($user->lang['STORE_UNWRITEABLE']); - } - - // If we have the css in the DB we'll use that in preference to the one on the - // filesystem. We will also create an appropriate cfg file - if ($css_storedb) - { - $zip->add_file("styles/themes/$theme_path/", 'styles/themes/', "$theme_path.css,theme.cfg"); - $zip->add_data($css_data, "$theme_path/$theme_path.css"); - } - else - { - $zip->add_file("styles/themes/$theme_path/", 'styles/themes/', 'theme.cfg'); - } - $zip->add_data($theme_config, "$theme_path/theme.cfg"); - - $zip->close(); - - unset($theme_config); - unset($css_data); - - if (empty($_POST['store'])) - { - 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")); - @unlink("{$phpbb_root_path}store/theme_$theme_path.$ext"); - exit; - } - - add_log('admin', 'LOG_EXPORT_THEME', $theme_name); - trigger_error(sprintf($user->lang['THEME_EXPORTED'], "store/theme_$theme_path.$ext")); + $files = array(array('src' => "styles/themes/$theme_path/", 'prefix' => 'styles/themes/', 'exclude' => "$theme_path.css,theme.cfg")); + $data = array(array('src' => $css_data, 'prefix' => "$theme_path/$theme_path.css"), array('src' => $cfg, 'prefix' => "$theme_path/theme.cfg")); } - - // Output list of themes - adm_page_header($user->lang['THEMES_EXPORT']); - -?> -

lang['THEMES_EXPORT']; ?>

- -

lang['THEMES_EXPORT_EXPLAIN']; ?>

- -
"> - - - - - - - - - - - - - - - - - -
lang['THEMES_EXPORT']; ?> -
lang['THEME_NAME']; ?>:
lang['DOWNLOAD_STORE']; ?>:
lang['DOWNLOAD_STORE_EXPLAIN']; ?>
Store   Download
lang['ARCHIVE_FORMAT']; ?>: 'zlib', 'tar' => '', 'tar.gz' => 'zlib', 'tar.bz2' => 'bz2'); - - foreach ($compress_types as $type => $module) + else { - if ($module && !extension_loaded($module)) - { - break; - } - echo ' .' . $type . '  '; + $files = array(array('src' => "styles/themes/$theme_path/", 'prefix' => 'styles/themes/', 'exclude' => "theme.cfg")); + $data = array(array('src' => $cfg, 'prefix' => "$theme_path/theme.cfg")); } + unset($css_data); -?>
  
-lang['NO_SUPPORT_ZIP']); + } + $ext = 'zip'; + $mimetype = 'zip'; + $compress = 'compress_zip'; + break; + + case 'tar.gz': + if (!extension_loaded('zlib')) + { + trigger_error($user->lang['NO_SUPPORT_GZ']); + } + $ext = 'tar.gz'; + $mimetype = 'x-gzip'; + $compress = 'compress_tar'; + break; + + case 'tar.bz2': + if (!extension_loaded('bz2')) + { + trigger_error($user->lang['NO_SUPPORT_BZ2']); + } + $ext = 'tar.bz2'; + $mimetype = 'x-bzip2'; + $compress = 'compress_tar'; + break; + + default: + $error[] = $user->lang[$l_prefix . '_ERR_ARCHIVE']; + } + + if (!sizeof($error)) + { + if (!($zip = new $compress('w', "{$phpbb_root_path}store/{$mode}_$path.$ext"))) + { + trigger_error($user->lang['STORE_UNWRITEABLE']); + } + + if ($files) + { + foreach ($files as $file_ary) + { + $zip->add_file($file_ary['src'], $file_ary['prefix'], $file_ary['exclude']); + } + } + + if ($data) + { + foreach ($data as $data_ary) + { + $zip->add_data($data_ary['src'], $data_ary['prefix']); + } + } + + $zip->close(); + unset($cfg); + + if (empty($_POST['store'])) + { + header('Pragma: no-cache'); + header("Content-Type: application/$mimetype; name=\"{$type}_$path.$ext\""); + header("Content-disposition: attachment; filename={$type}_$path.$ext"); + + echo implode('', file("{$phpbb_root_path}store/{$type}_$path.$ext")); + @unlink("{$phpbb_root_path}store/{$type}_$path.$ext"); + exit; + } + + add_log('admin', 'LOG_EXPORT_' . $l_prefix, $name); + trigger_error(sprintf($user->lang[$l_prefix . '_EXPORTED'], "store/{$type}_$path.$ext")); + } + } + + // Output list of themes + adm_page_header($user->lang[$l_prefix . '_EXPORT']); + +?> +

lang[$l_prefix . '_EXPORT']; ?>

+ +

lang[$l_prefix . '_EXPORT_EXPLAIN']; ?>

+ +
"> + + + + + + + + + + + + + + + + + + + + + + +
lang[$l_prefix . '_EXPORT']; ?> +
', $error); ?>
lang[$l_prefix . '_NAME']; ?>:
lang['DOWNLOAD_STORE']; ?>:
lang['DOWNLOAD_STORE_EXPLAIN']; ?>
Store   Download
lang['ARCHIVE_FORMAT']; ?>: 'zlib', 'tar' => '', 'tar.gz' => 'zlib', 'tar.bz2' => 'bz2'); + + foreach ($compress_types as $type => $module) + { + if ($module && !extension_loaded($module)) + { + break; + } + echo ' .' . $type . '  '; + } + +?>
  
+