diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php index f57440e62a..66cd2f6e55 100644 --- a/phpBB/adm/admin_styles.php +++ b/phpBB/adm/admin_styles.php @@ -797,7 +797,7 @@ switch ($mode) ?>
lang['EDIT_IMAGESET_EXPLAIN']; ?>
- - -sql_query($sql); + + if (!extract($db->sql_fetchrow($result))) + { + trigger_error($user->lang['NO_TEMPLATE']); + } + $db->sql_freeresult($result); + + if ($template_storedb && file_exists("{$phpbb_root_path}styles/$template_path/template/")) + { + $filelist = array('/' => array()); + + $sql = 'SELECT template_filename, template_mtime + FROM ' . STYLES_TPLDATA_TABLE . " + WHERE template_id = $template_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + if (filemtime("{$phpbb_root_path}styles/$template_path/template/" . $row['template_filename']) > $row['template_mtime']) + { + $filelist['/'][] = $row['template_filename']; + } + } + $db->sql_freeresult($result); + + store_templates('update', $template_id, $template_path, $filelist); + unset($filelist); + } + } + break; + case 'delete': if ($template_id) { - $sql = 'SELECT template_id, template_name, template_path + $sql = 'SELECT template_id, template_name, template_path, template_storedb FROM ' . STYLES_TPL_TABLE . " WHERE template_id = $template_id"; $result = $db->sql_query($sql); @@ -1323,7 +1121,14 @@ switch ($mode) } $db->sql_freeresult($result); - remove('template', $template_id, $template_name, $template_path); + 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; @@ -1344,9 +1149,12 @@ switch ($mode) $cfg = addslashes($template_name) . "\n"; $cfg .= addslashes($template_copyright) . "\n"; $cfg .= addslashes($config['version']) . "\n"; + $cfg .= addslashes($bbcode_bitfield) . "\n"; - if ($css_storedb) + if ($template_storedb) { + // TODO + // eek } else { @@ -1359,6 +1167,9 @@ switch ($mode) break; case 'cache': + $source = (!empty($_GET['source'])) ? htmlspecialchars($_GET['source']) : ''; + $file_ary = (!empty($_POST['delete'])) ? array_map('htmlspecialchars', $_POST['delete']) : ''; + $sql = 'SELECT * FROM ' . STYLES_TPL_TABLE . " WHERE template_id = $template_id"; @@ -1370,12 +1181,12 @@ switch ($mode) } $db->sql_freeresult($result); - $cache_prefix = 'tpl_' . $template_path; + $cache_prefix = "tpl_$template_path"; // User wants to delete one or more files ... - if ($_POST['update'] && !empty($_POST['delete'])) + if ($_POST['update'] && $file_ary) { - foreach ($_POST['delete'] as $file) + foreach ($file_ary as $file) { $file = "{$phpbb_root_path}cache/{$cache_prefix}_$file.html.$phpEx"; if (file_exists($file) && is_file($file)) @@ -1383,16 +1194,16 @@ switch ($mode) @unlink($file); } } + unset($file_ary); add_log('admin', 'LOG_CLEAR_TPLCACHE', $template_name); trigger_error($user->lang['TEMPLATE_CACHE_CLEARED']); } - // Someone wants to see the cached source ... so we'll highlight it, // add line numbers and indent it appropriately. This could be nasty // on larger source files ... - if (!empty($_GET['source']) && file_exists($phpbb_root_path . 'cache/' . $cache_prefix . '_' . $_GET['source'] . '.html.' . $phpEx)) + if ($source && file_exists("{$phpbb_root_path}cache/{$cache_prefix}_$source.html.$phpEx")) { adm_page_header($user->lang['TEMPLATE_CACHE']); @@ -1404,7 +1215,7 @@ switch ($mode) lang['ERR_TPLCACHE_READ']); } @@ -1490,9 +1301,9 @@ switch ($mode) if (is_file($phpbb_root_path . 'cache/' . $file) && strstr($file, $cache_prefix)) { $filename = preg_replace('#^' . $cache_prefix . '_(.*?)\.html\.' . $phpEx . '$#i', '\1', $file); - $tplcache_ary[$filename]['cache'] = filemtime($phpbb_root_path . 'cache/' . $file); - $tplcache_ary[$filename]['size'] = filesize($phpbb_root_path . 'cache/' . $file); - $tplcache_ary[$filename]['src'] = filemtime($phpbb_root_path . 'styles/templates/' . $template_path . '/' . $filename . '.html'); + $tplcache_ary[$filename]['cache'] = filemtime("{$phpbb_root_path}cache/$file"); + $tplcache_ary[$filename]['size'] = filesize("{$phpbb_root_path}cache/$file"); + $tplcache_ary[$filename]['src'] = filemtime("{$phpbb_root_path}styles/$template_path/template/$filename.html"); } } closedir($dp); @@ -1585,58 +1396,11 @@ function viewsource(url) case 'add': case 'details': case 'install': - - if ($template_id) - { - $sql = 'SELECT * - FROM ' . STYLES_TPL_TABLE . " - WHERE template_id = $template_id"; - $result = $db->sql_query($sql); - - if (!(extract($db->sql_fetchrow($result)))) - { - trigger_error($user->lang['NO_TEMPLATE']); - } - $db->sql_freeresult($result); - } - - // Output the page - adm_page_header($user->lang['EDIT_TEMPLATE']); - -?> - -lang['EDIT_TEMPLATE_EXPLAIN']; ?>
- - - $tpl_ary) { - $test_ary = array_merge($test_ary, $tpl_ary); + $test_ary += $tpl_ary; } - $dp = @opendir($phpbb_root_path . 'styles/templates/' . $template_path); + $dp = @opendir("{$phpbb_root_path}styles/$template_path/template"); while ($file = readdir($dp)) { - if (!strstr($file, 'bbcode.') && strstr($file, '.html') && is_file($phpbb_root_path . 'styles/templates/' . $template_path . '/' . $file)) + if (!strstr($file, 'bbcode.') && strstr($file, '.html') && is_file("{$phpbb_root_path}styles/$template_path/template/$file")) { if (!in_array($file, $test_ary)) { @@ -1679,10 +1443,10 @@ function viewsource(url) if ($tplname) { - $fp = fopen($phpbb_root_path . 'styles/templates/' . $template_path . '/' . $tplname, 'r');// . '.html' - while (!feof($fp)) + $fp = fopen("{$phpbb_root_path}styles/$template_path/template/$tplname", 'r');// . '.html' + while ($buffer = fread($fp, 1024)) { - $tpldata .= fread($fp, 4096); + $tpldata .= $buffer; } @fclose($fp); @@ -1712,10 +1476,10 @@ function viewsource(url) $tplname_options = ''; - $dp = @opendir($phpbb_root_path . 'styles/templates/' . $template_path); + $dp = @opendir("{$phpbb_root_path}styles/$template_path/template"); while ($file = readdir($dp)) { - if (strstr($file, '.html') && is_file($phpbb_root_path . 'styles/templates/' . $template_path . '/' . $file)) + if (strstr($file, '.html') && is_file("{$phpbb_root_path}styles/$template_path/template/$file")) { $tpl = substr($file, 0, strpos($file, '.')); $selected = ($tplname == $tpl) ? ' selected="selected"' : ''; @@ -1764,7 +1528,7 @@ function viewsource(url) // Front page - front('template', array('cache', 'details', 'delete', 'export', 'preview')); + front('template', array('cache', 'details', 'refresh', 'export', 'delete', 'preview')); break; @@ -1780,419 +1544,10 @@ function viewsource(url) case 'add': case 'details': case 'install': - - $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 ($theme_id && empty($_POST['update'])) - { - $sql = 'SELECT * - FROM ' . STYLES_CSS_TABLE . " - WHERE theme_id = $theme_id"; - $result = $db->sql_query($sql); - - if (!(extract($db->sql_fetchrow($result)))) - { - trigger_error($user->lang['NO_THEME']); - } - $db->sql_freeresult($result); - - $s_hidden_fields = ''; - } - else - { - if ($action == 'install' && !empty($_GET['name'])) - { - $theme_path = htmlspecialchars($_GET['name']); - if (!file_exists("{$phpbb_root_path}styles/themes/$theme_path/theme.cfg")) - { - trigger_error($user->lang['NO_THEME']); - } - - if (!($themecfg = file("{$phpbb_root_path}styles/themes/$theme_path/theme.cfg"))) - { - trigger_error($user->lang['NO_THEME']); - } - - $theme_version = preg_replace('#^2\.([0-9]+?)\.([0-9]+?).*?$#', '\1.\2', trim($themecfg[2])); - $phpbbversion = preg_replace('#^2\.([0-9]+?)\.([0-9]+?).*?$#', '\1.\2', $config['version']); - - if ($theme_version != $phpbbversion) - { - $error[] = $user->lang['THEME_VERSION_DIFF']; - } - - $theme_name = trim($themecfg[0]); - $theme_copyright = trim($themecfg[1]); - - $s_hidden_fields = ''; - } - else - { - $theme_name = (!empty($_POST['theme_name'])) ? htmlspecialchars(stripslashes($_POST['theme_name'])) : ''; - - $theme_copyright = (!empty($_POST['theme_copyright'])) ? htmlspecialchars(stripslashes($_POST['theme_copyright'])) : ''; - $css_storedb = (!empty($_POST['css_storedb'])) ? 1 : (($safe_mode) ? 1 : 0); - - $s_hidden_fields = (!empty($_POST['theme_basis'])) ? '' : ''; - if (!empty($_POST['theme_path'])) - { - $s_hidden_fields .= ''; - } - } - } - - - // Do the update thang - if (isset($_POST['update'])) - { - if (!$safe_mode && is_writeable("{$phpbb_root_path}styles") && $action == 'add') - { - if (!empty($_FILES['upload_file'])) - { - $realname = htmlspecialchars($_FILES['upload_file']['name']); - $filename = htmlspecialchars($_FILES['upload_file']['tmp_name']); - - if (!preg_match('#(' . $archive_preg . ')$#i', $realname, $match)) - { - $error[] = sprintf('UPLOAD_WRONG_TYPE', $archive_types); - } - - // 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"); - } - - include($phpbb_root_path . 'includes/functions_compress.'.$phpEx); - - 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(); - - $filelist = filelist($tmp_path, '', '*'); - - $is_theme = (in_array('theme.cfg', $filelist['/theme'])) ? true : false; -// $is_template = (in_array('template.cfg', $filelist['/template'])) ? true : false; -// $is_imageset = (in_array('imageset.cfg', $filelist['/imageset'])) ? true : false; -// $is_style = (in_array('style.cfg', $filelist[''])) ? true : false; - - if (!$is_theme) - { - die("Not a theme"); - } - - $cfg = file($tmp_path . 'theme/theme.cfg'); - if ($theme_name == '') - { - $theme_name = trim($cfg[0]); - } - $theme_copyright = trim($cfg[1]); - $theme_version = trim($cfg[2]); - unset($cfg); - } - else if (!empty($_POST['import_file'])) - { - } - } - - $sql_where = ($action == 'add' || $action == 'install') ? "WHERE theme_name = '" . $db->sql_escape($theme_name) . "'" : "WHERE theme_id <> $theme_id AND theme_name = '" . $db->sql_escape($theme_name) . "'"; - $sql = 'SELECT theme_name - FROM ' . STYLES_CSS_TABLE . " - $sql_where"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $error[] = $user->lang['THEME_ERR_NAME_EXIST']; - } - $db->sql_freeresult($result); - unset($row); - - if (empty($theme_name)) - { - $error[] = $user->lang['THEME_ERR_STYLE_NAME']; - } - - if (strlen($theme_name) > 30) - { - $error[] = $user->lang['THEME_ERR_NAME_LONG']; - } - - if (!preg_match('#^[a-z0-9_\-\+\. ]+$#i', $theme_name)) - { - $error[] = $user->lang['THEME_ERR_NAME_CHARS']; - } - - if (strlen($theme_copyright) > 60) - { - $error[] = $user->lang['THEME_ERR_COPY_LONG']; - } - - if (!sizeof($error)) - { - // Replace any chars which may cause us problems with _ - $theme_path = ($action == 'add') ? str_replace(' ', '_', $theme_name) : htmlspecialchars($_POST['theme_path']); - - $css_storedb = 1; - $css_data = ''; - if ($action == 'install') - { - if (!is_writeable("{$phpbb_root_path}styles/$theme_path/theme/stylesheet.css")) - { - $css_data = implode('', file("{$phpbb_root_path}styles/$theme_path/theme/stylesheet.css")); - } - else - { - $css_storedb = 0; - } - } - else if (!$safe_mode && is_writeable("{$phpbb_root_path}styles") && $action == 'add') - { - if (file_exists("{$phpbb_root_path}styles/$theme_path/theme/")) - { - for ($i = 1; $i < 100; $i++) - { - if (!file_exists("$phpbb_root_path/styles/{$theme_path}_{$i}/theme/")) - { - $theme_path .= "_$i"; - break; - } - } - } - - umask(0); - if (@mkdir("{$phpbb_root_path}styles/$theme_path", 0777)) - { - @chmod("{$phpbb_root_path}styles/$theme_path", 0777); - } - - if (@mkdir("{$phpbb_root_path}styles/$theme_path/theme/", 0777)) - { - if (!@chmod("{$phpbb_root_path}styles/themes/$theme_path", 0777)) - { - $css_storedb = 0; - } - } - - if (!empty($_FILES['upload_file']) || !empty($_POST['import_file'])) - { - // TODO - // mkdir, rmdir and rename error catching - ksort($filelist); - foreach ($filelist as $path => $file_ary) - { - if ($path && !file_exists("{$phpbb_root_path}styles/$theme_path$path")) - { - @mkdir("{$phpbb_root_path}styles/$theme_path$path", 0777); - } - - foreach ($file_ary as $file) - { - @rename("$tmp_path$path/$file", "{$phpbb_root_path}styles/$theme_path$path/$file"); - } - - if ($path && file_exists("$tmp_path$path")) - { - @rmdir("$tmp_path$path"); - } - } - - @rmdir("$tmp_path/theme"); - @rmdir($tmp_path); - } - else if (!empty($_POST['theme_basis']) && !$css_storedb) - { - $sql = 'SELECT theme_name, theme_path, css_storedb, css_data - FROM ' . STYLES_CSS_TABLE . ' - WHERE theme_id = ' . intval($_POST['theme_basis']); - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $css_data = ($row['css_storedb']) ? $row['css_data'] : implode('', file($phpbb_root_path . 'styles/themes/' . $row['theme_path'] . '/' . $row['theme_path'] . '.css')); - - if (!$css_storedb && ($fp = @fopen("{$phpbb_root_path}styles/$theme_path/theme/stylesheet.css", 'wb'))) - { - $css_storedb = (fwrite($fp, $css_data)) ? 0 : 1; - - if (!$css_storedb) - { - // Get a list of all files and folders in the basis themes folder - $filelist = filelist($phpbb_root_path . 'styles/' . $row['theme_path'] . '/themes', '', '*'); - - // Copy every file bar the original stylesheet - foreach ($filelist as $path => $file_ary) - { - foreach ($file_ary as $file) - { - if ($file == 'stylesheet.css') - { - continue; - } - - if (!file_exists("{$phpbb_root_path}styles/$theme_path/theme/$path")) - { - @mkdir("{$phpbb_root_path}styles/$theme_path/theme/$path"); - } - @copy("{$phpbb_root_path}styles/" . $row['theme_path'] . "/theme/$path/$file", "{$phpbb_root_path}styles/$theme_path/theme/$path/$file"); - } - } - unset($filelist); - } - } - else - { - $css_storedb = 1; - } - @fclose($fp); - } - $db->sql_freeresult($result); - } - } - - $sql_ary = array( - 'theme_name' => $theme_name, - ); - if ($action == 'add' || $action == 'install') - { - $sql_ary = array_merge($sql_ary, array( - 'theme_copyright' => $theme_copyright, - 'theme_path' => $theme_path, - 'css_storedb' => $css_storedb, - 'css_data' => ($css_storedb) ? $css_data : '',) - ); - } - - $sql = ($action == 'add' || $action == 'install') ? 'INSERT INTO ' . STYLES_CSS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary) : 'UPDATE ' . STYLES_CSS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE theme_id = ' . $theme_id; - $db->sql_query($sql); - - $message = ($action == 'add' || $action == 'install') ? (($css_storedb) ? 'THEME_DB_ADDED' : 'THEME_FS_ADDED') : 'THEME_DETAILS_UPDATE'; - $log = ($action == 'add' || $action == 'install') ? (($css_storedb) ? 'LOG_ADD_THEME_DB' : 'LOG_ADD_THEME_FS') : 'LOG_EDIT_THEME_DETAILS'; - - add_log('admin', $log, $theme_name); - trigger_error($user->lang[$message]); - } - } - - - $css_storedb_no = (!$css_storedb) ? ' checked="checked"' : ''; - $css_storedb_yes = ($css_storedb) ? ' checked="checked"' : ''; - - - // Output the page - adm_page_header($user->lang[$l_prefix . '_THEME']); - -?> - -lang[$l_prefix . '_THEME_EXPLAIN']; ?>
- - - $class_ary) { - $test_ary = array_merge($test_ary, $class_ary); + $test_ary += $class_ary; } $matches = preg_replace('#^\.#', '', $matches[1]); @@ -2692,10 +2047,9 @@ function csspreview() break; case 'delete': - if ($theme_id) { - $sql = 'SELECT theme_id, theme_name, theme_path + $sql = 'SELECT theme_id, theme_name, theme_path, theme_storedb FROM ' . STYLES_CSS_TABLE . " WHERE theme_id = $theme_id"; $result = $db->sql_query($sql); @@ -2706,13 +2060,11 @@ function csspreview() } $db->sql_freeresult($result); - remove('theme', $theme_id, $theme_name, $theme_path); + remove('theme', $theme_id, $theme_name, $theme_path, $theme_storedb); } - break; case 'export': - if ($theme_id) { $sql = 'SELECT * @@ -2744,23 +2096,16 @@ function csspreview() export('theme', $theme_id, $theme_name, $theme_path, $files, $data); } - break; - - case 'import': - case 'upload': - - - break; } // Front page - front('theme', array('details', 'delete', 'export', 'preview')); + front('theme', array('details', 'refresh', 'export', 'delete', 'preview')); break; } - +exit; // --------- @@ -2905,7 +2250,7 @@ function front($type, $options) } -function remove($type, $id, $name, $path) +function remove($type, $id, $name, $path, $storedb = false) { global $phpbb_root_path, $SID, $config, $db, $user, $mode, $action; @@ -3006,7 +2351,7 @@ function remove($type, $id, $name, $path) @@ -3033,6 +2378,760 @@ function remove($type, $id, $name, $path) } +function details($type, $mode, $action, $id) +{ + global $phpbb_root_path, $phpEx, $SID, $config, $db, $user; + global $archive_preg, $safe_mode; + + 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 (empty($_POST['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' && empty($_POST['update'])) + { + if (empty($_GET['name'])) + { + trigger_error($user->lang[$l_type . '_ERR_NO_NAME']); + } + + $path = trim(htmlspecialchars($_GET['name'])); + if (!file_exists("{$phpbb_root_path}styles/$path/$type/$type.cfg")) + { + trigger_error($user->lang['NO_' . $l_type]); + } + + if (!($cfg = file("{$phpbb_root_path}styles/$path/$type/$type.cfg"))) + { + trigger_error($user->lang['NO_' . $l_type]); + } + + $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']); + + if ($version != $phpbbversion) + { + $error[] = $user->lang[$l_type . '_VERSION_DIFF']; + } + + $s_hidden_fields = ''; + } + 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) + { + $s_hidden_fields .= ''; + } + } + } + + // Do the update thang + if (isset($_POST['update'])) + { + 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'])) + { + $realname = htmlspecialchars($_FILES['upload_file']['name']); + $filename = htmlspecialchars($_FILES['upload_file']['tmp_name']); + + if (!is_uploaded_file($filename)) + { + trigger_error("$filename was not uploaded"); + } + } + else + { + $realname = htmlspecialchars($_POST['import_file']); + $filename = "{$phpbb_root_path}store/$realname"; + } + + 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); + + // 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"); + } + + include($phpbb_root_path . 'includes/functions_compress.'.$phpEx); + + 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(); + + $filelist = filelist($tmp_path, '', '*'); + + if (!in_array($type . '.cfg', $filelist['/' . $type])) + { + trigger_error($user->lang[$l_type . '_ERR_NOT_' . $l_type]); + } + + $cfg = file("$tmp_path$type/$type.cfg"); + if ($name == '') + { + $name = trim($cfg[0]); + } + $copyright = trim($cfg[1]); + $version = trim($cfg[2]); + unset($cfg); + } + else if ($action == 'install') + { + $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 = (!empty($_POST['name'])) ? htmlspecialchars($_POST['name']) : trim($cfg[0]); + $storedb = (!empty($_POST['storedb'])) ? 1 : 0; + $copyright = trim($cfg[1]); + $version = trim($cfg[2]); + + 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"; + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + $error[] = $user->lang[$l_type . '_ERR_NAME_EXIST']; + } + $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'); + foreach ($filelist as $pathfile => $file_ary) + { + foreach ($file_ary as $file) + { + if (!is_writeable("{$phpbb_root_path}styles/$path/$type$pathfile/$file")) + { + $storedb = 1; + break; + } + } + } + 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")) + { + if (file_exists("{$phpbb_root_path}styles/$path/$type/")) + { + for ($i = 1; $i < 100; $i++) + { + if (!file_exists("$phpbb_root_path/styles/{$path}_{$i}/$type/")) + { + $path .= "_$i"; + break; + } + } + } + + 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; + } + } + } + + // 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') + { + $sql_ary += array( + $type . '_copyright'=> $copyright, + $type . '_path' => $path, + ); + + 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; + } + } + + if ($action == 'details' && $mode != 'imagesets') + { + $sql = "SELECT {$type}_path, {$type}_storedb" . (($type == 'theme') ? ', theme_data' : '') . " + FROM $table + WHERE {$type}_id = $id"; + $result = $db->sql_query($sql); + + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row[$type . '_storedb'] != $storedb) + { + $path = $row[$type . '_path']; + + 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); + + $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'); + + 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); + + while ($row = $db->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; + } + + fclose($fp); + + } + $db->sql_freeresult($result); + + if (!$storedb) + { + $sql = 'DELETE FROM ' . STYLES_TPLDATA_TABLE . " + WHERE template_id = $id"; + $db->sql_query($sql); + } + } + + $sql_ary += array( + $type . '_storedb' => $storedb, + ); + break; + } + } + } + + $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); + + if ($type == 'template' && $storedb) + { + $filelist = array('/template' => $filelist['']); + $id = $db->sql_nextid(); + store_templates('insert', $id, $path, $filelist); + } + + $db->sql_transaction('commit'); + + $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'; + + 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'])) + { + // 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); + } + } + + + $storedb_no = (!$storedb) ? ' checked="checked"' : ''; + $storedb_yes = ($storedb) ? ' checked="checked"' : ''; + + + // Output the page + adm_page_header($user->lang[$l_prefix . '_' . $l_type]); + +?> + +lang[$l_prefix . '_' . $l_type . '_EXPLAIN']; ?>
+ + + $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 export($type, $id, $name, $path, &$files, &$data) { global $phpbb_root_path, $phpEx, $SID, $config, $user, $mode, $action; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6d5c404121..5ccd044545 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1348,8 +1348,10 @@ function page_header($page_title = '') 'S_DISPLAY_MEMBERLIST' => (isset($auth)) ? $auth->acl_get('u_viewprofile') : 0, 'T_THEME_PATH' => 'styles/' . $user->theme['primary']['theme_path'] . '/theme/', - 'T_STYLESHEET_LINK' => (!$user->theme['primary']['css_storedb']) ? 'styles/' . $user->theme['primary']['theme_path'] . '/theme/stylesheet.css' : "style.$phpEx?sid=$user->session_id&id=" . $user->theme['primary']['theme_id'], - 'T_THEME_DATA' => (!$user->theme['primary']['css_storedb']) ? '' : $user->theme['primary']['css_data']) + 'T_TEMPLATE_PATH' => 'styles/' . $user->theme['primary']['template_path'] . 'template/', + 'T_IMAGESET_PATH' => 'styles/' . $user->theme['primary']['imageset_path'] . 'imageset/', + 'T_STYLESHEET_LINK' => (!$user->theme['primary']['theme_storedb']) ? 'styles/' . $user->theme['primary']['theme_path'] . '/theme/stylesheet.css' : "style.$phpEx?sid=$user->session_id&id=" . $user->theme['primary']['theme_id'], + 'T_THEME_DATA' => (!$user->theme['primary']['theme_storedb']) ? '' : $user->theme['primary']['theme_data']) ); if (!empty($config['send_encoding'])) @@ -1368,15 +1370,6 @@ function page_footer() { global $db, $config, $template, $SID, $user, $auth, $cache, $starttime, $phpEx; - // Close our DB connection. - $db->sql_close(); - - // Unload cache - if (!empty($cache)) - { - $cache->unload(); - } - // Output page creation time if (defined('DEBUG')) { @@ -1407,6 +1400,15 @@ function page_footer() ); $template->display('body'); + + // Close our DB connection. + $db->sql_close(); + + // Unload cache + if (!empty($cache)) + { + $cache->unload(); + } exit; } diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index de9eb95dd9..85378c2491 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -165,15 +165,13 @@ function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png') while ($fname = readdir($dh)) { - if (is_file($rootdir . $dir . '/' . $fname) && - preg_match('#\.' . $type . '$#i', $fname) && - filesize($rootdir . $dir . '/' . $fname)) + if (is_file("$rootdir$dir/$fname") && filesize("$rootdir$dir/$fname") && preg_match('#\.' . $type . '$#i', $fname)) { $matches[$dir][] = $fname; } - else if ($fname{0} != '.' && is_dir($rootdir . $dir . '/' . $fname)) + else if ($fname{0} != '.' && is_dir("$rootdir$dir/$fname")) { - $matches += filelist($rootdir, $dir . '/'. $fname, $type); + $matches += filelist($rootdir, "$dir/$fname", $type); } } diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index e24e29ac58..8ae054b556 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -461,8 +461,6 @@ class user extends session include($this->lang_path . '/' . $lang_set . '.' . $phpEx); }*/ - // TODO ? - // Cheat if (!empty($_GET['style']) && $auth->acl_get('a_styles')) { global $SID; diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index d7de109602..51935ba9df 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -70,13 +70,13 @@ class template if (file_exists($phpbb_root_path . 'styles/' . $user->theme['primary']['template_path'] . '/template')) { -// $this->tpl = 'primary'; + $this->tpl = 'primary'; $this->root = $phpbb_root_path . 'styles/' . $user->theme['primary']['template_path']. '/template'; $this->cachepath = $phpbb_root_path . 'cache/tpl_' . $user->theme['primary']['template_path'] . '_'; } else { -// $this->tpl = 'secondary'; + $this->tpl = 'secondary'; $this->root = $phpbb_root_path . 'styles/' . $user->theme['secondary']['template_path']. '/template'; $this->cachepath = $phpbb_root_path . 'cache/tpl_' . $user->theme['secondary']['template_path'] . '_'; } @@ -140,7 +140,7 @@ class template // Load a compiled template if possible, if not, recompile it function _tpl_load(&$handle) { - global $phpEx, $user; + global $phpEx, $user, $db; $filename = $this->cachepath . $this->filename[$handle] . '.' . (($this->static_lang) ? $user->data['user_lang'] . '.' : '') . $phpEx; @@ -165,28 +165,80 @@ class template if (!file_exists($this->files[$handle])) { -// $this->tpl = 'secondary'; + $this->tpl = 'secondary'; $this->files[$handle] = $phpbb_root_path . 'styles/' . $user->theme['secondary']['template_path'] . '/template/' . $this->filename[$handle]; } $str = ''; + if ($user->theme[$this->tpl]['template_storedb']) + { + $sql = 'SELECT * FROM ' . STYLES_TPLDATA_TABLE . ' + WHERE template_id = ' . $user->theme[$this->tpl]['template_id'] . " + AND (template_filename = '" . $db->sql_escape($this->filename[$handle]) . "' + OR template_included LIKE '%" . $db->sql_escape($this->filename[$handle]) . ":%')"; + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + do + { + if ($row['template_mtime'] < filemtime($phpbb_root_path . 'styles/' . $user->theme[$this->tpl]['template_path'] . '/template/' . $row['template_filename'])) + { + if ($row['template_filename'] == $this->filename[$handle]) + { + $this->_tpl_load_file($handle); + } + else + { + $this->files[$row['template_filename']] = $this->root . '/' . $row['template_filename']; + $this->_tpl_load_file($row['template_filename']); + unset($this->compiled_code[$row['template_filename']]); + unset($this->files[$row['template_filename']]); + } + } + + if ($row['template_filename'] == $this->filename[$handle]) + { + $this->compiled_code[$handle] = $this->compile(trim($row['template_data'])); + $this->compile_write($handle, $this->compiled_code[$handle]); + } + else + { + // Only bother compiling if it doesn't already exist + if (!file_exists($this->cachepath . $row['template_filename'] . '.' . (($this->static_lang) ? $user->data['user_lang'] . '.' : '') . $phpEx)) + { + $this->filename[$row['template_filename']] = $row['template_filename']; + $this->compile_write($row['template_filename'], $this->compile(trim($row['template_data']))); + unset($this->filename[$row['template_filename']]); + } + } + } + while ($row = $db->sql_fetchrow($result)); + } + $db->sql_freeresult($result); + return false; + } + + $this->_tpl_load_file($handle); + return false; + } + + // Load template source from file + function _tpl_load_file($handle) + { // Try and open template for read if (!($fp = @fopen($this->files[$handle], 'r'))) { trigger_error("template->_tpl_load(): File $filename does not exist or is empty", E_USER_ERROR); } - $str = @fread($fp, filesize($this->files[$handle])); + $this->compiled_code[$handle] = $this->compile(trim(@fread($fp, filesize($this->files[$handle])))); @fclose($fp); // Actually compile the code now. - $this->compiled_code[$handle] = $this->compile(trim($str)); $this->compile_write($handle, $this->compiled_code[$handle]); - - return false; } - // Assign key variable pairs from an array function assign_vars($vararray) { diff --git a/phpBB/language/en/lang_admin.php b/phpBB/language/en/lang_admin.php index 8871d219a8..18d5d4e2a3 100644 --- a/phpBB/language/en/lang_admin.php +++ b/phpBB/language/en/lang_admin.php @@ -60,9 +60,10 @@ $lang = array_merge($lang, array( 'GROUP_CAT' => 'Usergroups', 'CREATE' => 'Create', - 'LOG_CAT' => 'Logging', - 'ADMIN_LOGS'=> 'Admin Log', - 'MOD_LOGS' => 'Moderator Log', + 'LOG_CAT' => 'Logging', + 'ADMIN_LOGS' => 'Admin Log', + 'MOD_LOGS' => 'Moderator Log', + 'CRITICAL_LOGS' => 'Error Log', 'POST_CAT' => 'Posting', 'SMILE' => 'Smilies', @@ -927,10 +928,21 @@ $lang = array_merge($lang, array( 'TEMPLATES' => 'Templates', 'TEMPLATES_EXPLAIN' => 'A Template set comprises all the markup used to generate the layout of your board. Here you can edit existing template sets, delete, export, import and preview sets. You can also modify the templating code used to generate BBCode.', - 'EDIT_TEMPLATE' => 'Edit Template', - 'EDIT_TEMPLATE_EXPLAIN' => 'Use this panel to edit an existing compiled template set. When you have made the required changes you can recompile the template and (or) download it. Please remember that the existing HTML templates are not altered, only the compiled versions are affected. Therefore you should download any altered files if you wish to keep them for future use and for archival purposes.', - 'TEMPLATE_NAME' => 'Template name', - 'SELECT_TEMPLATE' => 'Select template', + 'EDIT_TEMPLATE' => 'Edit Template', + 'EDIT_TEMPLATE_EXPLAIN' => 'Use this panel to edit an existing compiled template set. When you have made the required changes you can recompile the template and (or) download it. Please remember that the existing HTML templates are not altered, only the compiled versions are affected. Therefore you should download any altered files if you wish to keep them for future use and for archival purposes.', + 'ADD_TEMPLATE' => 'Create Template', + 'ADD_TEMPLATE_EXPLAIN' => 'Here you can add a new template. Depending on your server configuration and file permissions you may have additional options here. For example you may be able to base this template set on an existing one. You may also be able to upload or import (from the store directory) a template archive. If you upload or import an archive the template name can be optionally taken from the archive name (to do this leave the template name blank).', + 'INSTALL_TEMPLATE' => 'Install Template', + 'INSTALL_TEMPLATE_EXPLAIN' => 'Here you can install a new template set. Depending on your server configuration you may have a number of options here.', + 'TEMPLATE_NAME' => 'Template name', + 'SELECT_TEMPLATE' => 'Select template', + 'TEMPLATE_EXISTING_BASIS' => 'Use existing template as basis', + 'TEMPLATE_UPLOAD_BASIS' => 'Upload a template', + 'TEMPLATE_IMPORT_BASIS' => 'Import template from store', + 'TEMPLATE_LOCATION' => 'Store templates in', + 'TEMPLATE_LOCATION_EXPLAIN' => 'Images are always stored on the filesystem.', + + 'TEMPLATE_CACHE' => 'Template Cache', 'TEMPLATE_CACHE_EXPLAIN'=> 'By default phpBB caches the compiled version of its templates. This decreases the load on the server each time a page is viewed and thus may reduce the page generation time. Here you can view the cache status of each file and delete individual files or the entire cache.', 'CACHE_FILENAME' => 'Template file', @@ -949,21 +961,32 @@ $lang = array_merge($lang, array( 'TEMPLATE_DELETED_FS' => 'Template set removed from database but some files may remain on the filesystem', 'ONLY_TEMPLATE' => 'This is the only remaining template set, you cannot delete it', - 'ERR_TPLCACHE_READ' => 'Cannot read the cache directory', - 'NO_CACHED_TPL_FILES' => 'No cached files for this template', + 'TEMPLATE_ERR_STYLE_NAME' => 'You must supply a name for this templates', + 'TEMPLATE_ERR_NAME_CHARS' => 'The template name can only contain alphanumeric characters, -, +, _ and space', + 'TEMPLATE_ERR_NAME_LONG' => 'The template name can be no longer than 30 characters', + 'TEMPLATE_ERR_NAME_EXIST' => 'A template set with that name already exists', + 'TEMPLATE_ERR_COPY_LONG' => 'The copyright can be no longer than 60 characters', + 'TEMPLATE_ERR_ARCHIVE' => 'Please select an archive method', + 'TEMPLATE_ERR_NOT_TEMPLATE' => 'The archive you specified does not contain a valid template set.', + 'ERR_TPLCACHE_READ' => 'Cannot read the cache directory', + 'NO_CACHED_TPL_FILES' => 'No cached files for this template', 'DOWNLOAD_STORE' => 'Download or Store archive', 'DOWNLOAD_STORE_EXPLAIN'=> 'You may directly download the archive or save it in your store/ folder.', 'ARCHIVE_FORMAT' => 'Archive file type', - 'SELECT_BASIS' => 'Select optional basis', - 'CACHE' => 'Cache', - 'EXPORT' => 'Export', - 'DETAILS' => 'Details', - 'NO_IMAGESET' => 'Cannot find imageset on filesystem', - 'NO_THEME' => 'Cannot find theme on filesystem', - 'NO_TEMPLATE' => 'Cannot find template on filesystem', - 'NO_STYLE' => 'Cannot find style on filesystem', + 'ALLOWED_FILETYPES' => 'Allowed filetypes', + 'SELECT_BASIS' => 'Select optional basis', + 'COPYRIGHT' => 'Copyright', + 'CACHE' => 'Cache', + 'EXPORT' => 'Export', + 'DETAILS' => 'Details', + 'REFRESH' => 'Refresh', + 'NO_IMAGESET' => 'Cannot find imageset on filesystem', + 'NO_THEME' => 'Cannot find theme on filesystem', + 'NO_TEMPLATE' => 'Cannot find template on filesystem', + 'NO_STYLE' => 'Cannot find style on filesystem', + 'UPLOAD_WRONG_TYPE' => 'Only the following filetypes are accepted: %s', 'THEMES' => 'Themes', @@ -971,20 +994,33 @@ $lang = array_merge($lang, array( 'SELECT_THEME_BASIS' => 'Select optional basis', 'THEME_VERSION_DIFF' => 'This theme was designed for a version of phpBB 2.2 different from that installed you may encounter some issues in its use.', - 'DELETE_THEME' => 'Delete Theme', + 'DELETE_THEME' => 'Delete theme', 'DELETE_THEME_EXPLAIN' => 'Here you can remove the selected theme from the database. Additionally, if you have permission you can elect to remove the theme from the filesystem. Please note that there is no undo capability. When the theme is deleted it is gone for good. It is recommended that you first export your theme for possible future use.', 'THEME_DELETED' => 'Theme deleted successfully', 'THEME_DELETED_FS' => 'Theme removed from database but some files may remain on the filesystem', 'ONLY_THEME' => 'This is the only remaining theme, you cannot delete it', - 'EDIT_THEME' => 'Edit Theme', + 'EDIT_THEME' => 'Edit theme', 'EDIT_THEME_EXPLAIN' => 'Here you can edit the selected theme, changing colours, images, etc. You can switch between a simplified interface where you can set basic colours, etc. and a more advanced "raw CSS" mode. Using the raw mode you can style additional CSS elements such as borders, etc. You only need set the parameters you need, e.g. if you do not want a background image leave that parameter unset. You may also add additional "custom" classes should your template or style make use of them.', + + 'EDIT_DETAILS_THEME' => 'Edit theme details', + 'EDIT_DETAILS_THEME_EXPLAIN'=> 'Here you can edit certain theme details such as changing its name. You may also be able to switch storage of the stylesheet from the filesystem to the database and vice versa. This option depends on your PHP configuration and whether your stylesheet can be written to by the webserver.', + 'ADD_THEME' => 'Create Theme', + 'ADD_THEME_EXPLAIN' => 'Here you can add a new theme. Depending on your server configuration and file permissions you may have additional options here. For example you may be able to base this theme on an existing one. You may also be able to upload or import (from the store directory) a theme archive. If you upload or import an archive the theme name can be optionally taken from the archive name (to do this leave the theme name blank).', + 'INSTALL_THEME' => 'Install Theme', + 'INSTALL_THEME_EXPLAIN' => 'Here you can edit the selected theme, changing colours, images, etc. You can switch between a simplified interface where you can set basic colours, etc. and a more advanced "raw CSS" mode. Using the raw mode you can style additional CSS elements such as borders, etc. You only need set the parameters you need, e.g. if you do not want a background image leave that parameter unset. You may also add additional "custom" classes should your template or style make use of them.', 'THEME_NAME' => 'Theme Name', + 'THEME_BASIS' => 'Theme Basis', + 'THEME_EXISTING_BASIS' => 'Use existing theme as basis', + 'THEME_UPLOAD_BASIS' => 'Upload a theme', + 'THEME_IMPORT_BASIS' => 'Import theme from store', + 'THEME_LOCATION' => 'Store stylesheet in', + 'THEME_LOCATION_EXPLAIN'=> 'Images are always stored on the filesystem.', + 'SELECT_CLASS' => 'Select class', 'SHOW_RAW_CSS' => 'Show CSS', 'HIDE_RAW_CSS' => 'Hide CSS', 'SHOW_RAW_CSS_EXPLAIN' => 'Enter each element on a new line, ending with a ; Expand the data for each element, e.g. do not use font: use font-family:, font-weight:, etc.', - 'CSS_CAT_TEXT' => 'Text Classes', 'CSS_BODY' => 'Body', 'CSS_P' => 'Paragraph', @@ -1057,6 +1093,7 @@ $lang = array_merge($lang, array( 'THEME_ERR_NAME_EXIST' => 'A theme with that name already exists', 'THEME_ERR_COPY_LONG' => 'The copyright can be no longer than 60 characters', 'THEME_ERR_ARCHIVE' => 'Please select an archive method', + 'THEME_ERR_NOT_THEME' => 'The archive you specified does not contain a valid theme.', 'THEME_UPDATED' => 'Theme updated successfully', 'THEME_DB_ADDED' => 'New theme added to database', diff --git a/phpBB/style.php b/phpBB/style.php index ec0d3a289b..dad6b24a88 100644 --- a/phpBB/style.php +++ b/phpBB/style.php @@ -67,7 +67,7 @@ if (!empty($_GET['id']) && !empty($_GET['sid'])) if ($db->sql_fetchrow($result)) { - $sql = "SELECT css_data + $sql = "SELECT theme_data FROM {$table_prefix}styles_theme WHERE theme_id = $id"; $result2 = $db->sql_query($sql, 300); @@ -75,9 +75,9 @@ if (!empty($_GET['id']) && !empty($_GET['sid'])) if ($row = $db->sql_fetchrow($result2)) { header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 3600)); - //header('Content-type: text/css'); + header('Content-type: text/css'); - echo $row['css_data']; + echo $row['theme_data']; } $db->sql_freeresult($result2); }