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']; ?>

- -

lang['DELETE_STYLE_EXPLAIN']; ?>

- -
"> - - - - - - - - - - - - - -
lang['DELETE_STYLE']; ?> -
lang['STYLE_NAME']; ?>:
lang['REPLACE_STYLE']; ?>:
lang['REPLACE_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']; ?>

-
"> +">
- + - + lang['STYLE_ERR_MORE_ELEMENTS']; + } + + $style_id = &$id; + $name = 'style_name'; + + $sql_select = 's.style_id, s.style_name, s.style_copyright'; + $sql_select .= ($inc_template) ? ', t.*' : ', t.template_name'; + $sql_select .= ($inc_theme) ? ', c.*' : ', c.theme_name'; + $sql_select .= ($inc_imageset) ? ', i.*' : ', i.imageset_name'; + $sql_from = STYLES_TABLE . ' s, ' . STYLES_TPL_TABLE . ' t, ' . STYLES_CSS_TABLE . ' c, ' . STYLES_IMAGE_TABLE . ' i'; + $sql_where = "s.style_id = $id AND t.template_id = s.template_id AND c.theme_id = s.theme_id AND i.imageset_id = s.imageset_id"; + + $l_prefix = 'STYLE'; + break; + + case 'template': + $template_id = &$id; + $name = 'template_name'; + + $sql_select = '*'; + $sql_from = STYLES_TPL_TABLE; + $sql_where = "template_id = $id"; + + $l_prefix = 'TEMPLATE'; + break; + + case 'theme': + $theme_id = &$id; + $name = 'theme_name'; + + $sql_select = '*'; + $sql_from = STYLES_CSS_TABLE; + $sql_where = "theme_id = $id"; + + $l_prefix = 'THEME'; + break; + + case 'imageset': + $imageset_id = &$id; + $name = 'imageset_name'; + + $sql_select = '*'; + $sql_from = STYLES_IMAGE_TABLE; + $sql_where = "imageset_id = $id"; + + $l_prefix = 'IMAGESET'; + break; + } + + // Lets do a merry dance ... either that or generate the archive + if ($update && !sizeof($error)) + { + $sql = "SELECT $sql_select + FROM $sql_from + WHERE $sql_where"; + $result = $db->sql_query($sql); + + if (!($style_row = ($db->sql_fetchrow($result)))) + { + trigger_error($user->lang['NO_' . $l_prefix]); + } + $db->sql_freeresult($result); + + $var_ary = array('style_id', 'style_name', 'style_copyright', 'template_id', 'template_name', 'template_path', 'template_copyright', 'template_storedb', 'bbcode_bitfield', 'theme_id', 'theme_name', 'theme_path', 'theme_copyright', 'theme_storedb', 'theme_mtime', 'theme_data', 'imageset_id', 'imageset_name', 'imageset_path', 'imageset_copyright'); + foreach ($var_ary as $var) + { + $$var = (!empty($style_row[$var])) ? $style_row[$var] : ''; + unset($style_row[$var]); + } + + $files = $data = array(); + + if ($mode == 'style') + { + $style_cfg = addslashes($style_name) . "\n"; + $style_cfg .= addslashes($style_copyright) . "\n"; + $style_cfg .= addslashes($config['version']) . "\n"; + $style_cfg .= ((!$inc_template) ? addslashes($template_name) : '') . "\n"; + $style_cfg .= ((!$inc_theme) ? addslashes($theme_name) : '') . "\n"; + $style_cfg .= ((!$inc_imageset) ? addslashes($imageset_name) : ''); + + $data[] = array( + 'src' => $style_cfg, + 'prefix' => 'style.cfg' + ); + unset($style_cfg); + } + + // Export template core code + if ($mode == 'template' || $inc_template) + { + $template_cfg = addslashes($template_name) . "\n"; + $template_cfg .= addslashes($template_copyright) . "\n"; + $template_cfg .= addslashes($config['version']) . "\n"; + $template_cfg .= addslashes($bbcode_bitfield); + + $data[] = array( + 'src' => $template_cfg, + 'prefix' => 'template/template.cfg' + ); + + // This is potentially nasty memory-wise ... + if (!$template_storedb) + { + $files[] = array( + 'src' => "styles/$template_path/template/", + 'prefix-' => "styles/$template_path/", + 'prefix+' => false, + 'exclude' => 'template.cfg' + ); + } + else + { + $sql = 'SELECT template_filename, template_data + FROM ' . STYLES_TPLDATA_TABLE . " + WHERE template_id = $template_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $data[] = array( + 'src' => $row['template_data'], + 'prefix' => 'template/' . $row['template_filename'] + ); + } + $db->sql_freeresult($result); + } + unset($template_cfg); + } + + // Export theme core code + if ($mode == 'theme' || $inc_theme) + { + $theme_cfg = addslashes($theme_name) . "\n"; + $theme_cfg .= addslashes($theme_copyright) . "\n"; + $theme_cfg .= addslashes($config['version']); + + $files[] = array( + 'src' => "styles/$theme_path/theme/", + 'prefix-' => "styles/$theme_path/", + 'prefix+' => false, + 'exclude' => ($theme_storedb) ? 'stylesheet.css,theme.cfg' : 'theme.cfg' + ); + + $data[] = array( + 'src' => $theme_cfg, + 'prefix' => 'theme/theme.cfg' + ); + + if ($theme_storedb) + { + $data[] = array( + 'src' => $theme_data, + 'prefix' => 'theme/stylesheet.css' + ); + } + unset($theme_data); + unset($theme_cfg); + } + + // Export imageset core code + if ($mode == 'imageset' || $inc_imageset) + { + $imageset_cfg = addslashes($imageset_name) . "\n"; + $imageset_cfg .= addslashes($imageset_copyright) . "\n"; + $imageset_cfg .= addslashes($config['version']); + + foreach (array_keys($style_row) as $key) + { + $imageset_cfg .= $key . '||' . str_replace("styles/$imageset_path/imageset/", '{PATH}', $style_row[$key]) . "\n"; + unset($style_row[$key]); + } + + $files[] = array( + 'src' => "styles/$imageset_path/imageset/", + 'prefix-' => "styles/$imageset_path/", + 'prefix+' => false, + 'exclude' => 'imageset.cfg' + ); + + $data[] = array( + 'src' => trim($imageset_cfg), + 'prefix' => 'imageset/imageset.cfg' + ); + unset($imageset_cfg); + } + + switch ($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: + $error[] = $user->lang[$l_prefix . '_ERR_ARCHIVE']; + } + + if (!sizeof($error)) + { + include($phpbb_root_path . 'includes/functions_compress.'.$phpEx); + + $path = str_replace(' ', '_', $$name); + + if (!($zip = new $compress('w', "{$phpbb_root_path}store/$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['prefix+'], $file_ary['exclude']); + } + } + + if ($data) + { + foreach ($data as $data_ary) + { + $zip->add_data($data_ary['src'], $data_ary['prefix']); + } + } + + $zip->close(); + + add_log('admin', 'LOG_EXPORT_' . $l_prefix, $$name); + + if (!$store) + { + header('Pragma: no-cache'); + header("Content-Type: application/$mimetype; name=\"$path.$ext\""); + header("Content-disposition: attachment; filename=$path.$ext"); + + $fp = fopen("{$phpbb_root_path}store/$path.$ext", 'rb'); + while ($buffer = fread($fp, 1024)) + { + echo $buffer; + } + fclose($fp); + @unlink("{$phpbb_root_path}store/$path.$ext"); + exit; + } + + trigger_error(sprintf($user->lang[$l_prefix . '_EXPORTED'], "store/$path.$ext")); + } + } + else + { + $sql = "SELECT {$mode}_id, {$mode}_name + FROM " . (($mode == 'style') ? STYLES_TABLE : $sql_from) . " + WHERE {$mode}_id = $id"; + $result = $db->sql_query($sql); + + if (!extract($db->sql_fetchrow($result))) + { + trigger_error($user->lang['NO_' . $l_prefix]); + } + $db->sql_freeresult($result); + } + + // Output list + adm_page_header($user->lang[$l_prefix . '_EXPORT']); + +?> +

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

+ +

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

+ +">
lang['DELETE_' . $l_prefix]; ?>
lang[$l_prefix . '_NAME']; ?>:
Delete from filesystem:lang['DELETE_FROM_FS']; ?>: lang['YES']; ?>   lang['NO']; ?>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
lang[$l_prefix . '_EXPORT']; ?> +
', $error); ?>
lang[$l_prefix . '_NAME']; ?>:
lang['INCLUDE_TEMPLATE']; ?>: lang['YES']; ?>    lang['NO']; ?>
lang['INCLUDE_THEME']; ?>: lang['YES']; ?>    lang['NO']; ?>
lang['INCLUDE_IMAGESET']; ?>: lang['YES']; ?>    lang['NO']; ?>
lang['DOWNLOAD_STORE']; ?>:
lang['DOWNLOAD_STORE_EXPLAIN']; ?>
lang['EXPORT_STORE']; ?>    lang['EXPORT_DOWNLOAD']; ?>
lang['ARCHIVE_FORMAT']; ?>: .tar   'zlib', 'tar.bz2' => 'bz2', 'zip' => 'zlib'); + + foreach ($compress_types as $type => $module) + { + if (!extension_loaded($module)) + { + break; + } + echo ' .' . $type . '  '; + } + +?>
  
+ $file_ary) + { + foreach ($file_ary as $file) + { + if (!($fp = fopen("{$phpbb_root_path}styles/$path$pathfile/$file", 'r'))) + { + trigger_error("Could not open {$phpbb_root_path}styles/$path/$pathfile/$file"); + } + $template_data = fread($fp, filesize("{$phpbb_root_path}styles/$path$pathfile/$file")); + fclose($fp); + + if (preg_match_all('##is', $template_data, $matches)) + { + foreach ($matches[1] as $match) + { + $includes[trim($match)][] = $file; + } + } + } + } + + foreach ($filelist as $pathfile => $file_ary) + { + foreach ($file_ary as $file) + { + // Skip index. + if (strpos($file, 'index.') === 0) + { + continue; + } + + // We could do this using extended inserts ... but that could be one + // heck of a lot of data ... + $sql_ary = array( + 'template_id' => $id, + 'template_filename' => $file, + 'template_included' => (!empty($includes[$file])) ? implode(':', $includes[$file]) . ':' : '', + 'template_mtime' => filemtime("{$phpbb_root_path}styles/$path$pathfile/$file"), + 'template_data' => implode('', file("{$phpbb_root_path}styles/$path$pathfile/$file")), + ); + + $sql = ($mode == 'insert') ? 'INSERT INTO ' . STYLES_TPLDATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary) : 'UPDATE ' . STYLES_TPLDATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary) . " WHERE template_id = $id AND template_filename = '" . $db->sql_escape($file) . "'"; + $db->sql_query($sql); + } + } +} + +function copy_files($src, $filelist, $dst) +{ + global $phpbb_root_path; + + if (!(is_writable("{$phpbb_root_path}styles"))) + { + return false; + } + + umask(0); + if (!file_exists("{$phpbb_root_path}styles/$dst")) + { + @mkdir("{$phpbb_root_path}styles/$dst", 0777); + chmod("{$phpbb_root_path}styles/$dst", 0777); + } + + @ksort($filelist); + foreach ($filelist as $filepath => $file_ary) + { + $filepath = (substr($filepath, 0, 1) != '/') ? "/$filepath" : $filepath; + + if ($filepath && !file_exists("{$phpbb_root_path}styles/$dst$filepath")) + { + @mkdir("{$phpbb_root_path}styles/$dst$filepath", 0777); + chmod("{$phpbb_root_path}styles/$dst$filepath", 0777); + } + + foreach ($file_ary as $file) + { + if (!file_exists("{$phpbb_root_path}styles/$dst$filepath$file")) + { + @rename("$src$filepath$file", "{$phpbb_root_path}styles/$dst$filepath$file"); + @chmod("{$phpbb_root_path}styles/$dst$filepath$file", 0777); + } + } + + if ($filepath && file_exists("$src$filepath")) + { + @rmdir("$src$filepath"); + } + } + + @rmdir("$src/$dst"); + @rmdir($src); +} + function cleanup_folder($path) { $filelist = filelist($path, '', '*'); @@ -2488,6 +2859,182 @@ function cleanup_folder($path) } @rmdir("$path"); } +// +// FUNCTIONS +// --------- + + + +// Hopefully temporary +function theme_preview(&$path, &$stylesheet, &$class, &$css_element) +{ + global $config, $user; + +?> + + + + + + + + + + + + + + + + + + + + + +

h1

h2

h3

mainmenu
 
+ + + + +
titles +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
th
cattitle / catcatdiv
topictitle / row1topicauthor / row2topicdetails / row1
row3
spacer
postdetails / row2postbody / row1 posthilit
+ +

+ + + + + + + + + + +
gengenmedgensmall
copyright phpBB
+ +

+ +
+ + + + + + + + + + + + + + +
+ +

+ + + + + + + + + + + + + + +
postbody / bold italic underline
+ + + +
A_N_Other wrote:
quote
+ + + + + + +
Code:
10 Print "hello"
20 Goto 10
+ + + + + + +
PHP:
// syntaxcomment
?>
<HTML>
<?php
echo $this = "HELLO";
+ +
+ + + + $file_ary) - { - foreach ($file_ary as $file) - { - if (!($fp = fopen("{$phpbb_root_path}styles/$path$pathfile/$file", 'r'))) - { - trigger_error("Could not open {$phpbb_root_path}styles/$path/$pathfile/$file"); - } - $template_data = fread($fp, filesize("{$phpbb_root_path}styles/$path$pathfile/$file")); - fclose($fp); - - if (preg_match_all('##is', $template_data, $matches)) - { - foreach ($matches[1] as $match) - { - $includes[trim($match)][] = $file; - } - } - } - } - - foreach ($filelist as $pathfile => $file_ary) - { - foreach ($file_ary as $file) - { - // Skip index. - if (strpos($file, 'index.') === 0) - { - continue; - } - - // We could do this using extended inserts ... but that could be one - // heck of a lot of data ... - $sql_ary = array( - 'template_id' => $id, - 'template_filename' => $file, - 'template_included' => (!empty($includes[$file])) ? implode(':', $includes[$file]) . ':' : '', - 'template_mtime' => filemtime("{$phpbb_root_path}styles/$path$pathfile/$file"), - 'template_data' => implode('', file("{$phpbb_root_path}styles/$path$pathfile/$file")), - ); - - $sql = ($mode == 'insert') ? 'INSERT INTO ' . STYLES_TPLDATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary) : 'UPDATE ' . STYLES_TPLDATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary) . " WHERE template_id = $id AND template_filename = '" . $db->sql_escape($file) . "'"; - $db->sql_query($sql); - } - } -} - -function copy_files($src, $filelist, $dst) -{ - global $phpbb_root_path; - - if (!(is_writable("{$phpbb_root_path}styles"))) - { - return false; - } - - umask(0); - if (!file_exists("{$phpbb_root_path}styles/$dst")) - { - @mkdir("{$phpbb_root_path}styles/$dst", 0777); - chmod("{$phpbb_root_path}styles/$dst", 0777); - } - - @ksort($filelist); - foreach ($filelist as $filepath => $file_ary) - { - $filepath = (substr($filepath, 0, 1) != '/') ? "/$filepath" : $filepath; - - if ($filepath && !file_exists("{$phpbb_root_path}styles/$dst$filepath")) - { - @mkdir("{$phpbb_root_path}styles/$dst$filepath", 0777); - chmod("{$phpbb_root_path}styles/$dst$filepath", 0777); - } - - foreach ($file_ary as $file) - { - if (!file_exists("{$phpbb_root_path}styles/$dst$filepath$file")) - { - @rename("$src$filepath$file", "{$phpbb_root_path}styles/$dst$filepath$file"); - @chmod("{$phpbb_root_path}styles/$dst$filepath$file", 0777); - } - } - - if ($filepath && file_exists("$src$filepath")) - { - @rmdir("$src$filepath"); - } - } - - @rmdir("$src/$dst"); - @rmdir($src); -} - -function export($mode, $id) -{ - global $phpbb_root_path, $phpEx, $SID, $config, $db, $user; - - $update = (isset($_POST['update'])) ? true : false; - - $inc_template = (!empty($_POST['inc_template'])) ? true : false; - $inc_theme = (!empty($_POST['inc_theme'])) ? true : false; - $inc_imageset = (!empty($_POST['inc_imageset'])) ? true : false; - $format = (isset($_POST['format'])) ? htmlspecialchars($_POST['format']) : ''; - $store = (!empty($_POST['store'])) ? true : false; - - switch ($mode) - { - case 'style': - if ($update && $inc_template + $inc_theme + $inc_imageset < 2) - { - $error[] = $user->lang['STYLE_ERR_MORE_ELEMENTS']; - } - - $style_id = &$id; - $name = 'style_name'; - - $sql_select = 's.style_id, s.style_name, s.style_copyright'; - $sql_select .= ($inc_template) ? ', t.*' : ', t.template_name'; - $sql_select .= ($inc_theme) ? ', c.*' : ', c.theme_name'; - $sql_select .= ($inc_imageset) ? ', i.*' : ', i.imageset_name'; - $sql_from = STYLES_TABLE . ' s, ' . STYLES_TPL_TABLE . ' t, ' . STYLES_CSS_TABLE . ' c, ' . STYLES_IMAGE_TABLE . ' i'; - $sql_where = "s.style_id = $id AND t.template_id = s.template_id AND c.theme_id = s.theme_id AND i.imageset_id = s.imageset_id"; - - $l_prefix = 'STYLE'; - break; - - case 'template': - $template_id = &$id; - $name = 'template_name'; - - $sql_select = '*'; - $sql_from = STYLES_TPL_TABLE; - $sql_where = "template_id = $id"; - - $l_prefix = 'TEMPLATE'; - break; - - case 'theme': - $theme_id = &$id; - $name = 'theme_name'; - - $sql_select = '*'; - $sql_from = STYLES_CSS_TABLE; - $sql_where = "theme_id = $id"; - - $l_prefix = 'THEME'; - break; - - case 'imageset': - $imageset_id = &$id; - $name = 'imageset_name'; - - $sql_select = '*'; - $sql_from = STYLES_IMAGE_TABLE; - $sql_where = "imageset_id = $id"; - - $l_prefix = 'IMAGESET'; - break; - } - - // Lets do a merry dance ... either that or generate the archive - if ($update && !sizeof($error)) - { - $sql = "SELECT $sql_select - FROM $sql_from - WHERE $sql_where"; - $result = $db->sql_query($sql); - - if (!($style_row = ($db->sql_fetchrow($result)))) - { - trigger_error($user->lang['NO_' . $l_prefix]); - } - $db->sql_freeresult($result); - - $var_ary = array('style_id', 'style_name', 'style_copyright', 'template_id', 'template_name', 'template_path', 'template_copyright', 'template_storedb', 'bbcode_bitfield', 'theme_id', 'theme_name', 'theme_path', 'theme_copyright', 'theme_storedb', 'theme_mtime', 'theme_data', 'imageset_id', 'imageset_name', 'imageset_path', 'imageset_copyright'); - foreach ($var_ary as $var) - { - $$var = (!empty($style_row[$var])) ? $style_row[$var] : ''; - unset($style_row[$var]); - } - - $files = $data = array(); - - if ($mode == 'style') - { - $style_cfg = addslashes($style_name) . "\n"; - $style_cfg .= addslashes($style_copyright) . "\n"; - $style_cfg .= addslashes($config['version']) . "\n"; - $style_cfg .= ((!$inc_template) ? addslashes($template_name) : '') . "\n"; - $style_cfg .= ((!$inc_theme) ? addslashes($theme_name) : '') . "\n"; - $style_cfg .= ((!$inc_imageset) ? addslashes($imageset_name) : ''); - - $data[] = array( - 'src' => $style_cfg, - 'prefix' => 'style.cfg' - ); - unset($style_cfg); - } - - // Export template core code - if ($mode == 'template' || $inc_template) - { - $template_cfg = addslashes($template_name) . "\n"; - $template_cfg .= addslashes($template_copyright) . "\n"; - $template_cfg .= addslashes($config['version']) . "\n"; - $template_cfg .= addslashes($bbcode_bitfield); - - $data[] = array( - 'src' => $template_cfg, - 'prefix' => 'template/template.cfg' - ); - - // This is potentially nasty memory-wise ... - if (!$template_storedb) - { - $files[] = array( - 'src' => "styles/$template_path/template/", - 'prefix-' => "styles/$template_path/", - 'prefix+' => false, - 'exclude' => 'template.cfg' - ); - } - else - { - $sql = 'SELECT template_filename, template_data - FROM ' . STYLES_TPLDATA_TABLE . " - WHERE template_id = $template_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $data[] = array( - 'src' => $row['template_data'], - 'prefix' => 'template/' . $row['template_filename'] - ); - } - $db->sql_freeresult($result); - } - unset($template_cfg); - } - - // Export theme core code - if ($mode == 'theme' || $inc_theme) - { - $theme_cfg = addslashes($theme_name) . "\n"; - $theme_cfg .= addslashes($theme_copyright) . "\n"; - $theme_cfg .= addslashes($config['version']); - - $files[] = array( - 'src' => "styles/$theme_path/theme/", - 'prefix-' => "styles/$theme_path/", - 'prefix+' => false, - 'exclude' => ($theme_storedb) ? 'stylesheet.css,theme.cfg' : 'theme.cfg' - ); - - $data[] = array( - 'src' => $theme_cfg, - 'prefix' => 'theme/theme.cfg' - ); - - if ($theme_storedb) - { - $data[] = array( - 'src' => $theme_data, - 'prefix' => 'theme/stylesheet.css' - ); - } - unset($theme_data); - unset($theme_cfg); - } - - // Export imageset core code - if ($mode == 'imageset' || $inc_imageset) - { - $imageset_cfg = addslashes($imageset_name) . "\n"; - $imageset_cfg .= addslashes($imageset_copyright) . "\n"; - $imageset_cfg .= addslashes($config['version']); - - foreach (array_keys($style_row) as $key) - { - $imageset_cfg .= $key . '||' . str_replace("styles/$imageset_path/imageset/", '{PATH}', $style_row[$key]) . "\n"; - unset($style_row[$key]); - } - - $files[] = array( - 'src' => "styles/$imageset_path/imageset/", - 'prefix-' => "styles/$imageset_path/", - 'prefix+' => false, - 'exclude' => 'imageset.cfg' - ); - - $data[] = array( - 'src' => trim($imageset_cfg), - 'prefix' => 'imageset/imageset.cfg' - ); - unset($imageset_cfg); - } - - switch ($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: - $error[] = $user->lang[$l_prefix . '_ERR_ARCHIVE']; - } - - if (!sizeof($error)) - { - include($phpbb_root_path . 'includes/functions_compress.'.$phpEx); - - $path = str_replace(' ', '_', $$name); - - if (!($zip = new $compress('w', "{$phpbb_root_path}store/$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['prefix+'], $file_ary['exclude']); - } - } - - if ($data) - { - foreach ($data as $data_ary) - { - $zip->add_data($data_ary['src'], $data_ary['prefix']); - } - } - - $zip->close(); - - add_log('admin', 'LOG_EXPORT_' . $l_prefix, $$name); - - if (!$store) - { - header('Pragma: no-cache'); - header("Content-Type: application/$mimetype; name=\"$path.$ext\""); - header("Content-disposition: attachment; filename=$path.$ext"); - - $fp = fopen("{$phpbb_root_path}store/$path.$ext", 'rb'); - while ($buffer = fread($fp, 1024)) - { - echo $buffer; - } - fclose($fp); - @unlink("{$phpbb_root_path}store/$path.$ext"); - exit; - } - - trigger_error(sprintf($user->lang[$l_prefix . '_EXPORTED'], "store/$path.$ext")); - } - } - else - { - $sql = "SELECT {$mode}_id, {$mode}_name - FROM " . (($mode == 'style') ? STYLES_TABLE : $sql_from) . " - WHERE {$mode}_id = $id"; - $result = $db->sql_query($sql); - - if (!extract($db->sql_fetchrow($result))) - { - trigger_error($user->lang['NO_' . $l_prefix]); - } - $db->sql_freeresult($result); - } - - // Output list - 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['INCLUDE_TEMPLATE']; ?>: lang['YES']; ?>    lang['NO']; ?>
lang['INCLUDE_THEME']; ?>: lang['YES']; ?>    lang['NO']; ?>
lang['INCLUDE_IMAGESET']; ?>: lang['YES']; ?>    lang['NO']; ?>
lang['DOWNLOAD_STORE']; ?>:
lang['DOWNLOAD_STORE_EXPLAIN']; ?>
lang['EXPORT_STORE']; ?>    lang['EXPORT_DOWNLOAD']; ?>
lang['ARCHIVE_FORMAT']; ?>: .tar   'zlib', 'tar.bz2' => 'bz2', 'zip' => 'zlib'); - - foreach ($compress_types as $type => $module) - { - if (!extension_loaded($module)) - { - break; - } - echo ' .' . $type . '  '; - } - -?>
  
- - - - - - - - - - - - - - - - - - - - - - -

h1

h2

h3

mainmenu
 
- - - - -
titles -
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
th
cattitle / catcatdiv
topictitle / row1topicauthor / row2topicdetails / row1
row3
spacer
postdetails / row2postbody / row1 posthilit
- -

- - - - - - - - - - -
gengenmedgensmall
copyright phpBB
- -

- -
- - - - - - - - - - - - - - -
- -

- - - - - - - - - - - - - - -
postbody / bold italic underline
- - - -
A_N_Other wrote:
quote
- - - - - - -
Code:
10 Print "hello"
20 Goto 10
- - - - - - -
PHP:
// syntaxcomment
?>
<HTML>
<?php
echo $this = "HELLO";
- -
- - - - \ No newline at end of file