示例#1
0
 public static function load()
 {
     /**
      * $module = array(
      *   "id" => "The Module ID",
      *   "location" => "The absolute location to module",
      *   "url" => "URL to Module"
      * )
      */
     foreach (self::$mods as $module) {
         require_once "{$module["location"]}/Module.php";
         $moduleIdentifier = "\\Lobby\\Module\\{$module['id']}";
         if (isset($module["appID"])) {
             $App = new Apps($module["appID"]);
             new $moduleIdentifier(array($module["id"], $module["location"], $module["url"]), $App->getInstance());
         } else {
             new $moduleIdentifier(array($module["id"], $module["location"], $module["url"]));
         }
     }
 }
示例#2
0
文件: Server.php 项目: LobbyOS/server
 /**
  * Get updates
  */
 public static function check()
 {
     $url = self::$apiURL . "/lobby/updates";
     $apps = Apps::getApps();
     try {
         $response = \Requests::post($url, array(), self::makeData(array("apps" => implode(",", $apps))))->body;
     } catch (\Requests_Exception $error) {
         \Lobby::log("Checkup with server failed ({$url}) : {$error}");
         $response = false;
     }
     if ($response) {
         $response = json_decode($response, true);
         if (is_array($response)) {
             DB::saveOption("lobby_latest_version", $response['version']);
             DB::saveOption("lobby_latest_version_release", $response['released']);
             DB::saveOption("lobby_latest_version_release_notes", $response['release_notes']);
             if (isset($response['apps']) && count($response['apps']) != 0) {
                 $AppUpdates = array();
                 foreach ($response['apps'] as $appID => $version) {
                     $App = new \Lobby\Apps($appID);
                     if ($App->hasUpdate($version)) {
                         $AppUpdates[$appID] = $version;
                     }
                 }
                 DB::saveOption("app_updates", json_encode($AppUpdates));
             }
             if (isset($response["notify"])) {
                 foreach ($response["notify"]["items"] as $itemID => $item) {
                     if (isset($item["href"])) {
                         $item["href"] = \Lobby::u($item["href"]);
                     }
                     Panel::addNotifyItem("lobby_server_msg_" . $itemID, $item);
                 }
                 foreach ($response["notify"]["remove_items"] as $itemID) {
                     Panel::removeNotifyItem("lobby_server_msg_" . $itemID);
                 }
             }
         }
     }
 }
示例#3
0
 public static function init()
 {
     $apps = \Lobby\Apps::getApps();
     foreach ($apps as $app => $null) {
         $module_name = 'apps/' . $app . '/module';
         $loc = APPS_DIR . "/{$app}/module";
         if (self::valid($module_name, $loc)) {
             self::$app_modules[$module_name] = $loc;
         }
     }
     self::$core_modules = self::dirModules("/includes/lib/modules");
     self::$custom_modules = self::dirModules("/contents/modules");
     self::$modules = array_merge(self::$core_modules, self::$custom_modules, self::$app_modules);
 }
示例#4
0
文件: Module.php 项目: LobbyOS/server
 public function appAdminSetup()
 {
     Router::route("/admin/app/[:appID]?/[**:page]?", function ($request) {
         $appID = $request->appID;
         $page = $request->page === null ? "/" : "/{$request->page}";
         $App = new \Lobby\Apps($appID);
         if (!$App->exists) {
             ser();
             return null;
         }
         Hooks::addFilter("admin.view.sidebar", function ($links) use($appID, $App) {
             $links["/admin/app/{$appID}"] = $App->info["name"];
             return $links;
         });
         Hooks::addFilter("app.manifest", function ($info) {
             $info["adminURL"] = L_URL . "/admin/app/" . $info["id"];
             return $info;
         });
         $class = $App->getInstance();
         /**
          * Set the title
          */
         Response::setTitle($App->info["name"]);
         $pageResponse = $class->page($page);
         if ($pageResponse === "auto") {
             if ($page === "/") {
                 $page = "/index";
             }
             $html = $class->inc("/src/page/admin{$page}.php");
             if ($html) {
                 Response::setPage($html);
             } else {
                 ser();
             }
         } else {
             if ($pageResponse === null) {
                 ob_start();
                 echo ser("Error", "The app '<strong>{$AppID}</strong>' does not have an Admin Page. <a clear href='" . \Lobby::u("/app/{$AppID}") . "' class='btn green'>Go To App</a>");
                 $error = ob_get_contents();
                 ob_end_clean();
                 Response::setPage($error);
             } else {
                 Response::setPage($pageResponse);
             }
         }
     });
 }
