当前位置: 首页>>代码示例>>PHP>>正文


PHP waRequest::getIp方法代码示例

本文整理汇总了PHP中waRequest::getIp方法的典型用法代码示例。如果您正苦于以下问题:PHP waRequest::getIp方法的具体用法?PHP waRequest::getIp怎么用?PHP waRequest::getIp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在waRequest的用法示例。


在下文中一共展示了waRequest::getIp方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: payment

 public function payment($payment_form_data, $order_data, $auto_submit = false)
 {
     $order = waOrder::factory($order_data);
     $fp_timestamp = time();
     $fp_sequence = $order->id;
     $fp_hash_string = $this->login . "^" . $fp_sequence . "^" . $fp_timestamp . "^" . $order->total . "^" . $order->currency;
     $form = array('x_login' => $this->login, 'x_test_request' => $this->testmode ? 'TRUE' : 'FALSE', 'x_show_form' => 'PAYMENT_FORM', 'x_fp_sequence' => $fp_sequence, 'x_fp_timestamp' => $fp_timestamp, 'x_fp_hash' => $this->hmac($this->key, $fp_hash_string), 'x_amount' => $order->total, 'x_currency_code' => $order->currency, 'x_first_name' => $order->billing_address['firstname'], 'x_last_name' => $order->billing_address['lastname'], 'x_address' => $order->billing_address['street'], 'x_city' => $order->billing_address['city'], 'x_state' => $order->billing_address['region_name'], 'x_zip' => $order->billing_address['zip'], 'x_country' => $order->billing_address['country_name'], 'x_email' => $order->contact_email, "x_customer_ip" => waRequest::getIp(), 'x_invoice_num' => $order->id_str, 'x_description' => $order->description_en, 'x_ship_to_first_name' => $order->shipping_address['firstname'], 'x_ship_to_last_name' => $order->shipping_address['lastname'], 'x_ship_to_address' => $order->shipping_address['street'], 'x_ship_to_city' => $order->shipping_address['city'], 'x_ship_to_state' => $order->shipping_address['region_name'], 'x_ship_to_zip' => $order->shipping_address['zip'], 'x_ship_to_country' => $order->shipping_address['country_name'], 'x_relay_response' => 'FALSE');
     $view = wa()->getView();
     $view->assign('form', $form);
     $view->assign('form_url', $this->getEndpointUrl());
     $view->assign('auto_submit', $auto_submit);
     return $view->fetch($this->path . '/templates/payment.html');
 }
开发者ID:Favorskij,项目名称:webasyst-framework,代码行数:13,代码来源:authorizenetsimPayment.class.php

