本文整理汇总了PHP中RequestUtil类的典型用法代码示例。如果您正苦于以下问题:PHP RequestUtil类的具体用法?PHP RequestUtil怎么用?PHP RequestUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RequestUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$workTime = new WorkTimeUtil();
if (RequestUtil::isPost()) {
$params = RequestUtil::postParams();
$params = array_map(function ($time) {
if (!preg_match("~^\\d{2}:\\d{2}:\\d{2}\$~", $time)) {
return "{$time}:00";
} else {
return $time;
}
}, $params);
$allDay = $workTime->build($params['allDayStart'], $params['allDayEnd']);
$morningShift = $workTime->build($params['morningShiftStart'], $params['morningShiftEnd']);
$middayShift = $workTime->build($params['middayShiftStart'], $params['middayShiftEnd']);
$nightShift = $workTime->build($params['nightShiftStart'], $params['nightShiftEnd']);
$workTime->saveWorkTime($allDay, $morningShift, $nightShift, $middayShift);
$workTime->getTime();
}
list($allDayStart, $allDayEnd) = $workTime->explode($workTime->getAllDay());
list($morningShiftStart, $morningShiftEnd) = $workTime->explode($workTime->getMorningShift());
list($middayShiftStart, $middayShiftEnd) = $workTime->explode($workTime->getMiddayShift());
list($nightShiftStart, $nightShiftEnd) = $workTime->explode($workTime->getNightShift());
$setting = array('allDayStart' => $allDayStart, 'allDayEnd' => $allDayEnd, 'morningShiftStart' => $morningShiftStart, 'morningShiftEnd' => $morningShiftEnd, 'nightShiftStart' => $nightShiftStart, 'nightShiftEnd' => $nightShiftEnd, 'middayShiftStart' => $middayShiftStart, 'middayShiftEnd' => $middayShiftEnd);
$this->view('workTimeSetting', array('setting' => $setting));
}
示例2: updateSlider
public function updateSlider($sliderId)
{
if (!$sliderId) {
$this->message('ID不能为空!');
}
if (RequestUtil::isPost()) {
$this->sliderModel->deleteSliderCache();
$params = RequestUtil::postParams();
// href
if (!preg_match('~^http[s]?://~', $params['href'])) {
$params['href'] = 'http://' . $params['href'];
}
if ($this->sliderModel->rules()->run()) {
$upload = UploadUtil::commonUpload(array('upload/resize_200x200', 'upload/resize_100x100', 'upload/resize_600x600'));
if ($upload) {
$params['pic'] = $upload;
}
$returnUrl = 'slider/updateSlider/' . $sliderId;
if ((new CurdUtil($this->sliderModel))->update(array('slider_id' => $sliderId), $params)) {
$this->message('修改成功!', $returnUrl);
} else {
$this->message('修改失败!', $returnUrl);
}
}
}
$slider = (new CurdUtil($this->sliderModel))->readOne(array('slider_id' => $sliderId, 'disabled' => 0));
if (!$slider) {
$this->message('记录不存在或者已被删除!', 'slider/index');
}
$this->view('slider/updateSlider', array('slider' => $slider));
}
示例3: index
public function index()
{
$error = '';
if (RequestUtil::isPost()) {
$validate = new ValidateUtil();
$validate->required('user_name');
$validate->required('password');
$validate->required('verify_code');
$params = RequestUtil::postParams();
if ($params['verify_code'] != UserUtil::getVerifyCode()) {
$error = '验证码错误!';
} else {
if ($validate->run()) {
$userModel = new UserModel();
$params['password'] = $userModel->encodePassword($params['password']);
$where = array('user_name' => $params['user_name'], 'password' => $params['password']);
$user = (new CurdUtil($userModel))->readOne($where, 'user_id desc', '*, user_type+0 as type');
if (!$user) {
$error = '登录失败,账号或者密码错误,请重试!';
} else {
(new CurdUtil($userModel))->update($where, array('last_login_time' => DateUtil::now()));
UserUtil::saveUser($user);
if (UserUtil::isAdmin()) {
ResponseUtil::redirect(UrlUtil::createBackendUrl('project/index'));
} else {
ResponseUtil::redirect(UrlUtil::createBackendUrl('beautician/index'));
}
}
}
}
}
$this->load->view('backend/login', array('error' => $error));
}
示例4: _finish
protected function _finish($code, $originalRedirectUri)
{
// This endpoint requires "Basic" auth.
$clientCredentials = $this->appInfo->getKey() . ":" . $this->appInfo->getSecret();
$authHeaderValue = "Basic " . base64_encode($clientCredentials);
$response = RequestUtil::doPostWithSpecificAuth($this->clientIdentifier, $authHeaderValue, $this->userLocale, $this->appInfo->getHost()->getApi(), "1/oauth2/token", array("grant_type" => "authorization_code", "code" => $code, "redirect_uri" => $originalRedirectUri));
if ($response->statusCode !== 200) {
throw RequestUtil::unexpectedStatus($response);
}
$parts = RequestUtil::parseResponseJson($response->body);
if (!array_key_exists('token_type', $parts) or !is_string($parts['token_type'])) {
throw new Exception_BadResponse("Missing \"token_type\" field.");
}
$tokenType = $parts['token_type'];
if (!array_key_exists('access_token', $parts) or !is_string($parts['access_token'])) {
throw new Exception_BadResponse("Missing \"access_token\" field.");
}
$accessToken = $parts['access_token'];
if (!array_key_exists('uid', $parts) or !is_string($parts['uid'])) {
throw new Exception_BadResponse("Missing \"uid\" string field.");
}
$userId = $parts['uid'];
if ($tokenType !== "Bearer" && $tokenType !== "bearer") {
throw new Exception_BadResponse("Unknown \"token_type\"; expecting \"Bearer\", got " . Client::q($tokenType));
}
return array($accessToken, $userId);
}
示例5: __construct
public function __construct($totalSize = 0, $config = 'pagination')
{
$config = ConfigUtil::loadConfig($config);
$instance = get_instance();
$config['total_rows'] = $totalSize;
$config['base_url'] = RequestUtil::CM();
$instance->load->library('pagination', $config);
$this->pagination = $instance->pagination;
}
示例6: GetConnectionString
/**
* Get connection string based on request variables
*/
protected function GetConnectionString()
{
$cstring = new DBConnectionString();
$cstring->Host = RequestUtil::Get('host');
$cstring->Port = RequestUtil::Get('port');
$cstring->Username = RequestUtil::Get('username');
$cstring->Password = RequestUtil::Get('password');
$cstring->DBName = RequestUtil::Get('schema');
return $cstring;
}
示例7: Init
/**
* Initialize the GlobalConfig object
*/
static function Init()
{
if (!self::$IS_INITIALIZED) {
require_once 'verysimple/HTTP/RequestUtil.php';
RequestUtil::NormalizeUrlRewrite();
require_once 'verysimple/Phreeze/Controller.php';
Controller::$SmartyViewPrefix = '';
Controller::$DefaultRedirectMode = 'header';
self::$IS_INITIALIZED = true;
}
}
示例8: Login
/**
* Process the login, create the user session and then redirect to
* the appropriate page
*/
public function Login()
{
$user = new ExampleUser();
if ($user->Login(RequestUtil::Get('username'), RequestUtil::Get('password'))) {
// login success
$this->SetCurrentUser($user);
$this->Redirect('SecureExample.UserPage');
} else {
// login failed
$this->Redirect('SecureExample.LoginForm', 'Combinaçãoo de usuário ou senha incorretos');
}
}
示例9: Login
/**
* Process the login, create the user session and then redirect to
* the appropriate page
*/
public function Login()
{
$user = new User($this->Phreezer);
if ($user->Login(RequestUtil::Get('username'), RequestUtil::Get('password'))) {
// login success
$this->SetCurrentUser($user);
$this->Redirect('Secure.UserPage');
} else {
// login failed
$this->Redirect('Secure.LoginForm', 'Usuario e senha invalidos.');
}
}
示例10: index
public function index($limit = '')
{
// 获得查询参数, 查询参数都为like模糊查询
$where = RequestUtil::buildLikeQueryParamsWithDisabled();
$this->db->select('*');
$orders = (new CurdUtil($this->offlineOrderModel))->readLimit($where, $limit, 'offline_order_id desc');
$ordersCount = (new CurdUtil($this->offlineOrderModel))->count($where);
$pages = (new PaginationUtil($ordersCount))->pagination();
$shops = (new ShopModel())->getAllShops();
$beauticians = (new BeauticianModel())->getAllFormatBeauticians();
$this->view('offline/order', array('orders' => $orders, 'pages' => $pages, 'beauticians' => $beauticians, 'params' => RequestUtil::getParams(), 'shops' => $shops, 'limit' => $limit));
}
示例11: index
public function index($limit = '')
{
// 获得查询参数, 查询参数都为like模糊查询
$where = RequestUtil::buildLikeQueryParamsWithDisabled();
$this->db->select('*');
$customers = (new CurdUtil($this->customerModel))->readLimit($where, $limit, 'customer_id desc');
$customersCount = (new CurdUtil($this->customerModel))->count($where);
$pages = (new PaginationUtil($customersCount))->pagination();
// 用户的性别,值为1时是男性,值为2时是女性,值为0时是未知
$sex = array('未知', '男', '女');
$this->view('customer/index', array('customers' => $customers, 'pages' => $pages, 'params' => RequestUtil::getParams(), 'limit' => $limit, 'sex' => $sex));
}
示例12: addForNewUserProject
/**
* 增加新用户专享
*/
public function addForNewUserProject()
{
if (RequestUtil::isPost()) {
$params = RequestUtil::postParams();
$insertId = (new CurdUtil($this->projectPropertyModel))->create($params);
if ($insertId) {
$this->message('新增成功!', 'ProjectProperty/projectForNewUserList');
} else {
$this->message('新增失败!');
}
}
$categories = (new CategoryModel())->getAllCategories();
$this->view('projectProperty/forNewUser', array('categories' => $categories));
}
示例13: testDisallowed
static function testDisallowed($url, $expectedExceptionMessage)
{
$curl = RequestUtil::mkCurl("test-ssl", $url);
$curl->set(CURLOPT_RETURNTRANSFER, true);
try {
$curl->exec();
} catch (Exception_NetworkIO $ex) {
if (strpos($ex->getMessage(), $expectedExceptionMessage) == 0) {
return true;
} else {
throw $ex;
}
}
return false;
}
示例14: addArticle
public function addArticle()
{
if (RequestUtil::isPost()) {
if ($this->articleModel->rules()->run()) {
$params = RequestUtil::postParams();
$insertId = (new CurdUtil($this->articleModel))->create(array_merge($params, array('create_time' => DateUtil::now())));
if ($insertId) {
$this->message('新增文章成功!', 'article/index');
} else {
$this->message('新增文章失败!', 'article/index');
}
}
}
$this->view('article/addArticle');
}
示例15: addShop
/**
* 添加店铺
*/
public function addShop()
{
if (RequestUtil::isPost()) {
if ($this->shopModel->rules()->run()) {
$params = RequestUtil::postParams();
$params['shop_logo'] = UploadUtil::commonUpload(array('upload/resize_200x200', 'upload/resize_100x100'));
$insertId = (new CurdUtil($this->shopModel))->create(array_merge($params, array('create_time' => DateUtil::now())));
if ($insertId) {
$this->message('新增店铺成功!', 'shop/index');
} else {
$this->message('新增店铺失败!', 'shop/index');
}
}
}
$this->view('shop/addShop');
}