PDA

View Full Version : [RELEASE v2] Homepage Login on non-vB page


RobAC
24 Jul 2001, 07:33
Ok....this is my first hack. It's small and should be very straight forward.

The source of this hack is a thread that started in the main Code Hacks forum by a user looking for a hack that would allow their members to log in from the main home page of their site. Once logged in, it would display a Welcome message when the logged in member returned to the home page.

The original source was provided by Demolition, but members were having problems with getting the hack to run.

Warning/Disclaimer: I am not a well seasoned PHP programmer. I get by as best I can, but usually learn from example and tinkering. I have changed the PHP coding around slightly, and added much more HTML in order to format the input fields etc. This hack was tested using Internet Explorer 5.5 and Netscat 4.7. I have verified that it works in both OS's several times. I am also running the latest version of PHP on my server, so I'm not sure how to help those of you that are running PHP3, but I'll do the best I can. I won't make any promises though. I plan on continuing to work on this as well as add a few more features to it as time permits.

Download the attached file and edit it using a text editor of your choice. Add the pathway to your forums directory where noted. Save the file as a PHP file to your main forums directory. If your site's home page is an HTML document you will have to call the PHP file using a server side include. If you're not sure how to do this, you should search the forums here as this topic has already been covered several times.

_
24 Jul 2001, 07:45
<form action="http://www.corvetteactioncenter.com/forums/member.php" method="post" />

You should really change that ;)

But nice hack for us html/php impaired :p

I'm just lazy.

RobAC
24 Jul 2001, 07:48
Sorry.....here it is. :rolleyes:

Ruth
24 Jul 2001, 09:39
RobAC, thanks

but i wasn't looking exactly for this, i was looking for a code to welcome the user in non-vB pages, when s/he logs in using login box in non vb pages, and this one doesnt work like this :(

Robert Basil
24 Jul 2001, 15:10
Rob,

I just added this hack to our community and it works great! Thanks!

RobAC
24 Jul 2001, 15:21
Originally posted by Ruth
RobAC, thanks

but i wasn't looking exactly for this, i was looking for a code to welcome the user in non-vB pages, when s/he logs in using login box in non vb pages, and this one doesnt work like this :(

Ruth,

Can you explain further? So you want it to say "Welcome back.....member on each non forum page? You don't want the login fields?

-Rob

BradC
24 Jul 2001, 15:47
By Definition Rob, I think what is wanted is lets say on the index.html or index page, it welcomes them to the site.

kind of like using a very basic phpportals :)

that is what I get out of it.

Rostor
24 Jul 2001, 18:19
Hi Rob, i try your hack but nothing works sorry :( it will be for the next time

Steve Machol
24 Jul 2001, 18:27
Originally posted by Ruth
RobAC, thanks

but i wasn't looking exactly for this, i was looking for a code to welcome the user in non-vB pages, when s/he logs in using login box in non vb pages, and this one doesnt work like this :(

Try this:

<?

require("./global.php");

if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];

echo"Welcome back, <b>$username</b>";

}
?>Here's a test page that has it in action. I don't know what it says if you're not a Member of OptiBoard though. Let me know.

http://www.optiboard.com/forums/last.php

Ruth
24 Jul 2001, 18:52
smachol, thanks, but i tried that it doesn't work...

RobAC, this is what i am trying to do...

i need to do the following in non-vB pages:

(1) if the user already logged use their cookies and display a welcome $username + logout link

(2) if the user is not logged use the login form before displaying the page content.

(3) prevent access to users awaiting confirmation (3) and users awaiting moderation (4)



<?

require("path-to/global.php");

if (!$bbuserinfo[userid] || $bbuserinfo[usergroupid]==3 || $bbuserinfo[usergroupid]==4) {
show_nopermission();
eval("dooutput(\"".gettemplate("error_wrongpassword")."\");");
}

if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];

