MyBB Community Forums

Full Version: What's the code for Users ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to get result of users with their formated username and print out the data of those in a separate file.

e.g. Finding out the IP of any member we use this code
$ip = $_SERVER['REMOTE_ADDR'];

I want similar kind of thing but for mybb users.

like this.

$user = ???

Can any one help me out Rolleyes ?
(2009-08-25, 03:01 AM)ghazal Wrote: [ -> ]I want to get result of users with their formated username and print out the data of those in a separate file.

Going from this, you just need to make an SQL query with the variables you're looking for. For example, for a specific user:

$db->simple_select("users", "uid, username, usergroup, displaygroup, lastip", "uid = '1000'");

For a selection of users that have visited in the last 7 days:

$threshold = TIME_NOW - 604800; // 7 days
$query = $db->simple_select("users", "uid, username, usergroup, displaygroup, lastip", "lastvisit >= '".$threshold."'");

while($user = $db->fetch_array($query))
{
	// Loop-de-loop
}

The code to format users in that loop would be:

$formatted_name = format_name($user['username'], $user['usergroup'], $user['displaygroup']);

The 'lastip' column in the user table is the best method to get a user's IP address. You can also use:

$ipaddress = $mybb->session->ipaddress;
Excellent..!

One more thing, I maked an script that trace the users appearance and occurance in the whole forum, and print out the data in a separate .html or .txt file.

That is written below;

$ip = $_SERVER['REMOTE_ADDR'];
$date = date("d-m-y / H:i:s");
$combine = $date . " - " . $ip . "<br />";
$fopen = fopen("file_name.html", "a");
fwrite($fopen, $combine);
fclose($fopen);

I have to ask can you please enter the required feilds in order to get the user with formated username in the above php code. So that the output values are some thing like this.

Username - IP - Date

Thanks for your assistence.
$ip = $mybb->session->ipaddress;
$date = my_date("", $mybb->settings['dateformat']).", ".my_date("", $mybb->settings['timeformat']); // Current time to MyBB's format
$user_info = format_name($mybb->user['username'], $mybb->['usergroup'], $mybb->['displaygroup']);
$combine = $user_info." &raquo; ".$date." - ". $ip."<br />";
$fopen = fopen("file_name.html", "a");
fwrite($fopen, $combine);
fclose($fopen);

Also, see the MyBB Forum rules: http://community.mybboard.net/thread-55227.html

This isn't MyBB support. Please review the "consequences" section and please, in future, post in the right section.
I tested it, It produces this parse error

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `'{'' or `'$'' in C:\wamp\www\test\global.php on line 4

Huh

I add that code to global.php page so that all pages will be trace.
$ip = $mybb->session->ipaddress;
$date = my_date("", $mybb->settings['dateformat']).", ".my_date("", $mybb->settings['timeformat']); // Current time to MyBB's format
$user_info = format_name($mybb->user['username'], $mybb->user['usergroup'], $mybb->user['displaygroup']);
$combine = $user_info." &raquo; ".$date." - ". $ip."<br />";
$fopen = fopen("file_name.html", "a");
fwrite($fopen, $combine);
fclose($fopen);

That should be good. Missed a user variable.

I wouldn't add it so high up in global.php, I'd add it near the end if anything - simply because $mybb and $session haven't been initiated until mid-way through this file.
Now its an error in ine number 407
Parse error: parse error, expecting `']'' in C:\wamp\www\test\global.php on line 407

This line code is this

WHERE pm.folder='1' AND pm.uid='{$mybb->user['uid']}' AND pm.status='0'
Sorry for bump it. Big Grin
That line looks fine Ghazal, there must be something before that... can you post that entire query?
Whoops. That's solved. Thanks TommM Heart