Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-10-2006, 05:24 AM
lightnb lightnb is offline
 
Join Date: Dec 2005
Posts: 106
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Checking vB usergroup from non-vb page

What is the php code to use to see if a user is logged into vb, and to see what group they are a member of, from a non-vB PHP page, within the same domain?
Reply With Quote
  #2  
Old 04-10-2006, 09:07 AM
RS_Jelle RS_Jelle is offline
 
Join Date: Jul 2005
Posts: 1,276
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have a look at this tutorial
Reply With Quote
  #3  
Old 04-10-2006, 09:18 AM
lightnb lightnb is offline
 
Join Date: Dec 2005
Posts: 106
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks. I'll try it, but it'd be cool if there were a simpler version... all i really need is somthing like:

PHP Code:
<?PHP

require_once('http://www.mysite.com/livexchange/forums/global.php');



// IF THE USER IS LOGGED IN
if ($bbuserinfo[userid])
{
echo 
'The user is logged in!';

}
// ELSE THEY ARE NOT
else
{
echo 
'The user is not logged in!';
}

?>
I have a form on my site that uploads to a database, and I want to use the vB login system as a cheap way of making sure only certain people can access it.
Reply With Quote
  #4  
Old 04-10-2006, 09:43 AM
RS_Jelle RS_Jelle is offline
 
Join Date: Jul 2005
Posts: 1,276
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Read the full tutorial, everything is in there (and a lot more) and it's very easy.

You need something like this:
PHP Code:
<?php

// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// ##################### DEFINE IMPORTANT CONSTANTS #######################
// change the line below to the actual filename without ".php" extention.
// the reason for using actual filename without extention as a value of this constant is to ensure uniqueness of the value throughout every PHP file of any given vBulletin installation.

define('THIS_SCRIPT''test');

// ########################## REQUIRE BACK-END ############################
chdir('/home/site/public_html/livexchange/forums/global.php');
require_once(
'./global.php');  

// #################### HARD CODE JAVASCRIPT PATHS ########################
$headinclude str_replace('clientscript'$vbulletin->options['bburl'] . '/clientscript'$headinclude);

// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################

if (!is_member_of($vbulletin->userinfo6) AND !is_member_of($vbulletin->userinfo7))
{
        
print_no_permission();
}

// Your upload code here

?>
Probably you need to change this code (have a look at your config.php for it):
PHP Code:
chdir('/home/site/public_html/livexchange/forums/global.php'); 
Also change the script name and the usergroups to the correct ones for your script.
Reply With Quote
  #5  
Old 04-10-2006, 09:57 AM
lightnb lightnb is offline
 
Join Date: Dec 2005
Posts: 106
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, got the test page working.

Well, it worked as a stand-alone page, but when i tried integrating it into another page, I get an error:

Code:
Fatal error: Call to a member function unlock_tables() on a non-object in /home/.sites/22/site13/web/livexchange/forums/includes/functions.php on line 4366

here's what I have:

PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
    <title>Glossary Administration</title>
</head>

<body>

<h2 align="left">Glossary Administration</h2>

<p align="left">



<?php

// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// ##################### DEFINE IMPORTANT CONSTANTS #######################
// change the line below to the actual filename without ".php" extention.
// the reason for using actual filename without extention as a value of this constant is to ensure uniqueness of the value throughout every PHP file of any given vBulletin installation.

define('THIS_SCRIPT''admin');

// ########################## REQUIRE BACK-END ############################
chdir('/pathtosite/forums');
require_once(
'./global.php');  

// #################### HARD CODE JAVASCRIPT PATHS ########################
$headinclude str_replace('clientscript'$vbulletin->options['bburl'] . '/clientscript'$headinclude);

// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################

if (!is_member_of($vbulletin->userinfo6) AND !is_member_of($vbulletin->userinfo7))
{
        
print_no_permission();
}

echo 
'You are logged in!<br>';

// Your upload code here

$configfile "config.php";
require 
$configfile;
$db mysql_connect("$host""$username""$password");
mysql_select_db("$databasename"$db);

