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 05-02-2006 10:46 PM

Did you try the edit at the end of step 4 in troubleshooting?

Weirdwolf 05-15-2006 03:52 PM

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.)

Billspaintball 05-16-2006 12:15 AM

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.

Weirdwolf 05-16-2006 01:23 AM

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>


Billspaintball 05-16-2006 04:21 AM

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.

Weirdwolf 05-16-2006 10:51 AM

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.

Billspaintball 05-16-2006 11:01 AM

Try
something like
Code:

if ($vbulletin->userinfo['usergroupid'] == '9' 
    or $vbulletin->userinfo['usergroupid'] == '6' 
)


Weirdwolf 05-17-2006 12:00 PM

Quote:

Originally Posted by Billspaintball
Try
something like
Code:

if ($vbulletin->userinfo['usergroupid'] == '9' 
    or $vbulletin->userinfo['usergroupid'] == '6' 
)


Works great, thanks! :banana:

Billspaintball 05-24-2006 01:16 AM

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.

pcwfreak 05-30-2006 08:26 PM

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

Thanks.


All times are GMT. The time now is 08:22 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.01275 seconds
  • Memory Usage 1,772KB
  • 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
  • (2)bbcode_code_printable
  • (5)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (2)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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