Commit | Line | Data |
---|---|---|
1edd3efc FB |
1 | <?php |
2 | $core->url->register('xorgAuth', 'Xorg', '^auth/(.*)$', array('xorgAuthentifier', 'doAuth')); | |
a1a69528 | 3 | $core->url->register('xorgLogin', 'XorgLogin', '^admin/(xorg\.php)$', array('xorgLoginPage', 'page')); |
1edd3efc FB |
4 | |
5 | class xorgAuthWidget { | |
6 | static public function widget(&$w) { | |
7 | global $core; | |
8 | if ($core->auth->xorg_infos['forlife']) { | |
9 | return '<p>Tu es ' . $core->auth->xorg_infos['prenom'] . ' ' . $core->auth->xorg_infos['nom'] . '<br />' | |
10 | . '<a href="auth/exit">déconnexion</a></p>'; | |
11 | } else { | |
12 | return '<p><a href="auth/Xorg?path=' . $_SERVER['REQUEST_URI'] . '">M\'authentifier via Polytechnique.org</a></p>'; | |
13 | } | |
14 | } | |
15 | } | |
16 | ||
a1a69528 FB |
17 | class xorgLoginPage extends dcUrlHandlers { |
18 | static public function page($args) { | |
19 | switch ($args) { | |
20 | case 'xorg.php': | |
21 | self::dispatchForm(); | |
22 | default: | |
23 | self::p404(); | |
24 | } | |
25 | } | |
26 | ||
27 | static protected function dispatchForm() { | |
28 | # If we have a session cookie, go to index.php | |
29 | if (isset($_SESSION['sess_user_id'])) | |
30 | { | |
31 | header('Location: http://murphy.m4x.org/~x2003bruneau/dotclear/admin/index.php'); | |
32 | } | |
33 | ||
34 | # Loading locales for detected language | |
35 | $dlang = http::getAcceptLanguage(); | |
36 | if ($dlang) { | |
37 | l10n::set(dirname(__FILE__).'/../locales/'.$dlang.'/main'); | |
38 | } | |
39 | ||
40 | global $core; | |
41 | $msg = $err = null; | |
42 | header('Content-Type: text/html; charset=UTF-8'); | |
43 | ?> | |
44 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
45 | <html xmlns="http://www.w3.org/1999/xhtml" | |
46 | xml:lang="en" lang="en"> | |
47 | <head> | |
48 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
49 | <meta http-equiv="Content-Script-Type" content="text/javascript" /> | |
50 | <meta http-equiv="Content-Style-Type" content="text/css" /> | |
51 | <meta http-equiv="Content-Language" content="en" /> | |
52 | <meta name="MSSmartTagsPreventParsing" content="TRUE" /> | |
53 | <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" /> | |
54 | <meta name="GOOGLEBOT" content="NOSNIPPET" /> | |
55 | <title><?php echo html::escapeHTML(DC_VENDOR_NAME); ?></title> | |
56 | ||
57 | <?php | |
58 | echo dcPage::jsLoadIE7(); | |
59 | echo dcPage::jsCommon(); | |
60 | ?> | |
61 | ||
62 | <style type="text/css"> | |
63 | @import url(style/default.css); | |
64 | </style> | |
65 | <?php | |
66 | # --BEHAVIOR-- loginPageHTMLHead | |
67 | $core->callBehavior('loginPageHTMLHead'); | |
68 | ?> | |
69 | </head> | |
70 | ||
71 | <body id="dotclear-admin" class="auth"> | |
72 | ||
73 | <form action="xorg.php" method="post" id="login-screen"> | |
74 | <h1><?php echo html::escapeHTML(DC_VENDOR_NAME); ?></h1> | |
75 | ||
76 | <?php | |
77 | if ($err) { | |
78 | echo '<div class="error">'.$err.'</div>'; | |
79 | } | |
80 | if ($msg) { | |
81 | echo '<p class="message">'.$msg.'</p>'; | |
82 | } | |
83 | ||
84 | { | |
85 | echo | |
86 | '<fieldset>'. | |
87 | '<p><a href="http://murphy.m4x.org/~x2003bruneau/dotclear/auth/Xorg?path=/~x2003bruneau/dotclear/admin/index.php">Via Polytechnique.org</a></p>' . | |
88 | '<p><a href="http://murphy.m4x.org/~x2003bruneau/dotclear/admin/auth.php">Via le formulaire</a></p>' . | |
89 | '</fieldset>'. | |
90 | ||
91 | '<p>'.__('You must accept cookies in order to use the private area.').'</p>'; | |
92 | ||
93 | if ($core->auth->allowPassChange()) { | |
94 | echo '<p><a href="auth.php?recover=1">'.__('I forgot my password').'</a></p>'; | |
95 | } | |
96 | } | |
97 | ?> | |
98 | </form> | |
99 | ||
100 | <script type="text/javascript"> | |
101 | //<![CDATA[ | |
102 | $('input[@name="user_id"]').get(0).focus(); | |
103 | //]]> | |
104 | </script> | |
105 | ||
106 | </body> | |
107 | </html> | |
108 | <?php | |
109 | exit; | |
110 | } | |
111 | } | |
112 | ||
1edd3efc FB |
113 | class xorgAuthentifier extends dcUrlHandlers { |
114 | static public function doAuth($args) { | |
be74d9bd | 115 | global $core; |
1edd3efc FB |
116 | switch ($args) { |
117 | case 'exit': | |
be74d9bd | 118 | $core->auth->killSession(); |
1edd3efc FB |
119 | break; |
120 | case 'Xorg': | |
e105d162 FB |
121 | if ($core->auth->callXorg($_GET['path'])) { |
122 | header('Location: http://murphy.m4x.org' . $_GET['path']); | |
123 | exit; | |
124 | } | |
1edd3efc FB |
125 | break; |
126 | case 'XorgReturn': | |
be74d9bd | 127 | $core->auth->returnXorg(); |
1edd3efc FB |
128 | break; |
129 | default: | |
130 | self::p404(); | |
131 | } | |
132 | return; | |
133 | } | |
134 | ||
1edd3efc FB |
135 | } |
136 | ?> |