*/ $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); } } }; try { /** * Update::app() will only return TRUE if download is completed */ if (Update::app($appID)) { $App = new Apps($appID); $App->enableApp(); sendStatusToLobby("install_finished", "Installed <b>{$appID}</b>.<cl/><a href='" . $App->info["url"] . "' class='btn green'>Open App</a>"); } } catch (\Exception $e) { sendStatusToLobby("error", $e->getMessage()); } }
{ $base = log($size) / log(1024); $base = floor($base); $suffix = array("", "KB", "MB", "GB", "TB"); return round(pow(1024, $base - floor($base)), 1) . $suffix[$base]; } $GLOBALS['last'] = 0; \Lobby\Update::$progress = function ($resource, $download_size, $downloaded, $upload_size, $uploaded) { if ($download_size == 0) { $percent = 0; } else { $percent = round($downloaded / $download_size * 100, 0); } if ($GLOBALS['last'] != $percent) { $GLOBALS['last'] = $percent; $rd_size = convertToReadableSize($download_size); echo "<script>document.querySelector('.downloadStatus').innerHTML = 'Downloaded {$percent}% of {$rd_size}';</script>"; flush(); if ($percent == 100) { echo "<p>Installing <b>{$GLOBALS['name']}</b>...</p>"; flush(); } } }; if ($type == "app" && \Lobby\Update::app($id)) { echo "Installed - The app has been installed. <a target='_parent' href='" . L_URL . "/admin/install-app.php?action=enable&id={$_GET['id']}" . H::csrf("g") . "'>Enable the app</a> to use it."; } else { if ($type == "lobby" && ($redirect = \Lobby\Update::software())) { echo "<a target='_parent' href='{$redirect}'>Updated Lobby</a>"; } }
$rd_size = FS::normalizeSize($download_size); echo "<script>document.getElementById('downloadStatus').innerHTML = 'Downloaded {$percent}% of {$rd_size}';</script>"; } else { $downloaded = FS::normalizeSize($downloaded); $GLOBALS['non_percent'] = 1; echo "<script>document.getElementById('downloadStatus').innerHTML = 'Downloaded {$downloaded}';</script>"; } flush(); if ($percent == 100 && !isset($GLOBALS['install-msg-printed'])) { echo "<p>Installing <b>{$GLOBALS['name']}</b>...</p>"; $GLOBALS['install-msg-printed'] = 1; flush(); } } }; if ($type === "app" && \Lobby\Update::app($appID)) { $App = new Apps($appID); $App->enableApp(); if ($isUpdate) { $appUpdates = Lobby\DB::getJSONOption("app_updates"); if (isset($appUpdates[$appID])) { unset($appUpdates[$appID]); } Lobby\DB::saveOption("app_updates", json_encode($AppUpdates)); } echo "Installed - The app has been " . ($isUpdate ? "updated." : "installed. <a target='_parent' href='" . $App->info["url"] . "'>Open App</a>"); } else { if ($type === "lobby" && ($redirect = \Lobby\Update::software())) { echo "<a target='_parent' href='{$redirect}'>Updated Lobby</a>"; } }