vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   VB Login on a Non-VB Page vB3 RC3 (https://vborg.vbsupport.ru/showthread.php?t=61112)

mcahill 02-02-2004 10:00 PM

VB Login on a Non-VB Page vB3 RC3
 
This is a simple modification to do, and adds a lot of value to your homepage.

Notes:

1. This script can occassionally have conflicts with other javascripts. Test before you deploy.
2. If you use and include to put the file on your page, be sure that the chdir and the require for global.php is in the head of the main document.
3. It is assumed that you are using a php page, and that you have already got connectivity with your database.


The code:

At the top of the document, before the <html> or <head> tags (edit to provide the path for your particular installation):

PHP Code:

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

Wherever you want your login:

PHP Code:

 <?
 

if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];
  
print("<align='center'><span class='sectionheader'>Welcome back, $username!<br>");

} else {
   


?>
<form action='/forum/login.php' method='post' onsubmit='md5hash(vb_login_password,vb_login_md5password)'>
        <script type='text/javascript' src='/forum/clientscript/vbulletin_md5.js'></script>
        
         <span class="sectionheader">Username:</span>
            <input type='text' class='button' name='vb_login_username' id='navbar_username' size='15' accesskey='u' tabindex='1' value='' onfocus='if (this.value == 'username') this.value = '';' /><br>
            
            <span class="sectionheader">Password:&nbsp;</span>
            <input type='password' class='button' name='vb_login_password' size='15' accesskey='p' tabindex='2' /><br>
            <input type='checkbox' name='cookieuser' value='1' tabindex='3' id='cb_cookieuser_navbar' accesskey='c' checked='checked' /><span class='sectionheader'>Remember Me</span><br>
        
        
        
        <input name="submit" type='submit' class='button' accesskey='s' tabindex='4' title='Log In' value='Log In' />
        <input type='hidden' name='do' value='login' />
        <input type='hidden' name='forceredirect' value='1' />            
        <input type='hidden' name='vb_login_md5password' />
        </form>
                        <?

 } 

?>

Troubleshooting:

Before requesting support, please check the following:

1. Make sure you have the path to your forum in the chdir. If you haven't done this, you will get a "can't include" error.
2. Make sure you have the chdir in the main document. If it isn't you will get a "can't modify header" error.
3. If those don't resolve the issue, try putting the login in a separate file, with no other code. If it works there, then you will know that you have a conflict with one of the scripts on the page you are trying to add the login to. I can't help you if you've got a conflict with another script.

vbmechanic 02-03-2004 01:18 PM

One suggestion, if you chdir at the top of the program to include something, you should also chdir back to the original location so you don't disrupt any relative includes further down the code.

PHP Code:

