Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Auth_vBulletin and Authentication

Quote Reply
Auth_vBulletin and Authentication
Hi,

I'm still having problems fully integrating a static GLinks 3.2.0 implementation with VBulletin 3.6.0 (as per http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=291880;)

Having searched the forums I can't find anything that appears to be an official solution to the problems that I and others have had regarding user authentication.

Questions:
  1. If a logged-in vBulletin user (who has the default vBulletin cookie) goes to the links area, the JavaScript on static pages doesn't detect that they're logged in. How can I fix this?
  2. If a registered vBulletin user (who has a cookie) goes to the links area, they are not able to log in. How can I fix this without asking them to visit the forum and then navigate back to links?
  3. The old version of Links 2.0 had about 2,000 people registered to get the update newsletter. How can I import them so that they can continue to get the newsletter?
I've attached an error log for an unregistered user attempting to log in via the normal form (just in case that helps).

Does anyone have any ideas on any of the above?

Any help will be very much appreciated, so thanks very much in advance.

:-)
Quote Reply
Re: [Red5] Auth_vBulletin and Authentication In reply to
I am having exactly the same problem - using Vbulletin 3.6. The static pages do not recognise that the user is logged in (but dynamic pages do).

Can someone please provide an answer; this is driving me mad trying to solve it.
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
If you know the name of the cookie in vBulletin, this my be a different approach you can use:

http://www.gossamer-threads.com/...i?post=293666#293666

Hope this helps,

- Jonathan
Quote Reply
Re: [jdgamble] Auth_vBulletin and Authentication In reply to
In Reply To:
If you know the name of the cookie in vBulletin, this my be a different approach you can use:

http://www.gossamer-threads.com/...i?post=293666#293666

Hope this helps,


I had a look through that and it looks like a pretty complicated fix. Although I am comfortable with coding, I am not sure that I really understand all of the instructions there.

I get an error "Unknown Tag: 'log' " having followed the final post to the letter.


The problem is that the Auth_vBulletin plugin doesn't work with current versions of vBulletin - and that is what needs fixing really.

Last edited by:

swissbob: Sep 30, 2006, 9:19 AM
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
OK, I presume that as well as everything in your final post, I also need to include this:

Code:

'log' => 'sub {
my $output;
my $session_id = GT::CGI->cookie(\'s\') || GT::CGI->param(\'s\');
if ($ENV{SCRIPT_NAME} =~ /nph-build/) {
$output = \'<!--#include virtual="/cgi-bin/log.cgi" -->\';
}
elsif ($ENV{QUERY_STRING} =~ /logout/) {
$output = "<a href=\'$CFG->{\'db_cgi_url\'}/user.cgi\'>Login</a>";
}
else {
if ($session_id) { $output = "<a href=\'$CFG->{\'db_cgi_url\'}/user.cgi?logout=1\'>Logout</a>"; }
else { $output = "<a href=\'$CFG->{\'db_cgi_url\'}/user.cgi\'>Login</a>"; }

}
return $output;

}',

My question is... where does that go?
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
Don't use that global. Just follow the directions on my LAST post.

- Jonathan
Quote Reply
Re: [jdgamble] Auth_vBulletin and Authentication In reply to
Well, I did that and just get the error: Unknown Tag: 'log'

I can't see where the tag is registered in your instructions
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
The global registered is 'login' - should that be 'log' instead?

I am getting really confused about this - I apologise. I am pretty sure that I have followed the instructions to the letter (and done nothing else).
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
I just wish the author would contribute more to making the plugin work. I don't like modifying code as you lose it all the next time the code's updated.

It's such an almost-awesome plugin that it deserves to be brought up-to-date. ;-)

Last edited by:

Red5: Sep 30, 2006, 9:49 AM
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
This is the only code you should use:

Quote:


here is the perl file log.cgi

Code:

#!/usr/bin/perl
#================================
use strict;
use lib '/home/httpd/vhosts/magicdirectory.com/cgi-bin/admin';
use Links qw/$IN/;
Links::init('/home/httpd/vhosts/magicdirectory.com/cgi-bin/admin');
use Links::SiteHTML;
local $SIG{__DIE__} = \&Links::fatal;
main();
sub main {
#---------------------------------------------------
#
my $username = $IN->cookie('Community_Name') || $IN->param('Community_Name');
print $IN->header;
print Links::SiteHTML::display('include_login', {Username => $username});
}



If you use GCommunity, then make sure you have not renamed your session name under

Setup -> User Session -> session_cookie_name_user

If you do not use GCommunity, then "Community_Name" should be replaced with "s".

You should create a global, say, "login" OR "log" with this sub routine:

Code:

sub {
my $output;

if ($ENV{SCRIPT_NAME} =~ /nph-build/) {
$output = '<!--#exec cgi="/cgi-bin/log.cgi" -->';
}
else {
$output = Links::SiteHTML::display('include_login');

}
return $output;

}



<%log%>, which you can put in your include_header.html file, will now automatically check to see what kind of file it is loaded. This requires SSI, so your files must be built with .shtml extension. Remember to also check your cgi paths.

Last but not least, you must create an "include_login" template file with something like this:

Code:

<%if Username%>
[<a href='<%db_cgi_url%>/user.cgi?logout=1'>Sign Out</a>,
<a href='<%db_cgi_url%>/user.cgi'>My Account</a>]
<%else%>
<a href="<%db_cgi_url%>/user.cgi">Sign In</a>
<%endif%>



Although javascript can seem easier, it is run from the user end. I am just completly anti-javascript when there is no need for it.

Hope someone uses this,

- Jonathan
Quote Reply
Re: [jdgamble] Auth_vBulletin and Authentication In reply to
OK, I must be missing something here.... now it just prints out:


sub { my $output; if ($ENV{SCRIPT_NAME} =~ /nph-build/) { $output = ''; } else { $output = Links::SiteHTML::display('include_login'); } return $output; }


I presume that this means that it isn't being parsed as a script and is being presented as HTML instead. And yes, this is using .shtml pages.

Thanks for your patience and help with this

Last edited by:

swissbob: Sep 30, 2006, 9:55 AM
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
Did you copy that sub exactly under Build->Template Globals?

- Jonathan
Quote Reply
Re: [jdgamble] Auth_vBulletin and Authentication In reply to
Yes. It is there, and it is being included.... it just isn't being parsed as a script.

Last edited by:

swissbob: Sep 30, 2006, 10:42 AM
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
I have no idea, unless your doing something wrong. Under Build->Template Globals there should be something like this:




- Jonathan
Quote Reply
Re: [jdgamble] Auth_vBulletin and Authentication In reply to
Yes, it looks just like that
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
I have no idea!

Let me ask you. Is your problem that when you are logged into vBulletin and you go to Links, the login screen apears asking you to login again (like when you go to add.cgi etc.) or is the problem that Login is displayed instead of Logout. These sound like the same thing, but not. If your problem is more than just displaying Login / Logout at the right times, there is no point of even using my method.

- Jonathan
Quote Reply
Re: [jdgamble] Auth_vBulletin and Authentication In reply to
In Reply To:
I have no idea!

Let me ask you. Is your problem that when you are logged into vBulletin and you go to Links, the login screen apears asking you to login again (like when you go to add.cgi etc.) or is the problem that Login is displayed instead of Logout. These sound like the same thing, but not. If your problem is more than just displaying Login / Logout at the right times, there is no point of even using my method.

It is the same problem as Red - it is displaying the 'log in' message on the static pages, even if a user is logged in. On the dynamic pages, it shows the 'log out' message, as it should.

I don't think that this has any bearing on the problem of the global not being parsed as a script though?
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
I think that the reason it is displaying the code instead of executing it is because you have a space before sub.

so it should be "sub { whatever }" not " sub {whatever}".

- Jonathan
Quote Reply
Re: [jdgamble] Auth_vBulletin and Authentication In reply to
In Reply To:
I think that the reason it is displaying the code instead of executing it is because you have a space before sub.

so it should be "sub { whatever }" not " sub {whatever}".

I already spotted that one... I will keep fiddling with it and see if I can work out what is wrong.

Cheers.
Quote Reply
Re: [jdgamble] Auth_vBulletin and Authentication In reply to
Hi,

Having read your post a little closer I realise I was mistaken about it modifying the GLinks code. I've just implemented your code and it seems to work just fine. Thanks very much for the plugin! :-)

However, I have one concern. My server currently has EXEC CGI switched off, so this will not work:

<!--#exec cgi="/cgi-bin/log.cgi" -->

I've just read this: http://httpd.apache.org/...ml#executingcommands

Quote:
Note that this feature is exceedingly dangerous, as it will execute whatever code happens to be embedded in the exec tag. If you have any situation where users can edit content on your web pages, such as with a "guestbook'', for example, make sure that you have this feature disabled.

Is this something to be concerned about?
Quote Reply
Re: [Red5] Auth_vBulletin and Authentication In reply to
If it will allow you to execute it, it is perfectly safe.

I suppose if your server does not allow SSI, but does allow php, you could use a .phtml extension with:

<? include "/path/to/perlfile.cgi"; ?>

instead of

$output = '<!--#exec cgi="/cgi-bin/log.cgi" -->';

- Jonathan

Last edited by:

jdgamble: Sep 30, 2006, 1:21 PM
Quote Reply
Re: [jdgamble] Auth_vBulletin and Authentication In reply to
Thanks for your reply.

I know so little about CGI programming that I'm getting lost when I'm not following instructions. PHP is fine, and .phtml sounds interesting. Could you show me what the new version of the sub (and any other mods) might look like modified please? Sorry to be a pain! ;-)

Last edited by:

Red5: Sep 30, 2006, 2:36 PM
Quote Reply
Re: [Red5] Auth_vBulletin and Authentication In reply to
Everything else would be the same. The sub would look like this:

Code:

sub {
my $output;

if ($ENV{SCRIPT_NAME} =~ /nph-build/) {
$output = '<? virtual("/cgi-bin/log.cgi"); ?>';
}
else {
$output = Links::SiteHTML::display('include_login');

}
return $output;

}


I realized include wouldn't work for a script, so virtual will do. Goto Setup->Build Options and change your build_index and build extension to ".phtml" instead of ".shtml" or "html" and or "index.shtml" etc.

- Jonathan
Quote Reply
Re: [jdgamble] Auth_vBulletin and Authentication In reply to
Thanks for the help.

So, as I have an established directory, I'd need to use the .htaccess mod_rewrite function to serve .phtml files (via a 301 redirect) when the old .html files are requested. ;-)
Quote Reply
Re: [Red5] Auth_vBulletin and Authentication In reply to
I couldn't get this to work in the end, so I have removed it. Thanks for your assistance though.

I would still like some official feedback on whether the broken plugin will be fixed, since it is still listed in the plugin manager. Is there an update planned please?
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
 

In Reply To
OK, I must be missing something here.... now it just prints out:


sub { my $output; if ($ENV{SCRIPT_NAME} =~ /nph-build/) { $output = ''; } else { $output = Links::SiteHTML::display('include_login'); } return $output; }


I presume that this means that it isn't being parsed as a script and is being presented as HTML instead. And yes, this is using .shtml pages.[/reply]
The variable you placed in the include_header template should be parsed just like all the other variables in the template. This part shouldn't depend on whether the page is html, shtml, php or whatever. The only reason you would need .shtml files for this code to work would be to parse the <!--#exec cgi="/cgi-bin/log.cgi" --> SSI command.

I installed this plugin and, after some initial troubles, got it working. My main problem was that I had saved the new include_login template as "include_login" and not "include_login.html" (it gave me HTTP 500 errors). Once I changed that, it all worked fine.

I created a Template Global called 'log', and then used this code in the 'include_header.html' template:
Code:
<div id="logbar">
<%log%>
</div>

Of course, I also had to change the paths in the log.cgi file, and the path in the SSI command.

I hope that helps. :-)

Quote Reply
Re: [Red5] Auth_vBulletin and Authentication In reply to
Yup, I spotted those issues as well.

