Changeset 118774 in spip-zone
- Timestamp:
- Nov 27, 2019, 10:34:56 AM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/cache_cool/trunk/cache_cool_options.php
r118628 r118774 149 149 $close = true; 150 150 if (defined('_DIR_PLUGIN_MEMOIZATION')){ 151 #spip_log('meta cache_cool_action_refresh : '.$GLOBALS['meta']['cache_cool_action_refresh'] ,'cachecool'._LOG_DEBUG);151 #spip_log('meta cache_cool_action_refresh : '.$GLOBALS['meta']['cache_cool_action_refresh']." (il y a ".($_SERVER['REQUEST_TIME']-$GLOBALS['meta']['cache_cool_action_refresh'])."s)",'cachecool'._LOG_DEBUG); 152 152 if (!isset($GLOBALS['meta']['cache_cool_action_refresh']) OR $GLOBALS['meta']['cache_cool_action_refresh']<$_SERVER['REQUEST_TIME']-86400){ 153 #spip_log('meta cache_cool_action_refresh_test : '.$GLOBALS['meta']['cache_cool_action_refresh_test']." (il y a ".($_SERVER['REQUEST_TIME']-$GLOBALS['meta']['cache_cool_action_refresh_test'])."s)",'cachecool'._LOG_DEBUG); 153 154 if (!isset($GLOBALS['meta']['cache_cool_action_refresh_test']) OR $GLOBALS['meta']['cache_cool_action_refresh_test']<$_SERVER['REQUEST_TIME']-86400){ 154 155 ecrire_meta('cache_cool_action_refresh_test',$_SERVER['REQUEST_TIME']); … … 177 178 } 178 179 } 179 else 180 else { 180 181 spip_log("cache_set('cachecool-$id') return false",'cachecool'); 182 } 181 183 } 182 184 } … … 328 330 */ 329 331 function cache_cool_async_curl($url){ 330 // Si fsockopen est possible, on lance l'url via un socket 331 // en asynchrone 332 #spip_log("cache_cool_async_curl $url","cachecool" . _LOG_DEBUG); 333 334 // methode la plus rapide : 335 // Si fsockopen est possible, on lance le cron via un socket en asynchrone 336 // si fsockopen echoue (disponibilite serveur, firewall) on essaye pas cURL 337 // car on a toutes les chances d'echouer pareil mais sans moyen de le savoir 338 // on passe direct a la methode background-image 332 339 if(function_exists('fsockopen')){ 333 340 $parts=parse_url($url); 334 $fp = @fsockopen($parts['host'],isset($parts['port'])?$parts['port']:80,$errno, $errstr, 30); 341 spip_log("cache_cool_async_curl avec fsockopen ".json_encode($parts),"cachecool" . _LOG_DEBUG); 342 switch ($parts['scheme']) { 343 case 'https': 344 $scheme = 'ssl://'; 345 $port = 443; 346 break; 347 case 'http': 348 default: 349 $scheme = ''; 350 $port = 80; 351 } 352 $fp = @fsockopen($scheme . $parts['host'], isset($parts['port']) ? $parts['port'] : $port, $errno, $errstr, 1); 335 353 if ($fp) { 354 $host_sent = $parts['host']; 355 if (isset($parts['port']) and $parts['port'] !== $port) { 356 $host_sent .= ':' . $parts['port']; 357 } 336 358 $timeout = 200; // ms 337 359 stream_set_timeout($fp, 0, $timeout * 1000); 338 360 $query = $parts['path'].($parts['query']?"?".$parts['query']:""); 339 361 $out = "GET ".$query." HTTP/1.1\r\n"; 340 $out.= "Host: ".$ parts['host']."\r\n";362 $out.= "Host: ".$host_sent."\r\n"; 341 363 $out.= "Connection: Close\r\n\r\n"; 342 364 fwrite($fp, $out); … … 354 376 } 355 377 } 356 357 378 // ici lancer le cron par un CURL asynchrone si CURL est present 358 if (function_exists("curl_init")){ 379 elseif (function_exists("curl_init")){ 380 spip_log("cache_cool_async_curl avec curl $url","cachecool" . _LOG_DEBUG); 359 381 //setting the curl parameters. 360 382 $ch = curl_init($url);
Note: See TracChangeset
for help on using the changeset viewer.