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)

DelaZ 09-08-2006 06:33 PM

Hey thanks for the hack!
I got a complete newbish question though... I'm rather new at this.

What's the code for the form itself? What do I place here exactly? (in html)
Quote:

Where you want to have your login box place this block of code.
This is my website btw:
http://www.++++hollywood.be (damn censoring :) ... it's "f u c k hollywood.be")
Thanks

Billspaintball 09-11-2006 04:27 AM

Quote:

Originally Posted by DelaZ
Hey thanks for the hack!
I got a complete newbish question though... I'm rather new at this.

What's the code for the form itself? What do I place here exactly? (in html)

Thanks

The actual form code is in the file login_inc.php

You just need to place
PHP Code:

<?php  
    
require_once('/path/to/your/login_inc.php');  
?>

At the point in your page that you want the login box to appear.

DelaZ 09-11-2006 04:28 PM

Quote:

Originally Posted by Billspaintball
The actual form code is in the file login_inc.php

You just need to place
PHP Code:

<?php  
    
require_once('/path/to/your/login_inc.php');  
?>

At the point in your page that you want the login box to appear.

Thanks alot works now

Peter_Rosado 09-24-2006 11:54 AM

Does this work in 3.6.1? hmmm

Billspaintball 09-26-2006 06:08 AM

Quote:

Originally Posted by Peter_Rosado
Does this work in 3.6.1? hmmm

Yes.
It works in all 3.5.x and 3.6.x releases to date.

TosaInu 10-01-2006 11:27 PM

I need to hide a html page until users are logged in. You start with making the page php, but HTML content is still visible. The HTML also contains some Javascript and it would be nice if this could be shielded permanently. Wrapping the whole HTML content inside <?php tags make it invisible, but also stops it from working.

How do I block the whole page until the user is logged in, also when viewing sourcecode?

Billspaintball 10-02-2006 03:26 AM

Quote:

Originally Posted by TosaInu
I need to hide a html page until users are logged in. You start with making the page php, but HTML content is still visible. The HTML also contains some Javascript and it would be nice if this could be shielded permanently. Wrapping the whole HTML content inside <?php tags make it invisible, but also stops it from working.

How do I block the whole page until the user is logged in, also when viewing sourcecode?

Just wrap the HTML inside PHP as you tried.
However, you must do it correctly else it wont work.

They must be put either in PRINT or ECHO statements.

Example:
PHP Code:

<?php echo("
      <div class=\"content\">
      <H1>Paintball ?</H1>
      <H2>Paintball? What's that?</H2>
      <p>Paintball is an intense,
      ...blah, blah, blah..
      </div>
"
); ?>

One important note.

See If you use quotes within PHP code you MUST escape them with \ else it will give you an error.

For example I had quotes in my enclosed HTML above so I did this
HTML Code:

<div class=\"content\">
Hope that makes sense :)

No need to read on from here, but there is another way which you may prefer.
You could always just add the html as an include when required.
For example.
PHP Code:

if ($usergroup == '6' )
    {include(
"/home/xxx/public_html/include/menu.inc");} 

The file menu.inc is just straight HTML content.
It has no body, title, header tags etc, just straight HTML content.

TheGorf 10-04-2006 07:21 PM

Is there any way to get around the chdir( ) requirement in the file that you are trying to place the logon form on? I'm trying to integrate this into our website, however we use a lot of include_once( ) to include various pieces of custom code to create the overall look and feel of the site. Consequently, this chdir really mucks things up.

Otherwise if I just put it on a static page it works great. :) Thoughts?

Billspaintball 10-04-2006 08:53 PM

Try this.
It should change you back to the origional directory.

PHP Code:

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


PS, if this works and you use this hack please click instal :)

TheGorf 10-04-2006 09:18 PM

ah ok that seems to have worked. Although there is an error in the piece of code I just downloaded:

The code is:
Code:

// 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>
";

