/** * 修改访问IP白名单 * @param $ipid IP地址Id号 * @param $ip 访问IP白名单 * @param $status 访问IP白名单的状态 * @return array('status'=>0,'msg'=>'') 成功status为1 */ static function updateIpLimit($ipid, $ip, $status) { $ret = array('status' => 0, 'msg' => ''); try { $ip = isset($ip) ? trim($ip) : ''; $status = isset($status) ? trim($status) : 0; if (empty($ipid) || !is_numeric($ipid) || intval($ipid) != $ipid) { throw new Exception('IP ID必须是整数'); } if (empty($ip) || !Comm::is_ip($ip)) { throw new Exception('IP地址格式错误'); } if (!is_numeric($status) || intval($status) != $status || $status != 0 && $status != 1) { throw new Exception('IP状态参数错误'); } $sql = 'update beu_user_ip_limit set IP=\'' . $ip . '\',status=' . $status . ' where id=' . $ipid; $data = Yii::app()->db->createCommand($sql)->execute(); if (empty($data)) { throw new Exception('IP白名单修改失败'); } $ret['status'] = 1; $ret['msg'] = 'IP白名单修改成功'; } catch (Exception $e) { $ret['msg'] = $e->getMessage(); } return $ret; }