本文整理汇总了PHP中waRequest::getUserAgent方法的典型用法代码示例。如果您正苦于以下问题:PHP waRequest::getUserAgent方法的具体用法?PHP waRequest::getUserAgent怎么用?PHP waRequest::getUserAgent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waRequest
的用法示例。
在下文中一共展示了waRequest::getUserAgent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createOrder
//.........这里部分代码省略.........
$order['params']['payment_params_' . $k] = $v;
}
unset($order['params']['payment']);
}
}
if ($skock_id = waRequest::post('stock_id')) {
$order['params']['stock_id'] = $skock_id;
}
$routing_url = wa()->getRouting()->getRootUrl();
$order['params']['storefront'] = wa()->getConfig()->getDomain() . ($routing_url ? '/' . $routing_url : '');
if ($ref = waRequest::cookie('referer')) {
$order['params']['referer'] = $ref;
$ref_parts = @parse_url($ref);
$order['params']['referer_host'] = $ref_parts['host'];
// try get search keywords
if (!empty($ref_parts['query'])) {
$search_engines = array('text' => 'yandex\\.|rambler\\.', 'q' => 'bing\\.com|mail\\.|google\\.', 's' => 'nigma\\.ru', 'p' => 'yahoo\\.com');
$q_var = false;
foreach ($search_engines as $q => $pattern) {
if (preg_match('/(' . $pattern . ')/si', $ref_parts['host'])) {
$q_var = $q;
break;
}
}
// default query var name
if (!$q_var) {
$q_var = 'q';
}
parse_str($ref_parts['query'], $query);
if (!empty($query[$q_var])) {
$order['params']['keyword'] = $query[$q_var];
}
}
}
if ($utm = waRequest::cookie('utm')) {
$utm = json_decode($utm, true);
if ($utm && is_array($utm)) {
foreach ($utm as $k => $v) {
$order['params']['utm_' . $k] = $v;
}
}
}
if (($landing = waRequest::cookie('landing')) && ($landing = @parse_url($landing))) {
if (!empty($landing['query'])) {
@parse_str($landing['query'], $arr);
if (!empty($arr['gclid']) && !empty($order['params']['referer_host']) && strpos($order['params']['referer_host'], 'google') !== false) {
$order['params']['referer_host'] .= ' (cpc)';
$order['params']['cpc'] = 1;
} else {
if (!empty($arr['_openstat']) && !empty($order['params']['referer_host']) && strpos($order['params']['referer_host'], 'yandex') !== false) {
$order['params']['referer_host'] .= ' (cpc)';
$order['params']['openstat'] = $arr['_openstat'];
$order['params']['cpc'] = 1;
}
}
}
$order['params']['landing'] = $landing['path'];
}
// A/B tests
/*
$abtest_variants_model = new shopAbtestVariantsModel();
foreach (waRequest::cookie() as $k => $v) {
if (substr($k, 0, 5) == 'waabt') {
$variant_id = $v;
$abtest_id = substr($k, 5);
if (wa_is_int($abtest_id) && wa_is_int($variant_id)) {
$row = $abtest_variants_model->getById($variant_id);
if ($row && $row['abtest_id'] == $abtest_id) {
$order['params']['abt' . $abtest_id] = $variant_id;
}
}
}
}
*/
$order['params']['ip'] = waRequest::getIp();
$order['params']['user_agent'] = waRequest::getUserAgent();
foreach (array('shipping', 'billing') as $ext) {
$address = $contact->getFirst('address.' . $ext);
if ($address) {
foreach ($address['data'] as $k => $v) {
$order['params'][$ext . '_address.' . $k] = $v;
}
}
}
if (isset($checkout_data['comment'])) {
$order['comment'] = $checkout_data['comment'];
}
$workflow = new shopWorkflow();
if ($order_id = $workflow->getActionById('create')->run($order)) {
$step_number = shopOnestepCheckout::getStepNumber();
$checkout_flow = new shopCheckoutFlowModel();
$checkout_flow->add(array('step' => $step_number));
$cart->clear();
wa()->getStorage()->remove('shop/checkout');
wa()->getStorage()->set('shop/order_id', $order_id);
return $order_id;
} else {
return false;
}
}
示例2: payment
/**
* Генерирует HTML-код формы оплаты.
*
* Платежная форма может отображаться во время оформления заказа или на странице просмотра ранее оформленного заказа.
* Значение атрибута "action" формы может содержать URL сервера платежной системы либо URL текущей страницы (т. е. быть пустым).
* Во втором случае отправленные пользователем платежные данные снова передаются в этот же метод для дальнейшей обработки, если это необходимо,
* например, для проверки, сохранения в базу данных, перенаправления на сайт платежной системы и т. д.
* @param array $payment_form_data Содержимое POST-запроса, полученное при отправке платежной формы
* (если в формы оплаты не указано значение атрибута "action")
* @param waOrder $order_data Объект, содержащий всю доступную информацию о заказе
* @param bool $auto_submit Флаг, обозначающий, должна ли платежная форма автоматически отправить данные без участия пользователя
* (удобно при оформлении заказа)
* @return string HTML-код платежной формы
* @throws waException
*/
public function payment($payment_form_data, $order_data, $auto_submit = false)
{
// заполняем обязательный элемент данных с описанием заказа
if (empty($order_data['description'])) {
$order_data['description'] = 'Заказ ' . $order_data['order_id'];
}
// вызываем класс-обертку, чтобы гарантировать использование данных в правильном формате
$order = waOrder::factory($order_data);
// добавляем в платежную форму поля, требуемые платежной системой WebMoney
$hidden_fields = array('LMI_MERCHANT_ID' => $this->LMI_MERCHANT_ID, 'LMI_PAYMENT_AMOUNT' => number_format($order->total, 2, '.', ''), 'LMI_CURRENCY' => strtoupper($order->currency), 'LMI_PAYMENT_NO' => $order_data['order_id'], 'LMI_PAYMENT_DESC' => $order->description, 'LMI_RESULT_URL' => $this->getRelayUrl(), 'wa_app' => $this->app_id, 'wa_merchant_contact_id' => $this->merchant_id);
if ($this->LMI_PAYEE_PURSE) {
$hidden_fields['LMI_PAYEE_PURSE'] = $this->LMI_PAYEE_PURSE;
}
if ($this->TESTMODE) {
$hidden_fields['LMI_SIM_MODE'] = $this->LMI_SIM_MODE;
}
if (!empty($order_data['customer_info']['email'])) {
$hidden_fields['LMI_PAYER_EMAIL'] = $order_data['customer_info']['email'];
}
$transaction_data = $this->formalizeData($hidden_fields);
// добавляем служебные URL:
// URL возврата покупателя после успешного завершения оплаты
$hidden_fields['LMI_SUCCESS_URL'] = $this->getAdapter()->getBackUrl(waAppPayment::URL_SUCCESS, $transaction_data);
// URL возврата покупателя после неудачной оплаты
$hidden_fields['LMI_FAILURE_URL'] = $this->getAdapter()->getBackUrl(waAppPayment::URL_FAIL, $transaction_data);
switch ($this->protocol) {
case self::PROTOCOL_PAYMASTER:
case self::PROTOCOL_WEBMONEY_LEGACY:
case self::PROTOCOL_PAYMASTER_COM:
case self::PROTOCOL_WEBMONEY_LEGACY_COM:
break;
case self::PROTOCOL_WEBMONEY:
default:
unset($hidden_fields['LMI_CURRENCY']);
if (strpos(waRequest::getUserAgent(), 'MSIE') !== false) {
$hidden_fields['LMI_PAYMENT_DESC'] = $order->description_en;
}
break;
}
$view = wa()->getView();
$view->assign('url', wa()->getRootUrl());
$view->assign('hidden_fields', $hidden_fields);
$view->assign('form_url', $this->getEndpointUrl());
$view->assign('form_options', $this->getFormOptions());
$view->assign('auto_submit', $auto_submit);
// для отображения платежной формы используем собственный шаблон
return $view->fetch($this->path . '/templates/payment.html');
}
示例3: signup
/**
* @param array $data
* @param array $errors
* @return bool|waContact
*/
public function signup($data, &$errors = array())
{
// check exists contacts
$auth = wa()->getAuth();
$field_id = $auth->getOption('login');
if ($field_id == 'login') {
$field_name = _ws('Login');
} else {
$field = waContactFields::get($field_id);
if ($field) {
$field_name = $field->getName();
} else {
$field_name = ucfirst($field_id);
}
}
$is_error = false;
// check passwords
if ($data['password'] !== $data['password_confirm']) {
$errors['password'] = array();
$errors['password_confirm'] = array(_ws('Passwords do not match'));
$is_error = true;
} elseif (!$data['password']) {
$errors['password'] = array();
$errors['password_confirm'][] = _ws('Password can not be empty.');
$is_error = true;
}
if (!$data[$field_id]) {
$errors[$field_id] = array(sprintf(_ws("%s is required"), $field_name));
$is_error = true;
}
if (!$is_error) {
$contact = $auth->getByLogin($data[$field_id]);
if ($contact) {
$errors[$field_id] = array(sprintf(_ws('User with the same %s is already registered'), $field_name));
$is_error = true;
}
}
$auth_config = wa()->getAuthConfig();
// set unknown or unconfirmed status for email
if (isset($data['email']) && $data['email']) {
if (!empty($auth_config['params']['confirm_email'])) {
$email_status = 'unconfirmed';
} else {
$email_status = 'unknown';
}
$data['email'] = array('value' => $data['email'], 'status' => $email_status);
}
// check captcha
if (isset($auth_config['signup_captcha']) && $auth_config['signup_captcha']) {
if (!wa()->getCaptcha()->isValid()) {
$errors['captcha'] = _ws('Invalid captcha');
$is_error = true;
}
}
if (is_array($auth_config['fields'])) {
foreach ($auth_config['fields'] as $fld_id => $fld) {
if (array_key_exists('required', $fld) && !$data[$fld_id] && $fld_id !== 'password') {
$field = waContactFields::get($fld_id);
if (!empty($fld['caption'])) {
$field_name = $fld['caption'];
} else {
if ($field) {
$field_name = $field->getName();
} else {
$field_name = ucfirst($fld_id);
}
}
$errors[$fld_id] = array(sprintf(_ws("%s is required"), $field_name));
$is_error = true;
}
}
}
if ($is_error) {
return false;
}
if (isset($data['birthday']) && is_array($data['birthday']['value'])) {
foreach ($data['birthday']['value'] as $bd_id => $bd_val) {
if (strlen($bd_val) === 0) {
$data['birthday']['value'][$bd_id] = null;
}
}
}
// remove password_confirm field
unset($data['password_confirm']);
// set advanced data
$data['create_method'] = 'signup';
$data['create_ip'] = waRequest::getIp();
$data['create_user_agent'] = waRequest::getUserAgent();
// try save contact
$contact = new waContact();
if (!($errors = $contact->save($data, true))) {
if (!empty($data['email'])) {
$this->send($contact);
}
/**
//.........这里部分代码省略.........
示例4: signup
/**
* @param array $data
* @param array $errors
* @return bool|waContact
*/
public function signup($data, &$errors = array())
{
// check exists contacts
$auth = wa()->getAuth();
$field_id = $auth->getOption('login');
if ($field_id == 'login') {
$field_name = _ws('Login');
} else {
$field = waContactFields::get($field_id);
if ($field) {
$field_name = $field->getName();
} else {
$field_name = ucfirst($field_id);
}
}
$is_error = false;
// check passwords
if ($data['password'] !== $data['password_confirm']) {
$errors['password'] = array();
$errors['password_confirm'] = array(_ws('Passwords do not match'));
$is_error = true;
} elseif (!$data['password']) {
$errors['password'] = array();
$errors['password_confirm'][] = _ws('Password can not be empty.');
$is_error = true;
}
if (!$data[$field_id]) {
$errors[$field_id] = array(sprintf(_ws("%s is required"), $field_name));
$is_error = true;
}
$contact = $auth->getByLogin($data[$field_id]);
if ($contact) {
$errors[$field_id] = array(sprintf(_ws('User with the same %s is already registered'), $field_name));
$is_error = true;
}
// set unconfirmed status for email
if (isset($data['email']) && $data['email']) {
$data['email'] = array('value' => $data['email'], 'status' => 'unconfirmed');
}
// check captcha
$auth_config = wa()->getAuthConfig();
if (isset($auth_config['signup_captcha']) && $auth_config['signup_captcha']) {
if (!wa()->getCaptcha()->isValid()) {
$errors['captcha'] = _ws('Invalid captcha');
$is_error = true;
}
}
if ($is_error) {
return false;
}
// remove password_confirm field
unset($data['password_confirm']);
// set advansed data
$data['create_method'] = 'signup';
$data['create_ip'] = waRequest::getIp();
$data['create_user_agent'] = waRequest::getUserAgent();
// try save contact
$contact = new waContact();
if (!($errors = $contact->save($data, true))) {
// after sign up callback
$this->afterSignup($contact);
// auth new contact
wa()->getAuth()->auth($contact);
return $contact;
}
if (isset($errors['name'])) {
$errors['firstname'] = array();
$errors['middlename'] = array();
$errors['lastname'] = $errors['name'];
}
return false;
}
示例5: createOrder
protected function createOrder()
{
$checkout_data = $this->getStorage()->get('shop/checkout');
$contact = $this->getUser()->isAuth() ? $this->getUser() : $checkout_data['contact'];
$cart = new shopCart();
$items = $cart->items(false);
// remove id from item
foreach ($items as &$item) {
unset($item['id']);
unset($item['parent_id']);
}
unset($item);
$order = array('contact' => $contact, 'items' => $items, 'total' => $cart->total(false), 'params' => isset($checkout_data['params']) ? $checkout_data['params'] : array());
$order['discount'] = shopDiscounts::apply($order);
if (isset($checkout_data['shipping'])) {
$order['params']['shipping_id'] = $checkout_data['shipping']['id'];
$order['params']['shipping_rate_id'] = $checkout_data['shipping']['rate_id'];
$shipping_step = new shopCheckoutShipping();
$rate = $shipping_step->getRate($order['params']['shipping_id'], $order['params']['shipping_rate_id']);
$order['params']['shipping_plugin'] = $rate['plugin'];
$order['params']['shipping_name'] = $rate['name'];
if (isset($rate['est_delivery'])) {
$order['params']['shipping_est_delivery'] = $rate['est_delivery'];
}
if (!isset($order['shipping'])) {
$order['shipping'] = $rate['rate'];
}
if (!empty($order['params']['shipping'])) {
foreach ($order['params']['shipping'] as $k => $v) {
$order['params']['shipping_params_' . $k] = $v;
}
unset($order['params']['shipping']);
}
} else {
$order['shipping'] = 0;
}
if (isset($checkout_data['payment'])) {
$order['params']['payment_id'] = $checkout_data['payment'];
$plugin_model = new shopPluginModel();
$plugin_info = $plugin_model->getById($checkout_data['payment']);
$order['params']['payment_name'] = $plugin_info['name'];
$order['params']['payment_plugin'] = $plugin_info['plugin'];
if (!empty($order['params']['payment'])) {
foreach ($order['params']['payment'] as $k => $v) {
$order['params']['payment_params_' . $k] = $v;
}
unset($order['params']['payment']);
}
}
if ($skock_id = waRequest::post('stock_id')) {
$order['params']['stock_id'] = $skock_id;
}
$routing_url = wa()->getRouting()->getRootUrl();
$order['params']['storefront'] = wa()->getConfig()->getDomain() . ($routing_url ? '/' . $routing_url : '');
if (($ref = wa()->getStorage()->get('shop/referer')) || ($ref = waRequest::cookie('referer'))) {
$order['params']['referer'] = $ref;
$ref_parts = parse_url($ref);
$order['params']['referer_host'] = $ref_parts['host'];
// try get search keywords
if (!empty($ref_parts['query'])) {
$search_engines = array('text' => 'yandex\\.|rambler\\.', 'q' => 'bing\\.com|mail\\.|google\\.', 's' => 'nigma\\.ru', 'p' => 'yahoo\\.com');
$q_var = false;
foreach ($search_engines as $q => $pattern) {
if (preg_match('/(' . $pattern . ')/si', $ref_parts['host'])) {
$q_var = $q;
break;
}
}
// default query var name
if (!$q_var) {
$q_var = 'q';
}
parse_str($ref_parts['query'], $query);
if (!empty($query[$q_var])) {
$order['params']['keyword'] = $query[$q_var];
}
}
}
if ($utm = waRequest::cookie('utm')) {
$utm = json_decode($utm, true);
if ($utm && is_array($utm)) {
foreach ($utm as $k => $v) {
$order['params']['utm_' . $k] = $v;
}
}
}
$order['params']['ip'] = waRequest::getIp();
$order['params']['user_agent'] = waRequest::getUserAgent();
foreach (array('shipping', 'billing') as $ext) {
$address = $contact->getFirst('address.' . $ext);
if ($address) {
foreach ($address['data'] as $k => $v) {
$order['params'][$ext . '_address.' . $k] = $v;
}
}
}
if (isset($checkout_data['comment'])) {
$order['comment'] = $checkout_data['comment'];
}
$workflow = new shopWorkflow();
//.........这里部分代码省略.........
示例6: isHttps
public static function isHttps()
{
if (!empty($_SERVER['HTTP_X_HTTPS']) && strtolower($_SERVER['HTTP_X_HTTPS']) != 'off') {
return true;
}
if (!empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) == 'on' || $_SERVER['HTTPS'] == '1')) {
return true;
}
if (!empty($_SERVER['HTTP_HTTPS']) && (strtolower($_SERVER['HTTP_HTTPS']) == 'on' || $_SERVER['HTTP_HTTPS'] == '1')) {
if ($_SERVER['HTTP_HTTPS'] != '1' && strpos(waRequest::getUserAgent(), 'Chrome/44.0') === false) {
return true;
}
}
if (!empty($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 1) {
return true;
}
if (!empty($_SERVER['HTTP_X_SSL']) && (strtolower($_SERVER['HTTP_X_SSL']) == 'yes' || $_SERVER['HTTP_X_SSL'] == '1')) {
return true;
}
if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
return true;
}
if (!empty($_SERVER['HTTP_X_SCHEME']) && strtolower($_SERVER['HTTP_X_SCHEME']) == 'https') {
return true;
}
return false;
}
示例7: callback
public static final function callback($module_id, $request = array())
{
$log = array('method' => __METHOD__, 'request' => $request, 'ip' => waRequest::getIp(), 'agent' => waRequest::getUserAgent());
self::log($module_id, $log);
$module = null;
try {
$module = self::factory($module_id);
return $module->callbackInit($request)->init()->callbackHandler($request);
} catch (Exception $ex) {
$log = array('method' => __METHOD__, 'exception' => $ex->getMessage());
self::log($module ? $module->getId() : 'general', $log);
if ($module) {
return $module->callbackExceptionHandler($ex);
} else {
return array('error' => $ex->getMessage(), 'code' => $ex->getCode());
}
}
}