linuxfront-v2-logistics/app-admin/index.php

Overview

This file serves as the entry point for the logistics application’s admin interface. Upon access, it immediately redirects users to the external admin portal at app-admin.freightanywhere.com.


Purpose

  • Ensure that any attempt to reach the local app-admin folder lands on the centralized admin application.
  • Provide both client-side and server-side redirection to maximize compatibility.
  • Prevent direct interaction with backend files in this directory.

Redirect Logic 🚀

Below is the complete content of index.php. It implements a two-fold redirection strategy:

<script type="text/javascript">
  // Client-side redirect for modern browsers
  window.location = "http://app-admin.freightanywhere.com/";
</script>
<?php
  // Server-side fallback redirect
  header("http://app-admin.freightanywhere.com/");
  exit();
?>

(excerpted from the source file )


Code Breakdown

Step Layer Statement Purpose
1 JavaScript (HTML) <script> window.location = "http://app-admin.freightanywhere.com/"; </script> Triggers immediate redirect in the browser
2 PHP header("http://app-admin.freightanywhere.com/"); exit(); Ensures redirect when JS is disabled or blocked

Usage Flow

  1. Browser loads this minimal PHP file.
  2. JavaScript executes and navigates the user to the admin domain.
  3. If JS is turned off, PHP’s header() call triggers an HTTP redirect.
  4. exit() halts further processing.

  • Configuration: In inc/config.php, constants like APP_ADMIN_URL and APP_ADMIN_DIR define trusted admin endpoints and directories .
  • Companion Directory: A similar redirect exists in linuxfront-v2/app-admin/index.php (points to a beta URL) .
  • Security Guards: Other parts of the app use session checks (e.g., user_secure.inc.php) to control access before forwarding to this script.

Security Considerations ⚠️

  • The hard-coded URL prevents open-redirect exploits.
  • No additional output avoids header errors.
  • Ensure this file cannot be overwritten or modified by unauthorized users.

Conclusion

This lightweight redirect script streamlines access to the centralized admin portal, combining both client-side and server-side techniques to ensure all users are properly forwarded.