Exemple #1
0
<?php

use Fr\Process;
$appID = \Request::postParam("id");
if (!CSRF::check()) {
    echo json_encode(array("statusID" => "error", "status" => "CSRF Token didn't match"));
} else {
    if ($appID === null) {
        echo json_encode(array("statusID" => "error", "status" => "Invalid App ID"));
    } else {
        /**
         * A queue of App downloads
         */
        $appInstallQueue = Lobby\DB::getJSONOption("lobby_app_downloads");
        /**
         * If the $appID is in the queue, then give the download status of it
         * If the updated value is less than 20 seconds ago, then restart the download
         */
        if (isset($appInstallQueue[$appID]) && $appInstallQueue[$appID]["updated"] > strtotime("-20 seconds")) {
            echo json_encode(array("statusID" => $appInstallQueue[$appID]["statusID"], "status" => $appInstallQueue[$appID]["status"]));
        } else {
            $appInfo = \Lobby\Server::store(array("get" => "app", "id" => $appID));
            /**
             * App doesn't exist on Lobby Store
             */
            if ($appInfo === "false") {
                echo json_encode(array("status" => "error", "error" => "App Doesn't Exist"));
            } else {
                $appName = $appInfo["name"];
                $Process = new Process(Process::getPHPExecutable(), array("arguments" => array(L_DIR . "/admin/ajax/install-app-bg.php", \Lobby::getLID(), base64_encode(serialize($_SERVER)), $appID)));
                /**
Exemple #2
0
<?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);
Exemple #3
0
            $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>";
    }
}