Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Need help with plugin (starting with SSI) - Auth_vBulletin

(Page 1 of 2)
> >
Quote Reply
Need help with plugin (starting with SSI) - Auth_vBulletin
Hello everyone!

I have Gossamer Links SQL 2.1.0 & vBulletin 3.8.0 and have been pulling my hair out trying to make the logging process work. I am close to solving the problem, but need some help as I am not the best programmer. There were two solutions presented, and I got stuck in both. Here's how far I got in each scenario:

1) http://www.gossamer-threads.com/...?post=291684;#291684 -> I followed garrynz's instructions, and what happens is when I try to log in, it just goes to vBulletin's login_links.php page and stays there. The page is also completely empty. However, if I manually go back to Gossamer's add.cgi page, I'm now logged in. This means everything except the redirecting part works.

2) http://www.gossamer-threads.com/...?post=291523;#291523 -> I followed aus_dave's instructions, and I am having the exact same problem that Evoir had, where vBulletin logs me in, then goes back to Gossamer's login page, where I'm supposedly still not logged in. However, if I manually go back to Gossamer's add.cgi page, I'm now logged in, just like the first scenario above. This means everything works, except now I get redirected to an incorrect place.

I believe I followed all the instructions correctly, EXCEPT the following which mentions SSI that I couldn't fully understand: http://www.gossamer-threads.com/...?post=294977;#294977 -> Can someone please give me more details on what I need to do? Here's what I did:

"<!--#include virtual="/vb.php"-->" -> I thought I was supposed to put this within the login.html template, but after I did that and tested it out, when I view the source of the actual login page, the "<!--#include virtual="/vb.php"-->" part still shows as is. I presume that this means that it isn't being parsed as a script and is being presented as HTML instead. Also, I put the vb.php in the same directory as the add.cgi file.

I think I'm missing something simple here, so any help is greatly appreciated. If someone can point me in the right direction (especially regarding the SSI issue), I might be able to solve the rest myself. Thank you in advance!

Last edited by:

V.E.C.T.O.R.: May 12, 2009, 9:35 PM
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
Well I've made a bit of progress: I found out that my server can process .shtml files for ssi, but .html files cannot. So I edited Gossamer's login.html template file used by add.cgi and other files and save it into and new file, login.shtml. Now what I can't figure out is, how do I make add.cgi and other files use login.shtml instead of login.html? Please help, thank you.
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
Am not fully aware of your issue, however if you are mainly having problem with using ssi on .html page, than you can try adding below lines in .htaccess file and your .html files should be able to process ssi codes.

AddType text/html .html
AddHandler server-parsed .html
AddHandler server-parsed .htm

Hope this helps.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
Hi Vishal, thanks for your advice. It didn't solve my problem per se, but at least taught me something new AND confirmed that there must be something else that I'm doing wrong. So far the new progress I've made today is:

I know now that I can use .html files to process ssi after creating a test file and seeing how it works. I also got curious as to how an html file can process a php file inside an ssi code, so made a test.html file that has the following code: "<!--#include virtual="/vb.php"-->"

When I went online to look at the result, it says: "[an error occurred while processing this directive]"

Well whatever that means, it means the ssi works with .html files, yay! So anyway, since I now know that the add.cgi file can use the login.html template to process the "<!--#include virtual="/vb.php"-->" part, I tested it out but when I view the source of the actual login page, the "<!--#include virtual="/vb.php"-->" part STILL shows as is.

So what the hell am I missing here? Please help, thank you.
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
If you want to add .php in a html file, add below line in your .htaccess file

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

p.s. Remember to remove
Code:
AddType text/html .html
AddHandler server-parsed .html
AddHandler server-parsed .htm
otherwise it will only give error. Cuz as far as I know, you can use ssi and php tags in .html with just this .htaccess modification.

However if you have pages named as .shtml already (so they process ssi code anyway), than you can use simple tags like <!--#include virtual="/test.php"--> and it should process php just fine.
p.s.s.. been a while I tested, this, so let me know if you use this method and php in .shtml page works out.

