[Fusionforge-commits] r9637 - trunk/gforge/www/include
Roland Mas
lolando at libremir.placard.fr.eu.org
Wed Apr 28 21:53:26 CEST 2010
Author: lolando
Date: 2010-04-28 21:53:26 +0200 (Wed, 28 Apr 2010)
New Revision: 9637
Modified:
trunk/gforge/www/include/pre.php
trunk/gforge/www/include/squal_pre.php
Log:
Merge pre.php and squal_pre.php, no need to maintain two almost identical files
Modified: trunk/gforge/www/include/pre.php
===================================================================
--- trunk/gforge/www/include/pre.php 2010-04-28 09:50:57 UTC (rev 9636)
+++ trunk/gforge/www/include/pre.php 2010-04-28 19:53:26 UTC (rev 9637)
@@ -2,13 +2,25 @@
/**
* pre.php - Automatically prepend to every page.
*
- * SourceForge: Breaking Down the Barriers to Open Source Development
- * Copyright 1999-2001 (c) VA Linux Systems
- * http://sourceforge.net
+ * Copyright 1999-2001, VA Linux Systems
+ * Copyright 2010, Roland Mas <lolando at debian.org>
*
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-// escaping lib
require_once $gfcommon.'include/escapingUtils.php';
if (isset($_SERVER) && array_key_exists('PHP_SELF', $_SERVER) && $_SERVER['PHP_SELF']) {
@@ -19,7 +31,7 @@
$GLOBALS['PHP_SELF'] = htmlspecialchars($GLOBALS['PHP_SELF']);
}
-// Just say no to link prefetching (Moz prefetching, Google Web Accelerator, others)
+// Block link prefetching (Moz prefetching, Google Web Accelerator, others)
// http://www.google.com/webmasters/faq.html#prefetchblock
if (getStringFromServer('HTTP_X_moz') === 'prefetch'){
header(getStringFromServer('SERVER_PROTOCOL') . ' 404 Prefetch Forbidden');
@@ -37,73 +49,41 @@
forge_read_config_file ($gfconfig.'/config.ini') ;
-// get constants used for flags or status
+// Get constants used for flags or status
require $gfcommon.'include/constants.php';
-
-//
-if (forge_get_config('use_jabber')) {
- require_once $gfcommon.'include/Jabber.class.php';
-}
-
-//library to determine browser settings
-require_once $gfwww.'include/browser.php';
-
-//base error library for new objects
+// Base error library for new objects
require_once $gfcommon.'include/Error.class.php';
-// HTML layout class, may be overriden by the Theme class
-require_once $gfwww.'include/Layout.class.php';
-
-
-//various html utilities
-require_once $gfcommon.'include/utils.php';
-
-//database abstraction
+// Database abstraction
require_once $gfcommon.'include/database-pgsql.php';
+db_connect();
+if (!$GLOBALS['gfconn']) {
+ print forge_get_config ('forge_name')." Could Not Connect to Database: ".db_error();
+ exit;
+}
-//security library
+// Security library
require_once $gfcommon.'include/session.php';
-//system library
+// System library
require_once $gfcommon.'include/System.class.php';
if (!forge_get_config('account_manager_type')) {
$sys_account_manager_type='UNIX';
}
require_once $gfcommon.'include/system/'.forge_get_config('account_manager_type').'.class.php';
$amt = forge_get_config('account_manager_type') ;
-$SYS=new $amt();
+$SYS = new $amt();
-//user functions like get_name, logged_in, etc
+// User-related classes and functions
require_once $gfcommon.'include/User.class.php';
-//group functions like get_name, etc
+// Project-related classes and functions
require_once $gfcommon.'include/Group.class.php';
-//permission functions
+// Permission-related functions
require_once $gfcommon.'include/Permission.class.php';
-//library to set up context help
-require_once $gfwww.'include/help.php';
-
-//exit_error library
-require_once $gfwww.'include/exit.php';
-
-//various html libs like button bar, themable
-require_once $gfwww.'include/html.php';
-
-//forms key generation
-require_once $gfcommon.'include/forms.php';
-
-// #### Connect to db
-
-db_connect();
-
-if (!$GLOBALS['gfconn']) {
- print forge_get_config ('forge_name')." Could Not Connect to Database: ".db_error();
- exit;
-}
-
// Plugins subsystem
require_once $gfcommon.'include/Plugin.class.php' ;
require_once $gfcommon.'include/PluginManager.class.php' ;
@@ -113,77 +93,78 @@
setup_plugin_manager () ;
+// Jabber subsystem
+if (forge_get_config('use_jabber')) {
+ require_once $gfcommon.'include/Jabber.class.php';
+}
-//determine if they're logged in
-session_set();
+if (isset($_SERVER['SERVER_SOFTWARE'])) { // We're on the web
+ // exit_error() and variants (for the web)
+ require_once $gfwww.'include/exit.php';
-plugin_hook('after_session_set');
+ // Library to determine browser settings
+ require_once $gfwww.'include/browser.php';
-//mandatory login
-if (!session_loggedin() && forge_get_config ('force_login') == 1 ) {
- $expl_pathinfo = explode('/',getStringFromServer('REQUEST_URI'));
- if (getStringFromServer('REQUEST_URI')!='/' && $expl_pathinfo[1]!='account' && $expl_pathinfo[1]!='export' ) exit_not_logged_in();
- // Show proj* export even if not logged in when force login
- // If not default web project page would be broken
- if ($expl_pathinfo[1]=='export' && !ereg("^proj", $expl_pathinfo[2])) exit_not_logged_in();
-}
+ // HTML layout class, may be overriden by the Theme class
+ require_once $gfwww.'include/Layout.class.php';
-//insert this page view into the database
-require_once $gfwww.'include/logger.php';
+ // Various HTML utilities
+ require_once $gfcommon.'include/utils.php';
-//
-// If logged in, set up a $LUSER var referencing
-// the logged in user's object
-//
-if (session_loggedin()) {
- //set up the user's timezone if they are logged in
- $LUSER =& session_get_user();
- $LUSER->setUpTheme();
- header('Cache-Control: private');
-}
+ // Library to set up context help
+ require_once $gfwww.'include/help.php';
-//
-// Include user Theme
-//
-require_once forge_get_config('themes_root').forge_get_config('default_theme').'/Theme.class.php';
+ // Various HTML libs like button bar, themable
+ require_once $gfwww.'include/html.php';
-$HTML=new Theme();
+ // Forms key generation
+ require_once $gfcommon.'include/forms.php';
-/*
+ // Determine if there's a web session running
+ session_set();
+
+ plugin_hook('after_session_set');
+
+ // Mandatory login
+ if (!session_loggedin() && forge_get_config ('force_login') == 1 ) {
+ $expl_pathinfo = explode('/',getStringFromServer('REQUEST_URI'));
+ if (getStringFromServer('REQUEST_URI')!='/' && $expl_pathinfo[1]!='account' && $expl_pathinfo[1]!='export' ) exit_not_logged_in();
+ // Show proj* export even if not logged in when force login
+ // If not default web project page would be broken
+ if ($expl_pathinfo[1]=='export' && !ereg("^proj", $expl_pathinfo[2])) exit_not_logged_in();
+ }
- Timezone must come after logger to prevent messups
+ // Insert this page view into the database
+ require_once $gfwww.'include/logger.php';
+ // If logged in, set up a $LUSER var referencing
+ // the logged in user's object
+ if (session_loggedin()) {
+ $LUSER =& session_get_user();
+ $LUSER->setUpTheme();
+ require_once forge_get_config('themes_root').forge_get_config('default_theme').'/Theme.class.php';
+ putenv ('TZ='. $LUSER->getTimeZone());
+ header ('Cache-Control: private');
+ }
-*/
-
-if (session_loggedin()) {
- //set up the user's timezone if they are logged in
- putenv('TZ='. $LUSER->getTimeZone());
-} else {
- //just use pacific time as always
+ $HTML = new Theme () ;
+} else { // Script run from cron or a command line
+ require_once $gfwww.'include/squal_exit.php';
}
-/*
-
- Now figure out what language file to instantiate
-
-*/
-
+// Determine locale
require_once $gfcommon.'include/gettext.php';
require_once $gfcommon.'include/group_section_texts.php';
setup_gettext_from_context();
/*
-
-
RESERVED VARIABLES
$gfconn
$session_hash
$LUSER - Logged in user object
$HTML
-
*/
Modified: trunk/gforge/www/include/squal_pre.php
===================================================================
--- trunk/gforge/www/include/squal_pre.php 2010-04-28 09:50:57 UTC (rev 9636)
+++ trunk/gforge/www/include/squal_pre.php 2010-04-28 19:53:26 UTC (rev 9637)
@@ -2,74 +2,9 @@
/**
* squal_pre.php
*
- * Drastically simplified version of pre.php
- *
- * Sets up database connection and session
- *
- * NOTE:
- * You cannot call HTML-related functions
- *
- * SourceForge: Breaking Down the Barriers to Open Source Development
- * Copyright 1999-2001 (c) VA Linux Systems
- * http://sourceforge.net
- *
+ * No longer required, all functionality provided by pre.php
*/
-if (!isset($no_gz_buffer) || !$no_gz_buffer) {
- ob_start("ob_gzhandler");
-}
+require_once ('pre.php') ;
-require $gfcgfile;
-require $gfcommon.'include/config.php';
-require $gfcommon.'include/config-vars.php';
-
-forge_read_config_file ($gfconfig.'/config.ini') ;
-
-require $gfcommon.'include/constants.php';
-require_once $gfcommon.'include/database-pgsql.php';
-require_once $gfcommon.'include/session.php';
-require_once $gfcommon.'include/Error.class.php';
-require_once $gfcommon.'include/User.class.php';
-require_once $gfcommon.'include/UserManager.class.php';
-require_once $gfcommon.'include/Permission.class.php';
-require_once $gfcommon.'include/utils.php';
-require_once $gfcommon.'include/Group.class.php';
-require_once $gfcommon.'include/ProjectManager.class.php';
-require_once $gfcommon.'include/escapingUtils.php';
-require_once $gfcommon.'include/gettext.php';
-
-// Plugins subsystem
-require_once $gfcommon.'include/Plugin.class.php' ;
-require_once $gfcommon.'include/PluginManager.class.php' ;
-
-//plain text version of exit_error();
-require_once $gfwww.'include/squal_exit.php';
-
-//needed for logging / logo
-//require_once('browser.php');
-
-//system library
-require_once $gfcommon.'include/System.class.php';
-if (!forge_get_config('account_manager_type')) {
- $sys_account_manager_type='UNIX';
-}
-require_once $gfcommon.'include/system/'.forge_get_config('account_manager_type').'.class.php';
-$amt = forge_get_config('account_manager_type') ;
-$SYS=new $amt();
-
-
-// #### Connect to db
-
-db_connect();
-
-if (!$gfconn) {
- exit_error("Could Not Connect to Database",db_error());
-}
-
-//require_once('logger.php');
-
-// #### set session
-
-session_set();
-
?>
More information about the Fusionforge-commits
mailing list