Fork me on GitHub

php121  Bottom

  • HI its not quite a module but i couldn;t find anywhere else to post this. I have php121 running on my site and would like it to auto login when the user logs in to postnuke. can some one tell me what file(s) I should add these functions too?

    Code

    function auto_121_login($uid)
    {
       global $db_usertable, $dbf_uid, $dbf_uname, $dbf_upassword, $dbf_user_chatting;

       $sql = "SELECT $dbf_uname, $dbf_upassword
          FROM $db_usertable
          WHERE $dbf_uid = $uid"
    ;

       $result=mysql_query($sql);
           
       $row = mysql_fetch_array($result);

       $username = $row["$dbf_uname"];
       $pass = $row["$dbf_upassword"];

       setcookie('php121un', $username, (time() + 2592000));
       setcookie('php121pw', substr($pass, 0, 9), (time() + 2592000));

       $sql = "UPDATE $db_usertable
          SET $dbf_user_chatting = "
    .time()."
          WHERE $dbf_uid = "
    .$uid;

       $result = mysql_query($sql);

       echo "<script language=\"JavaScript\">newwindow = window.open('./php121/php121im.php', 'name', 'height=400, width=200, left=20, top=20, toolbar=no, menubar=no, directories=no, location=no, scrollbars=no, status=no, resizable=yes, fullscreen=no'); if (newwindow.focus) {window.focus()};</script>";
    }

    function auto_121_logout()
    {
       global $db_usertable, $dbf_uid, $dbf_uname, $dbf_upassword, $dbf_user_chatting;
       
       $username = $_COOKIE['php121un'];
        $pass = $_COOKIE['php121pw'];

       $sql = "SELECT $dbf_uid, $dbf_upassword
          FROM $db_usertable
          WHERE $dbf_uname = '"
    . $username . "'";

       $result=mysql_query($sql);

       while($row = mysql_fetch_array($result))
       {
          if (substr($row["$dbf_upassword"], 0, 9) == $pass)
          {
             $uid = $row["$dbf_uid"];
          }
       }

       $sql = "UPDATE $db_usertable
          SET $dbf_user_chatting = 0
          WHERE $dbf_uid = $uid"
    ;

       $result=mysql_query($sql);
       
       setcookie('php121un', false);
        setcookie('php121pw', false);

       echo "<script language=\"JavaScript\">newwindow = window.open('', 'name'); newwindow.close();</script>";
    }
  • You could call this function from pnUserLogIn() /includes/pnUser.php just after the user was logged in.
  • but how would i call it, would have to use an include i spose but dont know how
  • You could hack pnUser.php like this:

    Before hack (line 117):

    Code

    // now we've logged in the permissions previously calculated are invalid
    $GLOBALS['authinfogathered'] = 0;
    }

    return true;


    After hack:

    Code

    // now we've logged in the permissions previously calculated are invalid
    $GLOBALS['authinfogathered'] = 0;

    include '121_login.php';

    auto_121_login($uid)
    }

    return true;


    That's assuming the file 121_login.php is in the same dir as the pnUser.php file.

    One other problem is the echo statement you're doing to add the script statement. I'm not sure if that's going to work. I think I would prefer using a user-variable and then display the script tag depending on the value of that user-var. You could easily do that in your theme-template if it's a Xanthia theme.

    By the way: what version are you running?

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