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