Note that after the first $forumpath the string should then be ."/login.php..." Otherwise the Log Out link points to an invalid path.

Jon. 10-06-2006 04:12 PM

Hello

Having problems with it logging me in. I've got my forum at thecarforum.net, and this page at imagecan.net. Both the forum folder and the imagecan folder are in my public html folder.

All logs in fine, but it just can't remember me. I log in and then it's forgotten about it. My cookie domain and path are both set to blank. Any ideas?

TosaInu 10-07-2006 09:55 PM

Thanks for the examples Billspaintball, they really helped me out.

Now I'm about to add a link into a template and I run into another problem. Normally <a href ="http://domain/vb/script.php" target="_blank">Script</a> works without problems. But when using something like that on a log page I just get a new blank screen that says about blank.

Just calling the page directly in the browser works fine. I tried things like ?[sessionurl], but that doesn't work. How to call a page inside a template?

There's at least a problem with the trailingslash in forumpath and
Code:

// If logged in display logout link
echo "<a href=\"".$forumpath."login.php?$session[sessionurl]do=logout&amp;logouthash=$logouthash";

in login_inc.php
forumpath should not have trailing and logout
Code:

// If logged in display logout link
echo "<a href=\"".$forumpath."/login.php?$session[sessionurl]do=logout&amp;logouthash=$logouthash";


TosaInu 10-10-2006 08:16 PM

Seems to be a browserissue, it also happens when the link to the login protected PHP is posted in a forumtopic. Firefox opens the page, but IE gives the about blank page. When looking closely, it actually requests the script URL but quickly procedes with the about blank page.

johnn 10-15-2006 08:39 AM

Quote:

Originally Posted by Billspaintball
Try this.
It should change you back to the origional directory.

PHP Code:

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


PS, if this works and you use this hack please click instal :)


That all worked for me, but when I attempt to use one of the php scripts I wrote, it isn't letting this script insert data into my MySQl database. It's an information script. It'll read the data from the mysql db just fine, but when I try to use a webpased php form to submit/edit information to my DB it doesn't work.

I don't get any PHP errors, it just.....doesn't work..Lol.

When I remove all the chdir things and forum inclusions for my login/page restrictions it works just fine.

Any thoughts on this?

masss 11-01-2006 01:43 AM

Ok now if this would just work with the new forums

wingVTA 11-01-2006 06:41 AM

Hi guys....

I get a problem tryig to incorporate this script!!

I actually get this problem with a lot of scripts!!

Quote:

Notice: Undefined index: REQUEST_URI in C:\Sites\Single30\vtamundane\webroot\forum\include s\class_core.php on line 1907

Notice: Undefined index: REQUEST_URI in C:\Sites\Single30\vtamundane\webroot\forum\include s\class_core.php on line 1907

Notice: Undefined index: PATH_INFO in C:\Sites\Single30\vtamundane\webroot\forum\include s\class_core.php on line 1913

Notice: Undefined index: PATH_INFO in C:\Sites\Single30\vtamundane\webroot\forum\include s\class_core.php on line 1913

Notice: Undefined index: REDIRECT_URL in C:\Sites\Single30\vtamundane\webroot\forum\include s\class_core.php on line 1917

Notice: Undefined index: REDIRECT_URL in C:\Sites\Single30\vtamundane\webroot\forum\include s\class_core.php on line 1917

Notice: Undefined index: HTTP_REFERER in C:\Sites\Single30\vtamundane\webroot\forum\include s\class_core.php on line 1574
Welcome Back, =VTA= teh-wing !
Log Out
^^ But as you can see, it knows who I am and I am logged in!!!

So the code is working!!

The problem is with using the global.php

I have tried adding "define('SKIP_REFERRER_CHECK', true);" to the login.php in the forum, but this does not help with anything...

Does anyone know what is causing this to go wrong, and if there is a way to fix it??

Cheers

wing

Billspaintball 11-02-2006 12:58 AM

Quote:

Originally Posted by masss
Ok now if this would just work with the new forums