示例#5
0
 /**
  * Get updates
  */
 public static function check()
 {
     $apps = array_keys(\Lobby\Apps::getApps());
     $response = \Lobby::loadURL(L_SERVER . "/updates", array("apps" => implode(",", $apps)), "POST");
     if ($response) {
         $response = json_decode($response, true);
         if (is_array($response)) {
             saveOption("lobby_latest_version", $response['version']);
             saveOption("lobby_latest_version_release", $response['released']);
             if (isset($response['apps']) && count($response['apps']) != 0) {
                 $AppUpdates = array();
                 foreach ($response['apps'] as $appID => $version) {
                     $App = new \Lobby\Apps($appID);
                     if ($App->info['version'] != $version) {
                         $AppUpdates[$appID] = $version;
                     }
                 }
                 saveOption("app_updates", json_encode($AppUpdates));
             }
         }
     }
 }
示例#6
0
文件: apps.php 项目: saviobosco/lobby
            ?>
">No, I'm Not</a>
        <?php 
            exit;
        } else {
            if ($action == "enable") {
                if ($App->enableApp()) {
                    sss("Enabled", "App has been enabled.");
                } else {
                    ser("Error", "The App couldn't be enabled. Try again.", false);
                }
            }
        }
    }
}
$Apps = \Lobby\Apps::getApps();
if (count($Apps) == 0) {
    ser("No Enabled Apps", "Lobby didn't find any apps that has been enabled", false);
}
if (count($Apps) != 0) {
    ?>
          <table style="width: 100%;margin-top:5px">
            <thead>
              <tr>
                <td>Name</td>
                <td>Version</td>
                <td>Description</td>
                <td>Actions</td>
              </tr>
            </thead>
            <tbody>
示例#7
0
文件: DB.php 项目: LobbyOS/server
 /**
  * Save App Data
  */
 public static function saveData($appID, $key, $value = "")
 {
     if (self::$installed && \Lobby\Apps::exists($appID) && $key != "") {
         $sql = self::$dbh->prepare("SELECT COUNT(`name`) FROM `" . self::$prefix . "data` WHERE `name` = ? AND `app`=?");
         $sql->execute(array($key, $appID));
         if ($sql->fetchColumn() != 0) {
             $sql = self::$dbh->prepare("UPDATE `" . self::$prefix . "data` SET `value` = ?, `updated` = CURRENT_TIMESTAMP WHERE `name` = ? AND `app` = ?");
             $sql->execute(array($value, $key, $appID));
             return true;
         } else {
             $sql = self::$dbh->prepare("INSERT INTO `" . self::$prefix . "data` (`app`, `name`, `value`, `created`, `updated`) VALUES (?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
             return $sql->execute(array($appID, $key, $value));
         }
     } else {
         return false;
     }
 }
示例#8
0
<?php

/**
 * Get installed apps and make the tiles on dashboard
 */
$apps = \Lobby\Apps::getEnabledApps();
if (count($apps) == 0) {
    echo ser("No Apps", "You haven't enabled or installed any apps. <br/>Get great Apps from " . \Lobby::l("/admin/lobby-store.php", "Lobby Store"));
} else {
    $dashboard_items = array("apps" => array());
    foreach ($apps as $app => $null) {
        $App = new \Lobby\Apps($app);
        $data = $App->info;
        $dashboard_items["apps"][$app] = $data;
    }
    \Lobby\UI\Themes::loadDashboard($dashboard_items);
}
示例#9
0
文件: init.php 项目: LobbyOS/server
    ?>
  <script>
    window.tmp = {};
    window.lobbyExtra = {
      url: "<?php 
    echo L_URL;
    ?>
",
      csrfToken: "<?php 
    echo CSRF::get();
    ?>
",
      sysInfo: {
        os: "<?php 
    echo \Lobby::getSysInfo("os");
    ?>
"
      }
    };
    <?php 
    if (\Lobby\Apps::isAppRunning()) {
        echo 'window.lobbyExtra["app"] = {
        id: "' . \Lobby\Apps::getInfo("id") . '",
        url: "' . \Lobby\Apps::getInfo("url") . '",
        src: "' . \Lobby\Apps::getInfo("srcURL") . '"
      };';
    }
    ?>
</script>
<?php 
});
示例#10
0
                 */
                $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());
    }
}
示例#11
0
文件: Lobby.php 项目: LobbyOS/server
 /**
  * Make a URL from Lobby Base Path.
  * Eg: /hello to http://lobby.dev/hello
  */
 public static function u($path = null, $relative = false)
 {
     if (self::$cli) {
         return null;
     }
     /**
      * The $path var is changed during the process
      * So, original path is stored separately
      */
     $origPath = $path;
     /**
      * The return URL
      */
     $url = $path;
     /**
      * Prettyify $path
      */
     if ($path !== null) {
         $path = ltrim($path, "/");
         $parts = parse_url($path);
         /**
          * Make host along with port:
          * 127.0.0.1:9000
          */
         if (isset($parts['host'])) {
             $urlHost = $parts['host'] . (isset($parts['port']) ? ":{$parts['port']}" : "");
         } else {
             $urlHost = null;
         }
     }
     /**
      * If no path, give the current page URL
      */
     if ($path == null) {
         $pageURL = 'http';
         if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
             $pageURL .= "s";
         }
         $pageURL .= "://";
         $requestURI = $relative === false ? Request::getRequestURI() : $_SERVER["REQUEST_URI"];
         if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] != "80") {
             $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $requestURI;
         } else {
             $pageURL .= $_SERVER["SERVER_NAME"] . $requestURI;
         }
         $url = $pageURL;
     } else {
         if ($path === self::$url) {
             $url = self::$url;
         } else {
             if (!preg_match("/http/", $path) || $urlHost !== self::$host) {
                 /**
                  * If $origPath is a relative URI
                  */
                 if ($urlHost == null) {
                     $url = self::$url . "/{$path}";
                 } else {
                     if (Apps::isAppRunning()) {
                         $url = Apps::getRunningInstance()->u($origPath);
                     }
                 }
             }
         }
     }
     return $url;
 }
示例#12
0
文件: apps.php 项目: LobbyOS/server
    }
} else {
    ?>
          <h2>Apps</h2>
          <p>Manage <b>installed apps</b>. You can find and install more Apps from <a href="<?php 
    echo L_URL;
    ?>
/admin/lobby-store.php">Lobby Store</a>.</p>
        <?php 
    $apps = Apps::getApps();
    if (empty($apps)) {
        echo ser("No Apps", "You haven't installed any apps. <br/>Get great Apps from " . \Lobby::l("/admin/lobby-store.php", "Lobby Store"));
    } else {
        echo '<div class="apps row">';
        foreach ($apps as $app) {
            $App = new Apps($app);
            ?>
              <div class="app col s12 m6 l4">
                <div class="app-inner card row">
                  <div class="lpane col s4 m5 l5">
                    <a href="<?php 
            echo \Lobby::u("/admin/apps.php?app={$app}");
            ?>
">
                      <img src="<?php 
            echo $App->info["logo"];
            ?>
" />
                    </a>
                  </div>
                  <div class="rpane col s8 m6 l7">
示例#13
0
文件: Module.php 项目: LobbyOS/server
 public function init()
 {
     $appID = $this->app->getData("appID");
     $this->appAdminSetup();
     if ($appID === null) {
         return null;
     }
     $App = new Apps($appID);
     $App->run();
     Hooks::addAction("router.finish", function () {
         /**
          * Route App Pages (/app/{appname}/{page}) to according apps
          */
         Router::route("/?[*:page]?", function ($request) {
             $appID = Apps::getInfo("id");
             $page = $request->page === null ? "/" : "/{$request->page}";
             if (substr($page, 0, 6) == "/admin") {
                 return false;
             } else {
                 $App = new \Lobby\Apps($appID);
                 $class = $App->getInstance();
                 /**
                  * Set the title
                  */
                 Response::setTitle($App->info["name"]);
                 $pageResponse = $class->page($page);
                 if ($pageResponse === "auto") {
                     if ($page === "/") {
                         $page = "/index";
                     }
                     $html = $class->inc("/src/page{$page}.php");
                     if ($html) {
                         Response::setPage($html);
                     } else {
                         ser();
                     }
                 } else {
                     if ($pageResponse === null) {
                         ser();
                     } else {
                         Response::setPage($pageResponse);
                     }
                 }
             }
         });
     });
     Router::route("/app/[:appID]?/[**:page]?", function ($request) {
         if ($request->appID === "admin") {
             Response::redirect("admin/app/admin/{$page}" . $request->page);
         }
         ser();
     });
     /**
      * Disable FilePicker Module
      */
     if (\Lobby\Modules::exists("filepicker")) {
         \Lobby\Modules::disableModule("filepicker");
     }
     Router::route("/includes/lib/modules?/[**:page]?", function ($request) {
         ser();
     });
     \Lobby\UI\Panel::addTopItem('indiModule', array("text" => "<img src='" . $this->app->srcURL . "/src/image/logo.svg' />", "href" => "/admin/app/indi", "position" => "left", "subItems" => array("appAdmin" => array("text" => "App Admin", "href" => "/admin/app/{$appID}"), "configIndi" => array("text" => "Configure Indi", "href" => "/admin/app/indi"))));
 }
示例#14
0
 /**
  * Print the <head> tag
  */
 public static function head($title = "")
 {
     header('Content-type: text/html; charset=utf-8');
     if ($title != "") {
         self::setTitle($title);
     }
     if (Assets::issetJS('jquery')) {
         /**
          * Load jQuery, jQuery UI, Lobby Main, App separately without async
          */
         $url = L_URL . "/includes/serve-assets.php?type=js&assets=" . implode(",", array(Assets::getJS('jquery'), Assets::getJS('jqueryui'), Assets::getJS('main'), Assets::issetJS('app') ? Assets::getJS('app') : ""));
         echo "<script src='{$url}'></script>";
         Assets::removeJS("jquery");
         Assets::removeJS("jqueryui");
         Assets::removeJS("main");
     }
     $jsURLParams = array("THEME_URL" => Themes::getThemeURL());
     if (Apps::isAppRunning()) {
         $jsURLParams["APP_URL"] = urlencode(Apps::getInfo("url"));
         $jsURLParams["APP_SRC"] = urlencode(Apps::getInfo("srcURL"));
     }
     $jsURL = Assets::getServeURL("js", $jsURLParams);
     echo "<script>lobby.load_script_url = '" . $jsURL . "';</script>";
     $cssServeParams = array("THEME_URL" => THEME_URL);
     /**
      * CSS Files
      */
     if (Apps::isAppRunning()) {
         $cssServeParams["APP_URL"] = urlencode(Apps::getInfo("url"));
         $cssServeParams["APP_SRC"] = urlencode(Apps::getInfo("srcURL"));
     }
     echo Assets::getServeLinkTag($cssServeParams);
     echo "<link href='" . L_URL . "/favicon.ico' sizes='16x16 32x32 64x64' rel='shortcut icon' />";
     /* Title */
     echo "<title>" . self::$title . "</title>";
 }