Exemplo n.º 1
0
                $successArray[] = "http://www.iwanttolol.com/" . $datarow[CSV_URL_INDEX];
            } else {
                $errorArray[] = "FTP error: {$thePage}";
            }
            // Close reference to file
            fclose($pageToBeDeployedHandle);
        }
    } else {
        $errorArray[] = "No content (" . strlen($theContent) . "): {$thePage}";
        error_log("No content: {$thePage}.   Content: \n" . $theContent, 0);
    }
    $counter++;
    if (DEBUG_MODE && $counter > 8) {
        break;
    }
    if ($counter % 4 == 0) {
        echo "..";
        @ob_flush();
        @flush();
    }
    if (kill_build()) {
        fwrite($statusFile, "<br>BUILD KILLED!!!<br>");
        $errorArray[] = "Build Killed!";
        break;
    }
}
if (FTP_ENABLED) {
    // close the connection and the file handler
    ftp_close($conn_id);
}
fwrite($statusFile, "Finished generate-detail-pages.php<br>");
Exemplo n.º 2
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);
    }
}
Exemplo n.º 3
0
function createMenu($hotelcsv, &$parentMenuObject, $navAppend = "", &$listPageObjectArray, $hotelChainMenu = false)
{
    global $statusFile;
    $maxRows = count($hotelcsv);
    $rowCounter = 0;
    $currentCountryMenuObject = null;
    $currentStateMenuObject = null;
    $currentHotelChainObject = null;
    $previousRow = null;
    $currentListObject = null;
    $debugCounter = 0;
    while ($rowCounter < $maxRows) {
        $currentRow = $hotelcsv[$rowCounter];
        if (empty($navAppend) || !empty($navAppend) && strpos($currentRow[CSV_TYPE_INDEX], $navAppend) !== false) {
            $hotelMenuObject = new MenuJSONObject($currentRow[CSV_HOTEL_NAME_INDEX], "/" . $currentRow[CSV_URL_INDEX], $navAppend);
            if ($hotelChainMenu) {
                $debugCounter++;
                if (DEBUG_MODE && $debugCounter > 6) {
                    break;
                }
                if (kill_build()) {
                    if (isset($statusFile)) {
                        fwrite($statusFile, "<br>BUILD KILLED!!!<br>");
                    }
                    $errorArray[] = "Build Killed!";
                    break;
                }
                //If same hotel chain then add to existing listing
                if (isSameHotelChainAsPrevious($currentRow, $previousRow)) {
                    //Add the hotel chain to the submenu
                    $currentHotelChainMenuObject->addSubmenu($hotelMenuObject);
                    //Listing is the same regardless
                    $currentListObject->addListing($currentRow[CSV_COUNTRY_CODE_INDEX], $currentRow[CSV_HOTEL_CODE_INDEX]);
                    //If not create a new listing and add it
                } else {
                    //Create new hotel chain menu object
                    $hotelChainUrl = create_hotel_chain_url($currentRow);
                    $currentHotelChainMenuObject = new MenuJSONObject($currentRow[CSV_HOTEL_CHAIN_INDEX], $hotelChainUrl);
                    $currentHotelChainMenuObject->addSubmenu($hotelMenuObject);
                    //Tack on the hotel chain to the parent object
                    $parentMenuObject->addSubmenu($currentHotelChainMenuObject);
                    //New listing object as well
                    $chainPath = $currentRow[CSV_HOTEL_CHAIN_INDEX];
                    $currentListObject = new ChainListPageObject($chainPath, $currentRow[CSV_HOTEL_CHAIN_INDEX]);
                    $currentListObject->addListing($currentRow[CSV_COUNTRY_CODE_INDEX], $currentRow[CSV_HOTEL_CODE_INDEX]);
                    $listPageObjectArray[] = $currentListObject;
                }
            } else {
                if (isSameStateAsPrevious($currentRow, $previousRow) && isSameCountryAsPrevious($currentRow, $previousRow)) {
                    //If no state these will still be equal
                    if (empty($currentStateMenuObject)) {
                        //Empty state field in the csv
                        $currentCountryMenuObject->addSubmenu($hotelMenuObject);
                    } else {
                        $currentStateMenuObject->addSubmenu($hotelMenuObject);
                    }
                    //Listing is the same regardless
                    $currentListObject->addListing($currentRow[CSV_HOTEL_CODE_INDEX]);
                } else {
                    if (isSameCountryAsPrevious($currentRow, $previousRow)) {
                        //Means same country but different states
                        //Create a new parent object for this state
                        $stateUrl = create_listing_url($currentRow, $navAppend);
                        $currentStateMenuObject = new MenuJSONObject($currentRow[CSV_CITY_OR_STATE_INDEX], $stateUrl, $navAppend);
                        //Add the hotel to the new state
                        $currentStateMenuObject->addSubmenu($hotelMenuObject);
                        //Add the new state to the country
                        $currentCountryMenuObject->addSubmenu($currentStateMenuObject);
                        //New listing object as well
                        $currentListObject = new ListPageObject($currentRow, $navAppend);
                        $currentListObject->addListing($currentRow[CSV_HOTEL_CODE_INDEX]);
                        $listPageObjectArray[] = $currentListObject;
                    } else {
                        if (empty($currentRow[CSV_CITY_OR_STATE_INDEX])) {
                            //Create new country menu object
                            $countryUrl = create_listing_url($currentRow, $navAppend);
                            $currentCountryMenuObject = new MenuJSONObject($currentRow[CSV_COUNTRY_INDEX], $countryUrl, $navAppend);
                            //If no state then null out the state object
                            $currentStateMenuObject = null;
                            $currentCountryMenuObject->addSubmenu($hotelMenuObject);
                        } else {
                            //Create new country menu object, but no url since the states will carry the list page urls
                            $countryUrl = create_listing_url($currentRow, $navAppend);
                            $currentCountryMenuObject = new MenuJSONObject($currentRow[CSV_COUNTRY_INDEX], "", $navAppend);
                            //If has a state, create that as well
                            $stateUrl = create_listing_url($currentRow, $navAppend);
                            $currentStateMenuObject = new MenuJSONObject($currentRow[CSV_CITY_OR_STATE_INDEX], $stateUrl, $navAppend);
                            $currentStateMenuObject->addSubmenu($hotelMenuObject);
                            $currentCountryMenuObject->addSubmenu($currentStateMenuObject);
                        }
                        //Tack on the country to the parent object
                        $parentMenuObject->addSubmenu($currentCountryMenuObject);
                        //New listing object as well
                        $currentListObject = new ListPageObject($currentRow, $navAppend);
                        $currentListObject->addListing($currentRow[CSV_HOTEL_CODE_INDEX]);
                        $listPageObjectArray[] = $currentListObject;
                    }
                }
            }
            $previousRow = $currentRow;
        }
        $rowCounter++;
    }
}