Exemplo n.º 1
0
 /**
  * Check if the credentials given can be used to establish a
  * connection with the DB server
  */
 public static function checkDatabaseConnection()
 {
     try {
         $db = new \PDO("mysql:host=" . self::$database['host'] . ";port=" . self::$database['port'], self::$database['username'], self::$database['password'], array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION));
         self::$dbh = $db;
         self::$dbh->exec("CREATE DATABASE IF NOT EXISTS `" . self::$database['dbname'] . "`");
         self::$dbh->query("USE `" . self::$database['dbname'] . "`");
         $notable = false;
         $tables = array("options", "data");
         // The Tables of Lobby
         foreach ($tables as $tableName) {
             $results = self::$dbh->prepare("SHOW TABLES LIKE ?");
             $results->execute(array(self::$database['prefix'] . $tableName));
             if (!$results || $results->rowCount() == 0) {
                 $notable = true;
             }
         }
         if (!$notable) {
             /**
              * Database tables exist
              */
             echo ser("Error", "Lobby Tables with prefix <b>" . self::$database['prefix'] . "</b> exists. Delete (DROP) those tables and <cl/><a class='btn orange' href='install.php?step=3&db_type=mysql" . \CSRF::getParam() . "'>Try Again</a>");
             return false;
         }
     } catch (\PDOException $Exception) {
         self::log("Database Connection Failed : " . $Exception->getMessage());
         echo ser("Error", "Unable to connect. Make sure that the settings you entered are correct. <cl/><a class='btn orange' href='install.php?step=3&db_type=mysql" . \CSRF::getParam() . "'>Try Again</a>");
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * Define some pages by default
  */
 public static function defaults()
 {
     /**
      * Route App Pages (/app/{appname}/{page}) to according apps
      */
     self::route("/app/[:appID]?/[**:page]?", function ($request) {
         $AppID = $request->appID;
         $page = $request->page != "" ? "/{$request->page}" : "/";
         /**
          * Check if App exists
          */
         $App = new \Lobby\Apps($AppID);
         if ($App->exists && $App->enabled) {
             $class = $App->run();
             $AppInfo = $App->info;
             /**
              * Set the title
              */
             Response::setTitle($AppInfo['name']);
             /**
              * Add the App item to the navbar
              */
             \Lobby\UI\Panel::addTopItem("lobbyApp{$AppID}", array("text" => $AppInfo['name'], "href" => $AppInfo['url'], "subItems" => array("app_admin" => array("text" => "Admin", "href" => "/admin/apps.php?app={$AppID}"), "app_disable" => array("text" => "Disable", "href" => "/admin/apps.php?action=disable&app={$AppID}" . \CSRF::getParam()), "app_remove" => array("text" => "Remove", "href" => "/admin/apps.php?action=remove&app={$AppID}" . \CSRF::getParam())), "position" => "left"));
             $pageResponse = $class->page($page);
             if ($pageResponse === "auto") {
                 if ($page === "/") {
                     $page = "/index";
                 }
                 if (is_dir($class->fs->loc("src/page{$page}"))) {
                     $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);
                 }
             }
         } else {
             echo ser();
         }
     });
     /**
      * Dashboard Page
      * The main Page. Add CSS & JS accordingly
      */
     self::route("/", function () {
         Response::setTitle("Dashboard");
         \Lobby\UI\Themes::loadDashboard("head");
         Response::loadPage("/includes/lib/lobby/inc/dashboard.php");
     });
 }
Exemplo n.º 3
0
                echo "<a class='btn red disabled' title='The app requirements are not satisfied. See 'Info' tab.'>Install</a>";
            }
        } else {
            if (version_compare($app['version'], $App->info['version'], ">")) {
                /**
                 * New version of app is available
                 */
                echo \Lobby::l("/admin/check-updates.php", "Update App", "class='btn red'");
            } else {
                if ($App->enabled) {
                    echo \Lobby::l($App->info['url'], "Open App", "class='btn green'");
                } else {
                    /**
                     * App is Disabled. Show button to enable it
                     */
                    echo \Lobby::l("/admin/apps.php?action=enable&redirect=1&app=" . $appID . CSRF::getParam(), "Enable App", "class='btn green'");
                }
            }
        }
        ?>
                <div class="chip" clear>Developed By <a href="<?php 
        echo $app['author_page'];
        ?>
" target="_blank"><?php 
        echo $app['author'];
        ?>
</a></div>
                <div class="chip" clear><a href="<?php 
        echo $app['app_page'];
        ?>
" target="_blank">App's Webpage</a></div>
Exemplo n.º 4
0
 /**
  * Update The Lobby Core (Software)
  */
 public static function software()
 {
     if (\Lobby\Modules::exists("admin")) {
         $admin_previously_installed = true;
     }
     $oldVer = self::$version;
     $latest_version = DB::getOption("lobby_latest_version");
     $url = Server::download("lobby", $latest_version);
     $zipFile = L_DIR . "/contents/update/" . $latest_version . ".zip";
     self::zipFile($url, $zipFile);
     // Make the Zip Object
     $zip = new \ZipArchive();
     if ($zip->open($zipFile) != "true") {
         self::log("Unable to open downloaded Zip File.");
         echo ser("Error", "Unable to open Zip File.  <a href='update.php'>Try again</a>");
     }
     self::log("Upgrading Lobby Software From {$zipFile}");
     /**
      * Extract New Version
      */
     $zip->extractTo(L_DIR);
     $zip->close();
     FS::remove($zipFile);
     self::finish_software_update(isset($admin_previously_installed));
     return L_URL . "/admin/settings.php?updated=1&oldver={$oldVer}" . \CSRF::getParam();
 }
Exemplo n.º 5
0
<?php

$this->setTitle("Admin");
?>
<div class="contents">
  <h1>Lobby Admin</h1>
  <?php 
echo \Lobby::l("/admin/app/lobby-server/new-app", "New App", "class='btn green' clear");
echo \Lobby::l("/admin/app/lobby-server/downloads", "Download Stats", "class='btn' clear");
echo \Lobby::l("https://lobby-subins.rhcloud.com/phpmyadmin", "Database", "class='btn red' clear target='_blank'");
echo \Lobby::l("/admin/app/lobby-server?clear-git-cache" . \CSRF::getParam(), "Clear Git Cache", "class='btn orange' clear");
if (isset($_GET["clear-git-cache"]) && \CSRF::check()) {
    \Lobby\DB::getDBH()->exec("TRUNCATE TABLE `git_cache`");
    echo "<h2>cleared</h2>";
}
?>
</div>
Exemplo n.º 6
0
"><?php 
            echo $App->info["name"];
            ?>
</a>
                    <div class="actions">
                      <?php 
            if ($App->hasUpdate()) {
                echo "<cl/>" . \Lobby::l("/admin/update.php", "Update", "class='btn orange'");
            } else {
                if ($App->enabled) {
                    echo \Lobby::l("/admin/apps.php?app={$app}&action=disable" . CSRF::getParam(), "Disable", "class='btn'");
                } else {
                    echo \Lobby::l("/admin/apps.php?app={$app}&action=enable" . CSRF::getParam(), "Enable", "class='btn green'");
                }
            }
            echo "<cl/>" . \Lobby::l("/admin/apps.php?app={$app}&action=remove" . CSRF::getParam(), "Remove", "class='btn red'");
            ?>
                    </div>
                  </div>
                </div>
              </div>
            <?php 
        }
        echo '</div>';
    }
}
?>
      </div>
    </div>
  </body>
</html>
Exemplo n.º 7
0
                                    \Lobby\Install::dbConfig(array("path" => str_replace(L_DIR, "", $db_loc), "prefix" => "l_"));
                                    /**
                                     * Make the Config File
                                     */
                                    \Lobby\Install::makeConfigFile("sqlite");
                                    /**
                                     * Enable app lEdit
                                     */
                                    \Lobby::$installed = true;
                                    \Lobby\DB::__constructStatic();
                                    $App = new \Lobby\Apps("ledit");
                                    $App->enableApp();
                                    echo sss("Success", "Database and <b>config.php</b> file was successfully created.");
                                    echo '<cl/><a href="?step=4' . CSRF::getParam() . '" class="btn">Proceed</a>';
                                } else {
                                    echo ser("Couldn't Make SQLite Database", "I was unable to make the database. Error :<blockquote>" . \Lobby\Install::$error . "</blockquote> <cl/>" . \Lobby::l("/admin/install.php?step=3&db_type=sqlite" . CSRF::getParam(), "Try Again", "class='btn'"));
                                }
                            }
                        } else {
                            if ($db_type === "mysql") {
                                ?>
                <h3>Database</h3>
                <p>Provide the database credentials. Double check before submitting</p>
                <form action="<?php 
                                \Lobby::u();
                                ?>
" method="POST">
                  <table>
                    <thead>
                      <tr>
                        <td width="20%">Name</td>
Exemplo n.º 8
0
                    if ($App->clearData()) {
                        echo sss("Cleared Data", "The data of <b>{$displayID}</b> was successfully cleared from the database.");
                    }
                } else {
                    if ($appID != null && $action == null && CSRF::check()) {
                        ?>
          <h1>Install App</h1>
          <p>The install progress will be displayed below. If this doesn't work, try the <?php 
                        echo \Lobby::l("/admin/install-app.php?app={$appID}&do=alternate-install" . CSRF::getParam(), "alternate install");
                        ?>
.</p>
          <?php 
                        if (isset($_GET["do"]) && $_GET["do"] === "alternate-install" && CSRF::check()) {
                            ?>
            <iframe src="<?php 
                            echo L_URL . "/admin/download.php?type=app&app={$appID}" . CSRF::getParam();
                            ?>
" style="border: 0;width: 100%;height: 300px;"></iframe>
        <?php 
                        } else {
                            ?>
            <ul id="appInstallationProgress" class="collection"></ul>
            <script>
              lobby.load(function(){
                lobby.installApp("<?php 
                            echo $appID;
                            ?>
", $("#appInstallationProgress"));
              });
            </script>
        <?php 
Exemplo n.º 9
0
            <p>
              Looks like everything is ok. Hope you backed up Lobby installation & Database.
              <div clear></div>
              You can update now.
            </p>
          <?php 
        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();