本文整理汇总了PHP中FormHelper::testInput方法的典型用法代码示例。如果您正苦于以下问题:PHP FormHelper::testInput方法的具体用法?PHP FormHelper::testInput怎么用?PHP FormHelper::testInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormHelper
的用法示例。
在下文中一共展示了FormHelper::testInput方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createReply
public function createReply()
{
// Create needed instances
$formval = new FormHelper();
$session = new SessionHelper();
$thisuser = new User();
$newpost = new Post();
$postModel = new PostModel();
$toppostid = $formval->testInput($_POST['toppost_id']);
$toppost = new Post($toppostid);
$currentcategory = new Category($toppost->category_id);
// Grab all data
// It's a reply so no title
$newpost->title = '';
$newpost->contents = $formval->testInput($_POST['contents']);
// It's a reply so insert the toppost id
$newpost->post_relation_id = $toppostid;
// The post_relation_id takes care of showing this post under the right toppost
$newpost->category_id = $toppost->category_id;
$newpost->user_id = $thisuser->id;
$newpost->date_created = time();
// Validate if contents is not empty
$formval->fieldEmpty('Contents', $newpost->contents);
if ($formval->formErrors()) {
$session->setMessage('Please provide contents', 3);
redirectTo(BASE_URL . 'index.php?c=user&a=viewcreatereply&id=' . $toppostid);
}
// The action of createTopPost would be the same as createReply
if ($currentcategory->is_locked != 1 && $postModel->createTopPost($newpost)) {
$session->setMessage('Reply posted', 4);
redirectTo(BASE_URL . 'index.php?c=user&a=viewpost&id=' . $toppostid);
} else {
if ($currentcategory->is_locked == 1) {
$session->setMessage('Reply not created, category is locked', 2);
} else {
$session->setMessage('Reply not created', 3);
}
redirectTo(BASE_URL . 'index.php?c=user&a=viewpost&id=' . $toppostid);
}
}
示例2: _authenticate
private function _authenticate()
{
$session = new SessionHelper();
$formval = new FormHelper();
// Captcha
include_once BASE_URI . 'app/vendor/securimage/securimage.php';
$securimage = new Securimage();
if ($securimage->check($formval->testInput($_POST['captcha_code'])) == false) {
$session->setMessage('Verification code was incorrect, please try again', 3);
return false;
}
$username = $formval->testInput($_POST['username']);
$password = $formval->testInput($_POST['password']);
$usermodel = new UserModel();
if ($usermodel->authenticateUser($username, $password)) {
return true;
} else {
$session->setMessage('Username / password incorrect or acount inactive', 3);
return false;
}
}
示例3: editCategoryLocked
public function editCategoryLocked()
{
$session = new SessionHelper();
$formval = new FormHelper();
// Id of the category being changed
$id = $formval->testInput($_POST['id']);
$categorymodel = new CategoryModel();
if ($formval->testInput($_POST['lock'])) {
if ($categorymodel->changeLocked($id, 1)) {
$session->setMessage('Setting changed', 4);
redirectTo(BASE_URL . 'index.php?c=user&a=editcategory&id=' . $id);
} else {
$session->setMessage('Setting not changed', 3);
redirectTo(BASE_URL . 'index.php?c=user&a=editcategory&id=' . $id);
}
} elseif ($formval->testInput($_POST['unlock'])) {
if ($categorymodel->changeLocked($id, 0)) {
$session->setMessage('Setting changed', 4);
redirectTo(BASE_URL . 'index.php?c=user&a=editcategory&id=' . $id);
} else {
$session->setMessage('Setting not changed', 3);
redirectTo(BASE_URL . 'index.php?c=user&a=editcategory&id=' . $id);
}
} else {
$session->setMessage('Setting not changed', 3);
redirectTo(BASE_URL . 'index.php?c=user&a=editcategory&id=' . $id);
}
}