MyBB Community Forums

Full Version: Automatic tast to ERASE ip's every 24 hours.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I want to include an automatic task that ERASES ip addresses every 24 hours of ALL users and logs.

I got this code off the web:


<?php
function task_cleanip($task)
{
 global $db, $lang, $cache;

 // Delay: 24h
 $cut = TIME_NOW-60*60;
 
 // Cleaning Admin logs
 $query = $db->update_query('adminlog', array('ipaddress' => '127.0.0.1'), 'dateline < '.$cut);
 // Cleaning Admin sessions
 $query = $db->update_query('adminsessions', array('ip' => '127.0.0.1'), 'dateline < '.$cut);
 
 // Cleaning Mail logs
 $query = $db->update_query('maillogs', array('ipaddress' => '127.0.0.1'), 'dateline < '.$cut);
 
 // Cleaning Moderators logs
 $query = $db->update_query('moderatorlog', array('ipaddress' => '127.0.0.1'), 'dateline < '.$cut);
 
 // Cleaning Posts
 $query = $db->update_query('posts', array(
 'ipaddress' => '127.0.0.1',
 'longipaddress' => ip2long('127.0.0.1')
 ), 
 'dateline < '.$cut);
 
 // Cleaning Search logs
 $query = $db->update_query('searchlog', array('ipaddress' => '127.0.0.1'), 'dateline < '.$cut);
 
 // Cleaning sessions
 $query = $db->update_query('sessions', array('ip' => '127.0.0.1'), 'time < '.$cut);
 
 // Cleaning all users IP
 $query = $db->update_query('users', array(
 'regip' => '127.0.0.1',
 'lastip' => '127.0.0.1',
 'longregip' => ip2long('127.0.0.1'),
 'longlastip' => ip2long('127.0.0.1')
 ), 
 '1=1');

 add_task_log($task, 'IP cleaneds');

} 
?>


I think this script MODIFIES ip's to 127.0.0.1 everywhere, correct?

Can it be modified so it erases them and not only modifies them?
If the answer is no, is the code alright and ready to be used?

Thanks!