Fix auth issues with Ajax
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 30 Oct 2006 12:37:25 +0000 (12:37 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 30 Oct 2006 12:37:25 +0000 (12:37 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1040 839d8a87-29fc-0310-9880-83ba4fa771e5

classes/platal.php
classes/plmodule.php
htdocs/javascript/ajax.js
include/platal.inc.php
modules/core.php
modules/lists.php

index 5e6374a..e8648ad 100644 (file)
@@ -99,10 +99,14 @@ class Platal
         $args[0] = &$page;
 
         if ($hook['auth'] > S::v('auth', AUTH_PUBLIC)) {
-            global $globals;
-
-            if (!call_user_func(array($globals->session, 'doAuth'))) {
-                $this->force_login($page);
+            if ($hook['type'] == DO_AUTH) {
+                global $globals;
+    
+                if (!call_user_func(array($globals->session, 'doAuth'))) {
+                    $this->force_login($page);
+                }
+            } else {
+                return PL_FORBIDDEN;
             }
         }
 
index ed4b07f..09c7baa 100644 (file)
@@ -23,7 +23,7 @@ class PLModule
 {
     function handlers()     { die("implement me"); }
 
-    function make_hook($fun, $auth, $perms = '', $type = SKINNED)
+    function make_hook($fun, $auth, $perms = '', $type = DO_AUTH)
     {
         return array('hook'  => array($this, 'handler_'.$fun),
                      'auth'  => $auth,
index ec485a7..8db2aef 100644 (file)
@@ -51,7 +51,9 @@ Ajax = {
             function()
             {
                 if(Ajax.xml_client.readyState == 4) {
-                    document.getElementById(obj).innerHTML = Ajax.xml_client.responseText;
+                    if (Ajax.xml_client.status == 200) {
+                        document.getElementById(obj).innerHTML = Ajax.xml_client.responseText;
+                    }
                 }
             };
         Ajax.xml_client.open ('GET', src, true);
index 3cdd140..b936f32 100644 (file)
@@ -40,6 +40,9 @@ define('SKINNED', 0);
 define('SIMPLE',  1);
 define('NO_SKIN', 2);
 
+define('NO_AUTH', 0);
+define('DO_AUTH', 1);
+
 function __autoload($cls)
 {
     @include dirname(dirname(__FILE__)).'/classes/'.strtolower($cls).'.php';
index 787e236..27f0c36 100644 (file)
@@ -40,13 +40,13 @@ class CoreModule extends PLModule
 
     function handler_403(&$page)
     {
-        header('HTTP/1.0 403 Forbidden');
+        header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
         $page->changeTpl('403.tpl');
     }
 
     function handler_404(&$page)
     {
-        header('HTTP/1.0 404 Not Found');
+        header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
         $page->changeTpl('404.tpl');
     }
 
index 6ee2131..b77ec70 100644 (file)
@@ -27,7 +27,7 @@ class ListsModule extends PLModule
     {
         return array(
             'lists'           => $this->make_hook('lists',     AUTH_MDP),
-            'lists/ajax'      => $this->make_hook('ajax',      AUTH_MDP),
+            'lists/ajax'      => $this->make_hook('ajax',      AUTH_MDP, '', NO_AUTH),
             'lists/create'    => $this->make_hook('create',    AUTH_MDP),
 
             'lists/members'   => $this->make_hook('members',   AUTH_COOKIE),