• 【PHP开发篇】一个统计客户端商机提交的获取IP地址


    1.对客服提交数据的ip地址记录。

    获取ip地址的方法:

            public function getIP() 
            { 
                global $ip; 
                if (getenv("HTTP_X_REAL_IP")) 
                $ip = getenv("HTTP_X_REAL_IP");
                else if (getenv("HTTP_CLIENT_IP")) 
                $ip = getenv("HTTP_CLIENT_IP"); 
                else if(getenv("HTTP_X_FORWARDED_FOR")) 
                $ip = getenv("HTTP_X_FORWARDED_FOR"); 
                else if(getenv("REMOTE_ADDR")) 
                $ip = getenv("REMOTE_ADDR"); 
                else 
                $ip = "Unknow"; 
    
                return $ip;
            } 
    

    ajax提交的请求处理function

     1     /*
     2      * ajax提交商机信息
     3      */
     4     public function ajaxPushAction(){
     5         $this->getRequest()->isPost() && $this->post = $this->getRequest()->getPost();
     6         if(!$this->post['t_name'] || !$this->post['t_tel']){
     7             $res = -1;
     8             Comm_Tools::renderJson($res);
     9         }
    10         $getip = $this->getIP();
    11         $this->post['getip'] = $getip;
    12         $url = "http://home.demo.cn/web/buss/ajaxPushBusinessToQueue";
    13         $res = Comm_Tools::curl($url, 'POST', $this->post);
    14         Comm_Tools::renderJson($res);
    15     }
  • 相关阅读:
    重构drf后的环境变量配置
    分离的前后台交互
    虚拟环境的搭建
    Python
    Python
    Python
    Python操作MongoDb数据库
    Python操作SQLite/MySQL/LMDB
    数据库-如何创建SQL Server身份验证用户
    Python
  • 原文地址:https://www.cnblogs.com/patf/p/5419907.html
Copyright © 2020-2023  润新知