New forums?

You mean vB 3.6.x ?
If so, it works fine with 3.6.1 (Havent tested with 3.6.2 but should work)

masss 11-12-2006 08:19 PM

ok what gives man

Unable to add cookies, header already sent.
File: /home/animelib/public_html/index.php
Line: 1

Billspaintball 11-15-2006 11:33 PM

Quote:

Originally Posted by masss (Post 1115681)
ok what gives man

Unable to add cookies, header already sent.
File: /home/animelib/public_html/index.php
Line: 1

The first item in the troubleshooting guide is your friend.
https://vborg.vbsupport.ru/showpost....98&postcount=2

You have some whitespace or html before a couple of lines.

dklassen 11-24-2006 08:21 PM

Got it installed ok and it seems to be working except for the fact that when I put in my user name and password it takes me to my forum but doesn't log me in. Any thoughts? I'm running 3.6.3

Billspaintball 11-27-2006 11:21 PM

Have you tried step 3 of the troubleshooting guide yet?
https://vborg.vbsupport.ru/showpost....98&postcount=2

Billspaintball 12-02-2006 03:14 AM

New update released.
Only a couple of minor changes.

Changelog

Version 1.20 (2nd December 2006)
  • Fixed Logout incorrect path bug
  • Made change to reduce compatibility problems with foreign scripts

Please make sure you have the latest script before reporting any problems.

Aur-Phala.Com 12-15-2006 05:08 PM

hey any idea how i could make it show on whosonline page
so people who are using my page www.aur-phala.com/hotmail
will show up on whos online so i can see whos checking that page out

for version 3.6.x thanx

Maestro 12-26-2006 11:38 PM

Any idea what would cause this? I'm using the following condition on a page to restrict something so that only usergroup 6 can see it:

Code:

<?php
if ($vbulletin->userinfo['usergroupid'] == '6' )
        {
        echo "This is only visible to people in usergroup 6";}
        ?>

For me the reverse seems to be happening, ie. all usergroups EXCEPT group 6 can see what's inside the quotes!

Maestro 12-27-2006 11:15 AM

Quote:

Originally Posted by Maestro (Post 1145564)
For me the reverse seems to be happening, ie. all usergroups EXCEPT group 6 can see what's inside the quotes!

Problem solved now. After a little more investigation it turns out it was always behaving as though I wasn't logged in because the page is in a different directory to the forum.

This is solved by altering Cookie Domain and Post Referrer Whitelist in the Control Panel as described earlier in the topic.

Excellent mod!

Billspaintball 01-09-2007 03:10 AM

Quote:

Originally Posted by Maestro (Post 1145752)
This is solved by altering Cookie Domain and Post Referrer Whitelist in the Control Panel as described earlier in the topic.

Great to hear.
Paths and cookies seem to be the biggest issue people face with this.
Quote:

Excellent mod!
Thanks you! :D

upirate 03-17-2007 05:59 AM

will this work on 3.6.5 ?

Billspaintball 03-18-2007 08:42 AM

Quote:

Originally Posted by upirate (Post 1205419)
will this work on 3.6.5 ?

Yes.

brandondrury 03-18-2007 08:19 PM

The script is working great in Maxthon, IE. However, when I use Firefox to login, I do not get redirected back to the page I started on. I get redirected to the index page of my forum.

I've noticed that in Firefox, if I log out, the vBulletin box that says "All cookies cleared!

* Return to the page you were previously viewing"

links to the index page of the forum.

I'm not sure where to start troubleshooting this one. Does the script make any special concessions for browsers. Does it even need to?

Thanks,
Brandon Drury

Billspaintball 03-18-2007 11:37 PM

Quote:

Originally Posted by brandondrury (Post 1206807)
The script is working great in Maxthon, IE. However, when I use Firefox to login, I do not get redirected back to the page I started on. I get redirected to the index page of my forum.

I've noticed that in Firefox, if I log out, the vBulletin box that says "All cookies cleared!

* Return to the page you were previously viewing"

links to the index page of the forum.

I'm not sure where to start troubleshooting this one. Does the script make any special concessions for browsers. Does it even need to?

Thanks,
Brandon Drury

Interesting.
I will try mine in Firefox and see if I can replicate it.

Billspaintball 04-24-2007 02:54 PM

Updated
  • Fixed - // in paths bug
  • Fixed - Javascript warning in some browsers
  • Fixed - Tidied up some code
  • Fixed - Avatar display code bug

Download the update from the first post, and see the 2nd post for additional workarounds for the 404 on Expired passwords and cross domain login issues.

Emma 05-02-2007 09:25 PM

This is exactly what I was looking for! One question though, what if I want the user to be redirected to the main page (the non-vb page where the login is) after the login instead of the forums homepage. What would I need to change?

Billspaintball 05-02-2007 11:02 PM

Quote:

Originally Posted by Emma (Post 1240113)
what if I want the user to be redirected to the main page (the non-vb page where the login is) after the login instead of the forums homepage. What would I need to change?

They are redirected back to the page they logged in from.

Emma 05-02-2007 11:14 PM

It's taking me to the forum home page though instead of back to the site's index page. :\ Any thoughts?

powerbook 05-03-2007 08:56 PM

I get logged on when I hit the"logon" button on the custom site page. It temporarily redirect me to the VB login.php page and recognizes me and says welcome in the VB splash screen.

It then redirects me back to the page I logged in from with the same login box as if I haven't logged on. If I run the code below on it's own it works properly and takes me back to the page I used for logon and welcomes me without the login text boxes.

1) Any idea what might be causing this,
2) Can you specify where it should redirect to if you don't want to be redirected to the logon page again?

Thanks

Quote:

<?php
$curdir = getcwd ();
chdir('/home/XXX/public_html');
require_once('/home/XXX/public_html/global.php');
chdir ($curdir);
?>
<html>
<body>
This is a heading<br />
This is some more stuff <br />
And another line<br />
You get the idea<br />
Just place stuff as you normally would with HTML<br />
I use CSS to style and position on my site fwiw<br />
<br />
How about we put the login box right under here?<br />
<br />
<?php
require_once('/home/XXX/public_html/test/login_inc.php');
?>
</body>
</html>

Emma 05-29-2007 03:59 AM

Still need some help with this myself. Also, I'm placing this code on all of my external forum pages, and while it shows me logged in on the main one, if I go to another page, it shows up saying I need to login again. Is there something I need to do with the cookies that I'm not aware of?

ZomgStuff 06-26-2007 04:47 AM

I'm having problems with 3.6.7 PL1

I'm seeing this at the very top of my external page, but everything else works.

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /global.php(237) : eval()'d code on line 2

CP, 07-05-2007 05:48 PM

Great hack ive installed it.. i just have a small query.. i would like my users to login and be redirected to a custom php file ive made, a page for members at the same time i would like the forum and user login session to be still active...

Cheers!

ApplePro 07-09-2007 12:03 PM

Hello guys,

When I run sample script (test.php), I'm getting an error about headers:

https://vborg.vbsupport.ru/

I've checked script and there are no spaces before first 4 lines of code.

By the way, I see this only when I logged out. When I logged in (through vBulletin), I see this:

https://vborg.vbsupport.ru/

How can I fix this?

PS: I have lastest vBulletin version installed. And the installation is fresh (just one thread).

beejeebers 07-21-2007 05:32 PM

This works wonderfully, but one question. How would I pull the password value out before it gets encrypted? I need that value for my main site's login script which I'm calling from login.php for the forums.

Any ideas?


All times are GMT. The time now is 08:23 PM.

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.02457 seconds
  • Memory Usage 1,861KB
  • 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
  • (4)bbcode_code_printable
  • (1)bbcode_html_printable
  • (6)bbcode_php_printable
  • (16)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)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