Example #1
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));
             }
         }
     }
 }
Example #2
0
 /**
  * Disable the app
  */
 public function disableApp()
 {
     if ($this->app && $this->isEnabled()) {
         $apps = self::getEnabledApps();
         if (isset($apps[$this->app])) {
             unset($apps[$this->app]);
             saveOption("active_apps", json_encode($apps));
             self::clearCache();
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Example #3
0
<?php

if (getOption("admin_installed") == null && \Lobby::$installed) {
    /**
     * Install Module
     */
    $salt = \Lobby::randStr(15);
    $cookie = \Lobby::randStr(15);
    saveOption("admin_secure_salt", $salt);
    saveOption("admin_secure_cookie", $cookie);
    $prefix = \Lobby\DB::$prefix;
    /**
     * Create `users` TABLE
     */
    $sql = \Lobby\DB::$dbh->prepare("CREATE TABLE IF NOT EXISTS `{$prefix}users` (\n\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t  `username` varchar(10) NOT NULL,\n\t  `email` tinytext NOT NULL,\n\t  `password` varchar(64) NOT NULL,\n\t  `password_salt` varchar(20) NOT NULL,\n\t  `name` varchar(30) NOT NULL,\n\t  `created` datetime NOT NULL,\n\t  `attempt` varchar(15) NOT NULL DEFAULT '0',\n\t  PRIMARY KEY (`id`)\n  ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
    if ($sql->execute() != 0) {
        saveOption("admin_installed", "true");
    }
}
Example #4
0
include "{$docRoot}/admin/sidebar.php";
?>
    <div class="workspace">
      <div class="content">
        <h1>Update</h1>
        <a class='button' href='check-updates.php'>Check For New Releases</a>
        <?php 
$AppUpdates = json_decode(getOption("app_updates"), true);
if (\H::input("action", "POST") == "updateApps" && H::csrf()) {
    foreach ($AppUpdates as $appID => $neverMindThisVariable) {
        if (isset($_POST[$appID])) {
            echo '<iframe src="' . L_URL . "/admin/download.php?type=app&id={$appID}" . H::csrf("g") . '" style="border: 0;width: 100%;height: 200px;"></iframe>';
            unset($AppUpdates[$appID]);
        }
    }
    saveOption("app_updates", json_encode($AppUpdates));
    $AppUpdates = json_decode(getOption("app_updates"), true);
}
if (!isset($_GET['step']) && isset($AppUpdates) && count($AppUpdates) != 0) {
    ?>
          <h2>Apps</h2>
          <p>App updates are available. Choose which apps to update from the following :</p>
          <form method="POST" clear>
            <?php 
    H::csrf(1);
    ?>
            <table>
              <thead>
                <tr>
                  <td style='width: 5%;'>Update ?</td>
                  <td style='width: 10%;'>App</td>
Example #5
0
<?php

require "../../../../load.php";
if (isset($_POST['key']) && isset($_POST['value']) && H::csrf()) {
    $key = urldecode($_POST['key']);
    $val = urldecode($_POST['value']);
    if (!saveOption($key, $val)) {
        echo "bad";
    } else {
        echo "good";
    }
} else {
    echo "fieldsMissing";
}
Example #6
0
    $adminArray = array("text" => "Admin", "href" => "/admin", "position" => "left");
    $adminArray["subItems"] = array("AppManager" => array("text" => "Apps", "href" => "/admin/apps.php"), "LobbyStore" => array("text" => "Lobby Store", "href" => "/admin/lobby-store.php"), "About" => array("text" => "About", "href" => "/admin/about.php"));
    \Lobby\UI\Panel::addTopItem("lobbyAdmin", $adminArray);
    /**
     * If there is a update available either app or core, add an 
     * "Update Available" icon on the right side of panel
     */
    $AppUpdates = json_decode(getOption("app_updates"), true);
    $lobby_version = getOption("lobby_version");
    $latestVersion = getOption("lobby_latest_version");
    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) {
            saveOption("lobby_latest_version", $l_info->version);
            saveOption("lobby_latest_version_release", $l_info->released);
        }
        \Lobby\Update::finish_software_update();
    }
    if (count($AppUpdates) != 0 || $latestVersion && $lobby_version != $latestVersion) {
        \Lobby\UI\Panel::addTopItem("updateNotify", array("html" => \Lobby::l("/admin/update.php", "<span id='update' title='An Update Is Available'></span>"), "position" => "right"));
    }
}
if (\Lobby::status("lobby.install")) {
    \Lobby::addStyle("admin", "/includes/lib/core/CSS/admin.css");
}
if (\Lobby::status("lobby.admin")) {
    /**
     * Add Admin Pages' stylesheet
     */
    \Lobby::addStyle("admin", "/includes/lib/core/CSS/admin.css");
Example #7
0
 public static function finish_software_update($admin_previously_installed = false)
 {
     if ($admin_previously_installed) {
         \Lobby\FS::remove("/contents/modules/admin/disabled.txt");
     }
     $latest_version = getOption("lobby_latest_version");
     \Lobby::log("Updated Lobby Software To version {$latest_version}");
     /* Remove Depreciated Files */
     if (\Lobby\FS::exists("/contents/update/removeFiles.php")) {
         $files = \Lobby\FS::get("/contents/update/removeFiles.php");
         $files = explode("\n", $files);
         if (count($files) != 0) {
             foreach ($files as $file) {
                 // iterate files
                 $fileLoc = L_DIR . "/{$file}";
                 if (file_exists($fileLoc) && $fileLoc != L_DIR) {
                     $type = filetype($fileLoc);
                     if ($type == "file") {
                         \Lobby\FS::remove($fileLoc);
                     } else {
                         if ($type == "dir") {
                             rmdir($fileLoc);
                         }
                     }
                 }
             }
             \Lobby\FS::remove(L_DIR . "/contents/update/removeFiles.php");
             \Lobby::log("Removed Deprecated Files");
         }
     }
     /**
      * Database Update
      */
     if (\Lobby\FS::exists("/update/sqlExecute.sql")) {
         \Lobby::log("Upgrading Lobby Database");
         $sqlCode = \Lobby\FS::get("/update/sqlExecute.sql");
         $sql = \Lobby\DB::prepare($sqlCode);
         if (!$sql->execute()) {
             ser("Error", "Database Update Couldn't be made. <a href='update.php'>Try again</a>");
         } else {
             \Lobby\FS::remove("/update/sqlExecute.sql");
         }
         \Lobby::log("Updated Lobby Database");
     }
     $oldVer = getOption("lobby_version");
     saveOption("lobby_version", $latest_version);
     saveOption("lobby_version_release", getOption("lobby_latest_version_release"));
     \Lobby\FS::remove("/upgrade.lobby");
     \Lobby::log("Lobby is successfully Updated.");
 }