本文整理汇总了PHP中waRequest::getMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP waRequest::getMethod方法的具体用法?PHP waRequest::getMethod怎么用?PHP waRequest::getMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waRequest
的用法示例。
在下文中一共展示了waRequest::getMethod方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$id = (int) waRequest::get('id', waRequest::TYPE_INT);
$action = waRequest::get('a');
if (waRequest::getMethod() != 'post') {
throw new waException('Send something via POST to confirm operation.');
}
$admin = 2 <= $this->getUser()->getRights(wa()->getApp(), 'backend');
if (!$admin && ($action != 'passwd' || $this->getUser()->getId() != $id)) {
throw new waRightsException('Access denied.');
}
switch ($action) {
case 'delete':
$this->deleteUser($id);
return;
case 'passwd':
$r = $this->userPassword($id);
if ($r) {
$this->response = $r;
}
return;
case 'create_login':
$r = $this->createLogin($id);
if ($r) {
$this->response = $r;
}
return;
case 'create_credentials':
$r = $this->createCredentials($id);
if ($r) {
$this->response = $r;
}
return;
}
}
示例2: execute
public function execute()
{
$this->settings = $this->getConfig()->getOption(null);
if (waRequest::getMethod() == 'post') {
$this->save($this->settings);
$this->view->assign('saved', 1);
}
$this->settings['image_sizes'] = array('system' => $this->formatSizes($this->getConfig()->getImageSizes('system')), 'custom' => $this->formatSizes((array) $this->settings['image_sizes']));
$this->view->assign('settings', $this->settings);
}
示例3: execute
public function execute()
{
$settings = $this->getConfig()->getOption(null);
if (waRequest::getMethod() == 'post') {
$this->save($settings);
$this->view->assign('saved', 1);
}
$settings['sizes'] = array('system' => $this->formatSizes($this->getConfig()->getSizes('system')), 'custom' => $this->formatSizes($settings['sizes']));
$this->view->assign('settings', $settings);
$this->view->assign('sidebar_width', $this->getConfig()->getSidebarWidth());
}
示例4: execute
public function execute()
{
$settings = $this->getConfig()->getOption(null);
if (waRequest::getMethod() == 'post') {
$this->save($settings);
$this->view->assign('saved', 1);
}
$settings['sizes'] = array('system' => $this->formatSizes($this->getConfig()->getSizes('system')), 'custom' => $this->formatSizes($settings['sizes']));
$settings += array('sharpen' => null, 'max_size' => 970, 'enable_2x' => null, 'save_quality' => null, 'save_original' => null, 'save_quality_2x' => null, 'thumbs_on_demand' => null);
$this->view->assign('settings', $settings);
$this->view->assign('sidebar_width', $this->getConfig()->getSidebarWidth());
}
示例5: execute
public function execute()
{
if (waRequest::getMethod() != 'post') {
return;
} else {
$request_id = waRequest::post('id');
$request_id = preg_replace("/[^0-9]/", "", $request_id);
$contact_id = wa()->getUser()->getId();
$model = new helpdeskFavoritesPluginModel();
$values = array('contact_id' => $contact_id, 'request_id' => $request_id);
$state = (int) waRequest::post('favorite');
if ($request_id && $state) {
//пока без UNIQUE можно смело вставлять
//Удаление все снесёт
$message = $model->insert($values);
} else {
$message = $model->deleteByField($values);
}
$this->view->assign('data', $message);
}
}
示例6: _auth
/**
* @param $params
* @return array|bool
* @throws waException
*/
protected function _auth($params)
{
if ($params && isset($params['id'])) {
$contact_model = new waContactModel();
$user_info = $contact_model->getById($params['id']);
if ($user_info && ($user_info['is_user'] > 0 || !$this->options['is_user'])) {
waSystem::getInstance()->getResponse()->setCookie('auth_token', null, -1);
return $this->getAuthData($user_info);
}
return false;
} elseif ($params && isset($params['login']) && isset($params['password'])) {
$login = $params['login'];
$password = $params['password'];
} elseif (waRequest::getMethod() == 'post' && waRequest::post('wa_auth_login')) {
$login = waRequest::post('login');
$password = waRequest::post('password');
if (!strlen($login)) {
throw new waException(_ws('Login is required'));
}
} else {
$login = null;
}
if ($login && strlen($login)) {
$user_info = $this->getByLogin($login);
if ($user_info && ($user_info['is_user'] > 0 || !$this->options['is_user']) && waContact::getPasswordHash($password) === $user_info['password']) {
$auth_config = wa()->getAuthConfig();
if (wa()->getEnv() == 'frontend' && !empty($auth_config['params']['confirm_email'])) {
$contact_emails_model = new waContactEmailsModel();
$email_row = $contact_emails_model->getByField(array('contact_id' => $user_info['id'], 'sort' => 0));
if ($email_row && $email_row['status'] == 'unconfirmed') {
$login_url = wa()->getRouteUrl((isset($auth_config['app']) ? $auth_config['app'] : '') . '/login', array());
$html = sprintf(_ws('A confirmation link has been sent to your email address provided during the signup. Please click this link to confirm your email and to sign in. <a class="send-email-confirmation" href="%s">Resend the link</a>'), $login_url . '?send_confirmation=1');
$html = '<div class="block-confirmation-email">' . $html . '</div>';
$html .= <<<HTML
<script type="text/javascript">
\$(function () {
\$('a.send-email-confirmation').click(function () {
\$.post(\$(this).attr('href'), {
login: \$(this).closest('form').find("input[name='login']").val()
}, function (response) {
\$('.block-confirmation-email').html(response);
});
return false;
});
});
</script>
HTML;
throw new waException($html);
}
}
$response = waSystem::getInstance()->getResponse();
// if remember
if (waRequest::post('remember')) {
$cookie_domain = ifset($this->options['cookie_domain'], '');
$response->setCookie('auth_token', $this->getToken($user_info), time() + 2592000, null, $cookie_domain, false, true);
$response->setCookie('remember', 1);
} else {
$response->setCookie('remember', 0);
}
// return array with compact user info
return $this->getAuthData($user_info);
} else {
if ($this->options['login'] == 'email') {
throw new waException(_ws('Invalid email or password'));
} else {
throw new waException(_ws('Invalid login or password'));
}
}
} else {
// try auth by cookie
return $this->_authByCookie();
}
}
示例7: execute
public function execute()
{
$contact_model = new waContactModel();
if ($contact_model->countAll()) {
$this->redirect($this->getConfig()->getBackendUrl(true));
}
if (($locale = waRequest::get('lang')) && waLocale::getInfo($locale)) {
// set locale
wa()->setLocale($locale);
// save to database default locale
$app_settings_model = new waAppSettingsModel();
$app_settings_model->set('webasyst', 'locale', $locale);
}
if (file_exists($this->getConfig()->getRootPath() . '/install.php')) {
@unlink($this->getConfig()->getRootPath() . '/install.php');
}
if (waRequest::getMethod() == 'post') {
$errors = array();
$login = waRequest::post('login');
$validator = new waLoginValidator();
if (!$validator->isValid($login)) {
$errors['login'] = implode("<br />", $validator->getErrors());
}
$password = waRequest::post('password');
$password_confirm = waRequest::post('password_confirm');
if ($password !== $password_confirm) {
$errors['password'] = _w('Passwords do not match');
}
$email = waRequest::post('email');
$validator = new waEmailValidator();
if (!$validator->isValid($email)) {
$errors['email'] = implode("<br />", $validator->getErrors());
}
if ($errors) {
$this->view->assign('errors', $errors);
} else {
// save account name
$app_settings_model = new waAppSettingsModel();
$app_settings_model->set('webasyst', 'name', waRequest::post('account_name'));
if ($email) {
$app_settings_model->set('webasyst', 'email', $email);
$app_settings_model->set('webasyst', 'sender', $email);
}
// create user
$user = new waUser();
$firstname = waRequest::post('firstname');
$user['firstname'] = $firstname ? $firstname : $login;
$user['lastname'] = waRequest::post('lastname');
$user['is_user'] = 1;
$user['login'] = $login;
$user['password'] = $password;
$user['email'] = $email;
$user['locale'] = wa()->getLocale();
$user['create_method'] = 'install';
if ($errors = $user->save()) {
$result = array();
foreach ($errors as $k => $v) {
$result['all'][] = $k . ": " . (is_array($v) ? implode(', ', $v) : $v);
}
$result['all'] = implode("\r\n", $result['all']);
$this->view->assign('errors', $result);
} else {
$user->setRight('webasyst', 'backend', 1);
waSystem::getInstance()->getAuth()->auth(array('login' => $login, 'password' => $password));
$path = $this->getConfig()->getPath('config');
// check routing.php
if (!file_exists($path . '/routing.php')) {
$apps = wa()->getApps();
$data = array();
$domain = $this->getConfig()->getDomain();
$site = false;
foreach ($apps as $app_id => $app) {
if ($app_id == 'site') {
$site = true;
} elseif (!empty($app['frontend'])) {
$routing = array('url' => $app_id . '/*', 'app' => $app_id);
if (!empty($app['routing_params']) && is_array($app['routing_params'])) {
$routing = array_merge($routing, $app['routing_params']);
}
$data[$domain][] = $routing;
}
}
if ($site) {
$data[$domain][] = array('url' => '*', 'app' => 'site');
}
waUtils::varExportToFile($data, $path . '/routing.php');
}
// redirect to backend
$this->redirect($this->getConfig()->getBackendUrl(true));
}
}
}
}
示例8: _auth
protected function _auth($params)
{
if ($params && isset($params['id'])) {
$contact_model = new waContactModel();
$user_info = $contact_model->getById($params['id']);
if ($user_info && ($user_info['is_user'] || !$this->options['is_user'])) {
waSystem::getInstance()->getResponse()->setCookie('auth_token', null, -1);
return $this->getAuthData($user_info);
}
return false;
} elseif ($params && isset($params['login']) && isset($params['password'])) {
$login = $params['login'];
$password = $params['password'];
} elseif (waRequest::getMethod() == 'post' && waRequest::post('wa_auth_login')) {
$login = waRequest::post('login');
$password = waRequest::post('password');
if (!strlen($login)) {
throw new waException(_ws('Login is required'));
}
} else {
$login = null;
}
if ($login && strlen($login)) {
$user_info = $this->getByLogin($login);
if ($user_info && ($user_info['is_user'] || !$this->options['is_user']) && waContact::getPasswordHash($password) === $user_info['password']) {
$response = waSystem::getInstance()->getResponse();
// if remember
if (waRequest::post('remember')) {
$response->setCookie('auth_token', $this->getToken($user_info), time() + 2592000, null, '', false, true);
$response->setCookie('remember', 1);
} else {
$response->setCookie('remember', 0);
}
// return array with compact user info
return $this->getAuthData($user_info);
} else {
if ($this->options['login'] == 'email') {
throw new waException(_ws('Invalid email or password'));
} else {
throw new waException(_ws('Invalid login or password'));
}
}
} else {
// try auth by cookie
return $this->_authByCookie();
}
}