View Single Post
  #1 (permalink)  
Old 03-05-2003, 06:31 PM
Elite311 Elite311 is offline
Junior Member
 
Join Date: Mar 2003
Posts: 11
Need Help making with my user block
I have been tryin to edit my user block myself and make it work but i really am not good with php at all. I was wondering if some could lend a hand editing some code. I have a user block different then this site with phpbb ported forums but the user block i have doesn't display if you have private messages proporly. I would really appreciate if someone could fix the block i have.

Code:
<?php
if (eregi("block-block-User_Info.php",$PHP_SELF)) { Header("Location: index.php"); }
$content = "";
global $user, $cookie, $prefix, $user_prefix, $dbi, $anonymous;
cookiedecode($user);
$username = $cookie[1];

$result = sql_query("select uname from $user_prefix"._users." order by uid DESC limit 0,1", $dbi);
list($lastuser) = sql_fetch_row($result, $dbi);
$numrows = sql_num_rows(sql_query("select uid from $user_prefix"._users."", $dbi), $dbi);
$result2 = sql_query("SELECT uname,guest FROM $prefix"._session." where guest=0", $dbi);
$member_online_num = sql_num_rows($result2, $dbi);
$who_online_now = "";
$i = 1;
while ($session = sql_fetch_array($result2, $dbi)) {
    if (isset($session["guest"]) and $session["guest"] == 0) {
        if ($i < 10) {
            $who_online_now .= "0$i:<A HREF=\"modules.php?name=Your_Account&amp;op=userinfo&amp;uname=$session[username]\">$session[username]</a>
\n";
        } else {
            $who_online_now .= "$i:<A HREF=\"modules.php?name=Your_Account&amp;op=userinfo&amp;uname=$session[username]\">$session[username]</a>
\n";
        }
        $who_online_now .= ($i != $member_online_num ? "  " : "");
        $i++;
    }
}
$Today = getdate();
//Formatting Current Date
$month = $Today['month'];
$mday = $Today['mday'];
$year = $Today['year'];
//Formatting Previous Date
$pmonth = $Today['month'];
$pmday = $Today['mday'];
$pmday = $mday-1;
$pyear = $Today['year'];
//Month conversion into numeric mode
if ($pmonth=="January") { $pmonth=1; } else
if ($pmonth=="February") { $pmonth=2; } else
if ($pmonth=="March") { $pmonth=3; } else
if ($pmonth=="April") { $pmonth=4; } else
if ($pmonth=="May") { $pmonth=5; } else
if ($pmonth=="June") { $pmonth=6; } else
if ($pmonth=="July") { $pmonth=7; } else
if ($pmonth=="August") { $pmonth=8; } else
if ($pmonth=="September") { $pmonth=9; } else
if ($pmonth=="October") { $pmonth=10; } else
if ($pmonth=="November") { $pmonth=11; } else
if ($pmonth=="December") { $pmonth=12; };
$test = mktime (0,0,0,$pmonth,$pmday,$pyear,1);

//Creating SQL parameter
$curDate2 = "%".$month[0].$month[1].$month[2]."%".$mday."%".$year."%";
$preday = strftime ("%d",$test);
$premonth = strftime ("%B",$test);
$preyear = strftime ("%Y",$test);
$curDateP = "%".$premonth[0].$premonth[1].$premonth[2]."%".$preday."%".$preyear."%";

//Executing SQL Today
$result2 = sql_query("SELECT COUNT(UID) AS userCount from $user_prefix"._users." WHERE user_regdate LIKE '$curDate2'", $dbi);
list($userCount) = sql_fetch_row($result2, $dbi);
//end

//Executing SQL Today
$result3 = sql_query("SELECT COUNT(UID) AS userCount from $user_prefix"._users." WHERE user_regdate LIKE '$curDateP'", $dbi);
list($userCount2) = sql_fetch_row($result3, $dbi);
//end

$result = sql_query("SELECT uname FROM ".$prefix."_session where guest=1", $dbi);
$guest_online_num = sql_num_rows($result, $dbi);