chdir("forum/"); 
require(
'./global.php');  
chdir("../); 

cheers!

buro9 02-03-2004 02:11 PM

Quote:

Originally Posted by vbmechanic
One suggestion, if you chdir at the top of the program to include something, you should also chdir back to the original location so you don't disrupt any relative includes further down the code.

A further note on this is that vBulletin's XSS measures are now kicking arse... and if you were going to use the above within another PHP script and expected some inputs or other vars that you can't get hold of... it's because \includes\init.php

You will need to have fun in there to work out how to get to your vars.

VeoMorphine 02-04-2004 10:50 AM

hmmmmmm...... Just a sugestion. Insted of writing out all the form code i think vbulletin has a make_login() or somthing like that function. But they way you did it offers more flex to it so, either way has its ups and downs.

apokphp 02-05-2004 02:17 AM

What about if the page is html. I know your hack is for .php, but is it possible to use on html pages? Or should the html page be converted to .php? And if so, isn't that done just by adding the <?php tag?

Wired1 02-05-2004 02:45 AM

Using <? just tells the server that PHP code is coming. It's still PHP, which is a server side thing. HTML is user side.

apokphp 02-05-2004 03:48 AM

My server has php. My index is html. I use vb as a forum. I'd like to use some form of vb logon on the front page which is not related to vb at all.

mcahill 02-05-2004 09:18 PM

The page needs to be php. That means it has to have a .php extension. If you're running vB on the same server, you have php installed.

If the page has an html extension, it will not be processed by the server.

Oxcide 02-05-2004 10:20 PM

Hehe, Apok has already seen this, to bad he never told me.

Anyway.

What if I want to use this on a remote server/site.

Should I include the remote database information above the chdir? And then use a URL to those files on the remote server? Or change it to connect to the server, and use the absolute path to the files?

Or is it as simple as doing

require('http://www.pathtoremoteserver.com/forums/global.php');

mcncyo 02-07-2004 10:37 AM

Quote:

Originally Posted by Oxcide
Hehe, Apok has already seen this, to bad he never told me.

Anyway.

What if I want to use this on a remote server/site.

Should I include the remote database information above the chdir? And then use a URL to those files on the remote server? Or change it to connect to the server, and use the absolute path to the files?

Or is it as simple as doing

require('http://www.pathtoremoteserver.com/forums/global.php');



I would also like to know how to do this but mine is on the same server

-animal- 02-07-2004 11:34 AM

the code works great but when i enter my login details, if the page changes to the "thanks for logging in" page and then back to the page that has the login forms. Is there anyway to say get it to not go to the thanks for loggin in page and then rather than just displaying the login boxed display the users avatar who just logged in?

thanks

mcahill 02-09-2004 12:26 PM

Set the value in the form for Forceredirect to 0 and it will not show the thank you for logging in. To get the avatar displayed, you'd need to take a look at what is available in bbuserinfo[] or figure out how to add the avatar stuff from you postbit template.

Blue Moose Aaron 02-11-2004 02:11 PM

Is it at all possible to have the users avatar show up?

Osterling 02-12-2004 01:56 AM

i did the direction and i am getting this error message:

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/exasko/public_html/forum_tester/test.php on line 13

line 13 is..

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

got any ideas what's wrong

killervette 02-12-2004 05:32 PM

redirect doesnt work for me.

gopherhockey 02-14-2004 02:49 PM

Quote:

Originally Posted by apokphp
My server has php. My index is html. I use vb as a forum. I'd like to use some form of vb logon on the front page which is not related to vb at all.

I have the same issue. I changed to .shtml and can now include .php pages. Make a blank .php page and put the snip of code they refer too in there.

misterfade 02-15-2004 10:08 PM

I got this to work, but it takes me back to where I put the login form. I want it to log me in an take me into the forums. How do I do that?

I already have this setup with VB2.3, and it works great. It's set so that when you go back to the index.php page of my site (not the forums), it shows:

"Welcome back, [name]
New Threads:
New Posts:
New PM's
Logout"

How can I do that with this hack? Having the login form/welcome box on a non-vb page is somewhat of a lifeline for my site, my members rely on it a lot so I really need to get this working, any suggestions?

Any help would be appreciated.

Thanks.

gmarik 02-16-2004 03:13 PM

So maybe somebody has putt it in a pop-up box - has somebody?
Could it be remade so I could use it in a HTML pure page, maybe with JS?

magmaink 02-23-2004 09:58 AM

Quote:

Originally Posted by exasko
i did the direction and i am getting this error message:

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/exasko/public_html/forum_tester/test.php on line 13

line 13 is..

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



got any ideas what's wrong

i have the same problem

Diana Notacat 02-24-2004 12:24 AM

This is working great. ;) Is there anyway to add some code where once a user is logged in they'll see content based on what user group they're in?

For example ALL members would see "Link1 Link2 Link3" but then only Admins/Mods or the user group you choose can see "Link4 Link5 Link6"....

idwf 02-25-2004 04:53 PM

'
Warning: main(): open_basedir restriction in effect. File(/forums/global.php) is not within the allowed path(s): (/home/indeathw:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/indeathw/public_html/indextest.php on line 2

Warning: main(/forums/global.php): failed to open stream: Operation not permitted in /home/indeathw/public_html/indextest.php on line 2

Fatal error: main(): Failed opening required '/forums/global.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/indeathw/public_html/indextest.php on line 2'

on RC4...any ideas????:ermm:

Jensie180 02-28-2004 08:58 AM

I downloaded this hack, work great! I only need some more stuff when the member is logged in. Like the avatar image, new pms, last visited? I know there are codes for this, but can someone help me get these?

Thanks!

cerebro 03-02-2004 09:50 PM

please some hack to login in ASP page..but i other webserver, diferent that forum server.

Chrissicom 03-14-2004 08:42 AM

hmmm I put the code on my index.htm on IIS 6 and it is just working fine, no need to rename it to .php (the .htm file is XHTML 1.1 compliant, but I don't think this affects the php code to working or non-working).... do I need to have index.php on Apache or it won't work?!?

cerebro 03-15-2004 04:53 PM

yeap, not need .php but you have the forum and website in the same SERVER.
I have one computer for my board, and another for my Forum...

brownafroduck 03-20-2004 05:19 PM

This seems to work great for me so far, but I have a question...

Can someone explain what is happening in the first piece of code? Just what does it mean and what is it doing?

Thanks. :)

Kumaro 03-20-2004 07:57 PM

Okay, I finally got this hack to work with my PHPnuke 7.1. There's still 1 problem remaining. It logs in and returns to the main page, however the message does not change to "Welcome username", it always shows the login form....I made it into a phpnuke block, so it is in its' own file. The login is successful, but there is no welcome page.

PHP Code:

if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];
  
