#!/usr/bin/php
<?php
    define('CRLF',"\r\n");
    ini_set('include_path',ini_get('include_path') . ":/data/sites/www.landscapeonline.com/includes");

    $requiredClasses[] = 'base/subscriber_class.php';

    require('lol_common.inc');
    
    $v = new subscriber_class();

    //$ca->setExpired();

    $list = $v->fetchRecentlyChanged(1);

    // the list of modified companies

    if(count($list) == 0) {
        return;
    }

$mail = <<<EOM
Subscriber changes from the last 24 hours:
EOM;

$mail .= CRLF . CRLF;

    foreach($list as $obj) {
        $mail .= "{$obj['comp_name']}: "; 
        $mail .= "http://www.landscapeonline.com/private/subscriber/listing_action.php?action=view&id={$obj['id']}" . CRLF;
    }

    $recipients = array(
        "porwig@landscapeonline.com",
        "jlipot@landscapeonline.com"
    );

    foreach($recipients as $key => $em) {
        $recipients[$key] = "<{$em}>";
    }

    $message = array(
        'To' => implode(', ', $recipients),
        'From' => "webmaster@landscapeonline.com",
        'Subject' => "Recently Changed Subscribers - " . date('F j, Y'),
        'Return-path' => 'webmaster@landscapeonline.com',
        'bodyTXT' => $mail
    );

    if($v->sendMail($message) !== TRUE) {
        print("Error sending mail.");
    }

    return;
?>
