Fork me on GitHub

Using external scripts with pn data  Bottom

  • I want to have an external script (totaly external from postnuke) which still requires users to be logged in and uses the pnAPI.

    What do I need to include into this external script so that the following code will work? pnUserLoggedIn() function in particular.

    Code

    // Show information for logged in user
    if (pnUserLoggedIn()) {
      $name = pnUserGetVar('name');
      if (isset($name)) {
        echo "Welcome to the site, $name";
      }
    }
  • SO it's not going to be in the pnFrame at all? You need to include the pnapi.php for sure.

    --
    Home Page | Find on Facebook | Follow on Twitter
  • At root (but not very secure)

    Code

    <?php

    include 'includes/pnAPI.php";
    pnInit();

    if (pnUserLoggedIn()) {

        $username = pnUserGetVar('
    uname');

        echo "Hi ".pnVarPrepForDisplay($username)." dude... And Welcome!!";

    } else {

        echo "Booou... !";

    }

    ?>


    ;)
  • Thanks Chestnut...

    I did have this script in a seperate folder including the pnAPI.php, I moved it to the PN-root folder (/html), however, I still get the following error
    -------
    Warning: Division by zero in /home/avalonse/public_html/html/test.php on line 3

    Warning: main(PHP): failed to open stream: No such file or directory in /home/avalonse/public_html/html/test.php on line 3

    Warning: main(): Failed opening 'PHP' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/avalonse/public_html/html/test.php on line 3

    Fatal error: Call to undefined function: pninit() in /home/avalonse/public_html/html/test.php on line 4
    -------
    Line 3 is > include 'includes/pnAPI.php";
    Line 4 is > pnInit();

    obviously pnAPI.php doesn't like being included here for some reason beyond my comprehension.
  • is there another option of reading the user's cookie to find their user ID and then trace it back to their details in the DB?

    I notice the session ID is encrypted however, probably to prevent doing things like this.
  • If you copy and paste, it should work, I have 3 or 4 like these... the problem is probably what is in your script or where you put it.
    ;)
  • 0 users

This list is based on users active over the last 60 minutes.