예제 #1
0
function compile_requires($file_contents, $file_path)
{
    $file_dir = get_file_dir($file_path);
    $temp_array = array();
    $result = '';
    if (preg_match_all('/@requires\\s+([^\\s]+)/is', $file_contents, $temp_array)) {
        $required_files = $temp_array[1];
        foreach ($required_files as $required_file) {
            $content = compile_comments($file_dir . $required_file);
            $result .= "\r\n" . trim($content);
        }
        return $result;
    } else {
        return $file_contents;
    }
}
예제 #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);
    }
}
예제 #3
0
         build_directory_structure($filePath);
         if (FTP_ENABLED) {
             build_directory_structure_ftp($conn_id, get_file_dir($filePath));
         }
     }
     $pageToBeDeployedHandle = fopen(DOC_ROOT_PATH . $datarow[CSV_URL_INDEX], 'w') or die("can't open file");
     fwrite($pageToBeDeployedHandle, $pageToBeDeployed);
     chmod(DOC_ROOT_PATH . $datarow[CSV_URL_INDEX], 0777);
     // Close reference to file
     fclose($pageToBeDeployedHandle);
     if (FTP_ENABLED) {
         $pageToBeDeployedHandle = fopen(DOC_ROOT_PATH . $datarow[CSV_URL_INDEX], 'r') or die("can't open file");
         // change to proper dir
         if (!@ftp_chdir($conn_id, REMOTE_DOC_ROOT_PATH . get_file_dir($filePath))) {
             build_directory_structure_ftp($conn_id, get_file_dir($filePath));
             ftp_chdir($conn_id, REMOTE_DOC_ROOT_PATH . get_file_dir($filePath));
         }
         // try to upload $file
         if (ftp_fput($conn_id, get_file_name($filePath), $pageToBeDeployedHandle, FTP_ASCII)) {
             $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++;