示例2: execute

 public function execute()
 {
     $data = $this->getReqiestData();
     $comment_id = $data['comment_id'];
     unset($data['comment_id']);
     $data['datetime'] = date('Y-m-d H:i:s');
     $contact_data = $this->getContactData();
     $data = array_merge($data, $contact_data);
     $this->errors += $this->comment_model->validate($data);
     if ($this->errors) {
         return false;
     }
     // taking into account possibility of stack
     $photo_id = $data['photo_id'];
     $photo_model = new photosPhotoModel();
     $parent_id = $photo_model->getStackParentId($photo_id);
     if ($parent_id) {
         // if it is stack work with parent
         $photo_id = $parent_id;
     }
     $data['photo_id'] = $photo_id;
     if (!isset($data['ip']) && ($ip = waRequest::getIp())) {
         $ip = ip2long($ip);
         if ($ip > 2147483647) {
             $ip -= 4294967296;
         }
         $data['ip'] = $ip;
     }
     $id = $this->comment_model->add($data, $comment_id);
     $this->added_comment = $this->comment_model->getById($id);
     if (preg_match('/(\\d+)/', $data['photo_comments_count_text'], $m)) {
         $count = $m[1] + 1;
         $this->response['photo_comments_count_text'] = _wp('%d comment', '%d comments', $count);
     }
     $comment = $data;
     $comment['id'] = $id;
     $comment['author'] = $this->getResponseAuthorData();
     $comment['status'] = photosCommentModel::STATUS_PUBLISHED;
     $photo_id = $comment['photo_id'];
     $this->view->assign('wrap_li', true);
     $this->view->assign('comment', $comment);
     $this->view->assign('contact_rights', wa()->getUser()->getRights('contacts', 'backend'));
     $this->response['html'] = $this->view->fetch($this->template);
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:44,代码来源:photosCommentAddController.class.php

示例3: vote

 public function vote($photo_id, $rate)
 {
     if (!wa()->getUser()->getId()) {
         return false;
     }
     if ($rate < 0 || $rate > 5) {
         return false;
     }
     $not_voted_photo_id = $this->filterNotVotedPhotoIds($photo_id);
     if (!$not_voted_photo_id) {
         return false;
     }
     $data = array('contact_id' => wa()->getUser()->getId(), 'rate' => $rate, 'datetime' => date('Y-m-d H:i:s'), 'ip' => waRequest::getIp(true));
     foreach ($not_voted_photo_id as $id) {
         $data['photo_id'] = $id;
         $this->insert($data);
     }
     $this->correctAggregatedRates($not_voted_photo_id);
     return true;
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:20,代码来源:photosPublicgalleryVote.model.php

示例4: isValid

 public function isValid($code = null, &$error = '')
 {
     if ($code === null) {
         $code = waRequest::post('g-recaptcha-response');
     }
     $handle = curl_init(self::SITE_VERIFY_URL);
     $options = array(CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query(array('secret' => $this->options['secret'], 'response' => $code, 'remoteip' => waRequest::getIp())), CURLOPT_HTTPHEADER => array('Content-Type: application/x-www-form-urlencoded'), CURLINFO_HEADER_OUT => false, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => true);
     curl_setopt_array($handle, $options);
     $response = curl_exec($handle);
     curl_close($handle);
     if ($response) {
         $response = json_decode($response, true);
         if (isset($response['success']) && $response['success'] == true) {
             return true;
         } elseif (isset($response['error-codes'])) {
             $errors = array();
             foreach ($response['error-codes'] as $error_code) {
                 switch ($error_code) {
                     case 'missing-input-secret':
                         $errors[] = _ws('The secret parameter is missing.');
                         break;
                     case 'invalid-input-secret':
                         $errors[] = _ws('The secret parameter is invalid or malformed.');
                         break;
                     case 'missing-input-response':
                         $errors[] = _ws('The response parameter is missing.');
                         break;
                     case 'invalid-input-response':
                         $errors[] = _ws('The response parameter is invalid or malformed.');
                         break;
                     default:
                         $errors[] = $error_code;
                 }
                 $error = implode('<br>', $errors);
             }
         }
     }
     return false;
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:39,代码来源:waReCaptcha.class.php

示例5: add

 public function add($review, $parent_id = null, $before_id = null)
 {
     if (empty($review['product_id'])) {
         return false;
     }
     if ($parent_id) {
         $parent = $this->getById($parent_id);
         if (!$parent) {
             return false;
         }
         if ($parent['review_id']) {
             $review['review_id'] = $parent['review_id'];
         } else {
             $review['review_id'] = $parent['id'];
         }
     }
     if (!isset($review['ip']) && ($ip = waRequest::getIp())) {
         $ip = ip2long($ip);
         if ($ip > 2147483647) {
             $ip -= 4294967296;
         }
         $review['ip'] = $ip;
     }
     if (!empty($review['contact_id'])) {
         $user = wa()->getUser();
         if ($user->getId() && !$user->get('is_user')) {
             $user->addToCategory(wa()->getApp());
         }
     }
     if (!isset($review['datetime'])) {
         $review['datetime'] = date('Y-m-d H:i:s');
     }
     if (isset($review['site']) && $review['site']) {
         if (!preg_match('@^https?://@', $review['site'])) {
             $review['site'] = 'http://' . $review['site'];
         }
     }
     $before_id = null;
     $id = parent::add($review, $parent_id, $before_id);
     if (!$id) {
         return false;
     }
     if (empty($review['review_id']) && !empty($review['rate'])) {
         $this->recalcProductRating($review['product_id'], $review['rate']);
     }
     return $id;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:47,代码来源:shopProductReviews.model.php

示例6: waModel

<?php

$model = new waModel();
try {
    $model->query("SELECT moderation FROM `photos_photo` WHERE 0");
} catch (waException $e) {
    // 0 - waited
    // 1 - approved
    // -1 - declined
    $sql = "ALTER TABLE `photos_photo` ADD COLUMN moderation TINYINT(1) NOT NULL DEFAULT 1";
    $model->query($sql);
}
try {
    $model->query("SELECT `votes_count` FROM `photos_photo` WHERE 0");
} catch (waException $e) {
    $model->exec("ALTER TABLE `photos_photo` ADD COLUMN votes_count INT(11) NOT NULL DEFAULT 0");
}
$contact_id = wa()->getUser()->getId();
$photo_model = new photosPhotoModel();
$data = array();
foreach ($photo_model->select('id, rate')->where('rate > 0')->fetchAll() as $item) {
    $data[] = array('photo_id' => $item['id'], 'contact_id' => $contact_id, 'rate' => $item['rate'], 'datetime' => date('Y-m-d H:i:s'), 'ip' => waRequest::getIp(true));
}
$vote_model = new photosPublicgalleryVoteModel();
$vote_model->multipleInsert($data);
$model->exec("UPDATE `photos_photo` SET votes_count = 1 WHERE rate > 0");
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:26,代码来源:install.php

示例7: 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;
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:101,代码来源:shopOnestepPluginFrontendOnestep.action.php

示例8: add

 public function add($comment, $parent = null)
 {
     if (!isset($comment['ip']) && ($ip = waRequest::getIp())) {
         $ip = ip2long($ip);
         if ($ip > 2147483647) {
             $ip -= 4294967296.0;
         }
         $comment['ip'] = $ip;
     }
     if (!isset($comment['datetime'])) {
         $comment['datetime'] = date('Y-m-d H:i:s');
     }
     if (isset($comment['site']) && $comment['site']) {
         if (!preg_match('@^https?://@', $comment['site'])) {
             $comment['site'] = 'http://' . $comment['site'];
         }
     }
     $comment[$this->parent] = $parent;
     blogActivity::setUserActivity();
     /**
      * @event comment_presave_frontend
      * @event comment_presave_backend
      * @param array $comment
      * @param int $comment.id
      * @param int $comment.parent
      * @return void
      */
     wa()->event('comment_presave_' . wa()->getEnv(), $comment);
     $comment['id'] = parent::add($comment, $parent);
     /**
      * @event comment_save_frontend
      * @event comment_save_backend
      * @param array $comment
      * @param int $comment.id
      * @param int $comment.parent
      * @return void
      */
     wa()->event('comment_save_' . wa()->getEnv(), $comment);
     return $comment['id'];
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:40,代码来源:blogComment.model.php

示例9: 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);
         }
         /**
//.........这里部分代码省略.........
开发者ID:Lazary,项目名称:webasyst,代码行数:101,代码来源:waSignupAction.class.php

示例10: 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;
 }
开发者ID:nowaym,项目名称:webasyst-framework,代码行数:77,代码来源:waSignupAction.class.php

示例11: callbackHandler

 /**
  * @param array $request
  * @throws waPaymentException
  * @return array|string|void
  */
 protected function callbackHandler($request)
 {
     $transaction_data = $this->formalizeData($request);
     if (!$this->order_id || !$this->app_id || !$this->merchant_id) {
         throw new waPaymentException('invalid invoice number');
     }
     $response_password = !empty($request['callbackPW']) ? $request['callbackPW'] : '';
     $result = array('p' => $this);
     if ($response_password != $this->response_password) {
         $result['rp_not_equal'] = true;
         $result['template'] = wa()->getConfig()->getRootPath() . '/wa-plugins/payment/' . $this->id . '/templates/callback.html';
         $result['back_url'] = $this->getAdapter()->getBackUrl(waAppPayment::URL_FAIL, $transaction_data);
         waLog::log("Payment Response password in plugin settings doesn't equal the same setting in the Merchant Interface\n" . "Client IP:" . waRequest::getIp(), 'worldpayPament.log');
         return $result;
     }
     if ($transaction_data['type'] == waPayment::OPERATION_AUTH_CAPTURE) {
         $app_payment_method = self::CALLBACK_CONFIRMATION;
         $back_url = $this->getAdapter()->getBackUrl(waAppPayment::URL_SUCCESS, $transaction_data);
     } else {
         $app_payment_method = self::CALLBACK_CANCEL;
         $back_url = $this->getAdapter()->getBackUrl(waAppPayment::URL_FAIL, $transaction_data);
     }
     $tm = new waTransactionModel();
     $fields = array('native_id' => $transaction_data['native_id'], 'plugin' => $this->id, 'type' => $app_payment_method);
     if (!$tm->getByFields($fields)) {
         $transaction_data = $this->saveTransaction($transaction_data, $request);
         $result += $this->execAppCallback($app_payment_method, $transaction_data);
     }
     $result['back_url'] = $back_url;
     $result['template'] = wa()->getConfig()->getRootPath() . '/wa-plugins/payment/' . $this->id . '/templates/callback.html';
     return $result;
 }
开发者ID:Favorskij,项目名称:webasyst-framework,代码行数:37,代码来源:worldpayPayment.class.php

示例12: beforeSaveField

 public function beforeSaveField(&$params)
 {
     if (empty($params['photo_id'])) {
         return;
     }
     if (is_array($params['photo_id'])) {
         $photo_id = (int) reset($params['photo_id']);
     } else {
         $photo_id = (int) $params['photo_id'];
     }
     $photo_model = new photosPhotoModel();
     $photo = $photo_model->getById($photo_id);
     if (!$photo) {
         return;
     }
     if (empty($params['data'])) {
         return;
     }
     $data = $params['data'];
     if (!isset($data['rate'])) {
         return;
     }
     $contact_id = wa()->getUser()->getId();
     $vote_model = new photosPublicgalleryVoteModel();
     if ($vote_model->getByField(array('photo_id' => $photo_id, 'contact_id' => $contact_id))) {
         $params['data'] = $photo['rate'];
     } else {
         $vote_model->insert(array('photo_id' => $photo_id, 'contact_id' => wa()->getUser()->getId(), 'rate' => $data['rate'], 'datetime' => date('Y-m-d H:i:s'), 'ip' => waRequest::getIp(true)));
         $params['data']['rate'] = $vote_model->getRate($photo_id);
         $params['data']['votes_count'] = $vote_model->getVotesCount($photo_id);
     }
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:32,代码来源:photosPublicgallery.plugin.php

示例13: 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();
//.........这里部分代码省略.........
开发者ID:Lazary,项目名称:webasyst,代码行数:101,代码来源:shopFrontendCheckout.action.php

示例14: 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());
         }
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:18,代码来源:waPayment.class.php


注:本文中的waRequest::getIp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。