echo"Welcome Back, <b>$username</b>";

} else {

?>

<table border="0" cellpadding="0" cellspacing="0" height="99">
<form action="http://path-to/forums/member3.php" method="post">
<tr>
<td nowrap height="13" colspan="2">
<p align="center"><font face="verdana,arial,helvetica" size="1" ><b>Login with username and password:</b></font></p>
</td>
</tr><tr>
<td nowrap height="25"><font size="2">User Name</font>
</td>
<td nowrap height="25"><input type="text" class="bginput" name="username" size="13">
</td>
</tr>
<tr>
<td nowrap height="27"><font size="2">Password</font></td>
<td nowrap height="27"><input type="hidden" name="s" value="$session[sessionhash]">
<input type="hidden" name="action" value="login"><input type="password" class="bginput" name="password" size="13">
<input type="submit" class="bginput" value="Login!"></td>
</tr>
</table>

<?

}

?>


i get error almost everywhere except for the login box, there is an error on show_nopermission line, and the user is not welcomed in non-vb pages. (i changed member.php to member3.php and alreasy set the redirect to the index of my main site (non-vB) )

please help :(

Steve Machol
24 Jul 2001, 18:58
Originally posted by Ruth
smachol, thanks, but i tried that it doesn't work...


Ruth, what doesn't work exactly? Make sure the script is in the same directory as your global.php file. This code works perfectly on my site.

RobAC
24 Jul 2001, 19:04
Ruth,

Can you be more specific when you say it doesn't work? Are you getting warning messages back? What version of PHP are you running? Is the pathway to the global.php file correct?

RobAC
24 Jul 2001, 19:07
Originally posted by Ruth
smachol, thanks, but i tried that it doesn't work...

RobAC, this is what i am trying to do...

i need to do the following in non-vB pages:

(1) if the user already logged use their cookies and display a welcome $username + logout link

(2) if the user is not logged use the login form before displaying the page content.

(3) prevent access to users awaiting confirmation (3) and users awaiting moderation (4)

i get error almost everywhere except for the login box, there is an error on show_nopermission line, and the user is not welcomed in non-vb pages. (i changed member.php to member3.php and alreasy set the redirect to the index of my main site (non-vB) )

please help :(


Is the main index page of your site an HTML document on PHP? So in other words, when someone clicks the link to go to your site....if they are a member, you want them to automatically be logged in....if they're cookies are set properly and have direct access to the site. If they aren't logged in, you want to be brought to a page that has nothing on it, other than the log in fields? It sounds like this is a little beyond my capability and I'm not sure I can help.

Ruth
24 Jul 2001, 19:28
Ruth, what doesn't work exactly?

Test 1
when i use that code without show_nopermission code, it only shows the login box in my index.php (non vB), when i try to login using the box, and it redirects me to the same page (index.php) it doesnt show the welcome screen, it shows the login box again (like if i'm not using cookies or not looged in)

Test 2
when i change number 0 to 1 in

if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];

echo"Welcome Back, <b>$username</b>";


i get the welcome screen only "Welcome Back" and not $username
but when i logout and come back it doesnt show the login box at all.


Test 3
when i add this to the code
if (!$bbuserinfo[userid] || $bbuserinfo[usergroupid]==3 || $bbuserinfo[usergroupid]==4) {
show_nopermission();
eval("dooutput(\"".gettemplate("error_wrongpassword")."\");");
}


i get error in show_nopermission(); line


Make sure the script is in the same directory as your global.php file. This code works perfectly on my site

the path to global.php works fine, and didnt have problem with it, however it is not in the same directory as the global.php, because i am trying to put this code in every non-vB page to protect it.

What version of PHP are you running?

PHP4 with Zend Optimizer

Is the main index page of your site an HTML document on PHP?

it is *.php

thanks for your help :)

Steve Machol
24 Jul 2001, 19:34
Ruth,

For what it's worth I believe I also had a problem using this unless the script was in the same directory as the global.php file. Sorry, I don't know what to recommend.

Ruth
24 Jul 2001, 19:49
smachol, is there a way by putting the script in the same path as global.php and just call it by one line like this code
require("./global.php");

maybe something like require or include ("path-to/forums/login.php");
in every protected page.

i'm not experienced in this.

thanks

Steve Machol
24 Jul 2001, 20:04
Ruth,

I'm just beginning to learn PHP myself. All I know is that the code I posted above works on my site when global.php and the script using it ('last.php') are in the same directory. I haven't yet tested any other variations.

BradC
25 Jul 2001, 03:50
How about putting in there the direct link to the global.php


require($DOCUMENT_ROOT . "/foldername/global.php");


foldername being whatever folder(s) lead to your vb folder..

then you can put the script anywhere.


update:

I use this for mine... my vb folder is "main" and I have an "about" folder in the same root as the main folder and I use this in all my pages to get the global.php


<?php
chdir($DOCUMENT_ROOT . "/main");
require($DOCUMENT_ROOT . "/main/global.php");
chdir($DOCUMENT_ROOT . "/about");
?>

mferrell
26 Jul 2001, 03:20
Anyone know how I can solve this error message when I require the global.php file on a non-vb page?

Warning: Failed opening './admin/config.php3' for inclusion (include_path='') in ./bulletinboard/global.php3 on line 66


Thanks.

Ruth
26 Jul 2001, 03:31
BradC thanks i'll try that...


Warning: Failed opening './admin/config.php3' for inclusion (include_path='') in ./bulletinboard/global.php3 on line 66

mferrell, make a duplicate file of global.php, change the path of config.php to the full path...and refer in your script to the duplicated global.php..and try...not sure if it works though.

mferrell
26 Jul 2001, 15:25
Thanks ... I'll give that a shot!

badmeetsevil-
28 Jul 2001, 22:55
Works fine for me, is there anyway for the login to bring you back to the page you used to login, or go to a specific page rather than the Forums? What I'm planning on doing, is having this in a pop-up, so you can sign in through the pop-up, and all it says after you sign in is something like, "Thanks for signing in, user." Is that possible, or will it always have to go to the BBS?

mferrell
29 Jul 2001, 01:01
I too have the login working fine on non-vb pages, but it takes you to the forum homepage. Does anyone know if it's possible to control what page gets loaded after login?

RobAC
29 Jul 2001, 01:33
I'll see what I can do about being able to specify a different page to go to after logging in.

badmeetsevil-
29 Jul 2001, 18:08
Thanks, that'd rule.

Nicholas Brown
02 Aug 2001, 19:47
how about


chdir("/your/path/to/forums/");
include("global.php");


?

mferrell
02 Aug 2001, 21:15
huh?

\/ash
04 Aug 2001, 07:20
ok could sumone post a WORKING script! All complete with deatiled instructions... Thank you!

certify
16 Aug 2001, 08:38
Will this work on .SHTML page?

it would be nice if I can directly call it via SSI e.g

<!-- include virtual="/something/something.php -->

Just like my site http://www.certifyexpress.com which it currently using UBB but I've just purchase VB license and will migrate to VB once I got the core hack on VB.

RobAC
16 Aug 2001, 12:21
certify,

yes it should.

Juan
16 Aug 2001, 12:59
This hack looks very cool. The only thing is that I can only get it to work correctly by calling the script direcly. When use php include on the index page, it gives me an error saying that headers have already been sent out.

Is there a way around it?

certify
16 Aug 2001, 16:15
Cool I'll use this hack. :)

certify
17 Aug 2001, 00:16
Can I have the login url instead of the login fields?

e.g.

You are not login, Login or Register

Juan
17 Aug 2001, 01:09
Has anyone got this hack to work correctly without geting any errors?

I've tried everything and always get errors when using php includes. Please, I need help.

Harry
17 Aug 2001, 01:32
Yes, worked without any problem. See at

http://www.schatzjagd.org

on the right side, with the who's online script

Harry

Rostor
26 Aug 2001, 15:41
Hi All,
it works but sometimes give me an error on header :eek:

Warning: Cannot add header information - headers already sent by (output started at C:\Inetpub\wwwroot\XXXXX\home.php:11) in C:\inetpub\wwwroot\XXXXX\forum\admin\functions.php on line 1459

Someone can help me plz ? :)

