Configuration Bootstrap (inc/config.php)
This file initializes the Tech Logistics web application environment. It manages sessions, security headers, error handling, directory constants, template mappings, and metadata. By including this file at the top of every page, the application ensures consistent configuration and behavior.
🔐 Session & Cookie Management
This section handles PHP sessions and custom session IDs for embedded contexts.
- Checks if the request’s
HTTP_REFERERmatches the Freight Anywhere portal. - If
sess_idoridis provided, it:- Calls
session_id()to reuse that session. - Starts the session with
session_start(). - Stores the session ID in
$_SESSION["header_view_sessionID"]. - Sends a custom
GMIIDcookie withSameSite=None; Secure. - Flags
$_SESSION["header_view_ignore"] = true.
- Calls
- Otherwise, it starts a new session by default.
if (isset($_SERVER['HTTP_REFERER'])
&& $_SERVER['HTTP_REFERER']=='https://tech.freightanywhere.com/') {
// Use provided session id
if (isset($_REQUEST['sess_id']) || isset($_REQUEST['id'])) {
session_id($_REQUEST['sess_id'] ?? $_REQUEST['id']);
session_start();
$_SESSION["header_view_sessionID"]=session_id();
header('Set-Cookie: GMIID=' . session_id() . '; SameSite=None; Secure');
$_SESSION["header_view_ignore"]=true;
}
} else {
session_start();
}
🌐 CORS & HTTP Headers
The file sets headers to allow cross-origin requests and standard HTTP methods:
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Headers: Origin, Content-Type, Accept, Authorization, X-Request-With, Set-Cookie, Cookie, Bearer');
These headers enable AJAX clients from any origin to interact with this API securely.
🚀 Error Reporting & Performance
- Memory Limit: Unlimited (
-1) to handle large payloads. - Error Reporting: Disabled (
error_reporting(0)) for production stability. - Profiler Flag: Controlled by the
PROFILERconstant.
ini_set('memory_limit','-1');
error_reporting(0);
📁 Directory & URL Constants
The application relies on consistent directory paths and base URLs.
| Constant | Description | Example Value |
|---|---|---|
| PORTAL | Domain identifier for portal-specific logic | techlogistics.com |
| TEMPLATE_DIR | Path to shared template files | /var/www/tech-portals/fawv2-tech-templates/ |
| SITE_DIR | Path to site-specific PHP files | /var/www/tech-portals/linuxfront-v2-logistics/ |
| APP_ADMIN_DIR | Admin portal files directory | /var/www/tech-portals/app-admin.freightanywhere.com/ |
| SITE_PATH | Base URL of current server | https://trynew.techlogistics.com/ (dynamic override) |
| TEMPLATE_JS_DIR | Sub-directory for template JS files | inc/scripts/ |
| SITE_JS_DIR | Sub-directory for site JS files | js/ |
$server_name = "https://trynew.techlogistics.com/";
if (!empty($_SERVER['SERVER_NAME'])) {
$server_name = "https://".$_SERVER['SERVER_NAME']."/";
}
define("PORTAL", "techlogistics.com");
define("TEMPLATE_DIR", "/var/www/tech-portals/fawv2-tech-templates/");
define("SITE_DIR", "/var/www/tech-portals/linuxfront-v2-logistics/");
define("APP_ADMIN_DIR", "/var/www/tech-portals/app-admin.freightanywhere.com/");
define("SITE_PATH", $server_name);
define("PROFILER", false);
🔑 Google Authenticator Integration
The file includes the PHPGangsta Google Authenticator library to support 2FA:
include_once "/var/www/tech-portals/fawv2-tech-templates/inc/libs/2fa/PHPGangsta/GoogleAuthenticator.php";
This enables OTP generation and verification in other parts of the application .
🏗️ Template & Database Configuration
After defining constants, the file incorporates shared template and database settings:
include_once(TEMPLATE_DIR . "inc/templates-config.php");
This pulls in database credentials, paging configuration, and other global settings .
📧 Email Addresses & Banner Control
Predefines key contact emails and excludes certain templates from banner display:
define("LOGISTICS_EMAIL","[email protected]");
define("INFO_EMAIL","[email protected]");
define("SALES_EMAIL","[email protected]");
define("ADAM_EMAIL","[email protected]");
define("STACY_EMAIL","[email protected]");
define("ROGER_EMAIL","[email protected]");
define("IMTIAZ_EMAIL","[email protected]");
define("TEST_EMAIL","[email protected]");
$exclude_banner = [
"start_quote","fetching_rates","select_carrier",
"provide_details","bookit","finish_shipment",
"shipment_success","cwt_rates"
];
🏷️ Page Metadata Configuration
The file maintains a map of default and page-specific <title> and <meta> descriptions. It selects the right metadata based on basename($_SERVER['PHP_SELF']):
$META = [
'default' => [
'title' => 'Freight Anywhere: We help shippers save thousands…',
'description' => 'Freight Anywhere helps freight managers…',
],
'index.php' => [
'title' => 'Tech Logistics: Smarter Freight Solutions…',
'description' => 'Discover Tech Logistics: innovative freight…'
],
// …other pages
];
$current_file = basename($_SERVER['PHP_SELF']);
$page_meta = $META[$current_file] ?? $META['default'];
$PAGE_TITLE = $page_meta['title'];
$MEATA['description'] = $page_meta['description'];
$MEATA['keywords'] = $page_meta['keywords'];
🔗 Integration & Usage
- Included by site templates to bootstrap every front-end page .
- Loaded by route scripts (
route.php,popup_template.php,report_app.php) to enforce consistent setup. - Provides global variables (
$TEMPLATE,$JS,$CSS) used downstream for asset loading and rendering.
flowchart LR
A[Client Request] --> B[route.php]
B --> C[inc/config.php]
C --> D[inc/templates-config.php]
C --> E[Session & CORS Setup]
C --> F[Constants & Metadata]
B --> G[Render Page/Template]
🛠️ Key Takeaways
- Centralized Bootstrapping: All essential setup occurs in one file.
- Flexible Deployment: Dynamic
SITE_PATHand directory constants adapt to different environments. - Secure & Controlled: Custom session handling, strict CORS, and no error leakage.
- Extensible: Easy to add new metadata, email contacts, or template overrides.
This comprehensive configuration file ensures that the Tech Logistics platform initializes reliably, securely, and consistently across all request handlers and templates.