Main Page | Directories | File List | File Members

su.php

Go to the documentation of this file.
00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: su.php 5451 2006-02-19 18:03:51Z yeupou $
00006 #
00007 #  Copyright 2004-2006 (c) Mathieu Roy <yeupou--gnu.org>
00008 # 
00009 # The Savane project is free software; you can redistribute it and/or
00010 # modify it under the terms of the GNU General Public License
00011 # as published by the Free Software Foundation; either version 2
00012 # of the License, or (at your option) any later version.
00013 #
00014 # The Savane project is distributed in the hope that it will be useful,
00015 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 # GNU General Public License for more details.
00018 #
00019 # You should have received a copy of the GNU General Public License
00020 # along with the Savane project; if not, write to the Free Software
00021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023 require "../include/pre.php";
00024 
00025 register_globals_off();
00026 
00027 # Login was asked and user can be super user? Set a cookie and that's done.
00028 # For now, set a cookie that does not stay long, we'll see if admin complains 
00029 # :P
00030 $action = sane_get("action");
00031 $uri = sane_get("uri");
00032 $from_brother = sane_get("from_brother");
00033 if ($action == "login" && user_can_be_super_user())
00034 {
00035   session_cookie("session_su", "wannabe");
00036   if ($GLOBALS['sys_brother_domain'])
00037     {
00038       if (!$from_brother)
00039         {
00040           header ("Location: ".su_getprotocol()."://".$GLOBALS['sys_brother_domain'].$GLOBALS['sys_home']."account/su.php?action=login&from_brother=1&uri=".urlencode($uri));
00041         }
00042       else {
00043         header("Location: ".su_getprotocol()."://".$GLOBALS['sys_brother_domain'].$uri);
00044       }
00045     }
00046   else {
00047     header("Location: ".$uri);
00048   }
00049 }
00050 
00051 elseif ($action == "login" && !user_is_super_user() && $from_brother)
00052 {
00053   # The user is not logged at this website, go back to the brother website
00054   header("Location: ".su_getprotocol()."://".$GLOBALS['sys_brother_domain'].$uri);
00055 }
00056 
00057 elseif ($action == "logout" && user_is_super_user())
00058 {
00059   #session_cookie('session_su', 'FALSE');
00060   session_delete_cookie("session_su");
00061   if ($GLOBALS['sys_brother_domain'])
00062     {
00063       if (!$from_brother)
00064         {
00065           header ("Location: ".su_getprotocol()."://".$GLOBALS['sys_brother_domain'].$GLOBALS['sys_home']."account/su.php?action=logout&from_brother=1&uri=".urlencode($uri));
00066           exit;
00067         }
00068       else {
00069         header("Location: ".su_getprotocol()."://".$GLOBALS['sys_brother_domain'].$uri);
00070       }
00071     }
00072   else {
00073     header("Location: ".$uri);
00074   }
00075 }
00076 
00077 elseif ($action == "logout" && !user_is_super_user() && $from_brother)
00078 {
00079   # The user is not logged at this website, go back to the brother website
00080   header("Location: ".su_getprotocol()."://".$GLOBALS['sys_brother_domain'].$uri);
00081 }
00082 
00083 else
00084 {
00085   exit_error(_("What are you doing here?"));
00086 }
00087 
00088 function su_getprotocol()
00089 {
00090   if (session_issecure())
00091     {
00092       return "https";
00093     }
00094   else
00095     {
00096       return "http";
00097     }
00098 }
00099 ?>

Generated on Sun Feb 26 13:23:04 2006 for Savane PHP Frontend Developer Reference by  doxygen 1.4.4