Hope this helps.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
Thanks again Vishal, it works, although now I'm getting those damn 500 internal server error messages. I tested it out, and found that I get them for .php files ONLY WITHIN the Gossamer Links directories (meaning both within the cgi-bin & static directories), so I'm gonna look into that now and will post what I find out about it. When am I gonna solve my neverending problems I wonder? Unsure
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
Glad that bit worked for you. However, I have never touched the vBulletin plugin for GLinks - so can't help you with its installation.

Hope it works out for you.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
Wow, I fixed the 500 internal server error!!! What happened was, in my old server I swear I had to chmod the static links directory to 777 to make it work. However, after testing out virtually every possible scenario, in this new server I had to chmod it back to the default, 755. So I hope this helps someone. Anyway, it's getting late so I'll go back to applying what you've helped me with so far Vishal to solve my original problem, and then post any more progress I make tomorrow hopefully...
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
Hi Vishal, I've made a HUGE progress over this weekend so far, as I've solved most of my own problems, with indirect help & inspiration from great people such as yourself! I'll post exactly what I did after I attack more on this .php ssi thing within .html files to see if it takes care of everything after I took care of the 500 internal server error messages...
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
All right, I've finally solved my original problem of integrating Gossamer Links w/ vBulletin 3.8.0. Here's exactly what I did, for anyone else having problems:

1) I went to the homepage (index.php) in vBulletin, and copied the entire login form, as follows:

<!-- login form -->
<form action="login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)">
<script type="text/javascript" src="clientscript/vbulletin_md5.js?v=380"></script>
<table cellpadding="0" cellspacing="3" border="0">
<tr>
<td class="smallfont" style="white-space: nowrap;"><label for="navbar_username">User Name</label></td>
<td><input type="text" class="bginput" style="font-size: 11px" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="User Name" onfocus="if (this.value == 'User Name') this.value = '';" /></td>
<td class="smallfont" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="103" id="cb_cookieuser_navbar" accesskey="c" />Remember Me?</label></td>
</tr>
<tr>
<td class="smallfont"><label for="navbar_password">Password</label></td>
<td><input type="password" class="bginput" style="font-size: 11px" name="vb_login_password" id="navbar_password" size="10" tabindex="102" /></td>
<td><input type="submit" class="button" value="Log in" tabindex="104" title="Enter your username and password in the boxes provided to login, or click the 'register' button to create a profile for yourself." accesskey="s" /></td>
</tr>
</table>
<input type="hidden" name="s" value="" />
<input type="hidden" name="securitytoken" value="guest" />
<input type="hidden" name="do" value="login" />
<input type="hidden" name="vb_login_md5password" />
<input type="hidden" name="vb_login_md5password_utf" />
</form>
<!-- / login form -->

2) I added the following to the above code:

<input type="hidden" name="forceredirect" value="1" />
<input type="hidden" name="url" value="<%url%>" />

3) Add the above pieces of code into the login.html template.

That's it! Forget about all the other stuff mentioned throughout this website, because the above works 100%, plain and simple.

Last edited by:

V.E.C.T.O.R.: May 23, 2009, 11:08 PM
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
After I got the login problem solved, I worked on getting to show whether a user was logged in or out by creating an "include_login" template file with the following piece of 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%>

All code mentioned above that solved my two main problems were found in the links mentioned in my original post all the way at the top, so thanks to those initial posters.
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
So now I'm at a point where if I can solve just two more problems, I would be fully done with integration of Gossamer Links with vBulletin 3.8.0. Here it is:

In my post right above, the logout code must actually be something like the following to correctly log out:

<a href="http://www.mysite.com/vbulletin/login.php?do=logout&logouthash=<? echo $logouthash; ?>">Log Out</a>

The $logouthash variable would come from the following code taken from vBulletin:
$logouthash = $vbulletin->userinfo['logouthash'];

