X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=_public.php;h=adc2d8b27312120484bf48a6dd2ca67c0d5398ef;hb=HEAD;hp=bef72247c4def68ba6cb863d59c80c18b7be82dd;hpb=1edd3efcc935b94876ab891d21d4ababfa5c0254;p=dotclear.git diff --git a/_public.php b/_public.php index bef7224..adc2d8b 100644 --- a/_public.php +++ b/_public.php @@ -1,82 +1,22 @@ url->register('xorgAuth', 'Xorg', '^auth/(.*)$', array('xorgAuthentifier', 'doAuth')); -class xorgAuthWidget { - static public function widget(&$w) { - global $core; - if ($core->auth->xorg_infos['forlife']) { - return '

Tu es ' . $core->auth->xorg_infos['prenom'] . ' ' . $core->auth->xorg_infos['nom'] . '
' - . 'déconnexion

'; - } else { - return '

M\'authentifier via Polytechnique.org

'; - } - } -} +require_once dirname(__FILE__) . '/page.auth.php'; +require_once dirname(__FILE__) . '/widget.auth.php'; +require_once dirname(__FILE__) . '/widget.copyright.php'; +require_once dirname(__FILE__) . '/widget.post.perms.php'; +require_once dirname(__FILE__) . '/class.xorg.auth.php'; +require_once dirname(__FILE__) . '/page.webservice.php'; -class xorgAuthentifier extends dcUrlHandlers { - static public function doAuth($args) { - @session_start(); - switch ($args) { - case 'exit': - self::killSession(); - break; - case 'Xorg': - self::callXorg(); - break; - case 'XorgReturn': - self::returnXorg(); - break; - default: - self::p404(); - } - return; - } +/* Xorg auth */ +$core->url->register('xorgAuth', 'XorgAuth', '^auth/(.*)$', array('xorgAuthentifier', 'doAuth')); - static protected function callXorg() { - if (@$_SESSION['auth-xorg']) { - header("Location: http://murphy.m4x.org/" . $_GET['path']); - return; - } - $_SESSION["auth-x-challenge"] = md5(uniqid(rand(), 1)); - $url = "https://www.polytechnique.org/auth-groupex/utf8"; - $url .= "?session=" . session_id(); - $url .= "&challenge=" . $_SESSION["auth-x-challenge"]; - $url .= "&pass=" . md5($_SESSION["auth-x-challenge"] . XORG_AUTH_KEY); - $url .= "&url=http://murphy.m4x.org/~x2003bruneau/dotclear/auth/XorgReturn" . urlencode("?path=" . $_GET['path']); - session_write_close(); - header("Location: $url"); - exit; - } +/* Declare the authentication widget on public page */ +$core->addBehavior('initWidgets', array('xorgAuthWidget', 'behavior_initWidgets')); +$core->addBehavior('initWidgets', array('xorgCopyrightWidget', 'behavior_initWidgets')); - static protected function returnXorg() { - if (!isset($_GET['auth'])) { - return false; - } - global $core; - $params = ''; - foreach($core->auth->xorg_infos as $key => $val) { - if(!isset($_GET[$key])) { - return false; - } - $_SESSION['auth-xorg-' . $key] = $_GET[$key]; - $core->auth->xorg_infos[$key] = $_GET[$key]; - $params .= $_GET[$key]; - } - if (md5('1' . $_SESSION['auth-x-challenge'] . XORG_AUTH_KEY . $params . '1') == $_GET['auth']) { - unset($_GET['auth']); - $_SESSION['auth-xorg'] = $_GET['forlife']; - header("Location: http://murphy.m4x.org/" . $_GET['path']); - return true; - } - $_SESSION['auth-xorg'] = null; - unset($_GET['auth']); - return false; - } +/* Post permission handling */ +$core->addBehavior('coreBlogGetPosts', array('xorgPostPermsWidget', 'behavior_coreBlogGetPosts')); - static protected function killSession() { - @session_destroy(); - header('Location: http://murphy.m4x.org/~x2003bruneau/dotclear/'); - exit; - } -} +/* Webservice to create new blog */ +$core->url->register('xorgWebservice', 'XorgWebservice', '^xorgservice/(.*)$', array('XorgWebservice', 'handle')); ?>