本文整理汇总了PHP中waRequest::method方法的典型用法代码示例。如果您正苦于以下问题:PHP waRequest::method方法的具体用法?PHP waRequest::method怎么用?PHP waRequest::method使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waRequest
的用法示例。
在下文中一共展示了waRequest::method方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
// Creating a model instance for retriving data from the database
// Создаем экземпляр модели для получения данных из БД
$model = new guestbookModel();
// If a POST request is received then a new record is added to the database
// Если пришёл POST-запрос, то нужно записать в БД новую запись
if (waRequest::method() == 'post') {
// Retrieving data from the POST request
// Получаем данные из POST
$name = waRequest::post('name');
$text = waRequest::post('text');
if ($name && $text) {
// Inserting a new record into the table
// Вставляем новую запись в таблицу
$model->insert(array('name' => $name, 'text' => $text, 'datetime' => date('Y-m-d H:i:s')));
}
$this->redirect();
}
// Retrieving guestbook records from the database
// Получаем записи гостевой книги из БД
$records = $model->order('datetime DESC')->fetchAll();
// Passing records to the template
// Передаем записи в шаблон
$this->view->assign('records', $records);
}
示例2: execute
public function execute()
{
if (wa()->getAuth()->isAuth()) {
$this->redirect(wa()->getAppUrl());
}
// check auth config
$auth = wa()->getAuthConfig();
if (!isset($auth['auth']) || !$auth['auth']) {
throw new waException(_ws('Page not found'), 404);
}
// check auth app and url
$signup_url = wa()->getRouteUrl((isset($auth['app']) ? $auth['app'] : '') . '/signup');
if (wa()->getConfig()->getRequestUrl(false) != $signup_url) {
$this->redirect($signup_url);
}
$errors = array();
if (waRequest::method() == 'post') {
// try sign up
if ($contact = $this->signup(waRequest::post('data'), $errors)) {
// assign new contact to view
$this->view->assign('contact', $contact);
}
}
$this->view->assign('errors', $errors);
wa()->getResponse()->setTitle(_ws('Sign up'));
}
示例3: execute
public function execute()
{
if (wa()->getAuth()->isAuth()) {
$this->afterAuth();
}
// check XMLHttpRequest (ajax)
$this->checkXMLHttpRequest();
if (wa()->getEnv() == 'frontend') {
$this->checkAuthConfig();
}
$auth = wa()->getAuth();
// check remember enabled
if (waRequest::method() == 'get') {
$this->view->assign('remember', waRequest::cookie('remember', 1));
}
$this->saveReferer();
$error = '';
// try auth
try {
if ($auth->auth()) {
$this->afterAuth();
}
} catch (waException $e) {
$error = $e->getMessage();
}
$this->view->assign('error', $error);
// assign auth options
$this->view->assign('options', $auth->getOptions());
wa()->getResponse()->setTitle(_ws('Log in'));
}
示例4: execute
public function execute()
{
// Setting the frontend layout
// Задаём лайаут для фронтенда
$this->setLayout(new guestbook2FrontendLayout());
// Setting the theme template
// Задаём шаблон темы
$this->setThemeTemplate('guestbook.html');
// if a POST request has been received then write a new record to the database
// Если пришёл POST-запрос, то нужно записать в БД новую запись
if (waRequest::method() == 'post') {
$this->add();
}
// Creating a model instance for retrieving data from the database
// Создаем экземпляр модели для получения данных из БД
$model = new guestbook2Model();
// Retrieving the record count per page from the app's settings
// Получаем количество записей на одной странице из настроек приложения
$limit = $this->getConfig()->getOption('records_per_page');
// Current page
// Текущая страница
$page = waRequest::param('page');
if (!$page) {
$page = 1;
}
$this->view->assign('page', $page);
// Calculating offset
// Вычисляем смещение
$offset = ($page - 1) * $limit;
// Retrieving all records from the database
// Получаем записи гостевой книги из БД
$records = $model->getRecords($offset, $limit);
// Total record count
// Всего записей
$records_count = $model->countAll();
$pages_count = ceil($records_count / $limit);
$this->view->assign('pages_count', $pages_count);
// Preparing records for being passed to the theme template
// Подготавливаем записи для передачи в шаблон темы
foreach ($records as &$r) {
if ($r['contact_id']) {
$r['name'] = htmlspecialchars($r['contact_name']);
// getting contact photo URL
// получаем URL на фотографию контакта
$r['photo_url'] = waContact::getPhotoUrl($r['contact_id'], $r['photo'], 20);
} else {
$r['name'] = htmlspecialchars($r['name']);
}
$r['text'] = nl2br(htmlspecialchars($r['text']));
}
unset($r);
// Passing records to the template
// Передаем записи в шаблон
$this->view->assign('records', $records);
// URL portion for links to pages
// Часть урла для ссылок на страницы
$this->view->assign('url', wa()->getRouteUrl('/frontend'));
}
示例5: updateLastPage
public function updateLastPage()
{
if (waRequest::isXMLHttpRequest() || !$this->id || wa()->getEnv() !== 'backend' || waRequest::method() == 'post') {
return;
}
$page = wa()->getRequest()->server('REQUEST_URI');
$backend = wa()->getConfig()->getBackendUrl(true);
if ($page === $backend || substr($page, 0, strlen($backend) + 1) === $backend . '?') {
return;
}
wa()->getResponse()->setCookie('last_page', $this->getId() . '^^^' . $page, null, null, '', false, true);
}
示例6: getResponse
public function getResponse($internal = false)
{
if (!$internal) {
// check request method
$request_method = strtoupper(waRequest::method());
if (is_array($this->method) && !in_array($request_method, $this->method) || !is_array($this->method) && $request_method != $this->method) {
throw new waAPIException('invalid_request', 'Method ' . $request_method . ' not allowed', 405);
}
}
$this->execute();
return $this->response;
}
示例7: execute
public function execute()
{
$cart = new shopCart();
$total = $cart->total();
$shipping = new shopCheckoutShipping();
$items = $shipping->getItems();
if (waRequest::method() == 'post') {
wa()->getStorage()->close();
$shipping_id = waRequest::post('shipping_id');
$customer = waRequest::post('customer_' . $shipping_id);
if (isset($customer['address.shipping'])) {
$address = $customer['address.shipping'];
} else {
$address = array();
}
if ($shipping_id) {
$this->response = $this->getRates($shipping_id, $items, $address, $total);
} else {
$this->errors = _w('Shipping is required');
}
} elseif ($shipping_ids = waRequest::get('shipping_id', array(), waRequest::TYPE_ARRAY_INT)) {
$address = $shipping->getAddress();
wa()->getStorage()->close();
$empty = true;
foreach ($address as $v) {
if ($v) {
$empty = false;
break;
}
}
if ($empty) {
$address = array();
}
if (!$address) {
$settings = wa('shop')->getConfig()->getCheckoutSettings();
if ($settings['contactinfo']['fields']['address']) {
foreach ($settings['contactinfo']['fields']['address']['fields'] as $k => $f) {
if (!empty($f['value'])) {
$address[$k] = $f['value'];
}
}
}
}
foreach ($shipping_ids as $shipping_id) {
$this->response[$shipping_id] = $this->getRates($shipping_id, $items, $address, $total);
}
}
}
示例8: execute
public function execute()
{
if (!waRequest::isMobile()) {
$this->setLayout(new webasystLoginLayout());
}
$this->response_type = waRequest::get('response_type');
$this->client_id = waRequest::get('client_id');
$this->client_name = waRequest::get('client_name');
if ($this->response_type === 'token') {
$this->required_fields['redirect_uri'] = true;
}
if (!$this->checkRequest()) {
$this->template = 'ApiError';
return;
}
$this->contact_id = $this->getUser()->getId();
if (waRequest::method() == 'post') {
if (waRequest::post('approve')) {
$this->approve();
} else {
$this->deny();
}
} else {
$tokens_model = new waApiTokensModel();
$token = $tokens_model->getByField(array('contact_id' => $this->contact_id, 'client_id' => $this->client_id));
// if token exists then create auth code and redirect to redirect_uri
if ($token) {
$this->approve();
}
}
$this->view->assign('client_name', $this->client_name, true);
$scope = explode(',', waRequest::get('scope'));
$apps = array();
foreach ($scope as $app_id) {
if (wa()->appExists($app_id)) {
$apps[] = wa()->getAppInfo($app_id);
}
}
$this->view->assign('scope', $apps);
}
示例9: execute
public function execute()
{
$confirm_hash = waRequest::get('confirm', false);
if (wa()->getAuth()->isAuth() && !$confirm_hash) {
$this->redirect(wa()->getAppUrl());
}
// check auth config
$auth = wa()->getAuthConfig();
if (!isset($auth['auth']) || !$auth['auth']) {
throw new waException(_ws('Page not found'), 404);
}
// check auth app and url
$signup_url = wa()->getRouteUrl((isset($auth['app']) ? $auth['app'] : '') . '/signup');
if (urldecode(wa()->getConfig()->getRequestUrl(false, true)) != $signup_url) {
$this->redirect($signup_url);
}
$errors = array();
if (waRequest::method() == 'post') {
// try sign up
if ($contact = $this->signup(waRequest::post('data'), $errors)) {
// assign new contact to view
$this->view->assign('contact', $contact);
}
} elseif ($confirm_hash) {
if ($contact = $this->confirmEmail($confirm_hash, $errors)) {
// if we successfully confirmed email
// assign contact with confirmed email to view
$this->view->assign('contact', $contact);
$this->view->assign('confirmed_email', true);
} else {
// else email is already confirmed or smth else happend
if (wa()->getAuth()->isAuth()) {
// redirect to main page
$this->redirect(wa()->getAppUrl());
}
}
}
$this->view->assign('errors', $errors);
wa()->getResponse()->setTitle(_ws('Sign up'));
}
示例10: init
public function init()
{
$files = array($this->getAppPath() . '/lib/config/config.php', $this->getPath('config') . '/apps/' . $this->application . '/config.php');
foreach ($files as $file_path) {
if (file_exists($file_path)) {
$config = (include $file_path);
if ($config && is_array($config)) {
foreach ($config as $name => $value) {
$this->options[$name] = $value;
}
}
}
}
$this->info = (include $this->getAppPath() . '/lib/config/app.php');
if ($this->environment == 'backend' && !empty($this->info['csrf']) && waRequest::method() == 'post') {
if (waRequest::post('_csrf') != waRequest::cookie('_csrf')) {
throw new waException('CSRF Protection', 403);
}
}
waAutoload::getInstance()->add($this->getClasses());
if (file_exists($this->getAppPath() . '/lib/config/factories.php')) {
$this->factories = (include $this->getAppPath() . '/lib/config/factories.php');
}
if (!empty($this->options['factories']) && is_array($this->options['factories'])) {
foreach ($this->options['factories'] as $k => $v) {
$this->factories[$k] = $v;
}
}
}
示例11: themeUpdateAction
public function themeUpdateAction()
{
$theme_id = waRequest::get('theme');
$theme = new waTheme($theme_id);
if (waRequest::method() == 'post') {
if (!waRequest::post("parent_only")) {
if (waRequest::post('reset')) {
foreach (waRequest::post('reset') as $f) {
$theme->revertFile($f);
}
}
$theme->update(false);
}
if ($theme->parent_theme && $theme->parent_theme->type == waTheme::OVERRIDDEN) {
if (waRequest::post('parent_reset')) {
foreach (waRequest::post('parent_reset') as $f) {
$theme->parent_theme->revertFile($f);
}
}
$theme->parent_theme->update(false);
}
$this->displayJson(array());
} else {
$theme_original = new waTheme($theme_id, true, 'original');
$data = array('theme' => $theme, 'theme_original_version' => $theme_original->version);
if ($theme->parent_theme && $theme->version == $theme_original->version && $theme->parent_theme->type == waTheme::OVERRIDDEN) {
$parent_theme_original = new waTheme($theme->parent_theme->id, $theme->parent_theme->app, 'original');
$data['theme_original_version'] = $parent_theme_original->version;
$data['parent_only'] = true;
}
$this->display($data, $this->getConfig()->getRootPath() . '/wa-system/design/templates/ThemeUpdate.html');
}
}
示例12: forgotPassword
protected function forgotPassword()
{
$error = '';
$auth = wa()->getAuth();
if (waRequest::method() == 'post' && !waRequest::post('ignore')) {
if ($contact = $this->findContact(waRequest::post('login'), $auth)) {
if ($contact->get('is_banned')) {
$error = _ws('Password recovery for this email has been banned.');
} elseif ($email = $contact->get('email', 'default')) {
if ($contact['locale']) {
wa()->setLocale($contact['locale']);
waLocale::loadByDomain('webasyst', wa()->getLocale());
}
$hash = $this->getHash($contact['id'], true);
if ($this->send($email, $this->getResetPasswordUrl($hash))) {
$this->view->assign('sent', 1);
} else {
$error = _ws('Sorry, we can not recover password for this login name or email. Please refer to your system administrator.');
}
}
} else {
if ($auth->getOption('login') == 'email') {
$error = _ws('No user with this email has been found.');
} else {
$error = _ws('No user with this login name or email has been found.');
}
}
}
$this->view->assign('options', $auth->getOptions());
$this->view->assign('error', $error);
if ($this->layout) {
$this->layout->assign('error', $error);
}
wa()->getResponse()->setTitle(_ws('Password recovery'));
}
示例13: checkout
public function checkout($templates)
{
$view = wa()->getView();
$steps = wa()->getConfig()->getCheckoutSettings();
$cart = new shopCart();
if (!$cart->count()) {
return false;
}
if (waRequest::method() == 'post') {
if (waRequest::post('wa_auth_login')) {
$login_action = new shopLoginAction();
$login_action->run();
} else {
$error = false;
foreach ($steps as $step_id => $step) {
$step_instance = self::getStep($step_id);
if (!$step_instance->execute()) {
$error = true;
}
}
if (waRequest::post('confirmation') && !$error && !self::checkCart()) {
if (self::createOrder()) {
wa()->getResponse()->redirect(wa()->getRouteUrl('/frontend/checkout', array('step' => 'success')));
}
}
}
}
$checkout_tpls = array();
foreach ($steps as $step_id => $step) {
$step = self::getStep($step_id);
$step->initDefault();
$steps[$step_id]['content'] = $step->display();
/**
* @event frontend_checkout
* @return array[string]string $return[%plugin_id%] html output
*/
$event_params = array('step' => $step_id);
$view->assign('frontend_checkout', wa()->event('frontend_checkout', $event_params));
$step_tpl_path = $templates['checkout.' . $step_id]['template_path'];
$step_tpl = $view->fetch($step_tpl_path);
$checkout_tpls[$step_id] = $step_tpl;
}
$view->assign('checkout_tpls', $checkout_tpls);
$view->assign('checkout_steps', $steps);
}
示例14: execute
public function execute()
{
$this->getResponse()->addHeader("Cache-Control", "no-store, no-cache, must-revalidate");
$this->getResponse()->addHeader("Expires", date("r"));
if (waRequest::method() == 'post') {
$data = wa()->getStorage()->get('shop/checkout', array());
if ($coupon_code = waRequest::post('coupon_code')) {
$data['coupon_code'] = $coupon_code;
} elseif (isset($data['coupon_code'])) {
unset($data['coupon_code']);
}
if (($use = waRequest::post('use_affiliate')) !== null) {
if ($use) {
$data['use_affiliate'] = 1;
} elseif (isset($data['use_affiliate'])) {
unset($data['use_affiliate']);
}
}
if ($coupon_code || $use) {
wa()->getStorage()->set('shop/checkout', $data);
wa()->getStorage()->remove('shop/cart');
}
}
$cart_model = new shopCartItemsModel();
$cart = new shopCart();
$code = $cart->getCode();
$errors = array();
if (waRequest::post('checkout')) {
$saved_quantity = $cart_model->select('id,quantity')->where("type='product' AND code = s:code", array('code' => $code))->fetchAll('id');
$quantity = waRequest::post('quantity');
foreach ($quantity as $id => $q) {
if ($q != $saved_quantity[$id]) {
$cart->setQuantity($id, $q);
}
}
$not_available_items = $cart_model->getNotAvailableProducts($code, !wa()->getSetting('ignore_stock_count'));
foreach ($not_available_items as $row) {
if ($row['sku_name']) {
$row['name'] .= ' (' . $row['sku_name'] . ')';
}
if ($row['available']) {
$errors[$row['id']] = sprintf(_w('Only %d pcs of %s are available, and you already have all of them in your shopping cart.'), $row['count'], $row['name']);
} else {
$errors[$row['id']] = _w('Oops! %s is not available for purchase at the moment. Please remove this product from your shopping cart to proceed.');
}
}
if (!$errors) {
$this->redirect(wa()->getRouteUrl('/frontend/checkout'));
}
}
$this->setThemeTemplate('cart.html');
$items = $cart_model->where('code= ?', $code)->order('parent_id')->fetchAll('id');
$product_ids = $sku_ids = $service_ids = $type_ids = array();
foreach ($items as $item) {
$product_ids[] = $item['product_id'];
$sku_ids[] = $item['sku_id'];
}
$product_ids = array_unique($product_ids);
$sku_ids = array_unique($sku_ids);
$product_model = new shopProductModel();
if (waRequest::param('url_type') == 2) {
$products = $product_model->getWithCategoryUrl($product_ids);
} else {
$products = $product_model->getById($product_ids);
}
$sku_model = new shopProductSkusModel();
$skus = $sku_model->getByField('id', $sku_ids, 'id');
$image_model = new shopProductImagesModel();
$delete_items = array();
foreach ($items as $item_id => &$item) {
if (!isset($skus[$item['sku_id']])) {
unset($items[$item_id]);
$delete_items[] = $item_id;
continue;
}
if ($item['type'] == 'product') {
$item['product'] = $products[$item['product_id']];
$sku = $skus[$item['sku_id']];
if ($sku['image_id'] && $sku['image_id'] != $item['product']['image_id']) {
$img = $image_model->getById($sku['image_id']);
if ($img) {
$item['product']['image_id'] = $sku['image_id'];
$item['product']['ext'] = $img['ext'];
}
}
$item['sku_name'] = $sku['name'];
$item['sku_code'] = $sku['sku'];
$item['price'] = $sku['price'];
$item['compare_price'] = $sku['compare_price'];
$item['currency'] = $item['product']['currency'];
$type_ids[] = $item['product']['type_id'];
if (isset($errors[$item_id])) {
$item['error'] = $errors[$item_id];
if (strpos($item['error'], '%s') !== false) {
$item['error'] = sprintf($item['error'], $item['product']['name'] . ($item['sku_name'] ? ' (' . $item['sku_name'] . ')' : ''));
}
}
}
}
unset($item);
//.........这里部分代码省略.........
示例15: dispatch
//.........这里部分代码省略.........
} else {
throw new waException("Page not found", 404);
}
} elseif (!strncmp($this->config->getRequestUrl(true), 'oauth.php', 9)) {
$app_id = $this->getStorage()->get('auth_app');
if ($app_id && !$this->appExists($app_id)) {
throw new waException("Page not found", 404);
}
$app_system = self::getInstance($app_id);
if (class_exists($app_id . 'OAuthController')) {
$app_system->getFrontController()->execute(null, 'OAuth');
} else {
wa('webasyst')->getFrontController()->execute(null, 'OAuth');
}
} elseif (!strncmp($this->config->getRequestUrl(true), 'payments.php/', 13)) {
$url = substr($this->config->getRequestUrl(true), 13);
waRequest::setParam('module_id', strtok($url, '/?'));
$webasyst_system = self::getInstance('webasyst');
$webasyst_system->getFrontController()->execute(null, 'payments', null, true);
} elseif ($this->getEnv() == 'backend' && !$this->getUser()->isAuth()) {
$webasyst_system = self::getInstance('webasyst', null, true);
$webasyst_system->getFrontController()->execute(null, 'login', waRequest::get('action'), true);
} elseif ($this->config instanceof waAppConfig) {
if ($this->getEnv() == 'backend' && !$this->getUser()->getRights($this->getConfig()->getApplication(), 'backend')) {
header("Location: " . $this->getConfig()->getBackendUrl(true));
exit;
}
$this->getFrontController()->dispatch();
} else {
$app = null;
$route = null;
if ($this->getEnv() == 'frontend') {
// logout
if (null !== ($logout_url = waRequest::get('logout'))) {
// for getting app
$this->getRouting()->dispatch();
$app = waRequest::param('app');
// For logging logout action
$data = array('app_id' => $app, 'contact_id' => $this->getUser()->getId(), 'datetime' => date("Y-m-d H:i:s"), 'action' => 'logout', 'params' => $this->getEnv());
// logout itself
$this->getUser()->logout();
if (!$logout_url) {
$logout_url = $this->config->getRequestUrl(false, true);
}
// logging logout
if (!class_exists('waLogModel')) {
wa('webasyst');
}
$log_model = new waLogModel();
$log_model->insert($data);
// make redirect after logout
$this->getResponse()->redirect($logout_url);
}
if (!$this->getRouting()->dispatch()) {
$this->getResponse()->redirect($this->getConfig()->getBackendUrl(true), 302);
}
$app = waRequest::param('app');
} else {
self::getInstance('webasyst');
$path = $this->getConfig()->getRequestUrl(true);
if (($i = strpos($path, '?')) !== false) {
$path = substr($path, 0, $i);
}
$url = explode("/", $path);
$app = isset($url[1]) && $url[1] != 'index.php' ? $url[1] : 'webasyst';
}
if (!$app) {
$app = 'webasyst';
}
$app_system = self::getInstance($app, null, true);
if ($app != 'webasyst' && $this->getEnv() == 'backend' && !$this->getUser()->getRights($app_system->getConfig()->getApplication(), 'backend')) {
//$this->getResponse()->redirect($this->getConfig()->getBackendUrl(true), 302);
throw new waRightsException('Access to this app denied', 403);
}
if ((waRequest::param('secure') || waRequest::param('auth')) && !$this->getUser()->isAuth()) {
$auth = $this->getAuthConfig();
if (!empty($auth['app'])) {
$app_system = self::getInstance($auth['app'], null, true);
}
$app_system->login();
} else {
if (waRequest::param('secure') && $app_system->getConfig()->getInfo('csrf') && waRequest::method() == 'post' && waRequest::post('_csrf') != waRequest::cookie('_csrf')) {
throw new waException('CSRF Protection', 403);
}
$app_system->getFrontController()->dispatch();
}
}
} catch (waApiException $e) {
print $e;
} catch (waException $e) {
print $e;
} catch (Exception $e) {
if (waSystemConfig::isDebug()) {
print $e;
} else {
$e = new waException($e->getMessage(), $e->getCode());
print $e;
}
}
}