public function test2Action() { $detect = new MobileDetect(); $deviceType = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'phone' : 'computer'; $scriptVersion = $detect->getHttpHeaders(); $mobileGrade = $detect->mobileGrade(); var_dump($deviceType . "::" . $mobileGrade); var_dump($scriptVersion); die; }
public function RegisterHook() { if (class_exists('MobileDetect') && MobileDetect::IsMobileTemplate()) { $this->AddHook('init_action', 'InitAction', 0, __CLASS__); } }
<?php if (!isset($_SESSION['app_devicetype'])) { require_once 'MobileDetect.php'; $detect = new MobileDetect(); if ($detect->isMobile() && !$detect->isTablet()) { $deviceType = 'phone'; } elseif ($detect->isTablet() && !$detect->isMobile()) { $deviceType = 'tablet'; } else { $deviceType = 'computer'; } $_SESSION['app_devicetype'] = $deviceType; } else { $deviceType = $_SESSION['app_devicetype']; } THCFrame\Events\Events::fire('plugin.mobiledetect.devicetype', array($deviceType));
/** * Проверяет является ли текущий шаблон мобильным * * @return bool */ public function IsMobileTemplate() { return MobileDetect::IsMobileTemplate(false); }
public static function generateForm() { global $cart, $cookie; $customer = new Customer((int) $cart->id_customer); $module = new Kwixo(); //For multishop if (_PS_VERSION_ < '1.5') { $kwixo = new KwixoPayment(); $customer_gender = $customer->id_gender; $male_gender = 1; $carrier_id = $cart->id_carrier; } else { $kwixo = new KwixoPayment($cart->id_shop); $gender = new Gender($customer->id_gender); $customer_gender = $gender->type; $male_gender = 0; //retrieve carrier_id in delivery string option, fix for PS 1.5 with onepagecheckout foreach ($cart->getDeliveryOption() as $delivery_string) { $carrier_id = substr($delivery_string, 0, -1); } } $mobile_detect = new MobileDetect(); $mobile = $mobile_detect->isMobile(); $control = new FianetKwixoControl(); $products = $cart->getProducts(); $invoice_address = new Address((int) $cart->id_address_invoice); $delivery_address = new Address((int) $cart->id_address_delivery); $carrier = new Carrier((int) $carrier_id); $currency = new Currency((int) $cart->id_currency); $invoice_country = new Country((int) $invoice_address->id_country); $delivery_country = new Country((int) $delivery_address->id_country); $invoice_company = $invoice_address->company == '' ? null : $invoice_address->company; $delivery_company = $delivery_address->company == '' ? null : $delivery_address->company; //Address and customer invoice $control->createInvoiceCustomer($customer_gender == $male_gender ? 'Monsieur' : 'Madame', $invoice_address->lastname, $invoice_address->firstname, $customer->email, $invoice_company, $invoice_address->phone_mobile, $invoice_address->phone); $control->createInvoiceAddress($invoice_address->address1, $invoice_address->postcode, $invoice_address->city, $invoice_country->iso_code, $invoice_address->address2); //gets the carrier kwixo type if (_PS_VERSION_ >= '1.5' && Shop::isFeatureActive()) { $carrier_type = Configuration::get('KWIXO_CARRIER_TYPE_' . (string) $carrier->id, null, null, $cart->id_shop); $carrier_speed = Configuration::get('KWIXO_CARRIER_SPEED_' . (string) $carrier->id, null, null, $cart->id_shop); } else { $carrier_type = Configuration::get('KWIXO_CARRIER_TYPE_' . (string) $carrier->id); $carrier_speed = Configuration::get('KWIXO_CARRIER_SPEED_' . (string) $carrier->id); } //if carrier type is empty, we take defaut carrier type if ($carrier_type == '0' || $carrier_type == '' || $carrier_type == false) { $carrier_type = Configuration::get('KWIXO_DEFAULT_CARRIER_TYPE'); $carrier_speed = Configuration::get('KWIXO_DEFAULT_CARRIER_SPEED'); $carrier_name = 'Transporteur'; } else { $carrier_name = $carrier->name; } switch ($carrier_type) { //if the order is to be delivered at home: element <utilisateur type="livraison"...> has to be added case '4': $control->createDeliveryCustomer($customer_gender == $male_gender ? 'Monsieur' : 'Madame', $delivery_address->lastname, $delivery_address->firstname, $customer->email, $delivery_company, $delivery_address->phone_mobile, $delivery_address->phone); $control->createDeliveryAddress($delivery_address->address1, $delivery_address->postcode, $delivery_address->city, $delivery_country->iso_code, $delivery_address->address2); //xml <infocommande> $order_details = $control->createOrderDetails($cart->id, $kwixo->getSiteid(), (string) $cart->getOrderTotal(true), $currency->iso_code, $_SERVER['REMOTE_ADDR'], date('Y-m-d H:i:s')); $kwixo_carrier = $order_details->createCarrier($carrier_name, $carrier_type, $carrier_speed); break; case '5': $order_details = $control->createOrderDetails($cart->id, $kwixo->getSiteid(), (string) $cart->getOrderTotal(true), $currency->iso_code, $_SERVER['REMOTE_ADDR'], date('Y-m-d H:i:s')); $kwixo_carrier = $order_details->createCarrier($carrier_name, $carrier_type, $carrier_speed); break; case '6': $order_details = $control->createOrderDetails($cart->id, $kwixo->getSiteid(), (string) $cart->getOrderTotal(true), $currency->iso_code, $_SERVER['REMOTE_ADDR'], date('Y-m-d H:i:s')); $socolissimoinfo = $module->getSoColissimoInfo($cart->id); $socolissimo_installed_module = Module::getInstanceByName('socolissimo'); if ($socolissimoinfo != false) { foreach ($socolissimoinfo as $info) { //get socolissimo informations $delivery_mode = $info['delivery_mode']; $firstname = $info['prfirstname']; $name = $info['prname']; $mobile_phone = $info['cephonenumber']; $company_name = $info['cecompanyname']; $email = $info['ceemail']; $address1 = $info['pradress1']; $address2 = $info['pradress2']; $address3 = $info['pradress3']; $address4 = $info['pradress4']; $zipcode = $info['przipcode']; $city = $info['prtown']; //data is retrieved differently and depending on the version of the module if ($socolissimo_installed_module->version < '2.8') { $address2 = $address1; $address1 = $name; $country = 'FR'; KwixoLogger::insertLogKwixo(__METHOD__ . " : " . __LINE__, "Module So Colissimo " . $socolissimo_installed_module->version . " détecté"); } else { $country = $info['cecountry']; } } //if delivery mode is DOM or RDV, <adresse type="livraison" ...> and <utilisateur type="livraison" ...> added if ($delivery_mode == 'DOM' || $delivery_mode == 'RDV') { $control->createDeliveryCustomer($customer_gender == $male_gender ? 'Monsieur' : 'Madame', $name, $firstname, $email, $company_name, $mobile_phone, null); $control->createDeliveryAddress($address3, $zipcode, $city, $country, $address4); $kwixo_carrier = $order_details->createCarrier($carrier_name, '4', $carrier_speed); } else { //<pointrelais> added if delivery mode is not BPR, A2P or CIT $kwixo_carrier = $order_details->createCarrier($carrier_name, '2', $carrier_speed); $drop_off_point = $kwixo_carrier->createDropOffPoint($address1, null); $drop_off_point->createAddress($address2, $zipcode, $city, $country, null); } } else { KwixoLogger::insertLogKwixo(__METHOD__ . " : " . __LINE__, "Flux incorrect : Module SoColissimo non installé ou non activé"); } break; default: $order_details = $control->createOrderDetails($cart->id, $kwixo->getSiteid(), (string) $cart->getOrderTotal(true), $currency->iso_code, $_SERVER['REMOTE_ADDR'], date('Y-m-d H:i:s')); $kwixo_carrier = $order_details->createCarrier($carrier_name, $carrier_type, $carrier_speed); if ($carrier_type == 1) { if ($module->checkShopAddress() == true) { //xml <pointrelais> $drop_off_point = $kwixo_carrier->createDropOffPoint(Configuration::get('PS_SHOP_NAME'), Configuration::get('PS_SHOP_NAME')); $drop_off_point->createAddress(Configuration::get('PS_SHOP_ADDR1'), Configuration::get('PS_SHOP_CODE'), Configuration::get('PS_SHOP_CITY'), Configuration::get('PS_SHOP_COUNTRY'), Configuration::get('PS_SHOP_ADDR2')); } else { //xml <pointrelais> $drop_off_point = $kwixo_carrier->createDropOffPoint($carrier_name, $carrier_name); $drop_off_point->createAddress($delivery_address->address1, $delivery_address->postcode, $delivery_address->city, $invoice_country->iso_code, $delivery_address->address2); } } else { //xml <pointrelais> $drop_off_point = $kwixo_carrier->createDropOffPoint($carrier_name, $carrier_name); $drop_off_point->createAddress($delivery_address->address1, $delivery_address->postcode, $delivery_address->city, $invoice_country->iso_code, $delivery_address->address2); } break; } //xml <list> $product_list = $order_details->createProductList(); $product_deliveries = array(); foreach ($products as $product) { $kwixo_categorie_id = Configuration::get('KWIXO_PRODUCT_TYPE_' . (int) $product['id_category_default']) == 0 ? Configuration::get('KWIXO_DEFAULT_PRODUCT_TYPE') : Configuration::get('KWIXO_PRODUCT_TYPE_' . (int) $product['id_category_default']); $product_reference = (isset($product['reference']) and !empty($product['reference'])) ? $product['reference'] : ((isset($product['ean13']) and !empty($product['ean13'])) ? $product['ean13'] : $product['name']); $product_list->createProduct($product['name'], str_replace("'", "", $product_reference), $kwixo_categorie_id, $product['price'], $product['cart_quantity']); $product_deliveries[] = Configuration::get('KWIXO_PRODUCT_TYPE_DELIVERY_' . (int) $product['id_category_default']); } $kwixo_delivery = $module->getKwixoDelivery($product_deliveries, $carrier->id); //xml <wallet> $date_order = date('Y-m-d H:i:s'); $wallet = $control->createWallet($date_order, $kwixo->generateDatelivr($date_order, $kwixo_delivery)); $wallet->addCrypt($kwixo->generateCrypt($control), '2.0'); //kwixo payment options //standard kwixo if (Tools::getValue('payment') == '1') { $control->createPaymentOptions('comptant', 0); } //comptant kwixo if (Tools::getValue('payment') == '2') { $control->createPaymentOptions('comptant', 1); } //credit kwixo if (Tools::getValue('payment') == '3') { $control->createPaymentOptions('credit'); } //facturable kwixo if (Tools::getValue('payment') == '4') { $control->createPaymentOptions('comptant', 1, 0); } $xml_params = new KwixoXMLParams(); $xml_params->addParam('custom', $cart->id); $xml_params->addParam('amount', $cart->getOrderTotal(true)); $xml_params->addParam('secure_key', $customer->secure_key); $xml_params->addParam('id_module', $module->name); //urlcall and urlsys link on PS 1.4 and PS 1.5 if (_PS_VERSION_ < '1.5') { $token = Tools::getAdminToken($kwixo->getSiteid() . $kwixo->getAuthkey()); $link_urlcall = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/kwixo/payment_return.php?token=' . $token; $link_urlsys = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/kwixo/push.php?token=' . $token; //returns kwixo form with auto submit return $kwixo->getTransactionForm($control, $xml_params, $link_urlsys, $link_urlcall, $mobile, KwixoForm::SUBMIT_AUTO, null); } else { $link_urlcall = Context::getContext()->link->getModuleLink('kwixo', 'urlcall'); $link_urlsys = Context::getContext()->link->getModuleLink('kwixo', 'urlsys'); //returns kwixo form with standard submit return $kwixo->getTransactionForm($control, $xml_params, $link_urlsys, $link_urlcall, $mobile, KwixoForm::SUBMIT_IMAGE, __PS_BASE_URI__ . 'modules/kwixo/img/logo_kwixo.png'); } }
/** * Detect device */ public function getPlatform() { $detect = new MobileDetect(); if ($detect->isMobile() || $detect->isTablet()) { return 'mobile'; } else { return 'pc'; } }
/** * Retrieves the appropriate theme * @return string $theme */ public function getTheme() { $theme = Cii::getConfig('theme', 'default'); // Allow for mobile devices to have a separate theme if (MobileDetect::isMobileDevice() && !Mobiledetect::isTabletDevice()) { $mobileTheme = Cii::getConfig('mobileTheme'); if ($mobileTheme != NULL && $mobileTheme != "") { $theme = $mobileTheme; } } // Allow for tablet devices to have a separate theme from desktop and mobile if (MobileDetect::isTabletDevice()) { $tabletTheme = Cii::getConfig('tabletTheme'); if ($tabletTheme != NULL && $tabletTheme != "") { $theme = $tabletTheme; } } return $theme; }
public static function generateForm() { global $cart, $cookie; $customer = new Customer((int) $cart->id_customer); //For multishop if (_PS_VERSION_ < '1.5') { $kwixo = new KwixoPayment(); $customer_gender = $customer->id_gender; $male_gender = 1; $carrier_id = $cart->id_carrier; } else { $kwixo = new KwixoPayment($cart->id_shop); $gender = new Gender($customer->id_gender); $customer_gender = $gender->type; $male_gender = 0; //retrieve carrier_id in delivery string option, fix for PS 1.5 with onepagecheckout foreach ($cart->getDeliveryOption() as $delivery_string) { $carrier_id = substr($delivery_string, 0, -1); } } $mobile_detect = new MobileDetect(); $mobile = $mobile_detect->isMobile(); $control = new FianetKwixoControl(); $products = $cart->getProducts(); $invoice_address = new Address((int) $cart->id_address_invoice); $delivery_address = new Address((int) $cart->id_address_delivery); $carrier = new Carrier((int) $carrier_id); $currency = new Currency((int) $cart->id_currency); $invoice_country = new Country((int) $invoice_address->id_country); $delivery_country = new Country((int) $delivery_address->id_country); $invoice_company = $invoice_address->company == '' ? null : $invoice_address->company; $delivery_company = $delivery_address->company == '' ? null : $delivery_address->company; //Address and customer invoice $control->createInvoiceCustomer($customer_gender == $male_gender ? 'Monsieur' : 'Madame', $invoice_address->lastname, $invoice_address->firstname, $customer->email, $invoice_company, $invoice_address->phone_mobile, $invoice_address->phone); $control->createInvoiceAddress($invoice_address->address1, $invoice_address->postcode, $invoice_address->city, $invoice_country->iso_code, $invoice_address->address2); //filter on carrier which have not address and customer delivery $types = array("1", "2", "3", "5"); //gets the carrier kwixo type if (_PS_VERSION_ >= '1.5' && Shop::isFeatureActive()) { $carrier_type = Configuration::get('KWIXO_CARRIER_TYPE_' . (string) $carrier->id, null, null, $cart->id_shop); $carrier_speed = Configuration::get('KWIXO_CARRIER_SPEED_' . (string) $carrier->id, null, null, $cart->id_shop); } else { $carrier_type = Configuration::get('KWIXO_CARRIER_TYPE_' . (string) $carrier->id); $carrier_speed = Configuration::get('KWIXO_CARRIER_SPEED_' . (string) $carrier->id); } //if carrier type is empty, we take defaut carrier type if ($carrier_type == '0' || $carrier_type == '' || $carrier_type == false) { $carrier_type = Configuration::get('KWIXO_DEFAULT_CARRIER_TYPE'); $carrier_speed = Configuration::get('KWIXO_DEFAULT_CARRIER_SPEED'); $carrier_name = 'Transporteur'; } else { $carrier_name = $carrier->name; } //if carrier type = 4, xml order have delivery address and customer if ($carrier_type == 4) { $control->createDeliveryCustomer($customer_gender == $male_gender ? 'Monsieur' : 'Madame', $delivery_address->lastname, $delivery_address->firstname, $customer->email, $delivery_company, $delivery_address->phone_mobile, $delivery_address->phone); $control->createDeliveryAddress($delivery_address->address1, $delivery_address->postcode, $delivery_address->city, $delivery_country->iso_code, $delivery_address->address2); //xml <infocommande> $order_details = $control->createOrderDetails($cart->id, $kwixo->getSiteid(), (string) $cart->getOrderTotal(true), $currency->iso_code, $_SERVER['REMOTE_ADDR'], date('Y-m-d H:i:s')); $kwixo_carrier = $order_details->createCarrier($carrier_name, $carrier_type, $carrier_speed); } elseif (in_array($carrier_type, $types)) { //xml <infocommande> $order_details = $control->createOrderDetails($cart->id, $kwixo->getSiteid(), (string) $cart->getOrderTotal(true), $currency->iso_code, $_SERVER['REMOTE_ADDR'], date('Y-m-d H:i:s')); $kwixo_carrier = $order_details->createCarrier($carrier_name, $carrier_type, $carrier_speed); if ($carrier_type == 1) { $payment = new Kwixo(); if ($payment->checkShopAddress() == true) { //xml <pointrelais> $drop_off_point = $kwixo_carrier->createDropOffPoint(Configuration::get('PS_SHOP_NAME'), Configuration::get('PS_SHOP_NAME')); $drop_off_point->createAddress(Configuration::get('PS_SHOP_ADDR1'), Configuration::get('PS_SHOP_CODE'), Configuration::get('PS_SHOP_CITY'), Configuration::get('PS_SHOP_COUNTRY'), Configuration::get('PS_SHOP_ADDR2')); } else { //xml <pointrelais> $drop_off_point = $kwixo_carrier->createDropOffPoint($carrier_name, $carrier_name); $drop_off_point->createAddress($delivery_address->address1, $delivery_address->postcode, $delivery_address->city, $invoice_country->iso_code, $delivery_address->address2); } } else { //xml <pointrelais> $drop_off_point = $kwixo_carrier->createDropOffPoint($carrier_name, $carrier_name); $drop_off_point->createAddress($delivery_address->address1, $delivery_address->postcode, $delivery_address->city, $invoice_country->iso_code, $delivery_address->address2); } } //xml <list> $product_list = $order_details->createProductList(); foreach ($products as $product) { $kwixo_categorie_id = Configuration::get('KWIXO_PRODUCT_TYPE_' . (int) $product['id_category_default']) == 0 ? Configuration::get('KWIXO_DEFAULT_PRODUCT_TYPE') : Configuration::get('KWIXO_PRODUCT_TYPE_' . (int) $product['id_category_default']); $product_reference = (isset($product['reference']) and !empty($product['reference'])) ? $product['reference'] : ((isset($product['ean13']) and !empty($product['ean13'])) ? $product['ean13'] : $product['name']); $product_list->createProduct($product['name'], $product_reference, $kwixo_categorie_id, $product['price'], $product['cart_quantity']); } //xml <wallet> $date_order = date('Y-m-d H:i:s'); $wallet = $control->createWallet($date_order, $kwixo->generateDatelivr($date_order, Configuration::get('KWIXO_DELIVERY'))); $wallet->addCrypt($kwixo->generateCrypt($control), $kwixo->getCryptversion()); //kwixo payment options //standard kwixo if (Tools::getValue('payment') == '1') { $control->createPaymentOptions('comptant', 0); } //comptant kwixo if (Tools::getValue('payment') == '2') { $control->createPaymentOptions('comptant', 1); } //credit kwixo if (Tools::getValue('payment') == '3') { $control->createPaymentOptions('credit'); } //facturable kwixo if (Tools::getValue('payment') == '4') { $control->createPaymentOptions('comptant', 1, 0); } $xml_params = new KwixoXMLParams(); $module = new Kwixo(); $xml_params->addParam('custom', $cart->id); $xml_params->addParam('amount', $cart->getOrderTotal(true)); $xml_params->addParam('secure_key', $customer->secure_key); $xml_params->addParam('id_module', $module->name); //urlcall and urlsys link on PS 1.4 and PS 1.5 if (_PS_VERSION_ < '1.5') { $token = Tools::getAdminToken($kwixo->getSiteid() . $kwixo->getAuthkey()); $link_urlcall = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/kwixo/payment_return.php?token=' . $token; $link_urlsys = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/kwixo/push.php?token=' . $token; //returns kwixo form with auto submit return $kwixo->getTransactionForm($control, $xml_params, $link_urlsys, $link_urlcall, $mobile, KwixoForm::SUBMIT_AUTO, null); } else { $link_urlcall = Context::getContext()->link->getModuleLink('kwixo', 'urlcall'); $link_urlsys = Context::getContext()->link->getModuleLink('kwixo', 'urlsys'); //returns kwixo form with standard submit return $kwixo->getTransactionForm($control, $xml_params, $link_urlsys, $link_urlcall, $mobile, KwixoForm::SUBMIT_IMAGE, __PS_BASE_URI__ . 'modules/kwixo/img/logo_kwixo.png'); } }
<?php require_once dirname(dirname(__FILE__)) . '/classes/lib/mobile-detect/MobileDetect.php'; MobileDetect::IsNeedShowMobile();
/** * Return information about user browser * * @return array Array of information ('browsername'=>,'browseros'=>,'browserversion'=>,'layout'=>(classic|phone|tablet)) */ function getBrowserInfo() { $name = 'unknown'; $version = ''; $os = 'unknown'; $phone = ''; $tablet = ''; // If phone/smartphone, we set phone os name. if (preg_match('/android/i', $_SERVER["HTTP_USER_AGENT"])) { $os = $phone = 'android'; } elseif (preg_match('/blackberry/i', $_SERVER["HTTP_USER_AGENT"])) { $os = $phone = 'blackberry'; } elseif (preg_match('/iphone/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'ios'; $phone = 'iphone'; } elseif (preg_match('/ipod/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'ios'; $phone = 'iphone'; } elseif (preg_match('/palm/i', $_SERVER["HTTP_USER_AGENT"])) { $os = $phone = 'palm'; } elseif (preg_match('/symbian/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'symbian'; $phone = 'unknown'; } elseif (preg_match('/webos/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'webos'; $phone = 'unknown'; } elseif (preg_match('/maemo/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'maemo'; $phone = 'unknown'; } elseif (preg_match('/iemobile/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'windows'; $phone = 'unkown'; } elseif (preg_match('/windows ce/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'windows'; $phone = 'unkown'; } // OS if (preg_match('/android/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'android'; } elseif (preg_match('/linux/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'linux'; } // Name if (preg_match('/firefox(\\/|\\s)([\\d\\.]*)/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name = 'firefox'; $version = $reg[2]; } elseif (preg_match('/chrome(\\/|\\s)([\\d\\.]+)/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name = 'chrome'; $version = $reg[2]; } elseif (preg_match('/chrome/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name = 'chrome'; } elseif (preg_match('/iceweasel/i', $_SERVER["HTTP_USER_AGENT"])) { $name = 'iceweasel'; $version = $reg[2]; } elseif (preg_match('/epiphany/i', $_SERVER["HTTP_USER_AGENT"])) { $name = 'epiphany'; $version = $reg[2]; } elseif ((empty($phone) || preg_match('/iphone/i', $_SERVER["HTTP_USER_AGENT"])) && preg_match('/safari(\\/|\\s)([\\d\\.]*)/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name = 'safari'; $version = $reg[2]; } elseif (preg_match('/opera(\\/|\\s)([\\d\\.]*)/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name = 'opera'; $version = $reg[2]; } elseif (preg_match('/(MSIE\\s([0-9]+\\.[0-9]))|.*(Trident\\/[0-9]+.[0-9];\\srv:([0-9]+\\.[0-9]+))/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name = 'ie'; $version = end($reg); } // MS products at end // Other $firefox = 0; if (in_array($name, array('firefox', 'iceweasel'))) { $firefox = 1; } include_once DOL_DOCUMENT_ROOT . '/core/class/mobiledetect.class.php'; $detectmobile = new MobileDetect(); $phone = $detectmobile->isMobile(); $tablet = $detectmobile->isTablet(); unset($detectmobile); // free memory return array('browsername' => $name, 'browserversion' => $version, 'browseros' => $os, 'browserfirefox' => $firefox, 'layout' => $tablet ? 'tablet' : ($phone ? 'phone' : 'classic'), 'phone' => $phone, 'tablet' => $tablet); }
require_once $mods; } foreach (glob(_MODULES . "/*.php") as $modules) { require_once $modules; } //======================================== Config $GLOBALS['CONFIG_DATABASE'] = array('host' => '192.168.75.140', 'user' => 'root', 'pwd' => 'admin888', 'dbname' => 'fxptpcn', 'port' => 3306, 'tb_prefix' => 'fx_'); //======================================= Smarty if (!defined('_SMARTY')) { define('_SMARTY', _LIBS . 'Smarty' . DS); } foreach (glob(_SMARTY . "/*.php") as $lib_smarty) { require_once $lib_smarty; } //====================================== Template $detect = new MobileDetect(); if ($detect->isMobile() || $detect->isTablet() && '192.168.75.99:86' == $_SERVER['HTTP_HOST']) { define('_DEVICE', 'mo' . DS); } else { define('_DEVICE', 'pc' . DS); } if (!defined('_SMARTY_TEMPLATE')) { define('_SMARTY_TEMPLATE', _SITE . 'template' . DS . _DEVICE); } if (!defined('_SMARTY_COMPILED')) { define('_SMARTY_COMPILED', _DATA . 'compileds' . DS . _DEVICE); } if (!defined('_SMARTY_CACHE')) { define('_SMARTY_CACHE', _DATA . 'caches' . DS . _DEVICE); } if (!defined('_UPLOAD')) {
static function IsMobile() { return class_exists('MobileDetect') && MobileDetect::IsMobileTemplate(); }
public static function IsNeedShowMobile() { if (!is_null(self::$bIsNeedShowMobile)) { return self::$bIsNeedShowMobile; } /** * Принудительно включаем мобильную версию */ if (getRequest('force-mobile', false, 'get') == 'on') { setcookie('use_mobile', 1, time() + 60 * 60 * 24 * 30, Config::Get('sys.cookie.path'), Config::Get('sys.cookie.host'), false); return self::$bIsNeedShowMobile = true; } /** * Принудительно включаем полную версию */ if (getRequest('force-mobile', false, 'get') == 'off') { setcookie('use_mobile', 0, time() + 60 * 60 * 24 * 30, Config::Get('sys.cookie.path'), Config::Get('sys.cookie.host'), false); return self::$bIsNeedShowMobile = false; } /** * Пользователь уже использует мобильную или полную версию */ if (isset($_COOKIE['use_mobile'])) { if ($_COOKIE['use_mobile']) { return self::$bIsNeedShowMobile = true; } else { return self::$bIsNeedShowMobile = false; } } /** * Запускаем авто-определение мобильного клиента */ if (self::DetectMobileDevice()) { setcookie('use_mobile', 1, time() + 60 * 60 * 24 * 30, Config::Get('sys.cookie.path'), Config::Get('sys.cookie.host'), false); return self::$bIsNeedShowMobile = true; } else { setcookie('use_mobile', 0, time() + 60 * 60 * 24 * 30, Config::Get('sys.cookie.path'), Config::Get('sys.cookie.host'), false); return self::$bIsNeedShowMobile = false; } }
</div> <div id="product-builder"> <?php $detect = new MobileDetect(); if ($detect->isMobile()) { ?> <div class="unsupported"> <h2>Unsupported Browser</h2> <p>For the most optimal user experience to customize your chocolate, please use one of the suggested web browsers below using a desktop computer rather than a mobile device.</p> <ul> <li>Chrome</li> <li>Mozilla Firefox</li> <li>Internet Explorer</li> </ul> <p>Feel free to call us at 1-866-230-7730 if you want to place your custom order with one of our friendly Customer Service Representatives.</p> <p>Or, if you need quick chocolate in bulk, please browse our bulk Grab and Go Chocolate Coins options with fast shipping by <a href="/products/category/grab_and_go">clicking here</a>.</p> </div> <?php } else { ?> <center> <div id="flashContent" style="display: none"> <a href="http://www.adobe.com/go/getflashplayer"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /> </a> </div> <!-- Include support librarys first --> <script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script> <script> var attributes = {}; attributes.id = "i1Content";
public static function isMobile() { //return true; return MobileDetect::get()->isMobile() || MobileDetect::get()->isTablet(); }
/** * Show kwixo's payment on payment page * * @param type $params * @return boolean */ public function hookPayment($params) { if (!$this->active) { return; } $total_cart = $params['cart']->getOrderTotal(true); if (_PS_VERSION_ < '1.5') { $kwixo = new KwixoPayment(); } else { $kwixo = new KwixoPayment($params['cart']->id_shop); } if ($kwixo->getStatus() == 'test') { $customer = new Customer((int) $params['cart']->id_customer); $customer_mail = $customer->email; if (Configuration::get('KWIXO_EMAILS_TEST') != '') { $mails_test = explode(',', Configuration::get('KWIXO_EMAILS_TEST')); if (!in_array($customer_mail, $mails_test)) { KwixoLogger::insertLogKwixo(__METHOD__ . " : " . __LINE__, "L'adresse {$customer_mail} n'est pas autorisée à utiliser Kwixo en test."); KwixoLogger::insertLogKwixo(__METHOD__ . " : " . __LINE__, "Liste des adresses autorisées : " . implode(', ', $mails_test)); return false; } } } $mobile_detect = new MobileDetect(); $mobile = $mobile_detect->isMobile(); $kwixo_standard = Configuration::get('KWIXO_OPTION_STANDARD') == '1' ? '1' : '0'; $kwixo_comptant = Configuration::get('KWIXO_OPTION_COMPTANT') == '1' ? '1' : '0'; $kwixo_facturable = Configuration::get('KWIXO_OPTION_FACTURABLE') == '1' ? '1' : '0'; $kwixo_credit = Configuration::get('KWIXO_OPTION_CREDIT') == '1' && $total_cart >= 150 && $total_cart <= 4000 && !$mobile ? '1' : '0'; if (version_compare(_PS_VERSION_, '1.5', '<')) { //token security $token = Tools::getAdminToken($kwixo->getSiteid() . $kwixo->getAuthkey()); $kwixo_std_link = __PS_BASE_URI__ . 'modules/' . $this->name . '/sendtoKwixo.php?payment=1&token=' . $token; $kwixo_cpt_link = __PS_BASE_URI__ . 'modules/' . $this->name . '/sendtoKwixo.php?payment=2&token=' . $token; $kwixo_credit_link = __PS_BASE_URI__ . 'modules/' . $this->name . '/sendtoKwixo.php?payment=3&token=' . $token; $kwixo_facturable_link = __PS_BASE_URI__ . 'modules/' . $this->name . '/sendtoKwixo.php?payment=4&token=' . $token; } else { $link = new Link(); $kwixo_std_link = $link->getModuleLink('kwixo', 'payment', array('payment' => '1'), true); $kwixo_cpt_link = $link->getModuleLink('kwixo', 'payment', array('payment' => '2'), true); $kwixo_credit_link = $link->getModuleLink('kwixo', 'payment', array('payment' => '3'), true); $kwixo_facturable_link = $link->getModuleLink('kwixo', 'payment', array('payment' => '4'), true); } $this->smarty->assign(array('kwixo_standard' => $kwixo_standard, 'kwixo_comptant' => $kwixo_comptant, 'kwixo_credit' => $kwixo_credit, 'kwixo_facturable' => $kwixo_facturable, 'kwixo_std_link' => $kwixo_std_link, 'kwixo_cpt_link' => $kwixo_cpt_link, 'kwixo_credit_link' => $kwixo_credit_link, 'kwixo_facturable_link' => $kwixo_facturable_link, 'url_simul' => 'https://secure.kwixo.com/credit/calculator.htm?merchantId=' . $kwixo->getSiteId() . '&amount=' . $total_cart, 'logo_kwixo_standard' => __PS_BASE_URI__ . 'modules/' . $this->name . '/img/kwixo_standard.jpg', 'logo_kwixo_comptant' => __PS_BASE_URI__ . 'modules/' . $this->name . '/img/kwixo_comptant.jpg', 'logo_kwixo_credit' => __PS_BASE_URI__ . 'modules/' . $this->name . '/img/kwixo_credit.jpg')); return $this->display(__FILE__, '/views/templates/hook/payment_short_description.tpl'); }
require_once $mods; } foreach (glob(_MODULES . "/*.php") as $modules) { require_once $modules; } //======================================== Config $GLOBALS['CONFIG_DATABASE'] = array('host' => '192.168.75.140', 'user' => 'root', 'pwd' => 'admin888', 'dbname' => 'fxptpcn', 'port' => 3306, 'tb_prefix' => 'fx_'); //======================================= Smarty if (!defined('_SMARTY')) { define('_SMARTY', _LIBS . 'Smarty' . DS); } foreach (glob(_SMARTY . "/*.php") as $lib_smarty) { require_once $lib_smarty; } //====================================== Template $detect = new MobileDetect(); if ($detect->isMobile() || $detect->isTablet()) { header("Location: http://192.168.75.99:86/"); exit; } if ('192.168.75.99:86' == $_SERVER['HTTP_HOST']) { define('_DEVICE', 'mo' . DS); } else { define('_DEVICE', 'pc' . DS); } if (!defined('_SMARTY_TEMPLATE')) { define('_SMARTY_TEMPLATE', _SITE . 'template' . DS . _DEVICE); } if (!defined('_SMARTY_COMPILED')) { define('_SMARTY_COMPILED', _DATA . 'compileds' . DS . _DEVICE); }
*/ set_include_path(implode(PATH_SEPARATOR, array(get_include_path(), CORE_PATH))); set_include_path(implode(PATH_SEPARATOR, array(get_include_path(), FCK_PATH))); set_include_path(implode(PATH_SEPARATOR, array(get_include_path(), MOBILE_DETECT_PATH))); /** * Autoloader */ function sf_autoloader($class) { include $class . '.class.php'; } spl_autoload_register('sf_autoloader'); /** * detect mobile */ $detect = new MobileDetect(); $deviceType = $detect->isMobile() ? $detect->isTablet() ? TABLET : PHONE : COMPUTER; switch ($deviceType) { case TABLET: header("location:" . MOBILE_URL); break; case PHONE: header("location:" . MOBILE_URL); break; case COMPUTER: break; default: break; } /** * a new registry object
/** * Инициализация */ public function LangInitStart() { if (MobileDetect::IsMobileTemplate()) { Config::Set('view.skin', Config::Get('plugin.mobiletpl.template')); } }