Route_28Dec17.php 🚦

This front‐controller file handles all incoming requests for the LinuxFront V2 Logistics site.
It loads configuration, routes API calls, serves assets, includes dynamic pages, and maps CMS templates.

Overview

Route_28Dec17.php orchestrates which script or template to include based on host, file extension, and requested page.
It ensures API endpoints, JavaScript assets, static files, CMS pages, and error pages load correctly.

Dependencies ⚙️

  • inc/config.php: Defines constants like SITE_DIR, TEMPLATE_DIR, SITE_JS_DIR, TEMPLATE_JS_DIR.
  • $file_extension: Holds the requested file’s extension.
  • $currnt_file_name: Stores the basename of the requested URI.
  • $TEMPLATE: An array mapping template filenames to page configurations.

Routing Flowchart

flowchart TD
  A[Start Request] --> B{Host == api.techlogistics.com?}
  B -- Yes --> C[Include API Top Script] --> Z[Exit]
  B -- No --> D{Extension == "js"?}
  D -- Yes --> E[Check SITE_JS_DIR] --> F{Exists?}
  F -- Yes --> G[Include Site JS] --> Z
  F -- No --> H[Check TEMPLATE_JS_DIR] --> I{Exists?}
  I -- Yes --> J[Include Template JS] --> Z
  I -- No --> K[Echo "No File Exist"] --> Z
  D -- No --> L[Check SITE_DIR for Static File]
  L -- Found --> M[Include Static File] --> Z
  L -- Not Found --> N{$TEMPLATE defines page?}
  N -- No --> O[Include 404.php]
  N -- Yes --> P{Popup Page?}
  P -- Yes --> Q[Include popup_template.php]
  P -- No --> R{CMS Page?}
  R -- Yes --> S[Set $currentcmsPage & Include cms.php]
  R -- No --> T[Include site_template.php]
  Z[Exit]

API Host Check 🌐

When $_SERVER["HTTP_HOST"] equals api.techlogistics.com, the file immediately includes the API top script:

if ($_SERVER["HTTP_HOST"] === 'api.techlogistics.com') {
    include TEMPLATE_DIR . '/rating_ltlquote_api_v1/rating_ltlquote_api_v1_top.php';
    exit;
}

This serves version 1 of the LTL rating API and stops further routing.

JavaScript Asset Handling 📄

If the requested URI ends in .js, the router:

  • Checks SITE_JS_DIR for the file
  • Falls back to TEMPLATE_JS_DIR
  • Otherwise returns No File Exist
Check Order Path Action
Site JS Directory SITE_DIR . SITE_JS_DIR . $currnt_file_name include_once if exists
Template JS Dir TEMPLATE_DIR . TEMPLATE_JS_DIR . $currnt_file_name include_once if exists
Fallback — echo "No File Exist"

After serving or echoing, the script exits.

Static File Inclusion 📂

For non-JS requests, the router checks:

if (file_exists(SITE_DIR . $currnt_file_name)) {
    include_once(SITE_DIR . $currnt_file_name);
    exit;
}

This allows custom scripts or static pages placed directly under SITE_DIR to load.

CMS & Popup Template Handling 📑

If no static file exists, the router consults the $TEMPLATE array:

  • Undefined template → serves 404.php
  • Popup pages → serves popup_template.php
  • CMS pages → sets $currentcmsPage and serves cms.php
  • Default → serves site_template.php
$popup_template_pages = [
  'nmfc_no_help.php', 'freight_class_help.php', 'shippment_detail.php',
  'choose_address.php', 'choose_product.php', 'canadian_customer_popup.php'
];

Requests for these filenames always use the popup wrapper.

CMS Page Mapping 🗺️

Filename $currentcmsPage Key
privacy_policy.php privacy_policy
terms_and_conditions.php terms_and_conditions
notification_of_infringement_dmca_policy.php notification_of_infringement_dmca_policy
request_a_quote.php request_a_quote
expedited_brokerage_services.php expedited_brokerage_services
freight_spend_management.php freight_spend_management
pre_auditing_and_carrier_payment_made_easy.php pre_auditing_and_carrier_payment_made_easy
monthly_savings_reports.php monthly_savings_reports
our_technology_advantage.php our_technology_advantage
easy_freight_claimsexpert_freight_claims_management.php easy_freight_claimsexpert_freight_claims_management
international_freight_spend_savings.php international_freight_spend_savings
the_tech_logistics_process.php the_tech_logistics_process
request_consultation.php request_consultation
brokerage_services.php brokerage_services
truckload_service.php truckload_service
ltl_service.php ltl_service
heavy_haul_services.php heavy_haul_services
inter_modal_rail_service.php inter_modal_rail_service
air_freight_services.php air_freight_services
ocean_freight.php ocean_freight
tech_logistics_ltl_freight_higher_profits_superior_technology.php tech_logistics_ltl_freight_higher_profits_superior_technology
solving_late_deliveries_time_sensitive_freight.php solving_late_deliveries_time_sensitive_freight
complicated_deliveries_going_to_a_hospital_in_canada.php complicated_deliveries_going_to_a_hospital_in_canada
tech_logistics_small_package_client_saves_hundreds_of_thousands_of_dollars.php tech_logistics_small_package_client_saves_hundreds_of_thousands_of_dollars
asia_import_freight_program_time.php asia_import_freight_program_time
brokerage_international_freight.php brokerage_international_freight
case_study.php case_study
perishable_freight_new_intermodal_system.php perishable_freight_new_intermodal_system
north_american_imports_exports_international_logistics_program.php north_american_imports_exports_international_logistics_program

Each mapping sets $currentcmsPage before including cms.php.

Fallback Handling 🔙

If no CMS mapping matches, the router includes the site_template.php file:

else {
  include_once("site_template.php");
}

This delivers the main site layout and content.

Code Snippet Example 💡

// Dynamic CMS page loader
else if ($currnt_file_name === 'privacy_policy.php') {
    $currentcmsPage = 'privacy_policy';
    include_once("cms.php");
}

It sets context for the CMS engine and loads the shared CMS template.


🚀 Route_28Dec17.php simplifies content delivery by centralizing all include logic. It adapts to API hosts, serves assets, supports popups, loads CMS pages, and fails gracefully.