Remove hardcoded pathes.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 1 Jun 2008 12:07:26 +0000 (14:07 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 1 Jun 2008 12:07:26 +0000 (14:07 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
class.xorg.auth.php
widget.auth.php
widget.post.perms.php

index e27e3d2..9fa422c 100644 (file)
@@ -1,5 +1,9 @@
 <?php
 
+if (!defined('DC_BLOG_ID')) {
+  define('DC_BLOG_ID', $_SERVER['DC_BLOG_ID']);
+}
+
 class xorgAuth extends dcAuth {
   public $xorg_infos = array('forlife' => null,
                              'prenom' => null,
@@ -103,9 +107,6 @@ class xorgAuth extends dcAuth {
   /** Xorg SSO API */
 
   public function callXorg($path = null) {
-    if (is_null($path)) {
-      $path = $_SERVER['REQUEST_URI'];
-    }
     $this->buildFromSession();
     if (@$_SESSION['auth-xorg']) {
       return true;
@@ -114,6 +115,9 @@ class xorgAuth extends dcAuth {
     if (!session_id()) {
       $core->session->start();
     }
+    if (is_null($path)) {
+      $path = @$_SERVER['PATH_INFO'];
+    }
     $_SESSION["auth-x-challenge"] = md5(uniqid(rand(), 1));
     $_SESSION['xorg-group'] = $core->blog->settings->get('xorg_blog_owner');
     $url = "https://www.polytechnique.org/auth-groupex/utf8";
@@ -155,7 +159,7 @@ class xorgAuth extends dcAuth {
       $_SESSION['sess_blog_id'] = 'default';
       $this->sudo(array($this, 'createUser'));
       $path = $_GET['path'];
-      header("Location: http://murphy.m4x.org" . $_GET['path']);
+      header('Location: ' . $core->blog->url . $_GET['path']);
       exit;
     }
     unset($_SESSION['auth-xorg']);
@@ -241,9 +245,18 @@ class xorgAuth extends dcAuth {
 
   public function authForm() {
     global $core;
-    $path = "http://murphy.m4x.org/~x2003bruneau/dotclear/";
+    if (!isset($core->blog)) {
+      $blog = @$core->getBlog(DC_BLOG_ID);
+    } else {
+      $blog = $core->blog;
+    }
+    $path = @$blog->url;
+    if (!$path) {
+      $path = $blog->f('blog_url');
+    }
+
     return '<fieldset>'.
-      '<p><a href="' . $path . 'auth/Xorg?path=/~x2003bruneau/dotclear/admin/index.php">Via Polytechnique.org</a></p>' .
+      '<p><a href="' . $path . 'auth/Xorg?path=/admin/index.php">Via Polytechnique.org</a></p>' .
       '</fieldset>'.
       '<p>'.__('You must accept cookies in order to use the private area.').'</p>';
   }
index 7a41403..ba14500 100644 (file)
@@ -14,7 +14,7 @@ class xorgAuthWidget {
       }
       return $str . '<a href="' . $core->blog->url . 'auth/exit">DĂ©connexion</a></p>';
     } else {
-      return '<p><a href="' . $core->blog->url . 'auth/Xorg?path=' . $_SERVER['REQUEST_URI'] . '">M\'authentifier via Polytechnique.org</a></p>';
+      return '<p><a href="' . $core->blog->url . 'auth/Xorg?path=' . $_SERVER['PATH_INFO'] . '">M\'authentifier via Polytechnique.org</a></p>';
     }
   }
 }
index 249c135..415d371 100644 (file)
@@ -118,7 +118,7 @@ class xorgPostPermsFilter extends rsExtPostPublic {
     $str = '<p class="error">'
          . 'Vous n\'avez pas les droits suffisants pour lire ce billet<br />';
     if (!$core->auth->userID()) {
-      $str .= 'Vous devez vous <a href="' . $core->blog->url . 'auth/Xorg?path=' . $_SERVER['REQUEST_URI'] .'">authentifier</a>';
+      $str .= 'Vous devez vous <a href="' . $core->blog->url . 'auth/Xorg?path=' . $_SERVER['PATH_INFO'] .'">authentifier</a>';
     } else {
       $str .= 'Tu dois ĂȘtre membre du groupe pour lire ce message';
     }