function _pugpig_package_download_batch($heading, $entries, $debug, $concurrent) { print_r("<h3>Downloading " . $heading . " - " . count($entries) . " files</h3>"); if ($debug) { var_dump($entries); } // Check the URLs we're about to download are real URLs $format_failures = array(); foreach (array_keys($entries) as $entry) { if (!filter_var($entry, FILTER_VALIDATE_URL)) { $format_failures[$entry] = "Invalid URL format: " . $entry; unset($entries[$entry]); } else { $path = $entries[$entry]; if (strpos($path, "?") || strpos($path, "&")) { $format_failures[$entry] = "Invalid local disk path: " . $path; unset($entries[$entry]); } } } _pugpig_package_show_failures($format_failures); // Both of these should become a settings, as well as timeout value $warning_file_size = 150 * 1024; // 150 Kb $mc = new MultiCurl($entries, $concurrent, $warning_file_size); $mc->process(); $failures = $mc->getFailures(); if (count($failures) > 0) { _pugpig_package_show_failures($failures); _print_immediately('<b>Aborting</b><br /><a href="javascript:location.reload(true);">Refresh this page to reload and try again. (It will resume from where it last succeeded.)</a><br />'); exit; } else { print_r("<em>Done</em><br />"); } return $entries; }
function _pugpig_package_download_batch($heading, $entries, $debug = false, $concurrent = 3) { print_r("<h3>Downloading " . $heading . " - " . count($entries) . " files</h3>"); // Check the URLs we're about to download are real URLs $format_failures = array(); foreach (array_keys($entries) as $entry) { if (!_pugpig_package_validate_download_url($entry, $entries[$entry], $format_failures)) { unset($entries[$entry]); } } _pugpig_package_show_failures($format_failures); // Both of these should become a settings, as well as timeout value $warning_file_size = 150 * 1024; // 150 Kb $mc = new MultiCurl($entries, $concurrent, $warning_file_size); $mc->process(); $successes = $mc->getSuccesses(); $failures = $mc->getFailures(); _pugpig_show_batch($successes); // _pugpig_array_to_table($successes); if (count($failures) > 0) { _pugpig_package_show_failures($failures); _print_immediately('<b>Aborting</b><br /><a href="javascript:location.reload(true);">Refresh this page to reload and try again. (It will resume from where it last succeeded.)</a><br />'); exit; } else { print_r("<em>Done</em><br />"); } return $entries; }