1 (edited by Jakelshark 2006-08-14 00:19)

Topic: Login intergration script, just not perfect

Hi, Im working on an easy to use script that will put a log in box on the main page.

I codded everything, and I am going to post the 0.1 release in this thread...

The only thing that is keeping it from being perfect is the logout function. I would like to be able to specify [by URL] where a user will be redirected after logging out.  You can do it with the login form, but I dont know how to get it to work with the logout...

Anyways, here is the script...just save it all as includes.php and put it in the directory of your main site files

<?php

/***************************************************************************************************
Simple login script made for punbb 1.2
Version: 0.1
Release Date: Jan 26, 2005

How to install this script...in just three steps!
First do a simple change on line 49

   define('PUN_ROOT', 'XXXXXX');

 XXXXXX is the location of your forum system relevant to the location of this file
 example

    define('PUN_ROOT', 'systems/forums/');


Change this bit of code [line 50] to the place you want a logging in user to be redirected to
    
    $return = "URL OF REDIRECTION"

example
    $return = "http://localhost/index.php"


Third step
Insert this code into the page you wish to have this log in functionality
*notes: take out the extra space at the ";? >"
        this is assuming that the includes file is in same location as target file

    <?php include "includes.php";? > 

Make sure the page is saved as a .php and it should work fine :D


Release Notes:
No lang pack support yet. Of course there are only a handful of words that would need changing.
I just have the page refresh to log in, no redirect screen...some may or may not like that.


**************************************************************************************************/


// Two Variables to set
define('PUN_ROOT', 'XXXXXX');
$return = "URL OF REDIRECTION";

// Connect to the system and create a simple trash variable [for easier form coding]
require PUN_ROOT.'include/common.php';
$root = PUN_ROOT;

// Check if guest, if so do a log in, otherwise great user
if ($pun_user['is_guest'])
    {
      // Below is the log in form for a guest, also including links for registration and to email password
      ?>
          <form id="login" method="post" action="<?php echo $root ?>login.php?action=in" onsubmit="return process_form(this)">
            <input type="hidden" name="form_sent" value="1" />
            <input type="hidden" name="redirect_url" value="<?php echo $return ?>" />
            <label class="conl"><?php echo $lang_common['Username'] ?><br /><input type="text" name="req_username" size="25" maxlength="25" tabindex="1" /><br /></label>
            <label class="conl"><?php echo $lang_common['Password'] ?><br /><input type="password" name="req_password" size="16" maxlength="16" tabindex="2" /><br /></label>
            <input type="submit" name="login" value="<?php echo $lang_common['Login'] ?>" tabindex="3" />
            <br><br>
              <a href="<?php echo $root ?>register.php" tabindex="4">Register</a> | 
            <a href="<?php echo $root ?>login.php?action=forget" tabindex="5">Email Password</a>
          </form>
      <?php
    } else {
       // The data to show to a member. This shows a welcome, then links for the profile and logout stuff
       ?>
          <br>
          <font face="Verdana, Arial, Helvetica, sans-serif" size="1">Greetings <b><?php echo $pun_user['username'];?></b>!<br>
          <a href="<?php echo $root ?>profile.php?id=<?php echo $pun_user["id"] ?>">Profile</a> | <a href="<?php echo $root ?>login.php?action=out&id=<?php echo $pun_user["id"] ?>">Logout</a>
          </font><br><br>
       <?php
    }
?>

2 (edited by Gizzmo 2005-01-26 20:09)

Re: Login intergration script, just not perfect

look in login.php near line 96

idont know if thiswill work so dont use it unless you test it first

if(isset($_GET['url']))
    $redir_url = $_GET['url'];
else
    $redir_url = 'index.php';

redirect($redir_url, $lang_login['Logout redirect']);