request MT2GS CMS ip logs

06/17/2011 23:38 .Rebel#1
hi people i am not a php programer but want ask if someone have the ip logs for this script

all ip login get log if someone have or know where i can find i apreciate
04/01/2013 04:09 FSXraptor#2
Still looking for it? I have it, I made it on my own, maybe I can share.
04/03/2013 18:20 FSXraptor#3
Well i got requests to share so here it is.

First if you don't have the table `loginlog2` inside your `log` database, or if it has a different structure than the one below, you'll need to run the following query.

Code:
SET FOREIGN_KEY_CHECKS=0;

DROP TABLE IF EXISTS `loginlog2`;
CREATE TABLE `loginlog2` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` text CHARACTER SET latin1,
  `is_gm` int(11) DEFAULT NULL,
  `login_time` datetime DEFAULT NULL,
  `channel` int(11) DEFAULT NULL,
  `account_id` int(11) DEFAULT NULL,
  `pid` int(11) DEFAULT NULL,
  `client_version` text CHARACTER SET latin1,
  `ip` text CHARACTER SET latin1,
  `logout_time` datetime DEFAULT NULL,
  `playtime` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Then you have to create a php (text) file named loginlog.php and put the following code in it.


PHP Code:
<?PHP

// Do we have rights to see this page?
if(isset($_SESSION['user_admin']) && checkInt($_SESSION['user_admin']) && $_SESSION['user_admin']>=7) {
  
    
// Check if we have used the search function
    // and modify the url.
    
if(!isset($_GET['filter']) && empty($_GET['filter'])) {
      
$_GET['filter']='';
      
$url_extension '';
    }
    else {
      
$url_extension '&filter='.$_GET['filter'];
    }

?>
<h2>Admin - Search login log</h2>
<p>In this page you can find certain information about the ingame logins of users accounts.<br/>
The search function reffers to full user account IDs.</p>
<form action="index.php" method="GET">
<input type="hidden" name="s" value="admin"/>
<input type="hidden" name="a" value="loginlog"/>
  <table>
    <tr>
      <td class="topLine" width="350"><b>Search account ID:</b></td>
      <td class="thell" width="550" style="text-align:center;"><input type="text" name="filter" value="<?PHP if(isset($_GET['filter'])) echo $_GET["filter"]; ?>" maxlength="40" size="40"/></td>
      <td class="tdunkel" width="250" style="text-align:center;"><input type="submit" name="search" value="Search"/></td>
    </tr>
  </table>
</form>
<?PHP

  
// How many results do we want per page?
  
$pageEntries 100;

  
// Do we see a page other than number 1?
  // If yes keep it, but if no then we see page number 1.
  
if(isset($_GET['p'])) {
    if(!
checkInt($_GET['p']) || !($_GET['p']>0)) $actPage 1;
    else 
$actPage $_GET['p'];
  }
  else { 
$actPage 1; }

  
// Find out how many are the total logins of the given account.
  
$sqlCmd "SELECT COUNT(*) as sumLogin  
  FROM log.loginlog2 
  WHERE loginlog2.account_id = '"
.mysql_real_escape_string($_GET['filter'])."'
  ORDER BY loginlog2.login_time DESC"
;
  
  
$sqlQry mysql_query($sqlCmd,$sqlServ);  
  
$getSum mysql_fetch_object($sqlQry);
  
$cPage calcPages($getSum->sumLogin,$actPage,$pageEntries);

  
// How many pages to display before and after the current page,
  // in the page navigation bar.
  
$maxRange 5;
  
  
// From the current page, how many pages before and
  // after will the far left and far right page links
  // be in the page navigation bar?
  
$maxStep 15;

  if((
$actPage-$maxRange)>0$sStart $actPage-$maxRange;
  else 
$sStart 1;
  if((
$actPage+$maxRange)<=$cPage[0]) $sEnd $actPage+$maxRange;
  else 
$sEnd $cPage[0];
  
  
// Page navigation bar start
  
echo '<table>
  <tr>
  <td class="tdunkel">'
;
  
  
// Far left page number-link.
  
if(($actPage-$maxStep)>0) echo '<a href="index.php?s=admin&a=loginlog'.$url_extension.'&p='.($actPage-$maxStep).'">'.($actPage-$maxStep).'</a> &laquo;';
  else echo 
'<a href="index.php?s=admin&a=loginlog'.$url_extension.'&p=1">1</a> &laquo;';
  echo
'</td>';
  
  
// Middle group of page numbers
  
for($i=$sStart;$i<=$sEnd;$i++) {
    
$sClass = ($i==$actPage) ? "topLine" "thell";
    echo
'<td class="'.$sClass.'" style="text-align:center;">';
    echo
'<a href="index.php?s=admin&a=loginlog'.$url_extension.'&p='.$i.'">'.$i.'</a>';
    echo
'</td>';
  }
  
  echo
'<td class="tdunkel" style="text-align:right;">';
  
  
// Far right page number-link.
  
if(($actPage+$maxStep)<=$cPage[0]) echo '&raquo; <a href="index.php?s=admin&a=loginlog'.$url_extension.'&p='.($actPage+$maxStep).'">'.($actPage+$maxStep).'</a>';
  else echo 
'&raquo; <a href="index.php?s=admin&a=loginlog'.$url_extension.'&p='.$cPage[0].'">'.$cPage[0].'</a>';
  echo
'</td>';
  echo
'</tr>';
  echo
'</table>'
  
// Page navigation bar end
  
?>
<table>
<tr>
  <td class="topLine"><b><center>Type</center></b></td>
  <td class="topLine"><b><center>Login time</center></b></td>
  <td class="topLine"><b><center>Channel</center></b></td>
  <td class="topLine"><b><center>Account ID</center></b></td>
  <td class="topLine"><b><center>Character ID</center></b></td>
  <td class="topLine"><b><center>ΙΡ</center></b></td>
  <td class="topLine"><b><center>Logout time</center></b></td>
</tr>
<?PHP

  
// Fetch the data from MySQL. IPs inside the table are stored after being
  // converted with INET_ATON(). See http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_inet-aton
  // Also see http://www.elitepvpers.com/forum/metin2-pserver-guides-strategies/1714179-how-convert-numeric-ip-dotted-quad-representation-log-database.html
  
  
$sqlCmd "SELECT type,is_gm,login_time,channel,account_id,pid,INET_NTOA(ip) AS finalIP,logout_time FROM log.loginlog2
  WHERE loginlog2.account_id = '"
.mysql_real_escape_string($_GET['filter'])."'
  ORDER BY loginlog2.login_time DESC
  LIMIT "
.$cPage[1].",".$pageEntries;

  echo
'Current search filter: &laquo;<b>'.$_GET['filter'].'</b>&raquo;';
  
$sqlQry mysql_query($sqlCmd,$sqlServ);
  
$x=$cPage[1]+1;
  while(
$getLogin mysql_fetch_object($sqlQry)) {
  
    
$zF = ($x%2==0) ? "thell" "tdunkel";
    echo 
"<tr>";
    echo 
"<td class=\"$zF\"><center>".$getLogin->type."</center></td>";
    echo 
"<td class=\"$zF\"><center>".$getLogin->login_time."</center></td>";
    echo 
"<td class=\"$zF\"><center>".$getLogin->channel."</center></td>";
    echo 
"<td class=\"$zF\"><center><a href='index.php?s=admin&a=users&acc=".$getLogin->account_id."'>".$getLogin->account_id."</a></center></td>";
    echo 
"<td class=\"$zF\"><center><a href='index.php?s=admin&a=charlist&filter=".$getLogin->pid."'>".$getLogin->pid."</a></center></td>";
    echo 
"<td class=\"$zF\"><a href='index.php?s=admin&a=iplist&filter=".$getLogin->finalIP."'>".$getLogin->finalIP."</a></td>";
    echo 
"<td class=\"$zF\"><center>".$getLogin->logout_time."</center></td>";
    echo 
"</td>";
    echo 
"</tr>";

    
$x++;
    
  }
  }
  
// oops, looks like our session timed out - 
  // we are not logged in etc..
  
else {
   echo
'<p>You do NOT have access to this page.</p>';
  }
?>
</table>

Upload the loginlog.php file to your /admin folder and visit the page /index.php?s=admin&a=loginlog.