Ejemplo n.º 1
0
 /**
  * Get Version of a component
  */
 public static function getDependencyVersion($dependency)
 {
     /**
      * If dependency is 'app/admin' etc.
      */
     if (strpos($dependency, "/") !== false) {
         list($dependency, $subDependency) = explode("/", $dependency);
     }
     switch ($dependency) {
         case "lobby":
             return \Lobby::getVersion();
             break;
         case "app":
             $App = new Apps($subDependency);
             return $App->exists ? $App->info["version"] : 0;
             break;
         case "curl":
             $curl = function_exists("curl_version") ? curl_version() : 0;
             return $curl === 0 ? 0 : $curl["version"];
             break;
         default:
             /**
              * phpversion() returns FALSE on failure
              */
             $v = phpversion($dependency);
             return $v ? $v : 0;
     }
 }
Ejemplo n.º 2
0
 public function makePanelItem($text, $href, $id, $extraClass = "")
 {
     if ($href == L_URL) {
         /**
          * Home button
          */
         $html = "<li class='item {$extraClass}' id='home'><a href='" . L_URL . "'></a></li>";
     } else {
         if ($href == "/admin") {
             /**
              * Admin button
              */
             $html = "<li class='item {$extraClass}' id='lobby'><a href='" . \Lobby::u($href) . "' class='parent'>Lobby</a></li>";
         } else {
             $html = '<li class="item ' . $extraClass . '" id="' . $id . '">';
             if ($href == "") {
                 $html .= $text;
             } else {
                 if ($href === "htmlContent") {
                     $html .= $text;
                 } else {
                     $html .= \Lobby::l($href, $text);
                 }
             }
             $html .= '</li>';
         }
     }
     return $html;
 }
Ejemplo n.º 3
0
 public function init()
 {
     if (!\Lobby::status("lobby.assets-serve")) {
         $this->addScript("filepicker.js");
         $this->addStyle("filepicker.css");
     }
 }
Ejemplo n.º 4
0
 /**
  * Load a theme
  */
 public static function loadTheme()
 {
     require_once L_DIR . "/includes/src/UI/Theme.php";
     require_once THEME_DIR . "/Theme.php";
     $className = "\\Lobby\\UI\\Themes\\" . self::$theme;
     $GLOBALS["THEME_OBJ"] = new $className();
     $GLOBALS["THEME_OBJ"]->init();
     /**
      * Load Panel
      */
     if (\Lobby::status("lobby.admin")) {
         \Lobby::hook("admin.head.begin", function () {
             $GLOBALS["THEME_OBJ"]->panel(true);
             $GLOBALS["THEME_OBJ"]->addStyle("/style.css");
             $GLOBALS["THEME_OBJ"]->addStyle("/admin.style.css");
         });
         \Lobby::hook("admin.body.begin", function () {
             echo $GLOBALS["THEME_OBJ"]->inc("/Panel/load.admin.php");
         });
     } else {
         $GLOBALS["THEME_OBJ"]->addStyle("/style.css");
         \Lobby::hook("head.begin", function () {
             $GLOBALS["THEME_OBJ"]->panel(false);
         });
         \Lobby::hook("body.begin", function () {
             echo $GLOBALS["THEME_OBJ"]->inc("/Panel/load.php");
         });
     }
 }
Ejemplo n.º 5
0
 public static function __constructStatic()
 {
     /**
      * Get DB config
      */
     $config = \Lobby::config(true);
     if (is_array($config)) {
         /**
          * Make DB credentials variables from the config.php file
          */
         self::$prefix = $config['prefix'];
         self::$type = $config['type'];
         $options = array(\PDO::ATTR_PERSISTENT => true, \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION);
         try {
             if ($config['type'] === 'mysql') {
                 self::$dbh = new \PDO("mysql:dbname={$config['dbname']};host={$config['host']};port={$config['port']};charset=utf8;", $config['username'], $config['password'], $options);
                 /**
                  * Check if Lobby tables exist
                  */
                 $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::$prefix . $tableName));
                     if ($results->rowCount() == 0) {
                         $notable = true;
                     }
                 }
             } else {
                 if ($config['type'] === 'sqlite') {
                     self::$dbh = new \PDO("sqlite:" . \Lobby\FS::loc($config['path']), "", "", $options);
                     /**
                      * Enable Multithreading Read/Write
                      */
                     self::$dbh->exec("PRAGMA journal_mode=WAL;");
                     /**
                      * Check if Lobby tables exist
                      */
                     $sql = self::$dbh->query("SELECT COUNT(1) FROM `sqlite_master` WHERE `type` = 'table' AND (`name` = 'l_data' OR `name` = 'l_options')");
                     $notable = $sql->fetchColumn() === "2" ? false : true;
                 }
             }
             if ($notable === false) {
                 /* There are database tables */
                 parent::$installed = true;
             } else {
                 parent::log(array("fatal", "Tables required by Lobby was not found in the database. Check your <b>config.php</b> and database to fix the error. Or Install again by removing <b>config.php</b>."));
             }
         } catch (\PDOException $e) {
             parent::$installed = false;
             $error = $e->getMessage();
             parent::log(array("fatal", "Unable to connect to database server. Is the database credentials given in <b>config.php</b> correct ? <blockquote>{$error}</blockquote>"));
         }
     } else {
         self::$installed = false;
     }
 }
 static function lookForLobby()
 {
     $database = DB::getInstance();
     if (self::isUserInLobby()) {
         return Lobby::viewLobby();
     } else {
         return ['loadview' => 'loadingpage', 'randomTip' => self::getRandomTip()];
     }
 }