My entire website is built in php code, so the above code works fine outside of the vbulletin directory, except within Gossamer Links pages, such as:
http://www.mysite.com/cgi-bin/links/add.cgi -> This is the "impossible to solve" question...
http://www.mysite.com/links/index.php -> The answer lies in the following post: http://www.gossamer-threads.com/...?post=291684;#291684 which I still need to dig deeper to see if I can figure it out on my own or if I need more help to solve...

So a long story short, how do I extract a variable from a php part of the website into a cgi part of the website? This is simply said than done, but I'm sure the answer will be simpler than I think, just like how my original problems were solved using simple pieces of code, and I'm sure some of those who have already integrated their versions of vBulletin with Gossamer Links must have figured the above out somehow if they want their members to log out as well as log in correctly. Any help with my final problem will be greatly appreciated. Thank you!

Last edited by:

V.E.C.T.O.R.: May 24, 2009, 12:22 AM
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
For Vishal and whoever else that might know the answer to one of my final problems, here's what I did so far (and I'm a novice in regards to .htaccess & ssi, so the following is written in detail to make sure there's nothing I did wrong outside of the usual):

I created a test.txt file, and included the following code, per Vishal's advice:

AddType text/html .html
AddHandler server-parsed .html
AddHandler server-parsed .htm

Then I uploaded the file, and renamed it to .htaccess. I then made a test.html file that has the following code: "<!--#include virtual="/vb.php"-->", and when I went online to look at the result, it says: "[an error occurred while processing this directive]", which means it at least does parse the code. I'll have to dig more into this to figure out how to parse .php files correctly within the static pages of Gossamer Links. I'll post more if I figure this out or if I need more help on this part...

Then again per Vishal's advice, I changed the .htaccess file to have just the following code to see if it'll parse .php files correctly:

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

Initially I got the 500 internal server error messages and got sidetracked, but after solving that problem, I am confirming that the above code does NOT work, meaning after testing out the test.html file with the code: "<!--#include virtual="/vb.php"-->", and when I went online to look at the result, it says: "<!--#include virtual="/vb.php"-->", which means it doesn't parse the code but just shows it as is.

So anyway, I tested both versions of the .htaccess files above in conjunction with the "include_login" template I created above, and I am confirming that none of them work, meaning pages such as http://www.mysite.com/cgi-bin/links/add.cgi that I changed to make it use the template show "<!--#include virtual="/vb.php"-->" as is, not parsed no matter what .htaccess file I use. I was not surprised after I just found and read the following post from Vishal a while back: http://www.gossamer-threads.com/...?post=297259;#297259

I didn't fully understand Vishal's post above, so have I missed something or is there absolutely no way to do this?
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
Ok, now I am really down to the final problem, as I just solved one of my last two problems, the easier one. Using Vishal's post (http://www.gossamer-threads.com/...?post=297259;#297259), I split a header template file into two separate ones (one for the php files & another for cgi files), and solved the login issue for the php files. Stupid me originally thought I needed help on using ssi on the .html files, forgetting that the static pages created by Gossamer Links would actually be .php files. Anyway, it's all done except for that real final question: How do I extract a variable from a php part of the website into a cgi part of the website? After everything that I've read so far, I'm not even sure if it's possible, but if it is that would be absolutely incredible, especially since I've solved every other problem I had before. Can anyone help me please? Thanks in advance!
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
To those who have the skills to take a stab at my ultimate problem, I googled using some keywords such as "extract variable php cgi" and found some people who claim that it can be done, including the following website:

http://www.dev411.com/...ing_PHP::Interpreter

