本文整理汇总了PHP中Tools::getRemoteAddr方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::getRemoteAddr方法的具体用法?PHP Tools::getRemoteAddr怎么用?PHP Tools::getRemoteAddr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools
的用法示例。
在下文中一共展示了Tools::getRemoteAddr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sds_init_error_warning
public static function sds_init_error_warning()
{
if ((int) Configuration::get('config_maintenance') == 1) {
echo "<div class='alert alert-warning'>Maintenance mode is enabled. This may cause functional problem at your slider revolution module.</div>";
if (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP')))) {
echo "<div class='alert alert-warning'>It's seemed that your IP is not present in Maintenance IP.</div>";
}
}
if (get_magic_quotes_gpc()) {
echo "<div class='alert alert-warning'>magic_quotes_gpc is enabled. This may cause functional problem at your slider revolution module. Please disable magic_quotes_gpc.</div>";
}
if (get_magic_quotes_runtime()) {
echo "<div class='alert alert-warning'>magic_quotes_runtime is enabled. This may cause functional problem at your slider revolution module. Please disable magic_quotes_runtime.</div>";
}
if (!defined('ABSPATH')) {
echo "<div class='alert alert-warning'>Fatal Error: 'ABSPATH' isn't defined.</div>";
return;
}
if (!is_writable(ABSPATH . '/uploads')) {
echo "<div class='alert alert-warning'>'" . ABSPATH . "/uploads' folder is not writeable. Change the folder permission.</div>";
}
if (!is_writable(ABSPATH . '/rs-plugin/css')) {
echo "<div class='alert alert-warning'>'" . ABSPATH . "/rs-plugin/css' folder is not writeable. Change the folder permission.</div>";
}
// if(!is_executable(ABSPATH.'/rs-plugin/fileuploader/uploadify.php')){
// echo "<div class='alert alert-warning'>'".ABSPATH."/rs-plugin/fileuploader/uploadify.php' file is not executable. Change the file permission.</div>";
// }
if (!is_writable(ABSPATH . '/cache')) {
echo "<div class='alert alert-warning'>'" . ABSPATH . "/cache' folder is not writeable. Change the folder permission.</div>";
}
}
示例2: setNewConnection
public static function setNewConnection($cookie)
{
// The old connections details are removed from the database in order to spare some memory
Connection::cleanConnectionsPages();
// A new connection is created if the guest made no actions during 30 minutes
$result = Db::getInstance()->getRow('
SELECT c.`id_guest`
FROM `' . _DB_PREFIX_ . 'connections` c
LEFT JOIN `' . _DB_PREFIX_ . 'connections_page` cp ON c.`id_connections` = cp.`id_connections`
WHERE c.`id_guest` = ' . intval($cookie->id_guest) . '
AND DATE_ADD(cp.`time_start`, INTERVAL 30 MINUTE) > \'' . pSQL(date('Y-m-d H:i:s')) . '\'
ORDER BY cp.`time_start` DESC');
if (!$result['id_guest'] and intval($cookie->id_guest)) {
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$arrayUrl = parse_url($referer);
if (!isset($arrayUrl['host']) or preg_replace('/^www./', '', $arrayUrl['host']) == preg_replace('/^www./', '', Tools::getHttpHost(false, false))) {
$referer = '';
}
$connection = new Connection();
$connection->id_guest = intval($cookie->id_guest);
$connection->id_page = Page::getCurrentId();
$connection->ip_address = Tools::getRemoteAddr() ? ip2long(Tools::getRemoteAddr()) : '';
if (Validate::isAbsoluteUrl($referer)) {
$connection->http_referer = $referer;
}
$connection->add();
$cookie->id_connections = $connection->id;
return $connection->id_page;
}
}
示例3: __construct
public function __construct()
{
$this->name = 'adminmarketingestep1';
$this->bootstrap = true;
$this->module = 'expressmailing';
$this->context = Context::getContext();
$this->lang = true;
$this->default_form_language = $this->context->language->id;
$this->campaign_id = (int) Tools::getValue('campaign_id');
if (empty($this->campaign_id)) {
Tools::redirectAdmin('index.php?controller=AdminMarketingX&token=' . Tools::getAdminTokenLite('AdminMarketingX'));
exit;
}
parent::__construct();
$online = true;
$ip_string = (string) Tools::getRemoteAddr();
$ip_long = ip2long($ip_string);
if (Tools::substr(Configuration::get('PS_SHOP_DOMAIN'), 0, 9) == 'localhost') {
$online = false;
}
if ($ip_long >= ip2long('10.0.0.0') && $ip_long <= ip2long('10.255.255.255')) {
$online = false;
}
if ($ip_long >= ip2long('127.0.0.0') && $ip_long <= ip2long('127.255.255.255')) {
$online = false;
}
if ($ip_long >= ip2long('172.16.0.0') && $ip_long <= ip2long('172.31.255.255')) {
$online = false;
}
if ($ip_long >= ip2long('192.168.0.0') && $ip_long <= ip2long('192.168.255.255')) {
$online = false;
} elseif ($ip_string == '::1') {
$online = false;
}
/* IPv6 */
if (!$online) {
$a = $this->module->l('You are currently testing your Prestashop on a local server :', 'adminmarketingestep1');
$b = $this->module->l('To enjoy the full IMAGE & TRACKING features, you need use a Prestashop online server !', 'adminmarketingestep1');
$this->warnings[] = $a . ' ' . Tools::getRemoteAddr();
$this->warnings[] = $b;
}
// API initialization
// ------------------
include _PS_MODULE_DIR_ . $this->module->name . '/controllers/admin/session_api.php';
$this->session_api = new SessionApi();
if ($this->session_api->connectFromCredentials('email')) {
// On retrouve le max_daily depuis l'API Express-Mailing
// -----------------------------------------------------
$parameters = array('account_id' => $this->session_api->account_id);
$response_array = array();
if ($this->session_api->call('email', 'account', 'get_formula', $parameters, $response_array)) {
if ((int) $response_array['broadcast_max_campaign'] > 0) {
$this->default_max_daily = $response_array['broadcast_max_campaign'];
}
}
}
}
示例4: processCustomerNewsletter
/**
* Process the newsletter settings and set the customer infos.
* @param Customer $customer Reference on the customer Object.
* @note At this point, the email has been validated.
*/
public static function processCustomerNewsletter(&$customer)
{
$customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr());
$customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s'));
if ($module_newsletter = Module::getInstanceByName('blocknewsletter')) {
if ($module_newsletter->active) {
$module_newsletter->confirmSubscription($customer->email);
}
}
}
示例5: display
public function display($file, $template, $cache_id = null, $compile_id = null)
{
$result = parent::display($file, $template, $cache_id, $compile_id);
$ip = Configuration::get('witm_config');
$ip_array = explode(',', $ip);
if (!in_array(Tools::getRemoteAddr(), $ip_array) && !in_array('*', $ip_array)) {
return $result;
}
return '<div class="div_infos_tpl"><span class="infos_tpl">TPL<span class="file_template">FILE : ' . $file . '<br/>TEMPLATE : ' . $template . '</span></span>' . $result . '</div>';
}
示例6: processLogin
public function processLogin()
{
require_once dirname(__FILE__) . '../../../../modules/designer/designer.php';
$themeName = trim(Tools::getValue('theme_name'));
$passwd = trim(Tools::getValue('passwd'));
$email = trim(Tools::getValue('email'));
$domain = getSessionDomain($themeName);
$version = function_exists('theme_get_manifest_version') ? '&ver=' . theme_get_manifest_version($themeName) : '';
$desktop = function_exists('getDesktopParams') ? getDesktopParams() : '';
if (empty($email)) {
$this->errors[] = Tools::displayError('E-mail is empty');
} elseif (!Validate::isEmail($email)) {
$this->errors[] = Tools::displayError('Invalid e-mail address');
}
if (empty($passwd)) {
$this->errors[] = Tools::displayError('Password is blank');
} elseif (!Validate::isPasswd($passwd)) {
$this->errors[] = Tools::displayError('Invalid password');
}
if (!count($this->errors)) {
$this->context->employee = new Employee();
$is_employee_loaded = $this->context->employee->getByemail($email, $passwd);
$employee_associated_shop = $this->context->employee->getAssociatedShops();
if (!$is_employee_loaded) {
$this->errors[] = Tools::displayError('Employee does not exist or password is incorrect.');
$this->context->employee->logout();
} elseif (empty($employee_associated_shop) && !$this->context->employee->isSuperAdmin()) {
$this->errors[] = Tools::displayError('Employee does not manage any shop anymore (shop has been deleted or permissions have been removed).');
$this->context->employee->logout();
} else {
$this->context->employee->remote_addr = ip2long(Tools::getRemoteAddr());
$cookie = Context::getContext()->cookie;
$cookie->id_employee = $this->context->employee->id;
$cookie->email = $this->context->employee->email;
$cookie->profile = $this->context->employee->id_profile;
$cookie->passwd = $this->context->employee->passwd;
$cookie->remote_addr = $this->context->employee->remote_addr;
$cookie->write();
if (Tools::getIsset('theme_name')) {
$url = $this->context->link->getAdminLink('AdminAjax') . '&ajax=1' . $domain . $version . $desktop;
} else {
$tab = new Tab((int) $this->context->employee->default_tab);
$url = $this->context->link->getAdminLink($tab->class_name);
}
if (Tools::isSubmit('ajax')) {
die(Tools::jsonEncode(array('hasErrors' => false, 'redirect' => $url)));
} else {
$this->redirect_after = $url;
}
}
}
if (Tools::isSubmit('ajax')) {
die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => $this->errors)));
}
}
示例7: exec
public static function exec($hook_name, $hook_args = array(), $id_module = null, $array_return = false, $check_exceptions = true, $use_push = false, $id_shop = null)
{
$output = parent::exec($hook_name, $hook_args, $id_module, $array_return, $check_exceptions, $use_push, $id_shop);
$live_edit = Tools::isSubmit('live_edit') ? true : false;
if (!($module_list = Hook::getHookModuleExecList($hook_name))) {
return '';
}
$ip = Configuration::get('witm_config');
$ip_array = explode(',', $ip);
$before_output = '';
$after_output = '';
if (in_array(Tools::getRemoteAddr(), $ip_array) || in_array('*', $ip_array)) {
if (Configuration::get('witm_h_m') == 1) {
$before_output .= '
<div class="div_infos_hook">
<span class="infos_hook"><span onclick="display_infos_hook(\'' . $hook_name . '\')"><i class="icon-expand-alt icon-large"></i> H-M</span>
<span class="hook_module" id="hook_module_' . $hook_name . '"><br/>
HOOK: ' . $hook_name . '<div class="see_modules"><span onclick="display_module(\'' . $hook_name . '\')"><i class="icon-expand-alt icon-large"></i> Modules</span><span id="d_m_' . $hook_name . '" class="display_modules">';
} else {
$before_output .= '
<div class="div_infos_hook">
<span class="infos_hook">H-M
<span class="hook_module"><br/>
HOOK: ' . $hook_name . '<div class="see_modules"><span onclick="display_module(\'' . $hook_name . '\')"><i class="icon-expand-alt icon-large"></i> Modules</span><span id="d_m_' . $hook_name . '" class="display_modules">';
}
$css_js = (int) Configuration::get('witm_css_js');
$img = '<img src="' . Context::getContext()->shop->physical_uri . '/modules/whatisthismodule/img/open_new_tab.png"/>';
foreach ($module_list as $module) {
$css = '';
$js = '';
if ($css_js == 1) {
foreach (Context::getContext()->controller->css_files as $key => $value) {
if (strstr($key, '/' . $module['module'] . '/')) {
$css .= '<br/> <a class="file_css" href="' . $key . '" target="_blank">CSS : ' . $key . ' ' . $img . '</a>';
}
}
foreach (Context::getContext()->controller->js_files as $key => $value) {
if (strstr($value, '/' . $module['module'] . '/')) {
$js .= '<br/> <a class="file_js" href="' . $value . '" target="_blank">JS : ' . $value . ' ' . $img . '</a>';
}
}
}
$before_output .= '<br/>- ' . $module['module'] . ($css != '' && $js != '' ? ' : ' : '') . $css . $js;
}
$before_output .= '</span></div></span></span>';
$after_output .= '</div>';
}
if ($array_return) {
return $output;
} else {
return ($live_edit ? '<script type="text/javascript">hooks_list.push(\'' . $hook_name . '\');</script>
<div id="' . $hook_name . '" class="dndHook" style="min-height:50px">' : '') . $before_output . $output . $after_output . ($live_edit ? '</div>' : '');
}
}
示例8: __construct
public function __construct($customer = array(), $cart = array(), $config = array())
{
$this->datasources = array("cart" => $cart, "customer" => $customer, "config" => $config);
$address = $this->datasources['cart']->id_address_delivery;
$address = new Address($address);
$country = new Country($address->id_country);
$validOrders = Db::getInstance()->getValue('SELECT COUNT(`' . Order::$definition['primary'] . '`) FROM ' . _DB_PREFIX_ . Order::$definition['table'] . ' WHERE id_customer = ' . $this->datasources['customer']->id . ' AND valid = 1');
$extra = array("total" => $this->datasources['cart']->getOrderTotal(true, Cart::BOTH), "validOrders" => $validOrders, "ip" => Tools::getRemoteAddr(), "moneda" => "ARS");
$this->datasources['address'] = $address;
$this->datasources['country'] = $country;
$this->datasources['extra'] = $extra;
}
示例9: indexAction
/**
* 默认动作
* Yaf支持直接把Yaf_Request_Abstract::getParam()得到的同名参数作为Action的形参
* 对于如下的例子, 当访问http://yourhost/sample/index/index/index/name/chenzhidong 的时候, 你就会发现不同
*/
public function indexAction($name = "Stranger")
{
//1. fetch query
$get = $this->getRequest()->getQuery("get", "default value");
//2. fetch model
$model = new SampleModel();
//setDatas
$model->setDatas(array('email' => 'sample@sample.com', 'nick' => 'nick', 'passwd' => '123456', 'ip_address' => Tools::getRemoteAddr()));
//3. assign
$this->_view->assign('content', $model->selectSample());
$this->_view->assign('name', $name);
//cache用法
//Cache::getInstance()->get($key);
//Cache::getInstance()->set($key);
//4. render by Yaf, 如果这里返回FALSE, Yaf将不会调用自动视图引擎Render模板
return true;
}
示例10: out
/**
* 写入日志
*
* @param string $strFileName
* @param string $strType
* @param string $strMSG
* @param string $strExtra
* @param string $line
*/
public static function out($strFileName = "", $strType = "I", $strMSG = "", $strExtra = "", $line = "")
{
if ($strType == "") {
$strType = "I";
}
if (!file_exists(self::$logpath)) {
if (!mkdir(self::$logpath, '0777')) {
if (DEBUG_MODE) {
die(Tools::displayError("Make " . self::$logpath . " error"));
} else {
die("error");
}
}
} elseif (!is_dir(self::$logpath)) {
if (DEBUG_MODE) {
die(Tools::displayError(self::$logpath . " is already token by a file"));
} else {
die("error");
}
} else {
if (!is_writable(self::$logpath)) {
@chmod(self::$logpath, 0777);
}
$logfile = rtrim(self::$logpath, '/') . '/' . $strFileName . '_' . date("ymd") . '.log';
if (file_exists($logfile) && !is_writable($logfile)) {
@chmod($logfile, 0644);
}
$handle = @fopen($logfile, "a+");
if ($handle) {
if (Tools::isCli()) {
$arg = "";
if ($_SERVER['argc'] > 0) {
$arg = " ARGV:" . json_encode($_SERVER['argv']);
}
$strContent = "[" . date("Y-m-d H:i:s") . "] [" . strtoupper($strType) . "] [CLI] MSG:[" . $strMSG . "]" . $strExtra . " Location:" . $_SERVER["SCRIPT_FILENAME"] . $arg . ($line ? " Line:" . $line : "") . "\n";
} else {
$strContent = "[" . date("Y-m-d H:i:s") . "] [" . strtoupper($strType) . "] [" . Tools::getRemoteAddr() . "] MSG:[" . $strMSG . "]" . $strExtra . " Location:" . $_SERVER["SCRIPT_FILENAME"] . ($line ? " Line:" . $line : "") . " QUERY_STRING:" . $_SERVER["QUERY_STRING"] . " HTTP_REFERER:" . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "") . " User-Agent:" . $_SERVER["HTTP_USER_AGENT"] . "\n";
}
if (!fwrite($handle, $strContent)) {
@fclose($handle);
die("Write permission deny");
}
@fclose($handle);
}
}
}
示例11: initContent
/**
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
try {
$resp = new Maestrano_Saml_Response($_POST['SAMLResponse']);
// Check if the Saml response is valid
if ($resp->isValid()) {
// Get the user as well as the user group
$mnoUser = new Maestrano_Sso_User($resp);
// intilize the user Model
$userModel = new Maestrano_Sso_Model_User();
// Find user in db by email if not exist then create locally
$userResp = $userModel->findOrCreate($mnoUser);
if ($userResp['id_employee'] > 0) {
//update the Cookie for prestashop
$cookie = new Cookie('psAdmin');
$cookie->id_employee = $userResp['id_employee'];
$cookie->email = $mnoUser->email;
$cookie->profile = $userResp['id_profile'];
$cookie->passwd = $userResp['passwd'];
$cookie->remote_addr = (int) ip2long(Tools::getRemoteAddr());
$cookie->last_activity = time();
// write the cookie in Prestashop session
$cookie->write();
// Once the user is created/identified, we store the maestrano session.
// This session will be used for single logout
$mnoSession = new Maestrano_Sso_Session($_SESSION, $mnoUser);
$mnoSession->save();
// If logged in redirect to admin dashboard startup page
if ($cookie->id_employee) {
$cookie = new Cookie('psAdDir');
Tools::redirect(Tools::getCurrentUrlProtocolPrefix() . Tools::getShopDomain() . __PS_BASE_URI__ . $cookie->admin_directory);
}
}
} else {
echo '<p>There was an error during the authentication process.</p><br/>';
echo '<p>Please try again. If issue persists please contact support@maestrano.com<p>';
exit;
}
} catch (Exception $ex) {
echo $ex;
exit;
}
}
示例12: postProcess
public function postProcess()
{
$cart = $this->context->cart;
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=1');
}
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
$authorized = false;
foreach (Module::getPaymentModules() as $module) {
if ($module['name'] == 'pagofacil') {
$authorized = true;
break;
}
}
if (!$authorized) {
die($this->module->l('Este método de pago no est´ disponible.', 'validation'));
}
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
// validacion
$arreglo_errores = array();
$arreglo_validacion = array('nombre' => array('message' => 'Debe capturar el nombre'), 'apellidos' => array('message' => 'Debe capturar los apellidos'), 'numeroTarjeta' => array('message' => 'Debe capturar el número de tarjeta'), 'cvt' => array('message' => 'Debe capturar el cvt'), 'cp' => array('message' => 'Debe capturar el cp'), 'mesExpiracion' => array('message' => 'Debe seleccionar el mes de expiración'), 'anyoExpiracion' => array('message' => 'Debe seleccionar el año de expiración'), 'email' => array('message' => 'Debe capturar el email'), 'telefono' => array('message' => 'Debe capturar el teléfono'), 'celular' => array('message' => 'Debe capturar el celular'), 'calleyNumero' => array('message' => 'Debe capturar la calle y número'), 'municipio' => array('message' => 'Debe capturar el municipio'), 'estado' => array('message' => 'Debe capturar el estado'), 'pais' => array('message' => 'Debe capturar el pais'));
foreach ($arreglo_validacion as $key => $item) {
if (trim(Tools::getValue($key)) == '') {
array_push($arreglo_errores, $item['message']);
}
}
if (count($arreglo_errores) > 0) {
session_start();
$_SESSION['errores'] = $arreglo_errores;
Tools::redirect($this->context->link->getModuleLink('pagofacil', 'payment'));
}
$currency = $this->context->currency;
$total = (double) $cart->getOrderTotal(true, Cart::BOTH);
//Realizar el pago con pagofacil
$data = array('idServicio' => urlencode('3'), 'idSucursal' => urlencode(Configuration::get('PF_API_BRANCH')), 'idUsuario' => urlencode(Configuration::get('PF_API_USER')), 'nombre' => urlencode(Tools::getValue('nombre')), 'apellidos' => urlencode(Tools::getValue('apellidos')), 'numeroTarjeta' => urlencode(Tools::getValue('numeroTarjeta')), 'cvt' => urlencode(Tools::getValue('cvt')), 'cp' => urlencode(Tools::getValue('cp')), 'mesExpiracion' => urlencode(Tools::getValue('mesExpiracion')), 'anyoExpiracion' => urlencode(Tools::getValue('anyoExpiracion')), 'monto' => urlencode($total), 'email' => urlencode(Tools::getValue('email')), 'telefono' => urlencode(Tools::getValue('telefono')), 'celular' => urlencode(Tools::getValue('celular')), 'calleyNumero' => urlencode(Tools::getValue('calleyNumero')), 'colonia' => urlencode(trim(Tools::getValue('colonia')) == '' ? 'S/D' : trim(Tools::getValue('colonia'))), 'municipio' => urlencode(Tools::getValue('municipio')), 'estado' => urlencode(Tools::getValue('estado')), 'pais' => urlencode(Tools::getValue('pais')), 'idPedido' => urlencode($cart->id), 'ip' => urlencode(Tools::getRemoteAddr()), 'httpUserAgent' => urlencode($_SERVER['HTTP_USER_AGENT']));
if (Configuration::get('PF_NO_MAIL') == '1') {
$data = array_merge($data, array('noMail' => 1));
}
if (Configuration::get('PF_EXCHANGE') != 'MXN') {
$data = array_merge($data, array('divisa' => Configuration::get('PF_EXCHANGE')));
}
if (Configuration::get('PF_INSTALLMENTS') == '1') {
if (Tools::getValue('msi') != '' && Tools::getValue('msi') != '00') {
$data = array_merge($data, array('plan' => 'MSI', 'mensualidades' => Tools::getValue('msi')));
}
}
// construccion de la peticion
$url = 'https://www.pagofacil.net/st/public/Wsrtransaccion/index/format/json';
if (Configuration::get('PF_ENVIRONMENT') == '2') {
$url = 'https://www.pagofacil.net/ws/public/Wsrtransaccion/index/format/json';
}
$url .= '/?method=transaccion';
foreach ($data as $key => $valor) {
$url .= "&data[{$key}]={$valor}";
}
//die($this->module->l($url, 'validation'));
// consumo del servicio
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Blindly accept the certificate
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
// tratamiento de la respuesta del servicio
if (($json = json_decode($response, true)) === NULL) {
session_start();
$_SESSION['errores'] = array($response == NULL ? 'Sin respuesta del servicio' : 'Respuesta del servicio: ' . $response);
Tools::redirect($this->context->link->getModuleLink('pagofacil', 'payment'));
}
if (!isset($json['WebServices_Transacciones']['transaccion'])) {
session_start();
$_SESSION['errores'] = array('No existe WebServices_Transacciones - transaccion', 'Respuesta del servicio: ' . $response);
Tools::redirect($this->context->link->getModuleLink('pagofacil', 'payment'));
}
$transaction = $json['WebServices_Transacciones']['transaccion'];
if (isset($transaction['autorizado']) && $transaction['autorizado'] == '1') {
try {
$this->module->validateOrder((int) $cart->id, 2, $total, $this->module->displayName, NULL, array(), (int) $currency->id, false, $customer->secure_key);
Tools::redirect('index.php?controller=order-confirmation&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
} catch (Exception $error) {
session_start();
$_SESSION['errores'] = array($error->getMessage());
Tools::redirect($this->context->link->getModuleLink('pagofacil', 'payment'));
}
} else {
$arreglo_errores = array();
if (is_array($transaction['error'])) {
foreach ($transaction['error'] as $key => $value) {
$arreglo_errores[$key] = $value;
}
} else {
$arreglo_errores[] = $transaction['texto'];
}
session_start();
$_SESSION['errores'] = $arreglo_errores;
Tools::redirect($this->context->link->getModuleLink('pagofacil', 'payment'));
//.........这里部分代码省略.........
示例13: hookActionValidateOrder
public function hookActionValidateOrder($params)
{
try {
$ip = Tools::getRemoteAddr();
$ip_forwarded_for = '';
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
$ip_forwarded_for = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
$details = $params['order'];
$cart_id = $details->id_cart;
$order_id = Order::getOrderByCartId($cart_id);
$currency = new Currency($details->id_currency);
$customer = new Customer((int) $details->id_customer);
$my_order = new Order($order_id);
$domain = Configuration::get('PS_SHOP_DOMAIN');
$auth_token = Configuration::get('PS_AUTH_TOKEN');
$data = array();
$this->fillGeneralOrderInfo($data, $order_id, $my_order, $ip, $cart_id, $currency, $customer);
$data['note'] = null;
if ($ip_forwarded_for) {
$data['note'] = 'forwarded for: ' . $ip_forwarded_for;
}
$this->fillLineItems($data, $my_order);
$carrier = new Carrier((int) $details->id_carrier, (int) $details->id_lang);
$this->fillShippingDetails($data, $my_order, $carrier);
$payments = $my_order->getOrderPayments();
$this->getPaymentDetails($data, $payments);
$address_invoice = new Address((int) $details->id_address_invoice);
$this->getBillingAddress($data, $address_invoice);
$address_shipping = new Address((int) $details->id_address_delivery);
$this->getShippingAddress($data, $address_shipping);
$this->storeIpAndRemoteForOrder($order_id, $ip, $ip_forwarded_for);
$this->fillCustomerInfo($data, $customer);
$data_string = Tools::jsonEncode($data);
$hash_code = hash_hmac('sha256', $data_string, $auth_token);
if ($this->curlExists()) {
$url = $this->getRiskifiedUrl();
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . Tools::strlen($data_string), 'X_RISKIFIED_SHOP_DOMAIN:' . $domain, 'X_RISKIFIED_HMAC_SHA256:' . $hash_code));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_getinfo($ch);
curl_exec($ch);
if (Configuration::get('RISKIFIED_MODE') == '1') {
Configuration::updateValue('RISKIFIED_CONFIGURATION_OK', true);
}
}
} catch (Exception $e) {
return;
}
}
示例14: isInWhitelistForGeolocation
protected static function isInWhitelistForGeolocation()
{
$allowed = false;
$user_ip = Tools::getRemoteAddr();
$ips = array();
// retrocompatibility
$ips_old = explode(';', Configuration::get('PS_GEOLOCATION_WHITELIST'));
if (is_array($ips_old) && count($ips_old)) {
foreach ($ips_old as $ip) {
$ips = array_merge($ips, explode("\n", $ip));
}
}
$ips = array_map('trim', $ips);
if (is_array($ips) && count($ips)) {
foreach ($ips as $ip) {
if (!empty($ip) && preg_match('/^' . $ip . '.*/', $user_ip)) {
$allowed = true;
}
}
}
return $allowed;
}
示例15: setNewConnection
public static function setNewConnection($cookie)
{
if (isset($_SERVER['HTTP_USER_AGENT']) and preg_match('/BotLink|ahoy|AlkalineBOT|anthill|appie|arale|araneo|AraybOt|ariadne|arks|ATN_Worldwide|Atomz|bbot|Bjaaland|Ukonline|borg\\-bot\\/0\\.9|boxseabot|bspider|calif|christcrawler|CMC\\/0\\.01|combine|confuzzledbot|CoolBot|cosmos|Internet Cruiser Robot|cusco|cyberspyder|cydralspider|desertrealm, desert realm|digger|DIIbot|grabber|downloadexpress|DragonBot|dwcp|ecollector|ebiness|elfinbot|esculapio|esther|fastcrawler|FDSE|FELIX IDE|ESI|fido|H�m�h�kki|KIT\\-Fireball|fouineur|Freecrawl|gammaSpider|gazz|gcreep|golem|googlebot|griffon|Gromit|gulliver|gulper|hambot|havIndex|hotwired|htdig|iajabot|INGRID\\/0\\.1|Informant|InfoSpiders|inspectorwww|irobot|Iron33|JBot|jcrawler|Teoma|Jeeves|jobo|image\\.kapsi\\.net|KDD\\-Explorer|ko_yappo_robot|label\\-grabber|larbin|legs|Linkidator|linkwalker|Lockon|logo_gif_crawler|marvin|mattie|mediafox|MerzScope|NEC\\-MeshExplorer|MindCrawler|udmsearch|moget|Motor|msnbot|muncher|muninn|MuscatFerret|MwdSearch|sharp\\-info\\-agent|WebMechanic|NetScoop|newscan\\-online|ObjectsSearch|Occam|Orbsearch\\/1\\.0|packrat|pageboy|ParaSite|patric|pegasus|perlcrawler|phpdig|piltdownman|Pimptrain|pjspider|PlumtreeWebAccessor|PortalBSpider|psbot|Getterrobo\\-Plus|Raven|RHCS|RixBot|roadrunner|Robbie|robi|RoboCrawl|robofox|Scooter|Search\\-AU|searchprocess|Senrigan|Shagseeker|sift|SimBot|Site Valet|skymob|SLCrawler\\/2\\.0|slurp|ESI|snooper|solbot|speedy|spider_monkey|SpiderBot\\/1\\.0|spiderline|nil|suke|http:\\/\\/www\\.sygol\\.com|tach_bw|TechBOT|templeton|titin|topiclink|UdmSearch|urlck|Valkyrie libwww\\-perl|verticrawl|Victoria|void\\-bot|Voyager|VWbot_K|crawlpaper|wapspider|WebBandit\\/1\\.0|webcatcher|T\\-H\\-U\\-N\\-D\\-E\\-R\\-S\\-T\\-O\\-N\\-E|WebMoose|webquest|webreaper|webs|webspider|WebWalker|wget|winona|whowhere|wlm|WOLP|WWWC|none|XGET|Nederland\\.zoek/i', $_SERVER['HTTP_USER_AGENT'])) {
// This is a bot and we have to retrieve its connection ID
if ($id_connections = Db::getInstance()->getValue('
SELECT `id_connections` FROM `' . _DB_PREFIX_ . 'connections` c
WHERE ip_address = ' . ip2long(Tools::getRemoteAddr()) . '
AND DATE_ADD(c.`date_add`, INTERVAL 30 MINUTE) > \'' . pSQL(date('Y-m-d H:i:00')) . '\'
ORDER BY c.`date_add` DESC')) {
$cookie->id_connections = (int) $id_connections;
return Page::getCurrentId();
}
}
// A new connection is created if the guest made no actions during 30 minutes
$result = Db::getInstance()->getRow('
SELECT c.`id_guest`
FROM `' . _DB_PREFIX_ . 'connections` c
WHERE c.`id_guest` = ' . (int) $cookie->id_guest . '
AND DATE_ADD(c.`date_add`, INTERVAL 30 MINUTE) > \'' . pSQL(date('Y-m-d H:i:00')) . '\'
ORDER BY c.`date_add` DESC');
if (!$result['id_guest'] and (int) $cookie->id_guest) {
// The old connections details are removed from the database in order to spare some memory
Connection::cleanConnectionsPages();
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$arrayUrl = parse_url($referer);
if (!isset($arrayUrl['host']) or preg_replace('/^www./', '', $arrayUrl['host']) == preg_replace('/^www./', '', Tools::getHttpHost(false, false))) {
$referer = '';
}
$connection = new Connection();
$connection->id_guest = (int) $cookie->id_guest;
$connection->id_page = Page::getCurrentId();
$connection->ip_address = Tools::getRemoteAddr() ? ip2long(Tools::getRemoteAddr()) : '';
if (Validate::isAbsoluteUrl($referer)) {
$connection->http_referer = $referer;
}
$connection->add();
$cookie->id_connections = $connection->id;
return $connection->id_page;
}
}