<?php $notifications = Lobby\DB::getJSONOption("notify_items"); /** * If there is a update available either app or core, add a Notify item */ if (\Lobby\Update::isAvailable()) { $notifications["update"] = array("contents" => "New Updates Are Available", "icon" => "update", "iconURL" => null, "href" => \Lobby::u("/admin/update.php")); } echo json_encode($notifications);
if (!\Lobby::status("lobby.install")) { /** * Left Menu */ \Lobby\UI\Panel::addTopItem("lobbyHome", array("text" => "Home", "href" => L_URL, "position" => "left")); $adminArray = array("text" => "Admin", "href" => "/admin", "position" => "left"); $adminArray["subItems"] = array("app_manager" => array("text" => "Apps", "href" => "/admin/apps.php"), "lobby_store" => array("text" => "Lobby Store", "href" => "/admin/lobby-store.php"), "about" => array("text" => "Settings", "href" => "/admin/settings.php")); \Lobby\UI\Panel::addTopItem("lobbyAdmin", $adminArray); if (\Lobby\FS::exists("/upgrade.lobby")) { require_once L_DIR . "/includes/src/Update.php"; $l_info = json_decode(\Lobby\FS::get("/lobby.json")); if ($lobby_version != $l_info->version) { Lobby\DB::saveOption("lobby_latest_version", $l_info->version); Lobby\DB::saveOption("lobby_latest_version_release", $l_info->released); } \Lobby\Update::finish_software_update(); } } if (\Lobby::status("lobby.admin")) { /** * Add Admin Pages' stylesheet, script */ \Assets::js("admin", "/admin/js/admin.js"); /** * Add sidebar */ Hooks::addAction("admin.body.begin", function () { require L_DIR . "/admin/inc/sidebar.php"; }); /** * Add sidebar handler in panel
\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); } } };
{ $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>"; } }
echo \Lobby::l("/admin/update.php?step=2" . CSRF::getParam(), "Start Update", "clear class='btn green'"); } elseif ($step == 2) { $version = Lobby\DB::getOption("lobby_latest_version"); echo '<iframe src="' . L_URL . "/admin/download.php?type=lobby" . CSRF::getParam() . '" style="border: 0;width: 100%;height: 200px;"></iframe>'; } } $shouldUpdate = Request::postParam("updateApp"); if ($action === "updateApps" && is_array($shouldUpdate) && CSRF::check()) { foreach ($shouldUpdate as $appID) { echo '<iframe src="' . L_URL . "/admin/download.php?type=app&app={$appID}&isUpdate=1" . CSRF::getParam() . '" style="border: 0;width: 100%;height: 200px;"></iframe>'; } } if ($step === null) { echo "<h2>Apps</h2>"; } $appUpdates = Update::getApps(); if ($step === null && empty($appUpdates)) { echo "<p>All apps are up to date.</p>"; } else { if ($step === null && isset($appUpdates) && count($appUpdates)) { ?> <p>New versions of apps are available. Choose which apps to update from the following :</p> <form method="POST" clear> <?php echo CSRF::getInput(); ?> <table> <thead> <tr> <td style='width: 2%;'>Update ?</td> <td style='width: 20%;'>App</td>