本文整理汇总了PHP中obj::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP obj::validate方法的具体用法?PHP obj::validate怎么用?PHP obj::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obj
的用法示例。
在下文中一共展示了obj::validate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addComment
/**
* 发表评论
*
*/
private function addComment()
{
$input_param = array();
$input_param['user_id'] = intval($_SESSION['userinfo']['user_id']);
$input_param['goods_id'] = intval($this->_input['goods_id']);
$input_param['comment_body'] = trim($this->_input['comment_body']);
/*验证信息*/
$this->objvalidate->setValidate(array('input' => $input_param['user_id'], 'require' => "true", 'message' => $this->_lang['product_good_comment_login']));
$this->objvalidate->setValidate(array('input' => $input_param['comment_body'], 'require' => "true", 'message' => $this->_lang['product_good_comment_null']));
/*判断验证码是否开启*/
if ($this->_viewinfo['websit']['view_comment_validate'] == '1') {
$this->objvalidate->setValidate(array('input' => strtoupper($this->_input['txt_comment_code']), 'require' => "true", "validator" => "Compare", "operator" => "==", "to" => strtoupper($_SESSION['seccode']), 'message' => $this->_lang['product_good_code_error']));
}
$error = $this->objvalidate->validate();
if ($error) {
$this->showMessage($error, $this->refer_url, 1);
}
if ($input_param['comment_body'] != "") {
$result = $this->obj_comment->addGoodsComment($input_param);
if ($result) {
$this->showMessage($this->_lang['product_good_comment_succ'], $this->_configinfo['websit']['site_url'] . "/product.php?id=" . $input_param['goods_id'], 1, 2000);
} else {
$this->showMessage($this->_lang['product_good_comment_error'], $this->_configinfo['websit']['site_url'] . "/product.php?id=" . $input_param['goods_id'], 1, 2000);
}
} else {
$this->showMessage($this->_lang['product_good_comment_null'], $this->_configinfo['websit']['site_url'] . "/product.php?id=" . $input_param['goods_id'], 1, 2000);
}
}
示例2: saveGoodsClass
/**
* 保存商品分类
*
*/
private function saveGoodsClass()
{
/*权限检查*/
$this->checkAdmin('goods_class_add');
$input_param['txt_class_top_id'] = intval($this->_input['txt_class_top_id']);
//父级分类id
$input_param['txt_class_name'] = trim($this->_input['txt_class_name']);
//分类名称
$input_param['txt_class_state'] = intval($this->_input['txt_class_state']);
//分类状态0、开启1、关闭
$input_param['txt_class_keywords'] = trim($this->_input['txt_class_keywords']);
//分类关键字
$input_param['txt_class_description'] = trim($this->_input['txt_class_description']);
//分类描述
$input_param['txt_class_sort'] = intval($this->_input['txt_class_sort']);
//分类排序
$input_param['txt_class_language'] = intval($this->_input['txt_class_language']);
//分类语言显示
$input_param['txt_class_url'] = trim($this->_input['txt_class_url']);
//分类指向的url外联
$input_param['txt_class_menu'] = intval($this->_input['txt_class_menu']);
//是否导航显示
$input_param['txt_class_language'] = intval($this->_input['txt_class_language']);
//选择语言
$input_param['txt_goods_type_id'] = intval($this->_input['txt_goods_type_id']);
//商品类型
$input_param['txt_modify_sub'] = intval($this->_input['modify_sub']);
//修改范围
$input_param['txt_class_attr'] = serialize(array_filter($this->_input['txt_class_attr'], 'htmlspecialchars'));
//序列化特殊属性
/**
* 验证注册信息
*/
$this->obj_validate->setValidate(array("input" => $input_param['txt_class_name'], "require" => "true", "message" => $this->_lang['admin_goods_class_name_is_null']));
//分类名称不能为空
$error = $this->obj_validate->validate();
if ($error != "") {
//返回错误信息
$this->adminMessage($error, $this->_configinfo['websit']['site_url'] . "/admin/admin_goods_class.php?action=page_goods_class", 1, 4000);
} else {
if ($this->_input['class_id'] != "") {
$class_id = intval($this->_input['class_id']);
//检查修改的分类topid是否是当前分类的下级,如果是返回错误,不是的话,正常进行
$productClassArray = $this->obj_goods_class->listClassDetail("");
$class_top_id = $input_param['txt_class_top_id'];
$sub_class = $this->obj_goods_class->getArrayById($productClassArray, $result, $class_id);
$sub_class[] = $class_id;
if ($sub_class != null) {
if (in_array($class_top_id, $sub_class)) {
$this->adminMessage($this->_lang['admin_goods_class_list_move_error'], $this->refer_url, 1, 3000);
}
}
$rs = $this->obj_goods_class->modifyGoodsClass($input_param, $class_id);
} else {
$rs = $this->obj_goods_class->addGoodsClass($input_param);
}
if ($rs) {
$this->obj_goods_class->createGoodsClassArray();
/*日志保存*/
$log_array = array();
$log_array['log_info'] = $this->_lang['admin_goods_class_save_ok'];
$this->obj_log->inLog($log_array);
$this->adminMessage($this->_lang['admin_goods_class_save_ok'], $this->_configinfo['websit']['site_url'] . "/admin/admin_goods_class.php?action=list", 1, 1000);
} else {
/*日志保存*/
$log_array = array();
$log_array['log_info'] = $this->_lang['admin_goods_class_save_false'];
$this->obj_log->inLog($log_array);
$this->adminMessage($this->_lang['admin_goods_class_save_false'], $this->_configinfo['websit']['site_url'] . "/admin/admin_goods_class.php?action=page_goods_class", 1, 4000);
}
}
}
示例3: __autoload
<?php
session_start();
function __autoload($class)
{
include_once '../lib/' . $class . '.php';
}
$form = new validator();
$obj = new obj();
if (isset($_POST['submit'])) {
$name_cat = $_POST['name_category'];
$name_cat_error = $form->walang_laman($name_cat, "Category");
$errors = $name_cat_error;
if (!isset($_POST['form_key']) || !$obj->validate()) {
$error = 'Invalid Token!';
} else {
if (empty($errors)) {
$data = array('catname' => $name_cat);
$obj->insert('tbl_m_category', $data);
$success = "yesssssssssssss";
}
}
}
//echo $_SESSION['form_key'];
echo $error ? $error : '';
echo $success ? $success : '';
?>
<form action="" method="post">
<?php
$obj->outputKey();
?>