* @copyright 2016-2017 GFI Informatique, 2016-2017 TNT * @license https://opensource.org/licenses/MIT MIT License */ require_once _PS_MODULE_DIR_.'tntofficiel/tntofficiel.php'; require_once _PS_MODULE_DIR_.'tntofficiel/libraries/TNTOfficiel_PasswordManager.php'; class TNTOfficiel_SysCheck { public static function getPHPConfig() { $arrUser = posix_getpwuid(posix_geteuid()); $arrEnv = array( 'http_proxy' => getenv('http_proxy'), 'https_proxy' => getenv('https_proxy'), 'ftp_proxy' => getenv('ftp_proxy') ); $arrPHPConstants = array( 'PHP_OS' => PHP_OS, 'PHP_VERSION' => PHP_VERSION, 'PHP_SAPI' => PHP_SAPI, 'PHP_INT_SIZE (bits)' => PHP_INT_SIZE * 8 ); $arrPHPExtensions = array_intersect_key(array_flip(get_loaded_extensions()), array( 'curl' => true, 'session' => true, 'mcrypt' => true, 'mhash' => true, 'mbstring' => true, 'iconv' => true, 'zip' => true, 'zlib' => true, 'dom' => true, 'xml' => true, 'SimpleXML' => true, 'Zend OPcache' => true, 'ionCube Loader' => true )); $arrPHPConfiguration = array_intersect_key(ini_get_all(null, false), array( // php 'magic_quotes' => 'Off', 'magic_quotes_gpc' => 'Off', 'max_input_vars' => '8192', // core - file uploads 'upload_max_filesize' => '4M', // core - language options 'disable_functions' => '', 'disable_classes' => '', // core - paths and directories 'open_basedir' => '', // core - data handling 'register_globals' => 'Off', // safe mode 'safe_mode' => '', 'safe_mode_gid' => '', 'safe_mode_exec_dir' => '', 'safe_mode_include_dir' => '', // filesystem 'allow_url_fopen' => 'On', 'allow_url_include' => 'Off', 'default_socket_timeout' => '60', // opcache 'opcache.enable' => 'true' )); if (array_key_exists('open_basedir', $arrPHPConfiguration)) { $arrPHPConfiguration['open_basedir'] = explode(PATH_SEPARATOR, $arrPHPConfiguration['open_basedir']); } return array( 'user' => $arrUser, 'env' => $arrEnv, 'constants' => $arrPHPConstants, 'extensions' => $arrPHPExtensions, 'configuration' => $arrPHPConfiguration ); } public static function getPSConfig() { //$__constants = get_defined_constants(true); $arrPSConstant = array( '_PS_VERSION_' => _PS_VERSION_, '_PS_JQUERY_VERSION_' => _PS_JQUERY_VERSION_, '_PS_MODE_DEV_' => _PS_MODE_DEV_, '_PS_DEBUG_PROFILING_' => _PS_DEBUG_PROFILING_, '_PS_MAGIC_QUOTES_GPC_' => _PS_MAGIC_QUOTES_GPC_, '_PS_USE_SQL_SLAVE_' => _PS_USE_SQL_SLAVE_, '_PS_CACHE_ENABLED_' => _PS_CACHE_ENABLED_, '_PS_CACHING_SYSTEM_' => _PS_CACHING_SYSTEM_, '_PS_DEFAULT_THEME_NAME_' => _PS_DEFAULT_THEME_NAME_, '_PS_THEME_DIR_' => _PS_THEME_DIR_, '_PS_THEME_OVERRIDE_DIR_' => _PS_THEME_OVERRIDE_DIR_, '_PS_THEME_MOBILE_DIR_' => _PS_THEME_MOBILE_DIR_, '_PS_THEME_MOBILE_OVERRIDE_DIR_' => _PS_THEME_MOBILE_OVERRIDE_DIR_, '_PS_THEME_TOUCHPAD_DIR_' => _PS_THEME_MOBILE_OVERRIDE_DIR_ ); $arrPSConfig = Configuration::getMultiple(array( // TNT 'TNT_CARRIER_ACTIVATED', 'TNT_CARRIER_ID', 'TNT_CARRIER_USERNAME', 'TNT_CARRIER_ACCOUNT', 'TNT_CARRIER_PASSWORD', 'TNT_CARRIER_PICKUP_NUMBER_SHOW', 'TNT_GOOGLE_MAP_API_KEY', 'TNT_CARRIER_MAX_PACKAGE_B2B', 'TNT_CARRIER_MAX_PACKAGE_B2C', 'TNT_CARRIER_ASSOCIATIONS', 'TNT_CARRIER_MIDDLEWARE_URL', 'TNT_CARRIER_MIDDLEWARE_SHORT_URL', 'TNT_CARRIER_SOAP_WSDL', 'TNT_CARRIER_ADDRESS_EMAIL', 'TNT_CARRIER_ADDRESS_PHONE', 'TNT_CARRIER_ADDRESS_BUILDING', 'TNT_CARRIER_ADDRESS_INTERCOM', 'TNT_CARRIER_ADDRESS_FLOOR', 'PS_DISABLE_OVERRIDES', 'PS_MULTISHOP_FEATURE_ACTIVE', 'PS_STOCK_MANAGEMENT', 'PS_ADVANCED_STOCK_MANAGEMENT', 'PS_ALLOW_MULTISHIPPING', 'PS_ORDER_PROCESS_TYPE', 'PS_SSL_ENABLED', 'PS_SSL_ENABLED_EVERYWHERE', 'PS_LANG_DEFAULT', 'PS_SHOP_NAME', 'PS_SHOP_EMAIL', 'PS_SHOP_PHONE', 'PS_DISTANCE_UNIT' )); return array( 'constants' => $arrPSConstant, 'configuration' => $arrPSConfig ); } public static function getShopContext() { $flagShopContext = Shop::getContext(); $arrConstShopContext = array(); if ($flagShopContext & Shop::CONTEXT_SHOP) { $arrConstShopContext[] = 'Shop::CONTEXT_SHOP'; } if ($flagShopContext & Shop::CONTEXT_GROUP) { $arrConstShopContext[] = 'Shop::CONTEXT_GROUP'; } if ($flagShopContext & Shop::CONTEXT_ALL) { $arrConstShopContext[] = 'Shop::CONTEXT_ALL'; } return array( 'Context::getContext()->shop' => Context::getContext()->shop, 'Shop::getContext()' => $arrConstShopContext, 'Shop::isFeatureActive()' => Shop::isFeatureActive(), 'Shop::getContextShopGroupID(true)' => Shop::getContextShopGroupID(true), 'Shop::getContextShopID(true)' => Shop::getContextShopID(true) ); } public static function getModule() { $objModule = Module::getInstanceByName(TNTOfficiel::MODULE_NAME); return array( 'Module::isInstalled()' => Module::isInstalled(TNTOfficiel::MODULE_NAME), 'Module::isEnabled()' => Module::isEnabled(TNTOfficiel::MODULE_NAME), 'Module::isModuleTrusted()' => Module::isModuleTrusted(TNTOfficiel::MODULE_NAME), 'Module::getInstanceByName()' => $objModule, '$objModule->isEnabledForShopContext()' => $objModule->isEnabledForShopContext() //'$objModule->getPossibleHooksList()' => $objModule->getPossibleHooksList() ); } public static function getAccount() { return array( 'MyTNTLogin' => (Configuration::get('TNT_CARRIER_USERNAME')), 'TNTAccount' => (Configuration::get('TNT_CARRIER_ACCOUNT')) //'MyTNTPassword' => TNTOfficiel_PasswordManager::decrypt(Configuration::get('TNT_CARRIER_PASSWORD')) ); } public static function cURLRequest($strURL, $arrOptions = null) { $arrcURL = array( 'options' => array( //CURLOPT_URL => $strURL, CURLOPT_SSL_VERIFYHOST => false, //CURLOPT_SSL_VERIFYPEER => false, CURLOPT_COOKIESESSION => true, // follow redirect. CURLOPT_FOLLOWLOCATION => true, // max redirection. CURLOPT_MAXREDIRS => 10, // return response with curl_exec (no direct output). CURLOPT_RETURNTRANSFER => true, // include response header? //CURLOPT_HEADER => false, // include request header? //CURLINFO_HEADER_OUT => false, // timeout for connection to the server. CURLOPT_CONNECTTIMEOUT => 3, // timout global. CURLOPT_TIMEOUT => 5 ) ); //CURLOPT_PROXY => $strProxy //CURLOPT_PROXYUSERPWD => 'user:password', //CURLOPT_PROXYAUTH => 1, //CURLOPT_PROXYPORT => 80, //CURLOPT_PROXYTYPE => CURLPROXY_HTTP, if (is_array($arrOptions)) { $arrcURL['options'] += $arrOptions; } $hdleCURL = curl_init(); foreach($arrcURL['options'] as $k => $o) { curl_setopt($hdleCURL, $k, $o); } curl_setopt($hdleCURL, CURLOPT_URL, $strURL); $arrcURL['response'] = curl_exec($hdleCURL); //CURLINFO_HEADER_OUT $arrcURL['info'] = curl_getinfo($hdleCURL); curl_close($hdleCURL); return $arrcURL; } }