<?php
/***************************************************************************
- * Copyright (C) 2003-2006 Polytechnique.org *
+ * Copyright (C) 2003-2007 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
var $baseurl;
var $spoolroot;
+ var $locale;
+ var $timezone;
+
function PlatalGlobals($sess)
{
$this->session = $sess;
$base = empty($_SERVER['HTTPS']) ? 'http://' : 'https://';
$this->baseurl = trim($base.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/');
- $this->spoolroot = dirname(dirname(dirname(__FILE__)));
+ $this->spoolroot = dirname(dirname(__FILE__));
$this->read_config();
$this->setlocale();
}
- function read_config()
+ function read_ini_file($filename)
{
- $array = parse_ini_file($this->spoolroot.'/configs/platal.ini', true);
- foreach ($array as $cat => $conf) {
- $c = strtolower($cat);
- foreach ($conf as $k => $v) {
- $this->$c->$k = $v;
- }
- }
-
- $array = parse_ini_file($this->spoolroot.'/configs/platal.conf', true);
+ $array = parse_ini_file($filename, true);
if (!is_array($array)) {
return;
}
-
- foreach ($array as $cat=>$conf) {
+ foreach ($array as $cat => $conf) {
$c = strtolower($cat);
- foreach ($conf as $key=>$val) {
- if ($c == 'core' && isset($this->$key)) {
- $this->$key=$val;
+ foreach ($conf as $k => $v) {
+ if ($c == 'core' && property_exists($this, $k)) {
+ $this->$k=$v;
} else {
- $this->$c->$key = $val;
+ if (!isset($this->$c)) {
+ $this->$c = new stdClass;
+ }
+ $this->$c->$k = $v;
}
}
}
}
+ function read_config()
+ {
+ $this->read_ini_file($this->spoolroot.'/configs/platal.ini');
+
+ $this->read_ini_file($this->spoolroot.'/configs/platal.conf');
+ }
+
function dbconnect()
{
@mysql_connect($this->dbhost, $this->dbuser, $this->dbpwd);
function setlocale()
{
- global $globals;
- setlocale(LC_MESSAGES, $globals->core->locale);
- setlocale(LC_TIME, $globals->core->locale);
- setlocale(LC_CTYPE, $globals->core->locale);
+ setlocale(LC_MESSAGES, $this->locale);
+ setlocale(LC_TIME, $this->locale);
+ setlocale(LC_CTYPE, $this->locale);
+ date_default_timezone_set($this->timezone);
}
function asso($key=null)
if (is_null($aid)) {
$gp = Get::v('n');
- $gp = substr($gp, 0, strpos($gp, '/'));
+ if ($p = strpos($gp, '/')) {
+ $gp = substr($gp, 0, $p);
+ }
if ($gp) {
$res = XDB::query('SELECT a.*, d.nom AS domnom