--- troll.module	2007-03-08 23:07:32.000000000 +0800
+++ troll.module	2008-03-12 18:32:15.000000000 +0800
@@ -1055,16 +1055,20 @@ function troll_list_users($edit) {
   $where[] = 'u.uid != 0';
 
   if (strlen($edit['username']) > 0) {
-    $where[] = "LOWER(u.name) LIKE '%%" . strtolower($edit['username']) . "%%' ";
+    $where[] = "LOWER(u.name) LIKE '%%%s%%' ";
+    $args[] = strtolower($edit['username']);
   }
   if (strlen($edit['mail']) > 0) {
-    $where[] = "LOWER(u.mail) LIKE '%%" . strtolower($edit['mail']) . "%%' ";
+    $where[] = "LOWER(u.mail) LIKE '%%%s%%' ";
+    $args[] = strtolower($edit['mail']);
   }
   if (strlen($edit['ip_address']) > 0) {
-    $where[] = "LOWER(t.ip_address) LIKE '%%" . strtolower($edit['ip_address']) . "%%' ";
+    $where[] = "LOWER(t.ip_address) LIKE '%%%s%%' ";
+    $args[] = strtolower($edit['ip_address']);
   }
   if (strlen($edit['date_created']) > 0) {
-    $where[] = "u.created > '" . strtotime($edit['date_created']) . "' ";
+    $where[] = "u.created > %d ";
+    $args[] = strtotime($edit['date_created']);
   }
 
   $sql = "SELECT u.uid, u.name, u.mail, u.status, t.ip_address, MAX(t.accessed) AS recorded, u.created FROM {users} u LEFT JOIN {troll_ip_track} t ON u.uid = t.uid";
@@ -1085,7 +1089,7 @@ function troll_list_users($edit) {
   $sql .= tablesort_sql($headers);
 
   $count = 'SELECT COUNT(*) FROM {users} u LEFT JOIN {troll_ip_track} t ON u.uid = t.uid WHERE '. implode(' AND ', $where) .' AND u.uid != 0';
-  $result = pager_query($sql, 25, 0, $count);
+  $result = pager_query($sql, 25, 0, $count, $args);
 
   while($user = db_fetch_object($result)) {
     $name = l($user->name, "admin/settings/troll/search/view/{$user->uid}", array('title' => t('View detailed user information')));
@@ -1129,19 +1133,19 @@ function troll_list_users($edit) {
  */
 function troll_search_user_detail($uid) {
   $u = user_load(array('uid' => $uid));
-  $u->ip = db_fetch_object(db_query('SELECT t.ip_address FROM {troll_ip_track} t WHERE t.uid = %d GROUP BY t.uid', $uid));
+  $u->ip = db_fetch_object(db_query('SELECT t.ip_address FROM {troll_ip_track} t WHERE t.uid = %d GROUP BY t.uid, t.ip_address', $uid));
 
   $roles = $u->roles;
 
   $form['details'] = array(
     '#type' => 'fieldset',
-    '#title' => t('Account Details for %username', array('%username' => $user->name))
+    '#title' => t('Account Details for %username', array('%username' => $u->name))
   );
 
   $form['details'][] = array(
     '#type' => 'item',
     '#title' => t('User Name'),
-    '#value' => $u->name
+    '#value' => theme('username', $u),
   );
   $form['details'][] = array(
     '#type' => 'item',
@@ -1215,12 +1219,12 @@ function troll_search_user_detail($uid) 
   $content .= theme('box', t('IP History'), ($posts ? $posts : t('No ip history')));
 
   // get recent posts
-  $rdat = db_query("SELECT * FROM {node} WHERE uid = %d ORDER BY created DESC LIMIT 1, 5", $uid);
+  $rdat = db_query("SELECT * FROM {node} WHERE uid = %d ORDER BY created DESC LIMIT 5", $uid);
 
   $posts = NULL;
   $rows = array();
   while ($node = db_fetch_object($rdat)) {
-    $rows[] = array(l($node->title, "node/{$node->nid}") .' '. theme('mark', node_mark($node->nid, $node->changed)), node_invoke($node, 'node_name'), date('M d, Y', $node->created), ($node->status ? t('published') : t('not published')));
+    $rows[] = array(l($node->title, "node/{$node->nid}") .' '. theme('mark', node_mark($node->nid, $node->changed)), $node->type, date('M d, Y', $node->created), ($node->status ? t('published') : t('not published')));
   }
   if ($rows) {
     $pheader = array(t('Title'), t('Type'), t('Created'), t('Status'));
@@ -1235,8 +1239,8 @@ function troll_search_user_detail($uid) 
 
   $rows = array();
   $posts = NULL;
-  while ($node = db_fetch_object($cdat)) {
-    $rows[] = array(l($node->subject, "node/{$node->nid}#comment-{$node->cid}") .' '. theme('mark', node_mark($node->nid, $node->changed)), date('M d, Y', $node->timestamp), ($node->status ? t('published') : t('not published')));
+  while ($comment = db_fetch_object($cdat)) {
+    $rows[] = array(l($comment->subject, 'node/'. $comment->nid, NULL, NULL, 'comment-'. $comment->cid) .' '. theme('mark', node_mark($comment->nid, $comment->changed)), date('M d, Y', $comment->timestamp), ($comment->status ? t('not published') : t('published')));
   }
 
   if ($rows) {
