// I do not want this script run from a browser
if (!empty($_SERVER['REMOTE_ADDR'])) {
    return;
}
$domain = $argv[1];
include_once "../../config.php";
global $CFG, $USER, $LNG;
include_once $HUB_FLM->getCodeDirPath("core/apilib.php");
include_once $HUB_FLM->getCodeDirPath("core/utillib.php");
// Check if emails should be sent out from this instalaltion first.
if (!$CFG->send_mail) {
    return;
}
header("Content-Type: text/plain");
$currentUser = $USER;
$us = getFollowEmailUsers('hourly');
$users = $us->users;
$count = count($users);
for ($i = 0; $i < $count; $i++) {
    $user = $users[$i];
    if (!$user instanceof Error) {
        $userid = $user->userid;
        //if ($userid != '137108251921190199260') { // '1722128760393014001402920636'
        //	continue;
        //}
        $USER = $user;
        $nextMessage = "";
        //'<div style="font-family:sans-serif,Arial,Helvettica; font-size: 10pt">';
        $followlastrun = $user->followlastrun;
        $now = time();
        if ($followlastrun == 0) {
// I do not want this script run from a browser
if (!empty($_SERVER['REMOTE_ADDR'])) {
    return;
}
$domain = $argv[1];
include_once "../../config.php";
global $CFG, $USER, $LNG;
include_once $HUB_FLM->getCodeDirPath("core/apilib.php");
include_once $HUB_FLM->getCodeDirPath("core/utillib.php");
// Check if emails should be sent out from this instalaltion first.
if (!$CFG->send_mail) {
    return;
}
header("Content-Type: text/plain");
$currentUser = $USER;
$us = getFollowEmailUsers('daily');
$users = $us->users;
$count = count($users);
for ($i = 0; $i < $count; $i++) {
    $user = $users[$i];
    if (!$user instanceof Error) {
        $userid = $user->userid;
        $USER = $user;
        $nextMessage = "";
        //'<div style="font-family:sans-serif,Arial,Helvettica; font-size: 10pt">';
        $followlastrun = $user->followlastrun;
        $now = time();
        if ($followlastrun == 0) {
            $timeback = 86400;
            //86400 = 24 hours or 1 Day
            $followlastrun = $now - $timeback;
// I do not want this script run from a browser
if (!empty($_SERVER['REMOTE_ADDR'])) {
    return;
}
$domain = $argv[1];
include_once "../../config.php";
global $CFG, $USER, $LNG, $HUB_FLM;
include_once $HUB_FLM->getCodeDirPath("core/apilib.php");
include_once $HUB_FLM->getCodeDirPath("core/utillib.php");
// Check if emails should be sent out from this instalaltion first.
if (!$CFG->send_mail) {
    return;
}
header("Content-Type: text/plain");
$currentUser = $USER;
$us = getFollowEmailUsers('weekly');
$users = $us->users;
$count = count($users);
for ($i = 0; $i < $count; $i++) {
    $user = $users[$i];
    if (!$user instanceof Error) {
        $userid = $user->userid;
        $USER = $user;
        $nextMessage = '';
        $followlastrun = $user->followlastrun;
        $now = time();
        if ($followlastrun == 0) {
            $timeback = 7 * 86400;
            //86400 = 24 hours or 1 Day
            $followlastrun = $now - $timeback;
        }
// I do not want this script run from a browser
if (!empty($_SERVER['REMOTE_ADDR'])) {
    return;
}
$domain = $argv[1];
include_once "../../config.php";
global $CFG, $USER, $LNG;
include_once $HUB_FLM->getCodeDirPath("core/apilib.php");
include_once $HUB_FLM->getCodeDirPath("core/utillib.php");
// Check if emails should be sent out from this instalaltion first.
if (!$CFG->send_mail) {
    return;
}
header("Content-Type: text/plain");
$currentUser = $USER;
$us = getFollowEmailUsers('monthly');
$users = $us->users;
$count = count($users);
for ($i = 0; $i < $count; $i++) {
    $user = $users[$i];
    if (!$user instanceof Error) {
        $userid = $user->userid;
        $USER = $user;
        $nextMessage = '';
        //'<div style="font-family:sans-serif,Arial,Helvettica; font-size: 10pt">';
        $followlastrun = $user->followlastrun;
        $now = time();
        if ($followlastrun == 0) {
            $timeback = 30 * 86400;
            //86400 = 24 hours or 1 Day
            $followlastrun = $now - $timeback;