Location: PHPKode > projects > ProNuke. Postnuke To Oracle > postnuke/html/modules/NS-User/user.php
<?php

//
//
//



$ModName = basename( dirname( __FILE__ ) );
modules_get_language();


function user_user_userinfo($var)
{
    global $user, $cookie, $sitename, $pntable, $uid, $dbconn;
    /* cookie bug patched by kain, supergate, shockzor (www.kuht.it) (www.twlc.net) */
    $var['uname'] = strip_tags($var['uname']);
    $column = &$pntable['users_column'];
    $result = $dbconn->Execute("SELECT $column[femail] as femail, $column[url] as url, $column[bio] as bio, $column[user_avatar] as user_avatar, $column[user_icq] as user_icq, $column[user_aim] as user_aim, $column[user_yim] as user_yim, $column[user_msnm] as user_msnm, $column[user_from] as user_from, $column[user_occ] as user_occ, $column[user_intrest] as user_intrest, $column[user_sig] as user_sig, $column[uid] as uid, $column[pass] as pass FROM $pntable[users] WHERE $column[uname]='$var[uname]'");
    $userinfo = $result->GetRowAssoc(false);
    $result->MoveNext();
    if (!$var['bypass']) {
        cookiedecode($user);
    }
    include("header.php");
    OpenTable();
    echo "";
    if (($var['uname'] == $cookie[1]) AND ($userinfo['pass'] == $cookie[2])) {
        echo "<center><font class=\"pn-pagetitle\">$var[uname]</font></center><br>";
    }else{
        echo "<center><font class=\"pn-pagetitle\">$var[uname]</font></center><br>";
    }
    if (($result->PO_RecordCount()==1)
           && ($userinfo['url'] || $userinfo['femail'] || $userinfo['bio'] ||
               $userinfo['user_avatar'] || $userinfo['user_icq'] ||
               $userinfo['user_aim'] || $userinfo['user_yim'] ||
               $userinfo['user_msnm'] || $userinfo['user_location'] ||
               $userinfo['user_occ'] || $userinfo['user_intrest'] ||
               $userinfo['user_sig'] || $userinfo['uid']))
        {
        echo "<center><font class=\"pn-normal\">";
        $userinfo['user_sig'] = nl2br($userinfo['user_sig']);  // 07-06-2001:Alarion - moved this line from about 10 down. Made more sense up here
        if ($userinfo['user_avatar']) {
            echo "<img src=\"images/avatar/$userinfo[user_avatar]\" alt=\"\"><br>\n";
        }
        if ($userinfo['url']) {
            echo "<font class=\"pn-normal\">"._MYHOMEPAGE." <a class=\"pn-normal\" href=\"$userinfo[url]\">$userinfo[url]</a><br></font>\n";
        }
        if ($userinfo['femail']) {
            echo "<font class=\"pn-normal\">"._MYEMAIL." <a class=\"pn-normal\" href=\"mailto:$userinfo[femail]\">$userinfo[femail]</a><br></font>\n";
        }
        if ($userinfo['user_icq']) {
            echo "<font class=\"pn-normal\">"._ICQ.": $userinfo[user_icq]<br></font>\n";
        }
        if ($userinfo['user_aim']) {
            echo "<font class=\"pn-normal\">"._AIM.": $userinfo[user_aim]<br></font>\n";
        }
        if ($userinfo['user_yim']) {
            echo "<font class=\"pn-normal\">"._YIM.": $userinfo[user_yim]<br></font>\n";
        }
        if ($userinfo['user_msnm']) {
            echo "<font class=\"pn-normal\">".MSNM.": $userinfo[user_msnm]<br></font>\n";
        }
        if ($userinfo['user_from']) {
            echo "<font class=\"pn-normal\">"._LOCATION.": $userinfo[user_from]<br></font>\n";
        }
        if ($userinfo['user_occ']) {
            echo "<font class=\"pn-normal\">"._OCCUPATION.": $userinfo[user_occ]<br>\n";
        }
        if ($userinfo['user_intrest']) {
            echo "<font class=\"pn-normal\">"._INTERESTS.": $userinfo[user_intrest]<br></font>\n";
        }
        if ($userinfo['user_sig']) {
            echo "<font class=\"pn-normal\"><br>"._SIGNATURE.":<br>$userinfo[user_sig]<br></font>\n";
        }
        if ($userinfo['bio']) {
            echo "<font class=\"pn-normal\"><br>"._EXTRAINFO.":<br>$userinfo[bio]<br></font>\n";
        }
        $column = &$pntable['session_column'];

        //FTO Test IS NULL for anonymous user (oracle)

        $query  = "SELECT $column[username] FROM $pntable[session]WHERE $column[username]='$var[uname]'";
        if (empty($var[uname]))
           { $query .= " OR $column[username] IS NULL";}
           
        $result = $dbconn->Execute($query);
        
        
        list($username) = $result->fields;
        if ($username == "") {
            $online = _OFFLINE;
        } else {
            $online = _ONLINE;
        }
                echo ""._REGISTEREDUSER." $userinfo[uid]";
        if ((is_user($user)) && ($var['uname'] != $cookie[1])) {
            echo "<br>"._USERSTATUS.": $online<br>\n";
            echo "<br>[ <a class=\"pn-normal\" href=\"modules.php?op=modload&amp;name=Messages&amp;file=replypmsg&amp;send=1&amp;uname=$var[uname]\">"._USENDPRIVATEMSG." $var[uname]</a> ]<br>\n";
        }
        echo "</font></center>";
    } else {
        echo "<center><font class=\"pn-normal\">"._NOINFOFOR." $uname</font></center>";
    }
    CloseTable();
    echo "<center><br><br>";
    user_main_last10com($var[uname]);
    echo "<br>";
    user_main_last10submit($var[uname]);
    echo "</center>";
    include("footer.php");
}

