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>"; } }
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; } }
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']; } } } }
/** * 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); } } }
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>'; }
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))); } }
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>' : ''); } }
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; }
/** * 默认动作 * 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' => '*****@*****.**', '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; }
/** * 写入日志 * * @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); } } }
public function getContent() { $html = ''; // Check configuration $allow_url_fopen = ini_get('allow_url_fopen'); $openssl = extension_loaded('openssl'); $curl = extension_loaded('curl'); $ping = ($allow_url_fopen || $curl) && $openssl && Tools::file_get_contents('https://developers.google.com/'); $online = in_array(Tools::getRemoteAddr(), array('127.0.0.1', '::1')) ? false : true; if (!$ping || !$online) { $html .= $this->displayError('<ul> ' . ($curl && $allow_url_fopen ? '' : '<li>' . $this->l('You are not allowed to open external URLs') . '</li>') . ' ' . ($curl && $allow_url_fopen ? '' : '<li>' . $this->l('cURL is not enabled') . '</li>') . ' ' . ($openssl ? '' : '<li>' . $this->l('OpenSSL is not enabled') . '</li>') . ' ' . ($allow_url_fopen && $openssl && !$ping ? '<li>' . $this->l('Google is unreachable (check your firewall)') . '</li>' : '') . ' ' . ($online ? '' : '<li>' . $this->l('You are currently testing your shop on a local server. In order to enjoy the full features, you need to put your shop on an online server.') . '</li>') . ' </ul>'); } $html .= ' <div class="info"> ' . $this->l('Please be aware the Google Analytics API module will only work if you either:') . ' <ul> <li>' . $this->l('have installed and configured the “Google Analytics” module') . '</li> <li>' . $this->l('or have already embedded the Google Analytics script into your shop.') . '</li> </ul> </div>'; if (Tools::getValue('PS_GAPI_VERSION')) { Configuration::updateValue('PS_GAPI_VERSION', (int) Tools::getValue('PS_GAPI_VERSION')); } $helper = new HelperOptions($this); $helper->id = $this->id; $helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->module = $this; $fields_options = array('general' => array('title' => $this->l('Which Google Analytics API version do you want to use?'), 'fields' => $fields = array('PS_GAPI_VERSION' => array('type' => 'radio', 'choices' => array(13 => $this->l('v1.3: easy to configure but deprecated and less secure'), 30 => $this->l('v3.0 with OAuth 2.0: most powerful and up-to-date version')), 'visibility' => Shop::CONTEXT_SHOP)), 'submit' => array('title' => $this->l('Save and configure')))); $helper->tpl_vars = array('currentIndex' => $helper->currentIndex); $html .= $helper->generateOptions($fields_options); if (Configuration::get('PS_GAPI_VERSION') == 30) { $html .= $this->api_3_0_getContent(); } elseif (Configuration::get('PS_GAPI_VERSION') == 13) { $html .= $this->api_1_3_getContent(); } return $html; }
/** * @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; } }
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')); } }
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; } }
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; }
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; } }
/** * Insert a new order on id_fianetsceau_state table when a new order arrives * * @param type Array */ public function hookNewOrder($params) { //insert data into id_fianetsceau_order when new order arrives $order = $params['order']; $this->insertOrder((int) $order->id, array('id_order' => (int) $order->id, 'id_fianetsceau_state' => '1', 'customer_ip_address' => Tools::getRemoteAddr(), 'date' => $order->date_add)); }
public function getContent() { global $currentIndex; $warnings = ''; if ($currentIndex == '' && _PS_VERSION_ >= 1.5) { $currentIndex = 'index.php?controller=' . Tools::safeOutput(Tools::getValue('controller')); } $currencies = DB::getInstance()->ExecuteS('SELECT c.iso_code, c.name, c.sign FROM ' . _DB_PREFIX_ . 'currency c'); if (Tools::isSubmit('submitHipayAZ')) { // Delete all configurated zones foreach ($_POST as $key => $val) { if (strncmp($key, 'HIPAY_AZ_ALL_', strlen('HIPAY_AZ_ALL_')) == 0) { $id = substr($key, -(strlen($key) - strlen('HIPAY_AZ_ALL_'))); Configuration::updateValue('HIPAY_AZ_' . $id, 'ko'); } } Db::getInstance()->Execute('DELETE FROM `' . _DB_PREFIX_ . 'module_country` WHERE `id_module` = ' . (int) $this->id); // Add the new configuration zones foreach ($_POST as $key => $val) { if (strncmp($key, 'HIPAY_AZ_', strlen('HIPAY_AZ_')) == 0) { Configuration::updateValue($key, 'ok'); } } $request = 'SELECT id_country FROM ' . _DB_PREFIX_ . 'country WHERE '; $results = Db::getInstance()->ExecuteS($request . $this->getRequestZones('id_zone')); foreach ($results as $rowValues) { Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'module_country VALUE(' . (int) $this->id . ', ' . (_PS_VERSION_ >= 1.5 ? Context::getContext()->shop->id . ',' : '') . ' ' . (int) $rowValues['id_country'] . ')'); } } elseif (Tools::isSubmit('submitHipay')) { $accounts = array(); foreach ($currencies as $currency) { if (Configuration::get('HIPAY_SITEID_' . $currency['iso_code']) != Tools::getValue('HIPAY_SITEID_' . $currency['iso_code'])) { Configuration::updateValue('HIPAY_CATEGORY_' . $currency['iso_code'], false); } Configuration::updateValue('HIPAY_PASSWORD_' . $currency['iso_code'], trim(Tools::getValue('HIPAY_PASSWORD_' . $currency['iso_code']))); Configuration::updateValue('HIPAY_SITEID_' . $currency['iso_code'], trim(Tools::getValue('HIPAY_SITEID_' . $currency['iso_code']))); Configuration::updateValue('HIPAY_CATEGORY_' . $currency['iso_code'], Tools::getValue('HIPAY_CATEGORY_' . $currency['iso_code'])); Configuration::updateValue('HIPAY_ACCOUNT_' . $currency['iso_code'], Tools::getValue('HIPAY_ACCOUNT_' . $currency['iso_code'])); if ($this->env and Tools::getValue('HIPAY_ACCOUNT_' . $currency['iso_code'])) { $accounts[Tools::getValue('HIPAY_ACCOUNT_' . $currency['iso_code'])] = 1; } } $i = 1; $dataSync = 'http://www.prestashop.com/modules/hipay.png?mode=' . ($this->env ? 'prod' : 'test'); foreach ($accounts as $account => $null) { $dataSync .= '&account' . $i++ . '=' . urlencode($account); } Configuration::updateValue('HIPAY_RATING', Tools::getValue('HIPAY_RATING')); $warnings .= $this->displayConfirmation($this->l('Configuration updated') . '<img src="' . $dataSync . '" style="float:right" />'); } elseif (Tools::isSubmit('submitHipayPaymentButton')) { Configuration::updateValue('HIPAY_PAYMENT_BUTTON', Tools::getValue('payment_button')); } // Check configuration $allow_url_fopen = ini_get('allow_url_fopen'); $openssl = extension_loaded('openssl'); $curl = extension_loaded('curl'); $ping = ($allow_url_fopen and $openssl and $fd = fsockopen('payment.hipay.com', 443) and fclose($fd)); $online = in_array(Tools::getRemoteAddr(), array('127.0.0.1', '::1')) ? false : true; $categories = true; $categoryRetrieval = true; foreach ($currencies as $currency) { $hipaySiteId = Configuration::get('HIPAY_SITEID_' . $currency['iso_code']); $hipayAccountId = Configuration::get('HIPAY_ACCOUNT_' . $currency['iso_code']); if ($hipaySiteId && $hipayAccountId && !count($this->getHipayCategories($hipaySiteId, $hipayAccountId))) { $categoryRetrieval = false; } if (Configuration::get('HIPAY_SITEID_' . $currency['iso_code']) && !Configuration::get('HIPAY_CATEGORY_' . $currency['iso_code'])) { $categories = false; } } if (!$allow_url_fopen or !$openssl or !$curl or !$ping or !$categories or !$categoryRetrieval or !$online) { $warnings .= ' <div class="warning warn"> ' . ($allow_url_fopen ? '' : '<h3>' . $this->l('You are not allowed to open external URLs') . '</h3>') . ' ' . ($curl ? '' : '<h3>' . $this->l('cURL is not enabled') . '</h3>') . ' ' . ($openssl ? '' : '<h3>' . $this->l('OpenSSL is not enabled') . '</h3>') . ' ' . (($allow_url_fopen and $openssl and !$ping) ? '<h3>' . $this->l('Cannot access payment gateway') . ' ' . HIPAY_GATEWAY_URL . ' (' . $this->l('check your firewall') . ')</h3>' : '') . ' ' . ($online ? '' : '<h3>' . $this->l('Your shop is not online') . '</h3>') . ' ' . ($categories ? '' : '<h3>' . $this->l('Hipay categories are not defined for each Site ID') . '</h3>') . ' ' . ($categoryRetrieval ? '' : '<h3>' . $this->l('Impossible to retrieve Hipay categories. Please refer to your error log for more details.') . '</h3>') . ' </div>'; } // Get subscription form value $form_values = $this->getFormValues(); // Lang of the button $iso_code = Context::getContext()->language->iso_code; if (!in_array($iso_code, array('fr', 'en', 'es', 'it'))) { $iso_code = 'en'; } $form_errors = ''; $account_created = false; if (Tools::isSubmit('create_account_action')) { $account_created = $this->processAccountCreation($form_errors); } $link = Tools::safeOutput($_SERVER['REQUEST_URI']); $form = ' <style> .hipay_label {float:none;font-weight:normal;padding:0;text-align:left;width:100%;line-height:30px} .hipay_help {vertical-align:middle} #hipay_table {border:1px solid #383838} #hipay_table td {border:1px solid #383838; width:250px; padding-left:8px; text-align:center} #hipay_table td.hipay_end {border-top:none} #hipay_table td.hipay_block {border-bottom:none} #hipay_steps_infos {border:none; margin-bottom:20px} /*#hipay_steps_infos td {border:none; width:70px; height:60px;padding-left:8px; text-align:left}*/ #hipay_steps_infos td.tab2 {border:none; width:700px;; height:60px;padding-left:8px; text-align:left} #hipay_steps_infos td.hipay_end {border-top:none} #hipay_steps_infos td.hipay_block {border-bottom:none} #hipay_steps_infos td.hipay_block {border-bottom:none} #hipay_steps_infos .account-creation input[type=text], #hipay_steps_infos .account-creation select {width: 300px; margin-bottom: 5px} .hipay_subtitle {color: #777; font-weight: bold} </style> <fieldset> <legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->l('Hipay') . '</legend> ' . $warnings . ' <p style="text-align:center;margin-bottom:30px;"><img src="../modules/' . $this->name . '/hipay.gif" /></p> <span class="hipay_subtitle">' . $this->l('The fast, simple multimedia payment solution for everyone in France and Europe!') . '</span><br /> ' . $this->l('Thanks to its adaptability and performance, Hipay has already won over 12,000 merchants and a million users. Its array of 15 of the most effective payment solutions in Europe offers your customers instant recognition and a reassuring guarantee for their consumer habits.') . ' <br /> <br />' . $this->l('Once your account is activated you will receive more details by email.') . ' <br />' . $this->l('All merchant using Prestashop can benefit from special price by contacting the following email:') . ' <strong><a href="mailto:prestashop@hipay.com">prestashop@hipay.com</a></strong><br /> <br /><strong>' . $this->l('Do not hesitate to contact us. The fees can decrease by 50%.') . '</strong><br /> <br />' . $this->l('Hipay boosts your sales Europe-wide thanks to:') . ' <ul> <li>' . $this->l('Payment solutions specific to each European country;') . '</li> <li>' . $this->l('No subscription or installation charges;') . '</li> <li>' . $this->l('Contacts with extensive experience of technical and financial issues;') . '</li> <li>' . $this->l('Dedicated customer service;') . '</li> <li>' . $this->l('Anti-fraud system and permanent monitoring for high-risk behaviour.') . '</li> </ul> ' . $this->l('Hipay is part of the Hi-Media Group (Allopass).') . '<br /><br /> ⇒ ' . $this->l('You can get a PDF documentation to configure HiPay in Prestashop') . ' : <a href="https://www.hipay.com/dl/HiPay_Wallet_Prestashop_Configuration_Guide_EN.pdf" target="_blank">English</a> - <a href="https://www.hipay.com/dl/HiPay_Wallet_Configuration_Module_Prestashop_FR.pdf" target="_blank">Français</a> </fieldset> <div class="clear"> </div> <fieldset> <legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->l('Configuration') . '</legend> ' . $this->l('The configuration of Hipay is really easy and runs into 3 steps') . '<br /><br /> <table id="hipay_steps_infos" cellspacing="0" cellpadding="0"> ' . ($account_created ? '<tr><td></td><td><div class="conf">' . $this->l('Account created!') . '</div></td></tr>' : '') . ' <tr> <td valign="top" style="padding-top:6px;"><img src="../modules/' . $this->name . '/1.png" alt="step 1" /></td> <td class="tab2">' . (Configuration::get('HIPAY_SITEID') ? '<a href="https://www.hipay.com/auth" style="color:#D9263F;font-weight:700">' . $this->l('Log in to your merchant account') . '</a><br />' : '<a id="account_creation" href="https://www.hipay.com/registration/register" style="color:#D9263F;font-weight:700"><img src="../modules/' . $this->name . '/button_' . $iso_code . '.jpg" alt="' . $this->l('Create a Hipay account') . '" title="' . $this->l('Create a Hipay account') . '" border="0" /></a> <br /><br />' . $this->l('If you already have an account you can go directly to step 2.')) . '<br /><br /> </td> </tr> <tr id="account_creation_form" style="' . (!Tools::isSubmit('create_account_action') || $account_created ? 'display: none;' : '') . '"> <td></td> <td class="tab2">'; if (!empty($form_errors)) { $form .= '<div class="warning warn">'; $form .= $form_errors; $form .= '</div>'; } $form .= ' <form class="account-creation" action="' . $currentIndex . '&configure=' . $this->name . '&token=' . Tools::safeOutput(Tools::getValue('token')) . '" method="post"> <div class="clear"><label for="email">' . $this->l('E-mail') . '</label><input type="text" value="' . $form_values['email'] . '" name="email" id="email"/></div> <div class="clear"><label for="firstname">' . $this->l('Firstname') . '</label><input type="text" value="' . $form_values['firstname'] . '" name="firstname" id="firstname"/></div> <div class="clear"><label for="lastname">' . $this->l('Lastname') . '</label><input type="text" value="' . $form_values['lastname'] . '" name="lastname" id="lastname"/></div> <div class="clear"> <label for="currency">' . $this->l('Currency') . '</label> <select name="currency" id="currency"> <option value="EUR">' . $this->l('Euro') . '</option> <option value="CAD">' . $this->l('Canadian dollar') . '</option> <option value="USD">' . $this->l('United States Dollar') . '</option> <option value="CHF">' . $this->l('Swiss franc') . '</option> <option value="AUD">' . $this->l('Australian dollar') . '</option> <option value="GBP">' . $this->l('British pound') . '</option> <option value="SEK">' . $this->l('Swedish krona') . '</option> </select> </div> <div class="clear"> <label for="business-line">' . $this->l('Business line') . '</label> <select name="business-line" id="business-line">'; foreach ($this->getBusinessLine() as $business) { if ($business->id == $form_values['business_line']) { $form .= '<option value="' . $business->id . '" selected="selected">' . $business->label . '</option>'; } else { $form .= '<option value="' . $business->id . '">' . $business->label . '</option>'; } } $form .= ' </select> </div> <div class="clear"> <label for="website-topic">' . $this->l('Website topic') . '</label> <select id="website-topic" name="website-topic"></select> </div> <div class="clear"><label for="contact-email">' . $this->l('Website contact e-mail') . '</label><input type="text" value="' . $form_values['contact_email'] . '" name="contact-email" id="contact-email"/></div> <div class="clear"><label for="website-name">' . $this->l('Website name') . '</label><input type="text" value="' . $form_values['website_name'] . '" name="website-name" id="website-name"/></div> <div class="clear"><label for="website-url">' . $this->l('Website URL') . '</label><input type="text" value="' . $form_values['website_url'] . '" name="website-url" id="website-url"/></div> <div class="clear"><label for="website-password">' . $this->l('Website merchant password') . '</label><input type="text" value="' . $form_values['password'] . '"name="website-password" id="website-password"/></div> <div class="clear"><input type="submit" name="create_account_action"/></div> </form> </td> </tr> <tr> <td><img src="../modules/' . $this->name . '/2.png" alt="step 2" /></td> <td class="tab2">' . $this->l('Activate the Hipay solution in your Prestashop, it\'s free!') . '</td> </tr> <tr><td></td><td> <form action="' . $link . '" method="post" style="padding-left:6px;"> <table id="hipay_table" cellspacing="0" cellpadding="0"> <tr> <td style=""> </td> <td style="height:40px;">' . $this->l('HiPay account') . '</td> </tr>'; foreach ($currencies as $currency) { $form .= '<tr> <td class="hipay_block"><b>' . $this->l('Configuration in') . ' ' . $currency['name'] . ' ' . $currency['sign'] . '</b></td> <td class="hipay_prod hipay_block" style="padding-left:10px"> <label class="hipay_label" for="HIPAY_ACCOUNT_' . $currency['iso_code'] . '">' . $this->l('Account number') . ' <a href="../modules/' . $this->name . '/screenshots/accountnumber.png" target="_blank"><img src="../modules/' . $this->name . '/help.png" class="hipay_help" /></a></label><br /> <input type="text" id="HIPAY_ACCOUNT_' . $currency['iso_code'] . '" name="HIPAY_ACCOUNT_' . $currency['iso_code'] . '" value="' . Tools::safeOutput(Tools::getValue('HIPAY_ACCOUNT_' . $currency['iso_code'], Configuration::get('HIPAY_ACCOUNT_' . $currency['iso_code']))) . '" /><br /> <label class="hipay_label" for="HIPAY_PASSWORD_' . $currency['iso_code'] . '">' . $this->l('Merchant password') . ' <a href="../modules/' . $this->name . '/screenshots/merchantpassword.png" target="_blank"><img src="../modules/' . $this->name . '/help.png" class="hipay_help" /></a></label><br /> <input type="text" id="HIPAY_PASSWORD_' . $currency['iso_code'] . '" name="HIPAY_PASSWORD_' . $currency['iso_code'] . '" value="' . Tools::safeOutput(Tools::getValue('HIPAY_PASSWORD_' . $currency['iso_code'], Configuration::get('HIPAY_PASSWORD_' . $currency['iso_code']))) . '" /><br /> <label class="hipay_label" for="HIPAY_SITEID_' . $currency['iso_code'] . '">' . $this->l('Site ID') . ' <a href="../modules/' . $this->name . '/screenshots/siteid.png" target="_blank"><img src="../modules/' . $this->name . '/help.png" class="hipay_help" /></a></label><br /> <input type="text" id="HIPAY_SITEID_' . $currency['iso_code'] . '" name="HIPAY_SITEID_' . $currency['iso_code'] . '" value="' . Tools::safeOutput(Tools::getValue('HIPAY_SITEID_' . $currency['iso_code'], Configuration::get('HIPAY_SITEID_' . $currency['iso_code']))) . '" /><br />'; if ($ping && ($hipaySiteId = (int) Configuration::get('HIPAY_SITEID_' . $currency['iso_code'])) && ($hipayAccountId = (int) Configuration::get('HIPAY_ACCOUNT_' . $currency['iso_code']))) { $form .= ' <label for="HIPAY_CATEGORY_' . $currency['iso_code'] . '" class="hipay_label">' . $this->l('Category') . '</label><br /> <select id="HIPAY_CATEGORY_' . $currency['iso_code'] . '" name="HIPAY_CATEGORY_' . $currency['iso_code'] . '">'; foreach ($this->getHipayCategories($hipaySiteId, $hipayAccountId) as $id => $name) { $form .= ' <option value="' . (int) $id . '" ' . (Tools::getValue('HIPAY_CATEGORY_' . $currency['iso_code'], Configuration::get('HIPAY_CATEGORY_' . $currency['iso_code'])) == $id ? 'selected="selected"' : '') . '>' . htmlentities($name, ENT_COMPAT, 'UTF-8') . '</option>'; } $form .= ' </select><br />'; } $form .= ' </td> </tr> <tr><td class="hipay_end"> </td><td class="hipay_prod hipay_end"> </td>'; $form .= '</tr>'; } $form .= '</table> <hr class="clear" /> <label for="HIPAY_RATING">' . $this->l('Authorized age group') . ' :</label> <div class="margin-form"> <select id="HIPAY_RATING" name="HIPAY_RATING"> <option value="ALL">' . $this->l('For all ages') . '</option> <option value="+12" ' . (Tools::getValue('HIPAY_RATING', Configuration::get('HIPAY_RATING')) == '+12' ? 'selected="selected"' : '') . '>' . $this->l('For ages 12 and over') . '</option> <option value="+16" ' . (Tools::getValue('HIPAY_RATING', Configuration::get('HIPAY_RATING')) == '+16' ? 'selected="selected"' : '') . '>' . $this->l('For ages 16 and over') . '</option> <option value="+18" ' . (Tools::getValue('HIPAY_RATING', Configuration::get('HIPAY_RATING')) == '+18' ? 'selected="selected"' : '') . '>' . $this->l('For ages 18 and over') . '</option> </select> </div> <hr class="clear" /> <p>' . $this->l('Notice: please verify that the currency mode you have chosen in the payment tab is compatible with your Hipay account(s).') . '</p> <input type="submit" name="submitHipay" value="' . $this->l('Update configuration') . '" class="button" style="font-weight:bold;"/> </form> </td> </tr> <tr> <td><img src="../modules/' . $this->name . '/3.png" alt="step 3" /></td> <td class="tab2">' . $this->l('Choose a set of buttons for your shop Hipay') . ' :</td> </tr> <tr> <td></td> <td> <form action="' . $currentIndex . '&configure=' . $this->name . '&token=' . Tools::safeOutput(Tools::getValue('token')) . '" method="post"> <table> <tr> <td> <input type="radio" name="payment_button" id="payment_button_be" value="be" ' . (Configuration::get('HIPAY_PAYMENT_BUTTON') == 'be' ? 'checked="checked"' : '') . '/> </td> <td> <label style="width: auto" for="payment_button_be"><img src="../modules/' . $this->name . '/payment_button/BE.png" /></label> </td> <td style="padding-left: 40px;"> <input type="radio" name="payment_button" id="payment_button_de" value="de" ' . (Configuration::get('HIPAY_PAYMENT_BUTTON') == 'de' ? 'checked="checked"' : '') . '/> </td> <td> <label style="width: auto" for="payment_button_de"><img src="../modules/' . $this->name . '/payment_button/DE.png" /></label> </td> </tr> <tr> <td> <input type="radio" name="payment_button" id="payment_button_fr" value="fr" ' . (Configuration::get('HIPAY_PAYMENT_BUTTON') == 'fr' ? 'checked="checked"' : '') . '/> </td> <td> <label style="width: auto" for="payment_button_fr"><img src="../modules/' . $this->name . '/payment_button/FR.png" /></label> </td> <td style="padding-left: 40px;"> <input type="radio" name="payment_button" id="payment_button_gb" value="gb" ' . (Configuration::get('HIPAY_PAYMENT_BUTTON') == 'gb' ? 'checked="checked"' : '') . '/> </td> <td> <label style="width: auto" for="payment_button_gb"><img src="../modules/' . $this->name . '/payment_button/GB.png" /></label> </td> </tr> <tr> <td> <input type="radio" name="payment_button" id="payment_button_it" value="it" ' . (Configuration::get('HIPAY_PAYMENT_BUTTON') == 'it' ? 'checked="checked"' : '') . '/> </td> <td> <label style="width: auto" for="payment_button_it"><img src="../modules/' . $this->name . '/payment_button/IT.png" /></label> </td> <td style="padding-left: 40px;"> <input type="radio" name="payment_button" id="payment_button_nl" value="nl" ' . (Configuration::get('HIPAY_PAYMENT_BUTTON') == 'nl' ? 'checked="checked"' : '') . '/> </td> <td> <label style="width: auto" for="payment_button_nl"><img src="../modules/' . $this->name . '/payment_button/NL.png" /></label> </td> </tr> <tr> <td> <input type="radio" name="payment_button" id="payment_button_pt" value="pt" ' . (Configuration::get('HIPAY_PAYMENT_BUTTON') == 'pt' ? 'checked="checked"' : '') . '/> </td> <td> <label style="width: auto" for="payment_button_pt"><img src="../modules/' . $this->name . '/payment_button/PT.png" /></label> </td> </tr> </table> <input type="submit" name="submitHipayPaymentButton" value="' . $this->l('Update configuration') . '" class="button" style="font-weight:bold;" /> </form> </td> </tr> </table> <script type="text/javascript"> function loadWebsiteTopic() { var locale = "' . $this->formatLanguageCode(Context::getContext()->language->iso_code) . '"; var business_line = $("#business-line").val(); $.ajax( { type: "POST", url: "' . __PS_BASE_URI__ . 'modules/hipay/ajax_websitetopic.php", data: { locale: locale, business_line: business_line, token: "' . substr(Tools::encrypt('hipay/websitetopic'), 0, 10) . '" }, success: function(result) { $("#website-topic").html(result); } }); } $("#business-line").change(function() { loadWebsiteTopic() }); loadWebsiteTopic(); </script> </fieldset> <br /> '; $form .= ' <fieldset> <legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->l('Zones restrictions') . '</legend> ' . $this->l('Select the authorized shipping zones') . ' :<br /><br /> <form action="' . $currentIndex . '&configure=hipay&token=' . Tools::safeOutput(Tools::getValue('token')) . '" method="post"> <table cellspacing="0" cellpadding="0" class="table"> <tr> <th class="center">' . $this->l('ID') . '</th> <th>' . $this->l('Zones') . '</th> <th align="center"><img src="../modules/' . $this->name . '/logo.gif" /></th> </tr> '; $result = Db::getInstance()->ExecuteS(' SELECT `id_zone`, `name` FROM ' . _DB_PREFIX_ . 'zone WHERE `active` = 1 '); foreach ($result as $rowNumber => $rowValues) { $form .= '<tr>'; $form .= '<td>' . $rowValues['id_zone'] . '</td>'; $form .= '<td>' . $rowValues['name'] . '</td>'; $chk = null; if (Configuration::get('HIPAY_AZ_' . $rowValues['id_zone']) == 'ok') { $chk = "checked "; } $form .= '<td align="center"><input type="checkbox" name="HIPAY_AZ_' . $rowValues['id_zone'] . '" value="ok" ' . $chk . '/>'; $form .= '<input type="hidden" name="HIPAY_AZ_ALL_' . $rowValues['id_zone'] . '" value="ok" /></td>'; $form .= '</tr>'; } $form .= ' </table><br> <input type="submit" name="submitHipayAZ" value="' . $this->l('Update zones') . '" class="button" style="font-weight:bold;" /> </form> </fieldset> <script type="text/javascript"> function switchHipayAccount(prod) { if (prod) {'; foreach ($currencies as $currency) { $form .= ' $("#HIPAY_ACCOUNT_' . $currency['iso_code'] . '").css("background-color", "#FFFFFF"); $("#HIPAY_PASSWORD_' . $currency['iso_code'] . '").css("background-color", "#FFFFFF"); $("#HIPAY_SITEID_' . $currency['iso_code'] . '").css("background-color", "#FFFFFF");'; } $form .= ' $(".hipay_prod").css("background-color", "#AADEAA"); $(".hipay_test").css("background-color", "transparent"); $(".hipay_prod_span").css("font-weight", "700"); $(".hipay_test_span").css("font-weight", "200"); } else {'; foreach ($currencies as $currency) { $form .= ' $("#HIPAY_ACCOUNT_' . $currency['iso_code'] . '").css("background-color", "#EEEEEE"); $("#HIPAY_PASSWORD_' . $currency['iso_code'] . '").css("background-color", "#EEEEEE"); $("#HIPAY_SITEID_' . $currency['iso_code'] . '").css("background-color", "#EEEEEE");'; } $form .= ' $(".hipay_prod").css("background-color", "transparent"); $(".hipay_test").css("background-color", "#AADEAA"); $(".hipay_prod_span").css("font-weight", "200"); $(".hipay_test_span").css("font-weight", "700"); } } switchHipayAccount(' . (int) $this->env . ');'; if (class_exists('SoapClient')) { $form .= ' $(\'#account_creation\').click(function() { $(\'#account_creation_form\').show(); return false; }); '; } $form .= ' </script>'; if ($this->ws_client == false) { return $this->displayError('To work properly the module need the Soap library to be installed.') . $form; } return $form; }
public function preProcess() { parent::preProcess(); if (self::$cookie->isLogged() and !Tools::isSubmit('ajax')) { Tools::redirect('my-account.php'); } if (Tools::getValue('create_account')) { $create_account = 1; self::$smarty->assign('email_create', 1); } if (Tools::isSubmit('SubmitCreate')) { if (!Validate::isEmail($email = Tools::getValue('email_create')) or empty($email)) { $this->errors[] = Tools::displayError('Invalid e-mail address'); } elseif (Customer::customerExists($email)) { $this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.'); $_POST['email'] = $_POST['email_create']; unset($_POST['email_create']); } else { $create_account = 1; self::$smarty->assign('email_create', Tools::safeOutput($email)); $_POST['email'] = $email; } } if (Tools::isSubmit('submitAccount') or Tools::isSubmit('submitGuestAccount')) { $create_account = 1; if (Tools::isSubmit('submitAccount')) { self::$smarty->assign('email_create', 1); } /* New Guest customer */ if (!Tools::getValue('is_new_customer', 1) and !Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) { $this->errors[] = Tools::displayError('You cannot create a guest account.'); } if (!Tools::getValue('is_new_customer', 1)) { $_POST['passwd'] = md5(time() . _COOKIE_KEY_); } if (isset($_POST['guest_email']) and $_POST['guest_email']) { $_POST['email'] = $_POST['guest_email']; } /* Preparing customer */ $customer = new Customer(); $lastnameAddress = $_POST['lastname']; $firstnameAddress = $_POST['firstname']; $_POST['lastname'] = $_POST['customer_lastname']; $_POST['firstname'] = $_POST['customer_firstname']; if (!Tools::getValue('phone') and !Tools::getValue('phone_mobile')) { $this->errors[] = Tools::displayError('You must register at least one phone number'); } if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) { $this->errors[] = Tools::displayError('Invalid date of birth'); } $customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days']; $this->errors = array_unique(array_merge($this->errors, $customer->validateControler())); /* Preparing address */ $address = new Address(); $_POST['lastname'] = $lastnameAddress; $_POST['firstname'] = $firstnameAddress; $address->id_customer = 1; $this->errors = array_unique(array_merge($this->errors, $address->validateControler())); /* US customer: normalize the address */ if ($address->id_country == Country::getByIso('US')) { include_once _PS_TAASC_PATH_ . 'AddressStandardizationSolution.php'; $normalize = new AddressStandardizationSolution(); $address->address1 = $normalize->AddressLineStandardization($address->address1); $address->address2 = $normalize->AddressLineStandardization($address->address2); } $zip_code_format = Country::getZipCodeFormat((int) Tools::getValue('id_country')); if (Country::getNeedZipCode((int) Tools::getValue('id_country'))) { if ($postcode = Tools::getValue('postcode') and $zip_code_format) { $zip_regexp = '/^' . $zip_code_format . '$/ui'; $zip_regexp = str_replace(' ', '( |)', $zip_regexp); $zip_regexp = str_replace('-', '(-|)', $zip_regexp); $zip_regexp = str_replace('N', '[0-9]', $zip_regexp); $zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp); $zip_regexp = str_replace('C', Country::getIsoById((int) Tools::getValue('id_country')), $zip_regexp); if (!preg_match($zip_regexp, $postcode)) { $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.') . '<br />' . Tools::displayError('Must be typed as follows:') . ' ' . str_replace('C', Country::getIsoById((int) Tools::getValue('id_country')), str_replace('N', '0', str_replace('L', 'A', $zip_code_format))); } } elseif ($zip_code_format) { $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is required.'); } elseif ($postcode and !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode)) { $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.'); } } if (Country::isNeedDniByCountryId($address->id_country) and (!Tools::getValue('dni') or !Validate::isDniLite(Tools::getValue('dni')))) { $this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.'); } elseif (!Country::isNeedDniByCountryId($address->id_country)) { $address->dni = NULL; } if (!sizeof($this->errors)) { if (Customer::customerExists(Tools::getValue('email'))) { $this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.'); } if (Tools::isSubmit('newsletter')) { $customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr()); $customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s')); } if (!sizeof($this->errors)) { if (!($country = new Country($address->id_country, Configuration::get('PS_LANG_DEFAULT'))) or !Validate::isLoadedObject($country)) { die(Tools::displayError()); } if ((int) $country->contains_states and !(int) $address->id_state) { $this->errors[] = Tools::displayError('This country requires a state selection.'); } else { $customer->active = 1; /* New Guest customer */ if (Tools::isSubmit('is_new_customer')) { $customer->is_guest = !Tools::getValue('is_new_customer', 1); } else { $customer->is_guest = 0; } if (!$customer->add()) { $this->errors[] = Tools::displayError('An error occurred while creating your account.'); } else { $address->id_customer = (int) $customer->id; if (!$address->add()) { $this->errors[] = Tools::displayError('An error occurred while creating your address.'); } else { if (!$customer->is_guest) { if (!Mail::Send((int) self::$cookie->id_lang, 'account', Mail::l('Welcome!'), array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd')), $customer->email, $customer->firstname . ' ' . $customer->lastname)) { $this->errors[] = Tools::displayError('Cannot send email'); } } self::$smarty->assign('confirmation', 1); self::$cookie->id_customer = (int) $customer->id; self::$cookie->customer_lastname = $customer->lastname; self::$cookie->customer_firstname = $customer->firstname; self::$cookie->passwd = $customer->passwd; self::$cookie->logged = 1; self::$cookie->email = $customer->email; self::$cookie->is_guest = !Tools::getValue('is_new_customer', 1); /* Update cart address */ self::$cart->secure_key = $customer->secure_key; self::$cart->id_address_delivery = Address::getFirstCustomerAddressId((int) $customer->id); self::$cart->id_address_invoice = Address::getFirstCustomerAddressId((int) $customer->id); self::$cart->update(); Module::hookExec('createAccount', array('_POST' => $_POST, 'newCustomer' => $customer)); if (Tools::isSubmit('ajax')) { $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'isSaved' => true, 'id_customer' => (int) self::$cookie->id_customer, 'id_address_delivery' => self::$cart->id_address_delivery, 'id_address_invoice' => self::$cart->id_address_invoice, 'token' => Tools::getToken(false)); die(Tools::jsonEncode($return)); } if ($back = Tools::getValue('back')) { Tools::redirect($back); } Tools::redirect('my-account.php'); } } } } } if (sizeof($this->errors)) { if (!Tools::getValue('is_new_customer')) { unset($_POST['passwd']); } if (Tools::isSubmit('ajax')) { $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'isSaved' => false, 'id_customer' => 0); die(Tools::jsonEncode($return)); } } } if (Tools::isSubmit('SubmitLogin')) { Module::hookExec('beforeAuthentication'); $passwd = trim(Tools::getValue('passwd')); $email = trim(Tools::getValue('email')); if (empty($email)) { $this->errors[] = Tools::displayError('E-mail address required'); } elseif (!Validate::isEmail($email)) { $this->errors[] = Tools::displayError('Invalid e-mail address'); } elseif (empty($passwd)) { $this->errors[] = Tools::displayError('Password is required'); } elseif (Tools::strlen($passwd) > 32) { $this->errors[] = Tools::displayError('Password is too long'); } elseif (!Validate::isPasswd($passwd)) { $this->errors[] = Tools::displayError('Invalid password'); } else { $customer = new Customer(); $authentication = $customer->getByEmail(trim($email), trim($passwd)); if (!$authentication or !$customer->id) { /* Handle brute force attacks */ sleep(1); $this->errors[] = Tools::displayError('Authentication failed'); } else { self::$cookie->id_compare = isset(self::$cookie->id_compare) ? self::$cookie->id_compare : CompareProduct::getIdCompareByIdCustomer($customer->id); self::$cookie->id_customer = (int) $customer->id; self::$cookie->customer_lastname = $customer->lastname; self::$cookie->customer_firstname = $customer->firstname; self::$cookie->id_default_group = $customer->id_default_group; self::$cookie->logged = 1; self::$cookie->is_guest = $customer->isGuest(); self::$cookie->passwd = $customer->passwd; self::$cookie->email = $customer->email; if (Configuration::get('PS_CART_FOLLOWING') and (empty(self::$cookie->id_cart) or Cart::getNbProducts(self::$cookie->id_cart) == 0)) { self::$cookie->id_cart = (int) Cart::lastNoneOrderedCart((int) $customer->id); } /* Update cart address */ self::$cart->id_carrier = 0; self::$cart->id_address_delivery = Address::getFirstCustomerAddressId((int) $customer->id); self::$cart->id_address_invoice = Address::getFirstCustomerAddressId((int) $customer->id); // If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated self::$cart->secure_key = $customer->secure_key; self::$cart->update(); Module::hookExec('authentication'); if (!Tools::isSubmit('ajax')) { if ($back = Tools::getValue('back')) { Tools::redirect($back); } Tools::redirect('my-account.php'); } } } if (Tools::isSubmit('ajax')) { $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'token' => Tools::getToken(false)); die(Tools::jsonEncode($return)); } } if (isset($create_account)) { /* Select the most appropriate country */ if (isset($_POST['id_country']) and is_numeric($_POST['id_country'])) { $selectedCountry = (int) $_POST['id_country']; } /* FIXME : language iso and country iso are not similar, * maybe an associative table with country an language can resolve it, * But for now it's a bug ! * @see : bug #6968 * @link:http://www.prestashop.com/bug_tracker/view/6968/ elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $array = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); if (Validate::isLanguageIsoCode($array[0])) { $selectedCountry = Country::getByIso($array[0]); if (!$selectedCountry) $selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT')); } }*/ if (!isset($selectedCountry)) { $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT'); } if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) { $countries = Carrier::getDeliveredCountries((int) self::$cookie->id_lang, true, true); } else { $countries = Country::getCountries((int) self::$cookie->id_lang, true); } self::$smarty->assign(array('countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'vat_management' => Configuration::get('VATNUMBER_MANAGEMENT'))); /* Call a hook to display more information on form */ self::$smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Module::hookExec('createAccountTop'))); } /* Generate years, months and days */ if (isset($_POST['years']) and is_numeric($_POST['years'])) { $selectedYears = (int) $_POST['years']; } $years = Tools::dateYears(); if (isset($_POST['months']) and is_numeric($_POST['months'])) { $selectedMonths = (int) $_POST['months']; } $months = Tools::dateMonths(); if (isset($_POST['days']) and is_numeric($_POST['days'])) { $selectedDays = (int) $_POST['days']; } $days = Tools::dateDays(); self::$smarty->assign(array('years' => $years, 'sl_year' => isset($selectedYears) ? $selectedYears : 0, 'months' => $months, 'sl_month' => isset($selectedMonths) ? $selectedMonths : 0, 'days' => $days, 'sl_day' => isset($selectedDays) ? $selectedDays : 0)); self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active); }
public function postProcess() { if ($id_customer_thread = (int) Tools::getValue('id_customer_thread')) { if ($id_contact = (int) Tools::getValue('id_contact')) { Db::getInstance()->execute(' UPDATE ' . _DB_PREFIX_ . 'customer_thread SET id_contact = ' . (int) $id_contact . ' WHERE id_customer_thread = ' . (int) $id_customer_thread); } if ($id_status = (int) Tools::getValue('setstatus')) { $status_array = array(1 => 'open', 2 => 'closed', 3 => 'pending1', 4 => 'pending2'); Db::getInstance()->execute(' UPDATE ' . _DB_PREFIX_ . 'customer_thread SET status = "' . $status_array[$id_status] . '" WHERE id_customer_thread = ' . (int) $id_customer_thread . ' LIMIT 1 '); } if (isset($_POST['id_employee_forward'])) { $messages = Db::getInstance()->getRow(' SELECT ct.*, cm.*, cl.name subject, CONCAT(e.firstname, \' \', e.lastname) employee_name, CONCAT(c.firstname, \' \', c.lastname) customer_name, c.firstname FROM ' . _DB_PREFIX_ . 'customer_thread ct LEFT JOIN ' . _DB_PREFIX_ . 'customer_message cm ON (ct.id_customer_thread = cm.id_customer_thread) LEFT JOIN ' . _DB_PREFIX_ . 'contact_lang cl ON (cl.id_contact = ct.id_contact AND cl.id_lang = ' . (int) $this->context->language->id . ') LEFT OUTER JOIN ' . _DB_PREFIX_ . 'employee e ON e.id_employee = cm.id_employee LEFT OUTER JOIN ' . _DB_PREFIX_ . 'customer c ON (c.email = ct.email) WHERE ct.id_customer_thread = ' . (int) Tools::getValue('id_customer_thread') . ' ORDER BY cm.date_add DESC '); $output = $this->displayMessage($messages, true, (int) Tools::getValue('id_employee_forward')); $cm = new CustomerMessage(); $cm->id_employee = (int) $this->context->employee->id; $cm->id_customer_thread = (int) Tools::getValue('id_customer_thread'); $cm->ip_address = (int) ip2long(Tools::getRemoteAddr()); $current_employee = $this->context->employee; $id_employee = (int) Tools::getValue('id_employee_forward'); $employee = new Employee($id_employee); $email = Tools::getValue('email'); $message = Tools::getValue('message_forward'); if (($error = $cm->validateField('message', $message, null, array(), true)) !== true) { $this->errors[] = $error; } elseif ($id_employee && $employee && Validate::isLoadedObject($employee)) { $params = array('{messages}' => stripslashes($output), '{employee}' => $current_employee->firstname . ' ' . $current_employee->lastname, '{comment}' => stripslashes(Tools::nl2br($_POST['message_forward'])), '{firstname}' => $employee->firstname, '{lastname}' => $employee->lastname); if (Mail::Send($this->context->language->id, 'forward_msg', Mail::l('Fwd: Customer message', $this->context->language->id), $params, $employee->email, $employee->firstname . ' ' . $employee->lastname, $current_employee->email, $current_employee->firstname . ' ' . $current_employee->lastname, null, null, _PS_MAIL_DIR_, true)) { $cm->private = 1; $cm->message = $this->l('Message forwarded to') . ' ' . $employee->firstname . ' ' . $employee->lastname . "\n" . $this->l('Comment:') . ' ' . $message; $cm->add(); } } elseif ($email && Validate::isEmail($email)) { $params = array('{messages}' => Tools::nl2br(stripslashes($output)), '{employee}' => $current_employee->firstname . ' ' . $current_employee->lastname, '{comment}' => stripslashes($_POST['message_forward'])); if (Mail::Send($this->context->language->id, 'forward_msg', Mail::l('Fwd: Customer message', $this->context->language->id), $params, $email, null, $current_employee->email, $current_employee->firstname . ' ' . $current_employee->lastname, null, null, _PS_MAIL_DIR_, true)) { $cm->message = $this->l('Message forwarded to') . ' ' . $email . "\n" . $this->l('Comment:') . ' ' . $message; $cm->add(); } } else { $this->errors[] = '<div class="alert error">' . Tools::displayError('The email address is invalid.') . '</div>'; } } if (Tools::isSubmit('submitReply')) { $ct = new CustomerThread($id_customer_thread); ShopUrl::cacheMainDomainForShop((int) $ct->id_shop); $cm = new CustomerMessage(); $cm->id_employee = (int) $this->context->employee->id; $cm->id_customer_thread = $ct->id; $cm->ip_address = (int) ip2long(Tools::getRemoteAddr()); $cm->message = Tools::getValue('reply_message'); if (($error = $cm->validateField('message', $cm->message, null, array(), true)) !== true) { $this->errors[] = $error; } elseif (isset($_FILES) && !empty($_FILES['joinFile']['name']) && $_FILES['joinFile']['error'] != 0) { $this->errors[] = Tools::displayError('An error occurred during the file upload process.'); } elseif ($cm->add()) { $file_attachment = null; if (!empty($_FILES['joinFile']['name'])) { $file_attachment['content'] = file_get_contents($_FILES['joinFile']['tmp_name']); $file_attachment['name'] = $_FILES['joinFile']['name']; $file_attachment['mime'] = $_FILES['joinFile']['type']; } $customer = new Customer($ct->id_customer); $params = array('{reply}' => Tools::nl2br(Tools::getValue('reply_message')), '{link}' => Tools::url($this->context->link->getPageLink('contact', true), 'id_customer_thread=' . (int) $ct->id . '&token=' . $ct->token), '{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname); //#ct == id_customer_thread #tc == token of thread <== used in the synchronization imap $contact = new Contact((int) $ct->id_contact, (int) $ct->id_lang); if (Validate::isLoadedObject($contact)) { $from_name = $contact->name; $from_email = $contact->email; } else { $from_name = null; $from_email = null; } if (Mail::Send((int) $ct->id_lang, 'reply_msg', sprintf(Mail::l('An answer to your message is available #ct%1$s #tc%2$s', $ct->id_lang), $ct->id, $ct->token), $params, Tools::getValue('msg_email'), null, $from_email, $from_name, $file_attachment, null, _PS_MAIL_DIR_, true)) { $ct->status = 'closed'; $ct->update(); } Tools::redirectAdmin(self::$currentIndex . '&id_customer_thread=' . (int) $id_customer_thread . '&viewcustomer_thread&token=' . Tools::getValue('token')); } else { $this->errors[] = Tools::displayError('An error occurred. Your message was not sent. Please contact your system administrator.'); } } } return parent::postProcess(); }
public function processLogin() { /* Check fields validity */ $passwd = trim(Tools::getValue('passwd')); $email = trim(Tools::getValue('email')); if (empty($email)) { $this->errors[] = Tools::displayError('Email is empty.'); } elseif (!Validate::isEmail($email)) { $this->errors[] = Tools::displayError('Invalid email address.'); } if (empty($passwd)) { $this->errors[] = Tools::displayError('The password field is blank.'); } elseif (!Validate::isPasswd($passwd)) { $this->errors[] = Tools::displayError('Invalid password.'); } if (!count($this->errors)) { // Find employee $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('The Employee does not exist, or the password provided is incorrect.'); $this->context->employee->logout(); } elseif (empty($employee_associated_shop) && !$this->context->employee->isSuperAdmin()) { $this->errors[] = Tools::displayError('This employee does not manage the shop anymore (Either the shop has been deleted or permissions have been revoked).'); $this->context->employee->logout(); } else { $this->context->employee->remote_addr = ip2long(Tools::getRemoteAddr()); // Update cookie $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 there is a valid controller name submitted, redirect to it if (isset($_POST['redirect']) && Validate::isControllerName($_POST['redirect'])) { $url = $this->context->link->getAdminLink($_POST['redirect']); } 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))); } }
/** * Display configuration form * * @params string $name Form name * @params array $fields Fields settings * * @global string $currentIndex Current URL in order to keep current Tab */ protected function _displayForm($name, $fields, $tabname, $size, $icon) { global $currentIndex; $defaultLanguage = (int) _PS_LANG_DEFAULT_; $languages = Language::getLanguages(false); $confValues = $this->getConf($fields, $languages); $divLangName = $this->getDivLang($fields); $required = false; echo ' <script type="text/javascript"> id_language = Number(' . $defaultLanguage . '); function addRemoteAddr(){ var length = $(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\').length; if (length > 0) $(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\',$(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\') +\',' . Tools::getRemoteAddr() . '\'); else $(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\',\'' . Tools::getRemoteAddr() . '\'); } </script> <form action="' . $currentIndex . '&submit' . $name . $this->table . '=1&token=' . $this->token . '" method="post" enctype="multipart/form-data"> <fieldset><legend><img src="../img/admin/' . strval($icon) . '.gif" />' . $tabname . '</legend>'; foreach ($fields as $key => $field) { /* PrestaShop demo mode */ if (_PS_MODE_DEMO_ && in_array($key, array('PS_SHOP_ENABLE', 'PS_MAINTENANCE_IP', 'PS_BASE_URI', 'PS_SSL_ENABLED'))) { echo '<div class="error">' . $this->l('This functionnality has been disabled.') . ' => ' . $field['title'] . '</div>'; continue; } /* PrestaShop demo mode*/ /* Specific line for e-mails settings */ if (get_class($this) == 'Adminemails' and $key == 'PS_MAIL_SERVER') { echo '<div id="smtp" style="display: ' . ((isset($confValues['PS_MAIL_METHOD']) and $confValues['PS_MAIL_METHOD'] == 2) ? 'block' : 'none') . ';">'; } if (isset($field['required']) and $field['required']) { $required = true; } $val = $this->getVal($confValues, $key); if (!in_array($field['type'], array('image', 'radio', 'container', 'container_end')) or isset($field['show'])) { echo '<div style="clear: both; padding-top:15px;">' . ($field['title'] ? '<label >' . str_replace(' :', ' :', $field['title']) . '</label>' : '') . '<div class="margin-form" style="padding-top:5px;">'; } /* Display the appropriate input type for each field */ switch ($field['type']) { case 'disabled': echo $field['disabled']; break; case 'select': echo ' <select name="' . $key . '"' . (isset($field['js']) === true ? ' onchange="' . $field['js'] . '"' : '') . ' id="' . $key . '">'; foreach ($field['list'] as $k => $value) { echo '<option value="' . (isset($value['cast']) ? $value['cast']($value[$field['identifier']]) : $value[$field['identifier']]) . '"' . ($val == $value[$field['identifier']] ? ' selected="selected"' : '') . '>' . $value['name'] . '</option>'; } echo ' </select>'; break; case 'selectLang': foreach ($languages as $language) { echo ' <div id="' . $key . '_' . $language['id_lang'] . '" style="margin-bottom:8px; display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left; vertical-align: top;"> <select name="' . $key . '_' . strtoupper($language['iso_code']) . '">'; foreach ($field['list'] as $k => $value) { echo '<option value="' . (isset($value['cast']) ? $value['cast']($value[$field['identifier']]) : $value[$field['identifier']]) . '"' . (htmlentities(Tools::getValue($key . '_' . strtoupper($language['iso_code']), Configuration::get($key . '_' . strtoupper($language['iso_code'])) ? Configuration::get($key . '_' . strtoupper($language['iso_code'])) : ''), ENT_COMPAT, 'UTF-8') == $value[$field['identifier']] ? ' selected="selected"' : '') . '>' . $value['name'] . '</option>'; } echo ' </select> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, $key); break; case 'bool': echo '<label class="t" for="' . $key . '_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" /></label> <input type="radio" name="' . $key . '" id="' . $key . '_on" value="1"' . ($val ? ' checked="checked"' : '') . (isset($field['js']['on']) ? $field['js']['on'] : '') . ' /> <label class="t" for="' . $key . '_on"> ' . $this->l('Yes') . '</label> <label class="t" for="' . $key . '_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" style="margin-left: 10px;" /></label> <input type="radio" name="' . $key . '" id="' . $key . '_off" value="0" ' . (!$val ? 'checked="checked"' : '') . (isset($field['js']['off']) ? $field['js']['off'] : '') . '/> <label class="t" for="' . $key . '_off"> ' . $this->l('No') . '</label>'; break; case 'radio': foreach ($field['choices'] as $cValue => $cKey) { echo '<input type="radio" name="' . $key . '" id="' . $key . $cValue . '_on" value="' . (int) $cValue . '"' . ($cValue == $val ? ' checked="checked"' : '') . (isset($field['js'][$cValue]) ? ' ' . $field['js'][$cValue] : '') . ' /><label class="t" for="' . $key . $cValue . '_on"> ' . $cKey . '</label><br />'; } echo '<br />'; break; case 'image': echo ' <table cellspacing="0" cellpadding="0" width="100%" style="text-align:left;"> <tr>'; if ($name == 'themes') { echo ' <td colspan="' . sizeof($field['list']) . '"> <b>' . $this->l('In order to use a new theme, please follow these steps:', get_class()) . '</b> <ul> <li>' . $this->l('Import your theme using this module:', get_class()) . ' <a href="index.php?tab=AdminModules&token=' . Tools::getAdminTokenLite('AdminModules') . '&filtername=themeinstallator" style="text-decoration: underline;">' . $this->l('Theme installer', get_class()) . '</a></li> <li>' . $this->l('When your theme is imported, please select the theme on this page', get_class()) . '</li> </ul> </td> </tr> <tr> '; } $i = 0; foreach ($field['list'] as $theme) { echo '<td class="center" style="width: 180px; padding:0px 20px 20px 0px;"> <input type="radio" name="' . $key . '" id="' . $key . '_' . $theme['name'] . '_on" style="vertical-align: text-bottom;" value="' . $theme['name'] . '"' . (_THEME_NAME_ == $theme['name'] ? 'checked="checked"' : '') . ' /> <label class="t" for="' . $key . '_' . $theme['name'] . '_on"> ' . Tools::strtolower($theme['name']) . '</label> <br /> <label class="t" for="' . $key . '_' . $theme['name'] . '_on"> <img src="../themes/' . $theme['name'] . '/preview.jpg" alt="' . Tools::strtolower($theme['name']) . '"> </label> </td>'; if (isset($field['max']) and ($i + 1) % $field['max'] == 0) { echo '</tr><tr>'; } $i++; } echo '</tr> </table>'; break; case 'price': $default_currency = new Currency((int) Configuration::get("PS_CURRENCY_DEFAULT")); echo $default_currency->getSign('left') . '<input type="' . $field['type'] . '" size="' . (isset($field['size']) ? (int) $field['size'] : 5) . '" name="' . $key . '" value="' . ($field['type'] == 'password' ? '' : htmlentities($val, ENT_COMPAT, 'UTF-8')) . '" />' . $default_currency->getSign('right') . ' ' . $this->l('(tax excl.)'); break; case 'textLang': foreach ($languages as $language) { echo ' <div id="' . $key . '_' . $language['id_lang'] . '" style="margin-bottom:8px; display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left; vertical-align: top;"> <input type="text" size="' . (isset($field['size']) ? (int) $field['size'] : 5) . '" name="' . $key . '_' . $language['id_lang'] . '" value="' . htmlentities($this->getVal($confValues, $key . '_' . $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, $key); break; case 'file': if (isset($field['thumb']) and $field['thumb'] and $field['thumb']['pos'] == 'before') { echo '<img src="' . $field['thumb']['file'] . '" alt="' . $field['title'] . '" title="' . $field['title'] . '" /><br />'; } echo '<input type="file" name="' . $key . '" />'; break; case 'textarea': echo '<textarea name=' . $key . ' cols="' . $field['cols'] . '" rows="' . $field['rows'] . '">' . htmlentities($val, ENT_COMPAT, 'UTF-8') . '</textarea>'; break; case 'container': echo '<div id="' . $key . '">'; break; case 'container_end': echo (isset($field['content']) === true ? $field['content'] : '') . '</div>'; break; case 'maintenance_ip': echo '<input type="text"' . (isset($field['id']) === true ? ' id="' . $field['id'] . '"' : '') . ' size="' . (isset($field['size']) ? (int) $field['size'] : 5) . '" name="' . $key . '" value="' . ($field['type'] == 'password' ? '' : htmlentities($val, ENT_COMPAT, 'UTF-8')) . '" />' . (isset($field['next']) ? ' ' . strval($field['next']) : '') . ' <a href="#" class="button" onclick="addRemoteAddr(); return false;">' . $this->l('Add my IP') . '</a>'; break; case 'limit': echo '<input type="text" size="' . (isset($field['size']) ? (int) $field['size'] : 5) . '" name="' . $key . '" value="' . ($field['type'] == 'password' ? '' : htmlentities($val, ENT_COMPAT, 'UTF-8')) . '" /> MB'; break; case 'text': default: echo '<input type="' . $field['type'] . '"' . (isset($field['id']) === true ? ' id="' . $field['id'] . '"' : '') . ' size="' . (isset($field['size']) ? (int) $field['size'] : 5) . '" name="' . $key . '" value="' . ($field['type'] == 'password' ? '' : htmlentities($val, ENT_COMPAT, 'UTF-8')) . '" />' . (isset($field['next']) ? ' ' . strval($field['next']) : ''); } echo (isset($field['required']) and $field['required'] and !in_array($field['type'], array('image', 'radio'))) ? ' <sup>*</sup>' : ''; echo isset($field['desc']) ? '<p style="clear:both">' . ((isset($field['thumb']) and $field['thumb'] and $field['thumb']['pos'] == 'after') ? '<img src="' . $field['thumb']['file'] . '" alt="' . $field['title'] . '" title="' . $field['title'] . '" style="float:left;" />' : '') . $field['desc'] . '</p>' : ''; if (!in_array($field['type'], array('image', 'radio', 'container', 'container_end')) or isset($field['show'])) { echo '</div></div>'; } } /* End of specific div for e-mails settings */ if (get_class($this) == 'Adminemails') { echo '<script type="text/javascript">if (getE(\'PS_MAIL_METHOD2_on\').checked) getE(\'smtp\').style.display = \'block\'; else getE(\'smtp\').style.display = \'none\';</script></div>'; } if (!is_writable(PS_ADMIN_DIR . '/../config/settings.inc.php') and $name == 'themes') { echo '<p><img src="../img/admin/warning.gif" alt="" /> ' . $this->l('if you change the theme, the settings.inc.php file must be writable (CHMOD 755 / 777)') . '</p>'; } echo ' <div align="center" style="margin-top: 20px;"> <input type="submit" value="' . $this->l(' Save ', 'AdminPreferences') . '" name="submit' . ucfirst($name) . $this->table . '" class="button" /> </div> ' . ($required ? '<div class="small"><sup>*</sup> ' . $this->l('Required field', 'AdminPreferences') . '</div>' : '') . ' </fieldset> </form>'; if (get_class($this) == 'AdminPreferences') { echo '<script type="text/javascript">changeCMSActivationAuthorization();</script>'; } }
protected function isLocalEnvironment() { if (isset($_SERVER['REMOTE_ADDR']) === false) { return true; } $local_ips = array('127.0.0.1', '::1'); return in_array(Tools::getRemoteAddr(), $local_ips); }
/** * isActiveDtb * * @access private * @return bool */ protected static function _isActiveDtb() { if (Configuration::get('MOD_DTB_ENABLE')) { if (in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('MOD_DTB_IP')))) { return true; } } return false; }
private function newsletterRegistration() { if (empty($_POST['email']) or !Validate::isEmail($_POST['email'])) { return $this->error = $this->l('Invalid e-mail address'); } elseif ($_POST['action'] == '1') { $registerStatus = $this->isNewsletterRegistered(pSQL($_POST['email'])); if ($registerStatus < 1) { return $this->error = $this->l('E-mail address not registered'); } elseif ($registerStatus == 1) { if (!Db::getInstance()->Execute('DELETE FROM ' . _DB_PREFIX_ . 'newsletter WHERE `email` = \'' . pSQL($_POST['email']) . '\'')) { return $this->error = $this->l('Error during unsubscription'); } return $this->valid = $this->l('Unsubscription successful'); } elseif ($registerStatus == 2) { if (!Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'customer SET `newsletter` = 0 WHERE `email` = \'' . pSQL($_POST['email']) . '\'')) { return $this->error = $this->l('Error during unsubscription'); } return $this->valid = $this->l('Unsubscription successful'); } } elseif ($_POST['action'] == '0') { $registerStatus = $this->isNewsletterRegistered(pSQL($_POST['email'])); if ($registerStatus > 0) { return $this->error = $this->l('E-mail address already registered'); } elseif ($registerStatus == -1) { global $cookie; if (!Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'newsletter (email, newsletter_date_add, ip_registration_newsletter, http_referer) VALUES (\'' . pSQL($_POST['email']) . '\', NOW(), \'' . pSQL(Tools::getRemoteAddr()) . '\', (SELECT c.http_referer FROM ' . _DB_PREFIX_ . 'connections c WHERE c.id_guest = ' . (int) $cookie->id_guest . ' ORDER BY c.date_add DESC LIMIT 1))')) { return $this->error = $this->l('Error during subscription'); } $this->sendVoucher(pSQL($_POST['email'])); return $this->valid = $this->l('Subscription successful'); } elseif ($registerStatus == 0) { if (!Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'customer SET `newsletter` = 1, newsletter_date_add = NOW(), `ip_registration_newsletter` = \'' . pSQL(Tools::getRemoteAddr()) . '\' WHERE `email` = \'' . pSQL($_POST['email']) . '\'')) { return $this->error = $this->l('Error during subscription'); } $this->sendVoucher(pSQL($_POST['email'])); return $this->valid = $this->l('Subscription successful'); } } }
function smartsendMail($sname, $semailAddr, $scomment, $slink = null) { $name = Tools::stripslashes($sname); $e_body = 'You have Received a New Comment In Your Blog Post From ' . $name . '. Comment: ' . $scomment . ' .Your Can reply Here : ' . $slink . ''; $emailAddr = Tools::stripslashes($semailAddr); $comment = Tools::stripslashes($scomment); $subject = 'New Comment Posted'; $id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $to = Configuration::get('PS_SHOP_EMAIL'); $contactMessage = "\n \t\t\t\t{$comment} \n \t\t\t\tName: {$name}\n \t\t\t\tIP: " . (version_compare(_PS_VERSION_, '1.3.0.0', '<') ? $_SERVER['REMOTE_ADDR'] : Tools::getRemoteAddr()); if (Mail::Send($id_lang, 'contact', $subject, array('{message}' => nl2br($e_body), '{email}' => $emailAddr), $to, null, $emailAddr, $name)) { return true; } }
/** * Check employee informations saved into cookie and return employee validity * * @return bool employee validity */ public function isLoggedBack() { if (!Cache::isStored('isLoggedBack' . $this->id)) { /* Employee is valid only if it can be load and if cookie password is the same as database one */ $result = $this->id && Validate::isUnsignedId($this->id) && Employee::checkPassword($this->id, Context::getContext()->cookie->passwd) && (!isset(Context::getContext()->cookie->remote_addr) || Context::getContext()->cookie->remote_addr == ip2long(Tools::getRemoteAddr()) || !Configuration::get('PS_COOKIE_CHECKIP')); Cache::store('isLoggedBack' . $this->id, $result); return $result; } return Cache::retrieve('isLoggedBack' . $this->id); }
/** * Check employee informations saved into cookie and return employee validity * * @deprecated as of version 1.5 use Employee::isLoggedBack() instead * @return boolean employee validity */ public function isLoggedBack() { Tools::displayAsDeprecated(); /* Employee is valid only if it can be load and if cookie password is the same as database one */ return $this->id_employee && Validate::isUnsignedId($this->id_employee) && Employee::checkPassword((int) $this->id_employee, $this->passwd) && (!isset($this->_content['remote_addr']) || $this->_content['remote_addr'] == ip2long(Tools::getRemoteAddr()) || !Configuration::get('PS_COOKIE_CHECKIP')); }
protected function registerGuest($email, $active = true) { $sql = 'INSERT INTO ' . _DB_PREFIX_ . 'newsletter (id_shop, id_shop_group, email, newsletter_date_add, ip_registration_newsletter, http_referer, active) VALUES (' . (int) Context::getContext()->shop->id . ', ' . (int) Context::getContext()->shop->id_shop_group . ', \'' . pSQL($email) . '\', NOW(), \'' . pSQL(Tools::getRemoteAddr()) . '\', ( SELECT c.http_referer FROM ' . _DB_PREFIX_ . 'connections c WHERE c.id_guest = ' . (int) Context::getContext()->customer->id . ' ORDER BY c.date_add DESC LIMIT 1 ), ' . (int) $active . ' )'; return Db::getInstance()->execute($sql); }
function submitAccount() { global $cookie, $errors, $smarty; $email = Tools::getValue('email'); if (empty($email) or !Validate::isEmail($email)) { $errors[] = Tools::displayError('e-mail not valid'); } elseif (!Validate::isPasswd(Tools::getValue('passwd'))) { $errors[] = Tools::displayError('invalid password'); } elseif (Customer::customerExists($email)) { $errors[] = Tools::displayError('someone has already registered with this e-mail address'); } elseif (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) { $errors[] = Tools::displayError('invalid birthday'); } else { $customer = new Customer(); if (Tools::isSubmit('newsletter')) { $customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr()); $customer->newsletter_date_add = pSQL(date('Y-m-d h:i:s')); } $customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days']; /* Customer and address, same fields, caching data */ $errors = $customer->validateControler(); $address = new Address(); $address->id_customer = 1; $errors = array_unique(array_merge($errors, $address->validateControler())); if (!sizeof($errors)) { $customer->active = 1; if (!$customer->add()) { $errors[] = Tools::displayError('an error occurred while creating your account'); } else { $address->id_customer = (int) $customer->id; if (!$address->add()) { $errors[] = Tools::displayError('an error occurred while creating your address'); } else { if (Mail::Send((int) $cookie->id_lang, 'account', Mail::l('Welcome!', (int) $cookie->id_lang), array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd')), $customer->email, $customer->firstname . ' ' . $customer->lastname)) { $smarty->assign('confirmation', 1); } $cookie->id_customer = (int) $customer->id; $cookie->customer_lastname = $customer->lastname; $cookie->customer_firstname = $customer->firstname; $cookie->passwd = $customer->passwd; $cookie->logged = 1; $cookie->email = $customer->email; Module::hookExec('createAccount', array('_POST' => $_POST, 'newCustomer' => $customer)); // Next ! $payerID = strval(Tools::getValue('payerID')); displayProcess($payerID); } } } } }