From fe67258e1ae6f875aeba9aaaee3f809ec6748ac0 Mon Sep 17 00:00:00 2001
From: Benoit Mortier <benoit.mortier@opensides.be>
Date: Sun, 2 Oct 2011 20:28:38 +0200
Subject: [PATCH] added a variables.inc file with only the variables that can
 in the future be generated by fusiondirectory-setup

---
 html/autocomplete.php |  1 +
 html/getFAIstatus.php |  2 ++
 html/getbin.php       |  2 ++
 html/index.php        |  1 +
 html/logout.php       |  2 ++
 html/main.php         |  1 +
 html/password.php     |  2 ++
 html/setup.php        |  1 +
 include/functions.inc | 36 ++++------------------------
 include/php_setup.inc | 11 +++++++--
 include/variables.inc | 56 +++++++++++++++++++++++++++++++++++++++++++
 11 files changed, 82 insertions(+), 33 deletions(-)
 create mode 100644 include/variables.inc

diff --git a/html/autocomplete.php b/html/autocomplete.php
index 63c2d2a72..09a407cda 100644
--- a/html/autocomplete.php
+++ b/html/autocomplete.php
@@ -23,6 +23,7 @@
 /* Basic setup, remove eventually registered sessions */
 @require_once ("../include/php_setup.inc");
 @require_once ("functions.inc");
+@require_once ("variables.inc");
 
 session_cache_limiter("private");
 session::start();
diff --git a/html/getFAIstatus.php b/html/getFAIstatus.php
index 825b73aa4..afba83204 100644
--- a/html/getFAIstatus.php
+++ b/html/getFAIstatus.php
@@ -23,6 +23,8 @@
 /* Basic setup, remove eventually registered sessions */
 @require_once ("../include/php_setup.inc");
 @require_once ("functions.inc");
+@require_once ("variables.inc");
+
 
 session_cache_limiter("private");
 session::start();
diff --git a/html/getbin.php b/html/getbin.php
index d6613d349..e78bdabb0 100644
--- a/html/getbin.php
+++ b/html/getbin.php
@@ -23,6 +23,8 @@
 /* Basic setup, remove eventually registered sessions */
 @require_once ("../include/php_setup.inc");
 @require_once ("functions.inc");
+@require_once ("variables.inc");
+
 error_reporting (0);
 session_cache_limiter("private");
 session::start();
diff --git a/html/index.php b/html/index.php
index 8f6a0f014..ebe035918 100644
--- a/html/index.php
+++ b/html/index.php
@@ -23,6 +23,7 @@
 /* Load required includes */
 require_once ("../include/php_setup.inc");
 require_once ("functions.inc");
+require_once ("variables.inc");
 require_once ("class_log.inc");
 header("Content-type: text/html; charset=UTF-8");
 
diff --git a/html/logout.php b/html/logout.php
index 630267c0f..631ef7cb2 100644
--- a/html/logout.php
+++ b/html/logout.php
@@ -23,6 +23,8 @@
 /* Basic setup, remove eventually registered sessions */
 require_once ("../include/php_setup.inc");
 require_once ("functions.inc");
+require_once ("variables.inc");
+
 header("Content-type: text/html; charset=UTF-8");
 
 /* try to start session, so we can remove userlocks, 
diff --git a/html/main.php b/html/main.php
index b880ea40e..81bde05f6 100644
--- a/html/main.php
+++ b/html/main.php
@@ -26,6 +26,7 @@ $start = microtime();
 /* Basic setup, remove eventually registered sessions */
 require_once ("../include/php_setup.inc");
 require_once ("functions.inc");
+require_once ("variables.inc");
 
 /* Set header */
 header("Content-type: text/html; charset=UTF-8");
diff --git a/html/password.php b/html/password.php
index 8e6f39ec7..85a6d40ec 100644
--- a/html/password.php
+++ b/html/password.php
@@ -31,6 +31,8 @@ function displayPWchanger()
 /* Load required includes */
 require_once ("../include/php_setup.inc");
 require_once ("functions.inc");
