Ejemplo n.º 1
0
function buildListPage($listPageObject)
{
    global $errorArray;
    global $successArray;
    global $templateHtml;
    global $statusFile;
    global $pageBeforeContent;
    global $pageAfterContent;
    global $conn_id;
    global $listCounter;
    global $numListPages;
    $errorSize = count($errorArray);
    fwrite($statusFile, "<strong>(" . ($listCounter + 1) . "/{$numListPages}) Memory Used:" . memory_get_usage() . "</strong>  " . $listPageObject->url . ":<br>");
    fwrite($statusFile, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $listPageObject->toString() . "<br>");
    //Open handle to page
    if (!file_exists(DOC_ROOT_PATH . "{$listPageObject->url}")) {
        build_directory_structure($listPageObject->url);
    }
    $pageToBeDeployedHandle = fopen(DOC_ROOT_PATH . $listPageObject->url, 'w') or die("can't open file");
    //Insert title into head section
    $updatedPageBeforeContent = str_replace("#head-additional-styles-and-scripts#", "<title>{$listPageObject->listingName} Vacation and Resort Listing</title>", $pageBeforeContent);
    // Add the remote path where the installation is located
    $updatedPageBeforeContent = str_replace("#remote-install-path#", REMOTE_INSTALL_PATH, $updatedPageBeforeContent);
    // Replace the agency code
    $updatedPageBeforeContent = str_replace("#agency-code#", AGENCY_CODE, $updatedPageBeforeContent);
    //Insert country code and empty hotel code for search
    $updatedPageBeforeContent = str_replace("#country-code-upper##hotel-code-upper#", "", $updatedPageBeforeContent);
    if (property_exists($listPageObject, "countryCode")) {
        $updatedPageBeforeContent = str_replace("#country-code-upper#", $listPageObject->countryCode, $updatedPageBeforeContent);
        $updatedPageBeforeContent = str_replace("#dest-region#", "", $updatedPageBeforeContent);
    } else {
        // Chain pages we aren't sure of country or hotel, so just filter by destination region
        $updatedPageBeforeContent = str_replace("#country-code-upper#", "", $updatedPageBeforeContent);
        $updatedPageBeforeContent = str_replace("#hotel-code-upper#", "", $updatedPageBeforeContent);
        $updatedPageBeforeContent = str_replace("#dest-region#", DEST_REGION_FILTER, $updatedPageBeforeContent);
    }
    $updatedPageBeforeContent = str_replace("#meta-keywords#", $listPageObject->listingName . ", " . $listPageObject->listingName . " hotel, " . $listPageObject->listingName . " resort, " . $listPageObject->listingName . " all inclusive", $updatedPageBeforeContent);
    $updatedPageBeforeContent = str_replace("#meta-description#", PRETTY_SITE_NAME . " provides All-inclusive vacations to " . $listPageObject->listingName . ".  Great prices, personal service, and can price match (then beat) any other offer.", $updatedPageBeforeContent);
    //Write html before the content
    fwrite($pageToBeDeployedHandle, $updatedPageBeforeContent);
    //Check to see if we should treat as a hotel chain object or standard hotel object
    if (strcmp(get_class($listPageObject), "ChainListPageObject") != 0) {
        foreach ($listPageObject->hotelCodes as $childHotel) {
            $hotelListObject = get_hotel_info($listPageObject->countryCode, $childHotel);
            if (!empty($hotelListObject->hotelName)) {
                $listOutput = $hotelListObject->formattedOutput();
                fwrite($statusFile, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $hotelListObject->hotelName . "<br>");
                //Write html for current hotel
                fwrite($pageToBeDeployedHandle, $listOutput);
            } else {
                $errorArray[$hotelListObject->countryCode . $hotelListObject->hotelCode] = "countryCode:{$hotelListObject->countryCode}, hotelCode:{$hotelListObject->hotelCode}";
            }
            if (kill_build()) {
                fwrite($statusFile, "<br>BUILD KILLED!!!<br>");
                $errorArray[] = "Build Killed!";
                break;
            }
        }
    } else {
        foreach ($listPageObject->hotels as $hotelListObject) {
            if (!empty($hotelListObject->hotelName)) {
                $listOutput = $hotelListObject->formattedOutput();
                fwrite($statusFile, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $hotelListObject->hotelName . "<br>");
                //Write html for current hotel
                fwrite($pageToBeDeployedHandle, $listOutput);
            } else {
                $errorArray[$hotelListObject->countryCode . $hotelListObject->hotelCode] = "countryCode:{$hotelListObject->countryCode}, hotelCode:{$hotelListObject->hotelCode}";
            }
            if (kill_build()) {
                fwrite($statusFile, "<br>BUILD KILLED!!!<br>");
                $errorArray[] = "Build Killed!";
                break;
            }
        }
    }
    fwrite($statusFile, "<br>");
    $pageAfterContent = str_replace("#pretty-site-name#", PRETTY_SITE_NAME, $pageAfterContent);
    //Write html after the content
    fwrite($pageToBeDeployedHandle, $pageAfterContent);
    chmod(DOC_ROOT_PATH . "{$listPageObject->url}", 0777);
    // Close reference to file
    fclose($pageToBeDeployedHandle);
    if (FTP_ENABLED) {
        $pageToBeDeployedHandle = fopen(DOC_ROOT_PATH . $listPageObject->url, 'r') or die("can't open file");
        // change to proper dir
        build_directory_structure_ftp($conn_id, get_file_dir($listPageObject->url));
        ftp_chdir($conn_id, REMOTE_DOC_ROOT_PATH . get_file_dir($listPageObject->url));
        // try to upload $file and check if all the hotels in list were successfully added (errors start == errors end)
        if (ftp_fput($conn_id, get_file_name($listPageObject->url), $pageToBeDeployedHandle, FTP_ASCII) && $errorSize == count($errorArray)) {
            $successArray[] = "http://" . SITE_DOMAIN . $listPageObject->url;
        } else {
            if ($errorSize == count($errorArray)) {
                // If the error count is equal then it is FTP error, else has been logged above
                $errorArray[] = "FTP error: {$listPageObject->url}";
            }
        }
        // Close reference to file
        fclose($pageToBeDeployedHandle);
    }
}
Ejemplo n.º 2
0
<?php

include_once "global-constants.php";
ini_set('error_reporting', E_ALL);
error_reporting(E_ALL);
ini_set('log_errors', TRUE);
ini_set('html_errors', FALSE);
ini_set('error_log', ERROR_LOG);
ini_set('display_errors', TRUE);
ini_set('memory_limit', '268435456');
ini_set('max_execution_time', '120');
// 0 = no limit.
ignore_user_abort(true);
include_once "helpers.php";
include_once "json.php";
$json = new Services_JSON();
$destinationCode = strtoupper($_GET["destinationCode"]);
$hotelCode = strtoupper($_GET["hotelCode"]);
$hotelObject = null;
if (isInDiskCache(CACHE_DESCRIPTION_PATH, $destinationCode . $hotelCode)) {
    $hotelObject = readHotelFromDiskCache($destinationCode, $hotelCode);
} else {
    $hotelObject = get_hotel_info($destinationCode, $hotelCode, false);
    writeHotelToDiskCache($hotelObject);
}
$jsonResponse = array("url" => "" . $hotelObject->hotelUrl, "desc" => "" . $hotelObject->hotelShortDescription . "(more)");
echo $json->encode($jsonResponse);
Ejemplo n.º 3
0
 //+6 to remove the head element since we already include in template.html
 $headFinish = strpos($theContent, "</head>") - $headStart;
 //	Don't want to share styles with this page so not resolving the css paths
 //$headSection = convert_relative_paths(substr($theContent, $headStart, $headFinish), TI_DOCROOT_URL);
 $headSection = substr($theContent, $headStart, $headFinish);
 $titleStart = strpos($headSection, "<title>");
 $titleEnd = strpos($headSection, "</title>");
 $headSection = substr($headSection, 0, $titleStart) . "<title>" . $datarow[CSV_HOTEL_NAME_INDEX] . " - All Inclusive vacations in " . $datarow[CSV_CITY_OR_STATE_INDEX] . " " . $datarow[CSV_COUNTRY_INDEX] . "</title>" . substr($headSection, $titleEnd + 8);
 $pageToBeDeployed = str_replace("#head-additional-styles-and-scripts#", $headSection, $pageToBeDeployed);
 $pageToBeDeployed = str_replace("#country-code-upper#", substr(strtoupper($datarow[CSV_COUNTRY_CODE_INDEX]), 0, 3), $pageToBeDeployed);
 $pageToBeDeployed = str_replace("#hotel-code-upper#", strtoupper($datarow[CSV_HOTEL_CODE_INDEX]), $pageToBeDeployed);
 $pageToBeDeployed = str_replace("#meta-keywords#", $datarow[CSV_HOTEL_NAME_INDEX] . ", " . $datarow[CSV_HOTEL_NAME_INDEX] . " " . $datarow[CSV_COUNTRY_INDEX] . ", " . $datarow[CSV_HOTEL_NAME_INDEX] . " " . $datarow[CSV_COUNTRY_INDEX] . " hotel, " . $datarow[CSV_HOTEL_NAME_INDEX] . " resort, " . $datarow[CSV_HOTEL_NAME_INDEX] . " hotel, " . $datarow[CSV_COUNTRY_INDEX] . " " . $datarow[CSV_HOTEL_NAME_INDEX] . ", " . $datarow[CSV_HOTEL_NAME_INDEX] . " all inclusive", $pageToBeDeployed);
 // Change to include the description from hotel info instead of generic line.  TODO, go back and replace this whole page
 //	to use the OO technique.
 //$pageToBeDeployed = str_replace("#meta-description#", PRETTY_SITE_NAME." provides All-inclusive vacations to ".$datarow[CSV_HOTEL_NAME_INDEX]." in ".$datarow[CSV_COUNTRY_INDEX].".  Great prices, personal service, and can price match (then beat) any other offer.", $pageToBeDeployed);
 $hotelObject = get_hotel_info($countryCode, $hotelCode, false);
 $pageToBeDeployed = str_replace("#meta-description#", $hotelObject->hotelShortDescription, $pageToBeDeployed);
 $pageToBeDeployed = str_replace("#agency-code#", AGENCY_CODE, $pageToBeDeployed);
 $pageToBeDeployed = str_replace("#pretty-site-name#", PRETTY_SITE_NAME, $pageToBeDeployed);
 // Trim the content area of the TI page
 $theContent = substr($theContent, strpos($theContent, '<div id="main">'));
 $theContent = convert_relative_paths(substr($theContent, 0, strpos($theContent, '<div id="footer_ext">')), TI_DOCROOT_URL);
 $tripAdvisor = '<div class="hotel_review"><iframe src=http://www.tripadvisor.com/WidgetEmbed-cdspropertysummary?display=true&amp;partnerId=CEBBFA18F4BB11DDBF8ADA0256D89593&amp;lang=en&amp;locationId=' . strtoupper($countryCode) . strtoupper($hotelCode) . ' width="240" height="320" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe></div>';
 $tripAdvisorPosition = strpos($theContent, '<div class="hotel_vtour">');
 $tripAdvisorPosition = strpos($theContent, '</div>', $tripAdvisorPosition) + 6;
 $theContent = str_insert($tripAdvisor, $theContent, $tripAdvisorPosition);
 $pageToBeDeployed = str_replace("#content#", $theContent, $pageToBeDeployed);
 // Detail pages already have their destination filtered
 $pageToBeDeployed = str_replace("#dest-region#", "", $pageToBeDeployed);
 // Add the remote path where the installation is located
 $pageToBeDeployed = str_replace("#remote-install-path#", REMOTE_INSTALL_PATH, $pageToBeDeployed);
Ejemplo n.º 4
0
 function addListing($countryCode_, $hotelCode_)
 {
     $this->hotels[] = get_hotel_info($countryCode_, $hotelCode_);
 }