View Single Post
  #8  
Old 04-27-2009, 03:20 PM
Bloodrun's Avatar
Bloodrun Bloodrun is offline
I am, who I am.
 
Join Date: Apr 2009
Posts: 532
Gender: Male
Credits: 29,674
Bloodrun
Send a message via Yahoo to Bloodrun
Default RE: Some very cool add-ons

Update!

There is a slight problem with this code. And that is, if a person does not hit the log-out button, it will continue to say that the person is online. Until he/she logs in again, in which it will say he/she is offline, until the Next time they log on.

So a little diaphram to help you understand that:

First Login, (does not log off)
-Is Online.
Second Login (it doesnt matter if he/she logs off or not)
-Offline.
Third Login (has to log off so the cycle doesnt repeat)
-Is Online (when they are actually online)

Now there is a solution to this problem. But it isn't has "Professional" as the first.

If you don't want to go through all this work, to end up with this possible broken cycle, all you have to do insert the following, in your account.php, accountpost.php, and profile.php: Note: You will need the same Database entry as in the first one, so use that one.

account.php
Find where it says:
PHP Code:

$query 
"SELECT * FROM ".$prefix."users WHERE username='$loggedinname'";
$result mysql_query($query);
$num mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) { 
And place the following:
Under the first group:
PHP Code:
$status=@mysql_result($result,$i,"status"); 
Under the second group:
PHP Code:
$status stripslashes($status); 
Then find where it says:
PHP Code:
<form name='form1' method='post' action='accountpost.php'>
  <
p>".$box."
  
Notify me via email when I receive a new message or reward code</p>
  <
p><u>Publically Viewable Details: </u></p
And place the following anywhere within that form:
PHP Code:
  <p>Status:
    <
select name='status' id='status'>
<
option value='none'>None</option>
<
option value='online'>Online!</option>
<
option value='offline'>Offline!</option>
<
option value='busy'>Busy!</option>
<
option value='away'>Away!</option>
</
select>
</
p
Note: you can add more, I made it short so you can get the gist of it. You can also add pictures to each one. You can do pretty much anything with it.

accountpost.php
Find where it says:
PHP Code:
// We are changing the settings

$newmsgnotify $_POST["newmsgnotify"];
$newmsgnotify preg_replace("/[^a-zA-Z0-9@._-]/"""$newmsgnotify);
$newmsgnotify secure($newmsgnotify); 
Then place this uner it:
PHP Code:
$status $_POST["status"];
$status secure($status); 
Then find where it says:
PHP Code:
// Run update queries...

$query "UPDATE ".$prefix."users SET newmessagenotify='".$newmsgnotify."' WHERE username='".$loggedinname."'";
mysql_query($query); 
And place this under it:
PHP Code:
$query "UPDATE ".$prefix."users SET status='".$status."' WHERE username='".$loggedinname."'";
mysql_query($query); 
profile.php
Find where it says:
PHP Code:
    $query "SELECT * FROM ".$prefix."users WHERE username = '".$user."'";
    
$result mysql_query($query);
    
$num mysql_numrows($result);

    if(
$num 0){

    
$i=0;
    while (
$i 1) { 
Place this under it:
PHP Code:
    $status=@mysql_result($result,$i,"status"); 
Then find where it says:
PHP Code:
    $ccstat cancp($usersgroup);
    if(
$ccstat == "yes"){
    
$userdisp "<img src='templates/icons/star.gif'> ".$usersname."";
    }
    else{
    
$userdisp $usersname;
    } 
And place this
PHP Code:
    if($status == "none") {
    
$userdisp "".$usersname."'s Profile:";
    }
    elseif(
$status == "online") {
    
$userdisp "".$usersname."'s Profile: Online Status: <b>Online!</b>";
    }
    elseif(
$status == "offline") {
    
$userdisp "".$usersname."'s Profile: Online Status: <b>Offline!</b>";
    }
    elseif(
$status == "busy") {
    
$userdisp "".$usersname."'s Profile: Online Status: <b>Busy!</b>";
    }
    elseif(
$status == "away") {
    
$userdisp "".$usersname."'s Profile: Online Status: <b>away!</b>";
    } 
Then find where it says:
PHP Code:
    $article_title $userdisp."'s Profile:"
And change it to:
PHP Code:
    $article_title "$userdisp"
Like I said this is just the very least you can do with the code. There is so much you can do with it. Who knows, maybe Ill bring in something else. =D
Reply With Quote