}
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:
* 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.
{
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
* 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.
*/
}
}
- public static function logger($uid)
+ public static function logger($uid = null)
{
if (!S::has('log')) {
if (S::has('suid')) {
public static function has_perms()
{
- global $session;
- return $session->checkPerms(PERMS_ADMIN);
+ return Platal::session()->checkPerms(PERMS_ADMIN);
}
public static function logged()
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.
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';
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)
$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');
}
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
*/
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()
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()
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'));
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);
}
$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')));