Ejemplo n.º 7
0
 public static function __constructStatic()
 {
     if (!isset($_COOKIE['csrfToken'])) {
         self::$token = Helper::randStr(10);
         setcookie("csrfToken", self::$token, 0, "/", Lobby::getHostname());
     } else {
         self::$token = $_COOKIE['csrfToken'];
     }
 }
Ejemplo n.º 8
0
 public function MasterAdd($id, $name, $description, $password)
 {
     $random_salt = \Lobby::randStr(15);
     $hashed = hash("sha512", $this->master_salt . $password . $random_salt);
     if (!$this->MasterExists($id)) {
         saveData("master_" . $id . "_name", $name);
         saveData("master_" . $id . "_description", $description);
         saveData("master_" . $id . "_password", $hashed);
         saveData("master_" . $id . "_password_salt", $random_salt);
         saveData("master_" . $id . "_items", '');
         \H::saveJSONData("keyrings", array($id => 1));
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 9
0
 public function init()
 {
     if (\Lobby::status("lobby.assets-serve") === false) {
         $this->install();
         $this->routes();
         require_once $this->app->dir . "/src/inc/load.php";
         if (LS::$loggedIn) {
             /**
              * Logged In
              */
             Hooks::addAction("init", function () {
                 /**
                  * Add Change Password Item in Top Panel -> Admin before Log Out item
                  * This is done by first removing the Log Out item, adding the Change
                  * Password item and then adding back the Log Out item
                  */
                 \Lobby\UI\Panel::addTopItem('adminModule', array("text" => "<img src='" . $this->app->srcURL . "/src/image/logo.svg' style='width: 40px;height: 40px;' />", "href" => "/", "position" => "left", "subItems" => array("changePassword" => array("text" => "Change Password", "href" => "/app/admin/change-password"), 'LogOut' => array("text" => "Log Out", "href" => "/app/admin/logout"))));
             });
         } else {
             /**
              * If `indi` module is active, make the index page available to everyone
              */
             if (!Modules::exists("app_indi")) {
                 if (\Lobby::curPage() != "/admin/login" && !\Lobby::status("lobby.install")) {
                     \Response::redirect("/admin/login");
                 }
             } else {
                 Panel::removeTopItem("indiModule", "left");
                 if (\Lobby::curPage() != "/admin/login" && \Lobby::curPage() != "/admin/install.php" && substr(\Lobby::curPage(), 0, 6) == "/admin") {
                     \Response::redirect("/admin/login");
                 }
             }
             Hooks::addFilter("panel.left.items", function ($left) {
                 unset($left["lobbyAdmin"]);
                 if (Modules::exists("app_indi")) {
                     unset($left["indiModule"]);
                 }
                 return $left;
             });
             Assets::removeJS("notify");
             Assets::removeCSS("notify");
         }
     }
 }
Ejemplo n.º 10
0
 public static function init()
 {
     $root = L_DIR;
     $config = \Lobby::config(true);
     if (is_array($config)) {
         /**
          * Make DB credentials variables from the config.php file
          */
         self::$prefix = $config['prefix'];
         $options = array(\PDO::ATTR_PERSISTENT => true, \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION);
         try {
             self::$dbh = new \PDO("mysql:dbname={$config['dbname']};host={$config['host']};port={$config['port']}", $config['username'], $config['password'], $options);
             $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::$prefix . $tableName));
                 if ($results->rowCount() == 0) {
                     $notable = true;
                 }
             }
             if ($notable === false) {
                 /* There are database tables */
                 parent::$installed = true;
             } else {
                 self::$error = "Lobby Tables Not Found";
                 self::log("Lobby Tables not found in database. Install Again.");
             }
         } catch (\PDOException $e) {
             parent::$installed = false;
             $error = $e->getMessage();
             self::$error = $error;
             $GLOBALS['initError'] = array("Couldn't Connect To Database", "Unable to connect to database server. Is the credentials given in <b>config.php</b> correct ? <blockquote>" . $error . "</blockquote>");
             self::log("Unable to connect to database server : " . $error);
         }
     } else {
         self::$installed = false;
     }
 }
Ejemplo n.º 11
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));
             }
         }
     }
 }
Ejemplo n.º 12
0
            \Lobby::ser("Output Path problem", "The path you gave as output doesn't exist or permission is not acceptable. Make sure it's an existing directory with Read & Write permission", false);
        } else {
            if (!ctype_alnum(str_replace(" ", "", $name))) {
                \Lobby::ser("Invalid Name", "Only alphanumeric characters are allowed for Site Name", false);
            } else {
                if (array_search($theme, $this->themes) === false) {
                    \Lobby::ser("Invalid Theme", "The theme you selected doesn't exist", false);
                } else {
                    // Everything's great
                    $this->addSite($name, $output, $theme);
                    \Lobby::sss("Site added", "The site was added successfully");
                }
            }
        }
    } else {
        \Lobby::ser("Fill Up", "Please fill the form completely", false);
    }
}
?>
  <form action="" method="POST">
    <label>
      <div>Site Name</div>
      <input type="text" name="site" />
    </label><cl/>
    <label>
      <div>Output Location</div>
      <input type="text" name="output" title="Where the generated site should be extracted" />
    </label><cl/>
    <label>
      <div>Empty Output location</div>
      <input type="checkbox" name="empty" title="Should the contents of output directory be removed before generating the site everytime" />
Ejemplo n.º 13
0
require_once 'includes/header.php';
$uid = $_SESSION['id'];
$lid = $_GET['id'];
$request = $_GET['request'];
$team = $_GET['team'];
$class = $_GET['class'];
$ready = $_GET['ready'];
$lat = $_GET['latitude'];
$lon = $_GET['longitude'];
$fid = $_GET['fid'];
$message = $_GET['message'];
if ($uid) {
    $user = new User($uid);
}
if ($lid) {
    $lobby = new Lobby($lid);
}
if ($uid && $lid) {
    $id = getLPid($uid, $lid);
}
if ($uid && $lid) {
    switch ($request) {
        case "userready":
            $status = readystatus($id, true);
            $leader = $lobby->lobbyLeader();
            $array = array('ready' => $status, 'leader' => $leader);
            echo json_encode($array);
            break;
        case "changeTeam":
            if (isset($team) && freeslots($lid, $team) > 0) {
                joinTeam($id, $team);
Ejemplo n.º 14
0
<?php

if (!\Lobby::status("lobby.serve")) {
    /**
     * For enabling access by \Lobby\Panel
     */
    require __DIR__ . "/class.panel.php";
    /**
     * Panel UI
     */
    if (!\Lobby::status("lobby.install")) {
        \Lobby::addScript("superfish", "/includes/lib/modules/panel/lib/superfish.js");
        \Lobby::addStyle("panel", "/includes/lib/modules/panel/lib/panel.css");
        \Lobby::addScript("panel", "/includes/lib/modules/panel/lib/panel.js");
    }
    if (\Lobby::$config['server_check'] === true) {
        /**
         * Default Items provided by the module
         */
        \Lobby\Panel::addTopItem("netStatus", array("html" => "<span id='net' title='Online'></span>", "position" => "right"));
        \Lobby::addScript("panel-item-connection", "/includes/lib/modules/panel/connection/connection.js");
    }
    \Lobby::hook("body.begin", function () {
        include __DIR__ . "/panel.ui.php";
    });
    \Lobby::hook("admin.body.begin", function () {
        include __DIR__ . "/panel.ui.php";
    });
}
Ejemplo n.º 15
0
<div class="contents">
  <h2>sige</h2>
  <p>Manage Pages of site <strong><?php 
echo $name;
?>
</strong></p>
  <p>
    <?php 
echo \Lobby::l("{$su}/edit", "New Page", "class='button'");
$pages = $this->getPages($name);
if (count($pages) == 0) {
    \Lobby::ser("No Pages", "No pages has been created.");
    echo '<p><strong>Note that a page called "index" should be created in the site.</strong></p>';
} else {
    echo "<h3>Pages</h3>";
    foreach ($pages as $id => $page) {
        echo \Lobby::l("{$su}/edit?id={$id}", "{$id}", "class='button'") . "<cl/>";
    }
}
?>
  </p>
</div>
Ejemplo n.º 16
0
<div class="sidebar">
  <div style="height:32px;text-align:center;margin-top:10px;">
    <a target="_blank" href="http://lobby.subinsb.com" style="color:white;">Lobby <?php 
echo getOption("lobby_version");
?>
</a>
  </div>
  <?php 
$links = array("/admin" => "Dashboard", "/admin/apps.php" => "Apps", "/admin/lobby-store.php" => "Lobby Store", "/admin/modules.php" => "Modules", "/admin/about.php" => "About");
$curPage = \Lobby::curPage();
foreach ($links as $link => $text) {
    if ($link == $curPage || $curPage == "/admin/update.php" && $text == "About") {
        echo \Lobby::l($link, $text, "class='link active'");
    } else {
        echo \Lobby::l($link, $text, "class='link'");
    }
}
?>
</div>
Ejemplo n.º 17
0
<?php

$this->addStyle("admin.css");
$this->addStyle("jquery.fancybox.css");
$this->addScript("jquery.fancybox.js");
$this->addScript("chart.min.js");
$this->addScript("admin.js");
?>
<div class='leftpane'>
  <center>
    <h3>logSys<br/><span style='font-size: 12px;'><?php 
echo $this->manifest['version'];
?>
<a style='display: block;' href='http://subinsb.com/php-logsys?utm_source=lobby_logsys.admin' target='_blank'>Documentation</a></span></h3>
  </center>
  <div>
    <?php 
$links = array("/admin" => "Home", "/admin/users" => "Users", "/admin/tokens" => "Tokens", "/admin/stats" => "Stats", "/admin/config" => "Settings");
foreach ($links as $link => $name) {
    echo $this->l($link, $name, \Lobby::curPage() == "/app/fr-logsys{$link}" ? "class='active'" : "");
}
?>
  </div>
</div>
<div class='rightpane'>
Ejemplo n.º 18
0
<?php

/**
 * Make important locations and URLs as 
 * constants to easily access them
 */
define("L_URL", \Lobby::getURL());
define("THEME_ID", Lobby\UI\Themes::getThemeID());
define("THEME_DIR", Lobby\UI\Themes::getThemeDir());
define("THEME_URL", Lobby\UI\Themes::getThemeURL());
/**
 * LOAD MODULES
 * ------------
 * It will first, load the core modules
 * Then the custom modules
 */
\Lobby\Modules::load();
Ejemplo n.º 19
0
    if ($q !== null) {
        $params = array("q" => $_GET['q']);
    } else {
        $params = array("get" => "popular");
    }
    if ($p !== null) {
        $params["p"] = $p;
    }
    $server_response = \Lobby\Server::store($params);
    if ($server_response == false) {
        echo ser("Nothing Found", "Nothing was found that matches your criteria. Sorry...");
    } else {
        echo "<div class='apps row'>";
        foreach ($server_response['apps'] as $app) {
            $appImage = $app['image'] != "" ? $app['image'] : L_URL . "/includes/lib/lobby/image/blank.png";
            $url = \Lobby::u("/admin/lobby-store.php?app={$app['id']}");
            ?>
                <div class="app card col s12 m6 l6">
                  <div class="app-inner row">
                    <div class="lpane col s4 m5 l4">
                      <a href="<?php 
            echo $url;
            ?>
">
                        <img src="<?php 
            echo $appImage;
            ?>
" />
                      </a>
                    </div>
                    <div class="rpane col s8 m6 l8">
Ejemplo n.º 20
0
<?php

require "../load.php";
?>
<!DOCTYPE html>
<html>
  <head>
    <?php 
\Lobby::doHook("admin.head.begin");
\Lobby::head("Install App");
//~
?>
  </head>
  <body>
    <?php 
\Lobby::doHook("admin.body.begin");
?>
    <div class="workspace">
      <div class="contents">
        <?php 
if (H::input("id") == null) {
    ser("Error", "No App is mentioned. Install Apps from <a href='lobby-store.php'>Lobby Store</a>");
}
if (H::input("action") == "enable" && H::csrf()) {
    $App = new \Lobby\Apps($_GET['id']);
    if (!$App->exists) {
        ser("Error", "App is not installed");
    }
    $App->enableApp();
    sss("Enabled", "The App <b>{$_GET['id']}</b> is enabled. The author says thanks.<a href='" . $App->info['URL'] . "' class='button green'>Open App</a>");
}
Ejemplo n.º 21
0
<?php

if (!\Lobby::status("lobby.admin")) {
    \Lobby::addScript("keyring_module", L_URL . "/contents/apps/keyring/module/js/keyring.js");
}
Ejemplo n.º 22
0
 /**
  * Write messages to log file
  */
 public function log($msg)
 {
     \Lobby::log($msg, "app." . $this->id . ".log");
 }
Ejemplo n.º 23
0
              <?php 
    foreach ($Apps as $app => $null) {
        $App = new \Lobby\Apps($app);
        $data = $App->info;
        $appImage = !isset($data['image']) ? L_URL . "/includes/lib/core/Img/blank.png" : $data['image'];
        $enabled = $App->isEnabled();
        ?>
                <tr <?php 
        if (!$enabled) {
            echo 'style="background: #EEE;"';
        }
        ?>
>
                  <td>
                    <a href="<?php 
        echo \Lobby::u("/admin/app/{$app}");
        ?>
"><?php 
        echo $data['name'];
        ?>
</a>
                  </td>
                  <td><?php 
        echo $data['version'];
        ?>
</td>
                  <td><?php 
        echo $data['short_description'];
        ?>
</td>
                  <td style="//text-align:center;">
Ejemplo n.º 24
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);
Ejemplo n.º 25
0
 /**
  * Write messages to log file
  */
 public function log($msg)
 {
     \Lobby::log($msg, "apps.log");
 }
Ejemplo n.º 26
0
  <head>
    <?php 
if (\Lobby::status("lobby.admin")) {
    \Hooks::doAction("admin.head.begin");
} else {
    \Hooks::doAction("head.begin");
}
\Response::head();
if (\Lobby::status("lobby.admin")) {
    \Hooks::doAction("admin.head.end");
} else {
    \Hooks::doAction("head.end");
}
?>
  </head>
  <body>
    <?php 
if (\Lobby::status("lobby.admin")) {
    \Hooks::doAction("admin.body.begin");
} else {
    \Hooks::doAction("body.begin");
}
?>
    <div id="workspace">
      <?php 
echo \Response::getPageContent();
?>
    </div>
  </body>
</html>
Ejemplo n.º 27
0
<div class="contents">
  <h1>CSS Compressor</h1>
  <p>Paste your CSS code in the textbox below and COMPRESS !</p>
  <form action="<?php 
echo \Lobby::u();
?>
" method="POST">
    <center>
      <textarea name="code"></textarea></textarea><cl/>
      <button style="font-size: 18px;">Compress</button>
    </center>
  </form>
  <?php 
if (isset($_POST['code'])) {
    include APP_DIR . "/src/load.php";
    $code = $_POST['code'];
    $cmp = $SC->_compressor("css", $code);
    $cmp = htmlspecialchars($cmp);
    ?>
    <h2>Compressed Code</h2>
    <p>Here is the compressed code. Hurray!</p>
    <textarea><?php 
    echo $cmp;
    ?>
</textarea>
  <?php 
}
?>
  <style>
    textarea{height: 200px;width: 600px;}
  </style>
Ejemplo n.º 28
0
 /**
  * Return the app class object
  */
 public function run()
 {
     if ($this->app) {
         require_once L_DIR . "/includes/src/App.php";
         require_once $this->appDir . "/App.php";
         \Lobby::addScript("app", "/includes/lib/core/JS/app.js");
         $appInfo = $this->info;
         $className = str_replace("-", "_", $this->app);
         /* Create the \Lobby\App Object */
         $class = new $className();
         /* Send app details to the \Lobby\App */
         $class->setTheVars($appInfo);
         /**
          * Define the App Constants
          */
         define("APP_DIR", $this->appDir);
         define("APP_SRC", $this->info['srcURL']);
         if (!defined("APP_URL")) {
             /**
              * We specifically check if APP_URL is defined,
              * because it may be already defined by `singleapp` module.
              */
             define("APP_URL", $this->info['URL']);
         }
         /* Return the App Object */
         return $class;
     }
 }
Ejemplo n.º 29
0
 public static function log($m)
 {
     return \Lobby::log($m, "app.sige.log");
     // Log writing will only happen in the debugging is enabled in config.php
 }
Ejemplo n.º 30
0
<?php

if (\Lobby::curPage() != "/includes/serve.php") {
    require_once __DIR__ . "/install.php";
    require_once __DIR__ . "/module.php";
}