* Nicolas Schodet <schodet-report...@ni.fr.eu.org> [2010-10-18 13:13]: > A fix should change the code which extract $url_forum not to assume > that phpbb is installed in a subdirectory of server root.
Here is a proposition: $host = $_SERVER["HTTP_HOST"]; $script = $_SERVER["SCRIPT_NAME"]; $dir = preg_replace('#/(?:|adm/|install-\w+/|download/)\w+\.php#', '', $script); $url_forum = preg_replace('/[^a-zA-Z0-9._-]/', '', @str_replace(array('http://', '/', ':'), array('' , '.', '.'), $host.$dir)); I am not sure the 'http://' substitution is really needed as HTTP Host: is supposed to contain only the hostname. There is still a problem if the same forum is accessed from different URL even without multisite, therefore I think this should be mentionned in README.Debian. Another solution is to make setting $url_forum mandatory so there is no bad surprise. Here is a test script which demonstrates problems with the old code: <?php $examples = array ( array ('example.com', '/'), array ('example.com', '/my-forum/'), array ('example.com', '/my/deep/forum/'), ); $scripts = array ('index.php', 'adm/index.php', 'install-424242/index.php', 'download/index.php'); foreach ($examples as $e) { foreach ($scripts as $s) { $host = $e[0]; $script = $e[1].$s; // In real life: // $host = $_SERVER["HTTP_HOST"]; // $script = $_SERVER["SCRIPT_NAME"]; echo "url: http://$host$script\n"; // Old code. $dir = explode('/', trim(dirname($script), '/'), 2); $url_forum = preg_replace("/[^a-zA-Z0-9.]/i", '', @str_replace(array('http://', '/', ':'), array('' , '.', '.'), $host.'/'.$dir[0])); echo " old code: $url_forum\n"; // Proposed code. $dir = preg_replace('#/(?:|adm/|install-\w+/|download/)\w+\.php#', '', $script); $url_forum = preg_replace('/[^a-zA-Z0-9._-]/', '', @str_replace(array('http://', '/', ':'), array('' , '.', '.'), $host.$dir)); echo " new code: $url_forum\n"; } echo "\n"; } Nicolas. -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org