Debug v22
This commit is contained in:
parent
37f7b7fa02
commit
765caf894b
3 changed files with 174 additions and 171 deletions
|
|
@ -93,12 +93,6 @@ $options['search_source_dolistore'] = getDolGlobalInt('MAIN_ENABLE_EXTERNALMODUL
|
|||
// MAIN_ENABLE_EXTERNALMODULES_COMMUNITY is 1 if we enabled the community modules
|
||||
$options['search_source_github'] = getDolGlobalInt('MAIN_ENABLE_EXTERNALMODULES_COMMUNITY');
|
||||
|
||||
//$remotestore = new Dolistore(false);
|
||||
$remotestore = new ExternalModules();
|
||||
if ($mode == 'marketplace') {
|
||||
$remotestore->loadRemoteSources();
|
||||
}
|
||||
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
|
@ -164,6 +158,13 @@ if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) {
|
|||
$allowonlineinstall = false;
|
||||
}
|
||||
|
||||
//$remotestore = new Dolistore(false);
|
||||
$remotestore = new ExternalModules();
|
||||
if ($mode == 'marketplace') {
|
||||
// Make remote calls
|
||||
$remotestore->loadRemoteSources();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
|
|
@ -358,30 +359,6 @@ if ($action == 'install' && $allowonlineinstall) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (!$error) {
|
||||
if (GETPOST('checkforcompliance')) {
|
||||
$dir = $dirins;
|
||||
$file = $modulenameval;
|
||||
// $installedmodule
|
||||
try {
|
||||
$res = include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error.
|
||||
$modName = substr($file, 0, dol_strlen($file) - 10);
|
||||
if ($modName) {
|
||||
if (class_exists($modName)) {
|
||||
$objMod = new $modName($db);
|
||||
'@phan-var-force DolibarrModules $objMod';
|
||||
|
||||
//var_dump($objMod);
|
||||
}
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
// Nothing done
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (!$error) {
|
||||
$searchParams = array(
|
||||
'search_keyword' => $modulenameval,
|
||||
|
|
@ -512,139 +489,141 @@ $i = 0; // is a sequencer of modules found
|
|||
$j = 0; // j is module number. Automatically affected if module number not defined.
|
||||
$modNameLoaded = array();
|
||||
|
||||
foreach ($modulesdir as $dir) {
|
||||
// Load modules attributes in arrays (name, numero, orders) from dir directory
|
||||
//print $dir."\n<br>";
|
||||
dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)");
|
||||
$handle = @opendir($dir);
|
||||
if (is_resource($handle)) {
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
//print "$i ".$file."\n<br>";
|
||||
if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') {
|
||||
$modName = substr($file, 0, dol_strlen($file) - 10);
|
||||
if ($mode == 'common' || $mode == 'commonkanban') {
|
||||
foreach ($modulesdir as $dir) {
|
||||
// Load modules attributes in arrays (name, numero, orders) from dir directory
|
||||
//print $dir."\n<br>";
|
||||
dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)");
|
||||
$handle = @opendir($dir);
|
||||
if (is_resource($handle)) {
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
//print "$i ".$file."\n<br>";
|
||||
if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') {
|
||||
$modName = substr($file, 0, dol_strlen($file) - 10);
|
||||
|
||||
if ($modName) {
|
||||
if (!empty($modNameLoaded[$modName])) { // In cache of already loaded modules ?
|
||||
$mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
|
||||
setEventMessages($mesg, null, 'warnings');
|
||||
dol_syslog($mesg, LOG_ERR);
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$res = include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error.
|
||||
if (class_exists($modName)) {
|
||||
$objMod = new $modName($db);
|
||||
'@phan-var-force DolibarrModules $objMod';
|
||||
$modNameLoaded[$modName] = $dir;
|
||||
if (!$objMod->numero > 0 && $modName != 'modUser') {
|
||||
dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR);
|
||||
}
|
||||
$j = $objMod->numero;
|
||||
|
||||
$modulequalified = 1;
|
||||
|
||||
// We discard modules according to features level (PS: if module is activated we always show it)
|
||||
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
|
||||
if ($objMod->version == 'development' && (!getDolGlobalString($const_name) && (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2))) {
|
||||
$modulequalified = 0;
|
||||
}
|
||||
if ($objMod->version == 'experimental' && (!getDolGlobalString($const_name) && (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1))) {
|
||||
$modulequalified = 0;
|
||||
}
|
||||
if (preg_match('/deprecated/', $objMod->version) && (!getDolGlobalString($const_name) && (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 0))) {
|
||||
$modulequalified = 0;
|
||||
}
|
||||
|
||||
// We discard modules according to property ->hidden
|
||||
if (!empty($objMod->hidden)) {
|
||||
$modulequalified = 0;
|
||||
}
|
||||
|
||||
if ($modulequalified > 0) {
|
||||
$publisher = dol_escape_htmltag($objMod->getPublisher());
|
||||
$external = ($objMod->isCoreOrExternalModule() == 'external');
|
||||
if ($external) {
|
||||
if ($publisher) {
|
||||
// Check if there is a logo forpublisher
|
||||
/* Do not show the company logo in combo. Make combo list dirty.
|
||||
if (!empty($objMod->editor_squarred_logo)) {
|
||||
$publisherlogoarray['external_'.$publisher] = img_picto('', $objMod->editor_squarred_logo, 'class="publisherlogoinline"');
|
||||
}
|
||||
$publisherlogo = empty($publisherlogoarray['external_'.$publisher]) ? '' : $publisherlogoarray['external_'.$publisher];
|
||||
*/
|
||||
$arrayofnatures['external_'.$publisher] = array('label' => $langs->trans("External").' - '.$publisher, 'data-html' => $langs->trans("External").' - <span class="opacitymedium inine-block valignmiddle">'.$publisher.'</span>');
|
||||
} else {
|
||||
$arrayofnatures['external_'] = array('label' => $langs->trans("External").' - ['.$langs->trans("UnknownPublishers").']');
|
||||
}
|
||||
}
|
||||
ksort($arrayofnatures);
|
||||
|
||||
// Define an array $categ with categ with at least one qualified module
|
||||
$filename[$i] = $modName;
|
||||
$modules[$modName] = $objMod;
|
||||
|
||||
// Gives the possibility to the module, to provide his own family info and position of this family
|
||||
if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) {
|
||||
$familyinfo = array_merge($familyinfo, $objMod->familyinfo);
|
||||
$familykey = key($objMod->familyinfo);
|
||||
} else {
|
||||
$familykey = $objMod->family;
|
||||
}
|
||||
'@phan-var-force string $familykey'; // if not, phan considers $familykey may be null
|
||||
|
||||
$moduleposition = ($objMod->module_position ? $objMod->module_position : '50');
|
||||
if ($objMod->isCoreOrExternalModule() == 'external' && $moduleposition < 100000) {
|
||||
// an external module should never return a value lower than '80'.
|
||||
$moduleposition = '80'; // External modules at end by default
|
||||
}
|
||||
|
||||
// Add list of warnings to show into arrayofwarnings and arrayofwarningsext
|
||||
if (!empty($objMod->warnings_activation)) {
|
||||
$arrayofwarnings[$modName] = $objMod->warnings_activation;
|
||||
}
|
||||
if (!empty($objMod->warnings_activation_ext)) {
|
||||
$arrayofwarningsext[$modName] = $objMod->warnings_activation_ext;
|
||||
}
|
||||
|
||||
$familyposition = (empty($familyinfo[$familykey]['position']) ? '0' : $familyinfo[$familykey]['position']);
|
||||
$listOfOfficialModuleGroups = array('hr', 'technic', 'interface', 'technic', 'portal', 'financial', 'crm', 'base', 'products', 'srm', 'ecm', 'projects', 'other');
|
||||
if ($external && !in_array($familykey, $listOfOfficialModuleGroups)) {
|
||||
// If module is extern and into a custom group (not into an official predefined one), it must appear at end (custom groups should not be before official groups).
|
||||
if (is_numeric($familyposition)) {
|
||||
$familyposition = sprintf("%03d", (int) $familyposition + 100);
|
||||
}
|
||||
}
|
||||
|
||||
$orders[$i] = $familyposition."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number
|
||||
|
||||
// Set categ[$i]
|
||||
$specialstring = 'unknown';
|
||||
if ($objMod->version == 'development' || $objMod->version == 'experimental') {
|
||||
$specialstring = 'expdev';
|
||||
}
|
||||
if (isset($categ[$specialstring])) {
|
||||
$categ[$specialstring]++; // Array of all different modules categories
|
||||
} else {
|
||||
$categ[$specialstring] = 1;
|
||||
}
|
||||
$j++;
|
||||
$i++;
|
||||
} else {
|
||||
dol_syslog("Module ".get_class($objMod)." not qualified");
|
||||
}
|
||||
} else {
|
||||
print info_admin("admin/modules.php Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)", 0, 0, '1', 'warning');
|
||||
if ($modName) {
|
||||
if (!empty($modNameLoaded[$modName])) { // In cache of already loaded modules ?
|
||||
$mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
|
||||
setEventMessages($mesg, null, 'warnings');
|
||||
dol_syslog($mesg, LOG_ERR);
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$res = include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error.
|
||||
if (class_exists($modName)) {
|
||||
$objMod = new $modName($db);
|
||||
'@phan-var-force DolibarrModules $objMod';
|
||||
$modNameLoaded[$modName] = $dir;
|
||||
if (!$objMod->numero > 0 && $modName != 'modUser') {
|
||||
dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR);
|
||||
}
|
||||
$j = $objMod->numero;
|
||||
|
||||
$modulequalified = 1;
|
||||
|
||||
// We discard modules according to features level (PS: if module is activated we always show it)
|
||||
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
|
||||
if ($objMod->version == 'development' && (!getDolGlobalString($const_name) && (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2))) {
|
||||
$modulequalified = 0;
|
||||
}
|
||||
if ($objMod->version == 'experimental' && (!getDolGlobalString($const_name) && (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1))) {
|
||||
$modulequalified = 0;
|
||||
}
|
||||
if (preg_match('/deprecated/', $objMod->version) && (!getDolGlobalString($const_name) && (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 0))) {
|
||||
$modulequalified = 0;
|
||||
}
|
||||
|
||||
// We discard modules according to property ->hidden
|
||||
if (!empty($objMod->hidden)) {
|
||||
$modulequalified = 0;
|
||||
}
|
||||
|
||||
if ($modulequalified > 0) {
|
||||
$publisher = dol_escape_htmltag($objMod->getPublisher());
|
||||
$external = ($objMod->isCoreOrExternalModule() == 'external');
|
||||
if ($external) {
|
||||
if ($publisher) {
|
||||
// Check if there is a logo forpublisher
|
||||
/* Do not show the company logo in combo. Make combo list dirty.
|
||||
if (!empty($objMod->editor_squarred_logo)) {
|
||||
$publisherlogoarray['external_'.$publisher] = img_picto('', $objMod->editor_squarred_logo, 'class="publisherlogoinline"');
|
||||
}
|
||||
$publisherlogo = empty($publisherlogoarray['external_'.$publisher]) ? '' : $publisherlogoarray['external_'.$publisher];
|
||||
*/
|
||||
$arrayofnatures['external_'.$publisher] = array('label' => $langs->trans("External").' - '.$publisher, 'data-html' => $langs->trans("External").' - <span class="opacitymedium inine-block valignmiddle">'.$publisher.'</span>');
|
||||
} else {
|
||||
$arrayofnatures['external_'] = array('label' => $langs->trans("External").' - ['.$langs->trans("UnknownPublishers").']');
|
||||
}
|
||||
}
|
||||
ksort($arrayofnatures);
|
||||
|
||||
// Define an array $categ with categ with at least one qualified module
|
||||
$filename[$i] = $modName;
|
||||
$modules[$modName] = $objMod;
|
||||
|
||||
// Gives the possibility to the module, to provide his own family info and position of this family
|
||||
if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) {
|
||||
$familyinfo = array_merge($familyinfo, $objMod->familyinfo);
|
||||
$familykey = key($objMod->familyinfo);
|
||||
} else {
|
||||
$familykey = $objMod->family;
|
||||
}
|
||||
'@phan-var-force string $familykey'; // if not, phan considers $familykey may be null
|
||||
|
||||
$moduleposition = ($objMod->module_position ? $objMod->module_position : '50');
|
||||
if ($objMod->isCoreOrExternalModule() == 'external' && $moduleposition < 100000) {
|
||||
// an external module should never return a value lower than '80'.
|
||||
$moduleposition = '80'; // External modules at end by default
|
||||
}
|
||||
|
||||
// Add list of warnings to show into arrayofwarnings and arrayofwarningsext
|
||||
if (!empty($objMod->warnings_activation)) {
|
||||
$arrayofwarnings[$modName] = $objMod->warnings_activation;
|
||||
}
|
||||
if (!empty($objMod->warnings_activation_ext)) {
|
||||
$arrayofwarningsext[$modName] = $objMod->warnings_activation_ext;
|
||||
}
|
||||
|
||||
$familyposition = (empty($familyinfo[$familykey]['position']) ? '0' : $familyinfo[$familykey]['position']);
|
||||
$listOfOfficialModuleGroups = array('hr', 'technic', 'interface', 'technic', 'portal', 'financial', 'crm', 'base', 'products', 'srm', 'ecm', 'projects', 'other');
|
||||
if ($external && !in_array($familykey, $listOfOfficialModuleGroups)) {
|
||||
// If module is extern and into a custom group (not into an official predefined one), it must appear at end (custom groups should not be before official groups).
|
||||
if (is_numeric($familyposition)) {
|
||||
$familyposition = sprintf("%03d", (int) $familyposition + 100);
|
||||
}
|
||||
}
|
||||
|
||||
$orders[$i] = $familyposition."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number
|
||||
|
||||
// Set categ[$i]
|
||||
$specialstring = 'unknown';
|
||||
if ($objMod->version == 'development' || $objMod->version == 'experimental') {
|
||||
$specialstring = 'expdev';
|
||||
}
|
||||
if (isset($categ[$specialstring])) {
|
||||
$categ[$specialstring]++; // Array of all different modules categories
|
||||
} else {
|
||||
$categ[$specialstring] = 1;
|
||||
}
|
||||
$j++;
|
||||
$i++;
|
||||
} else {
|
||||
dol_syslog("Module ".get_class($objMod)." not qualified");
|
||||
}
|
||||
} else {
|
||||
print info_admin("admin/modules.php Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)", 0, 0, '1', 'warning');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
} else {
|
||||
dol_syslog("htdocs/admin/modules.php: Failed to open directory ".$dir.". See permission and open_basedir option.", LOG_WARNING);
|
||||
}
|
||||
closedir($handle);
|
||||
} else {
|
||||
dol_syslog("htdocs/admin/modules.php: Failed to open directory ".$dir.". See permission and open_basedir option.", LOG_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1266,9 +1245,10 @@ if ($mode == 'marketplace') {
|
|||
print '<td></td>';
|
||||
print '</tr>';
|
||||
|
||||
$url = 'https://www.dolistore.com';
|
||||
|
||||
// Marketplace
|
||||
print '<tr class="oddeven">'."\n";
|
||||
$url = 'https://www.dolistore.com';
|
||||
print '<td class="hideonsmartphone center width150 nopaddingleftimp nopaddingrightimp"><a href="'.$url.'" target="_blank" rel="noopener noreferrer external"><img border="0" class="imgautosize imgmaxwidth100" src="'.DOL_URL_ROOT.'/theme/dolistore_logo.svg"></a></td>';
|
||||
print '<td><span class="opacitymedium">'.$langs->trans("DoliStoreDesc").'</span><br>';
|
||||
print img_picto('', 'url', 'class="pictofixedwidth"').'<a href="'.$url.'" target="_blank" rel="noopener noreferrer external">'.$url.'</a></td>';
|
||||
|
|
@ -1298,9 +1278,10 @@ if ($mode == 'marketplace') {
|
|||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$url = 'https://github.com/Dolibarr/dolibarr-community-modules';
|
||||
|
||||
// Community
|
||||
print '<tr class="oddeven">'."\n";
|
||||
$url = 'https://github.com/Dolibarr/dolibarr-community-modules';
|
||||
print '<td class="hideonsmartphone center width150 nopaddingleftimp nopaddingrightimp"><a href="'.$url.'" target="_blank" rel="noopener noreferrer external"><img border="0" class="imgautosize imgmaxwidth100" src="'.DOL_URL_ROOT.'/theme/dolibarr_logo.svg"></a></td>';
|
||||
print '<td><span class="opacitymedium">'.$langs->trans("CommunityModulesDesc").'</span><br>';
|
||||
print img_picto('', 'url', 'class="pictofixedwidth"').'<a href="'.$url.'" target="_blank" rel="noopener noreferrer external">'.$url.'</a></td>';
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ class ExternalModules
|
|||
}
|
||||
|
||||
$url .= (preg_match('/\?/', $url) ? '&' : '?').'apikey='.$this->dolistore_api_key;
|
||||
$response = getURLContent($url, 'GET', '', 1, $httpheader);
|
||||
$response = getURLContent($url, 'GET', '', 1, $httpheader, array('https'), 0, -1, 5, 5);
|
||||
|
||||
$status_code = $response['http_code'];
|
||||
$body = 'Error';
|
||||
|
|
@ -221,9 +221,24 @@ class ExternalModules
|
|||
if ($status_code == 200) {
|
||||
$body = $response['content'];
|
||||
$body = json_decode($body, true);
|
||||
$returnarray = array(
|
||||
'status_code' => $status_code,
|
||||
'response' => $body
|
||||
);
|
||||
} else {
|
||||
$returnarray = array(
|
||||
'status_code' => $status_code,
|
||||
'response' => $body
|
||||
);
|
||||
if (!empty($response['curl_error_no'])) {
|
||||
$returnarray['curl_error_no'] = $response['curl_error_no'];
|
||||
}
|
||||
if (!empty($response['curl_error_msg'])) {
|
||||
$returnarray['curl_error_msg'] = $response['curl_error_msg'];
|
||||
}
|
||||
}
|
||||
|
||||
return array('status_code' => $status_code, 'response' => $body);
|
||||
return $returnarray;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -746,6 +761,10 @@ class ExternalModules
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($request['response']['curl_error_msg'])) {
|
||||
$error_message .= ' - ' . $request['response']['curl_error_msg'];
|
||||
}
|
||||
|
||||
// Return the formatted error message
|
||||
return sprintf('This call to the API failed and returned an HTTP status of %d. That means: %s.', $request['status_code'], $error_message);
|
||||
}
|
||||
|
|
@ -1034,6 +1053,7 @@ class ExternalModules
|
|||
*/
|
||||
public function checkApiStatus()
|
||||
{
|
||||
// Call remote API
|
||||
$testRequest = $this->callApi('categories');
|
||||
|
||||
if (!isset($testRequest['response']) || !is_array($testRequest['response']) || ($testRequest['status_code'] != 200 && $testRequest['status_code'] != 201)) {
|
||||
|
|
|
|||
|
|
@ -30,17 +30,19 @@
|
|||
* - you can set MAIN_SECURITY_ANTI_SSRF_SERVER_IP to set static ip of server
|
||||
* - common local lookup ips like 127.*.*.* are automatically added
|
||||
*
|
||||
* @param string $url URL to call.
|
||||
* @param string $url URL to call.
|
||||
* @param 'POST'|'GET'|'HEAD'|'PUT'|'PUTALREADYFORMATED'|'POSTALREADYFORMATED'|'DELETE' $postorget 'POST', 'GET', 'HEAD', 'PUT', 'PUTALREADYFORMATED', 'POSTALREADYFORMATED', 'DELETE'
|
||||
* @param string $param Parameters of URL (x=value1&y=value2) or may be a formatted content with $postorget='PUTALREADYFORMATED'
|
||||
* @param int<0,1> $followlocation 0=Do not follow, 1=Follow location.
|
||||
* @param string[] $addheaders Array of string to add into header. Example: ('Accept: application/xrds+xml', ....)
|
||||
* @param string[] $allowedschemes List of schemes that are allowed ('http' + 'https' only by default)
|
||||
* @param int<0,2> $localurl 0=Only external URL are possible, 1=Only local URL, 2=Both external and local URL are allowed.
|
||||
* @param int<-1,1> $ssl_verifypeer -1=Auto (no ssl check on dev, check on prod), 0=No ssl check, 1=Always ssl check
|
||||
* @param string $param Parameters of URL (x=value1&y=value2) or may be a formatted content with $postorget='PUTALREADYFORMATED'
|
||||
* @param int<0,1> $followlocation 0=Do not follow, 1=Follow location.
|
||||
* @param string[] $addheaders Array of string to add into header. Example: ('Accept: application/xrds+xml', ....)
|
||||
* @param string[] $allowedschemes List of schemes that are allowed ('http' + 'https' only by default)
|
||||
* @param int<0,2> $localurl 0=Only external URL are possible, 1=Only local URL, 2=Both external and local URL are allowed.
|
||||
* @param int<-1,1> $ssl_verifypeer -1=Auto (no ssl check on dev, check on prod), 0=No ssl check, 1=Always ssl check
|
||||
* @param int $timeoutconnect Timeout connect
|
||||
* @param int $timeoutresponse Timeout response
|
||||
* @return array{http_code:int,content:string,curl_error_no:int,curl_error_msg:string} Returns an associative array containing the response from the server array('http_code'=>http response code, 'content'=>response, 'curl_error_no'=>errno, 'curl_error_msg'=>errmsg...)
|
||||
*/
|
||||
function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = 1, $addheaders = array(), $allowedschemes = array('http', 'https'), $localurl = 0, $ssl_verifypeer = -1)
|
||||
function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = 1, $addheaders = array(), $allowedschemes = array('http', 'https'), $localurl = 0, $ssl_verifypeer = -1, $timeoutconnect = 0, $timeoutresponse = 0)
|
||||
{
|
||||
//declaring of global variables
|
||||
global $conf;
|
||||
|
|
@ -117,8 +119,8 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation =
|
|||
}
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, getDolGlobalInt('MAIN_USE_CONNECT_TIMEOUT', 5));
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, getDolGlobalInt('MAIN_USE_RESPONSE_TIMEOUT', 30));
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeoutconnect ? $timeoutconnect : getDolGlobalInt('MAIN_USE_CONNECT_TIMEOUT', 5));
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeoutresponse ? $timeoutresponse : getDolGlobalInt('MAIN_USE_RESPONSE_TIMEOUT', 30));
|
||||
|
||||
// limit size of downloaded files.
|
||||
$maxsize = getDolGlobalInt('MAIN_SECURITY_MAXFILESIZE_DOWNLOADED');
|
||||
|
|
|
|||
Loading…
Reference in a new issue