mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 17:18:13 +01:00
Add try catch
This commit is contained in:
@@ -58,31 +58,36 @@ class DolGeoIP
|
|||||||
*/
|
*/
|
||||||
public function __construct($type, $datfile)
|
public function __construct($type, $datfile)
|
||||||
{
|
{
|
||||||
global $conf;
|
|
||||||
|
|
||||||
$geoipversion = '2'; // 'php', or geoip version '2'
|
$geoipversion = '2'; // 'php', or geoip version '2'
|
||||||
if (getDolGlobalString('GEOIP_VERSION')) {
|
if (getDolGlobalString('GEOIP_VERSION')) {
|
||||||
$geoipversion = getDolGlobalString('GEOIP_VERSION');
|
$geoipversion = getDolGlobalString('GEOIP_VERSION');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 'country') {
|
try {
|
||||||
// geoip may have been already included with PEAR
|
if ($type == 'country') {
|
||||||
if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) {
|
// geoip may have been already included with PEAR
|
||||||
if (function_exists('stream_wrapper_restore')) {
|
if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) {
|
||||||
stream_wrapper_restore('phar');
|
if (function_exists('stream_wrapper_restore')) {
|
||||||
|
stream_wrapper_restore('phar');
|
||||||
|
}
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar';
|
||||||
}
|
}
|
||||||
include_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar';
|
} elseif ($type == 'city') {
|
||||||
}
|
// geoip may have been already included with PEAR
|
||||||
} elseif ($type == 'city') {
|
if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) {
|
||||||
// geoip may have been already included with PEAR
|
if (function_exists('stream_wrapper_restore')) {
|
||||||
if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) {
|
stream_wrapper_restore('phar');
|
||||||
if (function_exists('stream_wrapper_restore')) {
|
}
|
||||||
stream_wrapper_restore('phar');
|
include_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar';
|
||||||
}
|
}
|
||||||
include_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar';
|
} else {
|
||||||
|
print 'ErrorBadParameterInConstructor';
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} catch (Exception $e) {
|
||||||
print 'ErrorBadParameterInConstructor';
|
$this->error = $e->getMessage();
|
||||||
|
$this->errorlabel = 'Exception '.$this->error;
|
||||||
|
dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user