<?php 

$dir = '../';

require_once $dir.'includes/main.php';

$day = 60 * 60 * 23;

if((fetch_record("SELECT date_created FROM _stats ORDER BY id DESC LIMIT 1") + $day) < $t){

   query("INSERT INTO stats (user_id, date_created) SELECT id, $t FROM users ORDER BY id ASC");
   query("UPDATE listings SET points = points - {$set['daily_deducted']} WHERE points > 0 ORDER BY id ASC");
   query("UPDATE users SET this_day = 0");
   date('l', $t) == 'Monday' ? query("UPDATE users SET this_week = 0") : null;
   date('d', $t) == '01' ? query("UPDATE users SET this_month = 0") : null;

   query("INSERT INTO _stats (date_created) VALUES ('{$t}')");

}

?>