After more tweaking, it was hanging on the dynamic pages and producing nothing on the static pages (which was progress believe it or not). However, it isn't worth my time to spend another day on it, so I will perhaps come back to it later and try again from scratch.

In the mean time, I hope that GT will consider an update to it. *hint*
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
In Reply To:
In the mean time, I hope that GT will consider an update to it. *hint*

Indeed, because it doesn't really do much in its current state. It's such a great idea and it's so close to being awesome - it just needs updating. <hint>

:-)
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
In Reply To:
The problem is that the Auth_vBulletin plugin doesn't work with current versions of vBulletin - and that is what needs fixing really.
Just to clarify, I am using this plugin on a dynamic site running Links 3.2 and vB 3.6 and it works fine.

Sorry I can't be of more help in helping to fix the problem. I have moved away from static sites as they seemed to be less able to take advantage of the user functions when compared with dynamic sites.
Quote Reply
Re: [aus_dave] Auth_vBulletin and Authentication In reply to
In Reply To:
In Reply To:
The problem is that the Auth_vBulletin plugin doesn't work with current versions of vBulletin - and that is what needs fixing really.

Just to clarify, I am using this plugin on a dynamic site running Links 3.2 and vB 3.6 and it works fine.

Sorry I can't be of more help in helping to fix the problem. I have moved away from static sites as they seemed to be less able to take advantage of the user functions when compared with dynamic sites.

The problem is that I have nearly 600,000 links in the directory in 400,000 categories. I am not sure that the dynamic system is the best option - it could kill the server if Google did a full crawl. I might be wrong on that.

It does work on the dynamic pages, yes, but a lot of people buy Links because of its SEO friendliness.
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
If you use rewrite rules you can retain the search engine friendly aspects by making the dynamic URLs appear static even though they are not. If there are 600,000 detailed pages in your site it might actually be beneficial to server resources, as you remove the need to regularly rebuild each of the pages (a lot of which would be rarely looked at probably). Plus think of the disk space you will save :).

You are running a huge directory though, most of the Links sites I operate are much smaller. In any case, I was just clarifying that the plugin itself still works, but something in the core vB or Links code has probably changed.
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
Is there any chance that someone from GT can comment on this please and advise whether the mod will be fixed or not?

If not, I will completely uninstall it, rather than continue to use the embarrasing fudge that I have now that doesn't really work properly.
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
If you send me admin access and a user login, I can take a look at it. However, as aus_dave has mentioned, it does work.

Adrian
Quote Reply
Re: [brewt] Auth_vBulletin and Authentication In reply to
In Reply To:
However, as aus_dave has mentioned, it does work.


No, it doesn't! Smile It works for dynamic pages, but NOT for static pages - it always shows the user as logged out. Nor is it possible to log in through the Links 'log in' box (at least on mine).

Not much point in sending you a link I am afraid as I have currently removed all of the log in sections from the templates so that it can't tell the user that they aren't logged in (when they are). I will have to put them back in at some point and ask for some assistance then, thanks.
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
Whether or not the static pages show the user as being logged in or not is a completely cosmetic thing (it is only controlled via javascript, is not a 100% indicator of if they are logged in). That alone is not an indicator of whether or not the plugin is working.

Adrian
Quote Reply
Re: [brewt] Auth_vBulletin and Authentication In reply to
In Reply To:
Whether or not the static pages show the user as being logged in or not is a completely cosmetic thing (it is only controlled via javascript, is not a 100% indicator of if they are logged in). That alone is not an indicator of whether or not the plugin is working.

Huh? So if they are logged in and the static pages alway tells them they are logged out, but the dynamic ones tell them they are logged in, you think that is working? It may be 'cosmetic' but it makes the plugin a nightmare, and it is BROKEN. Also, users can't log in through Links on mine - even if I use exactly the same details on the vBulletin log in. Nor does the registration via Links appear to work properly.

You shouldn't be offering it as a mod if it doesn't work properly.

Surely if it is just cosmetic, it won't be hard to fix or offer a patch solution? Please? Smile
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
You could use SSI

