\Lobby\Update::$progress = function ($resource, $download_size, $downloaded, $upload_size, $uploaded = "") use($appID, $lastPercentage) { /** * On new versions of cURL, $resource parameter is not passed * So, swap vars if it doesn't exist */ if (!is_resource($resource)) { $uploaded = $upload_size; $upload_size = $downloaded; $downloaded = $download_size; $download_size = $resource; } if ($download_size > 1000 && $downloaded > 0) { $percent = round($downloaded / $download_size * 100, 0); } else { $percent = 1; } if ($lastPercentage !== $percent || isset($GLOBALS['non_percent'])) { $lastPercentage = $percent; if ($download_size > 0) { $readable_size = FS::normalizeSize($download_size); sendStatusToLobby("download_status", "Downloaded {$percent}% of {$readable_size}"); } else { /** * We couldn't find the percentage */ $GLOBALS['non_percent'] = 1; $downloaded = FS::normalizeSize($downloaded); sendStatusToLobby("download_status", "Downloaded {$downloaded}"); } /** * Show Install message when download is completed */ if ($percent == 100 && !isset($GLOBALS['install-msg-printed'])) { $GLOBALS['install-msg-printed'] = 1; $downloaded = FS::normalizeSize($downloaded); sendStatusToLobby("download_status", "Downloaded 100% of {$downloaded}"); sleep(2); sendStatusToLobby("install_status", "Installing <b>{$appID}</b>..."); sleep(2); } } };