PDA

View Full Version : Using vBulletin Cookies Outside the Fourms


thorin
07-09-2002, 07:40 PM
I want to use the login cookie method for security outside of my forums area. What do I need to have in my files to make this happen? I am running in 100% php so this should be a pretty simple one for you guru's.

Here are the details:

The forums are located in a directory below the main site: "http://www.site.com/users/forums"
I want a login prompt at "http://www.site.com" and then proceed to "/users" once they have logged in using the vubulletin user db.

Neo
07-09-2002, 07:49 PM
I dont thing so. Unless you set up a multi domain cookie but it could be very un-secure.

thorin
07-09-2002, 08:02 PM
It is all ONE domain.

http://www.site.com
"/users" and "/users/forums" are all directories below "site.com"

Logician
07-09-2002, 09:12 PM
I want to use the login cookie method for security outside of my forums area.
cookies are neither good nor sufficient tools for security. What if user disabled cookies in vb settings or in his browser settings?

If you need to secure your non-vb pages according to vb user/usergroup info, give WebTemplates hack a shot.

thorin
07-09-2002, 09:41 PM
WOW man, nice work, but its a lot more than I need. Do you have a stripped down script to do this? I don't need to be able to edit the pages and that from the forums, just the login prompt if they haven't logged in already.

Logician
07-10-2002, 05:38 AM
I dont have a "light" version but I think it's not necessary either. I know the hack seems complicated but in fact it is not. After installation, all you have to do is to click ADD WEBTEMPLATE button, give it a name and copy/paste your non-vb page's source code inside it. Then put 0 1 3 tag inside your webtemplate and you are done.

Now only your registered members (who also verified his email) can see your webtemplate, if he is not a member or he is a logged off member, webtemplate will automatically display him the login/register screen.

So it is really very easy to use..

thorin
07-10-2002, 06:17 PM
hmm, do you have a working example of this somewhere I can see, I don't quite understand how the template is incorporated into my php files. I have 3 files per page, one is the header inculude, the other is the footer include and then the contents. so would the pages become dynamic?

Logician
07-10-2002, 08:29 PM
You tell me what do you have in your PHP file (content) and I'll tell you if you can convert it to a webtemplate.

Webtemplate hack comes with 2 default webtemplates "header" and "footer". You can customize them as you like then you add $header and $footer variables into your other webtemplates to include headers and footers to them.

As for the content page: If it is a static HTML page, all you have to do is to copy/paste its source code and now it becomes a webtemplate. Of course it's address changes: you now call it as yourboardurl/show.php?pg=yourtemplatename

If it's a dynamic PHP page which makes queries to MYSQL and get/post results on the fly, you can convert most of your queries to "webqueries" and insert into your webtemplates. For example if you have a query to list last 10 registered users of your board in your PHP file, you create a webquery named "_last10users", form the SELECT code and then insert "$_last10users" variable in any place in your webtemplate and while it's parsed it will retrieve data from MYSQL and automatically list the last 10 users.

But if your PHP does more than that (eg. gets/list 10 item from db, then puts a link to get 10 more) you may not do it with the hack.

There are some screenshots in the hack thread. If you want more, tell me what screenshot you exactly want.

thorin
07-10-2002, 08:56 PM
All the content is plain html, nothing fancy, I would like to get more in there as far as dynamics (how many people on the board, hot threads and last thread, newest member....etc) but that will come later, but I am thinking this will do it all, I am just a little warry about how it will work out, I don't have time to be a php programmer, but enough time to make it work the first time, its a tuff mulit-hat job I have.

thorin
07-10-2002, 08:57 PM
so a page url would look like "site.com/index.php?pagename"

Logician
07-10-2002, 09:13 PM
If it is plain HTML, it is VERY EASY to convert it to a webtemplate as I mentioned above. Just copy/paste its source code to a new webtemplate in your Admin CP and add the [cantsee] tag I mentioned above, you are done.

Now call it as www.yoursite.com/yourboard/show.php?pg=name_of_yourtemplate and here it is: If the visitor is a guest/unlogged member he will get please login/register to view this page message and if he is a logged-in user he will display your page. Very simple..

thorin
07-10-2002, 09:46 PM
so in the "mysite.com/index.php" file it would simply have the include like this? "show.php?pagename"

This is going to make nested php files? I am using windows2k and IIS, so I am stuck in CGI-ville...what's that gonna do to my perfomance?

thorin
07-10-2002, 09:48 PM
I would also REALLY like to see this working somewhere...I want to get a feel for it.

Logician
07-10-2002, 10:05 PM
so in the "mysite.com/index.php" file it would simply have the include like this? "show.php?pagename"
You dont need to include it, just link it from other pages, that's all.

To load it, call it from your browser address bar as "url/board/show.php?pg=templatename"

I would also REALLY like to see this working somewhere...I want to get a feel for it.

Here is a test template for you:

http://www.turkhukuksitesi.com/hukukforum/show.php?pg=testtemplate

However you cant feel it, because it's meaningless if you are a guest. You would feel it if you visited that template with different vb usernames to see dynamic content. Screenshots in the hack thread demonstrate it better. But you insisted so here you are..

And here is another template which is open to only Site Admin usergroup. Test it to see how hack forbids you from displaying the page if you dont have the permission:
http://www.turkhukuksitesi.com/hukukforum/show.php?pg=whoareyou

My 2 cents: Hack is not a pain to install. It will take you less than 15 minutes to install so give it a try and if it doesnt work, uninstall and forget it. You'll have the best feeling by trying it..

As for performance issues, hack thread has lots of information..

thorin
07-10-2002, 11:27 PM
just a quick question, this may sound dumb, but I wanna have my bases covered...in your instructions, you seperate things with "CUT" does this just signify the end of the instruction and the start of the code or does it mean to find that and cut it out of the file and then replace w/ your code? there needs to be some claification there for sure...

thorin
07-11-2002, 12:41 AM
ok, I think I got everything in right, I left the code that you said to find, in....but when I got to run the "webtemplates_install.php" nothing happens...it just goes to this URL w/ the same page conents as the first page....

/forums/webtemplates_install.php?p=1

I click the link and it loads the same page w/ the same URL...I looked in code and I know its not supposed to look like that, obviously :)

thorin
07-11-2002, 01:20 AM
here is what I have in the webtemplates_install.php

$servername='localhost';

## Username and password to log onto your MYSQL database server
## Remember: this username and password will be used when connecting to MYSQL database.
$dbusername='root'; //MYSQL username
$dbpassword=''; //MYSQL password

## Name of the MYSQL database where your vbdata is.
$dbname='vbulletin';

Logician
07-11-2002, 06:01 AM
thorin you need to edit this info to point your server/MYSQL username/password/databasename before running the script

and the CUT only points the begining and ending points, you dont need to delete the part unless it's obviously asked like "REPLACE it"

thorin
07-11-2002, 11:11 PM
Those are my correct settings, notice that the 'pass' is gone from the pasword string value?

Logician
07-12-2002, 05:17 AM
can you give me the URL to webtemplates_install.php (you can pm), let me see it..