vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Checking user group from a non vb page (https://vborg.vbsupport.ru/showthread.php?t=110338)

lightnb 03-14-2006 11:14 AM

Checking user group from a non vb page
 
I have the following code in my footer, which is included on every page:

PHP Code:

<?php

$forumpath 
"http://www.mysite.com/community/forums/";

if (
$vbulletin->userinfo['groupid']=6) {

echo 
"Admin/Mod CP button goes here!";

?>

I want it to check to see if the user is logged into vB and is in the admin usergroup, and if so, to display a button that links to the admin cp.

right now, it is showing the button regardless of log in status. what variable does vB use to store the user's usergroup?


thanks,

nick

lightnb 03-17-2006 10:34 PM

Bump

Freesteyelz 03-17-2006 11:06 PM

With conditionals I use:

Code:

<if condition="is_member_of($bbuserinfo, x)">
Your code here
</if>

Just extract from "is". Where "x" is just replace it with the Usergroup ID. To add more ID's add ", y, z" and so forth.

lightnb 03-19-2006 03:56 PM

With:

PHP Code:

<if condition="is_member_of($bbuserinfo, 6)">
My code here
</if> 

I get:

"Parse error: parse error, unexpected '<' in /home/.sites/22/site13/web/livexchange/footer.php on line 66"

lightnb 03-25-2006 02:27 AM

bump

Freesteyelz 03-25-2006 05:48 AM

You'll need to adjust the code to make it work. That was just an example conditional used in vB. I'm not sure exactly what the PHP protocol is but maybe:

Code:

if ($vbulletin->userinfo['usergroupid']=="6")
{
echo "Admin/Mod CP button goes here!";
}


lightnb 03-26-2006 03:33 AM

Quote:

Originally Posted by Freesteyelz
You'll need to adjust the code to make it work. That was just an example conditional used in vB. I'm not sure exactly what the PHP protocol is but maybe:

Code:

if ($vbulletin->userinfo['usergroupid']=="6")
{
echo "Admin/Mod CP button goes here!";
}


That doesn't produce any errors, but it doesn't do anything either...

I think there needs to be some other code before it to tell the script that it is looking for a vB variable...

Pickalo 03-26-2006 06:50 PM

You need to include the config.php I'd say.

Cole2026 03-26-2006 07:51 PM

No, Config.php just contains server-connect information.

You could do:
PHP Code:

$forumpath "http://www.mysite.com/community/forums";
require_once(
$forumpath '/global.php');

global 
$vbulletin;

if ( 
is_member_of($vbulletin6) )
{
   echo 
"Admin CP and ModCP links go here";
}

unset(
$vbulletin); 


lightnb 03-28-2006 03:16 AM

Doesn't seem to be working. I tried the code you gave me, but it just causes the page to sit forever, then asks me if i want to run or download the PHP file.

The whole footer is as follows:


HTML Code:

<!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>Xchange Footer</title>
<style type="text/css">
<!--
.style10 {color: #FFFFFF; font-family: Copperplate;}
-->

</style>
<script type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>
0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

</script>
</head>

<body onload="MM_preloadImages('forums/images/greenleaf/misc/contact_over.gif','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/privacystatement_over.gif','forums/images/greenleaf/misc/top_over.gif','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/contact_over.gif','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/top_over.gif')">
<table width="850" border="0" cellspacing="0" align="center" cellpadding="0">
  <tr height="25">
    <td><img src="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/mainbgbottom.jpg" width="850" height="25" /></td>
  </tr>
  <tr background="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/navbg.gif">
    <td><div align="center">
      <table width="850" border="0" cellspacing="0" cellpadding="0">
        <tr background="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/navbg.gif">
          <td width="258"><div align="left"><img src="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/cp.gif" width="257" height="27" /></div></td>
          <td width="347" background="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/navbg.gif">
                 
                 
<?PHP
$forumpath = "http://www.rahlentertainment.com/livexchange/forums";
require_once($forumpath . '/global.php');

global $vbulletin;

if ( is_member_of($vbulletin, 6) )
{
  echo "Admin CP and ModCP links go here";
}
unset($vbulletin); 
?>


</td>
          <td width="245"><div align="right"><a href="http://www.rahlentertainment.com/livexchange/forums/sendmessage.php4" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('contactus','','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/contact_over.gif',1)"><img src="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/contact.gif" alt="Contact US" name="contactus" width="71" height="26" border="0" id="contactus" /></a><a href="http://www.rahlentertainment.com/livexchange/privacy.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Privacy','','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/privacystatement_over.gif',1)"><img src="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/privacystatement.gif" alt="Privacy Statement" name="Privacy" width="130" height="26" border="0" id="Privacy" /></a><a href="#top" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('top','','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/top_over.gif',1)"><img src="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/top.gif" alt="TOP" name="top" width="43" height="26" border="0" id="top" /></a></div></td>
        </tr>
      </table>
    </div></td>
  </tr>
</table>
</body>
</html>



All times are GMT. The time now is 02:25 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.01283 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
  • (3)bbcode_code_printable
  • (1)bbcode_html_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete