public static function loadConfig() { $tz = DB::getOption("lobby_timezone"); if ($tz !== null) { self::$tz = $tz; } }
public static function addStat() { if (isset($_POST["lobby"]["lid"]) && isset($_POST["lobby"]["version"])) { $sql = \Lobby\DB::getDBH()->prepare("INSERT INTO `lobby_api_access` (`lid`, `version`, `accessed`, `frequency`) VALUES (:lid, :version, UNIX_TIMESTAMP(), '1') ON DUPLICATE KEY UPDATE `accessed` = UNIX_TIMESTAMP(), `frequency` = `frequency` + 1, `version` = :version"); $sql->execute(array("lid" => $_POST["lobby"]["lid"], "version" => $_POST["lobby"]["version"])); } }
function removeData($key = "", $appID = "") { if (!\Lobby::$installed) { return false; } else { $appID = $appID == "" ? $GLOBALS['AppID'] : $appID; return \Lobby\DB::removeData($appID, $key); } }
/** * Install module * -------------- * Create the `users` table */ public function install() { if (DB::getOption("admin_installed") == null && \Lobby::$installed) { /** * Install Module */ $salt = \Helper::randStr(15); $cookie = \Helper::randStr(15); DB::saveOption("admin_secure_salt", $salt); DB::saveOption("admin_secure_cookie", $cookie); $prefix = DB::getPrefix(); /** * Create `users` TABLE */ $sql = DB::getDBH()->prepare("CREATE TABLE IF NOT EXISTS `{$prefix}users` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `username` varchar(10) NOT NULL,\n `password` varchar(255) NOT NULL,\n `name` varchar(30) NOT NULL,\n `created` datetime NOT NULL,\n `attempt` varchar(15) NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;"); if ($sql->execute() != 0) { DB::saveOption("admin_installed", "true"); } } }
/** * 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); } } } } }
/** * Initialization * @param array $themeVARS Contains directory and URL to `themes` folder */ public static function __constructStatic($themesVARS) { self::$themesDir = $themesVARS[0]; self::$themesURL = Lobby::u($themesVARS[1]); self::$themeID = DB::getOption("active_theme"); /** * Default theme is `hine` */ if (self::$themeID === null) { self::$themeID = "hine"; } else { if (self::validTheme(self::$themeID) === false) { self::$themeID = "hine"; } } self::$url = self::$themesURL . "/" . self::$themeID; self::$dir = self::$themesDir . "/" . self::$themeID; if (!\Lobby::status("lobby.assets-serve")) { self::loadDefaults(); self::loadTheme(); } }
public function getRepo() { if (file_exists($this->git_dir)) { $this->recursiveRemoveDirectory($this->git_dir); } $repo = Gitonomy\Git\Admin::cloneTo($this->git_dir, $this->git_url, false); $tags = $repo->getReferences()->getTags(); /** * If no tags, use master */ if (empty($tags)) { $commitHash = $repo->getReferences()->getBranch('master')->getCommitHash(); } else { rsort($tags); $commitHash = $tags[0]->getCommitHash(); } if ($commitHash === $this->info["last_commit"]) { // No need of update return true; } $sql = \Lobby\DB::getDBH()->prepare("UPDATE `git_cache` SET `last_commit` = ? WHERE `git_url` = ?"); $sql->execute(array($commitHash, $this->git_url)); $this->recursiveRemoveDirectory($this->git_dir . "/.git"); /** * Get screenshots */ $manifest = json_decode(file_get_contents($this->git_dir . "/manifest.json"), true); // Manifest file is invalid if (!is_array($manifest)) { return false; } if (isset($manifest["version"])) { $latestVersion = $manifest["version"]; } else { return false; } if (isset($manifest->screenshots)) { $screenshots = array(); foreach ($manifest["screenshots"] as $img) { $url = parse_url($img); if ($url["host"] === "i.imgur.com") { $path = $url["path"]; // $path has slash at beginning $headers = @get_headers("http://i.imgur.com{$path}", 1); if ($headers[0] === "HTTP/1.1 200 OK") { $screenshots[] = "//i.imgur.com{$path}"; } } } if (empty($screenshots)) { unset($screenshots); } } if (exec("cd {$this->git_dir};zip -r '{$this->git_dir}/app.zip' ./ -1 -q;") !== false) { $logo = true; if (file_exists($this->git_dir . "/src/image/logo.svg")) { $this->convertLogoToPNG(); } else { if (file_exists($this->git_dir . "/src/image/logo.png")) { copy($this->git_dir . "/src/image/logo.png", $this->git_dir . "/logo.png"); } else { $logo = false; } } $webdavPass = getenv("SKY_WEBDAV_PASS"); $settings = array('baseUri' => "https://sky-phpgeek.rhcloud.com/remote.php/webdav/Apps/{$this->id}/", 'userName' => 'lobby-apps', 'password' => $webdavPass); $client = new Client($settings); /** * Create folder */ $client->request('MKCOL'); /** * Upload files */ $client->request('PUT', "{$this->id}.zip", file_get_contents($this->git_dir . "/app.zip")); if ($logo) { $client->request('PUT', "logo.png", file_get_contents($this->git_dir . "/logo.png")); } $request = \Requests::post("https://sky-phpgeek.rhcloud.com/ocs/v1.php/apps/files_sharing/api/v1/shares?format=json", array("Content-Type" => "application/x-www-form-urlencoded"), array("path" => "Apps/{$this->id}", "shareType" => "3"), array("auth" => array("lobby-apps", $webdavPass))); $response = json_decode($request->body); $this->cloud_id = $response->ocs->data->token; $extraColumnData = array("short_description" => $manifest["short_description"]); if (isset($latestVersion)) { $extraColumnData["version"] = $latestVersion; } if (isset($screenshots)) { $extraColumnData["screenshots"] = implode("\n", $screenshots); } if (isset($manifest["require"]) && is_array($manifest["require"])) { $extraColumnData["requires"] = json_encode($manifest["require"]); } /** * Update Cloud ID and download file size */ $appInfoUpdate = array(":cloudID" => $this->cloud_id, ":downloadSize" => filesize($this->git_dir . "/app.zip"), ":appID" => $this->id); $extraColumns = ""; if (!empty($extraColumnData)) { foreach ($extraColumnData as $k => $v) { $extraColumns .= ", {$k} = :{$k}"; $appInfoUpdate[":{$k}"] = $v; } } $sql = \Lobby\DB::getDBH()->prepare("UPDATE `apps` SET `cloud_id` = :cloudID, `download_size` = :downloadSize, `updated` = NOW() {$extraColumns} WHERE `id` = :appID"); $sql->execute($appInfoUpdate); $this->recursiveRemoveDirectory($this->git_dir); return true; } return false; }
<div>Version : <?php echo $app['version']; ?> </div> </div> </div> </div> <?php } } ?> </div> </div> <?php } else { $sql = \Lobby\DB::getDBH()->prepare("SELECT * FROM `apps` WHERE `id` = ?"); $sql->execute(array($node)); if ($sql->rowCount() == "0") { ser(); } else { $this->addStyle("app.css"); $appInfo = $sql->fetch(\PDO::FETCH_ASSOC); \Response::setTitle($appInfo['name'] . " | Store"); require_once $this->dir . "/src/inc/Parsedown.php"; $Parsedown = new Parsedown(); ?> <div class="contents"> <?php $no_header = 1; require_once $this->dir . "/src/inc/views/top.apps.php"; ?>
public static function finish_software_update($admin_previously_installed = false) { FS::write("/upgrade.lobby", "1", "w"); if ($admin_previously_installed) { FS::remove("/contents/modules/admin/disabled.txt"); } $latest_version = DB::getOption("lobby_latest_version"); self::log("Updated Lobby to version {$latest_version}"); /** * Remove Depreciated Files */ $deprecatedFilesInfoLoc = "/contents/update/removeFiles.php"; if (FS::exists($deprecatedFilesInfoLoc)) { $files = FS::get($deprecatedFilesInfoLoc); $files = explode("\n", $files); if (count($files) !== 0) { $files = array_filter($files); foreach ($files as $file) { $fileLoc = L_DIR . "/{$file}"; if (file_exists($fileLoc) && $fileLoc != L_DIR) { FS::remove($fileLoc); self::log("Removed Deprecated File: {$fileLoc}"); } } copy(FS::loc($deprecatedFilesInfoLoc), FS::loc("{$deprecatedFilesInfoLoc}.txt")); FS::remove($deprecatedFilesInfoLoc); self::log("Finished Removing Deprecated Files"); } } /** * Database Update */ if (FS::exists("/update/sqlExecute.sql")) { self::log("Upgrading Lobby Database"); $sqlCode = FS::get("/update/sqlExecute.sql"); $sql = \Lobby\DB::prepare($sqlCode); if (!$sql->execute()) { echo ser("Error", "Database Update Couldn't be made. <a href='update.php'>Try again</a>"); } else { FS::remove("/update/sqlExecute.sql"); } self::log("Updated Lobby Database"); } FS::remove("/upgrade.lobby"); self::log("Lobby is successfully Updated."); }
public function clearData() { $sql = \Lobby\DB::getDBH()->prepare("DELETE FROM `" . \Lobby\DB::getPrefix() . "data` WHERE `app` = ?"); $sql->execute(array($this->app)); return true; }
$App = new \Lobby\Apps("lobby-server"); $App->run(); require APPS_DIR . "/lobby-server/src/inc/LobbyGit.php"; /** * Argument 1 has the App ID */ if (isset($argv[1])) { $sql = \Lobby\DB::getDBH()->prepare("SELECT `id`, `git_url` FROM `apps` WHERE `id` = ?"); $sql->execute(array($argv[1])); if ($sql->rowCount() !== 0) { $r = $sql->fetch(\PDO::FETCH_ASSOC); $LG = new \LobbyGit($r['id'], $r['git_url']); if ($LG->update()) { echo "{$r['id']} updated\r\n"; } else { echo "{$r['id']} failed to update\r\n"; } } } else { $sql = \Lobby\DB::getDBH()->prepare("SELECT `id`, `git_url` FROM `apps` ORDER BY `downloads` DESC"); $sql->execute(); while ($r = $sql->fetch()) { echo "{$r['id']} updating...\n"; /** * Constructing will update app if it hasn't been updated in a day */ $LG = new \LobbyGit($r['id'], $r['git_url']); $LG->register(); echo "{$r['id']} updated.\n"; } }
<table> <thead> <colgroup> <col span="1" style="width: 15%;"> <col span="1" style="width: 15%;"> <col span="2" style="width: 55%;"> <col span="1" style="width: 15%;"> </colgroup> <tr> <th>Lobby Version</th> <th>Frequency</th> <th>Last Accessed</th> <th>Public ID</th> </tr> </thead> <tbody> <?php $sql = \Lobby\DB::getDBH()->query("SELECT * FROM `lobby_api_access` ORDER BY `accessed` DESC"); while ($r = $sql->fetch(\PDO::FETCH_ASSOC)) { echo "<tr>"; echo "<td>{$r['version']}</td>"; echo "<td>{$r['frequency']}</td>"; echo "<td>" . Lobby\Time::date(date("Y-m-d H:i:s", $r['accessed']), "Y-m-d H:i:s") . "</td>"; echo "<td><div style='width: 300px;'>{$r['lid']}</div></td>"; echo "</tr>"; } ?> </tbody> </table> </div>
$this->setTitle("New App"); ?> <div class="contents"> <h1>Add App</h1> <?php $app_info = array("id" => \Request::get("app_id"), "name" => \Request::get("app_name"), "git_url" => \Request::get("app_download"), "requires" => \Request::get("app_requires"), "short_description" => \Request::get("app_short_description"), "description" => \Request::get("app_description"), "category" => \Request::get("app_category"), "sub_category" => \Request::get("app_sub_category"), "version" => \Request::get("app_version"), "page" => \Request::get("app_page"), "author_id" => \Request::get("author_id")); if (isset($_POST['app_id']) && array_search(null, $app_info) === false && CSRF::check()) { $apps_sql = \Lobby\DB::getDBH()->prepare("SELECT COUNT(1) FROM `apps` WHERE `id` = ?"); $apps_sql->execute(array($app_info['id'])); if ($apps_sql->fetchColumn() != 0) { ser("App Exists", "Hmmm... Looks like the App ID you submitted already exists either on App Center Or in the App Queue. " . \Lobby::l("/apps/{$app_info['id']}", "See Existing App")); } else { $app_info["logo"] = isset($_POST["app_logo"]) ? "1" : "0"; $lobby_web = isset($_POST['app_lobby_web']) ? 1 : 0; $sql = \Lobby\DB::getDBH()->prepare("INSERT INTO `apps` (`id`, `name`, `version`, `logo`, `requires`, `git_url`, `description`, `short_description`, `category`, `sub_category`, `app_page`, `author`, `lobby_web`, `updated`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW());"); $sql->execute(array($app_info['id'], $app_info['name'], $app_info['version'], $app_info['logo'], $app_info['requires'], $app_info['git_url'], $app_info['description'], $app_info['short_description'], $app_info['category'], $app_info['sub_category'], $app_info['page'], $app_info['author_id'], $lobby_web)); require_once __DIR__ . "/../../inc/LobbyGit.php"; $LG = new LobbyGit($app_info["id"], $app_info["git_url"]); $LG->register(); sss("App Added", "App was added to the repository"); } } ?> <form action="<?php echo \Lobby::u(); ?> " method="POST"> <label> <span>App ID</span> <input type="text" name="app_id" />
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."); }
function filt($string) { return \Lobby\DB::filt(urldecode($string)); }
<div class="contents"> <h1><?php echo $u['display_name']; ?> </h1> <p>Real Name : <?php echo $u['name']; ?> </p> <p>Member of Lobby since <?php echo date("d F Y", $u['registered']); ?> </p> <h2>Apps</h2> <?php $sql = \Lobby\DB::getDBH()->prepare("SELECT `id`, `name`, `short_description`, `downloads` FROM `apps` WHERE `author` = ?"); $sql->execute(array($user)); if ($sql->rowCount() != 0) { echo "<table>"; echo "<thead><tr><td>App</td><td>Description</td><td>Downloads</td></tr></thead>"; echo "<tbody>"; while ($r = $sql->fetch()) { echo "<tr>\n <td><a target='_blank' href='/apps/{$r['id']}'>{$r['name']}</a></td>\n <td>{$r['short_description']}</td>\n <td>{$r['downloads']}</td>\n </tr>"; } echo "</tbody>"; echo "</table>"; } else { echo "User haven't created any apps"; } ?> </div>
<?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>
* Prefix is "l_" and can't be changed */ if ($db_create && \Lobby\Install::makeDatabase("l_", "sqlite")) { /** * We give the database config to the Install Class */ \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();
</td> </tr> <tr> <td>Latest Version Release Date</td> <td><?php echo Lobby\DB::getOption("lobby_latest_version_release"); ?> </td> </tr> </tbody> </table> <cl/> <?php /** * Check if the current version is not the latest version */ if (\Lobby::$version < \Lobby\DB::getOption("lobby_latest_version")) { ?> <div clear></div> <a class="btn red" href="update.php">Update To Version <?php echo Lobby\DB::getOption("lobby_latest_version"); ?> </a> <?php } ?> </div> </div> </body> </html>
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 `content` = ?, `updated` = NOW() WHERE `name` = ? AND `app` = ?"); $sql->execute(array($value, $key, $appID)); return true; } else { $sql = self::$dbh->prepare("INSERT INTO `" . self::$prefix . "data` (`app`, `name`, `content`, `created`, `updated`) VALUES (?, ?, ?, NOW(), NOW())"); return $sql->execute(array($appID, $key, $value)); } } else { return false; } } /** * Remove App Data */ public static function removeData($appID = "", $keyName) { if (self::$installed) { if ($keyName != "" && $appID != "") { $sql = self::$dbh->prepare("DELETE FROM `" . self::$prefix . "data` WHERE `name`=? AND `app`=?"); $sql->execute(array($keyName, $appID)); return true; } } } } \Lobby\DB::init();
if ($app_edit != true && ($queue_sql->fetchColumn() != 0 || $apps_sql->fetchColumn() != 0)) { ser("App Exists", "Hmmm... Looks like the App ID you submitted already exists either on App Center Or in the App Queue. " . \Lobby::l("/apps/{$app_info['id']}", "See Existing App")); } else { if ($app_edit != true && preg_match("/\\b(?:(?:https?|ftp):\\/\\/|www\\.)[-a-z0-9+&@#\\/%?=~_|!:,.;]*[-a-z0-9+&@#\\/%=~_|]/i", $app_info['git_url']) == 0) { ser("Invalid URL", "The app's source code URL you provided was invalid."); } else { if ($app_edit != true) { $sql = \Lobby\DB::getDBH()->prepare("INSERT INTO `apps_queue` (`id`, `name`, `src`, `description`, `category`, `sub_category`, `app_page`, `author`, `updated`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW());"); $sql->execute(array($app_info['id'], $app_info['name'], $app_info['git_url'], $app_info['description'], $app_info['category'], $app_info['sub_category'], $app_info['app_page'], \Fr\LS2::$user)); $admin_access_token = \Fr\LS2::getUser("username", 1); require_once $this->dir . "/src/inc/open.auth.php"; $Opth = new OpenAuth("EAtGbLfgxiCJxhwWfsLsyxA0p8Zj4oUyOd4POaVc", "80d23edfa535caf4cc44b91e16c55c0f09e3bed927fecff96b092df0f517f410"); $Opth->action("email", array("subject" => "Lobby App Review", "body" => "Dude, a person requested to review her/his app ({$app_info['id']}). Please go and check it. http://lobby.subinsb.com"), $admin_access_token); sss("App Submitted", "Your app was added to the review queue. You will be notified by email about your app's review status."); } else { $sql = \Lobby\DB::getDBH()->prepare("UPDATE `apps` SET `name` = ?, `logo` = ?, `description` = ?, `category` = ?, `sub_category` = ?, `app_page` = ?, `lobby_web` = ?, `updated` = NOW() WHERE `id` = ? AND `author` = ?"); $sql->execute(array($app_info['name'], $app_info['logo'], $app_info['description'], $app_info['category'], $app_info['sub_category'], $app_info['app_page'], $app_info['lobby_web'], $app_info['id'], \Fr\LS2::$user)); sss("Updated", "Your app was successfully updated."); } } } } if ($app_edit) { \Response::setTitle("Edit App " . $app_info['name'] . " | Me"); } else { \Response::setTitle("New App | Me"); } ?> <h1><?php echo $app_edit == true ? $app_info['name'] : "New App"; ?>
public function prepare($query) { $obj = \Lobby\DB::getDBH()->prepare($query); return $obj; }
function getAuthorName($id = 1) { $sql = \Lobby\DB::getDBH()->prepare("SELECT `name` FROM `users` WHERE `id` = ?"); $sql->execute(array($id)); return $sql->fetchColumn(); }
/** * Get App Data */ public static function getData($id, $name = "", $extra = false, $safe = true) { if (self::$installed) { $return = array(); $prefix = self::$prefix; if ($id != "" && $name == "") { $sql = self::$dbh->prepare("SELECT * FROM `{$prefix}data` WHERE `app` = ?"); $sql->execute(array($id)); $return = $sql->fetchAll(); foreach ($return as &$v) { $v["created"] = \Lobby\Time::date($v["created"]); $v["updated"] = \Lobby\Time::date($v["updated"]); } } else { $sql = self::$dbh->prepare("SELECT * FROM `{$prefix}data` WHERE `name` = ? AND `app` = ?"); $sql->execute(array($name, $id)); $r = $sql->fetchAll(\PDO::FETCH_ASSOC); $count = count($r); if ($count > 1) { /** * Multiple Results; so give a multidimensional array of results */ $return = $r; foreach ($return as &$v) { $v["created"] = \Lobby\Time::date($v["created"]); $v["updated"] = \Lobby\Time::date($v["updated"]); } } else { if ($count === 1) { /** * A single result is present, so give a single array only if $extra is TRUE */ $return = $r[0]; if ($extra === false) { $return = $return['value']; } else { /** * Cconvert time to the timezone chosen by user */ $return["created"] = \Lobby\Time::date($return["created"]); $return["updated"] = \Lobby\Time::date($return["updated"]); } } else { $return = array(); } } } if (is_array($return) && $safe === true) { array_walk_recursive($return, function (&$value) { $value = \Lobby\DB::filt($value); }); } return is_array($return) && count($return) == 0 ? null : $return; } }
/** * Remove an item from Notify */ public static function removeNotifyItem($id) { DB::saveJSONOption("notify_items", array($id => false)); }
public function removeData($key) { return DB::removeData($this->id, $key); }
<?php $offset = Request::postParam("offset"); if ($offset !== null) { $timeZone = \Lobby\Time::getTimezone($offset); if (@date_default_timezone_set($timeZone)) { \Lobby\DB::saveOption("lobby_timezone", $timeZone); } }