I'm having a hard time understanding where to start, but maybe someone can help me? Thanks in advance.
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
Are you just looking to have the logouthash in the Links pages? It's easy enough to get this using a global like so, call it vb_logouthash:
Code:
sub {
my $user = 'yourDBusername';
my $pass = 'yourDBpassword';
my $host = 'localhost';
my $db = 'yourBname';
my $vb_id = $USER->{vbID};
my $query = qq{SELECT salt FROM user WHERE userid='$vb_id'};
my $dbh = DBI->connect ("DBI:mysql:host=$host;database=$db",$user, $pass,{ PrintError => 1, RaiseError => 1 } )
|| die "ERROR: Can't connect";
my $sth = $dbh->prepare($query) || die("$DBI::errstr");
$sth->execute();
my $usersalt = $sth->fetchrow;
use Digest::SHA1 qw(sha1_hex);
my $logouthash = sha1_hex($vb_id . sha1_hex($usersalt) . sha1_hex('Your VB license number'));
$logouthash ? return $logouthash : return '0';
}

You need to add a column to the User table to store the user ID from vBulletin - you can find it dynamically by looking up the username but we use the vbID in Links a lot so we added that field. It's a simple modification to the Auth_vBulletin plugin to insert this value when the user is created (let me know if you need the code).

To construct a logout link, do something like the following:

Code:
<a href="/forums/login.php?do=logout&amp;logouthash=<%vb_logouthash%>">Logout</a>
Quote Reply
Re: [aus_dave] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
aus_dave wrote:
You need to add a column to the User table to store the user ID from vBulletin - you can find it dynamically by looking up the username but we use the vbID in Links a lot so we added that field. It's a simple modification to the Auth_vBulletin plugin to insert this value when the user is created (let me know if you need the code).

Hi aus_dave! Thank you so much for your quick reply. While I try to figure out how to apply your code (if you look at my posts above you can see I'm not the best in understanding and figuring out other people's instructions), can you please provide the code for the modification of the Auth_vBulletin plugin? And in the meanwhile I'll post the results here as soon as I make progress. Thanks again, and yes all i need to do at this point is have the logouthash in the dynamic Links pages, as I figured out how to show it in the static php pages.
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
Find the auth_get_user sub and replace it with the code below - the plugin on our site is modified a lot more than this but I've extracted just the part you need to get the vBulletin ID added to the User table.

Code:
sub auth_get_user {
# -------------------------------------------------------------------
# This function returns a user with Links SQL info. You should modify
# this code if you also want access to the vBulletin information.
#
my $args = shift;
GT::Plugins->action(STOP); # Make sure we don't run the main code.

my $user_db = $DB->table('Users');
my $user = $user_db->get($args->{Username});
if (! $user) {
$user->{Username} = $args->{Username};
$user->{Password} = ' ';
my $sth = $AUTH_DBH->prepare('SELECT email FROM ' . $VB_CFG->{tableprefix} . 'user WHERE username = ?');
$sth->execute($args->{Username});

my ($email) = $sth->fetchrow_array;
my $sth = $AUTH_DBH->prepare('SELECT userid FROM ' . $VB_CFG->{tableprefix} . 'user WHERE username = ?');
$sth->execute($args->{Username});

my ($id) = $sth->fetchrow_array;

$user->{vbID} = $id;
$user->{Email} = $email;
$user->{Name} = '';
$user->{ReceiveMail} = 'No';
$user->{Status} = 'Registered';

my $defaults = $user_db->default();
foreach (keys %$defaults) {
$user->{$_} = $defaults->{$_} unless (exists $user->{$_});
}
$user_db->insert($user) or Links::fatal("Unable to auto-create user: $args->{Username}. Reason: $GT::SQL::error");
}
return $user;
}

You will also need to add a new INT field to the User table, call it vbID and it should work fine.
Quote Reply
Re: [aus_dave] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
All right aus_dave, thanks again for your super-fast reply. I'll post here as soon as I see any progress. Wish me luck! :D

Last edited by:

V.E.C.T.O.R.: May 25, 2009, 7:22 PM
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
Hi aus_dave!

I think it's working!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I gotta test it out a bit more before I go too crazy, but just thought I'd let you know immediately whether it works or not, and so far it does. I'll post more (including something else regarding the login procedure that I just noticed) after I finish up on fully documenting what I did. THANKS SO MUCH, YOU'RE A GENIUS!!! :D
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
Hi aus_dave!

