26

Re: XtraCAD

John, try using @include with the full url.

Re: XtraCAD

I have completed the ammendment of the site login scripts calling PunBB's functions and made it simple so that a non programmers can set it up. I cannot upload the files to PunnBB so I will put them on a website and post the URL soon.

Paul M

28

Re: XtraCAD

Great Work. I have acres of webspace lying around on a commercial host. If you want me to up the files just email them to me and I will post the link back here.

29 (edited by Paul Marsland 2004-02-16 08:18)

Re: XtraCAD

Paul wrote:

Great Work. I have acres of webspace lying around on a commercial host. If you want me to up the files just email them to me and I will post the link back here.

To login to your PunBB forum from a main page from your site you can do so by:

1. replacing login.php with the modified version (see quote, you may have to wait a few hours for the link to appear) The mods will not alter the functionality of the script in any way.

Note, If PunBB is part of your main website you may as well use the cookie it creates to control access to any web pages that are for your site members only. For this reason the code below will allow logging in and control.

2. Add the following code at the top of each webpage you wish to either protect or login from. fail.php can be changed to point to your own failed login page. $member < 0 is used to restrict access, this example would allow anyone to view the page changing the 0 to 1 would change the access to members and admin, changing 0 to 2 would allow admin only.

<?php
  include("auth.php");
  if($member < 0){
    header ("Location: fail.php");
  }
?>

3. Add the following code where you wish the login boxes to appear (this is the minimum code, styles and formatting would be applied to suit your site). The body 'onLoad' tag is added only if you wish your login username field to have focus.

<body onLoad="document.getElementById('login').req_username.focus()">
<?php
  if ($member == 0)
    include("login.txt");
  else
    echo '<a href="forum/login.php?action=qout">Logout?</a>';
?>

4. Copy auth.php and login.txt to the same directory as your webpages.

auth.php contains the following code. $member = 0 if no cookie exists or a cookie for a Guest user has been set. $member = 1 if a member has logged in, $member = 2 if an administrator (with a username of admin) has logged in:


<?php
  function un_escape($str){
    return (get_magic_quotes_gpc() == 1) ? stripslashes($str) : $str;
  }
  if(isset($punbb_cookie)){
    list($str) = unserialize(un_escape($punbb_cookie));
    if ($str == "Guest")
      $member = 0;
    else if ($str == "admin")
      $member = 2;
    else
      $member = 1;
  } else
      $member = 0;
?>


login.txt contains the following code (this is the minimum code, styles and formatting would be applied to suit your site). The 'action' path may need to be ammended to point to where you have login.php.


<form method="post" action="forum/login.php?action=qin" id="login" onsubmit="return process_form(this)">
  <input type="hidden" name="form_sent" value="1">
  <input type="hidden" name="MainSiteLogin" value="<?php $text = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PATH_INFO'];echo "$text\">";?>
    <table cellspacing="1" cellpadding="4">
      <tr>
        <td nowrap"><b>Username</b></td>
        <td> <input type="text" name="req_username" size="25" maxlength="25"></td>
      </tr>
      <tr>
        <td nowrap"><b>Password</b>  </td>
        <td > <input type="password" name="req_password" size="16" maxlength="16"></td>
      </tr>
      <tr>
        <td><input type="submit" name="login" value="Login"></td>
      </tr>
    </table>
</form>

I hope this has been explained OK

Paul M

30

Re: XtraCAD

Files can be obtained here

http://www.post21.co.uk/punlogin/MainSiteLogin.zip

Re: XtraCAD

Qlogin required cgi-bin ?

32 (edited by Paul Marsland 2004-02-19 07:54)

Re: XtraCAD

qlogin is no longer required, The revised code above uses PunBB functions, but there is a neater solution with explanation on the Mod Discussions/Login Box forum.

33 (edited by Paul Marsland 2004-02-19 08:54)

Re: XtraCAD

Actually the code on the Mod Discussions forum does not work, it refers you to the forum homepage.

I have set up a test page at http://langworthy.bpweb.net/index1.php where you can see each bit of code in action. The username and password is test

I have ammended the code in login.txt to:

<form method="post" action="forum/login.php?action=in">
    <input type="hidden" name="form_sent" value="1">
    <input type="hidden" name="redirect_url" value="<?php echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\">";?>

    Username1:  <input type="text" name="req_username" size="25" maxlength="25"><br>
    Password1:  <input type="password" name="req_password" size="16" maxlength="16"><br>
    <input type="submit" name="login" value="Login">
</form>

PM

34

Re: XtraCAD

Paul Marsland wrote:

Actually the code on the Mod Discussions forum does not work, it refers you to the forum homepage.

That was one of the problems I was having which is what prompted me to ask you for your code in the first place. I am putting together a front page something like PunBB's main page but incorporating your login which I will put up as a demo.

35 (edited by Paul Marsland 2004-02-20 14:21)

Re: XtraCAD

You can get the current URL using javascript, the code below has been included at http://langworthy.bpweb.net/index1.php This works with the action=in function as do the others methods which return a valid URL you only need action=qout (part of the modded login.php) to return you back to your current page when logging out.

<form method="post" action="forum/login.php?action=in">
    <input type="hidden" name="form_sent" value="1">
<script language="javascript">
  var href = location.href;
  document.write('<input type="hidden" name="redirect_url" value="');
  document.write(href);
  document.write('">');
</script>
    Username3:  <input type="text" name="req_username" size="25" maxlength="25"><br>
    Password3:  <input type="password" name="req_password" size="16" maxlength="16"><br>
    <input type="submit" name="login" value="Login">
</form>

Paul M

36

Re: XtraCAD

Paul Marsland wrote:

You can get the current URL using javascript, the code below has been included at http://langworthy.bpweb.net/index1.php This works with the action=in function as do the others methods which return a valid URL you only need action=qout (part of the modded login.php) to return you back to your current page when logging out.

i do not agree, never worked for me..