Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Simple vB User login and access control on non vB pages Details »»
Simple vB User login and access control on non vB pages
Version: 1.30, by Billspaintball Billspaintball is offline
Developer Last Online: Nov 2011 Show Printable Version Email this Page

Version: 3.5.8 Rating:
Released: 11-16-2005 Last Update: 04-23-2007 Installs: 138
Additional Files  
No support by the author.

Hack Description

This is a cutdown version of the user authentication and access control system I use on the non vB pages on my website.

This uses the vB 3.5 login system to log you in and out. It allows you to move between your forums and other pages on your site while remaining logged in.

It allows you to do things such as restrict pages by usergroup, display different content depending on a user being logged in or not.
For example, you can have banner Adds displying to non members only, and/or let members access to specific content.

Ive cut it down to the bare minimum that it needs to work, no fancy stuff such as avatars, PM's, or even formating.

I will try and offer support, but work and family commitments mean I dont have much free time.

This code is a mix of my own, and pieces I have used from other hacks that are floating around.

This script has been confirmed as working on
  • vB 3.5.x - All Versions


Changelog

Version 1.30 (24th April 2007)
  • Fixed - // in paths bug
  • Fixed - Javascript warning in some browsers
  • Fixed - Tidied up some code

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

Version 1.10 (4th Feb 2006)
  • Changed login_inc.php so you only need to edit path in one place now.
  • Added more commenting to login_inc.php
  • Added usage instructions to instructions file
  • Added troubleshooting guide with all common problems and fixes to instructions file.
Note: It is NOT necessary to update from 1.0 to 1.10.
There is no functionality changes or bug fixes between these 2 releases.

Version 1.0 (17th November 2005)
  • Initial Release


Deluxe Version of this hack is now available
Has Avatars, PM's, Number of Posts etc.

Click Here


Click on Install
If you have this script installed then please click on the install link because;
  • You will get notified if any security issues are reported.
  • You will get notified when there are any upgrades to this script
  • It gives me a warm fuzzy feeling and motivates me to develop more

Donations
First of all, to be clear. This script is 100% free.

However if you feel an urge to donate I'm not going to say no.
Donations can be made at http://www.billspaintball.com/vb3/bd_donate.php

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #132  
Old 05-02-2006, 10:46 PM
Billspaintball's Avatar
Billspaintball Billspaintball is offline
 
Join Date: Sep 2003
Location: Bathurst, Au
Posts: 649
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you try the edit at the end of step 4 in troubleshooting?
Reply With Quote
  #133  
Old 05-15-2006, 03:52 PM
Weirdwolf's Avatar
Weirdwolf Weirdwolf is offline
 
Join Date: Jan 2004
Location: Kentucky
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm trying to restrict access to pages based on Usergroups, but I can't figure out what I shoud do with the code you provided. I have tried it in different locations on the page, but whether I'm logged in or not it always shows me the page. Any help? (The user login works perfectly for me, btw.)
Reply With Quote
  #134  
Old 05-16-2006, 12:15 AM
Billspaintball's Avatar
Billspaintball Billspaintball is offline
 
Join Date: Sep 2003
Location: Bathurst, Au
Posts: 649
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Weirdwolf
I'm trying to restrict access to pages based on Usergroups, but I can't figure out what I shoud do with the code you provided. I have tried it in different locations on the page, but whether I'm logged in or not it always shows me the page. Any help? (The user login works perfectly for me, btw.)
post a sample of your page and what you are trying to do, so we can have a look at it.
Reply With Quote
  #135  
Old 05-16-2006, 01:23 AM
Weirdwolf's Avatar
Weirdwolf Weirdwolf is offline
 
Join Date: Jan 2004
Location: Kentucky
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Right now I have it at the top of the page, and I'd like to restrict this page's access to those who attend here only. I've also tried replacing the 'Have stuff for here' with the content of the page, and that didn't work either. I realize I must be missing the obvious, but I'm just stumped at this point. Thanks for any help.

PHP Code:
<?php
   chdir
('forums'); 
   require_once(
'forums/global.php');  
?>
<?php
if ($vbulletin->userinfo['usergroupid'] == '9' )
    {
    echo 
"Have stuff for here";
             } else {
             echo 
"You do not have permission for this page"; }
    
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Richmond church of Christ Member Services</title>
<style type="text/css">
<!--
body,td,th {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
}
body {
    background-color: #0066FF;
}
#Layer1 {
    position:absolute;
    left:11px;
    top:8px;
    width:25px;
    height:70%;
    z-index:1;
    background-color: #0000FF;
}
#Layer2 {
    position:absolute;
    left:52px;
    top:19px;
    width:8px;
    height:90%;
    z-index:2;
    background-color: #0000FF;
}
.style1 {
    font-size: 14px;
    font-weight: bold;
}
.style3 {font-size: 10px}
-->
</style>
<link href="siteCSS.css" rel="stylesheet" type="text/css" />
</head>

