vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Simple vB User login and access control on non vB pages (https://vborg.vbsupport.ru/showthread.php?t=100992)

Billspaintball 06-22-2006 05:11 AM

Quote:

Originally Posted by Majava
Do i need to put that still in everypage? or just the index page?
.

If everything is just included into the index page thats the only spot you would need to put it.

You can post the index page code if you like and I will have a look for anything obvious.

Majava 06-22-2006 08:58 AM

This is at the top
PHP Code:

<?php
   chdir
('/path/to/forum'); 
   require_once(
'/path/to/forum/global.php');  

    
// Do not edit anything below this line
    // Do not edit anything below this line
    
session_start();

    
// You can now edit below this line
    // You can now edit below this line
?>

PHP Code:

            <?php
            $page 
$_GET['page'];
            
            if ((
$page == "news") || ($page == "status") || ($page == "armour") || 
                (
$page == "protector") || ($page == "garment") || ($page == "swords") || 
                (
$page == "blades") || ($page == "spears") || ($page == "glaives") || 
                (
$page == "bow") || ($page == "jewlery") || ($page == "accesories") || 
                (
$page == "skills") || ($page == "guides") || ($page == "guilds") || 
                (
$page == "quests") || ($page == "maps") || ($page == "faq") || 
                (
$page == "movies") || ($page == "screenshots") || ($page == "pictures") || 
                (
$page == "wallpapers") || ($page == "art") || ($page == "downloads") || 
                (
$page == "links") || ($page == "contact") || ($page == "jobs") || 
                (
$page == "irc") || ($page == "main") || ($page == "potions") ||
                (
$page == "scrolls") || ($page == "thanks") || ($page == "error_job") ||
                (
$page == "explist") || ($page == "mailthanks") || ($page == "register") ||
                (
$page == "lostpw")) {
    
                include(
"includes/".$page.".php");     
            } else if (
$page == "") {
                include(
"includes/main.php");
            } else {        
//                include("includes/broken.php"); 
            
}     
            
?>

This is my main code

Billspaintball 06-23-2006 03:14 AM

[QUOTE=Majava]This is at the top
PHP Code:

<?php
   chdir
('/path/to/forum'); 
   require_once(
'/path/to/forum/global.php');  

    
// Do not edit anything below this line
    // Do not edit anything below this line
    
session_start();

    
// You can now edit below this line
    // You can now edit below this line
?>

Try something like

PHP Code:

<?php  
session_start
();
$curdir getcwd (); 
chdir('/path/to/your/forums');     
require_once(
'/path/to/your/forums/global.php');  
chdir ($curdir); 
?>

If that fails to work then it looks like both scripts are just incompatible :(

Dark s.s. Trunk 06-24-2006 09:07 AM

I have a strange problem lol i seem to be permittly logged in. Now on my forums when i log off and go to main forum page it shows me as logged in, and on the page i put the code i hit log out goes to forums cookies cleared aand all but when it goes back to page still logged in,, even cleared IE cashe and still does it
----------------
Edit: that problem was bad cashe in IE but now ran into another problem, i have 2 php files i use one has a bit different b/c of the way i display some pages but works perfect on mainpage.php but any file that seems to use my mainpage2.php it goes to log in but keeps telling me to log in but still logged in on mainpage.php.. all ode for login exact same.

Note seems pages dun work on anything linked to in the address bar like thsi http://twistedeffects.com/mainpage.p...iles/tutorials

hurry 06-25-2006 10:28 AM

Quote:

Originally Posted by AutoXer
I fixed it. Here's how:

AdminCP -> vBulletin Options -> Cookies and HTTP Header Options -> Path to Save Cookies

I changed the 'Suggested Settings' dropdown from '/forums/' to '/'

I did this but it still does not work for me and gives me the forum logged in screen and then again returns back to the page without being logged in. Please help.

Billspaintball 06-27-2006 10:59 PM

Quote:

Originally Posted by Dark s.s. Trunk
Note seems pages dun work on anything linked to in the address bar like thsi http://twistedeffects.com/mainpage.p...iles/tutorials

I dont quite understand what you mean here.
What part of the login does not work exactly?

Billspaintball 06-27-2006 11:04 PM

Quote:

Originally Posted by hurry
I did this but it still does not work for me and gives me the forum logged in screen and then again returns back to the page without being logged in. Please help.

I need a bit more detail than this please.

Billspaintball 07-14-2006 05:02 AM

Updated instructions with a change that may allow cross domain login to work.

lightnb 07-14-2006 12:29 PM

I'm having an issue where including global.php causes my main script to stop functioning.

I've commented out your code, line by line to locate the problem, and my script works until I allow global.php to be called.

At that point, all of the links on the page stop working (the login box works fine).

It is a search results page, and the links are in this format:

PHP Code:

<a href="<?=$PHP_SELF?>?query=<?=$query?>&page=<?=$page?>&limit=5">5</a>

Any idea why global.php interferes with the functionality of these links?

Thanks,

Nick

Paris Holley 07-20-2006 03:48 PM

does not work in 3.6 rc2, including global.php causes scripts to become unresponsive

*nvm*

was a cookie conflict

Billspaintball 07-20-2006 09:50 PM

Quote:

Originally Posted by Paris Holley
does not work in 3.6 rc2, including global.php causes scripts to become unresponsive

*nvm*

was a cookie conflict

You had me worried. :eek:
I went and upgraded my test site to 3.6 rc2 straight away.
All still running fine on rc 2 :D

Billspaintball 07-20-2006 09:54 PM

Quote:

Originally Posted by lightnb
I'm having an issue where including global.php causes my main script to stop functioning.

I've commented out your code, line by line to locate the problem, and my script works until I allow global.php to be called.

At that point, all of the links on the page stop working (the login box works fine).

It is a search results page, and the links are in this format:

PHP Code:

<a href="<?=$PHP_SELF?>?query=<?=$query?>&page=<?=$page?>&limit=5">5</a>

Any idea why global.php interferes with the functionality of these links?

Thanks,

Nick

Global may be using the variables $query and/or $page.
Put a simple echo statement on your page to see if those values are what you expect them to be.

Evoir 08-01-2006 12:35 AM

Billspaintball, First, thanks for writing this script and giving everyone a hand with it. I'm hoping that you can help me figure out what's going on.... I am unable to get it to work. I've read the troubleshooting guide and tried everything, and read all 12 pages of this thread. One other person was having this exact trouble, too, but it didn't seem to get resolved. Oh, I am using an IP address because the site is not live yet, it is in development. There are no subdomains.

Here's what happens.

I uploaded the file to here and I get the standard vB login screen. When I login, I get redirected to http://69.5.17.244/login.php, which produces an error because that file does not exist.

If I am logged in before I go to the above url, I see the actual html as if I am logged in. If I logout, I get redirected to vB logout screen. I click "return to previous screen" and I get sent to a standard vB login. When I attempot to login, I get redirected to /login.php which doesn't exist. (loop)

I have used your little script that gives you the path, and am using that path in the scripts below. I have tried changing the cookie path etc in your troubleshooting guide. I am really hoping to be able to use your script to limit access to non vB pages based on usergroup.

Here's my code (using your test code with my paths):
Code:

<?php
chdir('/big/dom/xc5children/www/forums');
require_once('/big/dom/xc5children/www/forums/global.php');
?>
<html>
<body>
<?php
if ($vbulletin->userinfo['usergroupid'] == '6' )
    {
    echo "This is only visible to people in usergroup 6";}
    ?>

<?php
    require_once('/big/dom/xc5children/www/login_inc.php');
?>
</body>
</html>

and login_inc.php
Code:

<?php
// Edit the line below to show path to your forums
$forumpath = "/big/dom/xc5children/www/forums";


// You dont have to edit anything underneath here,
// but you can if you wish to style the login box
// to match the style of your site.


// We check if user is logged in
if ($vbulletin->userinfo['userid']!=0) {

// If Logged in display welcome back message
echo "Welcome Back, <b>";
echo $vbulletin->userinfo['username'];
echo " !</b><br>";

// If logged in display logout link
echo "<a href=\"".$forumpath."login.php?$session[sessionurl]do=logout&amp;logouthash=$logouthash";
echo $vbulletin->userinfo['logouthash'];
echo "\">";
echo "<font size=\"1\" face=\"verdana\">Log Out</font></a>
";

} else { // If user is not logged in, we do this stuff

// Display text and link to register.
echo "
        You have to <a href=\"".$forumpath."/register.php?s=$session[sessionhash]\"
        target=\"_parent\"><b>register</b></a>  before you can post on our forums or use our advanced features.
        ";

// Display login boxes + button
// You can style this with html or CSS as normal if desired.
echo"
        <form action=\"".$forumpath."/login.php\" method=post onsubmit=md5hash(vb_login_password,vb_login_md5password,vb_login_md5password_utf)>
        <script type=text/javascript src=\"".$forumpath."/clientscript/vbulletin_md5.js\"></script>
        User Name:<br>
        <input name=vb_login_username type=text id=navbar_username onfocus=if (this.value == '$vbphrase[username]') this.value = ''; size=10 />
                       
        <br>Password2:<br>
        <input name=vb_login_password type=password size=10 />
        </br>
               
        <label for=cb_cookieuser_navbar><input name=cookieuser type=checkbox id=cb_cookieuser_navbar value=1 checked=checked />
        Remember Me?<br /></label>
       
               
        <input type=submit title=$vbphrase[enter_username_to_login_or_register] value=\"Log In\" />
               
        <input type=hidden name=s value=$session[sessionhash] />
        <input type=hidden name=do value=login />               
        <input type=hidden name=vb_login_md5password />
        <input type=hidden name=vb_login_md5password_utf />

        </form>
";

}
?>


StriderX7 08-01-2006 11:20 AM

The scripts works well but I have a slight problem.

I've installed the login box on my Joomla page as a module and it works fine for the most part. It logs in ok and shows the "Please Wait While We Transfer You" screen on my forum. Then when it does redirect me it still has the login form there instead of the "Welcome Back, USERNAME" message.

I know that it does log me into the forum properly though because I created a Joomla vBulletin Who's Online module and that shows the username as online.

HELP!

Billspaintball 08-01-2006 01:59 PM

In then login_inc.php file, what happens if you change // Edit the line below to show path to your forums
$forumpath = "/big/dom/xc5children/www/forums"; to a full url.
For example
$forumpath = "http://www.yoursite.com/forums/";



Quote:

Originally Posted by Evoir
Oh, I am using an IP address because the site is not live yet, it is in development. There are no subdomains.

I wonder if that messes with the cookies causing the loop.

Billspaintball 08-01-2006 02:00 PM

Quote:

Originally Posted by StriderX7
The scripts works well but I have a slight problem.

I've installed the login box on my Joomla page as a module and it works fine for the most part. It logs in ok and shows the "Please Wait While We Transfer You" screen on my forum. Then when it does redirect me it still has the login form there instead of the "Welcome Back, USERNAME" message.

I know that it does log me into the forum properly though because I created a Joomla vBulletin Who's Online module and that shows the username as online.

HELP!

That sounds like a cookie problem.
Have you tried the troubleshooting on post 2 yet?

Evoir 08-01-2006 05:56 PM

Billspaintball,

Thanks for the quick support. I appreciate it!

It does seem like a path issue, because it is not recognizing the forums path, and is redirecting to /login.php instead of /forums/login.php for the redirect.
It should not be showing the standard vB login, but rather the more simple login that is located in login_inc.php, right?

Quote:

Originally Posted by Billspaintball
In then login_inc.php file, what happens if you change // Edit the line below to show path to your forums
$forumpath = "/big/dom/xc5children/www/forums"; to a full url.
For example
$forumpath = "http://www.yoursite.com/forums/";

I tried this (but using the IP address http://69.5.17.244/forums/) and no go.

I have tried multiple cookie settings in vB...

Path to Save Cookies "/"
Cookie Domain "blank"

but I have also tried other combinations. I should not be seeing the standard vB login, right?

Evoir 08-01-2006 09:15 PM

Aha! I found out what the problem was! I had my forums to not allow unregistered users to view the forums. So, vB was kicking in it's login before your login_inc.php could kick in. Then, on login_inc.php I had to change the
forumpath:

// Edit the line below to show path to your forums
$forumpath = "/forums/";

This works just fine.

I'd prefer to have the forum hidden from everyone except registered users within certain usergroups. But, I think that is incompatible with this script. IS there a way around this?

StriderX7 08-01-2006 09:55 PM

Quote:

Originally Posted by Billspaintball
That sounds like a cookie problem.
Have you tried the troubleshooting on post 2 yet?

Yep, my settings are already how the troubleshooter says they should be

lightwave 08-01-2006 10:39 PM

How do I make this work across different subdomains?

Billspaintball 08-02-2006 01:19 AM

Quote:

Originally Posted by lightwave
How do I make this work across different subdomains?

Tried step 4 yet?
https://vborg.vbsupport.ru/showpost....98&postcount=2

Evoir 08-02-2006 10:02 PM

Hi, I baaaack :)

I have another question: I'd like to lock up an entire page based on vB usergroup, and it seems like there is a problem doing this... here is the error I get:
Quote:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /big/dom/xc5children/www/private/aboutus/index.php on line 30
I'm using your second suggestion under USAGE:
Quote:

You can use a simple variation of this to restrict entire pages to a certain usergroup.
For example,
PHP Code:
<?php
if ($vbulletin->userinfo['usergroupid'] == '6' )
{
echo "Have stuff for here";
} else {
echo "You do not have permission for this page"; }
?>
Can you help me understand how to protect a whole page (including the navigation etc)? I simply wrapped my html inside of the quotes "Have stuff for here" in above example. It includes html and php calls (includes for the navigation etc). Basically, everything between <body> and </body>

soletrader 08-03-2006 12:12 AM

Quote:

Q. Now that I've installed this script I'm having problems logging in/out!

A. Try clearing your cookies. If you're still having problems afterwards, go to your Admin CP, click on vBulletin Options, and edit your Cookie Domain (listed under Cookies and HTTP Header Options). Change that option to ".yoursite.com" (note the two dots!). Also make sure that your Cookie Path option is set to "/".
Once you change that, close all browser windows, clear your cookies again, and then try to log in/out again.

Once I do this, I can no longer login to the control panel. Are there any solutions to this?

Billspaintball 08-03-2006 04:32 AM

Quote:

Originally Posted by Evoir
I simply wrapped my html inside of the quotes "Have stuff for here" in above example. It includes html and php calls (includes for the navigation etc). Basically, everything between <body> and </body>

Ok, thats were the problem is.

Wrapping the HTML in those tags is fine, however when you wrapped the PHP inside the echo tags everything breaks as you have found out.

If your wrapping a mix of HTML and PHO you need it in a format like this.

PHP Code:

<?php
if ($vbulletin->userinfo['usergroupid'] == '6' )
{
echo 
"Have stuff for here";
// put some PHP code here
echo "Now some more HTML goes here";
// and some more PHP stuff cos I can
echo "and the final HTML stuff here";
} else {
echo 
"You do not have permission for this page"; }
?>

Ive just used comments // in the above example where you would add your straight PHP code.

Hope thats a bit more clear.
If your still having problems just post the first dozen lines or so of your page or so.

Billspaintball 08-03-2006 04:57 AM

Quote:

Originally Posted by soletrader
Once I do this, I can no longer login to the control panel. Are there any solutions to this?

Did you flush the cookies in your browsers cache and force a page reload? (CTRL+F5 (I think) )

boske 08-04-2006 02:42 AM

Quote:

Originally Posted by Billspaintball
Did you flush the cookies in your browsers cache and force a page reload? (CTRL+F5 (I think) )

Yeah make sure you do this when you have changed Cookies and HTTP headers, I had the same problem as you.

quadude 08-13-2006 08:02 PM

Something maybe worth mentioning is that to prevent script issues from happenning(due to path changes) You can do something like this:
Code:

$cwd = getcwd();
chdir('/path/to/your/forums');
require_once('/path/to/your/forums/global.php');
chdir($cwd);


Evoir 08-13-2006 08:26 PM

Ok, now I am having trouble with any quotes being used within the document. Is there a way around this? I am using this code on a template, and my client is using quotes, which is causing an error.

Quote:

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /big/dom/xc5children/www/private/learning_areas/dramatic_play.php on line 38

grayloon 08-15-2006 08:32 PM

Since the chdir code must be first on the page, how do you handle the sending of headers (like cookies)?

Bahawolf2 08-15-2006 09:45 PM

I have a question...

I am using the script in other folders, and it wont then login... For example:

Main directory: public_html/
Forum Directory: public_html/forums/

Say I have a page in public_html/support/

The script doesnt login, or logout properly, but If I login to a page before the /support/ directory it works okay. Otherwise only pages in the public_html folder works.

Any help? I have changed the codes inserted in the page to reflect the change, (ie. ../forums/login_inc.php) like that.

Billspaintball 08-16-2006 05:18 AM

Quote:

Originally Posted by grayloon
Since the chdir code must be first on the page, how do you handle the sending of headers (like cookies)?

As long as its all before any page output there shouldant be any problems.

Billspaintball 08-16-2006 05:21 AM

Quote:

Originally Posted by quadude
Something maybe worth mentioning is that to prevent script issues from happenning(due to path changes) You can do something like this:
Code:

$cwd = getcwd();
chdir('/path/to/your/forums');
require_once('/path/to/your/forums/global.php');
chdir($cwd);


Yeah I should have done that I spose.

Zidane007nl 08-21-2006 10:02 PM

Good hack, got it running successfully finally.
But when someone who is banned on my forums is watching the website and is still logged in they get the forum banned message (which doesn't look well).

Billspaintball 08-23-2006 03:39 AM

Quote:

Originally Posted by Zidane007nl
Good hack, got it running successfully finally.
But when someone who is banned on my forums is watching the website and is still logged in they get the forum banned message (which doesn't look well).

I will look at that and see if I can do something about that.

Sparky_s 08-25-2006 08:35 PM

Works perfect on 3.6.0.

I added a little code in the login_irc.php to inform users that they can proceed to the forums.

Code:

//Added by Sparky-s 25/08/06
echo "<a href=\"".$forumpath."index.php";
echo "\">";
echo "<font size=\"1\" face=\"verdana\">You may click to proceed to the forums.</font></a>
";

echo "<font size=\"1\" face=\"verdana\">You may also </font></a>
";

The last bit is to lead to the log out link.

I'm mainly using this as a cover page for users with access masks before they get to the forum.

I'm not sure it it has been altered already like this, as I couldn't be bothered reading 14 pages.:D

I assume I'm allowed edit the login_inc file?
Thanks.

Sparky

Bahawolf2 08-27-2006 04:20 AM

Can anyone provide me with any assistance ot my problem above?

When i try to login it ends up going to

link.com/support/forums/login.php

instead of link.com/forums/login.php

UtilityGeek 08-29-2006 09:29 PM

I'm using this script with no issues however when I close the forums down, any non-vb page with the global.php included on it gives me the forum down message. Is there a way to check this (forum up/down) and display something else instead?

Billspaintball 08-30-2006 06:00 AM

Quote:

Originally Posted by Sparky_s

I assume I'm allowed edit the login_inc file?
Thanks.

Sparky

Sure can!

Billspaintball 08-30-2006 06:03 AM

Quote:

Originally Posted by UtilityGeek
I'm using this script with no issues however when I close the forums down, any non-vb page with the global.php included on it gives me the forum down message. Is there a way to check this (forum up/down) and display something else instead?

Problem with that, is if your using your vB login so you can do access control on your site like many are, you will loose that access control.
You would have anyone including guests having unrestricted access.

ocdotcom 08-30-2006 10:06 PM

Thanks very much - Im having fun playing with this


All times are GMT. The time now is 08:44 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.02557 seconds
  • Memory Usage 1,912KB
  • 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
  • (5)bbcode_code_printable
  • (7)bbcode_php_printable
  • (23)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)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