OperatelogModel.class.php 3.1 KB

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