From 47fa97fed308292ab5e7bed6f870b39f55747aa8 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 22 Jun 2008 10:08:36 +0200 Subject: [PATCH] Fixes Signed-off-by: Florent Bruneau --- classes/platal.php | 12 ++++++++++++ classes/plglobals.php | 23 +++++++++++++++++++++++ classes/plsession.php | 8 ++++++++ classes/s.php | 8 +++----- include/globals.inc.php.in | 12 +++--------- include/platal.inc.php | 8 ++------ include/xorg.misc.inc.php | 4 ++-- modules/platal.php | 7 +++---- 8 files changed, 56 insertions(+), 26 deletions(-) diff --git a/classes/platal.php b/classes/platal.php index aed33a8..1d5c466 100644 --- a/classes/platal.php +++ b/classes/platal.php @@ -337,6 +337,18 @@ class Platal } return self::$_page; } + + static public function &session() + { + global $session; + return $session; + } + + static public function &globals() + { + global $globals; + return $globals; + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: diff --git a/classes/plglobals.php b/classes/plglobals.php index d78d1e3..f614458 100644 --- a/classes/plglobals.php +++ b/classes/plglobals.php @@ -18,6 +18,14 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ +/** Debug levels: + * DEBUG_BT = show the backtraces (SQL/XMLRPC/...) + * DEBUG_VALID = run html validation + * DEBUG_SMARTY = don't hide smarty errors/warnings/notices + */ +define('DEBUG_BT', 1); +define('DEBUG_VALID', 2); +define('DEBUG_SMARTY', 4); /** PlGlobals provides functions to read a set of configuration files and gives * access to this configurations. @@ -41,6 +49,21 @@ class PlGlobals { public $coreVersion = '0.9.17'; + /** Debug level. + * This is a combination of the DEBUG_ flags. As soon as at least + * one flag is set, the debug mode is activated, this means: + * - debug panel on the top of the pages + * - don't hide php notices + * - recompile templates when they have been changed + */ + public $debug = 0; + + /** Access mode. + */ + public $mode = 'rw'; // 'rw' => read/write, + // 'r' => read/only + // '' => site down + /** BaseURL of the site. * This is read from the HTTP headers if available but you MUST give a * default value for this field in you configuration file (because, this diff --git a/classes/plsession.php b/classes/plsession.php index add2bd3..73426fd 100644 --- a/classes/plsession.php +++ b/classes/plsession.php @@ -19,6 +19,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ +/** Authentication level. + * Only AUTH_PUBLIC is mandatory. The others are defined as useful values, + * but can be overwritten by others auth levels definitions. + */ +define('AUTH_PUBLIC', 0); +define('AUTH_COOKIE', 1); +define('AUTH_MDP', 2); + /** The PlSession is a wrapper around the user session management. */ diff --git a/classes/s.php b/classes/s.php index 700fdf6..626dfef 100644 --- a/classes/s.php +++ b/classes/s.php @@ -72,7 +72,7 @@ class S } } - public static function logger($uid) + public static function logger($uid = null) { if (!S::has('log')) { if (S::has('suid')) { @@ -87,8 +87,7 @@ class S public static function has_perms() { - global $session; - return $session->checkPerms(PERMS_ADMIN); + return Platal::session()->checkPerms(PERMS_ADMIN); } public static function logged() @@ -98,8 +97,7 @@ class S public static function identified() { - global $session; - return S::v('auth', AUTH_PUBLIC) >= $session->sureLevel(); + return S::v('auth', AUTH_PUBLIC) >= Platal::session()->sureLevel(); } // Anti-XSRF protections. diff --git a/include/globals.inc.php.in b/include/globals.inc.php.in index 23b6374..1e15c81 100644 --- a/include/globals.inc.php.in +++ b/include/globals.inc.php.in @@ -21,14 +21,8 @@ class PlatalGlobals extends PlGlobals { - public $session; - /** The x.org version */ public $version = '@VERSION@'; - public $debug = 0; - public $mode = 'rw'; // 'rw' => read/write, - // 'r' => read/only - // '' => site down /** db params */ public $dbdb = 'x4dat'; @@ -41,11 +35,11 @@ class PlatalGlobals extends PlGlobals public $skin; public $register_skin; - public function __construct($sess) + public function __construct() { parent::__construct(array('platal.ini', 'platal.conf')); - $globals->bootstrap(array('NbIns'), 'update_NbIns');i - $globals->bootstrap(array('NbValid'), 'update_NbValid'); + $this->bootstrap(array('NbIns'), 'update_NbIns'); + $this->bootstrap(array('NbValid'), 'update_NbValid'); } public function asso($key=null) diff --git a/include/platal.inc.php b/include/platal.inc.php index bb33ca8..e30429d 100644 --- a/include/platal.inc.php +++ b/include/platal.inc.php @@ -21,10 +21,6 @@ $TIME_BEGIN = microtime(true); -define('AUTH_PUBLIC', 0); -define('AUTH_COOKIE', 1); -define('AUTH_MDP', 2); - define('PERMS_EXT', 'ext'); define('PERMS_USER', 'user'); define('PERMS_ADMIN', 'admin'); @@ -123,8 +119,8 @@ function pl_print_errors() } set_error_handler('pl_error_handler', E_ALL | E_STRICT); -//register_shutdown_function('pl_print_errors'); -register_shutdown_function('pl_dump_env'); +register_shutdown_function('pl_print_errors'); +//register_shutdown_function('pl_dump_env'); /** Check if the string is utf8 */ diff --git a/include/xorg.misc.inc.php b/include/xorg.misc.inc.php index eefbfb2..dd3c70f 100644 --- a/include/xorg.misc.inc.php +++ b/include/xorg.misc.inc.php @@ -354,7 +354,7 @@ function update_NbIns() FROM auth_user_md5 WHERE perms IN ('admin','user') AND deces=0"); $cnt = $res->fetchOneCell(); - $globals->change_dynamic_config(array('NbIns' => $cnt)); + $globals->changeDynamicConfig(array('NbIns' => $cnt)); } function update_NbValid() @@ -362,7 +362,7 @@ function update_NbValid() global $globals; $res = XDB::query("SELECT COUNT(*) FROM requests"); - $globals->change_dynamic_config(array('NbValid' => $res->fetchOneCell())); + $globals->changeDynamicConfig(array('NbValid' => $res->fetchOneCell())); } function update_NbNotifs() diff --git a/modules/platal.php b/modules/platal.php index 2dd4e08..1e01daa 100644 --- a/modules/platal.php +++ b/modules/platal.php @@ -394,7 +394,7 @@ Adresse de secours : " . Post::v('email') : "")); SET skin={?} WHERE user_id={?}', Env::i('newskin'), S::v('uid')); S::kill('skin'); - set_skin(); + Platal::session()->setSkin(); } $res = XDB::query('SELECT id FROM skins WHERE skin_tpl={?}', S::v('skin')); @@ -410,13 +410,12 @@ Adresse de secours : " . Post::v('email') : "")); function handler_exit(&$page, $level = null) { - global $session; if (S::has('suid')) { $a4l = S::v('forlife'); $suid = S::v('suid'); $log = S::v('log'); $log->log("suid_stop", S::v('forlife') . " by " . $suid['forlife']); - $session->stopSUID(); + Platal::session()->stopSUID(); pl_redirect('admin/user/' . $a4l); } @@ -438,7 +437,7 @@ Adresse de secours : " . Post::v('email') : "")); $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $_SESSION['log']->log('deconnexion',$ref); } - $session->destroy(); + Platal::session()->destroy(); if (Get::has('redirect')) { http_redirect(rawurldecode(Get::v('redirect'))); -- 2.1.4