本文整理汇总了PHP中Validate::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::validate方法的具体用法?PHP Validate::validate怎么用?PHP Validate::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::validate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store_class_editOp
/**
* 编辑
*/
public function store_class_editOp()
{
$lang = Language::getLangContent();
$model_class = Model('store_class');
if (chksubmit()) {
//验证
$obj_validate = new Validate();
$obj_validate->validateparam = array(array("input" => $_POST["sc_name"], "require" => "true", "message" => $lang['store_class_name_no_null']));
$error = $obj_validate->validate();
if ($error != '') {
showMessage($error);
} else {
$update_array = array();
$update_array['sc_name'] = $_POST['sc_name'];
$update_array['sc_bail'] = intval($_POST['sc_bail']);
$update_array['sc_sort'] = intval($_POST['sc_sort']);
$result = $model_class->editStoreClass($update_array, array('sc_id' => intval($_POST['sc_id'])));
if ($result) {
$this->log(L('nc_edit,store_class') . '[' . $_POST['sc_name'] . ']', 1);
showMessage($lang['nc_common_save_succ'], 'index.php?act=store_class&op=store_class');
} else {
showMessage($lang['nc_common_save_fail']);
}
}
}
$class_array = $model_class->getStoreClassInfo(array('sc_id' => intval($_GET['sc_id'])));
if (empty($class_array)) {
showMessage($lang['illegal_parameter']);
}
Tpl::output('class_array', $class_array);
Tpl::showpage('store_class.edit');
}
示例2: testOutOfExistsFieldNotFound
public function testOutOfExistsFieldNotFound()
{
$testdata = ["name" => "Foo Bar", "mobile" => "0912345678", "address" => "Hong Kong", "phone" => "12345678"];
$chk = new Validate($testdata);
$chk->outOf(["address", "phone", "mobile", "business"], 4);
$this->assertFalse($chk->validate());
}
示例3: unbindOp
public function unbindOp()
{
//修改密码
$model_member = Model('member');
$update_arr = array();
if ($_POST['is_editpw'] == 'yes') {
/**
* 填写密码信息验证
*/
$obj_validate = new Validate();
$obj_validate->validateparam = array(array("input" => $_POST["new_password"], "require" => "true", "validator" => "Length", "min" => 6, "max" => 20, "message" => Language::get('member_qqconnect_password_null')), array("input" => $_POST["confirm_password"], "require" => "true", "validator" => "Compare", "operator" => "==", "to" => $_POST["new_password"], "message" => Language::get('member_qqconnect_input_two_password_again')));
$error = $obj_validate->validate();
if ($error != '') {
showMessage($error, '', 'html', 'error');
}
$update_arr['member_passwd'] = md5(trim($_POST['new_password']));
}
$update_arr['member_qqopenid'] = '';
$update_arr['member_qqinfo'] = '';
$edit_state = $model_member->updateMember($update_arr, $_SESSION['member_id']);
if (!$edit_state) {
showMessage(Language::get('member_qqconnect_password_modify_fail'), 'html', 'error');
}
session_unset();
session_destroy();
showMessage(Language::get('member_qqconnect_unbind_success'), 'index.php?act=login&ref_url=' . urlencode('index.php?act=member_qqconnect&op=qqbind'));
}
示例4: paramOp
/**
* 上传参数设置
*
*/
public function paramOp()
{
if (chksubmit()) {
$obj_validate = new Validate();
$obj_validate->validateparam = array(array("input" => $_POST["image_max_filesize"], "require" => "true", "validator" => "Number", "message" => L('upload_image_filesize_is_number')), array("input" => trim($_POST["image_allow_ext"]), "require" => "true", "message" => L('image_allow_ext_not_null')));
$error = $obj_validate->validate();
if ($error != '') {
showMessage($error);
} else {
$model_setting = Model('setting');
$result = $model_setting->updateSetting(array('image_dir_type' => intval($_POST['image_dir_type']), 'image_max_filesize' => intval($_POST['image_max_filesize']), 'image_allow_ext' => $_POST['image_allow_ext']));
if ($result) {
$this->log(L('nc_edit,upload_param'), 1);
showMessage(L('nc_common_save_succ'));
} else {
$this->log(L('nc_edit,upload_param'), 0);
showMessage(L('nc_common_save_fail'));
}
}
}
//获取默认图片设置属性
$model_setting = Model('setting');
$list_setting = $model_setting->getListSetting();
Tpl::output('list_setting', $list_setting);
//输出子菜单
Tpl::output('top_link', $this->sublink($this->links, 'param'));
Tpl::showpage('upload.param');
}
示例5: admin_editOp
/**
* 管理员编辑
*/
public function admin_editOp()
{
/**
* 保存
*/
if (isset($_POST) && !empty($_POST)) {
//表单验证
$obj_validate = new Validate();
$obj_validate->validateparam = array(array("input" => trim($_POST['admin_password']), "require" => "true", "message" => Language::get('nc_admin_admin_password_is_not_null')), array("input" => trim($_POST['admin_confirm_password']), "require" => "true", "message" => Language::get('nc_admin_password_confirm_is_not_null')));
$error = $obj_validate->validate();
if ($error != '') {
$this->showTip(Language::get('error') . $error, '', 'error');
}
$condition = array();
$condition['admin_id'] = intval($_POST['admin_id']);
$params = array();
$params['admin_password'] = md5(trim($_POST['admin_password']));
$model = Model();
$result = $model->table('admin')->where($condition)->update($params);
if ($result) {
$this->showTip(Language::get('nc_admin_edit_account_succ'));
} else {
$this->showTip(Language::get('nc_admin_edit_account_fail'));
}
}
$admin_id = intval($_GET['admin_id']);
$model = Model();
$admininfo = $model->table('admin')->where(array('admin_id' => $admin_id))->find();
if (empty($admininfo)) {
$this->showTip(Language::get('nc_admin_add_account_succ'));
}
Tpl::output('admininfo', $admininfo);
Tpl::showpage('admin.edit');
}
示例6: save_mallconsultOp
/**
* 保存平台咨询
*/
public function save_mallconsultOp() {
if (!chksubmit()) {
showDialog(L('wrong_argument'), 'reload');
}
//验证表单信息
$obj_validate = new Validate();
$obj_validate->validateparam = array(
array("input"=>$_POST["type_id"],"require"=>"true","validator"=>"Number","message"=>"请选择咨询类型"),
array("input"=>$_POST["consult_content"],"require"=>"true","message"=>"请填写咨询内容")
);
$error = $obj_validate->validate();
if ($error != ''){
showDialog($error);
}
$insert = array();
$insert['mct_id'] = $_POST['type_id'];
$insert['member_id'] = $_SESSION['member_id'];
$insert['member_name'] = $_SESSION['member_name'];
$insert['mc_content'] = $_POST['consult_content'];
$result = Model('mall_consult')->addMallConsult($insert);
if ($result) {
showDialog(L('nc_common_op_succ'), 'reload', 'succ');
} else {
showDialog(L('nc_common_op_fail'), 'reload');
}
}
示例7: email_tpl_editOp
/**
* 编辑邮件模板
*/
public function email_tpl_editOp()
{
$model_templates = Model('mail_templates');
if (chksubmit()) {
$obj_validate = new Validate();
$obj_validate->validateparam = array(array("input" => $_POST["code"], "require" => "true", "message" => L('mailtemplates_edit_no_null')), array("input" => $_POST["title"], "require" => "true", "message" => L('mailtemplates_edit_title_null')), array("input" => $_POST["content"], "require" => "true", "message" => L('mailtemplates_edit_content_null')));
$error = $obj_validate->validate();
if ($error != '') {
showMessage($error);
} else {
$update_array = array();
$update_array['code'] = $_POST["code"];
$update_array['title'] = $_POST["title"];
$update_array['content'] = $_POST["content"];
$result = $model_templates->editTpl($update_array, array('code' => $_POST['code']));
if ($result === true) {
$this->log(L('nc_edit,email_tpl'), 1);
showMessage(L('mailtemplates_edit_succ'), 'index.php?act=message&op=email_tpl');
} else {
$this->log(L('nc_edit,email_tpl'), 0);
showMessage(L('mailtemplates_edit_fail'));
}
}
}
if (empty($_GET['code'])) {
showMessage(L('mailtemplates_edit_code_null'));
}
$templates_array = $model_templates->getTplInfo(array('code' => $_GET['code']));
Tpl::output('templates_array', $templates_array);
Tpl::output('top_link', $this->sublink($this->links, 'email_tpl'));
Tpl::showpage('message.email_tpl.edit');
}
示例8: settingOp
/**
* 金币设置
*/
public function settingOp()
{
/**
* 读取语言包
*/
$lang = Language::getLangContent();
/**
* 实例化模型
*/
$model_setting = Model('setting');
/**
* 保存信息
*/
if (chksubmit()) {
/**
* 验证
*/
$obj_validate = new Validate();
$obj_validate->validateparam = array(array("input" => $_POST["gold_isuse"], "require" => "true", "message" => $lang['gold_isuse_check']), array("input" => $_POST["gold_rmbratio"], "require" => "true", "validator" => "Number", "message" => $lang['gold_rmbratio_isnum']));
$error = $obj_validate->validate();
if ($error != '') {
showMessage($error);
} else {
/*
* 构造更新数据数组
*/
$update_array = array();
$update_array['promotion_allow'] = trim($_POST['promotion_allow']);
$update_array['points_isuse'] = trim($_POST['points_isuse']);
$update_array['gold_isuse'] = trim($_POST['gold_isuse']);
$update_array['gold_rmbratio'] = trim($_POST['gold_rmbratio']);
$update_array['predeposit_isuse'] = trim($_POST['predeposit_isuse']);
$update_array['groupbuy_allow'] = trim($_POST['groupbuy_allow']);
//积分中心
$update_array['pointshop_isuse'] = trim($_POST['pointshop_isuse']);
if (C('payment') != 1) {
$update_array['predeposit_isuse'] = 1;
}
//支付到平台时强制开启预存款功能
$result = $model_setting->updateSetting($update_array);
if ($result === true) {
showMessage($lang['nc_common_save_succ']);
} else {
showMessage($lang['nc_common_save_fail']);
}
}
}
/**
* 读取设置内容 $list_setting
*/
$list_setting = $model_setting->getListSetting();
/**
* 模板输出
*/
Tpl::output('list_setting', $list_setting);
Tpl::showpage('operation.setting');
}
示例9: _check_passwd_data
/**
* 检查修改密码数据
* @author Yusure http://yusure.cn
* @date 2016-02-15
* @param [param]
* @return [type] [description]
*/
private function _check_passwd_data()
{
import('Org.Util.Validate');
$obj_validate = new \Validate();
$obj_validate->validateparam = array(array('input' => $_POST['old_pwd'], 'require' => 'true', 'message' => '旧不能为空'), array('input' => $_POST['new_pwd'], 'require' => 'true', 'message' => '新密码不能为空'), array('input' => $_POST['new_pwd'], 'require' => 'true', 'validator' => 'length', 'min' => '6', 'max' => '16', 'message' => '密码范围在6~16位之间!'), array('input' => $_POST['confirm_pwd'], 'require' => 'true', 'message' => '确认密码不能为空'), array('input' => $_POST['new_pwd'], 'validator' => 'compare', 'operator' => '==', 'to' => $_POST['confirm_pwd'], 'message' => '您两次输入的密码不一致!'));
$error = $obj_validate->validate();
if ($error != '') {
$this->error($error);
}
}
示例10: _checkLoginPost
/**
* 检查登陆提交
* @author Yusure http://yusure.cn
* @date 2016-02-03
* @param [param]
* @return [type] [description]
*/
private function _checkLoginPost()
{
import('Org.Util.Validate');
$obj_validate = new \Validate();
$obj_validate->validateparam = array(array('input' => $_POST['user_name'], 'require' => 'true', 'message' => '用户名不能为空'), array('input' => $_POST['user_passwd'], 'require' => 'true', 'message' => '密码不能为空'), array('input' => $_POST['user_name'], 'require' => 'true', 'validator' => 'length', 'min' => '1', 'max' => '32', 'message' => '用户名太长'), array('input' => $_POST['user_passwd'], 'require' => 'true', 'validator' => 'length', 'min' => '1', 'max' => '32', 'message' => '密码太长'));
$error = $obj_validate->validate();
if ($error != '') {
$this->error($error);
}
}
示例11: mb_home_editOp
/**
* 编辑
*/
public function mb_home_editOp()
{
$model = Model('mb_home');
if ($_POST['form_submit'] == 'ok') {
//验证
$obj_validate = new Validate();
$obj_validate->validateparam = array(array("input" => $_POST["h_title"], "require" => "true", "message" => L('home_add_null')), array("input" => $_POST["h_desc"], "require" => "true", "message" => L('home_add_null')), array("input" => $_POST["h_keyword"], "require" => "true", "message" => L('home_add_null')), array("input" => $_POST["h_sort"], "require" => "true", 'validator' => 'Number', "message" => L('home_add_sort_int')));
$error = $obj_validate->validate();
if ($error != '') {
showMessage($error);
} else {
$home_array = $model->getMbHomeInfoByID(intval($_POST['h_id']));
//上传图片
if ($_FILES['h_img']['name'] != '') {
$upload = new UploadFile();
$upload->set('default_dir', ATTACH_MOBILE . '/home');
$result = $upload->upfile('h_img');
if ($result) {
$_POST['h_img'] = $upload->file_name;
} else {
showMessage($upload->error);
}
}
$update_array = array();
$update_array['h_title'] = trim($_POST['h_title']);
$update_array['h_desc'] = trim($_POST['h_desc']);
$update_array['h_keyword'] = trim($_POST['h_keyword']);
if (!empty($_POST['h_multi_keyword'])) {
$update_array['h_multi_keyword'] = $_POST['h_multi_keyword'];
}
if ($_POST['h_img']) {
$update_array['h_img'] = $_POST['h_img'];
}
$update_array['h_sort'] = trim($_POST['h_sort']);
$condition = array();
$condition['h_id'] = intval($_POST['h_id']);
$result = $model->editMbHome($update_array, $condition);
if ($result) {
//除图片
if (!empty($_POST['h_img']) && !empty($home_array['h_img'])) {
@unlink(BASE_ROOT_PATH . DS . DIR_UPLOAD . DS . ATTACH_MOBILE . '/home' . DS . $home_array['h_img']);
}
showMessage(L('home_edit_succ'), 'index.php?act=mb_home&op=mb_home_list');
} else {
showMessage(L('home_edit_fail'));
}
}
}
$home_array = $model->getMbHomeInfoByID(intval($_GET['h_id']));
if (empty($home_array)) {
showMessage(L('wrong_argument'));
}
Tpl::output('home_array', $home_array);
Tpl::showpage('mb_home.edit');
}
示例12: save
/**
* update/insert row
*
* @param array array The array of key => value pairs to be inserted into the database
*
* @return object
*/
public function save($array = null)
{
//get our class
$class = get_called_class();
//get our table column / field names
$fields = array_keys($class::$columns);
//get our table name
$table = $class::$table;
//if we're passed an array of key => value pairs, use those
//and override the other values that were passed in
if (!is_null($array) and is_array($array)) {
foreach ($array as $key => $value) {
$this->{$key} = $value;
}
}
//loop through out fields...
foreach ($fields as $key) {
//for ease or access, store this
$value = $this->{$key};
//auto-validate
$validated = Validate::validate($class, $key, $value);
//check the validate didnt return false (failing)
if ($validated === false) {
//if it did, throw an exception
throw new MeagrException('The value "' . $value . '" was given for "' . $key . '" breaking one or more validate rules "' . implode('", "', $class::$columns[$key]['validate']) . '". ');
continue;
}
//if we passed validate
if (isset($value) and !empty($value) and $validated !== false) {
$data[$key] = $validated;
//if the value was empty or not set, use the default value
} elseif (!empty($class::$columns[$key]['database']['default'])) {
$data[$key] = $class::$columns[$key]['database']['default'];
//we shouldnt really get here, but if we do, use empty string
} else {
$data[$key] = '';
}
}
//get the db instance
$db = new Database();
//update
if (isset($data['id']) and !empty($data['id'])) {
//set the updated time
$data['updated_at'] = date('Y-m-d H:i:s');
return $db->update($table, $data);
//insert
} else {
//set our time stamps
$data['created_at'] = date('Y-m-d H:i:s');
$data['updated_at'] = date('Y-m-d H:i:s');
return $db->insert($table, $data);
}
}
示例13: update_tag_nameOp
/**
* cms标签标题修改
*/
public function update_tag_nameOp()
{
$new_value = trim($_GET['value']);
$obj_validate = new Validate();
$obj_validate->validateparam = array(array('input' => $new_value, 'require' => 'true', "validator" => "Length", "min" => "1", "max" => "10", 'message' => Language::get('tag_name_error')));
$error = $obj_validate->validate();
if ($error != '') {
echo json_encode(array('result' => FALSE, 'message' => Language::get('tag_name_error')));
die;
} else {
$this->update_tag('tag_name', $new_value);
}
}
示例14: loginOp
/**
* 登录操作
*
*/
public function loginOp()
{
//检测登陆
$this->checklogin();
if (isset($_POST) && !empty($_POST)) {
$obj_validate = new Validate();
$obj_validate->validateparam = array(array("input" => $_POST["member_name"], "require" => "true", "message" => $lang['nc_login_username_is_not_null']), array("input" => $_POST["password"], "require" => "true", "message" => $lang['nc_login_password_is_not_null']));
$error = $obj_validate->validate();
if ($error != '') {
$this->showTip(Language::get('error') . $error, '', 'error');
}
$params = array();
$params['member_name'] = trim($_POST['member_name']);
$params['password'] = md5($_POST['password']);
$model = Model();
$memberinfo = $model->table('member')->where($params)->find();
if (empty($memberinfo)) {
$this->showTip(Language::get('login_index_login_again'), '', 'error');
}
$_SESSION['is_login'] = '1';
$_SESSION['member_id'] = $memberinfo['member_id'];
$_SESSION['member_name'] = $memberinfo['member_name'];
$_SESSION['avatar'] = $memberinfo['avatar'];
$_SESSION['store_id'] = $memberinfo['store_id'];
$model->table('member')->where(array('member_id' => $memberinfo['member_id']))->setInc('login_num', 1);
//选择城市
$area_id = $memberinfo['usercity'];
$model_area = Model('area');
$area_info = $model_area->getOne(array('area_id' => $area_id));
if (get_magic_quotes_gpc()) {
$area_str = serialize($area_info);
} else {
$area_str = serialize(@addslashes($area_info));
}
setCookie('city', $area_str);
$_POST['ref_url'] = strstr($_POST['ref_url'], 'logout') === false && !empty($_POST['ref_url']) ? $_POST['ref_url'] : 'index.php?act=index';
if ($_GET['inajax'] == 1) {
showDialog(Language::get('login_index_login_success'), 'reload', succ);
}
if (!empty($_POST['ref_url'])) {
$this->showTip(Language::get('login_index_login_success'), $_POST['ref_url'], 'succ');
} else {
$this->showTip(Language::get('login_index_login_again'), 'index.php?act=login', 'error');
}
}
if (empty($_GET['ref_url'])) {
$_GET['ref_url'] = getReferer();
}
Tpl::output('banner', 1);
Tpl::showpage('login');
}
示例15: addpointsOp
/**
* 积分添加
*/
public function addpointsOp()
{
if ($_POST['form_submit'] == 'ok') {
/**
* 验证
*/
$obj_validate = new Validate();
$obj_validate->validateparam = array(array("input" => $_POST["member_id"], "require" => "true", "message" => Language::get('admin_points_member_error_again')), array("input" => $_POST["pointsnum"], "require" => "true", 'validator' => 'Compare', 'operator' => ' >= ', 'to' => 1, "message" => Language::get('admin_points_points_min_error')));
$error = $obj_validate->validate();
if ($error != '') {
showMessage($error, '', '', 'error');
}
//查询会员信息
$obj_member = Model('member');
$member_id = intval($_POST['member_id']);
$member_info = $obj_member->infoMember(array('member_id' => "{$member_id}"));
if (!is_array($member_info) || count($member_info) <= 0) {
showMessage(Language::get('admin_points_userrecord_error'), 'index.php?act=points&op=addpoints', '', 'error');
}
$pointsnum = intval($_POST['pointsnum']);
if ($_POST['operatetype'] == 2 && $pointsnum > intval($member_info['member_points'])) {
showMessage(Language::get('admin_points_points_short_error') . $member_info['member_points'], 'index.php?act=points&op=addpoints', '', 'error');
}
$obj_points = Model('points');
$insert_arr['pl_memberid'] = $member_info['member_id'];
$insert_arr['pl_membername'] = $member_info['member_name'];
$admininfo = $this->getAdminInfo();
$insert_arr['pl_adminid'] = $admininfo['id'];
$insert_arr['pl_adminname'] = $admininfo['name'];
if ($_POST['operatetype'] == 2) {
$insert_arr['pl_points'] = -$_POST['pointsnum'];
} else {
$insert_arr['pl_points'] = $_POST['pointsnum'];
}
if ($_POST['pointsdesc']) {
$insert_arr['pl_desc'] = trim($_POST['pointsdesc']);
} else {
$insert_arr['pl_desc'] = Language::get('admin_points_system_desc');
}
$result = $obj_points->savePointsLog('system', $insert_arr, true);
if ($result) {
showMessage(Language::get('admin_points_add_success'), 'index.php?act=points&op=addpoints');
} else {
showMessage(Language::get('admin_points_add_fail'), 'index.php?act=points&op=addpoints', '', 'error');
}
} else {
Tpl::showpage('points.add');
}
}