12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/6/11
- * Time: 上午9:28
- */
- namespace common\api;
- use Yii;
- use yii\base\Component;
- class HttpServer extends Component{
- public function GetCurUrl()
- {
- $url='http://';
- if(isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']=='on'){
- $url='https://';
- }
- if($_SERVER['SERVER_PORT']!='80'){
- $url.=$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI'];
- }else{
- $url.=$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
- }
- return $url;
- }
- public function GetReferer()
- {
- if (!empty($_SERVER['HTTP_REFERER'])) {
- return $_SERVER['HTTP_REFERER'];
- }
- }
- function getAgentInfo()
- {
- if (!empty($_SERVER['HTTP_USER_AGENT'])) {
- $OS = $_SERVER['HTTP_USER_AGENT'];
- if (preg_match('/win/i', $OS)) {
- $OS = 'Windows';
- } elseif (preg_match('/mac/i', $OS)) {
- $OS = 'MAC';
- } elseif (preg_match('/linux/i', $OS)) {
- $OS = 'Linux';
- } elseif (preg_match('/unix/i', $OS)) {
- $OS = 'Unix';
- } elseif (preg_match('/bsd/i', $OS)) {
- $OS = 'BSD';
- } else {
- $OS = 'Other';
- }
- return $OS;
- } else {
- return "unknown";
- }
- }
- }
|