Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

how to log ip login player

Junior Spellweaver
Joined
Dec 21, 2008
Messages
195
Reaction score
10
hello i want to share my script to log ip address player

konek.php
<?php
function open_connection()
{
$host="localhost";
$username="your_username";
$password="your_password";

$databasename="pw";
$link=mysql_connect($host,$username,$password) or die ("Database tidak dapat dihubungkan!");
mysql_select_db($databasename,$link);
return $link;

// setting timer

$lama = 2;

$query = "DELETE FROM iplogin WHERE DATEDIFF(CURDATE(), date) > $lama";
$hasil = mysql_query($query);

}
?>

iplogin.php
<?php
// ----- ambil isi dari file koneksi.php
require("konek.php");

// ----- hubungkan ke database
$link=open_connection();

// ----- menentukan nama tabel
$tablename="iplogin";

// ----- perintah SQL dimasukkan ke dalam variable string
$sqlstr="select * from $tablename";

// ------ jalankan perintah SQL
$result = mysql_query ($sqlstr) or die ("Kesalahan pada perintah SQL!");

// ------ putus hubungan dengan database
mysql_close($link);

// ------ buat tampilan tabel
echo("<table width=500 border=1>");
echo("<tr><td >DATE</td><td>JAM</td><td>MENIT</td><td>ACCOUNT</td><td>USER_ID</td><td>IP ADDRESS</td></tr>");

// ------ ambil isi masing-masing record dari tabel mysql
while ($row = mysql_fetch_object ($result))
{

// ----- mengambil isi setiap kolom dari tabel mysql
$date=$row->date;
$hour=$row->hour;
$minute=$row->minute;
$account=$row->account;
$user_id=$row->user_id;
$ip_login=$row->ip_login;

// ------ menampilkan di layar browser seperti mozila firefox
echo("<tr><td>$date</td><td>$hour</td><td>$minute</td><td>$account</td><td>$user_id</td><td>$ip_login</td></tr>");
}
echo("</table>");

iplogin.sh
#!/bin/sh

// COMMENT : THIS IS SCRIPT BASE FROM RBB138

cd /root/pwserver/logs
grep -e ':account=:' world2.formatlog > iplogin.formatlog
chmod 777 iplogin.formatlog
sed -i 's/ /,/g' iplogin.formatlog
sed -i 's/=/,/g' iplogin.formatlog
sed -i 's/:/,/g' iplogin.formatlog
sed -i 's/,,,/,/g' iplogin.formatlog
sed -i 's/,,/,/g' iplogin.formatlog
mysqlimport --local -uroot -h127.0.0.1 -pPASSWORD --force --columns=date,hour,minute,@x,@x,@x,@x,@x,@x,@x,account,@x,user_id,@x,@x,@x,ip_login --fields-terminated-by=, pw /root/pwserver/logs/iplogin.formatlog
rm iplogin.formatlog

ok this is my script, thank you and sorry if i'm wrong :)

edit : i'm sorry, im forget about database, this is my table
CREATE TABLE IF NOT EXISTS `iplogin` (
`date` varchar(40) NOT NULL,
`hour` varchar(10) NOT NULL,
`minute` varchar(10) NOT NULL,
`account` varchar(35) NOT NULL,
`user_id` int(20) NOT NULL,
`ip_login` varchar(35) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

thank you
 
Last edited:
0, 1, 1, 2, 3, 5, 8, 13,
Joined
Sep 8, 2011
Messages
601
Reaction score
168
hello i want to share my script to log ip address player

konek.php


iplogin.php


iplogin.sh


ok this is my script, thank you and sorry if i'm wrong :)

This needs a database to store the output? if no then disregard my further post.
....:blush: id like to make one but i'm still learning the whole sql thing and it may take a long time.
Can you share the sql file please?
If not i'll plug away at it when time permits.
 
Junior Spellweaver
Joined
Dec 21, 2008
Messages
195
Reaction score
10
This needs a database to store the output? if no then disregard my further post.
....:blush: id like to make one but i'm still learning the whole sql thing and it may take a long time.
Can you share the sql file please?
If not i'll plug away at it when time permits.

im sorry , im forget about table.sql, update now in 1 post
 
0, 1, 1, 2, 3, 5, 8, 13,
Joined
Sep 8, 2011
Messages
601
Reaction score
168
The page with results shows but no results, iplogin.sh shows that the database has been accessed but 0 update of data for updating tables of sql database, hence iplogin.php shows table results empty.
 
Robb
Loyal Member
Joined
Jan 22, 2009
Messages
1,224
Reaction score
466
hello i want to share my script to log ip address player

iplogin.sh
cd /root/pwserver/logs
grep -e ':account=:' world2.formatlog > iplogin.formatlog
chmod 777 iplogin.formatlog
sed -i 's/ /,/g' iplogin.formatlog
sed -i 's/=/,/g' iplogin.formatlog
sed -i 's/:/,/g' iplogin.formatlog
sed -i 's/,,,/,/g' iplogin.formatlog
sed -i 's/,,/,/g' iplogin.formatlog
mysqlimport --local -uroot -h127.0.0.1 -pPASSWORD --force --columns=date,hour,minute,@x,@x,@x,@x,@x,@x,@x,account,@x,user_id,@x,@x,@x,ip_login --fields-terminated-by=, pw /root/pwserver/logs/iplogin.formatlog
rm iplogin.formatlog

ok this is my script, thank you and sorry if i'm wrong :)

edit : i'm sorry, im forget about database, this is my table


thank you

Your script?
Pretty sure thats my script.
 
Newbie Spellweaver
Joined
May 12, 2012
Messages
48
Reaction score
6
The page with results shows but no results, iplogin.sh shows that the database has been accessed but 0 update of data for updating tables of sql database, hence iplogin.php shows table results empty.

in file iplogin.sh fix line: grep -e ':account=:' world2.formatlog > iplogin.formatlog
->> grep -e ':account=' world2.formatlog > iplogin.formatlog
 
Legendary Battlemage
Joined
Aug 6, 2004
Messages
608
Reaction score
120
please update your post with proper credits then please.
 
Elite Diviner
Joined
Mar 12, 2009
Messages
472
Reaction score
59
Your script?
Pretty sure thats my script.

that's only simple regex dude, don't give yourself too much pride :D hahaha

see this part

// COMMENT : THIS IS SCRIPT BASE FROM RBB138

your name is already there, don't worry dude... :D hahaha
 
Newbie Spellweaver
Joined
Aug 19, 2011
Messages
49
Reaction score
0
: No such file or directory
: No such file or directory in/logs/
grep: world2. formatlog: no such file or directory
' not found (Errcode: 2) when using table: iploginmatlog
rm: cannot remove ' iplogin. formatlog ': no such file or directory
What could it be?
 
Angelemu founder
Joined
Mar 2, 2011
Messages
525
Reaction score
247
i guess you should fix the path to the logfiles to whatever your logserver config says they are
 
Back
Top