+require_once ("variables.inc");
+
 
 if(!class_exists("log")){
   require_once("class_log.inc");
diff --git a/html/setup.php b/html/setup.php
index 5917aa181..8f3be2d0c 100644
--- a/html/setup.php
+++ b/html/setup.php
@@ -23,6 +23,7 @@
 /* Get standard functions */
 require_once ("../include/php_setup.inc");
 require_once ("functions.inc");
+require_once ("variables.inc");
 
 require_once("../setup/class_setup.inc");
 require_once("../setup/class_setupStep.inc");
diff --git a/include/functions.inc b/include/functions.inc
index 5a6ba7ed2..bcceda39f 100644
--- a/include/functions.inc
+++ b/include/functions.inc
@@ -40,33 +40,12 @@ if(!isset($_SERVER['CONFIG_FILE'])){
 }
 
 /* Define common locations and variables */
+require_once ("variables.inc");
 
-/* Smarty compile dir */
-define ("SPOOL_DIR","/var/spool/fusiondirectory");
-
-/* Global cache dir */
-define ("CACHE_DIR","/var/cache/fusiondirectory");
-
-/* Global locale cache dir */
-define ("LOCALE_DIR", "/var/cache/fusiondirectory/locale");
-
-/* Global tmp dir */
-define ("TEMP_DIR","/var/cache/fusiondirectory/tmp");
-
-/* Directory containing the configuration template */
-define ("CONFIG_TEMPLATE_DIR", "/var/cache/fusiondirectory/template/");
-
-/* Directory containing the fai logs */
-define ("FAI_LOG_DIR", "/var/cache/fusiondirectory/fai/");
-
-/* fpdf library path */ 
-define("FPDF","/usr/share/php/fpdf/fpdf.php");
-
-/* Global FPDF FONT define */
-define("FPDF_FONTPATH", "/usr/share/php/fpdf/font/");
-
-/* name of the class.cache file */
-define("CLASS_CACHE", "class.cache");
+/* Include required files */
+require_once (CACHE_DIR."/".CLASS_CACHE);
+require_once ("functions_debug.inc");
+require_once ("accept-to-gettext.inc");
 
 /* Define get_list flags */
 define("GL_NONE",         0);
@@ -93,11 +72,6 @@ define('DES_CBC_MD5',3);
 define('DES3_CBC_MD5',5);
 define('DES3_CBC_SHA1',16);
 
-/* Include required files */
-require_once (CACHE_DIR."/".CLASS_CACHE);
-require_once ("functions_debug.inc");
-require_once ("accept-to-gettext.inc");
-
 /* Define constants for debugging */
 define ("DEBUG_TRACE",   1); /*! Debug level for tracing of common actions (save, check, etc.) */
 define ("DEBUG_LDAP",    2); /*! Debug level for LDAP queries */
diff --git a/include/php_setup.inc b/include/php_setup.inc
index c56511622..12dccf42b 100644
--- a/include/php_setup.inc
+++ b/include/php_setup.inc
@@ -20,7 +20,7 @@
   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 */
 
-define("SMARTY_PATH", "smarty/Smarty.class.php");
+require_once ("variables.inc");
 
 function gosaRaiseError($errno, $errstr, $errfile, $errline)
 {
@@ -288,7 +288,14 @@ ini_set("report_memleaks",1);
 ini_set("include_path",".:$BASE_DIR/include:$BASE_DIR/include/utils/excel:/usr/share/php");
 
 /* Do smarty setup */
-require(SMARTY_PATH);
+
+if (file_exists(SMARTY)) {
+ require(SMARTY);
+} else {
+ require(SMARTY3);
+}
+
+/*require(SMARTY_PATH);*/
 $smarty = new Smarty;
 $smarty->template_dir = $BASE_DIR.'/ihtml/';
 $smarty->caching= false;
diff --git a/include/variables.inc b/include/variables.inc
new file mode 100644
index 000000000..2a10e61ed
--- /dev/null
+++ b/include/variables.inc
@@ -0,0 +1,56 @@
+<?php
+
+/*
+  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
+  Copyright (C) 2003-2010  Cajus Pollmeier
+  Copyright (C) 2011  FusionDirectory
+
+  This program 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 License, or
+  (at your option) any later version.
+
+  This program 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 this program; if not, write to the Free Software
+  Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+/* Define common locations and variables */
+
+/* Smarty compile dir */
+define ("SPOOL_DIR","/var/spool/fusiondirectory");
+
+/* Global cache dir */
+define ("CACHE_DIR","/var/cache/fusiondirectory");
+
+/* Global locale cache dir */
+define ("LOCALE_DIR", "/var/cache/fusiondirectory/locale");
+
+/* Global tmp dir */
+define ("TEMP_DIR","/var/cache/fusiondirectory/tmp");
+
+/* Directory containing the configuration template */
+define ("CONFIG_TEMPLATE_DIR", "/var/cache/fusiondirectory/template/");
+
+/* Directory containing the fai logs */
+define ("FAI_LOG_DIR", "/var/cache/fusiondirectory/fai/");
+
+/* fpdf library path */ 
+define("FPDF","/usr/share/php/fpdf/fpdf.php");
+
+/* Global FPDF FONT define */
+define("FPDF_FONTPATH", "/usr/share/php/fpdf/font/");
+
+/* path for smarty libraries */
+define("SMARTY", "/usr/share/php/smarty/libs/Smarty.class.php");
+define("SMARTY3", "/usr/share/php/smarty3/Smarty.class.php");
+
+/* name of the class.cache file */
+define("CLASS_CACHE", "class.cache");
+
+?>
\ No newline at end of file
-- 
GitLab