samtha25
27 Aug 2001, 09:01
Originally posted by Rostor
[B]Hi All,
it works but sometimes give me an error on header :eek:

Warning: Cannot add header information - headers already sent by (output started at C:\Inetpub\wwwroot\XXXXX\home.php:11) in C:\inetpub\wwwroot\XXXXX\forum\admin\functions.php on line 1459

That's what I get at smachol page, not being a registered user. :)

This would be a very nice thing to have - just a login or the welcome back message on the home page, but I think Rob may have lost interest, as it looks like he may be using vbportal.

Steve Machol
27 Aug 2001, 18:47
Originally posted by samtha25
That's what I get at smachol page, not being a registered user. :) Ahh, I wasn't aware of this. I have put this project on hold because of other priorities right now. Hopefully someone can suggest a fix for non-registered viewers. If I had the time, I'm sure I could figure it out.

RobAC
28 Aug 2001, 14:31
Originally posted by samtha25


That's what I get at smachol page, not being a registered user. :)

This would be a very nice thing to have - just a login or the welcome back message on the home page, but I think Rob may have lost interest, as it looks like he may be using vbportal.

Samtha,

I haven't lost interest, but I've been really busy the last couple of weeks and spent the last 4-5 days dealing with a loss in my family. I'm just getting back to work now, but will be taking off in a couple days for a much needed vacation. I won't be able to take a look at this hack until after I get back.

