本文整理汇总了PHP中validate::getError方法的典型用法代码示例。如果您正苦于以下问题:PHP validate::getError方法的具体用法?PHP validate::getError怎么用?PHP validate::getError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validate
的用法示例。
在下文中一共展示了validate::getError方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: savepsw
function savepsw()
{
$objData = array('psw' => $this->_post('psw', ''));
//内容规则检查
T('content/validate');
$validate = array(array('psw', 'min_length', '密码长度必须大于4位', 4));
if (!validate::check($validate, $objData)) {
$this->JsonReturn(validate::getError());
}
if ($objData['psw'] != $this->_post('repsw')) {
$this->JsonReturn('两次密码不一致,请检查');
}
if ($objData['psw']) {
$psw = D('admin')->setUserPassword($objData['psw']);
if ($psw != steadmin::$adminInfo['psw']) {
D('steadmin')->update(array('psw' => $psw), array('user_id' => steadmin::$adminInfo['user_id']));
D('steadmin')->setUserLogin(array('user_id' => steadmin::$adminInfo['user_id'], 'psw' => $psw), 0, false);
//===记录操作日志====
parent::saveSySLog(2, array(), 0, array('user_id' => steadmin::$adminInfo['user_id']), '修改密码-编辑');
//===记录操作日志====
$this->JsonReturn('操作成功', null, 1);
}
}
$this->JsonReturn('密码未变更', null, 0);
}
示例2: save
function save()
{
if (load('string')) {
$feedback = array();
$feedback['fb_time'] = $this->_post('fbtime', '');
$feedback['fb_type'] = $this->_postid('fbtype', 0);
$feedback['fb_status'] = $this->_postid('fbstatus', 0);
$feedback['fb_content'] = $this->_post('fbcontent', '');
$feedback['fb_upload'] = $this->_post('fbupload', '');
$feedbackConfig = C('feedback');
if (!isHave($feedbackConfig['type']) || !is_array($feedbackConfig['type']) || !isHave($feedbackConfig['maxLen']) || !is_numeric($feedbackConfig['maxLen'])) {
return $this->JsonReturn('配置信息错误');
}
T('content/validate');
$validation = array(array('fb_time', 'required', '请选择时间'), array('fb_type', 'required', '请选择类型'), array('fb_status', 'required', '请选择处理状态'), array('fb_content', 'required', '填填写反馈'), array('fb_content', 'max_length', '反馈内容请不要超过' . $feedbackConfig['maxLen'] . '个字符', $feedbackConfig['maxLen']));
if (!isHave($feedbackConfig['type'][$feedback['fb_type']])) {
return $this->JsonReturn('无该反馈类型' . $feedback['fb_type']);
}
if (!isHave($feedbackConfig['status'][$feedback['fb_status']])) {
return $this->JsonReturn('无该处理结果');
}
if (!validate::check($validation, $feedback)) {
return $this->JsonReturn(validate::getError());
}
// validate 中并没有如 2015-08-03 这样的无时间格式检查
if (!strtotime($feedback['fb_time'])) {
return $this->JsonReturn('时间错误');
}
/* TODO
* 对于upload应该怎么样检查
*/
$fb_insert = array('worker_uid' => steadmin::$adminInfo['user_id'], 'type_id' => $feedback['fb_type'], 'status_id' => $feedback['fb_status'], 'feedback' => $feedback['fb_content'], 'fb_time' => inTime($feedback['fb_time']), 'upload' => $feedback['fb_upload'], 'ct_time' => TIME);
if (D('feedback')->insert($fb_insert)) {
return $this->JsonReturn('保存成功,可继续添加反馈', null, 1);
} else {
return $this->JsonReturn('保存失败');
}
} else {
$this->JsonReturn('加载string函数库时发生了错误');
}
}
示例3: header
$email_to = EMAIL;
$emailMessage = "From: " . $name . "\n";
$emailMessage .= "Email Address: " . $email . "\n\n";
$emailMessage .= $message;
//use php's mail function to send the email
@mail($email_to, $subject, $emailMessage, $header);
//grab the current url, append ?sent=yes to it and then redirect to that url
$url = "http" . (!empty($_SERVER['HTTPS']) ? "s" : "") . "://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header('Location: ' . $url . "?sent=yes");
} else {
//set the number of errors message
$message_text = $v->errorNumMessage();
//store the errors list in a variable
$errors = $v->displayErrors();
//get the individual error messages
$nameErr = $v->getError("your name");
$emailErr = $v->getError("email");
$messageErr = $v->getError("your message");
}
//end error check
}
// end isset
?>
-->
<!DOCTYPE html>
<html>
<head>
<title>TWC Recruitment - Recruiting the markets best talent</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
示例4: save
public function save()
{
parent::_authUser(array(1, 5, 7, 9));
$id = $this->_postid('id', 0);
if (!$id) {
$this->JsonReturn('参数丢失');
}
$rs = M('ste_shop')->where(array('shop_id' => $id))->find();
if (!$rs) {
showError('店铺不存在');
}
if (!parent::_checkUser($rs['user_id'], $id) && (parent::_checkIsPresident() && $rs['service_id'] != steadmin::$adminInfo['service_id'])) {
showError('编辑权限不足');
}
$objData = array();
$noField = array('user_id', 'city_id', 'goods_sales');
//获取字段内容
$fieldList = M('ste_shop')->getTableFields($noField);
foreach ($fieldList['fields'] as $key => $val) {
$objData[$key] = $val['type'] == 'int' ? $this->_postid($key, $val['value']) : $this->_post($key, $val['value']);
}
$objData['tips_list'] = $this->_post('tips_list');
$objData['hot_goods'] = $this->_post('hot_goods');
if ($objData['tips_list']) {
$objData['tips_list'] = ',' . implode(',', $objData['tips_list']) . ',';
}
if ($objData['hot_goods']) {
$objData['hot_goods'] = implode(',', $objData['hot_goods']);
}
if ($objData['deployment_users']) {
$objData['deployment_users'] = implode(',', $objData['deployment_users']);
}
//内容规则检查
T('content/validate');
$validate = array(array('shop_name', 'range_length', '店铺名称不符合要求', 2, 80), array('pic_url', 'required', '店铺小图不能为空'), array('score_total', 'double', '综合评分不符合要求'), array('score_flavour', 'double', '口味评分不符合要求'), array('score_service', 'double', '服务评分不符合要求'), array('ontime_point', 'int', '准点率必须为整数'));
if (!validate::check($validate, $objData)) {
$this->JsonReturn(validate::getError());
}
// z($objData);
//判断重复
$checkHas = M('ste_shop')->where(array('shop_name' => $objData['shop_name'], 'shop_alt_name' => $objData['shop_alt_name'], 'city_id' => steadmin::$adminInfo['city_id'], 'status' => 1))->getField('shop_id');
if ($checkHas && $checkHas != $id) {
$this->JsonReturn('同名店铺已存在,请检查');
}
// z($objData);
M('ste_shop')->update($objData, array('shop_id' => $id));
//判断店铺的服务中心有没有更改
if ($rs['service_id'] != $objData['service_id']) {
M('ste_goods')->update(array('service_id' => $objData['service_id']), array('shop_id' => $id));
}
//判断店铺的类型是否有更改
if ($rs['shop_type'] != $objData['shop_type']) {
D('api')->refreshConfig();
}
//===记录操作日志====
parent::saveSySLog(2, $objData, $id, array('shop_id' => $id), '店铺管理-更新');
//===记录操作日志====
$this->JsonReturn('ok', null, 1);
}
示例5: save
function save()
{
$fid = $this->_postid('fid', 0);
if (!$fid) {
showError('参数丢失');
}
$feedbackConfig = C('steward/service_log');
$servicelog = array();
$servicelog['fb_time'] = $this->_post('fbtime', '');
$servicelog['type_id'] = $this->_postid('fbtype', 0);
$servicelog['status_id'] = $this->_postid('fbstatus', 0);
$servicelog['feedback'] = $this->_post('fbcontent', '');
$servicelog['upload'] = $this->_post('fbupload');
$servicelog['order_id'] = $this->_postid('order_id');
$servicelog['phone'] = $this->_post('phone');
$servicelog['username'] = $this->_post('username');
T('content/validate');
$validation = array(array('fb_time', 'required', '请选择时间'), array('type_id', 'required', '请选择类型'), array('status_id', 'required', '请选择处理状态'), array('feedback', 'required', '填填写反馈'), array('feedback', 'max_length', '反馈内容请不要超过' . $feedbackConfig['maxLen'] . '个字符', $feedbackConfig['maxLen']));
if (!validate::check($validation, $servicelog)) {
return $this->JsonReturn(validate::getError());
}
if (isHave($servicelog['phone'])) {
$phoneValidation = array(array('phone', 'phone', '请填写正确的电话号码'));
if (!validate::check($phoneValidation, $servicelog)) {
return $this->JsonReturn(validate::getError());
}
}
if (isHave($servicelog['username'])) {
$usernameValidation = array(array('username', 'username', '请填写正确的电话号码'));
if (!validate::check($usernameValidation, $servicelog)) {
return $this->JsonReturn(validate::getError());
}
}
if (!isHave($feedbackConfig['type'][$servicelog['type_id']])) {
return $this->JsonReturn('无该反馈类型' . $servicelog['type_id']);
}
if (!isHave($feedbackConfig['status'][$servicelog['status_id']])) {
return $this->JsonReturn('无该处理结果');
}
$servicelog['fb_time'] = inTime($servicelog['fb_time']);
D('serviceLog')->update($servicelog, array('fid' => $fid));
$this->JsonReturn('保存成功', null, 1);
}
示例6:
$emailHeader = "You've Received an Estimate Inquiry from fullhouserenovations.com";
$emailMessage = "Name: " . $name . "\n\n";
$emailMessage .= "Email: " . $email . "\n\n";
$emailMessage .= "Phone: " . $phone . "\n\n";
$emailMessage .= "Quadrant: " . $quadrant . "\n\n";
$emailMessage .= "Budget: " . $budget . "\n\n";
$emailMessage .= "Message: " . $message;
@mail($email_to, $subject, $emailHeader, $emailMessage, $header);
$successMessage = "<p class=\"success\">Thank You. Your message has been sent.</p>";
} else {
//set the number of errors message
$message_text = $v->errorNumMessage();
//store the errors list in a variable
$errors = $v->displayErrors();
//get the individual error messages
$nameErr = $v->getError("name");
$emailErr = $v->getError("email");
$phoneErr = $v->getError("phone");
$quadrantErr = $v->getError("quadrant");
$messageErr = $v->getError("message");
}
}
// end isset
?>
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
示例7: save
function save()
{
$id = $this->_postid('id', 0);
if (!$id) {
$this->JsonReturn('参数丢失');
}
$objData = array();
$noFields = array('logincount', 'loginip', 'logintime', 'regdateline', 'build_uid', 'shop_id', 'unionid');
if (!parent::_checkIsAdmin()) {
$noFields = array_merge($noFields, array('city_id', 'service_id'));
}
//获取字段内容
$fieldList = D('steadmin')->getTableFields($noFields);
foreach ($fieldList['fields'] as $key => $val) {
$objData[$key] = $val['type'] == 'int' ? $this->_postid($key, $val['value']) : $this->_post($key, $val['value']);
}
$objData['repsw'] = $this->_post('repsw');
$rs = D('steadmin')->where(array('user_id' => $id))->find();
if (!parent::_checkIsPresident() && !parent::_checkIsAdmin() && $rs['user_id'] != steadmin::$adminInfo['user_id'] && $rs['build_uid'] !== steadmin::$adminInfo['user_id']) {
$this->JsonReturn('权限不足');
}
//社长
if (parent::_checkIsPresident()) {
if ($rs['service_id'] !== steadmin::$adminInfo['service_id']) {
$this->JsonReturn('权限不足');
} else {
$objData['service_id'] = steadmin::$adminInfo['service_id'];
}
}
//内容规则检查
T('content/validate');
$validate = array(array('username', 'username', '帐户名称不符合要求', 2, 30), array('real_name', 'username', '真实姓名不符合要求', 2, 30), array('phone', 'phone', '手机号码不符合要求'));
if ($objData['psw']) {
$validate[] = array('psw', 'min_length', '密码长度必须大于4位', 4);
}
$infoData = array('nick_name' => $this->_post('nick_name'), 'user_avatar' => $this->_post('user_avatar'), 'total_service' => $this->_postid('total_service'), 'average_times' => $this->_postid('average_times'), 'score_service' => $this->_post('score_service'), 'score_speed' => $this->_post('score_speed'), 'total_comment' => $this->_postid('total_comment'), 'wechat_id' => $this->_post('wechat_id'));
//工作人员完善资料
if (isset($objData['groupid']) && in_array($objData['groupid'], $this->hasWorkerInfo)) {
$validateInData = array(array('nick_name', 'username', '称呼不符合要求', 2, 30), array('user_avatar', 'required', '用户头像不能为空'), array('total_service', 'int', '总服务次数不符合要求'), array('average_times', 'int', '服务时间不符合要求'), array('score_service', 'double', '服务评分不符合要求'), array('score_speed', 'double', '速度评分不符合要求'), array('total_comment', 'int', '评论人次不符合要求'));
if (!validate::check($validateInData, $infoData)) {
$this->JsonReturn(validate::getError());
}
$validate[] = array('service_id', 'int', '商圈不能为空');
}
if (!validate::check($validate, $objData)) {
$this->JsonReturn(validate::getError());
}
if ($objData['psw'] && $objData['psw'] != $objData['repsw']) {
$this->JsonReturn('两次密码不一致');
}
if ($objData['psw']) {
$objData['psw'] = D('admin')->setUserPassword($objData['psw']);
} else {
unset($objData['psw']);
}
//检测账户名或手机号是否重复
$exist = D('steadmin')->field('user_id')->where(array('city_id' => steadmin::$adminInfo['city_id'], 'username' => $objData['username']))->find();
if ($exist && $exist['user_id'] != $id) {
$this->JsonReturn('该帐户名已存在');
}
// $exist = D('steadmin')->field('user_id')
// ->where(array('city_id' => steadmin::$adminInfo['city_id'], 'phone' => $objData['phone']))->find();
// if ($exist && $exist['user_id'] != $id) {
// $this->JsonReturn('该手机号已经存在');
// }
// if ($infoData['wechat_id']) {
// $exist = M('ste_worker')->field('user_id')
// ->where(array('wechat_id' => $infoData['wechat_id']))->find();
// if ($exist && $exist['user_id'] != $id) {
// $this->JsonReturn('该微信号已经存在');
// }
// }
if ($this->isLocal) {
$syncToQyh = false;
} else {
$syncToQyh = true;
}
if (parent::_checkIsAdmin()) {
$objData['effective'] = $this->_post('effective', 0);
if ($objData['effective']) {
$objData['effective'] = inTime($objData['effective']);
} else {
$objData['effective'] = 0;
}
$objData['status'] = $objData['status'] ? $objData['status'] : 0;
}
if ($objData['groupid'] == 8) {
//店长身份需要设置店铺
$objData['shop_id'] = $this->_postid('shop_id', 0);
} else {
$objData['shop_id'] = 0;
}
if ($objData['groupid'] == 9) {
//社长身份必须设置服务中心
$objData['service_id'] = $this->_postid('service_id', 0);
}
//社长必须有服务中心
if ($objData['groupid'] == 9 && !$objData['service_id']) {
$this->JsonReturn('服务中心不能为空');
}
//.........这里部分代码省略.........
示例8: batch
public function batch()
{
parent::_checkLogin();
parent::_authUser(array(1, 2, 5, 7, 8));
$gids = $this->_post('gid');
if (!$gids || !is_array($gids)) {
$this->JsonReturn('请先选择需要操作的商品');
}
$objData = array();
$list = array('original_price', 'price_pre', 'price', 'storage_counts', 'start_times', 'end_times', 'px', 'cate_id', 'order_counts');
foreach ($list as $val) {
$objData[$val] = $this->_post($val, '');
}
//内容规则检查
T('content/validate');
$validate = array();
if ($objData['price']) {
$validate[] = array('price', 'currency', '商品价格不正确');
} else {
unset($objData['price']);
}
if ($objData['storage_counts']) {
$validate[] = array('storage_counts', 'int', '库存不正确');
} else {
unset($objData['storage_counts']);
}
if ($objData['original_price']) {
$validate[] = array('original_price', 'currency', '商品原始价格不正确');
} else {
unset($objData['original_price']);
}
if ($objData['start_times']) {
$objData['start_times'] = inTime($objData['start_times']);
} else {
unset($objData['start_times']);
}
if ($objData['end_times']) {
$objData['end_times'] = inTime($objData['end_times']);
} else {
unset($objData['end_times']);
}
if (!$objData['cate_id']) {
unset($objData['cate_id']);
}
if (!$objData['price_pre']) {
unset($objData['price_pre']);
}
if ($objData['px'] !== '') {
$objData['px'] = intval($objData['px']);
} else {
unset($objData['px']);
}
if ($objData['order_counts'] !== '') {
$objData['order_counts'] = intval($objData['order_counts']);
} else {
unset($objData['order_counts']);
}
if (!$objData) {
$this->JsonReturn('必须有修改项!');
}
if ($validate && !validate::check($validate, $objData)) {
$this->JsonReturn(validate::getError());
}
//补充数据
$objData['refresh_time'] = TIME;
// z($objData);
//取出所以商品,并对商品做权限判断
$rs = M('ste_goods')->field('user_id,gid,shop_id')->where(array('gid' => $gids))->findAll(false);
if (!$rs) {
$this->JsonReturn('没有找到符合条件的商品');
}
$ids = array();
foreach ($rs as $val) {
if (!parent::_checkUser($val['user_id'], $val['shop_id'])) {
$this->JsonReturn('操作错误,没有编辑权限');
} else {
$ids[] = $val['gid'];
}
}
if ($ids) {
$total = M('ste_goods')->update($objData, array('gid' => $ids));
//===记录操作日志====
parent::saveSySLog(4, $objData, $ids, array('gid' => $ids), '商品管理-批量设置');
//===记录操作日志====
$this->JsonReturn('ok', $total, 1);
} else {
$this->JsonReturn('没有找到符合条件的商品');
}
}