split init from libraries

This commit is contained in:
Sean Coates
2004-09-24 17:32:19 +00:00
parent bf8c858d98
commit 10b03b3587
12 changed files with 76 additions and 50 deletions

60
include/init.inc.php Normal file
View File

@ -0,0 +1,60 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
+----------------------------------------------------------------------+
| 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$
*/
error_reporting(E_ALL);
define('PATH_ROOT', realpath(dirname(__FILE__) . '/../'));
define('SQLITE_DIR', PATH_ROOT . '/sqlite/');
define('CVS_DIR', PATH_ROOT . '/cvs/');
// project & language config
require_once('lib_proj_lang.inc.php');
// 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']);
}
// this very dirty fix makes /rfc work
$baseURL = str_replace('/rfc', '', $baseURL);
// actually define the constant (trim off any trailing slashes):
define('BASE_URL', rtrim($baseURL, '/'));
require_once('lib_general.inc.php');
?>

View File

@ -21,40 +21,6 @@
$Id$ $Id$
*/ */
error_reporting(E_ALL);
define('PATH_ROOT', realpath(dirname(__FILE__) . '/../'));
define('SQLITE_DIR', PATH_ROOT . '/sqlite/');
define('CVS_DIR', PATH_ROOT . '/cvs/');
// project & language config
require_once('lib_proj_lang.inc.php');
// 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']);
}
// this very dirty fix makes /rfc work
$baseURL = str_replace('/rfc', '', $baseURL);
// actually define the constant (trim off any trailing slashes):
define('BASE_URL', rtrim($baseURL, '/'));
function is_translation($project, $language) function is_translation($project, $language)
{ {
return is_dir(CVS_DIR . $GLOBALS['PROJECTS'][$project] . '/' . $language); return is_dir(CVS_DIR . $GLOBALS['PROJECTS'][$project] . '/' . $language);

View File

@ -32,7 +32,7 @@ $path = realpath(dirname(__FILE__));
require_once 'DB.php'; require_once 'DB.php';
require_once 'DB/storage.php'; require_once 'DB/storage.php';
require_once $path . '/rfc-config.php'; require_once $path . '/rfc-config.php';
require_once $path . '/../../include/lib_general.inc.php'; require_once $path . '/../../include/init.inc.php';
define('PEAR_DATABASE_DSN', 'sqlite:///'.$path.'/../../sqlite/rfc.sqlite'); define('PEAR_DATABASE_DSN', 'sqlite:///'.$path.'/../../sqlite/rfc.sqlite');

View File

@ -3,7 +3,7 @@ include '../include/jpgraph/jpgraph.php';
include '../include/jpgraph/jpgraph_pie.php'; include '../include/jpgraph/jpgraph_pie.php';
include '../include/jpgraph/jpgraph_pie3d.php'; include '../include/jpgraph/jpgraph_pie3d.php';
include '../include/lib_general.inc.php'; include '../include/init.inc.php';
include '../include/lib_revcheck.inc.php'; include '../include/lib_revcheck.inc.php';
$plop = array_shift($argv); $plop = array_shift($argv);

View File

@ -2,7 +2,7 @@
include '../include/jpgraph/jpgraph.php'; include '../include/jpgraph/jpgraph.php';
include '../include/jpgraph/jpgraph_bar.php'; include '../include/jpgraph/jpgraph_bar.php';
include '../include/lib_general.inc.php'; include '../include/init.inc.php';
include '../include/lib_revcheck.inc.php'; include '../include/lib_revcheck.inc.php';

View File

@ -65,7 +65,7 @@ exit(0);
**/ **/
// define some common variables // define some common variables
include '../include/lib_general.inc.php'; include '../include/init.inc.php';
// grab the documentation type // grab the documentation type
$TYPE = array_shift($argv); $TYPE = array_shift($argv);

View File

@ -2,7 +2,7 @@
/* $Id$ */ /* $Id$ */
// TODO: list of all project mailing lists somewhere (not here!) // TODO: list of all project mailing lists somewhere (not here!)
include_once '../include/lib_general.inc.php'; include_once '../include/init.inc.php';
echo site_header('Contact'); echo site_header('Contact');
?> ?>
<p> <p>

View File

@ -1,7 +1,7 @@
<?php <?php
/* $Id$ */ /* $Id$ */
include_once '../include/lib_general.inc.php'; include_once '../include/init.inc.php';
echo site_header('Copyright'); echo site_header('Copyright');
?> ?>
<h2>Source Code Copyright</h2> <h2>Source Code Copyright</h2>

View File

@ -1,7 +1,7 @@
<?php <?php
/* $Id$ */ /* $Id$ */
include '../include/lib_general.inc.php'; include '../include/init.inc.php';
echo site_header('Website credits'); echo site_header('Website credits');
?> ?>
<p> <p>

View File

@ -1,7 +1,7 @@
<?php <?php
/* $Id$ */ /* $Id$ */
include '../include/lib_general.inc.php'; include '../include/init.inc.php';
$red_status = isset($_SERVER["REDIRECT_STATUS"]) ? $_SERVER["REDIRECT_STATUS"] : ''; $red_status = isset($_SERVER["REDIRECT_STATUS"]) ? $_SERVER["REDIRECT_STATUS"] : '';
$title = 'Apache :: Error ' . $red_status; $title = 'Apache :: Error ' . $red_status;

View File

@ -1,7 +1,7 @@
<?php <?php
/* $Id$ */ /* $Id$ */
include_once '../include/lib_general.inc.php'; include_once '../include/init.inc.php';
echo site_header('Welcome!'); echo site_header('Welcome!');
?> ?>
<h2>What is this site?</h2> <h2>What is this site?</h2>

View File

@ -1,7 +1,7 @@
<?php <?php
/* $Id$ */ /* $Id$ */
include '../include/lib_general.inc.php'; include '../include/init.inc.php';
include '../include/lib_revcheck.inc.php'; include '../include/lib_revcheck.inc.php';
$LANG = LANGC; $LANG = LANGC;