$result = sql_query("SELECT uname FROM ".$prefix."_session where guest=0", $dbi);
$member_online_num = sql_num_rows($result, $dbi);

$who_online_num = $guest_online_num + $member_online_num;
$content .= "<form action=\"modules.php?name=Your_Account\" method=\"post\">";

if (is_user($user)) {
    $content .= "
<img src=\"images/blocks/group-4.gif\" height=\"14\" width=\"17\"> "._BWEL.", $username.
\n<hr>\n";
    $result = sql_query("select uid from $user_prefix"._users." where uname='$username'", $dbi);
    list($uid) = sql_fetch_row($result, $dbi);
    $result2 = sql_query("select to_userid from $prefix"._priv_msgs." where to_userid='$uid' and read_msg='0'", $dbi);
    $newpms = sql_num_rows($result2, $dbi);
    $result3 = sql_query("select to_userid from $prefix"._priv_msgs." where to_userid='$uid' and read_msg='1'", $dbi);
    $oldpms = sql_num_rows($result3, $dbi);
    $content .= "<img src=\"images/blocks/email-y.gif\" height=\"10\" width=\"14\"> <a href=\"modules.php?name=Private_Messages\">"._BPM."</a>
\n";
    $content .= "<img src=\"images/blocks/email-r.gif\" height=\"10\" width=\"14\"> "._BUNREAD.": $newpms
\n";
    $content .= "<img src=\"images/blocks/email-g.gif\" height=\"10\" width=\"14\"> "._BREAD.": $oldpms
\n<hr>\n";
} else {
    $content .= "<img src=\"images/blocks/group-4.gif\" height=\"14\" width=\"17\"> "._BWEL.", $anonymous\n<hr>";
    $content .= ""._NICKNAME." <input type=\"text\" name=\"uname\" size=\"10\" maxlength=\"25\">
";
    $content .= ""._PASSWORD." <input type=\"password\" name=\"pass\" size=\"10\" maxlength=\"20\">
";
    $content .= "<input type=\"hidden\" name=\"op\" value=\"login\">";
    $content .= "<input type=\"submit\" value=\""._LOGIN."\">\n (<a href=\"modules.php?name=Your_Account&amp;op=new_user\">"._BREG."</a>)<hr>";
}
$content .= "<img src=\"images/blocks/group-2.gif\" height=\"14\" width=\"17\"> <u>"._BMEMP.":</u>
\n";
$content .= "<img src=\"images/blocks/ur-moderator.gif\" height=\"14\" width=\"17\"> "._BLATEST.": <A HREF=\"modules.php?name=Your_Account&amp;op=userinfo&amp;uname=$lastuser\">$lastuser</a>
\n";
$content .= "<img src=\"images/blocks/ur-author.gif\" height=\"14\" width=\"17\"> "._BTD.": $userCount
\n";
$content .= "<img src=\"images/blocks/ur-admin.gif\" height=\"14\" width=\"17\"> "._BYD.": $userCount2
\n";
$content .= "<img src=\"images/blocks/ur-guest.gif\" height=\"14\" width=\"17\"> "._BOVER.": $numrows
\n<hr>\n";
$content .= "<img src=\"images/blocks/group-3.gif\" height=\"14\" width=\"17\"> <u>"._BVISIT.":</u>\n
\n";
$content .= "<img src=\"images/blocks/ur-anony.gif\" height=\"14\" width=\"17\"> "._BVIS.": $guest_online_num
\n";
$content .= "<img src=\"images/blocks/ur-member.gif\" height=\"14\" width=\"17\"> "._BMEM.": $member_online_num
\n";
$content .= "<img src=\"images/blocks/ur-registered.gif\" height=\"14\" width=\"17\"> "._BTT.": $who_online_num
\n";
if ($member_online_num > 0) {
    $content .= "<hr>\n<img src=\"images/blocks/group-1.gif\" height=\"14\" width=\"17\"> <u>"._BON.":</u>
$who_online_now";
}
$content .= "</form>";

?>
Reply With Quote