$content "<align=\"center\"><span class=\"sectionheader\">Welcome back, $username!<br>"

^^is that being ignored or something?

misterfade 03-23-2004 10:24 PM

Quote:

Originally Posted by mcahill
1. This script can occassionally have conflicts with other javascripts. Test before you deploy.

That's the exact problem I'm having with the javascript. The script works, but I always get an error when the page loads (before I login). I tried this hack without the javascript and it still works fine.

So, why is this line of javascript needed to login?
<script type='text/javascript' src='/forum/clientscript/vbulletin_md5.js'></script>

Thanks.

MindTrix 03-25-2004 02:06 PM

Thats the line that calls the java file

Snappa 03-25-2004 02:55 PM

bump!

gmarik 03-25-2004 04:29 PM

Is it ok with Gold?

Ky Kiske 03-25-2004 06:03 PM

How do you do this if your forum is on a different url then your main site?

Example: Like I have www.mysite.com and then I have www.myforums.com. How can I do it like this?

misterfade 03-25-2004 06:04 PM

Quote:

Originally Posted by MindTrix
Thats the line that calls the java file

Yes, I know but I'm just asking why is that line needed when the login form works without it?

misterfade 03-25-2004 10:16 PM

After testing this some more, I tried it on a blank page with just this code and I still get javascript errors (error message at the bottom left corner of my browser). Is it just me, or is anyone else having this problem? Could it be vbulletin's code that doesn't go well on external pages??

chapsrulez 03-26-2004 08:40 PM

Finally i managed to get this code working on my server, people can login from the home, but im getting a syntax error on line 12 which is the following.

<input type='text' class='button' name='vb_login_username' id='navbar_username' size='15' accesskey='u' tabindex='1' value='' onfocus='if (this.value == 'username') this.value = '';' /><br>

any info how to solve the problem.
thanks.

chapsrulez 03-26-2004 10:54 PM

Never mind about the above, i already fix that.

Also if u want to display last login and time after
if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];

Add the following.

$lastvisitdate=$pmbox['lastvisitdate'];
$lastvisittime=$pmbox['lastvisittime'];

It should look like
if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];
$lastvisitdate=$pmbox['lastvisitdate'];
$lastvisittime=$pmbox['lastvisittime'];

cheers.

accyroy 04-11-2004 02:46 PM

To fix the errors in the bottom of the screen you need to get rid of
Code:

onfocus='if (this.value == 'username') this.value = '';' /
from this line:

Code:

<input type='text' class='button' name='vb_login_username' id='navbar_username' size='15' accesskey='u' tabindex='1' value='' onfocus='if (this.value == 'username') this.value = '';' /><br>
Don't actually know what this does exactly, but everything seems to work normally without it and you lose the error message.

accyroy 04-11-2004 02:48 PM

Quote:

Originally Posted by gmarik
Is it ok with Gold?

yes, this works fine with gold.

Sakura Online 04-12-2004 05:24 AM

Quote:

Originally Posted by Kumaro
Okay, I finally got this hack to work with my PHPnuke 7.1. There's still 1 problem remaining. It logs in and returns to the main page, however the message does not change to "Welcome username", it always shows the login form....I made it into a phpnuke block, so it is in its' own file. The login is successful, but there is no welcome page.

PHP Code:

if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];
  
$content "<align=\"center\"><span class=\"sectionheader\">Welcome back, $username!<br>"

^^is that being ignored or something?

I'm having this exact same problem. does anyone know what to do about it?

KOM 04-13-2004 03:10 PM

I get this when I try to go to my website

Parse error: parse error in /home/wvgl/www/index.php on line 9


All times are GMT. The time now is 11:39 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02067 seconds
  • Memory Usage 1,839KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (5)bbcode_php_printable
  • (8)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete