From 2faf2639ee89ab6e92ac474bbc01ca226c4c4ed3 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 2 Jan 2006 17:30:59 +0000 Subject: [PATCH] - install style and style elements - refresh template and style cache git-svn-id: file:///svn/phpbb/trunk@5416 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/style/acp_main.html | 1 - phpBB/adm/style/acp_modules.html | 2 +- phpBB/adm/style/acp_styles.html | 10 +- phpBB/includes/acp/acp_modules.php | 4 +- phpBB/includes/acp/acp_styles.php | 631 +++++++++++++++++++++++++- phpBB/includes/constants.php | 1 - phpBB/includes/functions.php | 4 + phpBB/includes/functions_admin.php | 54 +++ phpBB/includes/functions_compress.php | 14 +- phpBB/includes/functions_transfer.php | 32 +- phpBB/language/en/acp/common.php | 9 + phpBB/language/en/acp/styles.php | 30 ++ phpBB/language/en/common.php | 1 + 13 files changed, 754 insertions(+), 39 deletions(-) diff --git a/phpBB/adm/style/acp_main.html b/phpBB/adm/style/acp_main.html index e36d51bc31..4b754c3c74 100644 --- a/phpBB/adm/style/acp_main.html +++ b/phpBB/adm/style/acp_main.html @@ -81,7 +81,6 @@ -

{L_ADMIN_LOG}

{L_ADMIN_LOG_INDEX_EXPLAIN}

diff --git a/phpBB/adm/style/acp_modules.html b/phpBB/adm/style/acp_modules.html index 4aca37e524..ee3369fd9a 100644 --- a/phpBB/adm/style/acp_modules.html +++ b/phpBB/adm/style/acp_modules.html @@ -78,7 +78,7 @@
-
+

