PageRenderTime 46ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/classes/bors/client.php

https://bitbucket.org/Balancer/bors-core
PHP | 44 lines | 35 code | 9 blank | 0 comment | 3 complexity | 2ca43d2a1c40c26e108f779b5cdb3633 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-3.0
  1. <?php
  2. class bors_client extends bors_object_simple
  3. {
  4. function can_cached() { return false; }
  5. function is_bot() { return empty($GLOBALS['client']['is_bot']) ? false : $GLOBALS['client']['is_bot']; }
  6. function is_crawler() { return @$GLOBALS['client']['is_crawler']; }
  7. static function factory($ip) { return bors_load(__CLASS__, $ip); }
  8. function ip()
  9. {
  10. if($this->id())
  11. return $this->id();
  12. if(empty($_SERVER['HTTP_X_FORWARDED_FOR']))
  13. return empty($_SERVER['REMOTE_ADDR']) ? NULL : $_SERVER['REMOTE_ADDR'];
  14. return $_SERVER['HTTP_X_FORWARDED_FOR'];
  15. }
  16. function referer() { return @$_SERVER['HTTP_REFERER']; }
  17. function agent() { return empty($_SERVER['HTTP_USER_AGENT']) ? NULL : $_SERVER['HTTP_USER_AGENT']; }
  18. function url()
  19. {
  20. $url = 'http://'.$_SERVER['HTTP_HOST'].'/'.$_SERVER['REQUEST_URI'];
  21. if($_SERVER['QUERY_STRING'])
  22. $url .= '?'.$_SERVER['QUERY_STRING'];
  23. return $url;
  24. }
  25. function place()
  26. {
  27. require_once('inc/clients/geoip-place.php');
  28. return geoip_place($this->ip());
  29. }
  30. function flag()
  31. {
  32. require_once('inc/clients/geoip-place.php');
  33. return geoip_flag($this->ip());
  34. }
  35. }