function main($params) { $params = parseParams($argv); if ($params['file']) { $locations = file($params['file']); # Per chris.chih from CDNetworks <*****@*****.**> # in March, 2014 email to Reuben, we can do 60 cache clear requests # with up to 1,000 urls per request $MAX_URLS = 1000; if (!is_array($locations) || count($locations) > $MAX_URLS) { print "error: specified file '{$params['file']}' must contain a list of urls, one per line, at most {$MAX_URLS}\n"; exit; } $locations = array_map(parseLocation, $locations); } else { $locations = array(parseLocation($params['url'])); } $html = CDNetworksSupport::doCDnetworksApiCall($params, $locations); print "response from CDNetworks:\n"; print $html . "\n"; }
function purgeThumbnailsFromCDNetworks($files) { $locations = array(); foreach ($files as $file) { $thumbnails = $file->getThumbnails(); $dir = array_shift($thumbnails); foreach ($thumbnails as $thumbnail) { $dirPath = str_replace("mwstore://local-backend/local-thumb/", "", $dir); $locations[] = "/images/thumb/" . $dirPath . "/" . $thumbnail; } } $user = $this->getOption('cdnuser'); $pass = $this->getOption('cdnpass'); if ($user && $pass) { $params = array('user' => $user, 'password' => $pass); decho("will call to cdnet with", $locations, false); //TODO if this list is longer than 1000 split into separate calls // or maybe just write this all to a file $html = CDNetworksSupport::doCDnetworksApiCall($params, $locations); decho("response from CDN", $html, false); } else { decho("must provide user and password to do cdn flush"); } }