diff --git a/phpBB/adm/style/acp_styles.html b/phpBB/adm/style/acp_styles.html index d8d1d11d9e..9d2cfdb4f1 100644 --- a/phpBB/adm/style/acp_styles.html +++ b/phpBB/adm/style/acp_styles.html @@ -163,24 +163,24 @@ {L_TITLE}
-
+
{NAME}
-
+
{COPYRIGHT}
-
+
{TEMPLATE_NAME}
-
+
{THEME_NAME}
-
+
{IMAGESET_NAME}
diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index 62c071dff8..b99d2c3824 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -299,7 +299,7 @@ class acp_modules $module_data['module_name'] = request_var('module_name', (string) $module_row['module_name']); $module_data['module_enabled'] = request_var('module_enabled', (int) $module_row['module_enabled']); $module_data['module_display'] = request_var('module_display', (int) $module_row['module_display']); - $module_data['parent_id'] = request_var('parent_id', (int) $module_row['parent_id']); + $module_data['parent_id'] = request_var('module_parent_id', (int) $module_row['parent_id']); $module_data['module_class'] = $this->module_class; $module_data['module_langname'] = request_var('module_langname', (string) $module_row['module_langname']); $module_data['module_mode'] = request_var('module_mode', (string) $module_row['module_mode']); @@ -385,7 +385,7 @@ class acp_modules $template->assign_vars(array_merge(array( 'S_EDIT_MODULE' => true, 'S_IS_CAT' => $is_cat, - 'S_CAT_OPTIONS' => $s_cat_option . $this->make_module_select($parent_id, ($action == 'edit') ? $module_row['module_id'] : false, false, false, false, true), + 'S_CAT_OPTIONS' => $s_cat_option . $this->make_module_select($module_data['parent_id'], ($action == 'edit') ? $module_row['module_id'] : false, false, false, false, true), 'S_MODULE_NAMES' => $s_name_options, 'S_MODULE_MODES' => $s_mode_options, 'U_BACK' => $u_action . '&parent_id=' . $parent_id, diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 3774a9ae87..331f04f3f3 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -8,6 +8,11 @@ * */ +/** +* todo: +* templates->cache (show template files in cache) +*/ + /** * @package acp */ @@ -102,11 +107,14 @@ pagination_sep = \'{PAGINATION_SEP}\' } break; - case 'add': case 'install': - install($mode, $action, $style_id); + $this->install($mode, $action); + return; break; + case 'add': + break; + case 'details': if ($style_id) { @@ -151,11 +159,99 @@ pagination_sep = \'{PAGINATION_SEP}\' case 'template': + switch ($action) + { + // Refresh/Renew template cache + case 'refresh': + + $sql = 'SELECT * + FROM ' . STYLES_TPL_TABLE . " + WHERE template_id = $style_id"; + $result = $db->sql_query($sql); + $template_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$template_row) + { + trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action)); + } + + if ($template_row['template_storedb'] && file_exists("{$phpbb_root_path}styles/{$template_row['template_path']}/template/")) + { + $filelist = array('/' => array()); + + $sql = 'SELECT template_filename, template_mtime + FROM ' . STYLES_TPLDATA_TABLE . " + WHERE template_id = $style_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + if (@filemtime("{$phpbb_root_path}styles/{$template_row['template_path']}/template/" . $row['template_filename']) > $row['template_mtime']) + { + $filelist['/'][] = $row['template_filename']; + } + } + $db->sql_freeresult($result); + + $this->store_templates('update', $style_id, $template_row['template_path'], $filelist); + unset($filelist); + } + + break; + } + $this->frontend('template', array('cache', 'details', 'refresh', 'export', 'delete')); break; case 'theme': + switch ($action) + { + // Refresh/Renew theme cache + case 'refresh': + + $sql = 'SELECT * + FROM ' . STYLES_CSS_TABLE . " + WHERE theme_id = $style_id"; + $result = $db->sql_query($sql); + $theme_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$theme_row) + { + trigger_error($user->lang['NO_THEME'] . adm_back_link($this->u_action)); + } + + if ($theme_row['theme_storedb'] && file_exists("{$phpbb_root_path}styles/{$theme_row['theme_path']}/theme/stylesheet.css")) + { + $theme_data = implode('', file("{$phpbb_root_path}styles/" . $theme_row['theme_path'] . '/theme/stylesheet.css')); + + // Match CSS imports + $matches = array(); + preg_match_all('/@import url\(\"(.*)\"\);/i', $theme_data, $matches); + + if (sizeof($matches)) + { + foreach ($matches[0] as $idx => $match) + { + $theme_data = str_replace($match, $this->load_css_file($theme_row['theme_path'], $matches[1][$idx]), $theme_data); + } + } + + // Save CSS contents + $sql_ary = array( + 'theme_mtime' => @filemtime("{$phpbb_root_path}styles/{$theme_row['theme_path']}/theme/stylesheet.css"), + 'theme_data' => $theme_data + ); + + $sql = 'UPDATE ' . STYLES_CSS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " + WHERE theme_id = $style_id"; + $db->sql_query($sql); + } + break; + } + $this->frontend('theme', array('details', 'refresh', 'export', 'delete')); break; @@ -783,7 +879,7 @@ pagination_sep = \'{PAGINATION_SEP}\' */ function details($mode, $style_id) { - global $template, $db, $config, $user, $safe_mode, $cache; + global $template, $db, $config, $user, $safe_mode, $cache, $phpbb_root_path; $update = (isset($_POST['update'])) ? true : false; $l_type = strtoupper($mode); @@ -871,23 +967,6 @@ pagination_sep = \'{PAGINATION_SEP}\' $error[] = $user->lang[$l_type . '_ERR_COPY_LONG']; } } -/* - if (!sizeof($error)) - { - // Check if the name already exist - $sql = "SELECT {$mode}_id - FROM $sql_from - WHERE {$mode}_name = '" . $db->sql_escape($name) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $error[] = $user->lang[$l_type . '_ERR_NAME_EXIST']; - } - } -*/ } if ($update && sizeof($error)) @@ -1106,6 +1185,518 @@ pagination_sep = \'{PAGINATION_SEP}\' return $content; } + /** + * Store template files into db + */ + function store_templates($mode, $style_id, $path, $filelist) + { + global $phpbb_root_path, $phpEx, $db; + + $includes = array(); + foreach ($filelist as $pathfile => $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' => $style_id, + 'template_filename' => $file, + 'template_included' => (isset($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")), + ); + + if ($mode == 'insert') + { + $sql = 'INSERT INTO ' . STYLES_TPLDATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); + } + else + { + $sql = 'UPDATE ' . STYLES_TPLDATA_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " + WHERE template_id = $style_id + AND template_filename = '" . $db->sql_escape($file) . "'"; + } + $db->sql_query($sql); + } + } + } + + /** + * Install Style/Template/Theme/Imageset + */ + function install($mode, $action) + { + global $phpbb_root_path, $phpEx, $SID, $config, $db, $cache, $user, $template; + + $l_type = strtoupper($mode); + + $error = $installcfg = $style_row = array(); + $root_path = $cfg_file = ''; + $element_ary = array('template' => STYLES_TPL_TABLE, 'theme' => STYLES_CSS_TABLE, 'imageset' => STYLES_IMAGE_TABLE); + + $install_path = request_var('path', ''); + $update = (isset($_POST['update'])) ? true : false; + + // Installing, obtain cfg file contents + if ($action == 'install' && $install_path) + { + $root_path = $phpbb_root_path . 'styles/' . $install_path . '/'; + $cfg_file = ($mode == 'style') ? "$root_path$mode.cfg" : "$root_path$mode/$mode.cfg"; + + if (!file_exists($cfg_file)) + { + $error[] = $user->lang[$l_type . '_ERR_NOT_' . $l_type]; + } + else + { + $installcfg = parse_cfg_file($cfg_file); + } + } + + // Installing + if (sizeof($installcfg)) + { + $name = $installcfg['name']; + $copyright = $installcfg['copyright']; + $version = $installcfg['version']; + + $style_row = array( + $mode . '_id' => 0, + $mode . '_name' => '', + $mode . '_copyright' => '' + ); + + switch ($mode) + { + case 'style': + + $style_row = array( + 'style_id' => 0, + 'style_name' => $installcfg['name'], + 'style_copyright' => $installcfg['copyright'] + ); + + $reqd_template = (isset($installcfg['required_template'])) ? $installcfg['required_template'] : ''; + $reqd_theme = (isset($installcfg['required_theme'])) ? $installcfg['required_theme'] : ''; + $reqd_imageset = (isset($installcfg['required_imageset'])) ? $installcfg['required_imageset'] : ''; + + // Check to see if each element is already installed, if it is grab the id + foreach ($element_ary as $element => $table) + { + $style_row = array_merge($style_row, array( + $element . '_id' => 0, + $element . '_name' => '', + $element . '_copyright' => '') + ); + + $this->test_installed($element, $error, $root_path, ${'reqd_' . $element}, $style_row[$element . '_id'], $style_row[$element . '_name'], $style_row[$element . '_copyright']); + } + + break; + + case 'template': + $this->test_installed('template', $error, $root_path, false, $style_row['template_id'], $style_row['template_name'], $style_row['template_copyright']); + break; + + case 'theme': + $this->test_installed('theme', $error, $root_path, false, $style_row['theme_id'], $style_row['theme_name'], $style_row['theme_copyright']); + break; + + case 'imageset': + $this->test_installed('imageset', $error, $root_path, false, $style_row['imageset_id'], $style_row['imageset_name'], $style_row['imageset_copyright']); + break; + } + } + else + { +// + } + + $style_row['store_db'] = request_var('store_db', 0); + $style_row['style_active'] = request_var('style_active', 1); + $style_row['style_default'] = request_var('style_default', 0); + + // User has submitted form and no errors have occured + if ($update && !sizeof($error)) + { + $sql_ary = array(); + + if ($mode == 'style') + { + $this->install_style($error, $action, $root_path, $style_row['style_id'], $style_row['style_name'], $style_row['style_copyright'], $style_row['style_active'], $style_row['style_default'], $style_row); + } + else + { + $this->install_element($mode, $error, 'install', $root_path, $style_row[$mode . '_id'], $style_row[$mode . '_name'], $style_row[$mode . '_copyright'], $style_row['store_db']); + } + + if (!sizeof($error)) + { + $cache->destroy('sql', STYLES_TABLE); + + $message = ($style_row['store_db']) ? '_ADDED_DB' : '_ADDED'; + trigger_error($user->lang[$l_type . $message] . adm_back_link($this->u_action)); + } + } + + $this->page_title = 'INSTALL_' . $l_type; + + $template->assign_vars(array( + 'S_DETAILS' => true, + 'S_INSTALL' => true, + 'S_ERROR_MSG' => (sizeof($error)) ? true : false, + 'S_STYLE' => ($mode == 'style') ? true : false, + 'S_TEMPLATE' => ($mode == 'template') ? true : false, + 'S_THEME' => ($mode == 'theme') ? true : false, + + 'S_STORE_DB' => (isset($style_row[$mode . '_storedb'])) ? $style_row[$mode . '_storedb'] : 0, + 'S_STYLE_ACTIVE' => (isset($style_row['style_active'])) ? $style_row['style_active'] : 0, + 'S_STYLE_DEFAULT' => (isset($style_row['style_default'])) ? $style_row['style_default'] : 0, + + 'U_ACTION' => $this->u_action . "&action=$action&path=" . urlencode($install_path), + 'U_BACK' => $this->u_action, + + 'L_TITLE' => $user->lang[$this->page_title], + 'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'], + 'L_NAME' => $user->lang[$l_type . '_NAME'], + 'L_LOCATION' => ($mode == 'template' || $mode == 'theme') ? $user->lang[$l_type . '_LOCATION'] : '', + 'L_LOCATION_EXPLAIN' => ($mode == 'template' || $mode == 'theme') ? $user->lang[$l_type . '_LOCATION_EXPLAIN'] : '', + + 'ERROR_MSG' => (sizeof($error)) ? implode('
', $error) : '', + 'NAME' => $style_row[$mode . '_name'], + 'COPYRIGHT' => $style_row[$mode . '_copyright'], + 'TEMPLATE_NAME' => ($mode == 'style') ? $style_row['template_name'] : '', + 'THEME_NAME' => ($mode == 'style') ? $style_row['theme_name'] : '', + 'IMAGESET_NAME' => ($mode == 'style') ? $style_row['imageset_name'] : '') + ); + } + + /** + * Is this element installed? If not, grab its cfg details + */ + function test_installed($element, &$error, $root_path, $reqd_name, &$id, &$name, &$copyright) + { + global $db, $user; + + switch ($element) + { + case 'template': + $sql_from = STYLES_TPL_TABLE; + break; + + case 'theme': + $sql_from = STYLES_CSS_TABLE; + break; + + case 'imageset': + $sql_from = STYLES_IMAGE_TABLE; + break; + } + + $l_element = strtoupper($element); + + $chk_name = ($reqd_name !== false) ? $reqd_name : $name; + + $sql = "SELECT {$element}_id, {$element}_name + FROM $sql_from + WHERE {$element}_name = '" . $db->sql_escape($chk_name) . "'"; + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + $name = $row[$element . '_name']; + $id = $row[$element . '_id']; + } + else + { + if (!($cfg = @file("$root_path$element/$element.cfg"))) + { + $error[] = sprintf($user->lang['REQUIRES_' . $l_element], $reqd_name); + return false; + } + + $cfg = parse_cfg_file("$root_path$element/$element.cfg", $cfg); + + $name = $cfg['name']; + $copyright = $cfg['copyright']; + $id = 0; + + unset($cfg); + } + $db->sql_freeresult($result); + } + + /** + * Install/Add style + */ + function install_style(&$error, $action, $root_path, &$id, $name, $copyright, $active, $default, &$style_row) + { + global $config, $db, $user; + + $element_ary = array('template', 'theme', 'imageset'); + + if (!$name) + { + $error[] = $user->lang[$l_type . '_ERR_STYLE_NAME']; + } + + // Check if the character set is allowed + if (!preg_match('/^[a-z0-9_\-\+ ]+$/i', $name)) + { + $error[] = $user->lang[$l_type . '_ERR_NAME_CHARS']; + } + + // Check length settings + if (strlen($name) > 30) + { + $error[] = $user->lang[$l_type . '_ERR_NAME_LONG']; + } + + if (strlen($copyright) > 60) + { + $error[] = $user->lang[$l_type . '_ERR_COPY_LONG']; + } + + // Check if the name already exist + $sql = 'SELECT style_id + FROM ' . STYLES_TABLE . " + WHERE style_name = '" . $db->sql_escape($name) . "'"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row) + { + $error[] = $user->lang[$l_type . '_ERR_NAME_EXIST']; + } + + if (sizeof($error)) + { + return false; + } + + foreach ($element_ary as $element) + { + // Zero id value ... need to install element ... run usual checks + // and do the install if necessary + if (!$style_row[$element . '_id']) + { + $this->install_element($element, $error, $action, $root_path, $style_row[$element . '_id'], $style_row[$element . '_name'], $style_row[$element . '_copyright']); + } + } + + if (!$style_row['template_id'] || !$style_row['theme_id'] || !$style_row['imageset_id']) + { + $error[] = $user->lang['STYLE_ERR_NO_IDS']; + } + + if (sizeof($error)) + { + return false; + } + + $db->sql_transaction('begin'); + + $sql_ary = array( + 'style_name' => $name, + 'style_copyright' => $copyright, + 'style_active' => $active, + 'template_id' => $style_row['template_id'], + 'theme_id' => $style_row['theme_id'], + 'imageset_id' => $style_row['imageset_id'], + ); + + $sql = 'INSERT INTO ' . STYLES_TABLE . ' + ' . $db->sql_build_array('INSERT', $sql_ary); + $db->sql_query($sql); + + $id = $db->sql_nextid(); + + if ($default) + { + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_style = $id + WHERE user_style = " . $config['default_style']; + $db->sql_query($sql); + + set_config('default_style', $id); + } + + $db->sql_transaction('commit'); + + add_log('admin', 'LOG_STYLE_ADD', $name); + } + + /** + * Install/add an element, doing various checks as we go + */ + function install_element($mode, &$error, $action, $root_path, &$id, $name, $copyright, $store_db = 0) + { + global $phpbb_root_path, $db, $user; + + switch ($mode) + { + case 'template': + $sql_from = STYLES_TPL_TABLE; + break; + + case 'theme': + $sql_from = STYLES_CSS_TABLE; + break; + + case 'imageset': + $sql_from = STYLES_IMAGE_TABLE; + break; + } + + $l_type = strtoupper($mode); + $path = str_replace(' ', '_', $name); + + if (!$name) + { + $error[] = $user->lang[$l_type . '_ERR_STYLE_NAME']; + } + + // Check if the character set is allowed + if (!preg_match('/^[a-z0-9_\-\+ ]+$/i', $name)) + { + $error[] = $user->lang[$l_type . '_ERR_NAME_CHARS']; + } + + // Check length settings + if (strlen($name) > 30) + { + $error[] = $user->lang[$l_type . '_ERR_NAME_LONG']; + } + + if (strlen($copyright) > 60) + { + $error[] = $user->lang[$l_type . '_ERR_COPY_LONG']; + } + + // Check if the name already exist + $sql = "SELECT {$mode}_id + FROM $sql_from + WHERE {$mode}_name = '" . $db->sql_escape($name) . "'"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row) + { + // If it exist, we just use the stlye on installation + if ($action == 'install') + { + $id = $row[$mode . '_id']; + return false; + } + + $error[] = $user->lang[$l_type . '_ERR_NAME_EXIST']; + } + + if (sizeof($error)) + { + return false; + } + + if ($action != 'install') + { + @mkdir("{$phpbb_root_path}styles/$path", 0777); + @chmod("{$phpbb_root_path}styles/$path", 0777); + + if ($root_path) + { + $this->copy_files("$root_path$type", filelist("$root_path$type", '', '*'), "$path/$type"); + } + } + + $sql_ary = array( + $mode . '_name' => $name, + $mode . '_copyright' => $copyright, + $mode . '_path' => $path, + ); + + if ($mode != 'imageset') + { + switch ($mode) + { + case 'template': + $sql_ary += array( + $mode . '_storedb' => (!is_writeable("{$phpbb_root_path}styles/$path/$mode")) ? 1 : 0 + ); + break; + + case 'theme': + $sql_ary += array( + 'theme_storedb' => (!is_writeable("{$phpbb_root_path}styles/$path/theme/stylesheet.css")) ? 1 : $store_db, + 'theme_data' => ($store_db) ? (($root_path) ? str_replace('./', "styles/$path/theme/", implode('', file("$root_path/$type/stylesheet.css"))) : '') : '', + 'theme_mtime' => ($store_db) ? filemtime("{$phpbb_root_path}styles/$path/theme/stylesheet.css") : 0 + ); + break; + } + } + else + { + $cfg_data = parse_cfg_file("$root_path$mode/imageset.cfg"); + + foreach ($cfg_data as $key => $value) + { + if (strpos($key, 'img_') === 0) + { + $key = substr($key, 4); + $sql_ary[$key] = str_replace('{PATH}', "styles/$path/imageset/", trim($value)); + } + } + unset($cfg_data); + } + + $db->sql_transaction('begin'); + + $sql = "INSERT INTO $sql_from + " . $db->sql_build_array('INSERT', $sql_ary); + $db->sql_query($sql); + + $id = $db->sql_nextid(); + + if ($mode == 'template' && $store_db) + { + $filelist = filelist("{$root_path}template", '', 'html'); + $this->store_templates('insert', $id, $path, $filelist); + } + + $db->sql_transaction('commit'); + + $log = ($store_db) ? 'LOG_' . $l_type . '_ADD_DB' : 'LOG_' . $l_type . '_ADD_FS'; + add_log('admin', $log, $name); + } } /** diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index b6932e5439..eb4217fb5c 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -141,7 +141,6 @@ define('FORUMS_ACCESS_TABLE', $table_prefix.'forum_access'); define('FORUMS_TRACK_TABLE', $table_prefix.'forums_marking'); define('FORUMS_WATCH_TABLE', $table_prefix.'forums_watch'); define('GROUPS_TABLE', $table_prefix.'groups'); -define('GROUPS_MODERATOR_TABLE', $table_prefix.'groups_moderator'); define('ICONS_TABLE', $table_prefix.'icons'); define('LANG_TABLE', $table_prefix.'lang'); define('LOG_TABLE', $table_prefix.'log'); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 64fda22ac8..3731b073cc 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1508,6 +1508,10 @@ function parse_cfg_file($filename, $lines = false) { $value = true; } + else if (!trim($value)) + { + $value = ''; + } else if (($value{0} == "'" && $value{sizeof($value)-1} == "'") || ($value{0} == '"' && $value{sizeof($value)-1} == '"')) { $value = substr($value, 1, sizeof($value)-2); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index e80696d23d..3929b43448 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2475,6 +2475,60 @@ function get_database_size() return $dbsize; } +/** +* Retrieve contents from remotely stored file +*/ +function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port = 80, $timeout = 10) +{ + global $user; + + if ($fsock = @fsockopen($host, $port, $errno, $errstr, $timeout)) + { + @fputs($fsock, "GET $directory/$filename HTTP/1.1\r\n"); + @fputs($fsock, "HOST: $host\r\n"); + @fputs($fsock, "Connection: close\r\n\r\n"); + + $file_info = ''; + $get_info = false; + + while (!@feof($fsock)) + { + if ($get_info) + { + $file_info .= @fread($fsock, 1024); + } + else + { + $line = @fgets($fsock, 1024); + if ($line == "\r\n") + { + $get_info = true; + } + else if (strpos($line, '404 Not Found') !== false) + { + $errstr = $user->lang['FILE_NOT_FOUND']; + return false; + } + } + } + @fclose($fsock); + } + else + { + if ($errstr) + { + return false; + } + else + { + $errstr = 'fsock disabled'; + return false; + } + } + + return $file_info; +} + /** * Tidy database * Removes all tracking rows older than 6 months, including mark_posted informations diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php index 0b24ec14dc..55457bc226 100644 --- a/phpBB/includes/functions_compress.php +++ b/phpBB/includes/functions_compress.php @@ -184,7 +184,12 @@ class compress_zip extends compress $file_name_length = unpack("v", fread($this->fp, 2)); // filename length $extra_field_length = unpack("v", fread($this->fp, 2)); // extra field length $file_name = fread($this->fp, $file_name_length[1]); // filename - fread($this->fp, $extra_field_length[1]); + + if ($extra_field_length[1]) + { + fread($this->fp, $extra_field_length[1]); + } + $file['offset'] = ftell($this->fp); // Bypass the whole compressed contents, and look for the next file @@ -560,7 +565,12 @@ class compress_tar extends compress { $fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && extension_loaded('zlib')) ? 'gzwrite' : 'fwrite'); $fzclose = ($this->isbz && function_exists('bzclose')) ? 'bzclose' : (($this->isgz && extension_loaded('zlib')) ? 'gzclose' : 'fclose'); - if ($this->wrote) $fzwrite($this->fp, pack("a1024", "")); + + if ($this->wrote) + { + $fzwrite($this->fp, pack("a1024", "")); + } + $fzclose($this->fp); } diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php index eee92c2cac..a7e3277196 100644 --- a/phpBB/includes/functions_transfer.php +++ b/phpBB/includes/functions_transfer.php @@ -37,7 +37,7 @@ class transfer $this->dir_perms = 777; // We use the store directory as temporary path to circumvent open basedir restrictions - $this->tmp_path = $phpbb_root_path . 'store/', + $this->tmp_path = $phpbb_root_path . 'store/'; } /** @@ -99,6 +99,8 @@ class transfer { global $phpbb_root_path; + $dir = str_replace($phpbb_root_path, '', $dir); + $dir = explode('/', $dir); $dirs = ''; @@ -176,6 +178,14 @@ class transfer return $this->_rmdir($dir); } + /** + * Open session + */ + function open_session() + { + return $this->_init(); + } + /** * Close current session */ @@ -216,7 +226,7 @@ class ftp extends transfer $this->username = $username; $this->password = $password; $this->timeout = $timeout; - $this->root_path = (($root_path{0} != '/' ) ? '/' : '') . (substr($root_path, -1, 1) == '/') ? substr($root_path, 0, -1) : $root_path; + $this->root_path = (($root_path{0} != '/' ) ? '/' : '') . ((substr($root_path, -1, 1) == '/') ? substr($root_path, 0, -1) : $root_path); return; } @@ -224,7 +234,7 @@ class ftp extends transfer /** * Init FTP Session */ - function init() + function _init() { // connect to the server $this->connection = @ftp_connect($this->host, $this->port, $this->timeout); @@ -246,7 +256,7 @@ class ftp extends transfer // change to the root directory if (!$this->_chdir($this->root_path)) { - return false; + return 'Unable to change directory'; } return true; @@ -302,9 +312,12 @@ class ftp extends transfer // extension list for files that need to be transfered as binary. // Taken from the old EasyMOD which was taken from the attachment MOD - $extensions = array('ace', 'ai', 'aif', 'aifc', 'aiff', 'ar', 'asf', 'asx', 'au', 'avi', 'doc', 'dot', 'gif', 'gtar', 'gz', 'ivf', 'jpeg', 'jpg', 'm3u', 'mid', 'midi', 'mlv', 'mp2', 'mp3', 'mp2v', 'mpa', 'mpe', 'mpeg', 'mpg', 'mpv2', 'pdf', 'png', 'ppt', 'ps', 'rar', 'rm', 'rmi', 'snd', 'swf', 'tga', 'tif', 'wav', 'wax', 'wm', 'wma', 'wmv', 'wmx', 'wvx', 'xls', 'zip') ; - $is_binary = in_array($file_extension, $extensions); - $mode = ($is_binary) ? FTP_BINARY : FTP_ASCII; +// $extensions = array('ace', 'ai', 'aif', 'aifc', 'aiff', 'ar', 'asf', 'asx', 'au', 'avi', 'doc', 'dot', 'gif', 'gtar', 'gz', 'ivf', 'jpeg', 'jpg', 'm3u', 'mid', 'midi', 'mlv', 'mp2', 'mp3', 'mp2v', 'mpa', 'mpe', 'mpeg', 'mpg', 'mpv2', 'pdf', 'png', 'ppt', 'ps', 'rar', 'rm', 'rmi', 'snd', 'swf', 'tga', 'tif', 'wav', 'wax', 'wm', 'wma', 'wmv', 'wmx', 'wvx', 'xls', 'zip') ; +// $is_binary = in_array($file_extension, $extensions); +// $mode = ($is_binary) ? FTP_BINARY : FTP_ASCII; + + // We only use the BINARY file mode to cicumvent rewrite actions from ftp server (mostly linefeeds being replaced) + $mode = FTP_BINARY; $to_dir = dirname($to_file); $to_file = basename($to_file); @@ -329,6 +342,11 @@ class ftp extends transfer */ function _close() { + if (!$this->connection) + { + return false; + } + return @ftp_quit($this->connection); } diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index ef46ee9be0..e989220aa5 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -105,6 +105,7 @@ $lang = array_merge($lang, array( 'ACP_STYLES' => 'Styles', 'ACP_TEMPLATES' => 'Templates', 'ACP_THEMES' => 'Themes', + 'ACP_UPDATE' => 'Updating', 'ACP_USER_ATTACH' => 'Attachments', 'ACP_USER_AVATAR' => 'Avatar', 'ACP_USER_FEEDBACK' => 'Feedback', @@ -116,6 +117,7 @@ $lang = array_merge($lang, array( 'ACP_USER_PROFILE' => 'Profile', 'ACP_USER_SECURITY' => 'User Security', 'ACP_USER_SIG' => 'Signature', + 'ACP_VERSION_CHECK' => 'Check for Updates', 'ACP_WORDS' => 'Word Censoring', 'ACTION' => 'Action', @@ -331,6 +333,8 @@ $lang = array_merge($lang, array( 'LOG_USERS_APPROVED' => 'Users approved in usergroup %s
» %s', 'LOG_USERS_ADDED' => 'Added new members to usergroup %s
» %s', + 'LOG_IMAGESET_ADD_DB' => 'Added new imageset to database
» %s', + 'LOG_IMAGESET_ADD_FS' => 'Add new imageset on filesystem
» %s', 'LOG_IMAGESET_DELETE' => 'Deleted imageset
» %s', 'LOG_IMAGESET_EDIT_DETAILS' => 'Edited imageset details
» %s', 'LOG_IMAGESET_EXPORT' => 'Exported imageset
» %s', @@ -375,14 +379,19 @@ $lang = array_merge($lang, array( 'LOG_RESYNC_POSTCOUNTS' => 'User postcounts synced', 'LOG_RESYNC_STATS' => 'Post, topic and user stats reset', + 'LOG_STYLE_ADD' => 'Added new style
» %s', 'LOG_STYLE_DELETE' => 'Deleted style
» %s', 'LOG_STYLE_EDIT_DETAILS' => 'Edited style
» %s', 'LOG_STYLE_EXPORT' => 'Exported style
» %s', + 'LOG_TEMPLATE_ADD_DB' => 'Added new template set to database
» %s', + 'LOG_TEMPLATE_ADD_FS' => 'Add new template set on filesystem
» %s', 'LOG_TEMPLATE_DELETE' => 'Deleted template set
» %s', 'LOG_TEMPLATE_EDIT_DETAILS' => 'Edited template details
» %s', 'LOG_TEMPLATE_EXPORT' => 'Exported template set
» %s', + 'LOG_THEME_ADD_DB' => 'Added new theme to database
» %s', + 'LOG_THEME_ADD_FS' => 'Add new theme on filesystem
» %s', 'LOG_THEME_DELETE' => 'Theme deleted
» %s', 'LOG_THEME_EDIT_DETAILS' => 'Edited theme details
» %s', 'LOG_THEME_EXPORT' => 'Exported theme
» %s', diff --git a/phpBB/language/en/acp/styles.php b/phpBB/language/en/acp/styles.php index c3962207a0..a83ffcc6ce 100644 --- a/phpBB/language/en/acp/styles.php +++ b/phpBB/language/en/acp/styles.php @@ -33,6 +33,14 @@ $lang = array_merge($lang, array( 'ACP_STYLES_EXPLAIN' => 'Here you can manage the available styles on your board. A style consists off a template, theme and imageset. You may alter existing styles, delete, deactivate, reactivate, create or import new ones. You can also see what a style will look like using the preview function. The current default style is noted by the presence of an asterix (*). Also listed is the total user count for each style, note that overriding user styles will not be reflected here.', 'ACP_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.', 'ACP_THEMES_EXPLAIN' => 'From here you can create, install, edit, delete and export themes. A theme is the combination of colours and images that are applied to your templates to define the basic look of your forum. The range of options open to you depends on the configuration of your server and phpBB installation, see the Manual for further details. Please note that when creating new themes the use of an existing theme as a basis is optional.', + 'ADD_IMAGESET' => 'Create Imageset', + 'ADD_IMAGESET_EXPLAIN' => 'Here you can create a new imageset. Depending on your server configuration and file permissions you may have additional options here. For example you may be able to base this imageset on an existing one. You may also be able to upload or import (from the store directory) a imageset archive. If you upload or import an archive the imageset name can be optionally taken from the archive name (to do this leave the imageset name blank).', + 'ADD_STYLE' => 'Create Style', + 'ADD_STYLE_EXPLAIN' => 'Here you can create a new style. Depending on your server configuration and file permissions you may have additional options. For example you may be able to base this style on an existing one. You may also be able to upload or import (from the store directory) a style archive. If you upload or import an archive the style name will be determined automatically.', + '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).', + '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).', 'ARCHIVE_FORMAT' => 'Archive file type', 'CACHE' => 'Cache', @@ -66,6 +74,8 @@ $lang = array_merge($lang, array( 'FROM' => 'from', // "Create new style .... from ..." + 'IMAGESET_ADDED' => 'New imageset added on filesystem', + 'IMAGESET_ADDED_DB' => 'New imageset added to database', 'IMAGESET_DELETED' => 'Imageset deleted successfully', 'IMAGESET_DELETED_FS' => 'Imageset removed from database but some files may remain on the filesystem', 'IMAGESET_DETAILS_UPDATED' => 'Imageset details successfully updated', @@ -74,6 +84,7 @@ $lang = array_merge($lang, array( 'IMAGESET_ERR_NAME_CHARS' => 'The imageset name can only contain alphanumeric characters, -, +, _ and space', 'IMAGESET_ERR_NAME_EXIST' => 'A imageset with that name already exists', 'IMAGESET_ERR_NAME_LONG' => 'The imageset name can be no longer than 30 characters', + 'IMAGESET_ERR_NOT_IMAGESET' => 'The archive you specified does not contain a valid imageset.', 'IMAGESET_ERR_STYLE_NAME' => 'You must supply a name for this imageset', 'IMAGESET_EXPORT' => 'Export Imageset', 'IMAGESET_EXPORT_EXPLAIN' => 'Here you can export an imageset in the form of an archive. This archive will contain all the data necessary to install the set of images on another board. You may select whether to download the file directly or to place it in your store folder for download later or via FTP.', @@ -82,6 +93,14 @@ $lang = array_merge($lang, array( 'INCLUDE_IMAGESET' => 'Include imageset', 'INCLUDE_TEMPLATE' => 'Include template', 'INCLUDE_THEME' => 'Include theme', + 'INSTALL_IMAGESET' => 'Install Imageset', + 'INSTALL_IMAGESET_EXPLAIN' => 'Here you can install your selected imageset. You can edit certain details if you wish or use the installation defaults.', + 'INSTALL_STYLE' => 'Install Style', + 'INSTALL_STYLE_EXPLAIN' => 'Here you can install a new style and if appropriate the corresponding style elements. If you already have the relevant style elements installed they will not be overwritten. Some styles require existing style elements to already be installed. If you try installing such a style and do not have the required elements you will be notified.', + '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.', + 'INSTALL_THEME' => 'Install Theme', + 'INSTALL_THEME_EXPLAIN' => 'Here you can install your selected theme. You can edit certain details if you wish or use the installation defaults.', 'INSTALLED_IMAGESET' => 'Installed imagesets', 'INSTALLED_STYLE' => 'Installed styles', 'INSTALLED_TEMPLATE' => 'Installed templates', @@ -111,12 +130,16 @@ $lang = array_merge($lang, array( 'REPLACE_TEMPLATE_EXPLAIN' => 'This template set will replace the one you are deleting in any styles that use it.', 'REPLACE_THEME' => 'Replace theme with', 'REPLACE_THEME_EXPLAIN' => 'This theme will replace the one you are deleting in any styles that use it.', + 'REQUIRES_IMAGESET' => 'This style requires the %s imageset to be installed.', + 'REQUIRES_TEMPLATE' => 'This style requires the %s template set to be installed.', + 'REQUIRES_THEME' => 'This style requires the %s theme to be installed.', 'STORE_DATABASE' => 'Database', 'STORE_FILESYSTEM' => 'Filesystem', 'STYLE_ACTIVATE' => 'Activate', 'STYLE_ACTIVE' => 'Active', + 'STYLE_ADDED' => 'Style added successfully', 'STYLE_DEACTIVATE' => 'Deactivate', 'STYLE_DEFAULT' => 'Make default style', 'STYLE_DELETED' => 'Style deleted successfully', @@ -128,6 +151,7 @@ $lang = array_merge($lang, array( 'STYLE_ERR_NAME_EXIST' => 'A style with that name already exists', 'STYLE_ERR_NAME_LONG' => 'The style name can be no longer than 30 characters', 'STYLE_ERR_NO_IDS' => 'You must select a template, theme and imageset for this style', + 'STYLE_ERR_NOT_STYLE' => 'The imported or uploaded file did not contain a valid style archive.', 'STYLE_ERR_STYLE_NAME' => 'You must supply a name for this style', 'STYLE_EXPORT' => 'Export Style', 'STYLE_EXPORT_EXPLAIN' => 'Here you can export a style in the form of an archive. A style does not need to contain all elements but it must contain at least one. For example if you have created a new theme and imageset for a commonly used template you could simply export the theme and imageset and ommit the template. You may select whether to download the file directly or to place it in your store folder for download later or via FTP.', @@ -138,6 +162,8 @@ $lang = array_merge($lang, array( 'STYLE_THEME' => 'Theme', 'STYLE_USED_BY' => 'Used by', + 'TEMPLATE_ADDED' => 'Template set added and stored on filesystem', + 'TEMPLATE_ADDED_DB' => 'Template set added and stored in database', 'TEMPLATE_DELETED' => 'Template set deleted successfully', 'TEMPLATE_DELETED_FS' => 'Template set removed from database but some files may remain on the filesystem', 'TEMPLATE_DETAILS_UPDATED' => 'Template details successfully updated', @@ -146,6 +172,7 @@ $lang = array_merge($lang, array( 'TEMPLATE_ERR_NAME_CHARS' => 'The template name can only contain alphanumeric characters, -, +, _ and space', 'TEMPLATE_ERR_NAME_EXIST' => 'A template set with that name already exists', 'TEMPLATE_ERR_NAME_LONG' => 'The template name can be no longer than 30 characters', + 'TEMPLATE_ERR_NOT_TEMPLATE' => 'The archive you specified does not contain a valid template set.', 'TEMPLATE_ERR_STYLE_NAME' => 'You must supply a name for this templates', 'TEMPLATE_EXPORT' => 'Export Templates', 'TEMPLATE_EXPORT_EXPLAIN' => 'Here you can export a template set in the form of an archive. This archive will contain all the files necessary to install the templates on another board. You may select whether to download the file directly or to place it in your store folder for download later or via FTP.', @@ -154,6 +181,8 @@ $lang = array_merge($lang, array( 'TEMPLATE_LOCATION_EXPLAIN' => 'Images are always stored on the filesystem.', 'TEMPLATE_NAME' => 'Template name', + 'THEME_ADDED' => 'New theme added on filesystem', + 'THEME_ADDED_DB' => 'New theme added to database', 'THEME_DELETED' => 'Theme deleted successfully', 'THEME_DELETED_FS' => 'Theme removed from database but files remain on the filesystem', 'THEME_DETAILS_UPDATED' => 'Theme details successfully updated', @@ -162,6 +191,7 @@ $lang = array_merge($lang, array( 'THEME_ERR_NAME_CHARS' => 'The theme name can only contain alphanumeric characters, -, +, _ and space', 'THEME_ERR_NAME_EXIST' => 'A theme with that name already exists', 'THEME_ERR_NAME_LONG' => 'The theme name can be no longer than 30 characters', + 'THEME_ERR_NOT_THEME' => 'The archive you specified does not contain a valid theme.', 'THEME_ERR_STYLE_NAME' => 'You must supply a name for this theme', 'THEME_EXPORT' => 'Export Theme', 'THEME_EXPORT_EXPLAIN' => 'Here you can export a theme in the form of an archive. This archive will contain all the data necessary to install the theme on another board. You may select whether to download the file directly or to place it in your store folder for download later or via FTP.', diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index b9ce1506d3..0483dd4286 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -126,6 +126,7 @@ $lang = array_merge($lang, array( 'FILENAME' => 'Filename', 'FILESIZE' => 'Filesize', 'FILE_COMMENT' => 'File comment', + 'FILE_NOT_FOUND' => 'The requested file could not be found', 'FIND_USERNAME' => 'Find a member', 'FOLDER' => 'Folder', 'FORGOT_PASS' => 'I forgot my password',