<body>
<p align="center"><img src="images/memserv.gif" width="484" height="37" align="middle" /></p>
<table width="80%" border="4" align="center" bordercolor="#999999" bgcolor="#FFFFFF">
  <tr>
    <td><table width="100%" align="center">
      <tr>
        <td width="50%" align="left" valign="top"><p>Welcome to the Richmond church of Christ Member Services area. Here you will find special areas and information specifically <em>for</em> members attending here in Richmond</p>
          
          <p><?php include('login_inc.php'); ?>&nbsp;</p></td>
          
        <td width="50%" align="left" valign="top"><p align="center" class="style1">Church News &amp; Announcements </p>
          <p>
            <?php include('news/index.php'); ?>
          &nbsp;</p></td>
      </tr>
    </table>
      <p align="center"><span class="style3">&copy;2006 Richmond church of Christ, Richmond, Kentucky, United States 40475 </span></p>
    </td>
  </tr>
</table>
</body>
</html>
Reply With Quote
  #136  
Old 05-16-2006, 04:21 AM
Billspaintball's Avatar
Billspaintball Billspaintball is offline
 
Join Date: Sep 2003
Location: Bathurst, Au
Posts: 649
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, I see whats gone wrong.
The "have stuff here" line is where you put your page contents.
For example;

PHP Code:
<?php
   chdir
('forums'); 
   require_once(
'forums/global.php');  
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Richmond church of Christ Member Services</title>
<style type="text/css">
<!--
body,td,th {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
}
body {
    background-color: #0066FF;
}
#Layer1 {
    position:absolute;
    left:11px;
    top:8px;
    width:25px;
    height:70%;
    z-index:1;
    background-color: #0000FF;
}
#Layer2 {
    position:absolute;
    left:52px;
    top:19px;
    width:8px;
    height:90%;
    z-index:2;
    background-color: #0000FF;
}
.style1 {
    font-size: 14px;
    font-weight: bold;
}
.style3 {font-size: 10px}
-->
</style>
<link href="siteCSS.css" rel="stylesheet" type="text/css" />
</head>

<body>


<?php include('login_inc.php'); ?>

<?php
if ($vbulletin->userinfo['usergroupid'] == '9' )
    {
    echo 
"
             <p align="center"><img src="images/memserv.gif" width="484" height="37" align="middle" /></p>
<table width="80%" border="4" align="center" bordercolor="#999999" bgcolor="#FFFFFF">
  <tr>
    <td><table width="100%" align="center">
      <tr>
        <td width="50%" align="left" valign="top"><p>Welcome to the Richmond church of Christ Member Services area. Here you will find special areas and information specifically <em>for</em> members attending here in Richmond</p>
          
          <p>nbsp;</p></td>
          
        <td width="50%" align="left" valign="top"><p align="center" class="style1">Church News &amp; Announcements </p>
          <p>"
;
            
include(
'news/index.php'
         
echo 
" &nbsp;</p></td>
      </tr>
    </table>
      <p align="center"><span class="style3">&copy;2006 Richmond church of Christ, Richmond, Kentucky, United States 40475 </span></p>
    </td>
  </tr>
</table>"
;

} else {
             echo 
"You do not have permission for this page"; }
    
?>

</body>
</html>
I havent tested the code cos Im at work.
I may have missed escaping a " somewhere (I have a habit of doing that) but you should get the idea of how it works.
Reply With Quote
  #137  
Old 05-16-2006, 10:51 AM
Weirdwolf's Avatar
Weirdwolf Weirdwolf is offline
 
Join Date: Jan 2004
Location: Kentucky
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That works great, but is there a way to set it for access from multiple usergroups? ie, Members are usergroup 9 and Admins are usergroup 6. I've tried it as

PHP Code:
if ($vbulletin->userinfo['usergroupid'] == '9' 
and

PHP Code:
if ($vbulletin->userinfo['usergroupid'] == '9,6' 
and

PHP Code:
if ($vbulletin->userinfo['usergroupid'] == '9','6' 
None of those seemed to work.
Reply With Quote
  #138  
Old 05-16-2006, 11:01 AM
Billspaintball's Avatar
Billspaintball Billspaintball is offline
 
Join Date: Sep 2003
Location: Bathurst, Au
Posts: 649
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try
something like
Code:
if ($vbulletin->userinfo['usergroupid'] == '9'  
     or $vbulletin->userinfo['usergroupid'] == '6'  
)
Reply With Quote
  #139  
Old 05-17-2006, 12:00 PM
Weirdwolf's Avatar
Weirdwolf Weirdwolf is offline
 
Join Date: Jan 2004
Location: Kentucky
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Billspaintball
Try
something like
Code:
if ($vbulletin->userinfo['usergroupid'] == '9'  
     or $vbulletin->userinfo['usergroupid'] == '6'  
)
Works great, thanks! :banana:
Reply With Quote
  #140  
Old 05-24-2006, 01:16 AM
Billspaintball's Avatar
Billspaintball Billspaintball is offline
 
Join Date: Sep 2003
Location: Bathurst, Au
Posts: 649
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Weirdwolf
Works great, thanks! :banana:
Added this info to the usage guide in the 2nd post.
Others may find it usefull as well.
Reply With Quote
  #141  
Old 05-30-2006, 08:26 PM
pcwfreak pcwfreak is offline
 
Join Date: Mar 2006
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there a way of making it remember a user without the 'Remember me?' checkbox?

Thanks.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:38 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04993 seconds
  • Memory Usage 2,346KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (5)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (2)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete