session = $sess; $base = empty($_SERVER['HTTPS']) ? 'http://' : 'https://'; $this->baseurl = @trim($base.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/'); $this->spoolroot = dirname(dirname(__FILE__)); $this->read_config(); $this->setlocale(); } private function read_ini_file($filename) { $array = parse_ini_file($filename, true); if (!is_array($array)) { return; } foreach ($array as $cat => $conf) { $c = strtolower($cat); foreach ($conf as $k => $v) { if ($c == 'core' && property_exists($this, $k)) { $this->$k=$v; } else { if (!isset($this->$c)) { $this->$c = new stdClass; } $this->$c->$k = $v; } } } } private function read_config() { $this->read_ini_file($this->spoolroot.'/configs/platal.ini'); $this->read_ini_file($this->spoolroot.'/configs/platal.conf'); } private function setlocale() { setlocale(LC_MESSAGES, $this->locale); setlocale(LC_TIME, $this->locale); setlocale(LC_CTYPE, $this->locale); date_default_timezone_set($this->timezone); mb_internal_encoding("UTF-8"); } public function asso($key=null) { static $aid = null; if (is_null($aid)) { $gp = Get::v('n'); if ($p = strpos($gp, '/')) { $gp = substr($gp, 0, $p); } if ($gp) { $res = XDB::query('SELECT a.*, d.nom AS domnom FROM groupex.asso AS a LEFT JOIN groupex.dom AS d ON d.id = a.dom WHERE diminutif = {?}', $gp); if (!($aid = $res->fetchOneAssoc())) { $aid = array(); } } else { $aid = array(); } } if (empty($key)) { return $aid; } elseif ( isset($aid[$key]) ) { return $aid[$key]; } else { return null; } } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>