certify
09 Oct 2001, 11:33
I'm trying to convert my files to PHP but there is something wrong with the this code. Try to register an account, then login and go the the 2 links below, you will notice that from the index.shtml you the system managed to detect that you are login but from index.php you are still not login?? :confused:

This file call the header from header.shtml
http://www.certifyexpress.com/microsoft/index.shtml


<tr>
<td width="100%"><font face="verdana" size="2">&nbsp;&nbsp;<!--#include virtual="/forum/homelogin.php" -->,&nbsp;&nbsp;<b>Total Registered Members : <font color="#FF3300"><!--#include virtual="/forum/registered.php" -->&nbsp;</b></font></font>
<br>
</td>



This file call the header from header.php
http://www.certifyexpress.com/microsoft/win2kpro/index.php


echo "<td width=100%><font face=verdana size=2>&nbsp;&nbsp;";
include("http://www.certifyexpress.com/forum/homelogin.php");
echo "&nbsp;&nbsp;<b>Total Registered Members : <font color=#FF3300>";
include ("http://www.certifyexpress.com/forum/registered.php");
echo "&nbsp;</b></font></font>";
echo "<br>";
echo "</td>";


Below are the codes for homelogin.php


require("global.php");

if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];

echo "<font face=\"verdana\" size=\"2\">&nbsp;<b>Welcome back, <font color=\"#FF3300\">$username</font>&nbsp;!</b>&nbsp;[<a href=\"http://www.certifyexpress.com/forum/member.php?s=&action=logout\">Logout</a>]</font>";

} else {

?>

<font face="verdana" size="2">You are not login. <b><a href="http://www.certifyexpress.com/forum/pageregister.php?action=login">Login</a></b> or <b><a href="http://www.certifyexpress.com/forum/register.php">Register</a></b></font>

<?

}

?>

badmeetsevil-
16 Oct 2001, 21:16
Rob: The Homepage Logon to any page you want is possible. I just saw it in action at phpportals.com. Do you have a est on when you'll start/finish it?

Hooper
17 Oct 2001, 02:09
I don't understand this hack. I merely used the forumhome_logincode in my front page design.

badmeetsevil-
17 Oct 2001, 23:53
Link?

Alien
22 Oct 2001, 10:56
I've tried a million variations listed by everyone here, and I still cannot get mine to function. :)

I can get the login form to work, but it shows up EVERY time even when the user is logged in and of course has a cookie set.

So what needs to be done to get it to not show the form and detect the users login correctly so it won't show the form?

Otherwise the login form itself works excellent, it just prompts to login every time which isn't really desired..

Thanks guys. :D

Blackangel
22 Oct 2001, 20:01
Originally posted by Rostor
Hi All,
it works but sometimes give me an error on header :eek:

Warning: Cannot add header information - headers already sent by (output started at C:\Inetpub\wwwroot\XXXXX\home.php:11) in C:\inetpub\wwwroot\XXXXX\forum\admin\functions.php on line 1459

Someone can help me plz ? :)

i get the same error ...

homepage working if i call homepage.php directly

but if i include or require it on php page .... et get this error.

Any tips ?

certify
24 Oct 2001, 14:19
Juan are you still having this problem?

I just got that fix 2 weeks ago, probably I can help.

Juan
24 Oct 2001, 14:26
Thank you. I've moved to vbportal so now I don't have the need.

certify
24 Oct 2001, 14:35
What is vbportal?

Juan
24 Oct 2001, 17:34
http://phpportals.com

certify
25 Oct 2001, 15:12
WoW, looks great... wish I seen this ealier.

bitbender
25 Oct 2001, 18:22
I tried this hack last nite on a PHP based front page

Now, being that I'm a id-10-T newbie with PHP, I'll claim no great shakes at page design, or PHP coding, but, it seems to have serious issues(MySql DB errors, and bad pass data to SQL call) if there are no cookies, but only gets the: Warning: Headers already sent" error message when a cookie is present. Also, it DOES issue the Welcom back message. I know that the admin.php is called from the global.php include....

