<?
$NETCAT_FOLDER = join(strstr(__FILE__, "/") ? "/" : "\\", array_slice(preg_split("/[\/\\\]+/", __FILE__), 0, -4)) . (strstr(__FILE__, "/") ? "/" : "\\");
include_once($NETCAT_FOLDER . "vars.inc.php");
require($INCLUDE_FOLDER . "index.php");

require './classes/record_online.class.php';
require './function.inc.php';
$nc_core = nc_core::get_object();


$dashamail = new DashaMail();

$online_users = $nc_core->db->get_results("SELECT `DashaMail_Online_ID` FROM `Module_DashaMail_Online` WHERE `Online` = 1 AND `TimeEnd` < " . time(), ARRAY_A);
if ($online_users) {

  foreach ($online_users as $online_user) {
    $record_online = new record_online();
    $record_online->load($online_user['DashaMail_Online_ID']);
    $record_online->set('online', 0);
    $record_online->save();

    $dashamail->event_send($dashamail->event_user_leave, $record_online->get('user_id'));
  }
}
