Portal   Forum   Members   Market   Gallery   Events

vB masters - how can I...

Discussion in 'Help Forum' started by KroeT, Nov 25, 2002.

  1. KroeT

    KroeT Peasant

    Joined:
    Jun 7, 2001
    Messages:
    659
    Likes Received:
    0
    Market Rating:
    0
    Integrate VB Security To Non-VB Page?


    require admin/global.php etc doesn't work, pages show up blank :/
     
  2. Jakeman

    Jakeman MSC Founder and Donator

    Joined:
    Feb 26, 2000
    Messages:
    25,759
    Likes Received:
    27
    Market Rating:
    16
    what type of security? what do you want it to check? as an example, here is my msc clan script's code for the clan server section:

    PHP:
    <?

    require (
    "./global.php");

    if (
    $bbuserinfo[usergroupid]==16) {
        eval(
    "\$claninfo = \"".gettemplate("claninfo")."\";");
    } else if (
    $bbuserinfo[usergroupid]==6) {
        eval(
    "\$claninfo = \"".gettemplate("claninfo")."\";");
    } else if (
    $bbuserinfo[usergroupid]==36) {
        eval(
    "\$claninfo = \"".gettemplate("claninfo")."\";");
    } else if (
    $bbuserinfo[usergroupid]==5) {
        eval(
    "\$claninfo = \"".gettemplate("claninfo")."\";");
    } else {
        eval(
    "\$claninfo = \"".gettemplate("claninfo_deny")."\";");
    }

    eval(
    "dooutput(\"".gettemplate("clan")."\");");

    ?>
    i use $claninfo in my clan template. if you are logged in and are an admin, mod or member of the clan member user group then you can see the server, else it gets the claninfo_deny template which says "you don't have access." or you can just use vB's no permission function to display a generic "no permission" page (which has a login form on it):

    PHP:
    shownopermission();
    the $bbuserinfo array contains several pieces of information about the logged in user that you can check for.
     
  3. KroeT

    KroeT Peasant

    Joined:
    Jun 7, 2001
    Messages:
    659
    Likes Received:
    0
    Market Rating:
    0
    I've created a database for targets (yeah, it's a game-site). People can input their targets, script saves it in a database, etc etc. It's still not quite integrated in the forums yet, because the code isn't quite done. I will integrate it in a week or so, using the templates like you mentioned above, but till then I'd like to do something like

    PHP:
    require ("./global.php");
    at the top of every custom php file (input.php for instance). They're custom php files with crappy code, but I'd like them to be invisible for people who aren't logged in, or show a nopermission thingy (which you used in your example).

    At the forums, I can use $bbuserinfo[age] to show the age of the person who's viewing the page (I know, useless, but it's just an example). I figured that requiring global.php in the code enables the possibility to do so as well, but it also requires templates to be used, and I just want to use the code baked into the php file for now :)

    I know, I'm an idiot :)
     
  4. Jakeman

    Jakeman MSC Founder and Donator

    Joined:
    Feb 26, 2000
    Messages:
    25,759
    Likes Received:
    27
    Market Rating:
    16
    requiring global.php from the forum directory will make that script connect to the forum database. you are using a different database and i don't know how to connect to two different dbs at once. when i do custom stuff i just create a new table in my vB database.
     
  5. KroeT

    KroeT Peasant

    Joined:
    Jun 7, 2001
    Messages:
    659
    Likes Received:
    0
    Market Rating:
    0
    Ehm, yeah... sorry :). I am using a different table in the same database, but I forgot to mention :)

    When I require global.php it asks for templates, because the page stays empty. The script has 2 templates, in the templates dir (old skool :P), and also has some html in between the php code. How can I implement this? Turn every bit of php code into variables and place those in the html templates in vbulletin?
     
  6. Jakeman

    Jakeman MSC Founder and Donator

    Joined:
    Feb 26, 2000
    Messages:
    25,759
    Likes Received:
    27
    Market Rating:
    16
    i put together this "explanation" file for another guy a while ago. this is a basic vB integrated file that uses templates and variables in the templates that parse into other templates. you can only have one of the last "eval dooutput" line. if you want to piece together multiple templates then you need eval templates to variables.

    a good example is my MSC Clan page. the clan servers are in a separate template. depending on the user group of the logged in user, the variable parses to either the template that shows the clan servers or the template that says you don't have access.

    PHP:
    <?php

    //use this line if the php file is outside of the forum directory.
    //this makes it so the php file is executed from the forum directory
    //when run from a browser
    //so you can include (global.php) without any problems
    chdir('/full/server/path/to/forum/directory');

    //must include the global.php file from the forum directory
    include("global.php");

    //the variable called "$variable" is parsed into the template
    //called "template1"
    //you can use $variable in the "template3" template
    //and "template1" will be output where the variable is
    eval("\$variable = \"".gettemplate('template1')."\";");

    //this statement adds to the value of $variable2 . this is how all
    //the "bit" templates work in vbulletin.
    //showthread is a good example, it adds all the html for the posts
    //into one variable and then outputs it all.
    //the "." in front of the equals sign is what adds to the value of
    //the variable.
    //this is usually used in while loops that get a data from multiple
    //rows and stuff.
    eval("\$variable2 .= \"".gettemplate('template2')."\";");

    //outputs contents of the template called "template3" when this
    //file is run from the browser
    eval("dooutput(\"".gettemplate("template3")."\");");

    ?>
     
  7. KroeT

    KroeT Peasant

    Joined:
    Jun 7, 2001
    Messages:
    659
    Likes Received:
    0
    Market Rating:
    0
    Thx m8, that helped me a lot :). It's working now, sort of ;). Busy week, but working nonetheless.
     

Hitometer: 53,932,355 since 1995