I also changed it up a bit, making all the statements after the } else { statement to be print( statements, as I wasn't getting a good result with the escape from html/PHP structure that was in place.

It DOES process the logon correctly, and allows the links on my front page direct access to the threads, so what I've got going wrong has to be simple....

Another consideration is that I use BadMeetsEvil's Headlines script, modified, and in several variants, each with a different forum category for all the areas on the board.

The other hacks used on the front page are;
Last 10 Posts (trimmed to 5)
Who's Online (Vertical Form)
Top 10 Posters

A sample of the page can be seen Here (http://www.bitbenderforums.com/phil5.php)

If you want to logon, use the userId: Varebel, password same as user Id. It's a read-only Id, so no posting is allowed, simply a test vehicle we use for see what the general public see's.

Thanks for any help in advance....Be kind, Old mainframers need help, too :))

JohnBradshaw
25 Oct 2001, 22:30
Hi

Can anyone help me?

I have a Digi Chat hosting thing, at the moment I can get it to log into the chat system if the user is already logged in and on the vB board.

But what I now need to do is allow a user to login and get to the chat system at the same time, anyone know how to do this?

The code I currently have is:
<?php

include("./global.php");

if (!$bbuserinfo[usergroupid]==7 || $bbuserinfo[usergroupid]==6 || $bbuserinfo[usergroupid]==5 || $bbuserinfo[usergroupid]==7) {
eval("dooutput(\"".gettemplate('chatmod')."\");");
} else {
if (!$bbuserinfo[usergroupid]==7 || $bbuserinfo[usergroupid]==2) {
eval("dooutput(\"".gettemplate('chat')."\");");
} else {
eval("dooutput(\"".show_nopermission()."\");");

} // end if

?>

And a template:
Chat
<html>
<head>
<title>$bbtitle - $foruminfo[title]</title>
$headinclude
</head>
<body>
$header
<center><!-- *** START APPLET CODE *** -->
<APPLET NAME="DigiChat"
CODEBASE="http://host4.digichat.com/DigiChat/DigiClasses/"
CODE="com.diginet.digichat.client.DigiChatApplet"
WIDTH="200" HEIGHT="100" ALIGN="MIDDLE"
ARCHIVE="client.jar">

<PARAM NAME="siteID" VALUE="XXXX">
<PARAM NAME="cabbase" VALUE="Client.cab">
<PARAM NAME="background" VALUE="0099cc">
<PARAM NAME="textcolor" VALUE="000000">
<PARAM NAME="nickname" VALUE="$bbuserinfo[username]">

DigiChat requires a Java Compatible web browser to run.
</APPLET>
<!-- *** END APPLET CODE *** --></center>
$footer
</body>
</html>

Gutspiller
14 Apr 2002, 01:56
I installed this hack and I like it, but it has spaces above and below the login. I was able to get rid of the spaces above and below the text after you login, but I can't seem to find out how to get rid of the spaces on the login menu thingy.

I am using the code that is in this attachment: http://www.vbulletin.org/forum/attachment.php?s=&postid=143603

(Post #3 in this thread.)

Can somebody please help me? I really want to use this hack, but those spaces just don't go with where I am trying to use this hack.

Thanks.

Meta
14 Apr 2002, 14:43
Yeah ... lovely hack ... works nice for me.

Thank you, RobAC!

mashby
21 Apr 2002, 22:25
Does anyone have this working with 2.2.5? I've installed it and everything is fine as long as the user is logged in. However, once you logout, it takes you to the login section and not the form that is part of the script.

Thoughts?

mashby
21 Apr 2002, 22:47
Ok, I have a few more details on this issue. :)

Since my VB board is part of a totally private site, I have it set so that guest cannot browse the board. Basically, there is no guest account.

So, if you're not logged in, you're immediately taken to the login window. Since this is being done as an include, it looks like I'm going to have to edit the template pretty heavily to get it to work correctly. Right now there are broken images and the re-directs aren't working.

I'm getting closer. :D

joecool
31 Aug 2002, 03:27
Read next post. :)

Editied....

joecool
31 Aug 2002, 14:09
Hey people.. If you get the error msg Cannot add header information, just add ::

<?php
chdir("forum/board/");
require('./global.php');
?>

At the VERY VERY top of your code.. Even before the HTML.. :)

this will change the directory, so you will have to reconfigure other PHP scripts, but stops header errors.

SVTBlackLight01
11 Mar 2003, 13:36
Originally posted by Hooper
I don't understand this hack. I merely used the forumhome_logincode in my front page design.

So far this is the only thing that I have gotten to even come close to working. The login works however you are redirected to the forums home page.

SVTBlackLight01
11 Mar 2003, 15:14
Originally posted by SVTBlackLight01


So far this is the only thing that I have gotten to even come close to working. The login works however you are redirected to the forums home page.

Well, this was way too easy so I must be missing something.

Anyway, to get it to return the same page, I made another member.php (members.php) and hard coded the return page url. Then reflected the new members.php path in the login box code.

I have tried it extensively and it worked every time.

Marulatree
24 Mar 2003, 12:12
Can anyone help me removing the spaces above and below the login boxes like what GUTSPLLER is talking about below:

04-14-02 at 12:56 AM Gutspiller said this in Post #53 (http://www.vbulletin.org/forum/showthread.php?postid=240394#post240394)
I installed this hack and I like it, but it has spaces above and below the login. I was able to get rid of the spaces above and below the text after you login, but I can't seem to find out how to get rid of the spaces on the login menu thingy.

I am using the code that is in this attachment: http://www.vbulletin.org/forum/attachment.php?s=&postid=143603

(Post #3 in this thread.)

Can somebody please help me? I really want to use this hack, but those spaces just don't go with where I am trying to use this hack.

Thanks.