function user_user_login($var) {
        access_user_login($var['uname'],$var['pass'],$var['url']);

}

 function user_user_getlogin() {
      global $stop,$minage;
        include("header.php");
      OpenTable();
       if ($stop) {
            echo "<center><font class=\"pn-title\">"._LOGININCOR."</font></center>\n";
        } else {
            echo "<center><font class=\"pn-title\">"._USERREGLOGIN."</font>\n"
                ."</center><br><font class=\"pn-title\">";

            echo ""._SELECTOPTION."<br><br>"
                ."<a href=\"user.php?op=loginscreen&amp;module=NS-User\">"._LOGINSITE."</a><br><br>";

    // age will not be checked, if $minage is set to 0 in config.php
        if ($minage==0) {
              echo "<a href=\"user.php?op=register&amp;module=NS-NewUser\">"._REGISTER."</a><br><br>";
        } else {
            echo "<a href=\"user.php?op=check_age&amp;module=NS-NewUser\">"._REGISTER."</a><br><br>";
        }

            echo "<a href=\"user.php?op=lostpassscreen&amp;module=NS-LostPassword\">"._RETRIEVEPASS."</a><br></font>";

        }

        CloseTable();
        echo "<br>\n";
        include ("footer.php");
 }

function user_main_last10com($uname) {
global $pntable, $dbconn;
OpenTable();
    echo "<font class=\"pn-title\">"._LAST10COMMENTS." $uname:</font><br>";
    $column = &$pntable['comments_column'];
    $myquery = buildSimpleQuery('comments', array ('tid', 'sid', 'subject'), "$column[name]='$uname'", "$column[tid] DESC", 10);
    $result = $dbconn->Execute($myquery);
// FTO Check EOF and databse error
    if (!$result) {
               PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
               die();
            }
    while(!$result->EOF) {

        list($tid, $sid, $subject) = $result->fields;

        $result->MoveNext();
        echo "<li><a class=\"pn-normal\" href=\"modules.php?op=modload&amp;name=News&amp;file=article&amp;thold=-1&amp;mode=flat&amp;order=0&amp;sid=$sid#$tid\">$subject</a><br>";
    }
    CloseTable();
    echo "<br>";
}

function user_main_last10submit($uname) {
    global $pntable,$dbconn;

    $myts = new MyTextSanitizer;
    global $typocode;
    $myts->typeCoding = $typocode;
    OpenTable();
    echo "<font class=\"pn-title\">"._LAST10SUBMISSIONS." $uname:</font><br>";
    $column = &$pntable['stories_column'];
    $myquery = buildSimpleQuery('stories', array ('sid', 'title'), "$column[informant]='$uname'", "$column[sid] DESC", 10);
    $result = $dbconn->Execute($myquery);
// FTO Check EOF and databse error
    if (!$result) {
          PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
          die();
    }
    while(!$result->EOF) {

        list($sid, $title) = $result->fields;

        $result->MoveNext();
        If (!$title)  {
            $title = '- no Title -' ;
        } else {
            $title = $myts->makeTboxData4Show($title);
        }
        echo "<li><a class=\"pn-normal\" href=\"modules.php?op=modload&name=News&file=article&sid=$sid\">$title</a><br>";
    }
    CloseTable();

    unset($myts);
}


// View main user page
// ====================
function user_user_main($var)
{
    global $user;
    include 'header.php';
    user_menu_draw();
    $userinfo = getusrinfo($user);
    user_main_last10com($userinfo['uname']);
    user_main_last10submit($userinfo['uname']);
    //user_main_automated();
    //user_main_article();
    //user_main_poll();
    include 'footer.php';
}

function user_user_loginscreen()
{
    include("header.php");
    OpenTable();
    echo "<form action=\"user.php\" method=\"post\">\n"
        ."<font class=\"pn-title\">"._USERLOGIN."</font><br><br>\n"
        ."<table border=\"0\"><tr><td>\n"
        ."<font class=\"pn-normal\">"._NICKNAME.": </font></td><td><input type=\"text\" name=\"uname\" size=\"26\" maxlength=\"25\"></td></tr>\n"
        ."<tr><td><font class=\"pn-normal\">"._PASSWORD.": </font></td><td><input type=\"password\" name=\"pass\" size=\"21\" maxlength=\"20\"></td></tr></table>\n"
        ."<input type=\"hidden\" name=\"url\" value=\"".getenv("HTTP_REFERER")."\">\n";
        user_submit('NS-User','login',_LOGIN);
    echo "</form>\n";
    CloseTable();
    echo "<br>";
    include("footer.php");
}

function user_user_logout($var)
{
    global $pntable, $user, $dbconn;

    csrfcheck();

    // eugeniobaldi 08-31-2001 - Error 456499 Error in reload
    if (is_user($user))   {                  
        $userinfo = getusrinfo($user);
        setcookie("user", "", time() - 3600);
        $column = &$pntable['session_column'];
        $sql = "DELETE FROM $pntable[session] WHERE $column[username]='$userinfo[uname]'";
        // Alarion 07-04-2001 - delete user entry from session table when logging out
        $result = $dbconn->Execute($sql);
        if($dbconn->ErrorNo()<>0) {
          error_log ("error updating session table: " . $dbconn->ErrorMsg());
        }
    }
    unset ($user);

    redirect_index(_YOUARELOGGEDOUT);
}
?>
Return current item: ProNuke. Postnuke To Oracle