Example #1
0
function photoCheck($abs_photos, $listingID)
{
    //for($i=3;$i>=0;$i--) {
    if (!photo_exists($abs_photos, $listingID, 0)) {
        if (!photo_exists($abs_photos, $listingID, 1)) {
            if (!photo_exists($abs_photos, $listingID, 2)) {
                if (!photo_exists($abs_photos, $listingID, 3)) {
                    // Download the photo from RETS
                    $rets = connectRETS();
                    if ($rets == null) {
                        $alerts_txt = "Could not connect to the RETS server.";
                        webadmin_alert($alerts_txt);
                    } else {
                        $photos = $rets->GetObject("Property", "Photo", $listingID);
                        foreach ($photos as $photo) {
                            $number = $photo['Object-ID'];
                            if ($photo['Success'] == true) {
                                file_put_contents($abs_photos . $listingID . "_" . $number . ".jpg", $photo['Data']);
                            }
                        }
                    }
                    $rets->Disconnect();
                    $rets = null;
                    //return "photo doesn't exist ($abs_photos,$listingID)";
                    return false;
                }
            }
        }
    } else {
        //return "photo exists";
        return true;
    }
}
$resources = array("Office" => array("Office"), "Agent" => array("Agent"), "Property" => array("ResidentialProperty", "VacantLand", "CommercialProperty", "MultiFamily", "BusinessOpportunity", "Rental"));
// DateTime which is used to determine how far back to retrieve records.
// using a really old date so we can get everything
$previous_start_time = "1980-01-01T00:00:00";
/* some more variables for internal use */
$log_file = "";
$eol = "\n";
$alerts_txt = "";
$files_arr = array();
/* Get functions that can be used */
require 'functions.php';
/* Start the log entry */
$log_file = "--------------------------------------------------------------" . $eol;
$log_file .= date("Y-m-d G:i") . $eol;
/* Connect to RETS server */
$rets = connectRETS();
if ($rets == null) {
    $alerts_txt .= "Could not connect to the RETS server.";
    $log_file .= $alerts_txt . $eol;
    $log_file .= print_r($rets->Error());
    webadmin_alert($alerts_txt);
} else {
    $log_file .= "Connected to RETS server and downloaded:" . $eol;
}
/* Get type info from the meta data */
$types = $rets->GetMetadataTypes();
if (!$types) {
    $log_file .= print_r($rets->Error());
} else {
    foreach ($types as $type) {
        if ($debugging) {