<!--#include virtual="/vb.php"-->

my vb.php is something like this.

Code:

<?php
chdir("path/to/forum");
require('../forum/global.php');
include('../forum/includes/functions_user.php');

// user logged in
if ($vbulletin->userinfo['userid'])
{
echo "<a href=/forum/login.php?$session[sessionurl]do=logout&amp;logouthash=$logouthash";
echo $vbulletin->userinfo['logouthash'];
echo ">";
echo " Log Out";
echo "</a>";
}

// user logged out
if ($vbulletin->userinfo['userid'] == '')
{
print '<a href="/forum/register.php" rel="nofollow">Register</A>';
if ($vbulletin->userinfo['userid'] == 0)
{
echo "<a href=\"/cgi-bin/dir/user.cgi?url=" . $_SERVER['REQUEST_URI'] . "\" rel=\"nofollow\">Login</a>";
}
}
?>

Last edited by:

garrynz: Nov 19, 2006, 2:03 AM
Quote Reply
Re: [garrynz] Auth_vBulletin and Authentication In reply to
In Reply To:
You could use SSI

<!--#include virtual="/vb.php"-->

my vb.php is something like this.

Code:

<?php
chdir("path/to/forum");
require('../forum/global.php');
include('../forum/includes/functions_user.php');

// user logged in
if ($vbulletin->userinfo['userid'])
{
echo "<a href=/forum/login.php?$session[sessionurl]do=logout&amp;logouthash=$logouthash";
echo $vbulletin->userinfo['logouthash'];
echo ">";
echo " Log Out";
echo "</a>";
}

// user logged out
if ($vbulletin->userinfo['userid'] == '')
{
print '<a href="/forum/register.php" rel="nofollow">Register</A>';
if ($vbulletin->userinfo['userid'] == 0)
{
echo "<a href=\"/cgi-bin/dir/user.cgi?url=" . $_SERVER['REQUEST_URI'] . "\" rel=\"nofollow\">Login</a>";
}
}
?>

That looks great. I will give it a go when I get back from the pub Crazy Wink

Thanks.
Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
In Reply To:
Also, users can't log in through Links on mine - even if I use exactly the same details on the vBulletin log in. Nor does the registration via Links appear to work properly.
This plugin allows you to use the vBulletin authentication code instead of the in-built Links code. This means that you can only register using the vBulletin side, not the Links side.

The same applies for logging in. You can provide a login form in the Links part of the site, but the form needs to post the data to /forums/login.php (or wherever you have vB installed). It's easiest to cut and paste the login box from vBulletin into Links and modify the styles etc.

If I understand you correctly you are still having problems even though you are doing things as explained above. I am happy to have a quick look at your site if you want to PM me a URL.

One of my Links sites uses a modified version of this plugin to integrate very tightly with vBulletin, including areas like the newsletter subscription. For the most part it works pretty well and gives users a seamless transition between each part of the site Smile.
Quote Reply
Re: [aus_dave] Auth_vBulletin and Authentication In reply to
Hmm, I can't seem to get this to work. I have the php file included and working. I don't get any error messages, so the include files are being found. BUT the 'userid' is always returned as '0'... so I get the 'Login' message every time.

Any idea what might be causing this please? I have checked that the username is registered and appears in the Admin section. The dynamic pages are still working just fine and showing the user as logged in.

Any ideas?

Code:
chdir("path/to/forum");
require('../forum/global.php');
include('../forum/includes/functions_user.php');

// user logged in
if ($vbulletin->userinfo['userid'])
{
echo "<a href=/forum/login.php?$session[sessionurl]do=logout&amp;logouthash=$logouthash";
echo $vbulletin->userinfo['logouthash'];
echo ">";
echo " Log Out";
echo "</a>";
}


Quote Reply
Re: [swissbob] Auth_vBulletin and Authentication In reply to
I worked out the problem. I needed to place the 'require' part of your code at the top of the page before any cookies are sent. Once the php had been moved, it worked just fine.

This involved changing all of the templates for the static HTML pages.