function update() { $db = new DB("pref"); $db->setColPrefix("pref_"); foreach ($this->_vars as $name => $value) { $db->value = $value; $db->update("pref_name = '" . $name . "' AND pref_target = '" . $db->escape($this->target) . "'"); } }
function getLastMsg($uid) { $db = new DB("messages"); $db->setColPrefix("message_"); $db->setSort("message_added DESC"); $db->select("message_sender = '" . USER_ID . "' AND message_receiver = '" . $uid . "' OR message_sender = '" . $uid . "' AND message_receiver = '" . USER_ID . "'"); $db->nextRecord(); return array("added" => $db->added); }
function addLog($user, $msg) { $db = new DB("users_log"); $db->setColPrefix("log_"); $db->user = $user; $db->poster = USER_ID; $db->added = time(); $db->msg = $msg; $db->insert(); }
/** * Load notifications * @param type $limit */ function load($limit = 5) { $db = new DB("notifications"); $db->setColPrefix("notification_"); $db->setSort("notification_added DESC"); if (intval($limit)) { $db->setLimit($limit); } $db->select("notification_user = '******'"); if ($db->numRows()) { $return = ""; while ($db->nextRecord()) { $return .= "<li>"; switch ($db->type) { case 'friend': $data = json_decode($db->data); $user = new Acl($data->user); switch ($data->type) { case 'accept': $return .= "<b><a href='" . page("profile", "view", $user->name) . "'>" . $user->name . "</a></b> <small>" . get_date($db->added) . "</small> <br /> " . _t("Has accepted your friend request"); break; case 'decline': $return .= "<b><a href='" . page("profile", "view", $user->name) . "'>" . $user->name . "</a></b> <small>" . get_date($db->added) . "</small> <br /> " . _t("Has declined your friend request"); break; case 'remove': $return .= "<b><a href='" . page("profile", "view", $user->name) . "'>" . $user->name . "</a></b> <small>" . get_date($db->added) . "</small> <br /> " . _t("Has removed you from his friends list"); break; } break; case 'system': $data = json_decode($db->data); $group = new DB("groups"); $group->setColPrefix("group_"); $group->select("group_id = '" . $data->group . "'"); $group->nextRecord(); switch ($data->type) { case 'upgrade': $return .= _t("You have been upgraded to ") . "<b>" . $group->name . "</b><br /><small>" . get_date($db->added) . "</small>"; break; case 'downgrade': $return .= _t("You have been demoted to ") . "<b>" . $group->name . "</b><br /><small>" . get_date($db->added) . "</small>"; break; } break; } $return .= "</li>"; } } else { $return = "<li>" . _t("No notifications found") . "</li>"; } echo $return; }
/** * Update the pref values on the selected target. */ function update() { $db = new DB("pref"); $db->setColPrefix("pref_"); foreach ($this->_vars as $name => $value) { $db->select("pref_name = '" . $name . "' AND pref_target = '" . $db->escape($this->target) . "'"); if ($db->numRows()) { $db->value = $value; $db->update("pref_name = '" . $name . "' AND pref_target = '" . $db->escape($this->target) . "'"); } else { $db->name = $name; $db->value = $value; $db->target = $this->target; $db->insert(); } } }
/** * Build the navigation * @return string */ function build() { $db = new DB("navigations"); $db->setColPrefix("navigation_"); $db->setSort("navigation_sorting ASC"); $db->select("navigation_lang = '" . CURRENT_LANGUAGE . "'"); if (!$db->numRows()) { $db->select("navigation_lang = '" . DEFAULT_LANGUAGE . "'"); } $menu = ""; while ($db->nextRecord()) { if ($db->module != "") { $menu .= $this->item($db->title, $db->application, $db->module); } else { $menu .= $this->item($db->title, $db->application); } } return $menu; }
</td> </tr> <tr> <td><input type="submit" name="install" value="<?php echo _t("Save"); ?> "></td> </tr> </table> </form> <?php if (isset($_POST['install'])) { try { if (empty($_POST['name'])) { throw new Exception("missing form"); } $db = new DB("widgets"); $db->setColPrefix("widget_"); $db->name = $_POST['name']; $db->module = $_POST['module']; $db->group = $_POST['group']; $db->update("widget_id = '" . $db->escape($this->id) . "'"); header("location: " . page("admin", "widgets")); } catch (Exception $e) { echo error(_t($e->getMessage())); } } } catch (Exception $e) { echo error(_t($e->getMessage())); }
/** * Get all forum categories * @param int $selected * @return string */ function getForumCategory($selected = "") { $data = ""; $db = new DB("forum_categories"); $db->setColPrefix("category_"); $db->setSort("category_sort ASC"); $db->select(); while ($db->nextRecord()) { if ($db->id == $selected) { $data .= "<option value='" . $db->id . "' SELECTED>" . $db->title . "</option>"; } else { $data .= "<option value='" . $db->id . "'>" . $db->title . "</option>"; } } return $data; }
try { if (!$this->addon) { throw new Exception("missing data"); } $addon = new Addon($this->addon); if (!$addon->checkInstall()) { throw new Exception("addons is not installable"); } if (isset($_POST['save'])) { try { if ($_POST['secure_input'] != $_SESSION['secure_token']) { throw new Exception("Wrong secured token"); } $addon->Install(); $db = new DB("addons"); $db->setColPrefix("addon_"); $db->installed = true; $db->group = $_POST['group']; $db->update("addon_name = '" . $db->escape($this->addon) . "'"); header("location: " . page("admin", "addons"), true); } catch (Exception $e) { echo error(_t($e->getMessage())); } } $db = new DB("addons"); $db->select("addon_name = '" . $db->escape($this->addon) . "'"); $db->nextRecord(); ?> <h4><?php echo _t("Edit Addon"); ?>
<td width="40px" class="border-bottom"></td> <td class="border-bottom"><?php echo _t("Forum name"); ?> </td> <td width="70px" class="border-bottom border-right"></td> <td width="66px" class="border-bottom border-right" align="center"><?php echo _t("Topics"); ?> </td> </tr> </thead> <tbody> <?php $forums = new DB("forum_forums"); $forums->setColPrefix("forum_"); $forums->setSort("forum_sort ASC"); $forums->select("forum_group <= " . $acl->group . " AND forum_category = '" . $forum_cat->id . "'"); while ($forums->nextRecord()) { $db = new DB(); $db->query("SELECT COUNT(topic_id) as topics FROM {PREFIX}forum_topics WHERE topic_forum = '" . $forums->id . "'"); $db->nextRecord(); $topics = $db->topics; $db = new DB("forum_topics"); $db->join("left", "{PREFIX}forum_posts", "topic_id", "post_topic"); $db->setSort("post_added DESC"); $db->setLimit("1"); $db->select("topic_forum = '" . $forums->id . "'"); if (!$db->numRows()) { $last_post = "--"; } else {
if (empty($_POST['subject'])) { throw new Exception("Missing subject name"); } if (empty($_POST['content'])) { throw new Exception("Missing topic content"); } $t = new DB("forum_topics"); $t->setColPrefix("topic_"); $t->userid = USER_ID; $t->subject = $_POST['subject']; $t->forum = $forum_id; $t->insert(); $topic_id = $t->getId(); $topic_name = cleanurl($_POST['subject']); $p = new DB("forum_posts"); $p->setColPrefix("post_"); $p->topic = $topic_id; $p->user = USER_ID; $p->content = $_POST['content']; $p->added = time(); $p->insert(); $post_id = $p->getId(); header("location: " . page("forums", "view-topic", "{$topic_name}-" . $topic_id, "", "", "page=p{$post_id}#post{$post_id}")); } catch (Exception $e) { echo error(_t($e->getMessage())); } } echo "<h4>" . _t("Create topic in") . " " . $db->name . "</h4>"; ?> <form method="post">
echo _t("Created"); ?> </strong> </td> <td width="100px" class="border-bottom"> <strong><?php echo _t("By"); ?> </strong> </td> </tr> </thead> <tbody> <?php $db = new DB("news"); $db->setColPrefix("news_"); $db->setSort("news_added DESC"); $db->select(); while ($db->nextRecord()) { $user = new Acl($db->userid); ?> <tr> <td class="border-bottom"> <a href="<?php echo page("admin", "news", "edit", "", "", "id=" . $db->id); ?> "><?php echo htmlformat($db->subject, false); ?> </a> </td>
/** * Generate a new passkey */ function newPasskey() { $passkey = md5(uniqid(true)); $db = new DB("users"); $db->setColPrefix("user_"); $db->passkey = $passkey; $db->update("user_id = '" . $this->id . "'"); $this->__set("passkey", $passkey); }
if (!intval($_GET['torrent'])) { throw new Exception("Invalid id"); } $torrent_id = $_GET['torrent']; $torrent = new DB("torrents"); $torrent->setColPrefix("torrent_"); $torrent->select("torrent_id = '" . $torrent_id . "'"); if (!$torrent->numRows()) { throw new Exception("File not found"); } $torrent->nextRecord(); if (!isset($_GET['passkey'])) { $acl = new Acl(USER_ID); } else { $db = new DB("users"); $db->setColPrefix("user_"); $db->select("user_passkey = '" . $db->escape($_GET['passkey']) . "'"); if (!$db->numRows()) { throw new Exception("user not found"); } $db->nextRecord(); $acl = new Acl($db->id); } $fn = PATH_TORRENTS . $torrent->id . ".torrent"; $dict = Bcode::bdec_file($fn, filesize($fn)); $dict['value']['announce']['value'] = CMS_URL . "announce.php?passkey=" . $acl->passkey; $dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']) . ":" . $dict['value']['announce']['value']; $dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']); header('Content-Disposition: attachment; filename="' . $torrent->filename . '"'); header("Content-Type: application/x-bittorrent"); die(Bcode::benc($dict));
$xml = new SimpleXMLElement("<rss></rss>"); $xml->addAttribute("version", "0.91"); $channel = $xml->addChild("channel"); $channel->addChild("title", $pref->name); $channel->addChild("link", CMS_URL); $channel->addChild("description", ""); $channel->addChild("language", "en-usde"); $channel->addChild("copyright", ""); $icon = $channel->addChild("image"); $icon->addChild("title", $pref->name); $icon->addChild("url", CMS_URL . "favicon.ico"); $icon->addChild("link", CMS_URL); $icon->addChild("width", "16"); $icon->addChild("height", "16"); $icon->addChild("description", ""); $db = new DB("torrents"); $db->setColPrefix("torrent_"); $db->query("SELECT * FROM {PREFIX}torrents WHERE " . implode(" OR ", $where) . " ORDER BY {$order} LIMIT 15"); while ($db->nextRecord()) { $link = $feed == "dl" ? page("torrent", "download", "", "", "", "torrent=" . $db->id . "&passkey=" . $passkey) : page("torrent", "details", "", "", "", "torrent=" . $db->id); $link = htmlentities($link); $item = $channel->addChild("item"); $item->addChild("title", $db->name); $item->addChild("link", $link); $item->addChild("description", $db->nfo); } header("Content-Type: application/xml"); die($xml->asXML()); } catch (Exception $e) { echo $e->getMessage(); }
<?php try { if (!isset($_GET['torrent'])) { throw new Exception("missing id"); } if (!intval($_GET['torrent'])) { throw new Exception("invalid id"); } $id = $_GET['torrent']; $db = new DB("torrents"); $db->select("torrent_id = '" . $db->escape($id) . "'"); if (!$db->numRows()) { throw new Exception("Could not find torrent"); } $db->nextRecord(); echo "<h4>" . $db->torrent_name . "</h4>"; $db = new DB("torrents_files"); $db->setColPrefix("file_"); $db->setSort("file_name ASC"); $db->select("file_torrent = '" . $db->escape($id) . "'"); echo "\n <table width='100%' class='forum' cellspacing='0' cellpadding='5'>\n <thead>\n <tr>\n <td class='border-bottom border-right' width='80%'>" . _t("Filename") . "</td>\n <td class='border-bottom'>" . _t("Size") . "</td>\n </tr>\n </thead>\n <tbody>"; while ($db->nextRecord()) { echo "<tr>\n <td class='border-bottom border-right' width='80%'>" . htmlformat($db->name) . "</td>\n <td class='border-bottom'>" . bytes($db->size) . "</td>\n </tr>"; } echo "</tbody></table>"; } catch (Exception $e) { echo error(_t($e->getMessage())); }
<?php define("REVISION", "14"); $system = new DB("system"); $system->setColPrefix("system_"); $system->select(); if (!$system->numRows()) { $system->revision = 0; $system->insert(); } $system->nextRecord(); $rev = $system->revision; $query = array(); if ($rev < 14) { $query[] = "ALTER TABLE `{PREFIX}users` ADD `user_invited` INT NOT NULL"; } if ($system->revision < REVISION) { $system->revision = REVISION; $system->update(); } $db = new DB(); if (count($query)) { foreach ($query as $sql) { $db->query($sql); } }
if (!$db->numRows()) { throw new Exception("No categories."); } if (isset($_POST['create'])) { try { if ($_POST['secure_input'] != $_SESSION['secure_token']) { throw new Exception("invalid token"); } if (empty($_POST['name'])) { throw new Exception("Cannot create a forum without a name"); } if (!intval($_POST['category']) || !intval($_POST['group'])) { throw new Exception("invalid form data"); } $db = new DB("forum_forums"); $db->setColPrefix("forum_"); $db->name = $_POST['name']; $db->description = $_POST['description']; $db->group = $_POST['group']; $db->category = $_POST['category']; $db->insert(); header("location: " . page("admin", "forum")); } catch (Exception $e) { echo error(_t($e->getMessage())); } } ?> <form method="POST"> <input type="hidden" name="secure_input" value="<?php echo $_SESSION['secure_token_last'];
?> </td> <td width="66px" class="border-bottom border-right" align="center"><?php echo _t("Replies"); ?> </td> <td class="border-bottom"><?php echo _t("Last post"); ?> </td> </tr> </thead> <tbody> <?php $db = new DB("forum_topics"); $db->setColPrefix("topic_"); $db->join("left", "{PREFIX}forum_posts", "post_topic", "topic_id"); $db->setSort("topic_sticky DESC, post_added DESC"); $db->select("topic_forum = '" . $db->escape($id) . "' GROUP BY post_topic"); while ($db->nextRecord()) { $q = new DB(); $q->query("SELECT COUNT(post_id) as posts FROM {PREFIX}forum_posts WHERE post_topic = '" . $db->id . "'"); $q->nextRecord(); $posts = $q->posts - 1; $q = new DB("forum_topics"); $q->join("left", "{PREFIX}forum_posts", "topic_id", "post_topic"); $q->setSort("post_added DESC"); $q->setLimit("1"); $q->select("topic_id= '" . $db->id . "'"); if (!$db->numRows()) { $last_post = "--";
<tr> <td class="border-bottom border-right"><?php echo _t("Store item"); ?> </td> <td class="border-bottom border-right"><?php echo _t("Costs"); ?> </td> <td class="border-bottom"></td> </tr> </thead> <tbody> <?php $db = new DB("bonus"); $db->setColPrefix("bonus_"); $db->setSort("bonus_sort ASC"); $db->select(); while ($db->nextRecord()) { $buy_button = $acl->bonusPoints() < $db->cost ? _t("Not enough points") : "<input type='submit' name='buy' value='" . _t("Buy") . "' />"; ?> <tr> <td class="border-bottom border-right"> <h4><?php echo $db->title; ?> </h4> <?php echo htmlformat($db->description, true); ?>
<?php /** * Copyright 2012, openTracker. (http://opentracker.nu) * * Licensed under The MIT License * Redistributions of files must retain the above copyright notice. * * @link http://opentracker.nu openTracker Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @author Wuild * @package openTracker */ if (!defined("INCLUDED")) { die("Access denied"); } $this->setTitle("Rules"); $db = new DB("rules"); $db->setColPrefix("rule_"); $db->select("rule_lang = '" . CURRENT_LANGUAGE . "'"); if (!$db->numRows()) { $db->select("rule_lang = '" . DEFAULT_LANGUAGE . "'"); } $db->nextRecord(); echo htmlformat($db->content, true);
<td align="center"> <form method="POST"> <input type="hidden" name="secure_input" value="<?php echo $_SESSION['secure_token_last']; ?> "> <input type="text" name="msg" size="40" /> <input type="submit" name="log" value="Add"><br /> </form> </td> </tr> <tr> <td> <?php $db = new DB("users_log"); $db->setColPrefix("log_"); $db->setSort("log_added DESC"); $db->select("log_user = '******'"); if ($db->numRows()) { while ($db->nextRecord()) { $user = new Acl($db->poster); ?> <div style="border-bottom: 1px solid #ddd; float:left; width: 100%;"> <div style="float:left; padding: 3px;"> <a href="<?php echo page("profile", "view", $user->name); ?> "><?php echo $user->name; ?> </a> -
<?php if (isset($_POST['reply'])) { try { if ($_POST['secure_input'] != $_SESSION['secure_token']) { throw new Exception("Wrong secured token"); } if (!intval($this->uid)) { throw new Exception("Missing unique user id"); } if (empty($_POST['msg'])) { throw new Exception("Cannot send an empty message"); } $db = new DB("messages"); $db->setColPrefix("message_"); $db->sender = USER_ID; $db->receiver = $this->uid; $db->content = $_POST['msg']; $db->added = time(); $db->insert(); } catch (Exception $e) { echo error(_t($e->getMessage())); } } if ($this->uid != 0) { ?> <div class="reply"> <form method="post"> <input type="hidden" name="secure_input" value="<?php echo $_SESSION['secure_token_last'];
<?php /** * Copyright 2012, openTracker. (http://opentracker.nu) * * Licensed under The MIT License * Redistributions of files must retain the above copyright notice. * * @link http://opentracker.nu openTracker Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @author Wuild * @package openTracker */ if (!defined("INCLUDED")) { die("Access denied"); } $this->setTitle("FAQ"); $db = new DB("faqs"); $db->setColPrefix("faq_"); $db->select("faq_lang = '" . CURRENT_LANGUAGE . "'"); if (!$db->numRows()) { $db->select("faq_lang = '" . DEFAULT_LANGUAGE . "'"); } $db->nextRecord(); echo htmlformat($db->content, true);
if (!defined("INCLUDED")) { die("Access denied"); } ?> <form method="post" enctype="multipart/form-data" action="<?php echo page("torrent", "upload"); ?> "> <input type="hidden" name="secure_input" value="<?php echo $_SESSION['secure_token_last']; ?> "> <div class="col_100 align_center"> <?php $cat = new DB("categories"); $cat->setColPrefix("category_"); $cat->select(); while ($cat->nextRecord()) { $sel = isset($_GET['c' . $cat->id]) ? " CHECKED" : ""; ?> <div class="col_5 align_center paddings"> <label for="cat_<?php echo $cat->id; ?> "><img src="images/categories/<?php echo $cat->icon; ?> " alt="<?php echo $cat->name; ?> " /><br />
function buildWidgets() { $acl = new Acl(USER_ID); if (USER_ID) { $data = ""; $db = new DB("widgets"); $db->setColPrefix("widget_"); $db->setSort("widget_sort ASC"); $db->select("widget_group <= " . $acl->group); while ($db->nextRecord()) { $widget = new Widget($db->module); $data .= $widget->build(); } return $data; } }
foreach ($applications as $name) { $files = makefilelist(PATH_APPLICATIONS . $name, ".|..|ajax.php|tpl|index.html|install.php|widget.php", true); $actions[$name][] = $files; } if (isset($_POST['create'])) { try { if ($_POST['secure_input'] != $_SESSION['secure_token']) { throw new Exception("Wrong secured token"); } if (empty($_POST['title'])) { throw new Exception("Empty title"); } $app = $_POST['application']; $action = $_POST['action_' . $app] != "main" ? $_POST['action_' . $app] : ""; $db = new DB("navigations"); $db->setColPrefix("navigation_"); $db->title = $_POST['title']; $db->application = $app; $db->module = $action; $db->lang = $_POST['language']; $db->insert(); header("location: " . page("admin", "navigation")); } catch (Exception $e) { echo error(_t($e->getMessage())); } } ?> <form method="post"> <input type="hidden" name="secure_input" value="<?php echo $_SESSION['secure_token_last'];
$db->update("torrent_id = '" . $db->escape($id) . "'"); preg_match("#tt(?P<imdbId>[0-9]{7,7})#", $link, $matches); if (count($matches) == 0) { continue; } $thenumbers = $matches['imdbId']; include PATH_LIBRARY . "imdb/imdb.class.php"; $movie = new imdb($thenumbers); $movieid = $thenumbers; $movie->setid($movieid); $gen = $movie->genres(); $plotoutline = $movie->plotoutline(); $mvrating = $movie->rating(); $photo_url = $movie->photo_localurl(); $db = new DB("torrents_imdb"); $db->setColPrefix("imdb_"); $db->torrent = $id; $db->genres = implode(", ", $gen); $db->plot = $plotoutline; $db->title = $movie->title(); $db->image = $photo_url; $db->rating = $mvrating; $db->insert(); } header("location: " . page("torrent", "details", "", "", "", "id=" . $id)); } else { $db = new DB("torrents"); $db->delete("torrent_id = {$id}"); throw new Exception("Could not upload torrent file. please contact staff."); } } catch (Exception $e) {
echo _t("Create group"); ?> " /> </form> <?php if (isset($_POST['create'])) { try { if ($_POST['secure_input'] != $_SESSION['secure_token']) { throw new Exception("Wrong secure token"); } if (empty($_POST['name']) || empty($_POST['name'])) { throw new Exception("Missing data"); } $db = new DB("groups"); $db->setColPrefix("group_"); $db->name = $_POST['name']; $db->acl = $_POST['acl']; if (isset($_POST['upgradable'])) { if ($_POST['upgradeto'] == 0) { throw new Exception("Missing upgrade to group data"); } $db->upgradable = 1; $db->upgradeto = $_POST['upgradeto']; $db->downgradeto = $_POST['downgradeto']; $db->minupload = $_POST['minupload']; $db->minratio = $_POST['minratio']; } $db->insert(); header("location: " . page("admin", "groups")); } catch (Exception $e) {
* @link http://opentracker.nu openTracker Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @author Wuild * @package openTracker */ if (!defined("INCLUDED")) { die("Access denied"); } try { $acl = new Acl(USER_ID); $tid = isset($_GET['torrent']) ? $_GET['torrent'] : ""; if (!intval($_GET['torrent'])) { throw new Exception("invalid id"); } $db = new DB("peers"); $db->setColPrefix("peer_"); $db->select("peer_torrent = '" . $db->escape($tid) . "' AND peer_seeder = '1'"); $no_peers = true; if ($db->numRows()) { echo "<h4>" . _t("Seeders") . "</h4>"; echo "\n <table width='100%' class='forum' cellspacing='0' cellpadding='5'>\n <thead>\n <tr>\n <td class='border-bottom border-right' width='200px'>Seeder</td>\n <td class='border-bottom border-right'>Downloaded</td>\n <td class='border-bottom border-right'>Uploaded</td>\n <td class='border-bottom border-right' align='center'>Seeded for</td>\n </tr>\n </thead>\n <tbody>\n "; while ($db->nextRecord()) { $user = new Acl($db->userid); echo "\n <tr>\n <td class='border-bottom border-right'>" . (!$user->anonymous || $acl->Access("x") ? "<a href='" . page("profile", "view", $user->name) . "'>" . $user->name . "</a>" : "Anonymous") . "</td>\n <td class='border-bottom border-right'>" . bytes($db->downloaded) . "</td>\n <td class='border-bottom border-right'>" . bytes($db->uploaded) . "</td>\n <td class='border-bottom border-right' align='center'>" . timediff($db->started, time()) . "</td>\n </tr>"; } echo "</tbody></table>"; $no_peers = false; } $db->select("peer_torrent = '" . $db->escape($tid) . "' AND peer_seeder = '0'"); if ($db->numRows()) { echo "<h4>" . _t("Leechers") . "</h4>";