Maison > Questions et réponses > le corps du texte
网站一直出现502 Bad gateway
是怎么回事,是一个公司内部系统。chrome
的console
报错是 Failed to load resource: net::ERR_CONNECTION_RESET
,系统是 centos 6.5 阿里云服务器,环境是lnmp,请问这种报错一般该怎么排查呢,已经锁定了是下面这一段代码问题。但是我目前还没找到,php是5.5.36
if ($_REQUEST["field"]) {
if (trim($_REQUEST['field']) == "all") {
$field = is_numeric(trim($_REQUEST['search'])) ? 'name|origin|type|description|estimate_price|gain_rate|gain_cycle|sales_price|product_amount|total_price|estimate_income' : 'name|origin|type|description';
} else {
$field = trim($_REQUEST['field']);
}
$search = empty($_REQUEST['search']) ? '' : trim($_REQUEST['search']);
$condition = empty($_REQUEST['condition']) ? 'is' : trim($_REQUEST['condition']);
$field_date = M('Fields')->where('(is_main=1 and model="" and form_type="datetime") or (is_main=1 and model="business" and form_type="datetime")')->select();
foreach($field_date as $v){
if ($field == $v['field']) $search = is_numeric($search)?$search:strtotime($search);
}
if ($this->_request('state')){
$state = $this->_request('state', 'trim');
$address_where[] = '%'.$state.'%';
if($this->_request('city')){
$city = $this->_request('city', 'trim');
$address_where[] = '%'.$city.'%';
if($this->_request('area')){
$area = $this->_request('area', 'trim');
$address_where[] = '%'.$this->_request('area', 'trim').'%';
}
}
if($search) $address_where[] = '%'.$search.'%';
$params = array('field='.trim($_REQUEST['field']), 'condition='.$condition, 'state='.$this->_request('state','trim'), 'city='.$this->_request('city','trim'),'area='.$this->_request('area','trim'),'search='.$this->_request('search','trim'));
if($condition == 'not_contain'){
$where[$field] = array('notlike', $address_where, 'OR');
}else{
$where[$field] = array('like', $address_where, 'AND');
}
}else{
$field_date = M('Fields')->where('is_main=1 and (model="" or model="business") and form_type="datetime"')->select();
foreach($field_date as $v){
if($field == $v['field'] || $field == 'customer.create_time' || $field == 'customer.update_time')
$search = is_numeric($search)?$search:strtotime($search);
}
if($field =="customer_id"){
$c_where['name'] = array('like','%'.$search.'%');
$customer_ids = M('Customer')->where($c_where)->getField('customer_id',true);
$where[$field] = array('in',$customer_ids);
}else{
switch ($condition) {
case "is" : $where[$field] = array('eq',$search);break;
case "isnot" : $where[$field] = array('neq',$search);break;
case "contains" : $where[$field] = array('like','%'.$search.'%');break;
case "not_contain" : $where[$field] = array('notlike','%'.$search.'%');break;
case "start_with" : $where[$field] = array('like',$search.'%');break;
case "end_with" : $where[$field] = array('like','%'.$search);break;
case "is_empty" : $where[$field] = array('eq','');break;
case "is_not_empty" : $where[$field] = array('neq','');break;
case "gt" : $where[$field] = array('gt',$search);break;
case "egt" : $where[$field] = array('egt',$search);break;
case "lt" : $where[$field] = array('lt',$search);break;
case "elt" : $where[$field] = array('elt',$search);break;
case "eq" : $where[$field] = array('eq',$search);break;
case "neq" : $where[$field] = array('neq',$search);break;
case "between" : $where[$field] = array('between',array($search-1,$search+86400));break;
case "nbetween" : $where[$field] = array('not between',array($search,$search+86399));break;
case "tgt" : $where[$field] = array('gt',$search+86400);break;
default : $where[$field] = array('eq',$search);
}
}
$params = array('field='.trim($_REQUEST['field']), 'condition='.$condition, 'search='.$search );
}
}
$order = empty($order) ? 'business.update_time desc' : $order;
if(trim($_GET['act']) == 'excel'){
if(vali_permission('business', 'export')){
$dc_id = $_GET['daochu'];
if($dc_id !=''){
$where['business_id'] = array('in',$dc_id);
}
$current_page = intval($_GET['current_page']);
$export_limit = intval($_GET['export_limit']);
$limit = ($export_limit*($current_page-1)).','.$export_limit;
$businessList = $d_v_business->where($where)->order($order)->limit($limit)->select();println($businessList);
session('export_status', 1);
$this->excelExport($businessList);
}else{
alert('error', L('HAVE NOT PRIVILEGES'), $_SERVER['HTTP_REFERER']);
}
}
if($_GET['listrows']){
$listrows = intval($_GET['listrows']);
$params[] = "listrows=" . intval($_GET['listrows']);
}else{
$listrows = 15;
$params[] = "listrows=15";
}
$list = $d_v_business->where($where)->order($order)->page($p.','.$listrows)->select();
$count = $d_v_business->where($where)->count();
import("@.ORG.Page");
$Page = new Page($count,$listrows);
if (!empty($_GET['by'])) {
$params[] = "by=".trim($_GET['by']);
}
$this->parameter = implode('&', $params);
if ($_GET['desc_order']) {
$params[] = "desc_order=" . trim($_GET['desc_order']);
} elseif($_GET['asc_order']){
$params[] = "asc_order=" . trim($_GET['asc_order']);
}
$Page->parameter = implode('&', $params);
$this->assign('page', $Page->show());
foreach($list as $key => $value){
$list[$key]['owner'] = D('RoleView')->where('role.role_id = %d', $value['owner_role_id'])->find();
$list[$key]['creator'] = D('RoleView')->where('role.role_id = %d', $value['creator_role_id'])->find();
$list[$key]['customer_name'] = M('customer')->where('customer_id = %s',$value['customer_id'])->getField('name');
$list[$key]['status_name'] = M('BusinessStatus')->where('status_id = %d', $value['status_id'])->getField('name');
if($by == 'deleted') {
$list[$key]["delete_role"] = D('RoleView')->where('role.role_id = %d', $value['delete_role_id'])->find();
}
}
$d_role_view = D('RoleView');
$this->listrows = $listrows;
$this->role_list = $d_role_view->where('role.role_id in (%s)', implode(',', $below_ids))->select();
$this->customer_list = M('customer')->where('owner_role_id in (%s)', implode(',', getSubRoleId()))->select();
$this->assign('list',$list);
$this->assign('count',$count);
$this->search_field_array = getMainFields('business');
$this->field_array = getIndexFields('business');
$this->alert = parseAlert();
$this->display();
}
PHPz2017-04-11 10:02:50
已经解决了,是$this->customer_list = M('customer')->where('owner_role_id in (%s)', implode(',', getSubRoleId()))->select();
这一行代码造成的,因为Customer
表数据太多做了多次查询
迷茫2017-04-11 10:02:50
HTTP Status 502 (错误网关)服务器作为网关或代理,从上游服务器收到无效响应。解决办法可以参考这篇文章502是什么问题,希望对你有帮助。免费的php视频教程。