● Some Coding Help??

Mon Oct 03, 2016 7:48 am
NOOB!!!
37 Posts
Reputation: 256.6
I'm messing around with a chat program.

PHP:  [ Select all ]

if(USER_IS_LOGGED_IN)

 
   $ses LOGGED_IN_USERID//tell freichat the userid of the current user

 
   setcookie("freichat_user""LOGGED_IN"time()+3600"/"); // *do not change -> freichat code
}
else {
 
   $ses null//tell freichat that the current user is a guest

 
   setcookie("freichat_user"nulltime()+3600"/"); // *do not change -> freichat code

 
How do set the if(USER_IS_LOGGED_IN)??
And how would I pull the user_id from database?

Ive been banging my head on this simple (I'm sure) code.....
Mon Oct 03, 2016 9:55 am
Clan Leader
Top Dog
Nuke Dev / Coder
3015 Posts
coRpSE
Currently Offline
Offline

Most Played:
This week: 77.7hrs.
Total Played: 195hrs.


  
There is life outside of the game.
Reputation: 7317.9
votes: 7
Are you looking for username or their id?

because if you're looking for username, then you can do this,

PHP:  [ Select all ]

global $userinfo;

if(
is_user())

 
   $ses $userinfo['username']; //tell freichat the userid of the current user

 
   setcookie("freichat_user""LOGGED_IN"time()+3600"/"); // *do not change -> freichat code
}
else {
 
   $ses null//tell freichat that the current user is a guest

 
   setcookie("freichat_user"nulltime()+3600"/"); // *do not change -> freichat code

 
Now, if its for the user id number, then it would be like this.

PHP:  [ Select all ]

global $userinfo;

if(
is_user())

 
   $ses $userinfo['user_id']; //tell freichat the userid of the current user

 
   setcookie("freichat_user""LOGGED_IN"time()+3600"/"); // *do not change -> freichat code
}
else {
 
   $ses null//tell freichat that the current user is a guest

 
   setcookie("freichat_user"nulltime()+3600"/"); // *do not change -> freichat code

 
You do need to make sure you have that global. Mind you, this will only work if the rest of the system is integrated with the Evo CMS so you can use the globals.


Expand
Mon Oct 03, 2016 11:34 am
Original Poster
NOOB!!!
37 Posts
Reputation: 256.6
Hey bud.  I do believe that got it working. Super Need to get some users on to test it, lol... It will actually pull the user's avatar also if I can figure that out..


 
Mon Oct 03, 2016 12:19 pm
Clan Leader
Top Dog
Nuke Dev / Coder
3015 Posts
coRpSE
Currently Offline
Offline

Most Played:
This week: 77.7hrs.
Total Played: 195hrs.


  
There is life outside of the game.
Reputation: 7317.9
votes: 7
that's not hard,

again, it would be just using the global of userinfo.

Something like this should work.

PHP:  [ Select all ]

$userinfo['user_avatar']; 


Now, if I wanted to make it so all I needed to do is put a variable like $avatar in a certain place, then I would write it like this.

PHP:  [ Select all ]

global $userinfo;
if(
is_user()){ 

 
$avatar_image $userinfo['user_avatar']; 
 
   if (!empty($avatar_image)){
        
$avatar "./modules/Forums/images/avatars/".$avatar_image;
    }else{
        
$avatar "./modules/Forums/images/avatars/blank.gif"
    }

 
the way that is designed is if they are a user, it will check to see if the the avatar is empty, if its not, then it will show their avatar image. Now, if it is empty, it will show the avatar blank.gif. Of course, your going to want to make sure you have a blank.gif avatar. Like this one here is mine,
Expand

Pretty much that's how I would do it, and now, if I wanted to display that image anywhere on that page I have that coding on, all I would do is this.
I would place this code where I wanted to display the avatar,

PHP:  [ Select all ]

echo '<img src="'.$avatar.'" style="max-width: 80px; max-height: 80px;" alt="">'

 
As you can see, I used a max width and a max height instead of setting a width and height because overall, by doing it this way it will not distort the image in any way. That of course would have to be adjusted to the size of the avatar you want to be shown.

And that's it, hope this helps.


 
Mon Oct 03, 2016 12:40 pm
Original Poster
NOOB!!!
37 Posts
Reputation: 256.6
There's a file called hardcode.php which handles all the sql db info.  It asks for a table and column where the avatar url is stored. I don't know if this is possible or if i would have to find where it sets the variable and code it with the path manually...

PHP:  [ Select all ]

/* Custom driver */
$usertable='nuke_users'//specifies the name of the table in which your user information is stored.
$row_username='username'//specifies the name of the field in which the user's name/display name is stored.
$row_userid='user_id'//specifies the name of the field in which the user's id is stored (usually id or userid)


$avatar_table_name='nuke_users'//specifies the table where avatar information is stored
$avatar_column_name='user_avatar'//specifies the column name where the avatar url is stored
$avatar_userid='user_id'//specifies the userid  to the user to get the user's avatar
$avatar_reference_user='username'//specifies the reference to the user to get the user's avatar in user table 
$avatar_reference_avatar='username'//specifies the reference to the user to get the user's avatar in avatar
$avatar_field_name=$avatar_column_name//to avoid unnecessary file changes , *do not change 

 
Obviously what I have set for the avatar is not correct, lol...


 
Forums ©