本文整理匯總了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);
}
}