//Add word
if($action=="add")
{
if(
$word&&$definition)
{
$addWord=mysql_query("INSERT INTO `mdglossary` (`word`, `definition`) VALUES ('$word', '$definition')"$db);
if(
$addWord)
{
echo 
"The word $word and it's definition has been successfully added to the database";
}
if(!
$addWord)
{
echo 
"There has been an error in adding the word $word";
}
}
if(!
$word||!$definition)
{
echo 
"
<form name=\"mdglossary\" action=\"
$PHP_SELF\" method=\"post\">
<b>Word</b>
<br>
<i>The word you want adding</i>
<br>
<input name=\"word\" type=\"text\" value=\"\" maxlength=\"40\">
<br>
<br>
<b>Definition</b>
<br>
<i>The definition of the word</i>
<br>
<textarea name=\"definition\" rows=\"6\" cols=\"50\" ></textarea>
<br>
<input name=\"action\" type=\"hidden\" value=\"add\">
<input type=\"submit\" value=\"Add\">&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"reset\" value=\"Reset\">
</form>
"
;
}
}

//Edit word
if($action=="edit")
{
if(
$word&&$definition)
{
$updateIt=mysql_query("UPDATE mdglossary SET word='$word', definition='$definition' WHERE id='$id'",$db);
if(
$updateIt)
{
echo 
"The word $word has been successfully updated";
}
if(!
$updateIt)
{
echo 
"There has been an error in updating the word $word";
}
}
if(!
$word&&!$defintion)
{
$getInfo=mysql_query("SELECT * FROM `mdglossary` WHERE id=$id",$db);
if(
$theInfo=mysql_fetch_array($getInfo))
{
echo 
"
<form name=\"mdglossary\" action=\"
$PHP_SELF\" method=\"post\">
<b>Word</b>
<br>
<i>The word you want editing</i>
<br>
<input name=\"word\" type=\"text\" value=\""
;
printf($theInfo["word"]);
echo 
"\" maxlength=\"40\">
<br>
<br>
<b>Definition</b>
<br>
<i>The definition of the word</i>
<br>
<textarea name=\"definition\" rows=\"6\" cols=\"50\" >"
;
printf($theInfo["definition"]);
echo 
"</textarea>
<br>
<input name=\"action\" type=\"hidden\" value=\"edit\">
<input name=\"id\" type=\"hidden\" value=\"
$id\">
<input type=\"submit\" value=\"Update\">&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"reset\" value=\"Reset\">
</form>
"
;
}
else
{
echo 
"There has been an error";
}
}
}

//Delete word
if($action=="delete")
{
if(
$check=="yes")
{
$deleteIt=mysql_query("DELETE FROM mdglossary WHERE id=$id",$db);
if(
$deleteIt)
{
echo 
"The word has successfully been deleted";
}
if(!
$deleteIt)
{
echo 
"There has been an error whilst the word was being deleted. Please try again";
}
}
else
{
$getDeleteInfo=mysql_query("SELECT * FROM mdglossary WHERE id='$id'",$db);
$deleteInfo=mysql_fetch_array($getDeleteInfo);
echo 
"Are you sure you want to delete the following word?<br>";
echo 
"
<dl>
<dt><b>
"
;
printf($deleteInfo["word"]);
echo 
"
</b></dt>
<dd>
"
;
printf($deleteInfo["definition"]);
echo 
"
</dd>
</dl>
"
;
echo 
"<br><a href=\"$PHP_SELF?action=delete&id=$id&check=yes\">Yes</a>&nbsp;&nbsp;&nbsp;<a href=\"$PHP_SELF?action=main\">No</a>";
}
}

//Get Code
if($action=="getcode")
{
$getInfo=mysql_query("SELECT * FROM `mdglossary` WHERE id=$id",$db);
if(
$getCode=mysql_fetch_array($getInfo))
{
$lowWord=strtolower($getCode["word"]);
echo 
"The code that you can copy and paste the word - <b>";
printf($getCode["word"]);
echo 
"</b> - into your pages is:<br><br>";
echo 
"<form><textarea cols=\"50\" rows=\"5\">";
echo 
"&lt;a href=\"$roottoglossary?word=$lowWord\" class=\"glossary\" title=\"Click here to find out what this word means\"&gt;";
printf($getCode["word"]);
echo 
"&lt;/a&gt;";
echo 
"</textarea></form>";
echo 
"Example:<br><br><a href=\"$roottoglossary?word=$lowWord\" class=\"glossary\" title=\"Click here to find out what this word means\">";
printf($getCode["word"]);
echo 
"</a>";
}
else
{
echo 
"Sorry, there has been an error";
}
}



