From 71dbb2c97ef9a2f4cef29c161a699f161e1948ac Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Mon, 11 Aug 2003 00:52:09 +0000 Subject: unified remove ... probably breaking other stuff in the process git-svn-id: file:///svn/phpbb/trunk@4372 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_styles.php | 2458 +++++++++++++++++++++----------------------- 1 file changed, 1176 insertions(+), 1282 deletions(-) (limited to 'phpBB/adm/admin_styles.php') 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') + { + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_style = $new_id + WHERE user_style = $id"; + $db->sql_query($sql); + } + else { - $filelist = filelist("{$phpbb_root_path}styles/$path/{$type}", '', '*'); - krsort($filelist); + $sql = "UPDATE $table + SET {$type}_id = $new_id + WHERE {$type}_id = $id"; + $db->sql_query($sql); - foreach ($filelist as $subpath => $file_ary) + if ($deletefs && is_writeable("{$phpbb_root_path}styles/$path/{$type}")) { - $subpath = "{$phpbb_root_path}styles/$path/{$type}$subpath"; - foreach ($file_ary as $file) + $filelist = filelist("{$phpbb_root_path}styles/$path/{$type}", '', '*'); + krsort($filelist); + + foreach ($filelist as $subpath => $file_ary) { -/* if (!@unlink("$subpath/$file")) + $subpath = "{$phpbb_root_path}styles/$path/{$type}$subpath"; + foreach ($file_ary as $file) { - $onfs = 1; - }*/ - } +/* if (!@unlink("$subpath$file")) + { + $onfs = 1; + } +*/ } -/* if (!@rmdir($subpath)) - { - $onfs = 1; - }*/ +/* if (!@rmdir($subpath)) + { + $onfs = 1; + } +*/ } + } + else + { + $onfs = (file_exists("{$phpbb_root_path}styles/$path/{$type}")) ? 1 : 0; } - } - else - { - $onfs = (file_exists("{$phpbb_root_path}styles/$path/{$type}") && !is_writeable("{$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']; ?>

-
"> +">
- + - + $file_ary) - { - foreach ($file_ary as $file) - { - @unlink("$path$filepath$file"); - } + $update = (isset($_POST['update'])) ? true : false; - if (file_exists("$path$filepath")) - { - @rmdir("$path$filepath"); - } - } - @rmdir("$path"); -} + $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; -function details($type, $mode, $action, $id) -{ - global $phpbb_root_path, $phpEx, $SID, $config, $db, $user; - global $archive_preg, $safe_mode; + switch ($mode) + { + case 'style': + if ($update && $inc_template + $inc_theme + $inc_imageset < 2) + { + $error[] = $user->lang['STYLE_ERR_MORE_ELEMENTS']; + } - $update = (!empty($_POST['update'])) ? true : false; + $style_id = &$id; + $name = 'style_name'; - switch ($type) - { - case 'theme': - $table = STYLES_CSS_TABLE; + $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': - $table = STYLES_TPL_TABLE; + $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': - $table = STYLES_IMAGE_TABLE; + $imageset_id = &$id; + $name = 'imageset_name'; + + $sql_select = '*'; + $sql_from = STYLES_IMAGE_TABLE; + $sql_where = "imageset_id = $id"; + + $l_prefix = 'IMAGESET'; break; } - $l_type = strtoupper($type); - $l_prefix = ($action == 'add') ? 'ADD' : (($action == 'details') ? 'EDIT_DETAILS' : 'INSTALL'); - - // Do we want to edit an existing theme or are we creating a new theme - // or submitting an existing one? - if (!$update) + // Lets do a merry dance ... either that or generate the archive + if ($update && !sizeof($error)) { - if ($id) - { - $sql = "SELECT * - FROM $table - WHERE {$type}_id = $id"; - $result = $db->sql_query($sql); + $sql = "SELECT $sql_select + FROM $sql_from + WHERE $sql_where"; + $result = $db->sql_query($sql); - if (!($row = $db->sql_fetchrow($result))) - { - trigger_error($user->lang['NO_' . $l_type]); - } - $db->sql_freeresult($result); + if (!($style_row = ($db->sql_fetchrow($result)))) + { + trigger_error($user->lang['NO_' . $l_prefix]); + } + $db->sql_freeresult($result); - $name = (!empty($row[$type . '_name'])) ? $row[$type . '_name'] : ''; - $copyright = (!empty($row[$type . '_copyright'])) ? $row[$type . '_copyright'] : ''; - $path = (!empty($row[$type . '_path'])) ? $row[$l_type . '_path'] : ''; - $storedb = (!empty($row[$type . '_storedb'])) ? $type[$type . '_storedb'] : ''; - $data = (!empty($row[$type . '_data'])) ? $row[$type . '_data'] : ''; - unset($row); + $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(); - $s_hidden_fields = ''; + 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); } - else if ($action == 'install') + + // Export template core code + if ($mode == 'template' || $inc_template) { - if (empty($_GET['name'])) - { - trigger_error($user->lang[$l_type . '_ERR_NO_NAME']); - } + $template_cfg = addslashes($template_name) . "\n"; + $template_cfg .= addslashes($template_copyright) . "\n"; + $template_cfg .= addslashes($config['version']) . "\n"; + $template_cfg .= addslashes($bbcode_bitfield); - $path = trim(htmlspecialchars($_GET['name'])); - if (!file_exists("{$phpbb_root_path}styles/$path/$type/$type.cfg")) + $data[] = array( + 'src' => $template_cfg, + 'prefix' => 'template/template.cfg' + ); + + // This is potentially nasty memory-wise ... + if (!$template_storedb) { - trigger_error($user->lang['NO_' . $l_type]); + $files[] = array( + 'src' => "styles/$template_path/template/", + 'prefix-' => "styles/$template_path/", + 'prefix+' => false, + 'exclude' => 'template.cfg' + ); } - - if (!($cfg = file("{$phpbb_root_path}styles/$path/$type/$type.cfg"))) + else { - trigger_error($user->lang['NO_' . $l_type]); + $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); + } - $name = trim($cfg[0]); - $copyright = trim($ecfg[1]); - $version = preg_replace('#^2\.([0-9]+?)\.([0-9]+?).*?$#', '\1.\2', trim($cfg[2])); - $phpbbversion = preg_replace('#^2\.([0-9]+?)\.([0-9]+?).*?$#', '\1.\2', $config['version']); + // 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']); - if ($version != $phpbbversion) + $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) { - $error[] = $user->lang[$l_type . '_VERSION_DIFF']; + $data[] = array( + 'src' => $theme_data, + 'prefix' => 'theme/stylesheet.css' + ); } - - $s_hidden_fields = ''; + unset($theme_data); + unset($theme_cfg); } - else - { - $name = (!empty($_POST['name'])) ? htmlspecialchars(stripslashes($_POST['name'])) : ''; - $copyright = (!empty($_POST['copyright'])) ? htmlspecialchars(stripslashes($_POST['copyright'])) : ''; - $storedb = (!empty($_POST['storedb'])) ? 1 : (($safe_mode) ? 1 : 0); - $basis = (!empty($_POST['basis'])) ? intval($_POST['basis']) : false; - $path = (!empty($_POST['path'])) ? htmlspecialchars(stripslashes($_POST['path'])) : ''; - $s_hidden_fields = (!empty($_POST['basis'])) ? '' : ''; - if ($path) + // 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) { - $s_hidden_fields .= ''; + $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); } - } - // Do the update thang - if ($update) - { - if (!$safe_mode && $action == 'add' && is_writeable("{$phpbb_root_path}styles") && (!empty($_FILES['upload_file']['name']) || !empty($_POST['import_file']))) + switch ($format) { - if (!empty($_FILES['upload_file']['name'])) - { - $realname = htmlspecialchars($_FILES['upload_file']['name']); - $filename = htmlspecialchars($_FILES['upload_file']['tmp_name']); + case 'tar': + $ext = 'tar'; + $mimetype = 'x-tar'; + $compress = 'compress_tar'; + break; - if (!is_uploaded_file($filename)) + case 'zip': + if (!extension_loaded('zlib')) { - trigger_error("$filename was not uploaded"); + trigger_error($user->lang['NO_SUPPORT_ZIP']); } - } - else - { - $realname = htmlspecialchars($_POST['import_file']); - $filename = "{$phpbb_root_path}store/$realname"; - } + $ext = 'zip'; + $mimetype = 'zip'; + $compress = 'compress_zip'; + break; - if (!preg_match('#(' . $archive_preg . ')$#i', $realname, $match)) + 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"))) { - $error[] = sprintf($user->lang['UPLOAD_WRONG_TYPE'], $archive_types); + trigger_error($user->lang['STORE_UNWRITEABLE']); } - $path = preg_replace('#^(.*?)' . preg_quote($match[0]) . '$#', '\1', $realname); - // Attempt to extract the files to a temporary directory in store - $tmp_path = $phpbb_root_path . 'store/tmp_' . substr(uniqid(''), 0, 10) . '/'; - if (!@mkdir($tmp_path)) + if ($files) { - trigger_error("Cannot create $tmp_path"); + foreach ($files as $file_ary) + { + $zip->add_file($file_ary['src'], $file_ary['prefix-'], $file_ary['prefix+'], $file_ary['exclude']); + } } - include($phpbb_root_path . 'includes/functions_compress.'.$phpEx); - - switch ($match[0]) + if ($data) { - case '.zip': - $zip = new compress_zip('r', $filename); - break; - default: - $zip = new compress_tar('r', $filename, $match[0]); + foreach ($data as $data_ary) + { + $zip->add_data($data_ary['src'], $data_ary['prefix']); + } } - $zip->extract($tmp_path); + $zip->close(); - $filelist = filelist($tmp_path, '', '*'); + add_log('admin', 'LOG_EXPORT_' . $l_prefix, $$name); - if (!in_array($type . '.cfg', $filelist['/' . $type])) + if (!$store) { - trigger_error($user->lang[$l_type . '_ERR_NOT_' . $l_type]); + 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; } - $cfg = file("$tmp_path$type/$type.cfg"); - $name = trim($cfg[0]); - $copyright = trim($cfg[1]); - $version = trim($cfg[2]); - unset($cfg); + trigger_error(sprintf($user->lang[$l_prefix . '_EXPORTED'], "store/$path.$ext")); } - else if ($action == 'install') - { - // NOT CONSISTENT WITH style installation - $path = (!empty($_POST['path'])) ? htmlspecialchars($_POST['path']) : ''; - - if (!($cfg = file("{$phpbb_root_path}styles/$path/$type/$type.cfg"))) - { - trigger_error($user->lang['NO_' . $l_type]); - } - - $name = trim($cfg[0]); - $copyright = trim($cfg[1]); - $version = trim($cfg[2]); - $storedb = (!empty($_POST['storedb'])) ? 1 : 0; - - unset($cfg); - } - else - { - $name = (!empty($_POST['name'])) ? htmlspecialchars($_POST['name']) : ''; - $copyright = (!empty($_POST['copyright'])) ? htmlspecialchars($_POST['copyright']) : ''; - $storedb = (!empty($_POST['storedb'])) ? 1 : 0; - } - - $sql_where = ($action == 'add' || $action == 'install') ? "WHERE {$type}_name = '" . $db->sql_escape($name) . "'" : "WHERE {$type}_id <> $id AND {$type}_name = '" . $db->sql_escape($name) . "'"; - $sql = "SELECT {$type}_name - FROM $table - $sql_where"; + } + else + { + $sql = "SELECT {$mode}_id, {$mode}_name + FROM " . (($mode == 'style') ? STYLES_TABLE : $sql_from) . " + WHERE {$mode}_id = $id"; $result = $db->sql_query($sql); - if ($row = $db->sql_fetchrow($result)) + if (!extract($db->sql_fetchrow($result))) { - $error[] = $user->lang[$l_type . '_ERR_NAME_EXIST']; + trigger_error($user->lang['NO_' . $l_prefix]); } $db->sql_freeresult($result); - unset($row); - - if (empty($name)) - { - $error[] = $user->lang[$l_type . '_ERR_STYLE_NAME']; - } - - if (strlen($name) > 30) - { - $error[] = $user->lang[$l_type . '_ERR_NAME_LONG']; - } - - if (!preg_match('#^[a-z0-9_\-\+\. ]+$#i', $name)) - { - $error[] = $user->lang[$l_type . '_ERR_NAME_CHARS']; - } - - if (strlen($copyright) > 60) - { - $error[] = $user->lang[$l_type . '_ERR_COPY_LONG']; - } - - if (!sizeof($error)) - { - $css_data = ''; - if ($action == 'install') - { - switch ($type) - { - case 'theme': - if (!is_writeable("{$phpbb_root_path}styles/$path/$type/stylesheet.css")) - { - $storedb = 1; - if (!($css_data = implode('', file("{$phpbb_root_path}styles/$path/$type/stylesheet.css")))) - { - trigger_error($user->lang['NO_THEME']); - } - } - break; - - case 'template': - $filelist = filelist("{$phpbb_root_path}styles/$path/$type", '', 'html'); - if (!is_writeable("{$phpbb_root_path}styles/$path/$type")) - { - $storedb = 1; - } - break; - - case 'imageset': - if (!($cfg = file("{$phpbb_root_path}styles/$path/$type/imageset.cfg"))) - { - trigger_error($user->lang['NO_IMAGESET']); - } - - for ($i = 3; $i < sizeof($cfg); $i++) - { - $tmp = explode('||', $cfg[$i]); - $sql_img_ary[$tmp[0]] = str_replace('{PATH}', "styles/$path/$type/", trim($tmp[1])); - } - unset($cfg); - break; - } - } - - - - if ($action == 'add' && !$safe_mode && is_writeable("{$phpbb_root_path}styles")) - { - umask(0); - if (@mkdir("{$phpbb_root_path}styles/$path", 0777)) - { - @chmod("{$phpbb_root_path}styles/$path", 0777); - } - - if (@mkdir("{$phpbb_root_path}styles/$path/$type", 0777)) - { - if (!@chmod("{$phpbb_root_path}styles/$path/$type", 0777)) - { - $storedb = 1; - } - } - - - - - if (!empty($_FILES['upload_file']) || !empty($_POST['import_file'])) - { - // TODO - // mkdir, rmdir and rename error catching - ksort($filelist); - foreach ($filelist as $filepath => $file_ary) - { - if ($path && !file_exists("{$phpbb_root_path}styles/$path$filepath")) - { - @mkdir("{$phpbb_root_path}styles/$path$filepath", 0777); - } - - foreach ($file_ary as $file) - { - @rename("$tmp_path$filepath/$file", "{$phpbb_root_path}styles/$path$filepath/$file"); - } - - if ($filepath && file_exists("$tmp_path$filepath")) - { - @rmdir("$tmp_path$filepath"); - } - } - - @rmdir("$tmp_path/$type"); - @rmdir($tmp_path); - } - else if ($basis && !$storedb && !$safe_mode) - { - switch ($type) - { - case 'theme': - $sql = "SELECT theme_name, theme_path, theme_storedb, css_data - FROM $table - WHERE theme_id = $basis"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $css_data = ($row['storedb']) ? $row['css_data'] : implode('', file($phpbb_root_path . 'styles/' . $row['theme_path'] . "/$type/stylesheet.css")); - - if (!$storedb && ($fp = @fopen("{$phpbb_root_path}styles/$path/$type/stylesheet.css", 'wb'))) - { - $storedb = (@fwrite($fp, $css_data)) ? 0 : 1; - - if (!$storedb) - { - unset($css_data); - - // Get a list of all files and folders in the basis themes folder - $filelist = filelist($phpbb_root_path . 'styles/' . $row['theme_path'] . '/' . $type, '', '*'); - - // Copy every file bar the original stylesheet - foreach ($filelist as $filepath => $file_ary) - { - foreach ($file_ary as $file) - { - if ($file == 'stylesheet.css') - { - continue; - } - - if (!file_exists("{$phpbb_root_path}styles/$path/$type/$filepath")) - { - @mkdir("{$phpbb_root_path}styles/$path/$type/$filepath"); - } - @copy("{$phpbb_root_path}styles/" . $row['theme_path'] . "/$type/$filepath/$file", "{$phpbb_root_path}styles/$path/$type/$filepath/$file"); - } - } - unset($filelist); - } - } - else - { - $storedb = 1; - } - @fclose($fp); - } - $db->sql_freeresult($result); - break; - - case 'template': - $sql = "SELECT theme_name, theme_path, theme_storedb, css_data - FROM $table - WHERE theme_id = $basis"; - $result = $db->sql_query($sql); - - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - if (!$row) - { - $error = $user->lang['NO_TEMPLATE']; - break; - } - - if (!is_writeable("{$phpbb_root_path}styles/$path/$type")) - { - $storedb = 1; - } - - if ($row['template_storedb']) - { - } - break; - - case 'imageset': - $sql = "SELECT imageset_name, imageset_path - FROM $table - WHERE imageset_id = $basis"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - // Get a list of all files and folders - $filelist = filelist("{$phpbb_root_path}styles/" . $row['imageset_path'] . '/imageset/', '', '*'); + } - // Copy every file - foreach ($filelist as $pathfile => $file_ary) - { - foreach ($file_ary as $file) - { - if (!file_exists("{$phpbb_root_path}styles/$path/$type/$pathfile")) - { - @mkdir("{$phpbb_root_path}styles/$path/$type/$pathfile"); - } - @copy("{$phpbb_root_path}styles/" . $row['imageset_path'] . "/$type$pathfile/$file", "{$phpbb_root_path}styles/$path/$type$pathfile/$file"); - } - } - unset($filelist); - } - $db->sql_freeresult($result); - break; - } - } - } + // Output list + adm_page_header($user->lang[$l_prefix . '_EXPORT']); - // Build relevant array ... we need to do this in bits depending on the - // action and type - $sql_ary = array( - $type . '_name' => $name, - ); +?> +

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

- if ($action == 'add' || $action == 'install') - { - $sql_ary += array( - $type . '_copyright'=> $copyright, - $type . '_path' => $path, - ); +

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

- switch ($type) - { - case 'theme': - $sql_ary += array( - $type . '_mtime' => ($storedb) ? filemtime("{$phpbb_root_path}styles/$path/$type/stylesheet.css") : 0, - $type . '_storedb' => $storedb, - $type . '_data' => ($storedb) ? $css_data : '', - ); - break; - case 'template': - $sql_ary += array( - $type . '_storedb' => $storedb, - ); - break; - } - } +">
lang['DELETE_' . $l_prefix]; ?>
lang[$l_prefix . '_NAME']; ?>:
Delete from filesystem:lang['DELETE_FROM_FS']; ?>: lang['YES']; ?>   lang['NO']; ?>
+ + +sql_query($sql); + if (sizeof($error)) + { - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); +?> + + + + + + + + + ($storedb) ? filemtime("{$phpbb_root_path}styles/$path/$type/stylesheet.css") : 0, - $type . '_storedb' => $storedb, - $type . '_data' => ($storedb) ? $css_data : '', - ); - break; - - case 'template': - $filelist = filelist("{$phpbb_root_path}styles/$path/template", '', 'html'); + if ($mode == 'style') + { - if (!$storedb && !$safe_mode && is_writeable("{$phpbb_root_path}styles/$path/template")) - { - $sql = 'SELECT * - FROM ' . STYLES_TPLDATA_TABLE . " - WHERE template_id = $id"; - $result = $db->sql_query($sql); +?> + + + + + + + + + + + + +sql_fetchrow($result)) - { - if (!($fp = fopen("{$phpbb_root_path}styles/$path/template/" . $row['template_filename'], 'wb'))) - { - $storedb = 1; - break; - } + } - if (!fwrite($fp, $row['template_data'])) - { - $storedb = 1; - break; - } +?> + + + + + + + + + + + +
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'); - } - $db->sql_freeresult($result); + foreach ($compress_types as $type => $module) + { + if (!extension_loaded($module)) + { + break; + } + echo ' .' . $type . '  '; + } - if (!$storedb) - { - $sql = 'DELETE FROM ' . STYLES_TPLDATA_TABLE . " - WHERE template_id = $id"; - $db->sql_query($sql); - } - } +?>
  
+ $storedb, - ); - break; - } - } - } + adm_page_footer(); - $db->sql_transaction('begin'); +} - $sql = ($action == 'add' || $action == 'install') ? "INSERT INTO $table " . $db->sql_build_array('INSERT', $sql_ary) : "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE {$type}_id = $id"; - $db->sql_query($sql); +function store_templates($mode, $id, $path, $filelist) +{ + global $phpbb_root_path, $phpEx, $db; - if ($type == 'template' && $storedb) + $includes = array(); + foreach ($filelist as $pathfile => $file_ary) + { + foreach ($file_ary as $file) + { + if (!($fp = fopen("{$phpbb_root_path}styles/$path$pathfile/$file", 'r'))) { - $filelist = array('/template' => $filelist['']); + 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 (!$id) + if (preg_match_all('##is', $template_data, $matches)) + { + foreach ($matches[1] as $match) { - $id = $db->sql_nextid(); + $includes[trim($match)][] = $file; } + } + } + } - store_templates('insert', $id, $path, $filelist); + foreach ($filelist as $pathfile => $file_ary) + { + foreach ($file_ary as $file) + { + // Skip index. + if (strpos($file, 'index.') === 0) + { + continue; } - $db->sql_transaction('commit'); + // 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")), + ); - $message = ($action == 'add' || $action == 'install') ? (($storedb) ? $l_prefix . '_DB_ADDED' : $l_prefix . '_FS_ADDED') : $l_prefix . '_DETAILS_UPDATE'; - $log = ($action == 'add' || $action == 'install') ? (($storedb) ? 'LOG_ADD_' . $l_prefix . '_DB' : 'LOG_ADD_' . $l_prefix . '_FS') : 'LOG_EDIT_' . $l_prefix . '_DETAILS'; + $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); + } + } +} - add_log('admin', $log, $_name); - trigger_error($user->lang[$message]); +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); } - - // If we were uploading or importing and an error occured we delete - // the temporary files - if (!empty($_FILES['upload_file']) || !empty($_POST['import_file'])) + foreach ($file_ary as $file) { - // TODO - // mkdir, rmdir and rename error catching - ksort($filelist); - foreach ($filelist as $filepath => $file_ary) + if (!file_exists("{$phpbb_root_path}styles/$dst$filepath$file")) { - foreach ($file_ary as $file) - { - @unlink("$tmp_path$filepath/$file"); - } - - if ($filepath && file_exists("$tmp_path$filepath")) - { - @rmdir("$tmp_path$filepath"); - } + @rename("$src$filepath$file", "{$phpbb_root_path}styles/$dst$filepath$file"); + @chmod("{$phpbb_root_path}styles/$dst$filepath$file", 0777); } + } - @rmdir("$tmp_path/$type"); - @rmdir($tmp_path); + if ($filepath && file_exists("$src$filepath")) + { + @rmdir("$src$filepath"); + } + } + + @rmdir("$src/$dst"); + @rmdir($src); +} + +function cleanup_folder($path) +{ + $filelist = filelist($path, '', '*'); + + krsort($filelist); + foreach ($filelist as $filepath => $file_ary) + { + foreach ($file_ary as $file) + { + @unlink("$path$filepath$file"); + } + + if (file_exists("$path$filepath")) + { + @rmdir("$path$filepath"); } } + @rmdir("$path"); +} +// +// FUNCTIONS +// --------- - $storedb_no = (!$storedb) ? ' checked="checked"' : ''; - $storedb_yes = ($storedb) ? ' checked="checked"' : ''; - - // Output the page - adm_page_header($user->lang[$l_prefix . '_' . $l_type]); +// Hopefully temporary +function theme_preview(&$path, &$stylesheet, &$class, &$css_element) +{ + global $config, $user; ?> + + + + + + + + + + + + + + + + + + - + - - } +

h1

h2

h3

mainmenu
', $error); ?> 
+ + +
titles +
-?> + - - + +
lang[$l_type . '_NAME']; ?>:' : "$name"; +
-?> + + + - - + + - - - + + + - + + + + + + + + + + +
th
lang['COPYRIGHT']; ?>:cattitle / catcatdiv
lang[$l_type . '_LOCATION']; ?>:
lang[$l_type . '_LOCATION_EXPLAIN']; ?>
/> lang['STORE_FILESYSTEM']; ?>   /> lang['STORE_DATABASE']; ?>topictitle / row1topicauthor / row2topicdetails / row1
row3
spacer
postdetails / row2postbody / row1 posthilit
- } +

- // Import, upload and basis options - if ($action == 'add' && !$safe_mode && is_writeable("{$phpbb_root_path}styles")) - { - $store_options = ''; - $dp = opendir("{$phpbb_root_path}store"); - while ($file = readdir($dp)) - { - if ($file{0} != '.' && preg_match('#(' . $archive_preg . ')$#i', $file)) - { - $store_options .= ""; - } - } - closedir($dp); + + + + + + + + + +
gengenmedgensmall
copyright phpBB
- $store_options = '' . $store_options; +

- $sql = "SELECT {$type}_id, {$type}_name - FROM $table"; - $result = $db->sql_query($sql); +
+ + + + + + + + + + + + + + +
- $basis_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - $selected = (!empty($_POST['basis']) && $_POST['basis'] == $row[$type . '_id']) ? ' selected="selected"' : ''; - $basis_options .= ''; - } - $db->sql_freeresult($result); +

-?> + - + - - + - - + - - + - - } +
-?> - - - -
lang[$l_type . '_BASIS']; ?>postbody / bold italic underline
lang[$l_type . '_EXISTING_BASIS']; ?>: + + + +
A_N_Other wrote:
quote
lang[$l_type . '_UPLOAD_BASIS']; ?>:
lang['ALLOWED_FILETYPES']; ?>:
+ + + + + + +
Code:
10 Print "hello"
20 Goto 10
lang[$l_type . '_IMPORT_BASIS']; ?>: + + + + + + +
PHP:
// syntaxcomment
?>
<HTML>
<?php
echo $this = "HELLO";
  
+ + $file_ary) - { - foreach ($file_ary as $file) + + + + + + + + + + +function details($type, $mode, $action, $id) +{ + global $phpbb_root_path, $phpEx, $SID, $config, $db, $user; + global $archive_preg, $safe_mode; + + $update = (!empty($_POST['update'])) ? true : false; + + switch ($type) + { + case 'theme': + $table = STYLES_CSS_TABLE; + break; + + case 'template': + $table = STYLES_TPL_TABLE; + break; + + case 'imageset': + $table = STYLES_IMAGE_TABLE; + break; + } + + $l_type = strtoupper($type); + $l_prefix = ($action == 'add') ? 'ADD' : (($action == 'details') ? 'EDIT_DETAILS' : 'INSTALL'); + + // Do we want to edit an existing theme or are we creating a new theme + // or submitting an existing one? + if (!$update) + { + if ($id) + { + $sql = "SELECT * + FROM $table + WHERE {$type}_id = $id"; + $result = $db->sql_query($sql); + + if (!($row = $db->sql_fetchrow($result))) + { + trigger_error($user->lang['NO_' . $l_type]); + } + $db->sql_freeresult($result); + + $name = (!empty($row[$type . '_name'])) ? $row[$type . '_name'] : ''; + $copyright = (!empty($row[$type . '_copyright'])) ? $row[$type . '_copyright'] : ''; + $path = (!empty($row[$type . '_path'])) ? $row[$l_type . '_path'] : ''; + $storedb = (!empty($row[$type . '_storedb'])) ? $type[$type . '_storedb'] : ''; + $data = (!empty($row[$type . '_data'])) ? $row[$type . '_data'] : ''; + unset($row); + + $s_hidden_fields = ''; + } + else if ($action == 'install') { - if (!($fp = fopen("{$phpbb_root_path}styles/$path$pathfile/$file", 'r'))) + if (empty($_GET['name'])) { - trigger_error("Could not open {$phpbb_root_path}styles/$path/$pathfile/$file"); + trigger_error($user->lang[$l_type . '_ERR_NO_NAME']); } - $template_data = fread($fp, filesize("{$phpbb_root_path}styles/$path$pathfile/$file")); - fclose($fp); - if (preg_match_all('##is', $template_data, $matches)) + $path = trim(htmlspecialchars($_GET['name'])); + if (!file_exists("{$phpbb_root_path}styles/$path/$type/$type.cfg")) { - foreach ($matches[1] as $match) - { - $includes[trim($match)][] = $file; - } + trigger_error($user->lang['NO_' . $l_type]); } - } - } - foreach ($filelist as $pathfile => $file_ary) - { - foreach ($file_ary as $file) - { - // Skip index. - if (strpos($file, 'index.') === 0) + if (!($cfg = file("{$phpbb_root_path}styles/$path/$type/$type.cfg"))) { - continue; + trigger_error($user->lang['NO_' . $l_type]); } - // 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); - } + $name = trim($cfg[0]); + $copyright = trim($ecfg[1]); + $version = preg_replace('#^2\.([0-9]+?)\.([0-9]+?).*?$#', '\1.\2', trim($cfg[2])); + $phpbbversion = preg_replace('#^2\.([0-9]+?)\.([0-9]+?).*?$#', '\1.\2', $config['version']); - @ksort($filelist); - foreach ($filelist as $filepath => $file_ary) - { - $filepath = (substr($filepath, 0, 1) != '/') ? "/$filepath" : $filepath; + if ($version != $phpbbversion) + { + $error[] = $user->lang[$l_type . '_VERSION_DIFF']; + } - 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); + $s_hidden_fields = ''; } - - foreach ($file_ary as $file) + else { - if (!file_exists("{$phpbb_root_path}styles/$dst$filepath$file")) + $name = (!empty($_POST['name'])) ? htmlspecialchars(stripslashes($_POST['name'])) : ''; + $copyright = (!empty($_POST['copyright'])) ? htmlspecialchars(stripslashes($_POST['copyright'])) : ''; + $storedb = (!empty($_POST['storedb'])) ? 1 : (($safe_mode) ? 1 : 0); + $basis = (!empty($_POST['basis'])) ? intval($_POST['basis']) : false; + $path = (!empty($_POST['path'])) ? htmlspecialchars(stripslashes($_POST['path'])) : ''; + + $s_hidden_fields = (!empty($_POST['basis'])) ? '' : ''; + if ($path) { - @rename("$src$filepath$file", "{$phpbb_root_path}styles/$dst$filepath$file"); - @chmod("{$phpbb_root_path}styles/$dst$filepath$file", 0777); + $s_hidden_fields .= ''; } } - - 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) + // Do the update thang + if ($update) { - case 'style': - if ($update && $inc_template + $inc_theme + $inc_imageset < 2) + if (!$safe_mode && $action == 'add' && is_writeable("{$phpbb_root_path}styles") && (!empty($_FILES['upload_file']['name']) || !empty($_POST['import_file']))) + { + if (!empty($_FILES['upload_file']['name'])) { - $error[] = $user->lang['STYLE_ERR_MORE_ELEMENTS']; - } - - $style_id = &$id; - $name = 'style_name'; + $realname = htmlspecialchars($_FILES['upload_file']['name']); + $filename = htmlspecialchars($_FILES['upload_file']['tmp_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"; + if (!is_uploaded_file($filename)) + { + trigger_error("$filename was not uploaded"); + } + } + else + { + $realname = htmlspecialchars($_POST['import_file']); + $filename = "{$phpbb_root_path}store/$realname"; + } - $l_prefix = 'STYLE'; - break; + if (!preg_match('#(' . $archive_preg . ')$#i', $realname, $match)) + { + $error[] = sprintf($user->lang['UPLOAD_WRONG_TYPE'], $archive_types); + } + $path = preg_replace('#^(.*?)' . preg_quote($match[0]) . '$#', '\1', $realname); - case 'template': - $template_id = &$id; - $name = 'template_name'; + // Attempt to extract the files to a temporary directory in store + $tmp_path = $phpbb_root_path . 'store/tmp_' . substr(uniqid(''), 0, 10) . '/'; + if (!@mkdir($tmp_path)) + { + trigger_error("Cannot create $tmp_path"); + } - $sql_select = '*'; - $sql_from = STYLES_TPL_TABLE; - $sql_where = "template_id = $id"; + include($phpbb_root_path . 'includes/functions_compress.'.$phpEx); - $l_prefix = 'TEMPLATE'; - break; + switch ($match[0]) + { + case '.zip': + $zip = new compress_zip('r', $filename); + break; + default: + $zip = new compress_tar('r', $filename, $match[0]); + } + $zip->extract($tmp_path); + $zip->close(); - case 'theme': - $theme_id = &$id; - $name = 'theme_name'; + $filelist = filelist($tmp_path, '', '*'); - $sql_select = '*'; - $sql_from = STYLES_CSS_TABLE; - $sql_where = "theme_id = $id"; + if (!in_array($type . '.cfg', $filelist['/' . $type])) + { + trigger_error($user->lang[$l_type . '_ERR_NOT_' . $l_type]); + } - $l_prefix = 'THEME'; - break; + $cfg = file("$tmp_path$type/$type.cfg"); + $name = trim($cfg[0]); + $copyright = trim($cfg[1]); + $version = trim($cfg[2]); + unset($cfg); + } + else if ($action == 'install') + { + // NOT CONSISTENT WITH style installation + $path = (!empty($_POST['path'])) ? htmlspecialchars($_POST['path']) : ''; - case 'imageset': - $imageset_id = &$id; - $name = 'imageset_name'; + if (!($cfg = file("{$phpbb_root_path}styles/$path/$type/$type.cfg"))) + { + trigger_error($user->lang['NO_' . $l_type]); + } - $sql_select = '*'; - $sql_from = STYLES_IMAGE_TABLE; - $sql_where = "imageset_id = $id"; + $name = trim($cfg[0]); + $copyright = trim($cfg[1]); + $version = trim($cfg[2]); + $storedb = (!empty($_POST['storedb'])) ? 1 : 0; - $l_prefix = 'IMAGESET'; - break; - } + unset($cfg); + } + else + { + $name = (!empty($_POST['name'])) ? htmlspecialchars($_POST['name']) : ''; + $copyright = (!empty($_POST['copyright'])) ? htmlspecialchars($_POST['copyright']) : ''; + $storedb = (!empty($_POST['storedb'])) ? 1 : 0; + } - // 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"; + $sql_where = ($action == 'add' || $action == 'install') ? "WHERE {$type}_name = '" . $db->sql_escape($name) . "'" : "WHERE {$type}_id <> $id AND {$type}_name = '" . $db->sql_escape($name) . "'"; + $sql = "SELECT {$type}_name + FROM $table + $sql_where"; $result = $db->sql_query($sql); - if (!($style_row = ($db->sql_fetchrow($result)))) + if ($row = $db->sql_fetchrow($result)) + { + $error[] = $user->lang[$l_type . '_ERR_NAME_EXIST']; + } + $db->sql_freeresult($result); + unset($row); + + if (empty($name)) { - trigger_error($user->lang['NO_' . $l_prefix]); + $error[] = $user->lang[$l_type . '_ERR_STYLE_NAME']; } - $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) + if (strlen($name) > 30) { - $$var = (!empty($style_row[$var])) ? $style_row[$var] : ''; - unset($style_row[$var]); + $error[] = $user->lang[$l_type . '_ERR_NAME_LONG']; } - - $files = $data = array(); - if ($mode == 'style') + if (!preg_match('#^[a-z0-9_\-\+\. ]+$#i', $name)) { - $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) : ''); + $error[] = $user->lang[$l_type . '_ERR_NAME_CHARS']; + } - $data[] = array( - 'src' => $style_cfg, - 'prefix' => 'style.cfg' - ); - unset($style_cfg); + if (strlen($copyright) > 60) + { + $error[] = $user->lang[$l_type . '_ERR_COPY_LONG']; } - // Export template core code - if ($mode == 'template' || $inc_template) + if (!sizeof($error)) { - $template_cfg = addslashes($template_name) . "\n"; - $template_cfg .= addslashes($template_copyright) . "\n"; - $template_cfg .= addslashes($config['version']) . "\n"; - $template_cfg .= addslashes($bbcode_bitfield); + $css_data = ''; + if ($action == 'install') + { + switch ($type) + { + case 'theme': + if (!is_writeable("{$phpbb_root_path}styles/$path/$type/stylesheet.css")) + { + $storedb = 1; + if (!($css_data = implode('', file("{$phpbb_root_path}styles/$path/$type/stylesheet.css")))) + { + trigger_error($user->lang['NO_THEME']); + } + } + break; - $data[] = array( - 'src' => $template_cfg, - 'prefix' => 'template/template.cfg' - ); + case 'template': + $filelist = filelist("{$phpbb_root_path}styles/$path/$type", '', 'html'); + if (!is_writeable("{$phpbb_root_path}styles/$path/$type")) + { + $storedb = 1; + } + break; - // 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' - ); + case 'imageset': + if (!($cfg = file("{$phpbb_root_path}styles/$path/$type/imageset.cfg"))) + { + trigger_error($user->lang['NO_IMAGESET']); + } + + for ($i = 3; $i < sizeof($cfg); $i++) + { + $tmp = explode('||', $cfg[$i]); + $sql_img_ary[$tmp[0]] = str_replace('{PATH}', "styles/$path/$type/", trim($tmp[1])); + } + unset($cfg); + break; + } } - else + + + + if ($action == 'add' && !$safe_mode && is_writeable("{$phpbb_root_path}styles")) { - $sql = 'SELECT template_filename, template_data - FROM ' . STYLES_TPLDATA_TABLE . " - WHERE template_id = $template_id"; - $result = $db->sql_query($sql); + umask(0); + if (@mkdir("{$phpbb_root_path}styles/$path", 0777)) + { + @chmod("{$phpbb_root_path}styles/$path", 0777); + } - while ($row = $db->sql_fetchrow($result)) + if (@mkdir("{$phpbb_root_path}styles/$path/$type", 0777)) { - $data[] = array( - 'src' => $row['template_data'], - 'prefix' => 'template/' . $row['template_filename'] - ); + if (!@chmod("{$phpbb_root_path}styles/$path/$type", 0777)) + { + $storedb = 1; + } } - $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); - } + if (!empty($_FILES['upload_file']) || !empty($_POST['import_file'])) + { + // TODO + // mkdir, rmdir and rename error catching + ksort($filelist); + foreach ($filelist as $filepath => $file_ary) + { + if ($path && !file_exists("{$phpbb_root_path}styles/$path$filepath")) + { + @mkdir("{$phpbb_root_path}styles/$path$filepath", 0777); + } + + foreach ($file_ary as $file) + { + @rename("$tmp_path$filepath/$file", "{$phpbb_root_path}styles/$path$filepath/$file"); + } - // 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]); - } + if ($filepath && file_exists("$tmp_path$filepath")) + { + @rmdir("$tmp_path$filepath"); + } + } - $files[] = array( - 'src' => "styles/$imageset_path/imageset/", - 'prefix-' => "styles/$imageset_path/", - 'prefix+' => false, - 'exclude' => 'imageset.cfg' - ); + @rmdir("$tmp_path/$type"); + @rmdir($tmp_path); + } + else if ($basis && !$storedb && !$safe_mode) + { + switch ($type) + { + case 'theme': + $sql = "SELECT theme_name, theme_path, theme_storedb, css_data + FROM $table + WHERE theme_id = $basis"; + $result = $db->sql_query($sql); - $data[] = array( - 'src' => trim($imageset_cfg), - 'prefix' => 'imageset/imageset.cfg' - ); - unset($imageset_cfg); - } + if ($row = $db->sql_fetchrow($result)) + { + $css_data = ($row['storedb']) ? $row['css_data'] : implode('', file($phpbb_root_path . 'styles/' . $row['theme_path'] . "/$type/stylesheet.css")); - switch ($format) - { - case 'tar': - $ext = 'tar'; - $mimetype = 'x-tar'; - $compress = 'compress_tar'; - break; + if (!$storedb && ($fp = @fopen("{$phpbb_root_path}styles/$path/$type/stylesheet.css", 'wb'))) + { + $storedb = (@fwrite($fp, $css_data)) ? 0 : 1; - case 'zip': - if (!extension_loaded('zlib')) - { - trigger_error($user->lang['NO_SUPPORT_ZIP']); - } - $ext = 'zip'; - $mimetype = 'zip'; - $compress = 'compress_zip'; - break; + if (!$storedb) + { + unset($css_data); - case 'tar.gz': - if (!extension_loaded('zlib')) - { - trigger_error($user->lang['NO_SUPPORT_GZ']); - } - $ext = 'tar.gz'; - $mimetype = 'x-gzip'; - $compress = 'compress_tar'; - break; + // Get a list of all files and folders in the basis themes folder + $filelist = filelist($phpbb_root_path . 'styles/' . $row['theme_path'] . '/' . $type, '', '*'); + + // Copy every file bar the original stylesheet + foreach ($filelist as $filepath => $file_ary) + { + foreach ($file_ary as $file) + { + if ($file == 'stylesheet.css') + { + continue; + } + + if (!file_exists("{$phpbb_root_path}styles/$path/$type/$filepath")) + { + @mkdir("{$phpbb_root_path}styles/$path/$type/$filepath"); + } + @copy("{$phpbb_root_path}styles/" . $row['theme_path'] . "/$type/$filepath/$file", "{$phpbb_root_path}styles/$path/$type/$filepath/$file"); + } + } + unset($filelist); + } + } + else + { + $storedb = 1; + } + @fclose($fp); + } + $db->sql_freeresult($result); + 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; + case 'template': + $sql = "SELECT theme_name, theme_path, theme_storedb, css_data + FROM $table + WHERE theme_id = $basis"; + $result = $db->sql_query($sql); - default: - $error[] = $user->lang[$l_prefix . '_ERR_ARCHIVE']; - } + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + if (!$row) + { + $error = $user->lang['NO_TEMPLATE']; + break; + } - if (!sizeof($error)) - { - include($phpbb_root_path . 'includes/functions_compress.'.$phpEx); + if (!is_writeable("{$phpbb_root_path}styles/$path/$type")) + { + $storedb = 1; + } - $path = str_replace(' ', '_', $$name); + if ($row['template_storedb']) + { + } + break; + + case 'imageset': + $sql = "SELECT imageset_name, imageset_path + FROM $table + WHERE imageset_id = $basis"; + $result = $db->sql_query($sql); - if (!($zip = new $compress('w', "{$phpbb_root_path}store/$path.$ext"))) - { - trigger_error($user->lang['STORE_UNWRITEABLE']); - } + if ($row = $db->sql_fetchrow($result)) + { + // Get a list of all files and folders + $filelist = filelist("{$phpbb_root_path}styles/" . $row['imageset_path'] . '/imageset/', '', '*'); - if ($files) - { - foreach ($files as $file_ary) - { - $zip->add_file($file_ary['src'], $file_ary['prefix-'], $file_ary['prefix+'], $file_ary['exclude']); + // Copy every file + foreach ($filelist as $pathfile => $file_ary) + { + foreach ($file_ary as $file) + { + if (!file_exists("{$phpbb_root_path}styles/$path/$type/$pathfile")) + { + @mkdir("{$phpbb_root_path}styles/$path/$type/$pathfile"); + } + @copy("{$phpbb_root_path}styles/" . $row['imageset_path'] . "/$type$pathfile/$file", "{$phpbb_root_path}styles/$path/$type$pathfile/$file"); + } + } + unset($filelist); + } + $db->sql_freeresult($result); + break; + } } } - if ($data) + // Build relevant array ... we need to do this in bits depending on the + // action and type + $sql_ary = array( + $type . '_name' => $name, + ); + + if ($action == 'add' || $action == 'install') { - foreach ($data as $data_ary) + $sql_ary += array( + $type . '_copyright'=> $copyright, + $type . '_path' => $path, + ); + + switch ($type) { - $zip->add_data($data_ary['src'], $data_ary['prefix']); + case 'theme': + $sql_ary += array( + $type . '_mtime' => ($storedb) ? filemtime("{$phpbb_root_path}styles/$path/$type/stylesheet.css") : 0, + $type . '_storedb' => $storedb, + $type . '_data' => ($storedb) ? $css_data : '', + ); + break; + case 'template': + $sql_ary += array( + $type . '_storedb' => $storedb, + ); + break; } } - $zip->close(); - - add_log('admin', 'LOG_EXPORT_' . $l_prefix, $$name); - - if (!$store) + if ($action == 'details' && $mode != 'imageset') { - header('Pragma: no-cache'); - header("Content-Type: application/$mimetype; name=\"$path.$ext\""); - header("Content-disposition: attachment; filename=$path.$ext"); + $sql = "SELECT {$type}_path, {$type}_storedb" . (($type == 'theme') ? ', theme_data' : '') . " + FROM $table + WHERE {$type}_id = $id"; + $result = $db->sql_query($sql); - $fp = fopen("{$phpbb_root_path}store/$path.$ext", 'rb'); - while ($buffer = fread($fp, 1024)) + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row[$type . '_storedb'] != $storedb) { - echo $buffer; - } - fclose($fp); - @unlink("{$phpbb_root_path}store/$path.$ext"); - exit; - } + $path = $row[$type . '_path']; - 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); + switch ($type) + { + case 'theme': + $css_data = implode('', file("{$phpbb_root_path}styles/$path/$type/stylesheet.css")); + if (!$storedb && !$safe_mode && is_writeable("{$phpbb_root_path}styles/$path/theme/stylesheet.css")) + { + $storedb = 1; + if ($fp = @fopen("{$phpbb_root_path}styles/$path/$type/stylesheet.css", 'wb')) + { + $storedb = (@fwrite($fp, str_replace("styles/$path/theme/", './', $css_data))) ? 0 : 1; + } + fclose($fp); + } + $css_data = str_replace('./', "styles/$path/theme/", $css_data); - if (!extract($db->sql_fetchrow($result))) - { - trigger_error($user->lang['NO_' . $l_prefix]); - } - $db->sql_freeresult($result); - } + $sql_ary += array( + $type . '_mtime' => ($storedb) ? filemtime("{$phpbb_root_path}styles/$path/$type/stylesheet.css") : 0, + $type . '_storedb' => $storedb, + $type . '_data' => ($storedb) ? $css_data : '', + ); + break; + + case 'template': + $filelist = filelist("{$phpbb_root_path}styles/$path/template", '', 'html'); - // Output list - adm_page_header($user->lang[$l_prefix . '_EXPORT']); + if (!$storedb && !$safe_mode && is_writeable("{$phpbb_root_path}styles/$path/template")) + { + $sql = 'SELECT * + FROM ' . STYLES_TPLDATA_TABLE . " + WHERE template_id = $id"; + $result = $db->sql_query($sql); -?> -

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

+ while ($row = $db->sql_fetchrow($result)) + { + if (!($fp = fopen("{$phpbb_root_path}styles/$path/template/" . $row['template_filename'], 'wb'))) + { + $storedb = 1; + break; + } -

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

+ if (!fwrite($fp, $row['template_data'])) + { + $storedb = 1; + break; + } -
"> - - -sql_freeresult($result); -?> - - - -sql_query($sql); + } + } - } + $sql_ary += array( + $type . '_storedb' => $storedb, + ); + break; + } + } + } -?> - - - - -sql_transaction('begin'); - if ($mode == 'style') - { + $sql = ($action == 'add' || $action == 'install') ? "INSERT INTO $table " . $db->sql_build_array('INSERT', $sql_ary) : "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE {$type}_id = $id"; + $db->sql_query($sql); -?> - - - - - - - - - - - - - $filelist['']); + + if (!$id) + { + $id = $db->sql_nextid(); + } - } + store_templates('insert', $id, $path, $filelist); + } -?> - - - - - - - - - - - -
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  sql_transaction('commit'); - $compress_types = array('tar.gz' => 'zlib', 'tar.bz2' => 'bz2', 'zip' => 'zlib'); + $message = ($action == 'add' || $action == 'install') ? (($storedb) ? $l_prefix . '_DB_ADDED' : $l_prefix . '_FS_ADDED') : $l_prefix . '_DETAILS_UPDATE'; + $log = ($action == 'add' || $action == 'install') ? (($storedb) ? 'LOG_ADD_' . $l_prefix . '_DB' : 'LOG_ADD_' . $l_prefix . '_FS') : 'LOG_EDIT_' . $l_prefix . '_DETAILS'; - foreach ($compress_types as $type => $module) - { - if (!extension_loaded($module)) + add_log('admin', $log, $_name); + trigger_error($user->lang[$message]); + } + + + // If we were uploading or importing and an error occured we delete + // the temporary files + if (!empty($_FILES['upload_file']) || !empty($_POST['import_file'])) { - break; + // TODO + // mkdir, rmdir and rename error catching + ksort($filelist); + foreach ($filelist as $filepath => $file_ary) + { + foreach ($file_ary as $file) + { + @unlink("$tmp_path$filepath/$file"); + } + + if ($filepath && file_exists("$tmp_path$filepath")) + { + @rmdir("$tmp_path$filepath"); + } + } + + @rmdir("$tmp_path/$type"); + @rmdir($tmp_path); } - echo ' .' . $type . '  '; } -?>
  
-lang[$l_prefix . '_' . $l_type]); ?> - - - - - - - - - - - - - - - - - - - + -

h1

h2

h3

mainmenu
 ', $error); ?>
+ - - titles - - + } - +?> - - -
+ lang[$l_type . '_NAME']; ?>: + ' : "$name"; - - - - - - - - - - - - - - - +?> - + + + - - - + + -
th
cattitle / catcatdiv
topictitle / row1topicauthor / row2topicdetails / row1
row3
spacerlang['COPYRIGHT']; ?>:
postdetails / row2postbody / row1 posthilitlang[$l_type . '_LOCATION']; ?>:
lang[$l_type . '_LOCATION_EXPLAIN']; ?>
/> lang['STORE_FILESYSTEM']; ?>   /> lang['STORE_DATABASE']; ?>
+
+ } - - - - - - - - - -
gengenmedgensmall
copyright phpBB
+ // Import, upload and basis options + if ($action == 'add' && !$safe_mode && is_writeable("{$phpbb_root_path}styles")) + { + $store_options = ''; + $dp = opendir("{$phpbb_root_path}store"); + while ($file = readdir($dp)) + { + if ($file{0} != '.' && preg_match('#(' . $archive_preg . ')$#i', $file)) + { + $store_options .= ""; + } + } + closedir($dp); -

+ $store_options = '' . $store_options; -
- - - - - - - - - - - - - - -
+ $sql = "SELECT {$type}_id, {$type}_name + FROM $table"; + $result = $db->sql_query($sql); -

+ $basis_options = ''; + while ($row = $db->sql_fetchrow($result)) + { + $selected = (!empty($_POST['basis']) && $_POST['basis'] == $row[$type . '_id']) ? ' selected="selected"' : ''; + $basis_options .= ''; + } + $db->sql_freeresult($result); - +?> - + - + + - + + - + + -
postbody / bold italic underlinelang[$l_type . '_BASIS']; ?>
- - - -
A_N_Other wrote:
quote
lang[$l_type . '_EXISTING_BASIS']; ?>:
- - - - - - -
Code:
10 Print "hello"
20 Goto 10
lang[$l_type . '_UPLOAD_BASIS']; ?>:
lang['ALLOWED_FILETYPES']; ?>:
- - - - - - -
PHP:
// syntaxcomment
?>
<HTML>
<?php
echo $this = "HELLO";
lang[$l_type . '_IMPORT_BASIS']; ?>:
+ + } - - +?> + +    + + \ No newline at end of file -- cgit v1.2.1