本文整理匯總了PHP中Core\Helper\Utility\Validator::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validator::validate方法的具體用法?PHP Validator::validate怎麽用?PHP Validator::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Core\Helper\Utility\Validator
的用法示例。
在下文中一共展示了Validator::validate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get
public function get($f3)
{
// 設置 order_refer 記錄,記錄在客戶端
$orderRefer = array();
// 檢查彩貝的記錄
$caibeiRefer = $f3->get('SESSION[yiqifa_caibei_order_refer]');
if (!empty($caibeiRefer)) {
$orderRefer = $caibeiRefer;
unset($orderRefer['refer_host']);
// 去掉彩貝的 refer_host
}
// 清除彩貝記錄
$f3->set('SESSION[yiqifa_caibei_order_refer]', null);
$orderRefer['utm_source'] = 'YIQIFACPS';
// 保存額外的 億起發 參數
$validator = new Validator($_REQUEST);
$referParamArray = array();
$referParamArray['src'] = $validator->validate('src');
$referParamArray['cid'] = $validator->validate('cid');
$referParamArray['wi'] = $validator->validate('wi');
$referParamArray['channel'] = $validator->validate('channel');
$orderRefer['refer_param'] = json_encode($referParamArray);
//設置 cookie
ReferHelper::setOrderReferSpecific($f3, $orderRefer, YiqifaCpsPlugin::getOptionValue('yiqifacps_duration'));
// 頁麵跳轉到商品
$url = $validator->validate('url');
$redirectUrl = empty($url) ? '/' : $url;
RouteHelper::reRoute($this, $redirectUrl);
return;
}
示例2: ListSettle
/**
* 列出結算列表
*
* @param $f3
*/
public function ListSettle($f3)
{
global $smarty;
// 參數驗證
$validator = new Validator($f3->get('GET'));
$pageNo = $validator->digits()->min(0)->validate('pageNo');
$pageSize = $validator->digits()->min(0)->validate('pageSize');
// 設置缺省值
$pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0;
$pageSize = isset($pageSize) && $pageSize > 0 ? $pageSize : 10;
// 表單查詢
$formQuery = array();
//結算時間
$settleTimeStartStr = $validator->validate('settle_time_start');
$settleTimeStart = Time::gmStrToTime($settleTimeStartStr) ?: null;
$settleTimeEndStr = $validator->validate('settle_time_end');
$settleTimeEnd = Time::gmStrToTime($settleTimeEndStr) ?: null;
$formQuery['create_time'] = array($settleTimeStart, $settleTimeEnd);
//是否已經付款
$is_pay = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('is_pay');
switch ($is_pay) {
case 1:
$formQuery['pay_time'] = 0;
break;
case 2:
$formQuery['pay_time'] = array($is_pay, null);
break;
default:
break;
}
// 供貨商隻能查看自己的結算曆史
$authSupplierUser = AuthHelper::getAuthUser();
$formQuery['suppliers_id'] = $authSupplierUser['suppliers_id'];
// 構建查詢條件
$condArray = null;
if (!empty($formQuery)) {
$condArray = QueryBuilder::buildQueryCondArray($formQuery);
}
// 查詢結算列表
$orderSettleService = new OrderSettleService();
$totalCount = $orderSettleService->countOrderSettleArray($condArray);
if ($totalCount <= 0) {
// 沒商品,可以直接退出了
goto out;
}
// 頁數超過最大值,返回
if ($pageNo * $pageSize >= $totalCount) {
RouteHelper::reRoute($this, '/Order/Settle/ListSettle');
}
// 結算列表
$orderSettleArray = $orderSettleService->fetchOrderSettleArray($condArray, $pageNo * $pageSize, $pageSize);
// 給模板賦值
$smarty->assign('totalCount', $totalCount);
$smarty->assign('pageNo', $pageNo);
$smarty->assign('pageSize', $pageSize);
$smarty->assign('orderSettleArray', $orderSettleArray);
out:
$smarty->display('order_settle_listsettle.tpl');
}
示例3: post
public function post($f3)
{
global $smarty;
// 首先做參數合法性驗證
$validator = new Validator($f3->get('POST'));
$input = array();
$input['user_name'] = $validator->required('用戶名不能為空')->minLength(2, '用戶名最短為2個字符')->validate('user_name');
$input['password'] = $validator->required('密碼不能為空')->minLength(6, '密碼最短為6個非空字符')->validate('password');
$input['email'] = $validator->validate('email');
$input['mobile_phone'] = $validator->digits('手機號格式不對')->validate('mobile_phone');
$p_captcha = $validator->required('驗證碼不能為空')->validate('captcha');
// 手機輸入,輸入法經常無故添加空格,我們需要去除所有的空額,防止出錯
$p_captcha = Utils::filterAlnumStr($p_captcha);
// 需要跳轉回去的地址
$returnUrl = $validator->validate('returnUrl');
if (!$this->validate($validator)) {
goto out_fail;
}
// 檢查驗證碼是否有效
$captchaController = new \Controller\Image\Captcha();
if (!$captchaController->validateCaptcha($p_captcha)) {
$this->addFlashMessage('驗證碼錯誤[' . $p_captcha . '][' . $captchaController->getCaptcha() . ']');
goto out_fail;
}
$userService = new UserService();
// 檢查用戶是否已經注冊
$isUserExist = $userService->isUserExist($input['user_name'], $input['email']);
if ($isUserExist) {
$this->addFlashMessage($isUserExist . '已經存在');
goto out_fail;
}
// 注冊用戶
$user = $userService->registerUser($input);
if (!$user) {
$this->addFlashMessage('用戶注冊失敗,請稍後刷新頁麵重試');
goto out_fail;
}
// 記錄用戶的登陸信息
$userInfo = $user->toArray();
unset($userInfo['password']);
// 不要記錄密碼
AuthHelper::saveAuthUser($userInfo, 'normal');
$this->addFlashMessage("注冊成功");
if ($returnUrl) {
header('Location:' . $returnUrl);
return;
} else {
// 跳轉到用戶之前看的頁麵,如果之前沒有看過的頁麵那就回到首頁
RouteHelper::jumpBack($this, '/', true);
}
return;
// 這裏正常返回
out_fail:
// 失敗,從這裏出口
$smarty->assign('captchaUrl', RouteHelper::makeUrl('/Image/Captcha', array('hash' => time())));
$smarty->display('user_register.tpl', 'User|Register|post');
}
示例4: get
public function get($f3)
{
global $smarty;
// 權限檢查
$this->requirePrivilege('manage_misc_cron');
// 參數驗證
$validator = new Validator($f3->get('GET'));
$pageNo = $validator->digits()->min(0)->validate('pageNo');
$pageSize = $validator->digits()->min(0)->validate('pageSize');
// 設置缺省值
$pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0;
$pageSize = isset($pageSize) && $pageSize > 0 ? $pageSize : 20;
//查詢條件
$searchFormQuery = array();
$searchFormQuery['task_name'] = $validator->validate('task_name');
$searchFormQuery['task_desc'] = $validator->validate('task_desc');
$returnCode = $validator->digits()->filter('ValidatorIntValue')->validate('return_code');
if (0 === $returnCode) {
$searchFormQuery['task_run_time'] = array('>', 0);
$searchFormQuery['return_code'] = 0;
} elseif ($returnCode > 0) {
$searchFormQuery['task_run_time'] = array('>', 0);
$searchFormQuery['return_code'] = array('<>', 0);
} else {
// do nothing
}
//任務時間
$taskTimeStartStr = $validator->validate('task_time_start');
$taskTimeStart = Time::gmStrToTime($taskTimeStartStr) ?: null;
$taskTimeEndStr = $validator->validate('task_time_end');
$taskTimeEnd = Time::gmStrToTime($taskTimeEndStr) ?: null;
$searchFormQuery['task_time'] = array($taskTimeStart, $taskTimeEnd);
if (!$this->validate($validator)) {
goto out_display;
}
// 建立查詢條件
$searchParamArray = QueryBuilder::buildQueryCondArray($searchFormQuery);
$cronTaskService = new CronTaskService();
$totalCount = $cronTaskService->countCronTaskArray($searchParamArray);
if ($totalCount <= 0) {
// 沒任務,可以直接退出了
goto out_display;
}
// 頁數超過最大值,返回第一頁
if ($pageNo * $pageSize >= $totalCount) {
RouteHelper::reRoute($this, '/Misc/Cron');
}
$cronTaskArray = $cronTaskService->fetchCronTaskArray($searchParamArray, $pageNo * $pageSize, $pageSize);
// 給模板賦值
$smarty->assign('totalCount', $totalCount);
$smarty->assign('pageNo', $pageNo);
$smarty->assign('pageSize', $pageSize);
$smarty->assign('cronTaskArray', $cronTaskArray);
out_display:
$smarty->display('misc_cron.tpl');
}
示例5: post
public function post($f3)
{
global $smarty;
// 首先做參數合法性驗證
$validator = new Validator($f3->get('POST'));
$input = array();
$input['oldpassword'] = $validator->validate('oldpassword');
$input['password'] = $validator->validate('password');
$input['email'] = $validator->validate('email');
$input['mobile_phone'] = $validator->digits('手機號格式不對')->validate('mobile_phone');
// 用戶打算修改密碼
if (!Utils::isBlank($input['password'])) {
$validator->required('必須提供舊密碼才能修改密碼')->validate('oldpassword');
}
// 提供的舊密碼,但是新密碼為空
if (!Utils::isBlank($input['oldpassword'])) {
$validator->required('新密碼不能為空')->validate('password');
}
if (!$this->validate($validator)) {
goto out_fail;
}
$userInfo = AuthHelper::getAuthUser();
$userService = new UserService();
$user = $userService->loadUserById($userInfo['user_id']);
if (!$user) {
// 非法用戶,應該讓它自動登陸出去
$this->addFlashMessage('非法登陸用戶');
RouteHelper::reRoute($this, '/User/Logout', false);
}
// 用戶打算修改密碼,但是舊密碼不對
if (!empty($input['password']) && !$userService->verifyPassword($userInfo['user_id'], $input['oldpassword'])) {
$this->addFlashMessage('舊密碼不對');
goto out_fail;
}
// 更新數據
unset($input['oldpassword']);
$userService->updateUser($user, $input);
// 更新認證記錄
AuthHelper::removeAuthUser();
AuthHelper::saveAuthUser($user->toArray());
$this->addFlashMessage('資料更新成功');
RouteHelper::reRoute($this, '/My/Profile');
return;
// 這裏正常返回
out_fail:
// 失敗返回
$smarty->display('my_profile.tpl', 'post');
}
示例6: post
public function post($f3)
{
global $smarty;
// 首先做參數合法性驗證
$validator = new Validator($f3->get('POST'));
$input = array();
$input['phone'] = $validator->validate('phone');
$input['address'] = $validator->validate('address');
$input['oldpassword'] = $validator->validate('oldpassword');
$input['password'] = $validator->validate('password');
// 用戶打算修改密碼
if (!Utils::isBlank($input['password'])) {
$validator->required('必須提供舊密碼才能修改密碼')->validate('oldpassword');
}
// 提供的舊密碼,但是新密碼為空
if (!Utils::isBlank($input['oldpassword'])) {
$validator->required('新密碼不能為空')->validate('password');
}
if (!$this->validate($validator)) {
goto out;
}
$authSupplierUser = AuthHelper::getAuthUser();
$supplierUserService = new SupplierUserService();
// 驗證用戶登陸
$supplierUser = $supplierUserService->loadSupplierById($authSupplierUser['suppliers_id']);
if ($supplierUser->isEmpty()) {
$this->addFlashMessage("非法登陸用戶");
RouteHelper::reRoute($this, '/User/Logout', false);
}
// 用戶打算修改密碼,但是舊密碼不對
if (!empty($input['password']) && !$supplierUserService->verifyPassword($authSupplierUser['suppliers_id'], $input['oldpassword'])) {
$this->addFlashMessage('舊密碼不對');
goto out;
}
// 更新數據
unset($input['oldpassword']);
$supplierUserService->updateSupplier($supplierUser, $input);
// 記錄用戶的登陸信息
$supplierUserInfo = $supplierUser->toArray();
unset($supplierUserInfo['password']);
// 不要記錄密碼
AuthHelper::saveAuthUser($supplierUserInfo);
$this->addFlashMessage("修改資料成功");
$smarty->assign($supplierUserInfo);
out:
// 從這裏出去
$smarty->display('my_profile.tpl');
}
示例7: Search
/**
*
* 根據某些查詢條件取得商品的列表
*
* @param $f3
*/
public function Search($f3)
{
// 參數驗證
$validator = new Validator($f3->get('GET'));
$errorMessage = '';
$searchFormQuery = array();
$searchFormQuery['is_on_sale'] = $validator->digits()->min(0)->filter('ValidatorIntValue')->validate('is_on_sale');
$searchFormQuery['goods_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('goods_id');
$searchFormQuery['suppliers_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('suppliers_id');
$searchFormQuery['goods_name'] = $validator->validate('goods_name');
$searchFormQuery['cat_id'] = $validator->digits()->min(0)->filter('ValidatorIntValue')->validate('cat_id');
if (!$this->validate($validator)) {
$errorMessage = implode('|', $this->flashMessageArray);
goto out_fail;
}
// 建立查詢條件
$searchParamArray = QueryBuilder::buildSearchParamArray($searchFormQuery);
// 商品列表
$goodsArray = SearchHelper::search(SearchHelper::Module_Goods, $this->searchFieldSelector, $searchParamArray, array(array('goods_id', 'desc')), 0, 25);
out:
Ajax::header();
echo Ajax::buildResult(null, null, $goodsArray);
return;
out_fail:
// 失敗,返回出錯信息
Ajax::header();
echo Ajax::buildResult(-1, $errorMessage, null);
}
示例8: ListChildTreeNodeAllStr
public function ListChildTreeNodeAllStr($f3)
{
// 參數驗證
$validator = new Validator($f3->get('GET'));
$errorMessage = '';
$treeKey = $validator->required()->validate('treeKey');
$parentId = $validator->digits()->min(0)->validate('parentId');
$parentId = $parentId ?: 0;
// 用戶也可以通過 treeNodeName 來做查詢
$treeNodeName = $validator->validate('treeNodeName');
if (!$this->validate($validator)) {
$errorMessage = implode('|', $this->flashMessageArray);
goto out_fail;
}
// 檢查緩存
$cacheKey = md5(__NAMESPACE__ . '\\' . __CLASS__ . '\\' . __METHOD__ . '\\' . $treeKey . '\\' . $parentId . '\\' . $treeNodeName);
$outputArray = $f3->get($cacheKey);
if (!empty($outputArray)) {
goto out;
}
$metaTreeService = new MetaTreeService();
if (!empty($treeNodeName)) {
$treeNode = $metaTreeService->loadTreeNodeWithTreeKeyAndName($treeKey, $treeNodeName);
if (!$treeNode->isEmpty()) {
$parentId = $treeNode['meta_id'];
}
}
// 取得樹形的層級結構
$treeNodeArray = $metaTreeService->fetchChildTreeNodeArrayAll($treeKey, $parentId);
// 構建顯示輸出
$outputArray = array();
function buildHierarchyArray(&$outputArray, $treeNodeArray, $separator = '')
{
$hierarchySeparator = '---------->';
foreach ($treeNodeArray as $treeNodeItem) {
$outputItem = array();
$outputItem['meta_id'] = $treeNodeItem['meta_id'];
$outputItem['meta_name'] = $treeNodeItem['meta_name'];
$outputItem['display_text'] = $separator . $treeNodeItem['meta_name'];
$outputArray[] = $outputItem;
// 有子節點,遞歸建立子節點
if (isset($treeNodeItem['child_list'])) {
buildHierarchyArray($outputArray, $treeNodeItem['child_list'], $separator . $hierarchySeparator);
}
}
}
buildHierarchyArray($outputArray, $treeNodeArray, '');
$f3->set($cacheKey, $outputArray, 600);
//緩存 10 分鍾
out:
Ajax::header();
echo Ajax::buildResult(null, null, $outputArray);
return;
out_fail:
// 失敗,返回出錯信息
Ajax::header();
echo Ajax::buildResult(-1, $errorMessage, null);
}
示例9: Edit
/**
* 角色詳情顯示
*/
public function Edit($f3)
{
// 權限檢查
$this->requirePrivilege('manage_account_role_edit_get');
global $smarty;
// 參數驗證
$validator = new Validator($f3->get('GET'));
$meta_id = $validator->digits()->min(1)->validate('meta_id');
$meta_id = $meta_id > 0 ? $meta_id : 0;
if (!$this->validate($validator)) {
goto out;
}
// 查詢角色信息
$metaRoleService = new MetaRoleService();
$role = $metaRoleService->loadRoleById($meta_id);
if (0 != $meta_id && $role->isEmpty()) {
// 不存在的角色
$this->addFlashMessage('角色不存在');
goto out;
}
if ($role->isEmpty()) {
// 新建角色
$this->requirePrivilege('manage_account_role_create');
}
if (!$f3->get('POST')) {
// 沒有 post ,隻是普通的顯示
goto out_display;
}
// 權限檢查
$this->requirePrivilege('manage_account_role_edit_post');
// 用戶提交了更新請求,這裏做角色信息更新
$validator = new Validator($f3->get('POST'));
$metaRoleService->saveRole($meta_id, $validator->validate('meta_name'), $validator->validate('meta_desc'), $role['meta_data']);
if (0 == $meta_id) {
$this->addFlashMessage('成功新建角色');
} else {
$this->addFlashMessage('角色信息更新成功');
}
out_display:
//給 smarty 模板賦值
$smarty->assign($role->toArray());
out:
$smarty->display('account_role_edit.tpl');
}
示例10: Edit
/**
* 更新或者新建一個分類
*
* @param $f3
*/
public function Edit($f3)
{
// 權限檢查
$this->requirePrivilege('manage_goods_category_edit');
// 參數驗證
$validator = new Validator($f3->get('POST'));
$meta_id = $validator->digits()->validate('meta_id');
$meta_id = $meta_id ?: 0;
$meta_name = $validator->validate('meta_name');
$parent_meta_id = $validator->digits()->validate('parent_meta_id');
$meta_sort_order = $validator->digits()->validate('meta_sort_order');
$meta_status = $validator->digits()->validate('meta_status');
// 篩選屬性
$filterTypeIdArray = $validator->validate('filterTypeIdArray');
$filterAttrItemIdArray = $validator->validate('filterAttrItemIdArray');
if (!$this->validate($validator)) {
goto out;
}
if ($parent_meta_id > 0 && $parent_meta_id == $meta_id) {
$this->addFlashMessage('父分類不能指向自己');
goto out;
}
// 構造篩選屬性結構
$filterArray = array();
$count = min(count($filterTypeIdArray), count($filterAttrItemIdArray));
for ($index = 0; $index < $count; $index++) {
$typeId = abs(intval($filterTypeIdArray[$index]));
$attrItemId = abs(intval($filterAttrItemIdArray[$index]));
if ($typeId <= 0 || $attrItemId <= 0) {
// 非法值跳過
continue;
}
$filterArray[] = array('typeId' => $typeId, 'attrItemId' => $attrItemId);
}
$meta_data = array('filterArray' => $filterArray);
$goodsCategoryService = new GoodsCategoryService();
$goodsCategoryService->saveCategoryById($meta_id, $parent_meta_id, $meta_name, null, json_encode($meta_data), $meta_sort_order, $meta_status);
// 清除商品分類的緩存
ClearHelper::clearGoodsCategory();
$this->addFlashMessage('商品分類保存成功');
out:
RouteHelper::reRoute($this, '/Goods/Category');
}
示例11: post
public function post($f3)
{
// 權限檢查
$this->requirePrivilege('manage_plugin_theme_adv_configure');
// 參數驗證
$validator = new Validator($f3->get('POST'));
// slider 廣告設置
$imageArray = $validator->validate('image');
$urlArray = $validator->validate('url');
$targetArray = $validator->validate('target');
$imageSize = is_array($imageArray) ? count($imageArray) : 0;
$shop_index_adv_slider = array();
// 組織數據結構
for ($index = 0; $index < $imageSize; $index++) {
$shop_index_adv_slider[] = array('image' => $imageArray[$index], 'url' => $urlArray[$index], 'target' => $targetArray[$index]);
}
ShopThemePlugin::saveOptionValue('shop_index_adv_slider', json_encode($shop_index_adv_slider));
// 清除 /Shop/Index 頁麵
$shopClear = new ShopClear();
$shopClear->clearHomePage();
$this->addFlashMessage('保存設置成功');
RouteHelper::reRoute($this, '/Theme/Shop/AdvShopSlider');
}
示例12: post
public function post($f3)
{
global $smarty;
// 首先做參數合法性驗證
$validator = new Validator($f3->get('POST'));
$input = array();
$input['user_name'] = $validator->required('用戶名不能為空')->minLength(2, '用戶名最短為2個字符')->validate('user_name');
$input['password'] = $validator->required('密碼不能為空')->minLength(6, '密碼最短為6個非空字符')->validate('password');
$input['email'] = $validator->validate('email');
$input['mobile_phone'] = $validator->digits('手機號格式不對')->validate('mobile_phone');
$p_captcha = $validator->required('驗證碼不能為空')->validate('captcha');
if (!$this->validate($validator)) {
goto out_fail;
}
// 檢查驗證碼是否有效
$captchaController = new \Controller\Image\Captcha();
if (!$captchaController->validateCaptcha($p_captcha)) {
$this->addFlashMessage("驗證碼錯誤");
goto out_fail;
}
$userService = new UserService();
// 檢查用戶是否已經注冊
$isUserExist = $userService->isUserExist($input['user_name'], $input['email']);
if ($isUserExist) {
$this->addFlashMessage($isUserExist . '已經存在');
goto out_fail;
}
// 注冊用戶
$user = $userService->registerUser($input);
if (!$user) {
$this->addFlashMessage('用戶注冊失敗,請稍後刷新頁麵重試');
goto out_fail;
}
// 記錄用戶的登陸信息
$userInfo = $user->toArray();
unset($userInfo['password']);
// 不要記錄密碼
AuthHelper::saveAuthUser($userInfo, 'normal');
// 設置用戶名在網頁顯示
ClientData::saveClientData(Login::$clientDataIsUserLoginKey, true);
ClientData::saveClientData(Login::$clientDataUserNameDisplayKey, $user->user_name);
$this->addFlashMessage("注冊成功");
// 跳轉到用戶之前看的頁麵,如果之前沒有看過的頁麵那就回到首頁
RouteHelper::jumpBack($this, '/', true);
return;
// 這裏正常返回
out_fail:
// 失敗,從這裏出口
$smarty->display('user_login.tpl', 'User|Register|post');
}
示例13: post
public function post($f3)
{
global $smarty;
// 首先做參數合法性驗證
$validator = new Validator($f3->get('POST'));
$input = array();
$input['user_name'] = $validator->required('用戶名不能為空')->validate('user_name');
$input['password'] = $validator->required('密碼不能為空')->validate('password');
$p_captcha = $validator->required('驗證碼不能為空')->validate('captcha');
// 手機輸入,輸入法經常無故添加空格,我們需要去除所有的空額,防止出錯
$p_captcha = Utils::filterAlnumStr($p_captcha);
// 需要跳轉回去的地址
$returnUrl = $validator->validate('returnUrl');
if (!$this->validate($validator)) {
goto out_fail;
}
// 檢查驗證碼是否有效
$captchaController = new \Controller\Image\Captcha();
if (!$captchaController->validateCaptcha($p_captcha)) {
$this->addFlashMessage('驗證碼錯誤[' . $p_captcha . '][' . $captchaController->getCaptcha() . ']');
goto out_fail;
}
$userService = new UserService();
// 驗證用戶登陸
$user = $userService->doAuthUser($input['user_name'], $input['user_name'], $input['password']);
if (!$user) {
$this->addFlashMessage("登陸失敗,用戶名、密碼錯誤");
goto out_fail;
}
// 記錄用戶的登陸信息
$userInfo = $user->toArray();
unset($userInfo['password']);
// 不要記錄密碼
AuthHelper::saveAuthUser($userInfo, 'normal');
$this->addFlashMessage("登陸成功");
if ($returnUrl) {
header('Location:' . $returnUrl);
return;
} else {
// 跳轉到用戶之前看的頁麵,如果之前沒有看過的頁麵那就回到首頁
RouteHelper::jumpBack($this, '/', true);
}
return;
// 這裏正常返回
out_fail:
// 失敗從這裏出口
$smarty->assign('captchaUrl', RouteHelper::makeUrl('/Image/Captcha', array('hash' => time())));
$smarty->display('user_login.tpl', 'User|Login|post');
}
示例14: Edit
public function Edit($f3)
{
// 權限檢查
$this->requirePrivilege('manage_goods_brand_listbrand');
global $smarty;
// 參數驗證
$validator = new Validator($f3->get('GET'));
$brand_id = $validator->digits()->min(1)->validate('brand_id');
if (!$brand_id) {
$brand_id = 0;
}
$goodsBrandService = new GoodsBrandService();
$goodsBrand = $goodsBrandService->loadBrandById($brand_id);
if (!$f3->get('POST')) {
// 沒有 post ,隻是普通的顯示
goto out_display;
}
unset($validator);
$validator = new Validator($f3->get('POST'));
$goodsBrand->brand_name = $validator->required()->validate('brand_name');
$goodsBrand->brand_desc = $validator->required()->validate('brand_desc');
$goodsBrand->brand_logo = $validator->validate('brand_logo');
$goodsBrand->is_custom = $validator->digits()->filter('ValidatorIntValue')->validate('is_custom');
$goodsBrand->custom_page = $f3->get('POST[custom_page]');
if (!$this->validate($validator)) {
goto out_display;
}
$goodsBrand->save();
if (0 == $brand_id) {
$this->addFlashMessage('新建商品品牌成功');
} else {
$this->addFlashMessage('更新商品品牌成功');
}
// 記錄管理員日誌
AdminLog::logAdminOperate('goods.brand.edit', '編輯品牌', $goodsBrand->brand_name);
out_display:
// 新建的品牌,reRoute 到編輯頁麵
if (!$brand_id) {
RouteHelper::reRoute($this, RouteHelper::makeUrl('/Goods/Brand/Edit', array('brand_id' => $goodsBrand->brand_id), true));
}
//給 smarty 模板賦值
$smarty->assign($goodsBrand->toArray());
$smarty->display('goods_brand_edit.tpl');
return;
out_fail:
// 失敗從這裏退出
RouteHelper::reRoute($this, '/Goods/Brand/ListBrand');
}
示例15: Edit
/**
* 更新或者新建一個快遞公司
*
* @param $f3
*/
public function Edit($f3)
{
// 權限檢查
$this->requirePrivilege('manage_misc_express_edit');
global $smarty;
// 參數驗證
$validator = new Validator($f3->get('GET'));
$meta_id = $validator->digits()->validate('meta_id');
$meta_id = $meta_id ?: 0;
// 加載 快遞信息
$expressService = new ExpressService();
$expressInfo = $expressService->loadMetaById($meta_id);
if (Request::isRequestGet()) {
goto out_assign;
}
// 安全性檢查
if ($meta_id > 0) {
if ($expressInfo->isEmpty() || ExpressService::META_TYPE != $expressInfo->meta_type) {
$this->addFlashMessage('非法ID[' . $meta_id . ']');
goto out;
}
}
unset($validator);
$validator = new Validator($f3->get('POST'));
$inputArray = array();
$inputArray['meta_type'] = ExpressService::META_TYPE;
$inputArray['meta_name'] = $validator->required()->validate('meta_name');
$inputArray['meta_ename'] = $validator->required()->validate('meta_ename');
$inputArray['meta_sort_order'] = $validator->digits()->validate('meta_sort_order');
$inputArray['meta_status'] = $validator->digits()->validate('meta_status');
$inputArray['meta_desc'] = $validator->validate('meta_desc');
if (!$this->validate($validator)) {
goto out;
}
// 保存
$expressInfo->copyFrom($inputArray);
$expressInfo->save();
$this->addFlashMessage('快遞信息保存成功');
// POST 成功從這裏退出
RouteHelper::reRoute($this, RouteHelper::makeUrl('/Misc/Express/Edit', array('meta_id' => $expressInfo->meta_id), true));
return;
out_assign:
$smarty->assign($expressInfo->toArray());
out:
$smarty->display('misc_express_edit.tpl');
}