<?php
/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
+ * Copyright (C) 2003-2009 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
function handlers()
{
return array(
- 'index' => $this->make_hook('index', AUTH_PUBLIC),
- 'cacert.pem' => $this->make_hook('cacert', AUTH_PUBLIC),
- 'changelog' => $this->make_hook('changelog', AUTH_PUBLIC),
+ 'index' => $this->make_hook('index', AUTH_PUBLIC),
+ 'cacert.pem' => $this->make_hook('cacert', AUTH_PUBLIC),
+ 'changelog' => $this->make_hook('changelog', AUTH_PUBLIC),
// Preferences thingies
- 'prefs' => $this->make_hook('prefs', AUTH_COOKIE),
- 'prefs/rss' => $this->make_hook('prefs_rss', AUTH_COOKIE),
- 'prefs/webredirect'
- => $this->make_hook('webredir', AUTH_MDP),
- 'prefs/skin' => $this->make_hook('skin', AUTH_COOKIE),
+ 'prefs' => $this->make_hook('prefs', AUTH_COOKIE),
+ 'prefs/rss' => $this->make_hook('prefs_rss', AUTH_COOKIE),
+ 'prefs/webredirect' => $this->make_hook('webredir', AUTH_MDP),
+ 'prefs/skin' => $this->make_hook('skin', AUTH_COOKIE),
// password related thingies
- 'password' => $this->make_hook('password', AUTH_MDP),
- 'tmpPWD' => $this->make_hook('tmpPWD', AUTH_PUBLIC),
- 'password/smtp' => $this->make_hook('smtppass', AUTH_MDP),
- 'recovery' => $this->make_hook('recovery', AUTH_PUBLIC),
- 'exit' => $this->make_hook('exit', AUTH_PUBLIC),
- 'review' => $this->make_hook('review', AUTH_PUBLIC),
- 'deconnexion.php' => $this->make_hook('exit', AUTH_PUBLIC),
+ 'password' => $this->make_hook('password', AUTH_MDP),
+ 'tmpPWD' => $this->make_hook('tmpPWD', AUTH_PUBLIC),
+ 'password/smtp' => $this->make_hook('smtppass', AUTH_MDP),
+ 'recovery' => $this->make_hook('recovery', AUTH_PUBLIC),
+ 'exit' => $this->make_hook('exit', AUTH_PUBLIC),
+ 'review' => $this->make_hook('review', AUTH_PUBLIC),
+ 'deconnexion.php' => $this->make_hook('exit', AUTH_PUBLIC),
);
}
function handler_index(&$page)
{
+ // Include X-XRDS-Location response-header for Yadis discovery
+ global $globals;
+ header('X-XRDS-Location: ' . $globals->baseurl . '/openid/xrds');
+
+ // Redirect to the suitable page
if (S::logged()) {
pl_redirect('events');
} else if (!@$GLOBALS['IS_XNET_SITE']) {
$page->changeTpl('platal/changeLog.tpl');
$clog = pl_entities(file_get_contents(dirname(__FILE__).'/../ChangeLog'));
- $clog = preg_replace('/=+\s*/', '</pre><hr /><pre>', $clog);
+ $clog = preg_replace('/===+\s*/', '</pre><hr /><pre>', $clog);
// url catch only (not all wiki syntax)
$clog = preg_replace(array(
'/((?:https?|ftp):\/\/(?:\.*,*[\w@~%$£µ&i#\-+=_\/\?;])*)/ui',
function handler_prefs(&$page)
{
$page->changeTpl('platal/preferences.tpl');
- $page->assign('xorg_title','Polytechnique.org - Mes préférences');
+ $page->setTitle('Mes préférences');
if (Post::has('mail_fmt')) {
$fmt = Post::v('mail_fmt');
if (Post::has('rss')) {
$this->__set_rss_state(Post::b('rss'));
}
+
+ # FIXME: this code is not multi-domain compatible. We should decide how
+ # carva will extend to users not in the main domain.
+ $res = XDB::query("SELECT alias
+ FROM aliases
+ WHERE id = {?} AND FIND_IN_SET('bestalias', flags)",
+ S::user()->id());
+ $page->assign('bestalias', $res->fetchOneCell());
}
function handler_webredir(&$page)
{
$page->changeTpl('platal/webredirect.tpl');
- $page->assign('xorg_title','Polytechnique.org - Redirection de page WEB');
+ $page->setTitle('Redirection de page WEB');
$log =& S::v('log');
$url = Env::v('url');
XDB::execute('UPDATE auth_user_quick
SET redirecturl = {?} WHERE user_id = {?}',
$url, S::v('uid'));
- $log->log('carva_add', 'http://'.Env::v('url'));
+ S::logger()->log('carva_add', 'http://'.Env::v('url'));
$page->trigSuccess("Redirection activée vers <a href='http://$url'>$url</a>");
} elseif (Env::v('submit') == "Supprimer") {
XDB::execute("UPDATE auth_user_quick
SET redirecturl = ''
WHERE user_id = {?}",
S::v('uid'));
- $log->log("carva_del", $url);
+ S::logger()->log("carva_del", $url);
Post::kill('url');
$page->trigSuccess('Redirection supprimée');
}
WHERE user_id = {?}',
S::v('uid'));
$page->assign('carva', $res->fetchOneCell());
+
+ # FIXME: this code is not multi-domain compatible. We should decide how
+ # carva will extend to users not in the main domain.
+ $res = XDB::query("SELECT alias
+ FROM aliases
+ WHERE id = {?} AND FIND_IN_SET('bestalias', flags)",
+ S::user()->id());
+ $page->assign('bestalias', $res->fetchOneCell());
}
function handler_prefs_rss(&$page)
// updates the Google Apps password as well.
if ($globals->mailstorage->googleapps_domain) {
require_once 'googleapps.inc.php';
- $account = new GoogleAppsAccount(S::v('uid'), S::v('forlife'));
+ $account = new GoogleAppsAccount(S::user());
if ($account->active() && $account->sync_password) {
$account->set_password($password);
}
}
- $log =& S::v('log');
- $log->log('passwd', '');
-
- if (Cookie::v('ORGaccess')) {
- setcookie('ORGaccess', hash_encrypt($password), (time()+25920000), '/', '' ,0);
- }
+ S::logger()->log('passwd');
+ Platal::session()->setAccessCookie(true);
$page->changeTpl('platal/motdepasse.success.tpl');
$page->run();
$page->changeTpl('platal/motdepasse.tpl');
$page->addJsLink('motdepasse.js');
- $page->assign('xorg_title','Polytechnique.org - Mon mot de passe');
+ $page->setTitle('Mon mot de passe');
}
function handler_smtppass(&$page)
{
$page->changeTpl('platal/acces_smtp.tpl');
- $page->assign('xorg_title','Polytechnique.org - Acces SMTP/NNTP');
+ $page->setTitle('Acces SMTP/NNTP');
- require_once 'wiki.inc.php';
- wiki_require_page('Xorg.SMTPSécurisé');
- wiki_require_page('Xorg.NNTPSécurisé');
+ $wp = new PlWikiPage('Xorg.SMTPSécurisé');
+ $wp->buildCache();
+ $wp = new PlWikiPage('Xorg.NNTPSécurisé');
+ $wp->buildCache();
$uid = S::v('uid');
$pass = Env::v('smtppass1');
XDB::execute('UPDATE auth_user_md5 SET smtppass = {?}
WHERE user_id = {?}', $pass, $uid);
$page->trigSuccess('Mot de passe enregistré');
- $log->log("passwd_ssl");
+ S::logger()->log("passwd_ssl");
} elseif (Env::v('op') == "Supprimer") {
XDB::execute('UPDATE auth_user_md5 SET smtppass = ""
WHERE user_id = {?}', $uid);
$page->trigSuccess('Compte SMTP et NNTP supprimé');
- $log->log("passwd_del");
+ S::logger()->log("passwd_del");
}
$res = XDB::query("SELECT IF(smtppass != '', 'actif', '')
$mymail->send();
// on cree un objet logger et on log l'evenement
- $logger = $_SESSION['log'] = new CoreLogger($uid);
- $logger->log('recovery', $mails);
+ S::logger($uid)->log('recovery', $mails);
} else {
$page->trigError('Les informations que tu as rentrées ne permettent pas de récupérer ton mot de passe.<br />'.
'Si tu as un homonyme, utilise prenom.nom.promo comme login');
// updates the Google Apps password as well.
if ($globals->mailstorage->googleapps_domain) {
require_once 'googleapps.inc.php';
- $account = new GoogleAppsAccount($uid);
+ $account = new GoogleAppsAccount(User::getSilent($uid));
if ($account->active() && $account->sync_password) {
$account->set_password($password);
}
}
- $logger = new CoreLogger($uid);
- $logger->log("passwd","");
+ S::logger($uid)->log("passwd", "");
$page->changeTpl('platal/tmpPWD.success.tpl');
} else {
$page->changeTpl('platal/motdepasse.tpl');
global $globals;
$page->changeTpl('platal/skins.tpl');
- $page->assign('xorg_title','Polytechnique.org - Skins');
+ $page->setTitle('Skins');
if (Env::has('newskin')) { // formulaire soumis, traitons les données envoyées
XDB::execute('UPDATE auth_user_quick
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)
{
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 = $suid;
- S::kill('suid');
- pl_redirect('admin/user/' . $a4l);
+ S::logger()->log("suid_stop", S::user()->login() . " by " . $suid['hruid']);
+ Platal::session()->stopSUID();
+ pl_redirect('admin/user/' . S::user()->login());
}
if ($level == 'forget' || $level == 'forgetall') {
- setcookie('ORGaccess', '', time() - 3600, '/', '', 0);
- Cookie::kill('ORGaccess');
- if (isset($_SESSION['log']))
- $_SESSION['log']->log("cookie_off");
+ Platal::session()->killAccessCookie();
}
if ($level == 'forgetuid' || $level == 'forgetall') {
- setcookie('ORGuid', '', time() - 3600, '/', '', 0);
- Cookie::kill('ORGuid');
- setcookie('ORGdomain', '', time() - 3600, '/', '', 0);
- Cookie::kill('ORGdomain');
+ Platal::session()->killLoginFormCookies();
}
- if (isset($_SESSION['log'])) {
- $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
- $_SESSION['log']->log('deconnexion',$ref);
+ if (S::logged()) {
+ S::logger()->log('deconnexion', @$_SERVER['HTTP_REFERER']);
+ Platal::session()->destroy();
}
- XorgSession::destroy();
-
if (Get::has('redirect')) {
http_redirect(rawurldecode(Get::v('redirect')));
} else {
function handler_review(&$page, $action = null, $mode = null)
{
- require_once 'wiki.inc.php';
- require_once dirname(__FILE__) . '/platal/review.inc.php';
- $dir = wiki_work_dir();
+ // Include X-XRDS-Location response-header for Yadis discovery
+ global $globals;
+ header('X-XRDS-Location: ' . $globals->baseurl . '/openid/xrds');
+
+ $this->load('review.inc.php');
$dom = 'Review';
if (@$GLOBALS['IS_XNET_SITE']) {
$dom .= 'Xnet';
}
- if (!is_dir($dir)) {
- $page->kill("Impossible de trouver le wiki");
- }
- if (!file_exists($dir . '/' . $dom . '.Admin')) {
- $page->kill("Impossible de trouver la page d'administration");
- }
- $conf = preg_grep('/^text=/', explode("\n", file_get_contents($dir . '/' . $dom . '.Admin')));
- $conf = preg_split('/(text\=|\%0a)/', array_shift($conf), -1, PREG_SPLIT_NO_EMPTY);
- $wiz = new PlWizard('Tour d\'horizon', 'core/plwizard.tpl', true);
+ $wp = new PlWikiPage($dom . '.Admin');
+ $conf = explode('%0a', $wp->getField('text'));
+ $wiz = new PlWizard('Tour d\'horizon', PlPage::getCoreTpl('plwizard.tpl'), true);
foreach ($conf as $line) {
$list = preg_split('/\s*[*|]\s*/', $line, -1, PREG_SPLIT_NO_EMPTY);
$wiz->addPage('ReviewPage', $list[0], $list[1]);