From a8c22829d8e8845cd4ddf4ef8b61a1ed79edfffc Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Mon, 12 Mar 2018 22:57:42 +0100 Subject: Imported from the SVN repository http://svn.wolffelaar.nl/wsvn/phpbb/branches/jessie/ Signed-off-by: Olivier Gayot --- debian/patches/021_multisite.patch | 474 +++++++++++++++++++++++++++++++++++++ 1 file changed, 474 insertions(+) create mode 100644 debian/patches/021_multisite.patch (limited to 'debian/patches/021_multisite.patch') diff --git a/debian/patches/021_multisite.patch b/debian/patches/021_multisite.patch new file mode 100644 index 0000000..cff5bc3 --- /dev/null +++ b/debian/patches/021_multisite.patch @@ -0,0 +1,474 @@ +Author: David Prévot +Reviewed-by: J.M. Roth +Description: Makes caches, file uploads, etc. work when multiple forums use the same codebase. +Bug-Debian: http://bugs.debian.org/437836 +Last-Update: 2013-09-28 +--- a/cron.php ++++ b/cron.php +@@ -72,7 +72,9 @@ + { + case 'queue': + +- if (time() - $config['queue_interval'] <= $config['last_queue_run'] || !file_exists($phpbb_root_path . 'cache/queue.' . $phpEx)) ++ global $url_forum; ++ ++ if (time() - $config['queue_interval'] <= $config['last_queue_run'] || !file_exists($phpbb_root_path . 'cache/' . $url_forum . '/queue.' . $phpEx)) + { + break; + } +--- a/includes/acm/acm_file.php ++++ b/includes/acm/acm_file.php +@@ -35,8 +35,16 @@ + */ + function acm() + { +- global $phpbb_root_path; +- $this->cache_dir = $phpbb_root_path . 'cache/'; ++ global $phpbb_root_path, $url_forum; ++ ++ $cache = $phpbb_root_path . 'cache/' . $url_forum . '/'; ++ ++ if (!file_exists($cache)) { ++ mkdir($cache); ++ } ++ @chmod($cache, 0750); ++ ++ $this->cache_dir = $cache; + } + + /** +--- a/includes/acp/acp_database.php ++++ b/includes/acp/acp_database.php +@@ -27,7 +27,11 @@ + function main($id, $mode) + { + global $cache, $db, $user, $auth, $template, $table_prefix; +- global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; ++ global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx, $url_forum; ++ ++ if (!file_exists("$phpbb_root_path/store/$url_forum")) { ++ mkdir("$phpbb_root_path/store/$url_forum", 0750); ++ } + + if (!class_exists('phpbb_db_tools')) + { +@@ -234,7 +238,7 @@ + trigger_error($user->lang['BACKUP_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); + } + +- $file_name = $phpbb_root_path . 'store/' . $matches[0]; ++ $file_name = $phpbb_root_path . 'store/'. $url_forum. '/' . $matches[0]; + + if (!file_exists($file_name) || !is_readable($file_name)) + { +@@ -434,7 +438,7 @@ + $methods[] = $type; + } + +- $dir = $phpbb_root_path . 'store/'; ++ $dir = $phpbb_root_path . 'store/'. $url_forum. '/'; + $dh = @opendir($dir); + + $backup_files = array(); +@@ -553,8 +557,8 @@ + + if ($store == true) + { +- global $phpbb_root_path; +- $file = $phpbb_root_path . 'store/' . $filename . $ext; ++ global $phpbb_root_path, $url_forum; ++ $file = $phpbb_root_path . 'store/'. $url_forum. '/' . $filename . $ext; + + $this->fp = $open($file, 'w'); + +--- a/includes/acp/acp_language.php ++++ b/includes/acp/acp_language.php +@@ -34,6 +34,7 @@ + global $config, $db, $user, $auth, $template, $cache; + global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix; + global $safe_mode, $file_uploads; ++ global $url_forum; + + include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx); + +@@ -269,15 +270,15 @@ + + foreach ($mkdir_ary as $dir) + { +- $dir = $phpbb_root_path . 'store/' . $dir; ++ $dir = $phpbb_root_path . 'store/' . $url_forum . '/' . $dir; + + if (!is_dir($dir)) + { +- if (!@mkdir($dir, 0777)) ++ if (!@mkdir($dir, 0777, true)) + { + trigger_error("Could not create directory $dir", E_USER_ERROR); + } +- @chmod($dir, 0777); ++ @chmod($dir, 0750); + } + } + } +@@ -398,7 +399,7 @@ + } + + $transfer->rename($lang_path . $file, $lang_path . $file . '.bak'); +- $result = $transfer->copy_file('store/' . $lang_path . $file, $lang_path . $file); ++ $result = $transfer->copy_file('store/' . $url_forum . '/' . $lang_path . $file, $lang_path . $file); + + if ($result === false) + { +@@ -412,9 +413,9 @@ + $transfer->close_session(); + + // Remove from storage folder +- if (file_exists($phpbb_root_path . 'store/' . $lang_path . $file)) ++ if (file_exists($phpbb_root_path . 'store/' . $url_forum . '/' . $lang_path . $file)) + { +- @unlink($phpbb_root_path . 'store/' . $lang_path . $file); ++ @unlink($phpbb_root_path . 'store/' . $url_forum . '/' . $lang_path . $file); + } + + add_log('admin', 'LOG_LANGUAGE_FILE_REPLACED', $file); +@@ -1016,13 +1017,18 @@ + + include_once($phpbb_root_path . 'includes/functions_compress.' . $phpEx); + ++ // create subdir in store before writing to it ++ if (!@mkdir($phpbb_root_path . 'store/' . $url_forum, 0750, true)) ++ { ++ trigger_error("Could not create directory store/$url_forum", E_USER_ERROR); ++ } + if ($use_method == '.zip') + { +- $compress = new compress_zip('w', $phpbb_root_path . 'store/lang_' . $row['lang_iso'] . $use_method); ++ $compress = new compress_zip('w', $phpbb_root_path . 'store/' . $url_forum . '/' . 'lang_' . $row['lang_iso'] . $use_method); + } + else + { +- $compress = new compress_tar('w', $phpbb_root_path . 'store/lang_' . $row['lang_iso'] . $use_method, $use_method); ++ $compress = new compress_tar('w', $phpbb_root_path . 'store/' . $url_forum . '/' . 'lang_' . $row['lang_iso'] . $use_method, $use_method); + } + + // Get email templates +@@ -1075,7 +1081,7 @@ + $compress->close(); + + $compress->download('lang_' . $row['lang_iso']); +- @unlink($phpbb_root_path . 'store/lang_' . $row['lang_iso'] . $use_method); ++ @unlink($phpbb_root_path . 'store/' . $url_forum . '/' . 'lang_' . $row['lang_iso'] . $use_method); + + exit; + +@@ -1232,13 +1238,13 @@ + */ + function get_filename($lang_iso, $directory, $filename, $check_store = false, $only_return_filename = false) + { +- global $phpbb_root_path, $safe_mode; ++ global $phpbb_root_path, $safe_mode, $url_forum; + + $check_filename = "language/$lang_iso/" . (($directory) ? $directory . '/' : '') . $filename; + + if ($check_store) + { +- $check_store_filename = ($safe_mode) ? "store/langfile_{$lang_iso}" . (($directory) ? '_' . $directory : '') . "_{$filename}" : "store/language/$lang_iso/" . (($directory) ? $directory . '/' : '') . $filename; ++ $check_store_filename = ($safe_mode) ? "store/$url_forum/langfile_{$lang_iso}" . (($directory) ? '_' . $directory : '') . "_{$filename}" : "store/$url_forum/language/$lang_iso/" . (($directory) ? $directory . '/' : '') . $filename; + + if (!$only_return_filename && file_exists($phpbb_root_path . $check_store_filename)) + { +--- a/includes/acp/acp_styles.php ++++ b/includes/acp/acp_styles.php +@@ -953,7 +953,7 @@ + */ + function template_cache($template_id) + { +- global $phpbb_root_path, $phpEx, $config, $db, $cache, $user, $template; ++ global $phpbb_root_path, $phpEx, $config, $db, $cache, $user, $template, $url_forum; + + $source = str_replace('/', '.', request_var('source', '')); + $file_ary = array_diff(request_var('delete', array('')), array('')); +@@ -983,7 +983,7 @@ + // 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 ($source && file_exists("{$phpbb_root_path}cache/{$cache_prefix}_$source.html.$phpEx")) ++ if ($source && file_exists("{$phpbb_root_path}cache/$url_forum/{$cache_prefix}_$source.html.$phpEx")) + { + adm_page_header($user->lang['TEMPLATE_CACHE']); + +@@ -995,7 +995,7 @@ + 'FILENAME' => str_replace('.', '/', $source) . '.html') + ); + +- $code = str_replace(array("\r\n", "\r"), array("\n", "\n"), file_get_contents("{$phpbb_root_path}cache/{$cache_prefix}_$source.html.$phpEx")); ++ $code = str_replace(array("\r\n", "\r"), array("\n", "\n"), file_get_contents("{$phpbb_root_path}cache/$url_forum/{$cache_prefix}_$source.html.$phpEx")); + + $conf = array('highlight.bg', 'highlight.comment', 'highlight.default', 'highlight.html', 'highlight.keyword', 'highlight.string'); + foreach ($conf as $ini_var) +@@ -1070,7 +1070,7 @@ + + $filename = "{$cache_prefix}_$file.html.$phpEx"; + +- if (!file_exists("{$phpbb_root_path}cache/$filename")) ++ if (!file_exists("{$phpbb_root_path}cache/$url_forum/$filename")) + { + continue; + } +@@ -1107,10 +1107,10 @@ + $template->assign_block_vars('file', array( + 'U_VIEWSOURCE' => $this->u_action . "&action=cache&id=$template_id&source=$file", + +- 'CACHED' => $user->format_date(filemtime("{$phpbb_root_path}cache/$filename")), ++ 'CACHED' => $user->format_date(filemtime("{$phpbb_root_path}cache/$url_forum/$filename")), + 'FILENAME' => $file, + 'FILENAME_PATH' => $file_tpl, +- 'FILESIZE' => get_formatted_filesize(filesize("{$phpbb_root_path}cache/$filename")), ++ 'FILESIZE' => get_formatted_filesize(filesize("{$phpbb_root_path}cache/$url_forum/$filename")), + 'MODIFIED' => $user->format_date((!$template_row['template_storedb']) ? filemtime($file_tpl) : $filemtime[$file . '.html'])) + ); + } +@@ -1926,7 +1926,7 @@ + */ + function export($mode, $style_id) + { +- global $db, $template, $user, $phpbb_root_path, $cache, $phpEx, $config; ++ global $db, $template, $user, $phpbb_root_path, $cache, $phpEx, $config, $url_forum; + + $update = (isset($_POST['update'])) ? true : false; + +@@ -2271,13 +2271,17 @@ + $path = $style_row[$mode . '_path']; + } + ++ if (!file_exists("$phpbb_root_path/store/$url_forum")) { ++ mkdir("$phpbb_root_path/store/$url_forum", 0750); ++ } ++ + if ($format == 'zip') + { +- $compress = new compress_zip('w', $phpbb_root_path . "store/$path$ext"); ++ $compress = new compress_zip('w', $phpbb_root_path . "store/$url_forum/$path$ext"); + } + else + { +- $compress = new compress_tar('w', $phpbb_root_path . "store/$path$ext", $ext); ++ $compress = new compress_tar('w', $phpbb_root_path . "store/$url_forum/$path$ext", $ext); + } + + if (sizeof($files)) +@@ -2303,11 +2307,11 @@ + if (!$store) + { + $compress->download($path); +- @unlink("{$phpbb_root_path}store/$path$ext"); ++ @unlink("{$phpbb_root_path}store/$url_forum/$path$ext"); + exit; + } + +- trigger_error(sprintf($user->lang[$l_prefix . '_EXPORTED'], "store/$path$ext") . adm_back_link($this->u_action)); ++ trigger_error(sprintf($user->lang[$l_prefix . '_EXPORTED'], "store/$url_forum/$path$ext") . adm_back_link($this->u_action)); + } + } + +@@ -2835,11 +2839,11 @@ + */ + function template_cache_filelist($template_path) + { +- global $phpbb_root_path, $phpEx, $user; ++ global $phpbb_root_path, $phpEx, $user, $url_forum; + + $cache_prefix = 'tpl_' . str_replace('_', '-', $template_path); + +- if (!($dp = @opendir("{$phpbb_root_path}cache"))) ++ if (!($dp = @opendir("{$phpbb_root_path}cache/$url_forum"))) + { + trigger_error($user->lang['TEMPLATE_ERR_CACHE_READ'] . adm_back_link($this->u_action), E_USER_WARNING); + } +@@ -2852,7 +2856,7 @@ + continue; + } + +- if (is_file($phpbb_root_path . 'cache/' . $file) && (strpos($file, $cache_prefix) === 0)) ++ if (is_file($phpbb_root_path . 'cache/' . $url_forum . '/' . $file) && (strpos($file, $cache_prefix) === 0)) + { + $file_ary[] = str_replace('.', '/', preg_replace('#^' . preg_quote($cache_prefix, '#') . '_(.*?)\.html\.' . $phpEx . '$#i', '\1', $file)); + } +@@ -2871,7 +2875,7 @@ + */ + function clear_template_cache($template_row, $file_ary = false) + { +- global $phpbb_root_path, $phpEx, $user; ++ global $phpbb_root_path, $phpEx, $user, $url_forum; + + $cache_prefix = 'tpl_' . str_replace('_', '-', $template_row['template_path']); + +@@ -2889,7 +2893,7 @@ + { + $file = str_replace('/', '.', $file); + +- $file = "{$phpbb_root_path}cache/{$cache_prefix}_$file.html.$phpEx"; ++ $file = "{$phpbb_root_path}cache/$url_forum/{$cache_prefix}_$file.html.$phpEx"; + if (file_exists($file) && is_file($file)) + { + @unlink($file); +--- a/includes/functions.php ++++ b/includes/functions.php +@@ -4769,7 +4769,7 @@ + */ + function page_footer($run_cron = true) + { +- global $db, $config, $template, $user, $auth, $cache, $starttime, $phpbb_root_path, $phpEx; ++ global $db, $config, $template, $user, $auth, $cache, $starttime, $phpbb_root_path, $phpEx, $url_forum; + + // Output page creation time + if (defined('DEBUG')) +@@ -4835,7 +4835,7 @@ + { + $cron_type = ''; + +- if ($time_now - $config['queue_interval'] > $config['last_queue_run'] && !defined('IN_ADMIN') && file_exists($phpbb_root_path . 'cache/queue.' . $phpEx)) ++ if ($time_now - $config['queue_interval'] > $config['last_queue_run'] && !defined('IN_ADMIN') && file_exists($phpbb_root_path . 'cache/' . $url_forum . '/queue.' . $phpEx)) + { + // Process email queue + $cron_type = 'queue'; +--- a/includes/functions_compress.php ++++ b/includes/functions_compress.php +@@ -462,7 +462,7 @@ + */ + function download($filename, $download_name = false) + { +- global $phpbb_root_path; ++ global $phpbb_root_path, $url_forum; + + if ($download_name === false) + { +@@ -475,7 +475,7 @@ + header("Content-Type: $mimetype; name=\"$download_name.zip\""); + header("Content-disposition: attachment; filename=$download_name.zip"); + +- $fp = @fopen("{$phpbb_root_path}store/$filename.zip", 'rb'); ++ $fp = @fopen("{$phpbb_root_path}store/$url_forum/$filename.zip", 'rb'); + if ($fp) + { + while ($buffer = fread($fp, 1024)) +@@ -694,7 +694,7 @@ + */ + function download($filename, $download_name = false) + { +- global $phpbb_root_path; ++ global $phpbb_root_path, $url_forum; + + if ($download_name === false) + { +@@ -724,7 +724,7 @@ + header("Content-Type: $mimetype; name=\"$download_name$this->type\""); + header("Content-disposition: attachment; filename=$download_name$this->type"); + +- $fp = @fopen("{$phpbb_root_path}store/$filename$this->type", 'rb'); ++ $fp = @fopen("{$phpbb_root_path}store/$url_forum/$filename$this->type", 'rb'); + if ($fp) + { + while ($buffer = fread($fp, 1024)) +--- a/includes/functions_messenger.php ++++ b/includes/functions_messenger.php +@@ -641,10 +641,10 @@ + */ + function queue() + { +- global $phpEx, $phpbb_root_path; ++ global $phpEx, $phpbb_root_path, $url_forum; + + $this->data = array(); +- $this->cache_file = "{$phpbb_root_path}cache/queue.$phpEx"; ++ $this->cache_file = "{$phpbb_root_path}cache/$url_forum/queue.$phpEx"; + + // Determine EOL character (\n for UNIX, \r\n for Windows and \r for Mac) + $this->eol = (!defined('PHP_EOL')) ? (($eol = strtolower(substr(PHP_OS, 0, 3))) == 'win') ? "\r\n" : (($eol == 'mac') ? "\r" : "\n") : PHP_EOL; +--- a/includes/functions_posting.php ++++ b/includes/functions_posting.php +@@ -453,6 +453,7 @@ + $no_image = ($cat_id == ATTACHMENT_CATEGORY_IMAGE) ? false : true; + + $file->move_file($config['upload_path'], false, $no_image); ++ chmod($config['upload_path'].'/'.$file->realname, 0640); + + if (sizeof($file->error)) + { +--- a/includes/functions_transfer.php ++++ b/includes/functions_transfer.php +@@ -38,13 +38,13 @@ + */ + function transfer() + { +- global $phpbb_root_path; ++ global $phpbb_root_path, $url_forum; + + $this->file_perms = 0644; + $this->dir_perms = 0777; + + // 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/'. $url_forum. '/'; + } + + /** +--- a/includes/functions_user.php ++++ b/includes/functions_user.php +@@ -2091,6 +2091,7 @@ + + // Move file and overwrite any existing image + $file->move_file($destination, true); ++ chmod("$destination/".$file->realname, 0640); + + if (sizeof($file->error)) + { +--- a/includes/template.php ++++ b/includes/template.php +@@ -51,12 +51,12 @@ + */ + function set_template() + { +- global $phpbb_root_path, $user; ++ global $phpbb_root_path, $user, $url_forum; + + if (file_exists($phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template')) + { + $this->root = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template'; +- $this->cachepath = $phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $user->theme['template_path']) . '_'; ++ $this->cachepath = $phpbb_root_path . 'cache/' . $url_forum . '/tpl_' . str_replace('_', '-', $user->theme['template_path']) . '_'; + + if ($this->orig_tpl_storedb === null) + { +@@ -92,7 +92,7 @@ + */ + function set_custom_template($template_path, $template_name, $fallback_template_path = false) + { +- global $phpbb_root_path, $user; ++ global $phpbb_root_path, $user, $url_forum; + + // Make sure $template_path has no ending slash + if (substr($template_path, -1) == '/') +@@ -101,7 +101,7 @@ + } + + $this->root = $template_path; +- $this->cachepath = $phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $template_name) . '_'; ++ $this->cachepath = $phpbb_root_path . 'cache/' . $url_forum . '/ctpl_' . str_replace('_', '-', $template_name) . '_'; + + if ($fallback_template_path !== false) + { +--- a/includes/acm/acm_memory.php ++++ b/includes/acm/acm_memory.php +@@ -36,9 +36,9 @@ + */ + function acm_memory() + { +- global $phpbb_root_path, $dbname, $table_prefix; ++ global $phpbb_root_path, $dbname, $table_prefix, $url_forum; + +- $this->cache_dir = $phpbb_root_path . 'cache/'; ++ $this->cache_dir = $phpbb_root_path . 'cache/' . $url_forum . '/'; + $this->key_prefix = substr(md5($dbname . $table_prefix), 0, 8) . '_'; + + if (!isset($this->extension) || !extension_loaded($this->extension)) -- cgit v1.2.3