OperatelogModel.class.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. *
  6. * @author J_da
  7. *
  8. */
  9. namespace Seller\Model;
  10. class OperatelogModel{
  11. /*
  12. DROP TABLE IF EXISTS `oscshop_lionfish_comshop_systemoperation_log`;
  13. CREATE TABLE `oscshop_lionfish_comshop_systemoperation_log` (
  14. `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id',
  15. `operation_type` enum('detailed_list') NOT NULL COMMENT '操作类型,detailed_list表示清单',
  16. `operation_seller_id` int(10) NOT NULL COMMENT '管理员id',
  17. `operation_seller_name` varchar(50) NOT NULL COMMENT '管理员名称',
  18. `ip` varchar(50) NOT NULL COMMENT 'ip',
  19. `content` text NOT NULL COMMENT '操作内容',
  20. `addtime` int(10) NOT NULL COMMENT '操作时间',
  21. PRIMARY KEY (`id`)
  22. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='狮子鱼商城系统操作日志表' AUTO_INCREMENT=1 ;
  23. */
  24. public function addOperateLog($operation_type,$content)
  25. {
  26. $ip = get_client_ip();
  27. $operation_seller_id = SELLERUID;
  28. if (defined('ROLE') && ROLE == 'agenter' ) {
  29. $operation_seller_id = $_SESSION["oscshop_seller_s"]["agent_auth"]["uid"];
  30. $items = M('lionfish_comshop_supply')->field('name')->where( array('id' =>$operation_seller_id ) )->find();
  31. $operation_seller_name ='供应商--'.$items['name'];
  32. }else{
  33. $items = M('seller')->field('s_uname')->where( array('s_id' =>$operation_seller_id ) )->find();
  34. $operation_seller_name = '管理员--'.$items['s_uname'];
  35. }
  36. $ins_data = array();
  37. $ins_data['operation_type'] = $operation_type;
  38. $ins_data['operation_seller_id'] = $operation_seller_id;
  39. $ins_data['operation_seller_name'] = $operation_seller_name;
  40. $ins_data['ip'] = $ip;
  41. $ins_data['content'] = $content;
  42. $ins_data['addtime'] = time();
  43. M('lionfish_comshop_systemoperation_log')->add($ins_data);
  44. }
  45. function get_ip_city($ip){
  46. $ch = curl_init();
  47. $url = 'https://whois.pconline.com.cn/ipJson.jsp?ip='.$ip;
  48. //用curl发送接收数据
  49. curl_setopt($ch, CURLOPT_URL, $url);
  50. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  51. //请求为https
  52. curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );
  53. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  54. $location = curl_exec($ch);
  55. curl_close($ch);
  56. //转码
  57. $location = mb_convert_encoding($location, 'utf-8','GB2312');
  58. //var_dump($location);
  59. //截取{}中的字符串
  60. $location = substr($location, strlen('({')+strpos($location, '({'),(strlen($location) - strpos($location, '})'))*(-1));
  61. //将截取的字符串$location中的‘,’替换成‘&’ 将字符串中的‘:‘替换成‘=’
  62. $location = str_replace('"',"",str_replace(":","=",str_replace(",","&",$location)));
  63. //php内置函数,将处理成类似于url参数的格式的字符串 转换成数组
  64. parse_str($location,$ip_location);
  65. return $ip_location['addr'];
  66. }
  67. }
  68. ?>