switch to plain ini override. thanks to Vincent for the __FILE__ tip !
authorx2000habouzit <x2000habouzit>
Mon, 22 Nov 2004 21:40:47 +0000 (21:40 +0000)
committerx2000habouzit <x2000habouzit>
Mon, 22 Nov 2004 21:40:47 +0000 (21:40 +0000)
configs/.cvsignore [new file with mode: 0644]
include/xorg.globals.inc.php.in
include/xorg.inc.php
install.d/platal.conf [new file with mode: 0644]
install.d/xorg.config.inc.php [deleted file]

diff --git a/configs/.cvsignore b/configs/.cvsignore
new file mode 100644 (file)
index 0000000..55d50bd
--- /dev/null
@@ -0,0 +1 @@
+platal.conf
index d8d9560..432f4d6 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-    $Id: xorg.globals.inc.php.in,v 1.3 2004-11-22 10:42:52 x2000habouzit Exp $
+    $Id: xorg.globals.inc.php.in,v 1.4 2004-11-22 21:40:47 x2000habouzit Exp $
  ***************************************************************************/
 
 require_once("diogenes.core.globals.inc.php");
@@ -59,6 +59,35 @@ class XorgGlobals extends DiogenesCoreGlobals
     /** recherche */
     var $public_max_search_results = 25;
     var $search_results_per_page   = 20;
+
+    function XorgGlobals() {
+        $ini = dirname(dirname(__FILE__)).'/configs/platal.conf';
+        $array = parse_ini_file($ini, true);
+        if (!is_array($array)) {
+            return;
+        }
+
+        foreach ($array as $cat=>$conf) {
+            $c = strtolower($cat);
+            foreach ($conf as $key=>$val) {
+                if ($c == 'global') {
+                    global $$key;
+                    $$key = $val;
+                } elseif ($c == 'core') {
+                    $this->$key=$val;
+                } else {
+                    $this->$c->$key = $val;
+                }
+            }
+        }
+
+        session_start();
+
+        $this->dbconnect();
+        if ($this->debug) {
+            $this->db->trace_on();
+        }
+    }
 }
 
 // }}}
index 18b9322..800a9c9 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-    $Id: xorg.inc.php,v 1.2 2004-11-22 20:05:10 x2000habouzit Exp $
+    $Id: xorg.inc.php,v 1.3 2004-11-22 21:40:47 x2000habouzit Exp $
  ***************************************************************************/
 
 function microtime_float() 
@@ -53,7 +53,6 @@ require_once("xorg/menu.inc.php");
 require_once("xorg/session.inc.php");
 
 $globals = new XorgGlobals;
-require_once("xorg.config.inc.php");
 
 // }}}
 // {{{ Build Menu, TODO: move that into appropriates hooks
@@ -103,18 +102,6 @@ $globals->menu->addPublicEntry(XOM_INFOS, 10, 'Nous contacter',         'docs/co
 $globals->menu->addPublicEntry(XOM_INFOS, 20, 'FAQ',                    'docs/faq.php');
 
 // }}}
-// {{{ start session + database connection
-
-session_start();
-
-// connect to database
-$globals->dbconnect();
-if ($globals->debug) {
-    $globals->db->trace_on();
-}
-
-//}}}
-
 // {{{ function _new_page()
 
 function _new_page($type, $tpl_name, $tpl_head, $min_auth, $admin=false)
diff --git a/install.d/platal.conf b/install.d/platal.conf
new file mode 100644 (file)
index 0000000..5e8f067
--- /dev/null
@@ -0,0 +1,28 @@
+; {{{ [Core]
+
+[Core]
+
+debug      = true
+dbuser     = "***"
+dbpwd      = "***"
+
+; base url of the site, WITHOUT LEADING /
+baseurl    = "http://dev.m4x.org/~x2000habouzit";
+root       = "/home/x2000habouzit/dev/public/";
+spoolroot  = "/home/x2000habouzit/dev/public/";
+
+econfiance = "***";
+
+; }}}
+; {{{ [Global]
+
+[Global]
+
+news_server    = "localhost"
+news_port      = 119
+news_auth_pass = "***"
+news_web_user  = "***"
+news_web_pass  = "***"
+
+; }}}
+; vim:set syntax=dosini:
diff --git a/install.d/xorg.config.inc.php b/install.d/xorg.config.inc.php
deleted file mode 100644 (file)
index 106b490..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2004 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  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            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************
-    $Id: xorg.config.inc.php,v 1.1 2004-11-22 06:49:07 x2000habouzit Exp $
- ***************************************************************************/
-
-// {{{ BDD
-
-/** BDD overrides */
-#$globals->dbhost='djali.polytechnique.org';
-$globals->debug  = true;
-$globals->dbuser = '***';
-$globals->dbpwd  = '***';
-// }}}
-// {{{ Paths
-
-/* URL de la racine pour les mails contenant des URL (pas de slash final!) */
-$globals->baseurl   = "http://dev.m4x.org/~x2000habouzit";
-$globals->root      = "/home/x2000habouzit/dev/public/";
-$globals->spoolroot = "/home/x2000habouzit/dev/public/";
-
-// }}}
-// {{{ Extra
-
-# JPF
-$globals->econfiance = '***';
-
-/* les parametres pour se connecter au serveur NNTP */
-if (!isset($news_server)) $news_server="localhost";
-if (!isset($news_port)) $news_port=119;
-if (!isset($news_auth_pass)) $news_auth_pass="***";
-$news_web_user = '***';
-$news_web_pass = '***';
-
-// }}}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
-?>