Welcome, Guest
  • Author Topic: a script that checks whether the user is logged in?  (Read 5993 times)

    Faheem Ullah Hashmi

    • Seasoned Programmer
    • ***
    • Posts: 250
      • MSN Messenger - faheem_u_h@hotmail.com
      • View Profile
      • Blue Vision
      • Email
    Re:a script that checks whether the user is logged in?
    « Reply #15 on: 03/04/03, 12:15 »
    well... then simplest way is that u need to create a variable in php page ..

    something like...

    $userLogedIn
    $usernotLogedin

    and send this variable with every click... in URL encoded format..

    will be something like...

    http://www.abc.com/mypage.php?login=yes

    so if user comes to...

    http://www.abc.com/mypage.php

    he will have a no login status..

    but its not the full proof this..

    for this .. u can use.. time stamp ..



    need to check time on runtime... and add it in login variable and compare it... ... ad soo ...

    its a lil loong thing..

    but try it... i hope this will solve ur prob atleast..

    GOOD LUCK
    .                 \\|//
     .                (o o)
    ~~~~oOOo~(_)~oOOo~~~~
                                            c/ya
                                            Faheem
    http://www.debug-zone.com
    http://www.debug-zone.com/info/faheem.html
    faheem@debug-zone.com

    Mohsin Sumar

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 1646
    • Mohsin Sumar, Extreme Web Technologies
      • MSN Messenger - mohsinsumar@hotmail.com
      • Yahoo Instant Messenger - mohsinsumar
      • View Profile
      • Extreme Web Technologies
      • Email
    Re:a script that checks whether the user is logged in?
    « Reply #16 on: 03/04/03, 13:26 »
    well.. i guess i try this after i m done with the login thing under the Mysql forum .. well.. after that.. i will have some hints on variables n so on.. so then i can proceed on to this one! thanx for the help though..
    - Best Regards, Mohsin Sumar
    - Mohsin Sumar dot com is hosted by Extreme Web Technologies

    Mohsin Sumar

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 1646
    • Mohsin Sumar, Extreme Web Technologies
      • MSN Messenger - mohsinsumar@hotmail.com
      • Yahoo Instant Messenger - mohsinsumar
      • View Profile
      • Extreme Web Technologies
      • Email
    Re:a script that checks whether the user is logged in?
    « Reply #17 on: 03/05/03, 10:45 »
    after a few hours of constant studying and testing of the viewforum.php copy file n editing it.. i finally come up to this thing:

    [script]
    <?php
    define('IN_PHPBB', true);
    $phpbb_root_path = './';
    include($phpbb_root_path . 'extension.inc');
    include($phpbb_root_path . 'common.'.$phpEx);

    if ( !$userdata['session_logged_in'] )
       {
          $Message = "Welcome";
       }
    else
       {
          $Message = "Login requred";
       }

    ?>
    <html>
    <head>
    <title><? print $Message; ?></title>
    </head>
    <body>
    <p><? print $Message; ?></p>
    </body>
    </html>
    [/script]

    well... this does work in some way but doesnt in another..
    well.. wen the user is logged in.. works well.. but wen he isnt.. it still displays the Welcome meaning that the user is logged in.. now how do i get that solved?

    « Last Edit: 03/05/03, 10:53 by Mohsin Sumar »
    - Best Regards, Mohsin Sumar
    - Mohsin Sumar dot com is hosted by Extreme Web Technologies

    Faheem Ullah Hashmi

    • Seasoned Programmer
    • ***
    • Posts: 250
      • MSN Messenger - faheem_u_h@hotmail.com
      • View Profile
      • Blue Vision
      • Email
    Re:a script that checks whether the user is logged in?
    « Reply #18 on: 03/05/03, 12:43 »
    ok.. if the user is loged in.. then

    Code: [Select]

    $userdata = "'session_logged_in";


    and if user is not loged in what is happening ... i mean what will be the value of  
    Code: [Select]

    $userdata



    i think this prob is coz of .. login session... its not expiring correctly
    .                 \\|//
     .                (o o)
    ~~~~oOOo~(_)~oOOo~~~~
                                            c/ya
                                            Faheem
    http://www.debug-zone.com
    http://www.debug-zone.com/info/faheem.html
    faheem@debug-zone.com

    Mohsin Sumar

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 1646
    • Mohsin Sumar, Extreme Web Technologies
      • MSN Messenger - mohsinsumar@hotmail.com
      • Yahoo Instant Messenger - mohsinsumar
      • View Profile
      • Extreme Web Technologies
      • Email
    Re:a script that checks whether the user is logged in?
    « Reply #19 on: 03/05/03, 13:00 »
    i dont know wat becomes the value wen the user is not logged in.. unfortunately.. i cannot post the script here as the forum sends back an error stating that the post is too long.. hence.. i need some help on it as to locate my error.. anyhow.. i will try to get the script for download perhaps.. by the way.. doesnt the code seem well.. as its checking whether that condition is true or not.. IF the condition would be, it would display the Welcome or ELSE login.. but that doesnt seem to work?
    - Best Regards, Mohsin Sumar
    - Mohsin Sumar dot com is hosted by Extreme Web Technologies

    Faheem Ullah Hashmi

    • Seasoned Programmer
    • ***
    • Posts: 250
      • MSN Messenger - faheem_u_h@hotmail.com
      • View Profile
      • Blue Vision
      • Email
    Re:a script that checks whether the user is logged in?
    « Reply #20 on: 03/05/03, 13:06 »
    incert this line in ur php page .. and run it..

    Code: [Select]

    echo ($userdata);


    this will display the value of the variable...
    .                 \\|//
     .                (o o)
    ~~~~oOOo~(_)~oOOo~~~~
                                            c/ya
                                            Faheem
    http://www.debug-zone.com
    http://www.debug-zone.com/info/faheem.html
    faheem@debug-zone.com

    Mohsin Sumar

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 1646
    • Mohsin Sumar, Extreme Web Technologies
      • MSN Messenger - mohsinsumar@hotmail.com
      • Yahoo Instant Messenger - mohsinsumar
      • View Profile
      • Extreme Web Technologies
      • Email
    Re:a script that checks whether the user is logged in?
    « Reply #21 on: 03/06/03, 06:58 »
    well.. its gives the output:

    Array

    ??? wats wrong.. may b i try re-creating the script from the original once again to trace my problem
    - Best Regards, Mohsin Sumar
    - Mohsin Sumar dot com is hosted by Extreme Web Technologies

    Faheem Ullah Hashmi

    • Seasoned Programmer
    • ***
    • Posts: 250
      • MSN Messenger - faheem_u_h@hotmail.com
      • View Profile
      • Blue Vision
      • Email
    Re:a script that checks whether the user is logged in?
    « Reply #22 on: 03/06/03, 09:16 »
    u need to check whats the value of that array...

    so that it will be confurmed that if user session is being created and getting expire or not.. !

    only then u can handel it...
    .                 \\|//
     .                (o o)
    ~~~~oOOo~(_)~oOOo~~~~
                                            c/ya
                                            Faheem
    http://www.debug-zone.com
    http://www.debug-zone.com/info/faheem.html
    faheem@debug-zone.com

    Mohsin Sumar

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 1646
    • Mohsin Sumar, Extreme Web Technologies
      • MSN Messenger - mohsinsumar@hotmail.com
      • Yahoo Instant Messenger - mohsinsumar
      • View Profile
      • Extreme Web Technologies
      • Email
    Re:a script that checks whether the user is logged in?
    « Reply #23 on: 03/06/03, 11:04 »
    ok.. and how do i check the value of the Array? as the php script i pasted before has NO ARRAYS or anything...
    - Best Regards, Mohsin Sumar
    - Mohsin Sumar dot com is hosted by Extreme Web Technologies

    Faheem Ullah Hashmi

    • Seasoned Programmer
    • ***
    • Posts: 250
      • MSN Messenger - faheem_u_h@hotmail.com
      • View Profile
      • Blue Vision
      • Email
    Re:a script that checks whether the user is logged in?
    « Reply #24 on: 03/06/03, 11:12 »
    u must know the name of that array..

    how u r creating that array ?

    or how u r creating taht variabale.. ?

    from where that variable is being assigned a value.. ?

    check that point... and then check those values..

    amd make it sure that is it really assigning the value to the variable.. !!
    .                 \\|//
     .                (o o)
    ~~~~oOOo~(_)~oOOo~~~~
                                            c/ya
                                            Faheem
    http://www.debug-zone.com
    http://www.debug-zone.com/info/faheem.html
    faheem@debug-zone.com

    Mohsin Sumar

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 1646
    • Mohsin Sumar, Extreme Web Technologies
      • MSN Messenger - mohsinsumar@hotmail.com
      • Yahoo Instant Messenger - mohsinsumar
      • View Profile
      • Extreme Web Technologies
      • Email
    Re:a script that checks whether the user is logged in?
    « Reply #25 on: 03/06/03, 11:16 »
    ok.. then i guess i must have messed up with the viewforum.php (COPY FILE) in order to create that login.. as the variable isnt created.. so the main thing that occurs is the first one.. i get back here after i create my new script.. thanx for the help.. until then.. HaPpY fLaShInG!  8)
    - Best Regards, Mohsin Sumar
    - Mohsin Sumar dot com is hosted by Extreme Web Technologies

    Mohsin Sumar

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 1646
    • Mohsin Sumar, Extreme Web Technologies
      • MSN Messenger - mohsinsumar@hotmail.com
      • Yahoo Instant Messenger - mohsinsumar
      • View Profile
      • Extreme Web Technologies
      • Email
    Re:a script that checks whether the user is logged in?
    « Reply #26 on: 03/09/03, 02:45 »
    hey again.. was working on the script for the past few days.. and finally came to a conclusion that works but i need some modifications to it!

    here is the code to it:

    [script]
    <?php

    define('IN_PHPBB', true);
    $phpbb_root_path = './';
    include($phpbb_root_path . 'extension.inc');
    include($phpbb_root_path . 'common.'.$phpEx);

    //
    // Start session management
    //
    $userdata = session_pagestart($user_ip, PAGE_POSTING);
    init_userprefs($userdata);
    //
    // End session management
    //

    //
    // The user is not authed, if they're not logged in then redirect
    // them, else show them an error message
    //
    if ( !$is_auth[$is_auth_type] )
    {
       if ( $userdata['session_logged_in'] )
       {
          message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_' . $is_auth_type], $is_auth[$is_auth_type . "_type"]));
       }
       
       redirect(append_sid("login.php" . $redirect, true));
    }
    ?>
    [/script]

    the thing is .. htat when the user is not logged in.. the page redirects to the login page and if the user is logged in.. it displays the normal template..

    now the modifications i want to do is that the page that is displayed .. wich is the template.. i want to remove it.. but how? i have tried messing around the code.. nothing works.. tried looking at the included files.. nothing ther too!! how do I do it?
    - Best Regards, Mohsin Sumar
    - Mohsin Sumar dot com is hosted by Extreme Web Technologies

    Mohsin Sumar

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 1646
    • Mohsin Sumar, Extreme Web Technologies
      • MSN Messenger - mohsinsumar@hotmail.com
      • Yahoo Instant Messenger - mohsinsumar
      • View Profile
      • Extreme Web Technologies
      • Email
    Re:a script that checks whether the user is logged in?
    « Reply #27 on: 03/09/03, 04:01 »
    yippieeeee!!!  :D :) ;D 8) ::) :o

    I DID IT!!! ;)

    i finally managed to set the login page to work the way i needed it!!! thanx for all your help, vesa and faheem.. thank you so very much...
    « Last Edit: 03/09/03, 04:08 by Mohsin Sumar »
    - Best Regards, Mohsin Sumar
    - Mohsin Sumar dot com is hosted by Extreme Web Technologies

    Mohsin Sumar

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 1646
    • Mohsin Sumar, Extreme Web Technologies
      • MSN Messenger - mohsinsumar@hotmail.com
      • Yahoo Instant Messenger - mohsinsumar
      • View Profile
      • Extreme Web Technologies
      • Email
    Re:a script that checks whether the user is logged in?
    « Reply #28 on: 03/09/03, 04:30 »
    too happy to solve my problem leaded my self into another problem :(

    ok.. heres the code:

    [scirpt]
    <?php

    define('IN_PHPBB', true);
    $phpbb_root_path = 'Board/';
    include($phpbb_root_path . 'extension.inc');
    include($phpbb_root_path . 'common2.'.$phpEx);

    //
    // Start session management
    //
    $userdata = session_pagestart($user_ip, PAGE_POSTING);
    init_userprefs($userdata);
    //
    // End session management
    //

    //
    // The user is not authed, if they're not logged in then redirect
    // them, else show them an error message
    //
    if ( !$is_auth[$is_auth_type] )
    {
       if ( $userdata['session_logged_in'] )
       {
          print ("<html>
               <head>
               <title>Welcome to the page.</title>
               </head>
               <body>
               <p align='center'>Welcome to the page.</p>
               <body>
          </html>");
       }
          print ("<html>
               <head>
               <title>Please Login or Register!</title>
               <META HTTP-EQUIV='Refresh' CONTENT='3; URL=login.php'>
               </head>
               <body>
               <h1 align='center'>Redirecting your browser to Login page.</h1>
               <p align='center'>If your browser does not refresh in 3 seconds, click <a href = login.php>here</a>.
               </p>
               <body>
          </html>");
           }
    ?>
    [/script]

    now wen the user is not logged in .. the page is showing the redirection thing.. but wen the user is logeed in.. the page is displaying BOTH!! how do i get it to display only ONE!! !!! please helpppppppp!!!!! ???
    - Best Regards, Mohsin Sumar
    - Mohsin Sumar dot com is hosted by Extreme Web Technologies

    Musicman

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 2685
      • View Profile
      • Email
    Re:a script that checks whether the user is logged in?
    « Reply #29 on: 03/10/03, 17:23 »
    Hi,

    at first glance I cannot see that else  keyword separating the two parts

    Musicman