= self::$cache_life) { Run::Summon( [ 'Cache_image', $url, $path ] ); return false; } else { return ((filesize($path)) ? true : false); } } Run::Summon( [ 'Cache_image', $url, $path ] ); return false; } static function url_to_cache($url,$file) { $fp = fopen($file,'wb'); if (! $fp) { logger('failed to open storage file: ' . $file,LOGGER_NORMAL,LOG_ERR); return false; } $redirects = 0; $x = z_fetch_url($url,true,$redirects,[ 'filep' => $fp, 'novalidate' => true ]); fclose($fp); if ($x['success'] && file_exists($file)) { $i = @getimagesize($file); if ($i && $i[2]) { // looking for non-zero imagetype Run::Summon( [ 'CacheThumb' , basename($file) ] ); return true; } } // We could not cache the image for some reason. Leave an empty file here // to provide a record of the attempt. We'll use this as a flag to avoid // doing it again repeatedly. file_put_contents($file, EMPTY_STR); logger('cache failed ' . $file); return false; } }