} } unset($floorplan, $floorplan_array, $i); $render = remove_lastchar($render, "^"); $render = remove_lastchar($render, "^"); // brochure $render .= "http://" . WS_HOSTNAME . "/property/pdf/" . $row['dea_id']; $render .= "~\n"; //End of record + line feed // loop } // end of datafeed $render .= "#END#"; $local_file = $strPath . "/" . $strTextFile; // if the file already exists, delet before re-writing if (file_exists($local_file)) { unlink($local_file); } // write $render to file if (!file_put_contents($local_file, $render)) { echo "could not write to file"; exit; } $ftp = new FTP($CONFIG[FEED_NAME]['ftp_server'], $CONFIG[FEED_NAME]['ftp_username'], $CONFIG[FEED_NAME]['ftp_password']); try { $ftp->upload($strPath, $CONFIG[FEED_NAME]['ftp_destination']); } catch (Exception $e) { } file_put_contents(WS_PATH_LOGS . "/ftpUploadErrorLog.log", $ftp->getErrorLog(), FILE_APPEND); file_put_contents(WS_PATH_LOGS . "/ftpUploadMessageLog.log", $ftp->getMessageLog(), FILE_APPEND);
public function actionZoomf() { global $CONFIG; $feedName = "zoomf"; $strPath = $this->getFeedFolderPath($feedName); $command = Yii::app()->db->createCommand($this->getSQLStatement()); $dataReader = $command->query(); $RENDER = $this->getFeedHeader($dataReader); foreach ($dataReader as $row) { switch ($row['dea_branch']) { case 2: $intRMBranchID = 24869; break; case 4: $intRMBranchID = 24869; break; case 1: case 3: default: $intRMBranchID = 3120; break; } $postcode = explode(" ", $row["pro_postcode"]); $RENDER .= $intRMBranchID . "_" . $row["dea_id"] . "^"; //AGENT_REF $RENDER .= $row["pro_addr1"] . "^"; //ADDRESS_1 $RENDER .= $row["pro_addr3"] . "^"; //ADDRESS_2 $RENDER .= $row["are_title"] . "^"; //ADDRESS_3 $RENDER .= "^"; //ADDRESS_4 $RENDER .= $row["pro_addr5"] . "^"; //TOWN $RENDER .= $postcode[0] . "^"; //POSTCODE1 $RENDER .= $postcode[1] . "^"; //POSTCODE2 $RENDER .= "^"; //FEATURE1 property type $RENDER .= "^"; //FEATURE2 bedroms $RENDER .= "^"; //FEATURE3 ch $RENDER .= "^"; //FEATURE4 dg $RENDER .= "^"; //FEATURE5 $RENDER .= "^"; //FEATURE6 $RENDER .= "^"; //FEATURE7 $RENDER .= "^"; //FEATURE8 $RENDER .= "^"; //FEATURE9 $RENDER .= "^"; //FEATURE10 $length = 300 - strlen($row["dea_strapline"]); // 300 is allowed, but i add (cont) so we use 294 $desc = $this->htmlentitiesWithStripTag($row["dea_description"]); $trimmed = preg_replace("/[\r\n]+[\\s\t]*[\r\n]+/", "", $desc); $trimmed = str_replace("&#039;", "'", $trimmed); $trimmed = str_replace("&amp;#039;", "'", $trimmed); $trimmed = str_replace("&eacute;", "�", $trimmed); $trimmed = substr($trimmed, 0, $length); $RENDER .= $row["dea_strapline"] . ": " . $trimmed . "^"; //SUMMARY $longDescription = $row["dea_description"]; if ($row["total_area"]) { $longDescription .= "<p>Approximate Gross Internal Area: " . $row["total_area"] . " square metres</p>"; } $longDescription .= "<p>For further information or to arrange a viewing, please contact our <b>" . $row["bra_title"] . " Branch</b> on <b>" . $row["bra_tel"] . ".</b></p>"; $longDescription .= "<p>Visit <b>www.woosterstock.co.uk</b> for full details, colour photos, maps and floor plans.</p>"; $longDescription .= "<p>We endeavour to make all our property particulars, descriptions, floor-plans, marketing and local information accurate and reliable but we make no guarantees as to the accuracy of this information. All measurements and dimensions are for guidance only and should not be considered accurate. If there is any point which is of particular importance to you we advise that you contact us to confirm the details; particularly if you are contemplating travelling some distance to view the property. Please note that we have not tested any services or appliances mentioned in property sales details.</p>"; $RENDER .= preg_replace("/[\r\n]+[\\s\t]*[\r\n]+/", "", $longDescription) . "^"; //DESCRIPTION $RENDER .= $intRMBranchID . "^"; //BRANCH_ID // we have three possible sattusses : under Offer statuses returns 1; 0 otherwise $row["dea_status"] == 'Under Offer' || $row["dea_status"] == 'Under Offer with Other' ? $RENDER .= "1" . "^" : ($RENDER .= "0" . "^"); $RENDER .= $row["dea_bedroom"] . "^"; //BEDROOMS $RENDER .= $row["dea_marketprice"] . "^"; //PRICE $RENDER .= "0" . "^"; //PRICE_QUALIFIER if ($row["dea_psubtype"] == 4) { //PROP_SUB_ID $RENDER .= "4" . "^"; } elseif ($row["dea_psubtype"] == 5) { $RENDER .= "3" . "^"; } elseif ($row["dea_psubtype"] == 6) { $RENDER .= "1" . "^"; } elseif ($row["dea_psubtype"] == 7) { $RENDER .= "2" . "^"; } elseif ($row["dea_psubtype"] == 8) { $RENDER .= "5" . "^"; } elseif ($row["dea_psubtype"] == 9) { $RENDER .= "12" . "^"; } elseif ($row["dea_psubtype"] == 10) { $RENDER .= "26" . "^"; } elseif ($row["dea_psubtype"] == 11) { $RENDER .= "29" . "^"; } elseif ($row["dea_psubtype"] == 12) { $RENDER .= "11" . "^"; } elseif ($row["dea_psubtype"] == 13) { $RENDER .= "9" . "^"; } elseif ($row["dea_psubtype"] == 14) { $RENDER .= "19" . "^"; } elseif ($row["dea_psubtype"] == 15) { $RENDER .= "19" . "^"; } elseif ($row["dea_psubtype"] == 16) { $RENDER .= "51" . "^"; } elseif ($row["dea_psubtype"] == 17) { $RENDER .= "20" . "^"; } elseif ($row["dea_psubtype"] == 19) { $RENDER .= "28" . "^"; } elseif ($row["dea_psubtype"] == 20) { $RENDER .= "28" . "^"; } elseif ($row["dea_psubtype"] == 21) { $RENDER .= "28" . "^"; } elseif ($row["dea_psubtype"] == 22) { $RENDER .= "23" . "^"; } elseif ($row["dea_psubtype"] == 23) { $RENDER .= "28" . "^"; } elseif ($row["dea_psubtype"] == 25) { $RENDER .= "21" . "^"; } elseif ($row["dea_psubtype"] == 26) { $RENDER .= "48" . "^"; } elseif ($row["dea_psubtype"] == 27) { $RENDER .= "19" . "^"; } elseif ($row["dea_psubtype"] == 28) { $RENDER .= "19" . "^"; } elseif ($row["dea_psubtype"] == 29) { $RENDER .= "19" . "^"; } else { if ($row["dea_ptype"] == 1) { $RENDER .= "26" . "^"; } elseif ($row["dea_ptype"] == 2) { $RENDER .= "28" . "^"; } elseif ($row["dea_ptype"] == 3) { $RENDER .= "19" . "^"; } } $RENDER .= $row["dea_launchdate"] . "^"; //CREATE_DATE $RENDER .= date("Y-m-d H:i:s") . "^"; //UPDATE_DATE $RENDER .= $row["pro_addr3"] . ", " . $row["are_title"] . ", " . $postcode[0] . "^"; //DISPLAY_ADDRESS $RENDER .= "1" . "^"; //PUBLISHED_FLAG if ($row["dea_type"] == 'Lettings') { //LET_DATE_AVAILABLE $RENDER .= $row["dea_available"] . "^"; } else { $RENDER .= "^"; } $RENDER .= "^"; //LET_BOND if ($row["PriceType"] == 1) { //LET_TYPE_ID $RENDER .= "1" . "^"; } elseif ($row["PriceType"] == 2) { $RENDER .= "2" . "^"; } else { $RENDER .= "0" . "^"; } if ($row["furnished"] == 1) { //LET_FURN_ID $RENDER .= "2" . "^"; } elseif ($row["furnished"] == 2) { $RENDER .= "1" . "^"; } elseif ($row["furnished"] == 3) { $RENDER .= "0" . "^"; } else { $RENDER .= "3" . "^"; } $RENDER .= "0" . "^"; //LET_RENT_FREQUENCY if ($row["dea_type"] == 'Sales') { //TRANS_TYPE_ID $RENDER .= "1" . "^"; } else { $RENDER .= "2" . "^"; } $image_path = WS_PATH_IMAGES . '/' . $row["dea_id"] . '/'; if ($row["photos"]) { $photo_array = explode("~", $row["photos"]); } /* $max_images = sizeof($photo_array); */ $max_images = 10; for ($i = 0; $i <= $max_images; $i++) { if ($photo_array[$i]) { $photo = explode("|", $photo_array[$i]); if (file_exists($image_path . str_replace(".jpg", "_large.jpg", $photo[0]))) { $source_image = $image_path . str_replace(".jpg", "_large.jpg", $photo[0]); } elseif (file_exists($image_path . str_replace(".jpg", "_small.jpg", $photo[0]))) { $source_image = $image_path . str_replace(".jpg", "_small.jpg", $photo[0]); } $rm_image_name = $intRMBranchID . '_' . $row["dea_id"] . '_IMG_' . substr("0" . $i, -2) . '.jpg'; // if the file already exists, delet before re-writing if (file_exists($strPath . "/" . $rm_image_name)) { unlink($strPath . "/" . $rm_image_name); } copy($source_image, $strPath . "/" . $rm_image_name); $RENDER .= $rm_image_name . "^"; //MEDIA_IMAGE_00 $filesToDelete[] = $strPath . "/" . $rm_image_name; $RENDER .= $photo[1] . "^"; //MEDIA_IMAGE_TEXT_00 } else { // no image $RENDER .= "^"; //MEDIA_IMAGE_00 $RENDER .= "^"; //MEDIA_IMAGE_TEXT_00 } } // epc document if ($row["epc"]) { $epc_array = explode("~", $row["epc"]); } $max_epc = 2; for ($i = 0; $i < $max_epc; $i++) { if ($epc_array[$i]) { $epc = explode("|", $epc_array[$i]); if (file_exists($image_path . str_replace(".jpg", "_large.jpg", $epc[0]))) { $source_image = $image_path . str_replace(".jpg", "_large.jpg", $epc[0]); } elseif (file_exists($image_path . str_replace(".jpg", "_small.jpg", $epc[0]))) { $source_image = $image_path . str_replace(".jpg", "_small.jpg", $epc[0]); } $rm_image_name = $intRMBranchID . '_' . $row["dea_id"] . '_IMG_' . substr("0" . ($i + 60), -2) . '.jpg'; // if the file already exists, delet before re-writing if (file_exists($strPath . "/" . $rm_image_name)) { unlink($strPath . "/" . $rm_image_name); } copy($source_image, $strPath . "/" . $rm_image_name); $RENDER .= $rm_image_name . "^"; //MEDIA_IMAGE_00 $filesToDelete[] = $strPath . "/" . $rm_image_name; $RENDER .= $epc[1] . "^"; //MEDIA_IMAGE_TEXT_00 } else { // no image $RENDER .= "^"; //MEDIA_IMAGE_00 $RENDER .= "^"; //MEDIA_IMAGE_TEXT_00 } } // floorplans if ($row["floorplans"]) { $floorplan_array = explode("~", $row["floorplans"]); } $max_floorplans = 5; for ($i = 0; $i <= $max_floorplans; $i++) { if ($floorplan_array[$i]) { $floorplan = explode("|", $floorplan_array[$i]); if (file_exists($image_path . $floorplan[0])) { $source_image = $image_path . $floorplan[0]; } $rm_image_name = $intRMBranchID . '_' . $row["dea_id"] . '_FLP_' . substr("0" . $i, -2) . '.gif'; // if the file already exists, delete before re-writing if (file_exists($strPath . "/" . $rm_image_name)) { unlink($strPath . "/" . $rm_image_name); } copy($source_image, $strPath . "/" . $rm_image_name); $RENDER .= $rm_image_name . "^"; //MEDIA_FLOOR_PLAN_01 $filesToDelete[] = $strPath . "/" . $rm_image_name; $RENDER .= $floorplan[1] . "^"; //MEDIA_FLOOR_PLAN_TEXT_01 } else { // no image $RENDER .= "^"; //MEDIA_FLOOR_PLAN_01 $RENDER .= "^"; //MEDIA_FLOOR_PLAN_TEXT_01 } } $RENDER = $this->removeLastChar($RENDER, "^"); $RENDER = $this->removeLastChar($RENDER, "^"); // brochure $render .= "http://" . WS_HOSTNAME . "/property/pdf/" . $row['dea_id']; $RENDER .= "~\n"; //End of record + line feed } $RENDER .= "#END#"; $local_file = $strPath . "/" . date('Ymd') . ".txt"; if (!file_put_contents($local_file, $RENDER)) { die("could not write to file"); } $filesToDelete[] = $strPath . "/" . date("Ymd") . ".tar"; $this->backupsus($strPath); // delete all files in array (that is all images and the blm text file) foreach ($filesToDelete as $filename) { @unlink($filename); } $dst_dir = $CONFIG[FEED_NAME]['ftp_destination']; $ftp = new FTP($CONFIG[FEED_NAME]['ftp_server'], $CONFIG[FEED_NAME]['ftp_username'], $CONFIG[FEED_NAME]['ftp_password']); try { $ftp->upload($strPath, $dst_dir); } catch (Exception $e) { } file_put_contents(WS_PATH_LOGS . "/ftpUploadErrorLog.log", $ftp->getErrorLog(), FILE_APPEND); file_put_contents(WS_PATH_LOGS . "/ftpUploadMessageLog.log", $ftp->getMessageLog(), FILE_APPEND); // ================================================================================= // <<< functions }