Cleanup: delete ips

Started by cherwonk, July 30, 2011, 09:45:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

putyn

i have no idea what its with that query your getting an error - the code that i posted should work :P it logic i think to check every filed and not only lastlogin

cherwonk

#3
Wow fast , along the lines I was leaning towards. Will test it and let you know

Thank you
well added that and got sql error , funny thing it wasnt even from that line.
was from
include/cleanup.php on line 194
Code (php) Select
sql_query($sql) or sqlerr(__FILE__, __LINE__);


I added this
Code (php) Select
sql_query("DELETE FROM ips WHERE lastlogin < $dt");
and it cleaned up the IPs from the login , so Im assuming the problem was with the ors

putyn

you could do something like
Code (php) Select

sql_query('DELETE FROM ips WHERE lastbrowse < '.$dt.' OR lastlogin < '.$dt.' OR  lastannounce < '.$dt ) or sqlerr(__FILE__,__LINE__);

cherwonk

finding a problem with the clean up code for the ip log
Code (php) Select
//== Delete ips
  $dt =  TIME_NOW -  62 * 86400;
  sql_query("DELETE FROM ips WHERE access < $dt");


which was all good when the sql was
Code (mysql) Select
-- Table structure for table `iplog`
--

CREATE TABLE `iplog` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `ip` int(12) default '0',
  `userid` int(10) default NULL,
  `access` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`),
  KEY `userid` (`userid`),
  KEY `ip` (`ip`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `iplog`
--



But now with the code being
Code (mysql) Select
CREATE TABLE `ips` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `ip` varchar(15) character set latin1 collate latin1_bin default NULL,
  `userid` int(10) default NULL,
  `type` enum('login','announce','browse') NOT NULL,
  `seedbox` tinyint(1) NOT NULL default '0',
  `lastbrowse` int(11) NOT NULL default '0',
  `lastlogin` int(11) NOT NULL default '0',
  `lastannounce` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`),
  KEY `userid` (`userid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;


there no reference to access. Im seeing Ips piling up . Would we need to write a line for each lastbrowse,
  lastlogin and lastannounce