Cozza38

Untitled

May 16th, 2015
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. function getNetwork()
  2. {
  3. // It should be noted that this function is designed specifically for getting the local / wan name for Plex.
  4. global $domain_name;
  5. global $plex_server_ip;
  6.  
  7. $clientIP = get_client_ip();
  8. if ($clientIP == $plex_server_ip):
  9. $network = 'http://' . $plex_server_ip;
  10. else:
  11. $network = 'http://' . $domain_name;
  12. endif;
  13. return $network;
  14. }
  15.  
  16. function get_client_ip()
  17. {
  18. if (isset($_SERVER["REMOTE_ADDR"])) {
  19. $ipaddress = $_SERVER["REMOTE_ADDR"];
  20. } else if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
  21. $ipaddress = $_SERVER["HTTP_X_FORWARDED_FOR"];
  22. } else if (isset($_SERVER["HTTP_CLIENT_IP"])) {
  23. $ipaddress = $_SERVER["HTTP_CLIENT_IP"];
  24. }
  25. return $ipaddress;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment