Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-17-2012, 01:27 PM   #11
mydogmax
Registered User
 
Join Date: Jun 2008
Posts: 42
Default

Hi

Can you tell me how to adapt the logout1() function so that it uses return "../../login.php";

Code:
function logout1(){
global $logoutAction2;
$logoutAction2 = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction2 .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
$logoutGoTo = "../../login.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
}
mydogmax is offline   Reply With Quote
Old 06-17-2012, 01:48 PM   #12
-:)lauri
Senior Member
 
Join Date: Aug 2008
Location: Helsinki, Finland
Posts: 1,184
Default

so your logout1() function looks like:

PHP Code:
function logout1(){
    global 
$logoutAction2;
    
$logoutAction2 $_SERVER['PHP_SELF']."?doLogout=true";
    if ((isset(
$_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
        
$logoutAction2 .="&"htmlentities($_SERVER['QUERY_STRING']);
    }
    if ((isset(
$_GET['doLogout'])) &&($_GET['doLogout']=="true")){
        
//to fully log out a visitor we need to clear the session varialbles
        
$_SESSION['MM_Username'] = NULL;
        
$_SESSION['MM_UserGroup'] = NULL;
        
$_SESSION['PrevUrl'] = NULL;
        unset(
$_SESSION['MM_Username']);
        unset(
$_SESSION['MM_UserGroup']);
        unset(
$_SESSION['PrevUrl']);
        
$logoutGoTo "../../login.php";
        if (
$logoutGoTo) {
            
header("Location: $logoutGoTo");
            exit;
        }
    }

In the end of the function

change this:
PHP Code:
//...
        
if ($logoutGoTo) {
            
header("Location: $logoutGoTo");
            exit;
        } 
to this

PHP Code:
//...
        
if ($logoutGoTo) {
            return 
$logoutGoTo;
        } 
actually the last if looks like irrelevant so you should be able to change this

PHP Code:
//...
        
$logoutGoTo "../../login.php";
        if (
$logoutGoTo) {
            
header("Location: $logoutGoTo");
            exit;
        } 
to this

PHP Code:
//...
        
return "../../login.php"
or if you're checking if the page exist before redirection user to there then it should be like:

PHP Code:
//...
        
$logoutGoTo "../../login.php";
        if (
file_exists($logoutGoTo)) {
            return 
$logoutGoTo;
        } 

Last edited by -:)lauri; 06-17-2012 at 01:52 PM.
-:)lauri is offline   Reply With Quote
Old 06-17-2012, 04:04 PM   #13
mydogmax
Registered User
 
Join Date: Jun 2008
Posts: 42
Default

When you say handler.php do you mean the file that contains the logout button,
in this case computers_publicaccess.php
I tried this and received a 404 error
Code:
logOutBtn.onPress = function()
{
    var my_vars = new LoadVars();
    my_vars.logout = "djvksaldk";
    my_vars.onLoad = function(loggedOut:Boolean)
    {
        if(loggedOut)
        {
            getURL(my_vars.url,"_self");
        }
    }
    my_vars.sendAndLoad("computers_publicaccess.php", my_vars, "POST");
}
Not Found

The requested URL /tutor_admin/public/computers/undefined was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
mydogmax is offline   Reply With Quote
Old 06-17-2012, 05:06 PM   #14
-:)lauri
Senior Member
 
Join Date: Aug 2008
Location: Helsinki, Finland
Posts: 1,184
Default

handle.php was separate file and I didn't put there anything else than this:
PHP Code:
<?php
    
require_once 'functions.php';
    
    if(isset(
$_POST['logout']))
    {
        echo 
"url=" logout1();
    }
?>
Now you should have "handle.php" with content above on your server in the same folder than the file where you have the file which contains the web page that contains the button.

...and then the button file should of course refer to handler.php file rather than anything else:

Code:
logOutBtn.onPress = function()
{
    var my_vars = new LoadVars();
    my_vars.logout = "djvksaldk";
    my_vars.onLoad = function(loggedOut:Boolean)
    {
        if(loggedOut)
        {
            getURL(my_vars.url,"_self");
        }
    }
    my_vars.sendAndLoad("handle.php", my_vars, "POST");
}

Last edited by -:)lauri; 06-17-2012 at 05:15 PM.
-:)lauri is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:41 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.