function getWebRoot() { static $web_root = null; if (is_null($web_root)) { // assert('$_SERVER["SCRIPT_NAME"]'); // $web_root = dirname($_SERVER['SCRIPT_NAME']); $web_root = realpath(dirname(__FILE__)); $web_root = str_replace("\\", '/', $web_root); if (strpos($web_root, fbWeb::getDocRoot()) === 0) { $web_root = substr($web_root, strlen(fbWeb::getDocRoot())); } } return $web_root; }
<?php // $CVSHeader: _freebeer/www/lib/tests/_header.php,v 1.3 2004/03/08 04:29:18 ross Exp $ // Copyright (c) 2002-2004, Ross Smith. All rights reserved. // Licensed under the BSD or LGPL License. See license.txt for details. defined('FREEBEER_BASE') || define('FREEBEER_BASE', getenv('FREEBEER_BASE') ? getenv('FREEBEER_BASE') : dirname(dirname(dirname(dirname(__FILE__))))); require_once FREEBEER_BASE . '/lib/HTTP.php'; require_once FREEBEER_BASE . '/www/fbWeb.php'; $www_root = fbWeb::getWebRoot(); $doc_root = fbWeb::getDocRoot(); //$root_dir = $doc_root . $www_root; if (isset($test_name)) { $test_name = $www_root . $test_name; } fbHTTP::sendNoCacheHeaders(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- $CVSHeader: _freebeer/www/lib/tests/_header.php,v 1.3 2004/03/08 04:29:18 ross Exp $ Copyright (c) 2001-2003, Ross Smith. All rights reserved. Licensed under the BSD or LGPL License. See doc/license.txt for details. --> <head> <title><?php echo $test_name; ?> Test Suite</title>
<?php // $CVSHeader: _freebeer/www/_source.php,v 1.2 2004/03/07 17:51:33 ross Exp $ // Copyright (c) 2002-2004, Ross Smith. All rights reserved. // Licensed under the BSD or LGPL License. See license.txt for details. error_reporting(2047); defined('FREEBEER_BASE') || define('FREEBEER_BASE', getenv('FREEBEER_BASE') ? getenv('FREEBEER_BASE') : dirname(dirname(__FILE__))); require_once FREEBEER_BASE . '/lib/HTTP.php'; require_once './_header.php'; // required for Opera 7.x fbHTTP::sendNoCacheHeaders(); $file = isset($_REQUEST['file']) ? $_REQUEST['file'] : false; if (strpos($file, fbWeb::getDocRoot()) !== 0) { exit; } if (!preg_match('/\\.(php|js)$/i', $file)) { exit; } highlight_file($file);