cvs: docweb / INSTALL.txt /include lib_general.inc.php lib_proj_lang.inc.php lib_site_conf.inc.php /www .htaccess credits.php error.php redirect.php
| From: | Sean Coates | Date: | Sat, 11 Sep 2004 23:17:15 +0000 |
| Subject: | cvs: docweb / INSTALL.txt /include lib_general.inc.php lib_proj_lang.inc.php lib_site_conf.inc.php /www .htaccess credits.php error.php redirect.php | ||
| Groups: | php.doc.web | ||
| Request: | Send a blank email to doc-web+get-279@lists.php.net to get a copy of this message | ||
sean Sat Sep 11 19:17:15 2004 EDT
Added files:
/docweb/include lib_proj_lang.inc.php
/docweb/www redirect.php
Removed files:
/docweb/include lib_site_conf.inc.php
Modified files:
/docweb INSTALL.txt
/docweb/include lib_general.inc.php
/docweb/www .htaccess credits.php error.php
Log:
subdomains -> paths
#see http://www.phpdoc.info/docweb-rfc/
#this commit is big (for me) so let me know if it breaks something
http://cvs.php.net/diff.php/docweb/INSTALL.txt?r1=1.3&r2=1.4&ty=u Index: docweb/INSTALL.txt diff -u docweb/INSTALL.txt:1.3 docweb/INSTALL.txt:1.4 --- docweb/INSTALL.txt:1.3 Thu Sep 2 14:20:38 2004 +++ docweb/INSTALL.txt Sat Sep 11 19:17:14 2004 @@ -9,25 +9,21 @@ user who apache runs under. 4. The PEAR packages for the RFC System can be found at include/rfc/PACKAGES 5. Configure the virtual host under apache. Current 'suggested settings' are: +<VirtualHost 127.0.0.1:80> -<VirtualHost 65.75.184.99:80> -ServerName docweb.php.mirrors.powertrip.co.za -ServerAlias *.docs.php.mirrors.powertrip.co.za docs.php.mirrors.powertrip.co.za -ServerAdmin systems-team@yourwebhost.co.za -DocumentRoot /home/pure-ftpd-users/php001/docs.php.mirrors.powertrip.co.za/www + ServerName doc.php.net + ServerAdmin docweb@lists.php.net -... + DocumentRoot /path/to/docweb/www -ErrorDocument 404 /error.php + ErrorDocument 404 /error.php + php_flag register_globals Off + php_flag magic_quotes_gpc Off + php_flag magic_quotes_runtime Off -... + RewriteEngine on + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.*)$ redirect.php -<IfModule mod_php4.c> -php_flag register_globals Off -php_flag magic_quotes_gpc Off -php_flag magic_quotes_runtime Off -php_value include_path "/home/pure-ftpd-users/php001/docs.php.mirrors.powertrip.co.za/include:/usr/local/share/pear" -</IfModule> </VirtualHost> -6. Copy include/lib_site_conf.inc.php to include/lib_site_conf_local.inc.php and - edit it appropriately for your local configuration http://cvs.php.net/diff.php/docweb/include/lib_general.inc.php?r1=1.19&r2=1.20&ty=u Index: docweb/include/lib_general.inc.php diff -u docweb/include/lib_general.inc.php:1.19 docweb/include/lib_general.inc.php:1.20 --- docweb/include/lib_general.inc.php:1.19 Fri Sep 10 14:27:03 2004 +++ docweb/include/lib_general.inc.php Sat Sep 11 19:17:14 2004 @@ -16,85 +16,41 @@ | Authors: Yannick Torres <yannick@php.net> | | Mehdi Achour <didou@php.net> | | Gabor Hojtsy <goba@php.net> | +| Sean Coates <sean@php.net> | +----------------------------------------------------------------------+ -$Id: lib_general.inc.php,v 1.19 2004/09/10 18:27:03 sean Exp $ +$Id: lib_general.inc.php,v 1.20 2004/09/11 23:17:14 sean Exp $ */ error_reporting(E_ALL); -// Copy lib_site_conf.inc.php and add proper settings! -include_once 'lib_site_conf_local.inc.php'; - +define('PATH_ROOT', realpath(dirname(__FILE__) . '/../')); define('SQLITE_DIR', PATH_ROOT . '/sqlite/'); define('CVS_DIR', PATH_ROOT . '/cvs/'); -// Map of supported documentation types to CVS module names -$PROJECTS = array( - 'php' => array('PHP Documentation', 'phpdoc-all'), - 'smarty' => array('Smarty', 'smarty/docs'), - 'pear' => array('PEAR Documentation', 'peardoc'), - 'gtk' => array('PHP-GTK Documentation', 'php-gtk-docs'), - 'livedocs' => array('Livedocs', ''), - 'pecl' => array('PECL Documentation', ''), - 'www' => array('Documentation', ''), -); - -// Supported languages -$LANGUAGES = array( - 'all' => 'All', - 'ar' => 'Arabic', - 'pt_BR' => 'Brazilian Portuguese', - 'zh' => 'Chinese (Simplified)', - 'hk' => 'Chinese (Hong Kong Cantonese)', - 'tw' => 'Chinese (Traditional)', - 'cs' => 'Czech', - 'da' => 'Danish', - 'nl' => 'Dutch', - 'fi' => 'Finnish', - 'fr' => 'French', - 'de' => 'German', - 'el' => 'Greek', - 'he' => 'Hebrew', - 'hu' => 'Hungarian', - 'it' => 'Italian', - 'ja' => 'Japanese', - 'kr' => 'Korean', - 'pl' => 'Polish', - 'pt' => 'Portuguese', - 'ro' => 'Romanian', - 'ru' => 'Russian', - 'sk' => 'Slovak', - 'sl' => 'Slovenian', - 'es' => 'Spanish', - 'sv' => 'Swedish', - 'tr' => 'Turkish', - 'en' => 'English' -); - -// If PHP is running as an Apache module, get -if (substr(php_sapi_name(), 0, 6) == 'apache') { - - // Grab subdomains if provided - $domains = explode( - ".", - preg_replace("!\\.?" . preg_quote(WEB_ROOT) . "$!", '', $_SERVER['HTTP_HOST']) - ); +// project & language config +require_once('lib_proj_lang.inc.php'); - $project = 'www'; $language = 'all'; - foreach($domains as $domain) { - $domain = ($domain == 'pt_br' ? 'pt_BR' : $domain); - if (in_array($domain, array_keys($PROJECTS))) { - $project = $domain; - } - elseif (in_array($domain, array_keys($LANGUAGES))) { - $language = $domain; - } - } - - define('SITE', $project); - define('LANGC', $language); - define('LANGD', $LANGUAGES[$language]); +// get defaults +list($defaultProject) = array_keys($PROJECTS); +list($defaultLanguage) = array_keys($LANGUAGES); + +// set up constants (use defaults if necessary) +define('SITE', isset($project) ? $project : $defaultProject); +define('LANGC', isset($language) ? $language : $defaultLanguage); +define('URI', isset($uri) ? $uri : $_SERVER['REQUEST_URI']); +define('LANGD', $LANGUAGES[LANGC]); + +// set up BASE_URL +if (substr($_SERVER['REQUEST_URI'], -1, 1) == '/') +{ + // is a directory, use verbatim + $baseURL = $_SERVER['REQUEST_URI']; +} else { + // not a dir, use the dirname + $baseURL = dirname($_SERVER['REQUEST_URI']); } +// actually define the constant (trim off any trailing slashes): +define('BASE_URL', rtrim($baseURL, '/')); function is_translation($project, $language) { @@ -214,7 +170,7 @@ function site_footer() { - $master = get_resource_url(); + $master = get_insite_address(NULL, NULL, ''); $buff = <<<END_OF_BUFFER </div> <div id="footer"> @@ -292,35 +248,39 @@ // Returns an insite address for a specified project, language and path (with fallback) function get_insite_address($project = NULL, $lang = NULL, $path = NULL) { - if (!isset($project)) { $project = SITE; } + if (!isset($project)) { $project = SITE; } if (!isset($lang)) { $lang = LANGC; } - if (!isset($path)) { $path = $_SERVER['PHP_SELF']; } - - $project = ($project == 'www') ? '' : "$project."; - $lang = ($lang == 'all') ? '' : "$lang."; + if (!isset($path)) { $path = URI; } - return 'http://' . $project . $lang . WEB_ROOT . $path; + $ret = '/'; + if ($project != $GLOBALS['defaultProject']) { + $ret .= "$project/"; + } + if ($lang != $GLOBALS['defaultLanguage']) { + $ret .= "$lang/"; + } + return $ret . ($path == '/' ? '' : $path); } function get_resource_url($url = '') { - return 'http://' . WEB_ROOT . '/' . $url; + return "/$url"; } // This function provides the relevant insite navigation options for the // particular page the user is viewing currently function site_nav_provider() { - $links = array('<a href="/">Subsite homepage</a>'); - $links[] = '<a href="/rfc/rfc-overview.php">Request For Comments</a>'; + $links = array('<a href="'. BASE_URL .'/">Subsite homepage</a>'); + $links[] = '<a href="'. BASE_URL .'/rfc/rfc-overview.php">Request For Comments</a>'; if (in_array(SITE, array('gtk', 'pear', 'php', 'smarty'))) { - $links[] = '<a href="/revcheck.php">Revision check</a>'; + $links[] = '<a href="'. BASE_URL .'/revcheck.php">Revision check</a>'; } if (SITE == 'php') { - $links[] = '<a href="/dochowto/index.php">Documentation Howto</a>'; + $links[] = '<a href="'. BASE_URL .'/dochowto/index.php">Documentation Howto</a>'; } if (strpos($_SERVER['PHP_SELF'], 'rfc') !== false) { - $links[] = '<a href="/rfc/rfc-proposal-edit.php">Submit RFC</a>'; + $links[] = '<a href="'. BASE_URL .'/rfc/rfc-proposal-edit.php">Submit RFC</a>'; } if (count($links) == 0) { $links[] = 'N/A'; http://cvs.php.net/diff.php/docweb/www/.htaccess?r1=1.1&r2=1.2&ty=u Index: docweb/www/.htaccess diff -u docweb/www/.htaccess:1.1 docweb/www/.htaccess:1.2 --- docweb/www/.htaccess:1.1 Thu Aug 5 08:29:49 2004 +++ docweb/www/.htaccess Sat Sep 11 19:17:15 2004 @@ -1 +1,11 @@ -ErrorDocument 404 /error.php \ No newline at end of file +ErrorDocument 404 /error.php + +php_flag register_globals Off +php_flag magic_quotes_gpc Off +php_flag magic_quotes_runtime Off + +RewriteEngine on +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ redirect.php + http://cvs.php.net/diff.php/docweb/www/credits.php?r1=1.5&r2=1.6&ty=u Index: docweb/www/credits.php diff -u docweb/www/credits.php:1.5 docweb/www/credits.php:1.6 --- docweb/www/credits.php:1.5 Sat Sep 11 08:28:17 2004 +++ docweb/www/credits.php Sat Sep 11 19:17:15 2004 @@ -1,5 +1,5 @@ <?php -/* $Id: credits.php,v 1.5 2004/09/11 12:28:17 goba Exp $ */ +/* $Id: credits.php,v 1.6 2004/09/11 23:17:15 sean Exp $ */ include '../include/lib_general.inc.php'; echo site_header('Website credits'); @@ -15,7 +15,9 @@ <dt>PHP.net services (CVS, mailing list, etc)</dt> <dd>PHP.net system administration team</dd> <dt>Website development</dt> - <dd>Mehdi Achour, Vincent Gevers, Gabor Hojtsy and Yannick Torres</dd> + <dd> + Mehdi Achour, Vincent Gevers, Gabor Hojtsy, + Yannick Torres and Sean Coates</dd> </dl> <p> http://cvs.php.net/diff.php/docweb/www/error.php?r1=1.4&r2=1.5&ty=u Index: docweb/www/error.php diff -u docweb/www/error.php:1.4 docweb/www/error.php:1.5 --- docweb/www/error.php:1.4 Thu Aug 5 12:19:10 2004 +++ docweb/www/error.php Sat Sep 11 19:17:15 2004 @@ -1,15 +1,7 @@ <?php -/* $Id: error.php,v 1.4 2004/08/05 16:19:10 jacques Exp $ */ +/* $Id: error.php,v 1.5 2004/09/11 23:17:15 sean Exp $ */ include '../include/lib_general.inc.php'; - -if( !isset($_SERVER["REDIRECT_STATUS"]) || $_SERVER["REDIRECT_STATUS"] == 200 ) { - -header("Location: /"); -exit; - -} - $title = 'Apache :: Error ' . $_SERVER["REDIRECT_STATUS"]; echo site_header($title); http://cvs.php.net/co.php/docweb/include/lib_proj_lang.inc.php?r=1.1&p=1 Index: docweb/include/lib_proj_lang.inc.php +++ docweb/include/lib_proj_lang.inc.php <?php /* +----------------------------------------------------------------------+ | PHP Documentation Tools Site Source Code | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Yannick Torres <yannick@php.net> | | Mehdi Achour <didou@php.net> | | Gabor Hojtsy <goba@php.net> | | Sean Coates <sean@php.net> | +----------------------------------------------------------------------+ $Id: lib_proj_lang.inc.php,v 1.1 2004/09/11 23:17:14 sean Exp $ */ // split from lib_general.inc.php // Map of supported documentation types to CVS module names $PROJECTS = array( 'www' => array('Documentation', ''), 'php' => array('PHP Documentation', 'phpdoc-all'), 'smarty' => array('Smarty', 'smarty/docs'), 'pear' => array('PEAR Documentation', 'peardoc'), 'gtk' => array('PHP-GTK Documentation', 'php-gtk-docs'), 'livedocs' => array('Livedocs', ''), 'pecl' => array('PECL Documentation', ''), ); // Supported languages $LANGUAGES = array( 'all' => 'All', 'ar' => 'Arabic', 'pt_BR' => 'Brazilian Portuguese', 'zh' => 'Chinese (Simplified)', 'hk' => 'Chinese (Hong Kong Cantonese)', 'tw' => 'Chinese (Traditional)', 'cs' => 'Czech', 'da' => 'Danish', 'nl' => 'Dutch', 'fi' => 'Finnish', 'fr' => 'French', 'de' => 'German', 'el' => 'Greek', 'he' => 'Hebrew', 'hu' => 'Hungarian', 'it' => 'Italian', 'ja' => 'Japanese', 'kr' => 'Korean', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ro' => 'Romanian', 'ru' => 'Russian', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'es' => 'Spanish', 'sv' => 'Swedish', 'tr' => 'Turkish', 'en' => 'English', ); ?> http://cvs.php.net/co.php/docweb/www/redirect.php?r=1.1&p=1 Index: docweb/www/redirect.php +++ docweb/www/redirect.php <?php /* +----------------------------------------------------------------------+ | PHP Documentation Tools Site Source Code | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Sean Coates <sean@php.net> | +----------------------------------------------------------------------+ $Id: redirect.php,v 1.1 2004/09/11 23:17:15 sean Exp $ */ require_once('../include/lib_proj_lang.inc.php'); function part_is_project($part) { return in_array($part, array_keys($GLOBALS['PROJECTS'])); } function part_is_language($part) { return in_array($part, array_keys($GLOBALS['LANGUAGES'])); } function part_get_filename($part) { // strip query string $filename = preg_replace('/\?.*$/', '', $part); // remove webroot-escape attempts $filename = str_replace(array('..', '//'), array('', '/'), $filename); // fake DirectoryIndex if (substr($filename, -1) == '/' || $filename == '') { $filename .= 'index.php'; } $filename = "./$filename"; return $filename; } function part_is_valid_uri($part) { return file_exists(part_get_filename($part)); } $parts = explode('/', $_SERVER['REQUEST_URI'], 4); if ( // /proj/lang/URI count($parts) == 4 && part_is_project($parts[1]) && part_is_language($parts[2]) && part_is_valid_uri($parts[3]) ) { $project = $parts[1]; $language = $parts[2]; $uri = $parts[3]; } elseif ( // /lang/proj/URI count($parts) == 4 && part_is_language($parts[1]) && part_is_project($parts[2]) && part_is_valid_uri($parts[3]) ) { $language = $parts[1]; $project = $parts[2]; $uri = $parts[3]; } elseif ( // /lang (no trailing slash) count($parts) == 2 && (part_is_language($parts[1]) || part_is_project($parts[1])) ) { // redirect (add trailing slash) // NOTE: we lose get/post data, here header("Location: /{$parts[1]}/"); exit(); } elseif ( count($parts) == 3 && ( ( // /lang/proj (no trailing slash) part_is_language($parts[1]) && part_is_project($parts[2]) ) || ( // /proj/lang (no trailing slash) part_is_project($parts[1]) && part_is_language($parts[2]) ) ) ) { // redirect (add trailing slash) // NOTE: we lose get/post data, here header("Location: /{$parts[1]}/{$parts[2]}/"); exit(); } elseif ( // /proj/URI part_is_project($parts[1]) && part_is_valid_uri(implode('/', array_slice($parts, 2))) ) { $project = $parts[1]; $uri = implode('/', array_slice($parts, 2)); } elseif ( // /lang/URI part_is_language($parts[1]) && part_is_valid_uri(implode('/', array_slice($parts, 2))) ) { $language = $parts[1]; $uri = implode('/', array_slice($parts, 2)); } // we have a valid URI, answer the request if (isset($uri)) { header($_SERVER['SERVER_PROTOCOL']." 200 Found (magic redirect)"); require(part_get_filename($uri)); } else { // no resource found: header($_SERVER['SERVER_PROTOCOL']." 404 Not Found"); $_SERVER["REDIRECT_STATUS"] = '404'; require('error.php'); } ?>
http://cvs.php.net/diff.php/docweb/INSTALL.txt?r1=1.3&r2=1.4&ty=u Index: docweb/INSTALL.txt diff -u docweb/INSTALL.txt:1.3 docweb/INSTALL.txt:1.4 --- docweb/INSTALL.txt:1.3 Thu Sep 2 14:20:38 2004 +++ docweb/INSTALL.txt Sat Sep 11 19:17:14 2004 @@ -9,25 +9,21 @@ user who apache runs under. 4. The PEAR packages for the RFC System can be found at include/rfc/PACKAGES 5. Configure the virtual host under apache. Current 'suggested settings' are: +<VirtualHost 127.0.0.1:80> -<VirtualHost 65.75.184.99:80> -ServerName docweb.php.mirrors.powertrip.co.za -ServerAlias *.docs.php.mirrors.powertrip.co.za docs.php.mirrors.powertrip.co.za -ServerAdmin systems-team@yourwebhost.co.za -DocumentRoot /home/pure-ftpd-users/php001/docs.php.mirrors.powertrip.co.za/www + ServerName doc.php.net + ServerAdmin docweb@lists.php.net -... + DocumentRoot /path/to/docweb/www -ErrorDocument 404 /error.php + ErrorDocument 404 /error.php + php_flag register_globals Off + php_flag magic_quotes_gpc Off + php_flag magic_quotes_runtime Off -... + RewriteEngine on + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.*)$ redirect.php -<IfModule mod_php4.c> -php_flag register_globals Off -php_flag magic_quotes_gpc Off -php_flag magic_quotes_runtime Off -php_value include_path "/home/pure-ftpd-users/php001/docs.php.mirrors.powertrip.co.za/include:/usr/local/share/pear" -</IfModule> </VirtualHost> -6. Copy include/lib_site_conf.inc.php to include/lib_site_conf_local.inc.php and - edit it appropriately for your local configuration http://cvs.php.net/diff.php/docweb/include/lib_general.inc.php?r1=1.19&r2=1.20&ty=u Index: docweb/include/lib_general.inc.php diff -u docweb/include/lib_general.inc.php:1.19 docweb/include/lib_general.inc.php:1.20 --- docweb/include/lib_general.inc.php:1.19 Fri Sep 10 14:27:03 2004 +++ docweb/include/lib_general.inc.php Sat Sep 11 19:17:14 2004 @@ -16,85 +16,41 @@ | Authors: Yannick Torres <yannick@php.net> | | Mehdi Achour <didou@php.net> | | Gabor Hojtsy <goba@php.net> | +| Sean Coates <sean@php.net> | +----------------------------------------------------------------------+ -$Id: lib_general.inc.php,v 1.19 2004/09/10 18:27:03 sean Exp $ +$Id: lib_general.inc.php,v 1.20 2004/09/11 23:17:14 sean Exp $ */ error_reporting(E_ALL); -// Copy lib_site_conf.inc.php and add proper settings! -include_once 'lib_site_conf_local.inc.php'; - +define('PATH_ROOT', realpath(dirname(__FILE__) . '/../')); define('SQLITE_DIR', PATH_ROOT . '/sqlite/'); define('CVS_DIR', PATH_ROOT . '/cvs/'); -// Map of supported documentation types to CVS module names -$PROJECTS = array( - 'php' => array('PHP Documentation', 'phpdoc-all'), - 'smarty' => array('Smarty', 'smarty/docs'), - 'pear' => array('PEAR Documentation', 'peardoc'), - 'gtk' => array('PHP-GTK Documentation', 'php-gtk-docs'), - 'livedocs' => array('Livedocs', ''), - 'pecl' => array('PECL Documentation', ''), - 'www' => array('Documentation', ''), -); - -// Supported languages -$LANGUAGES = array( - 'all' => 'All', - 'ar' => 'Arabic', - 'pt_BR' => 'Brazilian Portuguese', - 'zh' => 'Chinese (Simplified)', - 'hk' => 'Chinese (Hong Kong Cantonese)', - 'tw' => 'Chinese (Traditional)', - 'cs' => 'Czech', - 'da' => 'Danish', - 'nl' => 'Dutch', - 'fi' => 'Finnish', - 'fr' => 'French', - 'de' => 'German', - 'el' => 'Greek', - 'he' => 'Hebrew', - 'hu' => 'Hungarian', - 'it' => 'Italian', - 'ja' => 'Japanese', - 'kr' => 'Korean', - 'pl' => 'Polish', - 'pt' => 'Portuguese', - 'ro' => 'Romanian', - 'ru' => 'Russian', - 'sk' => 'Slovak', - 'sl' => 'Slovenian', - 'es' => 'Spanish', - 'sv' => 'Swedish', - 'tr' => 'Turkish', - 'en' => 'English' -); - -// If PHP is running as an Apache module, get -if (substr(php_sapi_name(), 0, 6) == 'apache') { - - // Grab subdomains if provided - $domains = explode( - ".", - preg_replace("!\\.?" . preg_quote(WEB_ROOT) . "$!", '', $_SERVER['HTTP_HOST']) - ); +// project & language config +require_once('lib_proj_lang.inc.php'); - $project = 'www'; $language = 'all'; - foreach($domains as $domain) { - $domain = ($domain == 'pt_br' ? 'pt_BR' : $domain); - if (in_array($domain, array_keys($PROJECTS))) { - $project = $domain; - } - elseif (in_array($domain, array_keys($LANGUAGES))) { - $language = $domain; - } - } - - define('SITE', $project); - define('LANGC', $language); - define('LANGD', $LANGUAGES[$language]); +// get defaults +list($defaultProject) = array_keys($PROJECTS); +list($defaultLanguage) = array_keys($LANGUAGES); + +// set up constants (use defaults if necessary) +define('SITE', isset($project) ? $project : $defaultProject); +define('LANGC', isset($language) ? $language : $defaultLanguage); +define('URI', isset($uri) ? $uri : $_SERVER['REQUEST_URI']); +define('LANGD', $LANGUAGES[LANGC]); + +// set up BASE_URL +if (substr($_SERVER['REQUEST_URI'], -1, 1) == '/') +{ + // is a directory, use verbatim + $baseURL = $_SERVER['REQUEST_URI']; +} else { + // not a dir, use the dirname + $baseURL = dirname($_SERVER['REQUEST_URI']); } +// actually define the constant (trim off any trailing slashes): +define('BASE_URL', rtrim($baseURL, '/')); function is_translation($project, $language) { @@ -214,7 +170,7 @@ function site_footer() { - $master = get_resource_url(); + $master = get_insite_address(NULL, NULL, ''); $buff = <<<END_OF_BUFFER </div> <div id="footer"> @@ -292,35 +248,39 @@ // Returns an insite address for a specified project, language and path (with fallback) function get_insite_address($project = NULL, $lang = NULL, $path = NULL) { - if (!isset($project)) { $project = SITE; } + if (!isset($project)) { $project = SITE; } if (!isset($lang)) { $lang = LANGC; } - if (!isset($path)) { $path = $_SERVER['PHP_SELF']; } - - $project = ($project == 'www') ? '' : "$project."; - $lang = ($lang == 'all') ? '' : "$lang."; + if (!isset($path)) { $path = URI; } - return 'http://' . $project . $lang . WEB_ROOT . $path; + $ret = '/'; + if ($project != $GLOBALS['defaultProject']) { + $ret .= "$project/"; + } + if ($lang != $GLOBALS['defaultLanguage']) { + $ret .= "$lang/"; + } + return $ret . ($path == '/' ? '' : $path); } function get_resource_url($url = '') { - return 'http://' . WEB_ROOT . '/' . $url; + return "/$url"; } // This function provides the relevant insite navigation options for the // particular page the user is viewing currently function site_nav_provider() { - $links = array('<a href="/">Subsite homepage</a>'); - $links[] = '<a href="/rfc/rfc-overview.php">Request For Comments</a>'; + $links = array('<a href="'. BASE_URL .'/">Subsite homepage</a>'); + $links[] = '<a href="'. BASE_URL .'/rfc/rfc-overview.php">Request For Comments</a>'; if (in_array(SITE, array('gtk', 'pear', 'php', 'smarty'))) { - $links[] = '<a href="/revcheck.php">Revision check</a>'; + $links[] = '<a href="'. BASE_URL .'/revcheck.php">Revision check</a>'; } if (SITE == 'php') { - $links[] = '<a href="/dochowto/index.php">Documentation Howto</a>'; + $links[] = '<a href="'. BASE_URL .'/dochowto/index.php">Documentation Howto</a>'; } if (strpos($_SERVER['PHP_SELF'], 'rfc') !== false) { - $links[] = '<a href="/rfc/rfc-proposal-edit.php">Submit RFC</a>'; + $links[] = '<a href="'. BASE_URL .'/rfc/rfc-proposal-edit.php">Submit RFC</a>'; } if (count($links) == 0) { $links[] = 'N/A'; http://cvs.php.net/diff.php/docweb/www/.htaccess?r1=1.1&r2=1.2&ty=u Index: docweb/www/.htaccess diff -u docweb/www/.htaccess:1.1 docweb/www/.htaccess:1.2 --- docweb/www/.htaccess:1.1 Thu Aug 5 08:29:49 2004 +++ docweb/www/.htaccess Sat Sep 11 19:17:15 2004 @@ -1 +1,11 @@ -ErrorDocument 404 /error.php \ No newline at end of file +ErrorDocument 404 /error.php + +php_flag register_globals Off +php_flag magic_quotes_gpc Off +php_flag magic_quotes_runtime Off + +RewriteEngine on +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ redirect.php + http://cvs.php.net/diff.php/docweb/www/credits.php?r1=1.5&r2=1.6&ty=u Index: docweb/www/credits.php diff -u docweb/www/credits.php:1.5 docweb/www/credits.php:1.6 --- docweb/www/credits.php:1.5 Sat Sep 11 08:28:17 2004 +++ docweb/www/credits.php Sat Sep 11 19:17:15 2004 @@ -1,5 +1,5 @@ <?php -/* $Id: credits.php,v 1.5 2004/09/11 12:28:17 goba Exp $ */ +/* $Id: credits.php,v 1.6 2004/09/11 23:17:15 sean Exp $ */ include '../include/lib_general.inc.php'; echo site_header('Website credits'); @@ -15,7 +15,9 @@ <dt>PHP.net services (CVS, mailing list, etc)</dt> <dd>PHP.net system administration team</dd> <dt>Website development</dt> - <dd>Mehdi Achour, Vincent Gevers, Gabor Hojtsy and Yannick Torres</dd> + <dd> + Mehdi Achour, Vincent Gevers, Gabor Hojtsy, + Yannick Torres and Sean Coates</dd> </dl> <p> http://cvs.php.net/diff.php/docweb/www/error.php?r1=1.4&r2=1.5&ty=u Index: docweb/www/error.php diff -u docweb/www/error.php:1.4 docweb/www/error.php:1.5 --- docweb/www/error.php:1.4 Thu Aug 5 12:19:10 2004 +++ docweb/www/error.php Sat Sep 11 19:17:15 2004 @@ -1,15 +1,7 @@ <?php -/* $Id: error.php,v 1.4 2004/08/05 16:19:10 jacques Exp $ */ +/* $Id: error.php,v 1.5 2004/09/11 23:17:15 sean Exp $ */ include '../include/lib_general.inc.php'; - -if( !isset($_SERVER["REDIRECT_STATUS"]) || $_SERVER["REDIRECT_STATUS"] == 200 ) { - -header("Location: /"); -exit; - -} - $title = 'Apache :: Error ' . $_SERVER["REDIRECT_STATUS"]; echo site_header($title); http://cvs.php.net/co.php/docweb/include/lib_proj_lang.inc.php?r=1.1&p=1 Index: docweb/include/lib_proj_lang.inc.php +++ docweb/include/lib_proj_lang.inc.php <?php /* +----------------------------------------------------------------------+ | PHP Documentation Tools Site Source Code | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Yannick Torres <yannick@php.net> | | Mehdi Achour <didou@php.net> | | Gabor Hojtsy <goba@php.net> | | Sean Coates <sean@php.net> | +----------------------------------------------------------------------+ $Id: lib_proj_lang.inc.php,v 1.1 2004/09/11 23:17:14 sean Exp $ */ // split from lib_general.inc.php // Map of supported documentation types to CVS module names $PROJECTS = array( 'www' => array('Documentation', ''), 'php' => array('PHP Documentation', 'phpdoc-all'), 'smarty' => array('Smarty', 'smarty/docs'), 'pear' => array('PEAR Documentation', 'peardoc'), 'gtk' => array('PHP-GTK Documentation', 'php-gtk-docs'), 'livedocs' => array('Livedocs', ''), 'pecl' => array('PECL Documentation', ''), ); // Supported languages $LANGUAGES = array( 'all' => 'All', 'ar' => 'Arabic', 'pt_BR' => 'Brazilian Portuguese', 'zh' => 'Chinese (Simplified)', 'hk' => 'Chinese (Hong Kong Cantonese)', 'tw' => 'Chinese (Traditional)', 'cs' => 'Czech', 'da' => 'Danish', 'nl' => 'Dutch', 'fi' => 'Finnish', 'fr' => 'French', 'de' => 'German', 'el' => 'Greek', 'he' => 'Hebrew', 'hu' => 'Hungarian', 'it' => 'Italian', 'ja' => 'Japanese', 'kr' => 'Korean', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ro' => 'Romanian', 'ru' => 'Russian', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'es' => 'Spanish', 'sv' => 'Swedish', 'tr' => 'Turkish', 'en' => 'English', ); ?> http://cvs.php.net/co.php/docweb/www/redirect.php?r=1.1&p=1 Index: docweb/www/redirect.php +++ docweb/www/redirect.php <?php /* +----------------------------------------------------------------------+ | PHP Documentation Tools Site Source Code | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Sean Coates <sean@php.net> | +----------------------------------------------------------------------+ $Id: redirect.php,v 1.1 2004/09/11 23:17:15 sean Exp $ */ require_once('../include/lib_proj_lang.inc.php'); function part_is_project($part) { return in_array($part, array_keys($GLOBALS['PROJECTS'])); } function part_is_language($part) { return in_array($part, array_keys($GLOBALS['LANGUAGES'])); } function part_get_filename($part) { // strip query string $filename = preg_replace('/\?.*$/', '', $part); // remove webroot-escape attempts $filename = str_replace(array('..', '//'), array('', '/'), $filename); // fake DirectoryIndex if (substr($filename, -1) == '/' || $filename == '') { $filename .= 'index.php'; } $filename = "./$filename"; return $filename; } function part_is_valid_uri($part) { return file_exists(part_get_filename($part)); } $parts = explode('/', $_SERVER['REQUEST_URI'], 4); if ( // /proj/lang/URI count($parts) == 4 && part_is_project($parts[1]) && part_is_language($parts[2]) && part_is_valid_uri($parts[3]) ) { $project = $parts[1]; $language = $parts[2]; $uri = $parts[3]; } elseif ( // /lang/proj/URI count($parts) == 4 && part_is_language($parts[1]) && part_is_project($parts[2]) && part_is_valid_uri($parts[3]) ) { $language = $parts[1]; $project = $parts[2]; $uri = $parts[3]; } elseif ( // /lang (no trailing slash) count($parts) == 2 && (part_is_language($parts[1]) || part_is_project($parts[1])) ) { // redirect (add trailing slash) // NOTE: we lose get/post data, here header("Location: /{$parts[1]}/"); exit(); } elseif ( count($parts) == 3 && ( ( // /lang/proj (no trailing slash) part_is_language($parts[1]) && part_is_project($parts[2]) ) || ( // /proj/lang (no trailing slash) part_is_project($parts[1]) && part_is_language($parts[2]) ) ) ) { // redirect (add trailing slash) // NOTE: we lose get/post data, here header("Location: /{$parts[1]}/{$parts[2]}/"); exit(); } elseif ( // /proj/URI part_is_project($parts[1]) && part_is_valid_uri(implode('/', array_slice($parts, 2))) ) { $project = $parts[1]; $uri = implode('/', array_slice($parts, 2)); } elseif ( // /lang/URI part_is_language($parts[1]) && part_is_valid_uri(implode('/', array_slice($parts, 2))) ) { $language = $parts[1]; $uri = implode('/', array_slice($parts, 2)); } // we have a valid URI, answer the request if (isset($uri)) { header($_SERVER['SERVER_PROTOCOL']." 200 Found (magic redirect)"); require(part_get_filename($uri)); } else { // no resource found: header($_SERVER['SERVER_PROTOCOL']." 404 Not Found"); $_SERVER["REDIRECT_STATUS"] = '404'; require('error.php'); } ?>