public function postComment() { $data = array(); $data['data_id'] = I('post.id', '', 'htmlspecialchars'); //数据ID $data['pid'] = I('post.pid', '0', 'htmlspecialchars'); //父级评论ID $data['ppid'] = I('post.ppid', '0', 'htmlspecialchars'); //父父级评论ID $data['uid'] = session('?uid') ? session('uid') : 0; //用户ID $data['puid'] = I('post.puid', '0', 'htmlspecialchars'); //父父级评论用户ID $content = I('post.content', '', 'htmlspecialchars'); //评论内容 $data['content'] = filterExpression($content); $data['ip'] = get_client_ip(); $Ip = new IpLocation('UTFWry.dat'); $data['area'] = $Ip->getlocation($data['ip']); // 获取某个IP地址所在的位置 $data['post_time'] = time(); if (!is_numeric($data['data_id'])) { echo json_encode(array('status' => 2, 'info' => 'error')); exit; } $id = D('Comment')->saveComment($data); $data = D('Comment')->getComment($id); $res = array(); $res['data'] = $data; $res['status'] = 1; $res['info'] = 'ok'; echo json_encode($res); }
public function message_deal() { $msg = array(); $msg['name'] = I('post.name'); $msg['email'] = I('post.email'); if ($msg['name'] == "" || $msg['email'] == "") { echo 'failure'; exit; } $msg['phonenum'] = I('post.phone'); $msg['content'] = I('post.content'); $msg['time'] = time(); $msg['ip'] = get_client_ip(); $Ip = new IpLocation('UTFWry.dat'); // 实例化类 参数表示IP地址库文件 $area = $Ip->getlocation($msg['ip']); // 获取某个IP地址所在的位置 $msg['area'] = $area['country'] . " " . $area['area']; $Messages = D('messages'); $Messages->add($msg); echo 'ok'; }
private static function chunzhenIP($ip) { $ip = Verif::canshu($ip, 'chunzhenIP$ip', true); $Ips = new IpLocation('UTFWry.dat'); // 实例化类 参数表示IP地址库文件 $IPinfo = $Ips->getlocation($ip); // 获取某个IP地址所在 return $IPinfo; }