Advertisement
Guest User

helper.php

a guest
Jul 10th, 2012
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. helper.php    
  2.  
  3.  /**
  4.          * @brief Returns the server protocol
  5.          * @returns the server protocol
  6.          *
  7.          * Returns the server protocol. It respects reverse proxy servers and load balancers
  8.          */
  9.     public static function serverProtocol() {
  10.  
  11.         if ($_SERVER['HTTP_X_FORWARDED_HOST'] == 'ssl-account.com'){
  12.             $proto = 'https';
  13.         }else{
  14.             if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
  15.                 $proto = strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']);
  16.             }else{
  17.                 if(isset($_SERVER['HTTPS']) and !empty($_SERVER['HTTPS']) and ($_SERVER['HTTPS']!='off')) {
  18.                     $proto = 'https';
  19.                 }else{
  20.                     $proto = 'http';
  21.                 }
  22.             }  
  23.         }
  24.         return($proto);
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement