spazz Posted February 9, 2008 Posted February 9, 2008 Not sure if this is the right section for this. I am currently having an issue with players changing their username and causing trouble in the shoutbox in my game and then changing it back. By the time I log into the db and try to trace it, they have already changed it back. I currently have the link disabled. I am looking for a script that will log the changes in the database but easily accessible through the staff panel, much like the xfer logs. I would be willing to pay someone to have this done right. PM me so that we may discuss it. Quote
Ghetto Posted February 9, 2008 Posted February 9, 2008 Re: Looking for a username change log database script Why dont you just make it so they have to pay to change there name? Or heres a quick username log for you. V2 staff_logs.php Find: case 'stafflogs': view_staff_logs(); break; Add after: case 'usernamelogs': view_name_logs(); break; Find: $h->endpage(); Add befor: function view_name_logs() { global $db,$ir,$c,$h,$userid; if($ir['user_level'] != 2) { die("403"); } $_GET['st']=abs((int) $_GET['st']); $rpp=100; echo "<h3>Username Logs</h3> <table width=100% cellspacing='0' border='1' class='table'><tr> <th>Userid</th> <th>Old Name</th> <th>New Name</th><th>Time</th> <th>IP</th> </tr>"; $q=$db->query("SELECT n.*, u.* FROM namelogs n LEFT JOIN users u ON n.user=u.userid ORDER BY n.time DESC LIMIT {$_GET['st']},$rpp"); while($r=$db->fetch_row($q)) { echo "<tr><td>{$r['user']}</td> <td>{$r['oldname']}</td> <td>{$r['newname']}</td><td>".date('F j Y g:i:s a', $r['time'])."</td><td>{$r['ip']}</td></tr>"; } echo "</table> "; $mypage=floor($_GET['st']/$rpp)+1; $q2=$db->query("SELECT id FROM namelogs"); $rs=$db->num_rows($q2); $pages=ceil($rs/$rpp); echo "Pages: "; for($i=1;$i<=$pages;$i++) { $st=($i-1)*$rpp; echo "[url='staff_logs.php?action=usernamelogs&st=$st']$i[/url] "; if($i % 7 == 0) { echo " \n"; } } } Open preferences.php Fine: $_POST['newname']=str_replace(array("<", ">", "\\\'"), array("<", ">", "'"), $_POST['newname']); Add befor $db->query("INSERT INTO namelogs VALUES('',$userid,'{$ir['username']}','{$_POST['newname']}', unix_timestamp(), '{$ir['lastip']}')"); SQL: CREATE TABLE `namelogs` ( `id` int(11) NOT NULL auto_increment, `user` int(11) NOT NULL default '0', `oldname` varchar(255) NOT NULL default '', `newname` varchar(255) NOT NULL default '', `time` int(11) NOT NULL default '', `ip` varchar(15) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; I have not tested this but it should work. Quote
spazz Posted February 9, 2008 Author Posted February 9, 2008 Re: Looking for a username change log database script Thank you very much for the help, just a few things. 1. accorrding to your code, it looks like there is supposed to be a row in the namelogs called time, I was getting an error till I noticed and added one. 2. This one has me stumped, when I go to change my name I get this: QUERY ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MY OLD USER NAME,test, MY IP)' at line 1 Query was INSERT INTO namelogs VALUES('',1,MY OLD USER NAME,test, MY IP) Quote
Ghetto Posted February 9, 2008 Posted February 9, 2008 Re: Looking for a username change log database script Ok ive updated the code. Ive tested it and its working now. Ive added the time in the logs aswell ok. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.