//Add wordpack
if($action=="addwordpack")
{
if(
$packname)
{
echo 
"Include file:<br>";
if(include (
$packname))
{

$insertPack=mysql_query($insertLines);

if(
$insertPack)
{
echo 
"the pack has been added successfully<br>";
}
else
{
echo 
"Sorry there has been an error<br>";
}
}
else
{
echo 
"Sorry, there has been a problem opening $packname. Check that you have uploaded it correctly and that you have typed in the name correctly.";
echo 
"
<br>
<form name=\"pack\" action=\"
$PHP_SELF\" method=\"get\">
<input name=\"packname\" type=\"text\" value=\"\">
<input name=\"action\" type=\"hidden\" value=\"addwordpack\">
<br>
<input type=\"submit\" value=\"Add\">
</form>
"
;
}
$rep "<br>(";
$insertLines ereg_replace("\("$rep$insertLines);
echo 
$insertLines;
}
else
{
echo 
"Type in the filename of the wordpack you want to add. (ie <i>internetpack.php</i>)";
echo 
"
<br>
<form name=\"pack\" action=\"
$PHP_SELF\" method=\"get\">
<input name=\"packname\" type=\"text\" value=\"\">
<input name=\"action\" type=\"hidden\" value=\"addwordpack\">
<br>
<input type=\"submit\" value=\"Add\">
</form>
"
;
}
}

//Help
if($action=="help")
{
echo 
"For up-to-date help, information and upgrades to MD Glossary, as well as other new programs to use on your website, visit <a href=\"http://www.matthewdingley.co.uk/programs/glossary/\" target=\"_blank\">MD Web</a>";
}

//Main menu
if($action=="main"||!$action)
{
echo 
"<a href=\"$PHP_SELF?action=add\">Add a word</a>&nbsp;&nbsp;&nbsp;<a href=\"$PHP_SELF?action=help\">Help</a><br><br>";
echo 
"You can also go to <a href=\"www.matthewdingley.co.uk/programs/news/\">MD Web</a> and download a wordpack. This will have loads of pre-done words for you to use. When you have downloaded the
word pack, click <a href=\"
$PHP_SELF?action=addwordpack\">here</a> to install it.";
$getWords=mysql_query("SELECT * FROM mdglossary ORDER BY word");
if(
$getWordArray=mysql_fetch_array($getWords))
{
echo 
"<table width=\"90%\" cellspacing=\"8\" cellpadding=\"0\">";
do
{
echo 
"
       <tr>
              <td>
           <dl>
           <dt><b>
           "
;
printf($getWordArray["word"]);
           echo 
"
           </b></dt>
           <dd>
           "
;
printf($getWordArray["definition"]);
           echo 
"
           </dd>
           </dl>
           </td>
           
           <td>
           <a href=\"
$PHP_SELF?action=edit&id=";
printf($getWordArray["id"]);
           echo 
"
           \">Edit</a>
           </td>
           
           <td>
           <a href=\"
$PHP_SELF?action=delete&id=";
printf($getWordArray["id"]);
           echo 
"
           \">Delete</a>
           </td>
           <td>
           <a href=\"
$PHP_SELF?action=getcode&id=";
printf($getWordArray["id"]);
           echo 
"
           \">Get&nbsp;code</a>
           </td>
        </tr>
"
;
}
while(
$getWordArray=mysql_fetch_array($getWords));
echo 
"</table>";
}
else
{
echo 
"<br><br>There are currently no words in the database. <a href=\"$PHP_SELF?action=add\">Add a word</a>";
}
}
if(
$action=="add"||$action=="edit"||$action=="delete"||$action=="getcode"||$action=="install"||$action=="addwordpack"||$action=="help")
{
echo 
"<br><br><a href=\"$PHP_SELF?action=main\">Main menu</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"$PHP_SELF?action=add\">Add a word</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"$PHP_SELF?action=help\">Help</a>";
}
?>
</body>
</html>
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 08:35 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.04141 seconds
  • Memory Usage 2,294KB
  • Queries Executed 13 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete