/** * @see Sppc_Protection_Abstract::isValid() * * @param $value string */ public function isValid($value = null) { if (is_null($value)) { // Если не передан ip, тогда берем ip из параметров $parameters = Sppc_Protection_Parameters::getInstance(); $value = $parameters->getParameter('ip_address'); } $this->_setValue($value); $CI =& get_instance(); $CI->load->helper('location'); $ip = iptolong($this->_value); $number = (int) $this->_getSetting('MaximumSearchNumber', 100); $period = (int) $this->_getSetting('TimePeriod', 5); if (0 < $number) { // Use database $CI->db->insert('fraud_quick_search', array('ip' => $ip, 'search_date' => time())); // Чекаем $CI->db->where('ip', $ip)->where('search_date >=', time() - $period)->from('fraud_quick_search'); $count = $CI->db->count_all_results(); if ($count > $number) { $this->_error(); return false; } } return true; }
public function save_travelnote() { if (I('post.Submit')) { $post = I('post.'); $data['uid'] = $post['uid'] = cookie('uid'); $post['dateline'] = time(); $post['ip'] = iptolong(get_client_ip()); $post['uname'] = cookie('uname'); $data['message'] = stripcslashes($_POST['editorValue']); preg_match_all("/<img.*?>/im", $data['message'], $ereg); $img = $ereg[0][0]; //图片 $p = "#src=('|\")(.*)('|\")#isU"; //正则表达式 preg_match_all($p, $img, $img1); $img_path = $img1[2][0]; //获取第一张图片路径 if (!$img_path) { $post['pic_flag'] = 0; } else { $post['pic_flag'] = 1; $info = getimagesize(I('server.DOCUMENT_ROOT') . $img_path); if ($info[1] > $info[0]) { $y = 140; $x = ceil(140 * $info[0] / $info[1]); } else { $x = 140; $y = ceil(140 * $info[1] / $info[0]); } $end = strrpos($img_path, '/') + 1; $data['pic'] = substr($img_path, 0, $end) . 'thumb_' . substr($img_path, $end); $data['pic_flag'] = 1; $image = new \Think\Image(); $image->open('..' . $img_path); $image->thumb($x, $y, \Think\Image::IMAGE_THUMB_FILLED)->save('..' . $data['pic']); } $blog = M('blog'); $bloginfo = M('bloginfo'); if ($post['blogid']) { $blog->save($post); $data['blogid'] = $post['blogid']; $bloginfo->save($data); } else { $data['blogid'] = $blog->add($post); if ($data['blogid']) { $bloginfo->add($data); } else { $this->error('创建失败,请稍后重试'); } } $this->redirect('User/index', array(), 0); } $this->error('您的操作有误'); }
public function register() { if (IS_POST) { $post = I('post.'); if (!check_verify($post['verify'])) { $this->error('验证码输入错误!'); } if ($post['password'] != $post['password_confirm']) { $this->error('密码和重复密码不一致!'); } if (!ereg("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\\.[a-zA-Z0-9_-])+", $post['email'])) { $this->error('邮箱格式不正确'); } $UserLog = M('UserLogin'); $uid = $UserLog->field('id')->where('email="' . $post['email'] . '"')->find(); if ($uid) { $this->error('您输入的邮箱已被注册!'); } $post['reg_time'] = $post['last_login_time'] = time(); $post['reg_ip'] = $post['last_login_ip'] = iptolong(get_client_ip()); $post['password'] = md5($post['password']); $post['status'] = 1; $UserLog->create($post); $uid = $UserLog->add(); if ($uid) { cookie('cache_id', $uid); cookie('em', $post['email']); $emailurl = preg_replace("/^([a-zA-Z0-9_-])+@(([a-zA-Z0-9_-])+)\\.([a-zA-Z0-9_-])+/", "http://mail.\\2.com", $post['email']); //邮箱验证码 $mail_verify = $uid . '_' . substr(md5($post['email']), 0, 5); $mail_verify_url = $_SERVER['HTTP_HOST'] . U('Login/email_verify', 'mail_verify=' . $mail_verify); $this->assign('email', $post['email']); $this->assign('emailurl', $emailurl); $this->assign('mail_verify_url', $mail_verify_url); $mail_con = $this->fetch('emailverifycon'); //发送邮件 load('@.function_mail'); $mail_res = sendmail($post['email'], '[途经网]邮箱验证', $mail_con); if ($mail_res) { $this->display(); } else { $this->error('邮件发送失败,请联系客服进行问题反馈', U('Login/login')); } } else { $this->error('操作失败,请稍后重试!'); } } else { $this->error('您访问的页面有误'); } }
/** * @see Sppc_Protection_Abstract::isValid() */ public function isValid($value = null) { if (is_null($value)) { // Если не передан ip, тогда получаем ip из параметров $parameters = Sppc_Protection_Parameters::getInstance(); $value = $parameters->getParameter('ip_address'); } $CI =& get_instance(); $CI->load->helper('location'); $this->_setValue($value); $ip = iptolong($this->_value); $CI->db->from('fraud_firewall')->where('ip_start <=', $ip)->where('ip_finish >=', $ip); if (0 < $CI->db->count_all_results()) { $this->_error(); return false; } return true; }
/** * @see Sppc_Protection_Abstract::isValid() * * @param $value array with keys 'ip' (string) & 'proxy_ip' (string) */ public function isValid($value = null) { $this->_setValue($value); $CI =& get_instance(); $CI->load->helper('location'); // Проверяем на anonymous proxy $CI->db->from('fraud_proxies')->where('ip_start <=', ip2long($this->_ip))->where('ip_finish >=', ip2long($this->_ip)); if (0 < $CI->db->count_all_results()) { $this->_error(self::PROXY_NOT_ALLOWED); return false; } $CI->db->from('fraud_proxies')->where('(ip_start-4294967296) <=', ip2long($this->_ip))->where('(ip_finish-4294967296) >=', ip2long($this->_ip)); if (0 < $CI->db->count_all_results()) { $this->_error(self::PROXY_NOT_ALLOWED); return false; } // Проверяем на transparent proxy if ('true' == $this->_getSetting('block_transparent_clicks', 'false') && 0 < iptolong($this->_ip_proxy)) { $allowed = false; if ('true' == $this->_getSetting('allowed_proxy_clicks', 'true')) { // Проверяем на нахождение в разрешенном листе $CI->db->from('fraud_allowed')->where('ip_start <=', ip2long($this->_ip_proxy))->where('ip_finish >=', ip2long($this->_ip_proxy)); if (0 < $CI->db->count_all_results()) { $allowed = true; } $CI->db->from('fraud_allowed')->where('(ip_start-4294967296) <=', ip2long($this->_ip_proxy))->where('(ip_finish-4294967296) >=', ip2long($this->_ip_proxy)); if (0 < $CI->db->count_all_results()) { $allowed |= true; } } if (!$allowed) { $this->_error(self::TRANSPARENT_PROXY_NOT_ALLOWED); return false; } } return true; }
/** * Установка айпишника проксика пользователя * * @param string $ip_address */ public function setIpAddressProxy($ip_address) { $this->ip_proxy_set = true; if ($this->ip_address_proxy != $ip_address) { $this->ip_address_proxy = $ip_address; $this->ip_proxy = iptolong($this->ip_address_proxy); } }
public function save() { if (I('post.Submit')) { $post = I('post.'); $timeArr = explode(' - ', $post['time']); $data['uid'] = $post['uid'] = cookie('uid'); $post['dateline'] = time(); $post['ip'] = iptolong(get_client_ip()); $post['uname'] = cookie('uname'); $post['deadline'] = strtotime($post['deadline']); $post['starttime'] = strtotime(trim($timeArr[0])); $post['endtime'] = strtotime(trim($timeArr[1])); $post['day'] = ceil(($post['endtime'] - $post['starttime']) / 86400); $data['message'] = stripcslashes($_POST['editorValue']); if (!$post['active_pic']) { preg_match_all("/<img.*?>/im", $data['message'], $ereg); $img = $ereg[0][0]; //图片 $p = "#src=('|\")(.*)('|\")#isU"; //正则表达式 preg_match_all($p, $img, $img1); $img_path = $img1[2][0]; //获取第一张图片路径 if (!$img_path) { $post['pic_flag'] = 0; } else { $post['pic_flag'] = 1; $info = getimagesize(I('server.DOCUMENT_ROOT') . $img_path); if ($info[1] > $info[0]) { $y = 140; $x = ceil(140 * $info[0] / $info[1]); } else { $x = 140; $y = ceil(140 * $info[1] / $info[0]); } $end = strrpos($img_path, '/') + 1; $data['active_pic'] = substr($img_path, 0, $end) . 'thumb_' . substr($img_path, $end); $image = new \Think\Image(); $image->open('..' . $img_path); $image->thumb($x, $y, \Think\Image::IMAGE_THUMB_FILLED)->save('..' . $data['active_pic']); } } else { $data['active_pic'] = $post['active_pic']; $post['pic_flag'] = 1; } $htmlcon = msubstr(strip_tags($data['message']), 0, 150); $feedinfo = array('uid' => $data['uid'], 'uname' => $post['uname'], 'type' => 'Activity', 'dateline' => $post['dateline'], 'title' => $post['title'], 'pic' => $data['active_pic'], 'data' => $htmlcon); $activity = M('activity'); $activityinfo = M('activityinfo'); if ($post['aid']) { $activity->save($post); $data['aid'] = $post['aid']; $activityinfo->save($data); $feedinfo['oid'] = $post['aid']; $feedinfo['status'] = 2; } else { $data['aid'] = $activity->add($post); if ($data['aid']) { $activityinfo->add($data); $feedinfo['oid'] = $data['aid']; $feedinfo['status'] = 1; } else { $this->error('创建失败,请稍后重试'); } } $feed = M('feed'); $feed->add($feedinfo); $id = $post['aid'] ? $post['aid'] : $data['aid']; $this->redirect('Activity/index', array('id' => $id), 0); } $this->error('您的操作有误'); }