<?php
$res = run_query('DELETE FROM '.$config["table_prefix"].'mail_archive WHERE add_time<"' . date('Y-m-d H:i:s',strtotime('-14 days')) . '"');
$row  = sql_fetch_assoc($res);
$res = run_query('OPTIMIZE TABLE '.$config['table_prefix'].'mail_archive');
$row  = sql_fetch_assoc($res);
$result = run_query('SELECT * FROM ' . $config['table_prefix'] . 'config WHERE name="auto_delete_mailing_days"');
if (!sql_num_rows($result)) {
    run_query('INSERT INTO ' . $config['table_prefix'] . 'config (name, value) VALUES ("auto_delete_mailing_days", "14")');
}