I guess I got too excited a bit early lol. Anyway, it's working but not 100% yet. There are two things that are not happening correctly:

1) I created two test accounts to make sure of this, but no matter what the new vbID field is always "0" when I log into Links with the new usernames.
2) So I manually changed those fields to the correct numbers, and the logouthash variable gets extracted, but the numbers don't match the correct numbers, so I get an error when trying to log out. Specifically, the correct numbers have a format that is something like "xxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", and the incorrect numbers have a format that is something like "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", and I can't see any matching patterns, so something is wrong I think.

Any idea what's going on? While I await your answer, I'm gonna go back and triple-check that I didn't do anything wrong myself...
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
Ok, a quick update. I got curious, so hard-coded the following:

$user->{vbID} = '10';

Then created another test account, logged into Links, and the vbID field is STILL "0"?!?

What I originally did was download the Auth_vBulletin.pm file from the Plugins directory, open it with Wordpad, edit it, and re-upload it, making sure to overwrite the original file. After confirming that the number was still "0", I did it again, this time deleting the original file in the Plugins directory to make sure I uploaded the edited version since maybe before the overwriting didn't work or whatever. It's still "0", so for whatever reason Links is still somehow using the original file. Now how is this possible? Did I miss a step?

Last edited by:

V.E.C.T.O.R.: May 26, 2009, 1:24 PM
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
Ok, another quick update. I found out the vBulletin code to get the logouthash:

$user['securitytoken_raw'] = sha1($user['userid'] . sha1($user['salt']) . sha1(COOKIE_SALT));
$user['securitytoken'] = TIMENOW . '-' . sha1(TIMENOW . $user['securitytoken_raw']);
$user['logouthash'] =& $user['securitytoken'];

TIMENOW is supposed to be the current time in UNIX time, so I got to the following:

my $logouthash = time . '-' . sha1_hex(time . $vb_id . sha1_hex($usersalt) . sha1_hex('My VB license number'));

So now the logouthash looks like it shows up in correct format, but it still doesn't work. Maybe the current time in UNIX time in perl is not "time"? I'm gonna look further into what else I might've done wrong. I think I'm getting closer to a solution... :D

Last edited by:

V.E.C.T.O.R.: May 26, 2009, 2:29 PM
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
Wait, I think I'm onto something here. Just in case you're here aus_dave, don't bother doing anything more until I post more progress. I think I know what happened and should be able to figure this out on my own very soon. I'll be back (oh by the way, Terminator Salvation was awesome hehe)!

Last edited by:

V.E.C.T.O.R.: May 26, 2009, 8:41 PM
Quote Reply
Re: [V.E.C.T.O.R.] Need help with plugin (starting with SSI) - Auth_vBulletin In reply to
All right, it's what I thought. The correct code should've been:

my $logouthash = time . '-' . sha1_hex(time . sha1_hex($vb_id . sha1_hex($usersalt) . sha1_hex('My VB license number')));

So now I think I'm REALLY up to my final problem, although now I can see that I can just edit my logouthash so that I don't even need the $vb_id. To satisfy my curiosity, I'll quote the exact problem:

V.E.C.T.O.R. wrote:
Ok, a quick update. I got curious, so hard-coded the following:

$user->{vbID} = '10';

Then created another test account, logged into Links, and the vbID field is STILL "0"?!?

What I originally did was download the Auth_vBulletin.pm file from the Plugins directory, open it with Wordpad, edit it, and re-upload it, making sure to overwrite the original file. After confirming that the number was still "0", I did it again, this time deleting the original file in the Plugins directory to make sure I uploaded the edited version since maybe before the overwriting didn't work or whatever. It's still "0", so for whatever reason Links is still somehow using the original file. Now how is this possible? Did I miss a step?


So yeah, like how do I edit a plugin and make Links USE the edited plugin instead of the original one? After all I've been through, this one's GOTTA be a simple one to solve? :D

Last edited by:

V.E.C.T.O.R.: May 26, 2009, 9:19 PM
> >