Getting the user's last post IP...
#1
Is it possible to get a user's last post IP via code?
Reply
#2
You've made similar thread before: http://community.mybb.com/thread-84074.html

If you want to get the User's IP in post then you can use this variable;
$post['ipaddress']
Reply
#3
(2011-05-10, 03:24 AM)Yaldaram Wrote: You've made similar thread before: http://community.mybb.com/thread-84074.html

If you want to get the User's IP in post then you can use this variable;
$post['ipaddress']
How exactly does the variable contain a certain users last IP?
Currently, my script only gets the user's last login IP by running a query...
Reply
#4
Where exactly you want to show the User's IP ? In post or any where else ?
Reply
#5
You can get the IP address from where a user has last posted with this code:
$query = $db->query("SELECT ipaddress FROM mybb_posts WHERE uid=1 ORDER BY dateline DESC LIMIT 1");
$lastpostip = $db->fetch_field($query, "ipaddress");
Of course you need to change the uid (now = 1) in the query to make it more dynamic. But you already have the users last ip, so I guess you know how to do that.
Reply
#6
This is what my script currently does:
1. Get the Users current IP. $_SERVER['REMOTE_ADDR'];
2. Run a DB Query getting a user's info.
$query = $db->query("SELECT username,postnum,usergroup,additionalgroups,lastip FROM mybb_users WHERE lastip='$ip'");
3. echo the info.
Currently, step 2 gets the users information based on their last login IP, I want it to get the information based on their last post IP. That way, the script only gets the information of active posting uesrs.
Reply
#7
Then try this:
$query = $db->query("SELECT u.username, u.postnum, u.usergroup, u.additionalgroups, p.ipaddress FROM ".TABLE_PREFIX."posts p INNER JOIN ".TABLE_PREFIX."users u ON p.uid = u.uid WHERE p.ipaddress='$ip' ORDER BY p.dateline DESC LIMIT 1");

Edit: replaced php with code tags to prevent the content from being stretched.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)