<?PHP

/* ====================
Seditio - Website engine
Copyright Neocrome
http://www.neocrome.net

[BEGIN_SED]
File=plugins/cleaner/cleaner.php
Version=101
Updated=2006-mar-15
Type=Plugin
Author=Neocrome
Description=
[END_SED]

[BEGIN_SED_EXTPLUGIN]
Code=cleaner
Part=main
File=cleaner
Hooks=admin.home
Tags=
Order=10
[END_SED_EXTPLUGIN]
==================== */

if (!defined('SED_CODE')) { die('Wrong URL.'); }

// ============= Cleaning the accounts not activated within 2 days

$timeago = $sys['now'] - 172800; // 2 days (2 x 24 x 3600 seconds)
$sqltmp1 = sed_sql_query("SELECT user_id FROM $db_users WHERE user_maingrp=2 AND user_lastlog=0 AND user_regdate<$timeago");
$sqltmp2 = sed_sql_query("DELETE FROM $db_users WHERE user_maingrp=2 AND user_lastlog=0 AND user_regdate<$timeago");
$deleted = mysql_affected_rows();

while ($row = sed_sql_fetcharray($sqltmp1))
	{ $sqltmp2 = sed_sql_query("DELETE FROM $db_users WHERE user_id='".$row['user_id']."' AND user_lastlog=0"); }


if ($deleted>0)
	{ sed_log('Cleaner plugin deleted '.$deleted.' inactivated user account(s)','adm'); }

// ============= Cleaning the old log entries

$timeago = $sys['now'] - 604800; // 7 days (7 x 24 x 3600 seconds)
$sqltmp = sed_sql_query("DELETE FROM $db_logger WHERE log_date<$timeago");
$deleted = mysql_affected_rows();
if ($deleted>0)
	{ sed_log('Cleaner plugin deleted '.$deleted.' log entries older than 1 week','adm'); }

?>
