case 'rating':
if (!$row["rating"]) {
$rating = "--";
} else {
$rating = "<a title='$row[rating]/5'>" . ratingpic($row["rating"]) . "</a>";
}
//$rating = ratingpic($row["rating"]);
//$srating .= "$rpic (" . $row["rating"] . " out of 5) " . $row["numratings"] . " users have rated this torrent";
print("<td class='ttable_col$x' align='center'>$rating</td>");
break;
} case 'rating':
if (!$row["rating"]) {
$rating = "--";
} else {
// $rating = "<a title='$row[rating]/5'>" . ratingpic($row["rating"]) . "</a>";
// $rating = ratingpic($row["rating"]);
// $rating .= "$rpic (" . $row["rating"] . " out of 5) " . $row["numratings"] . " users have rated this torrent";
}
print("<td class='ttable_col$x' align='center'>$rating</td>");
break;
} $site_config["torrenttable_columns"] = "tube,category,cover,name,dl,uploader,comments,size,seeders,leechers,health,external,rating";
"niki, post: 69594, member: 20338":
thanks for the help I just made the modification and the stars don't show in the torrent page on torrent.php:rolleyes:
$site_config["torrenttable_columns"]function ratingpic($num)
{
global $config;
$r = round($num * 2) / 2;
if ($r != $num) {
$n = $num - $r;
if ($n < .25) {
$n = 0;
} elseif ($n >= .25 && $n < .75) {
$n = .5;
}
$r += $n;
}
if ($r < 1 || $r > 5) {
return;
}
return "<img src=\"" . $config["SITEURL"] . "/images/rating/$r.png\" border=\"0\" alt=\"rating: $num/5\" title=\"rating: $num/5\" />";
}<?php
class Forums extends Controller
{
public function __construct()
{
$this->valid = new Validation();
$this->forumModel = $this->model('Forum');
}
/**
* Lets show the validation in one place so we dont have to repeat :)
*/
private function validForumUser($extra = false)
{
global $config;
if (!$config["FORUMS_GUESTREAD"]) {
loggedinonly();
}
if ($_SESSION["forumbanned"] == "yes" || $_SESSION["view_forum"] == "no") {
Session::flashmsg('danger', Lang::T("FORUM_BANNED"), 1);
}
if ($extra = true) {
// maybe add some topic/forum id checks on some
}
}
/**
* View Forum Index.
*/
public function index()
{
dbconn();
global $config;
$this->validForumUser();
//Here we decide if the forums is on or off
if ($config["FORUMS"]) {
// Action: DEFAULT ACTION (VIEW FORUMS)
if (isset(Input::get("catchup"))) {
catch_up();
}
// Action: SHOW MAIN FORUM INDEX
$forums_res = $this->forumModel->getIndex();
if ($forums_res->rowCount() == 0) {
Redirect::autolink1($config['SITEURL'] . '/index', 'danger', 'There is no Forums available');
}
//topic count and post counts
$postcount = number_format(get_row_count("forum_posts"));
$topiccount = number_format(get_row_count("forum_topics"));
$data = [
'mainquery' => $forums_res,
'themedir' => THEMEDIR,
'postcount' => $postcount,
'topiccount' => $topiccount,
];
$this->view('forum/index', $data, true);
} else {
//HEY IF FORUMS ARE OFF, SHOW THIS FLASH MESSAGE
Session::flashmsg('warning', Lang::T("Unfortunatley the forums are not currently available."), 1);
}
}
/**
* Post New Topic.
*/
public function newtopic()
{
dbconn();
global $config;
$this->validForumUser();
if ($config["FORUMS"]) {
$forumid = $_GET["forumid"];
if (!is_valid_id($forumid)) {
Session::flashmsg('warning', "No Forum ID $forumid", 1);
}
$data = [
'id' => $forumid,
];
$this->view('forum/newtopic', $data, true);
die;
}
}
/**
* Search Forum.
*/
public function search()
{
dbconn();
global $config;
$this->validForumUser();
$data = [];
$this->view('forum/search', $data, true);
die;
}
/**
* View Unread Topics.
*/
public function viewunread()
{
dbconn();
global $config;
$this->validForumUser();
$res = $this->forumModel->viewunread();
$data = [
'res' => $res,
'n' => 0
];
$this->view('forum/viewunread', $data, true);
die;
}
/**
* View Forum.
*/
public function viewforum()
{
dbconn();
global $config;
$this->validForumUser();
$forumid = Input::get("forumid");
if (!is_valid_id($forumid)) {
Session::flashmsg('warning', Lang::T("FORUMS_DENIED"), 1);
}
// Get forum name
$res = DB::run("SELECT name, minclassread, guest_read FROM forum_forums WHERE id=?", [$forumid]);
$arr = $res->fetch(PDO::FETCH_ASSOC);
$forumname = $arr["name"];
if (!$forumname || $_SESSION['class'] < $arr["minclassread"] && $arr["guest_read"] == "no") {
Session::flashmsg('warning', Lang::T("FORUMS_NOT_PERMIT"), 1);
}
// Get topics data and display category
$topicsres = DB::run("SELECT * FROM forum_topics WHERE forumid=$forumid ORDER BY sticky, lastpost DESC")->fetchAll();
$data = [
'topicsres' => $topicsres,
'forumname' => $forumname,
'forumid' => $forumid
];
$this->view('forum/viewforum', $data, true);
die;
}
/**
*Reply To Post. not in use yet
*/
public function reply()
{
require_once "helpers/bbcode_helper.php";
dbconn();
//////////////////////////////////
die('you found me thank fuck - lol');
/////////////////////////////////
global $config;
$this->validForumUser();
$topicid = Input::get("topicid");
if (!is_valid_id($topicid)) {
Session::flashmsg('warning', sprintf(Lang::T("FORUMS_NO_ID_FORUM"), $topicid), 1);
}
stdhead(Lang::T("FORUMS_POST_REPLY"));
begin_frame(Lang::T("FORUMS_POST_REPLY"));
insert_compose_frame($topicid, false);
end_frame();
stdfoot();
die;
}
/**
* Edit a Post.
*/
public function editpost()
{
require_once "helpers/bbcode_helper.php";
dbconn();
global $config, $THEME;
$this->validForumUser();
$postid = Input::get("postid");
if (!is_valid_id($postid)) {
Session::flashmsg('warning', Lang::T("FORUMS_DENIED"), 1);
}
$res = DB::run("SELECT * FROM forum_posts WHERE id=?", [$postid]);
if ($res->rowCount() != 1) {
Session::flashmsg('warning', $postid, 1);
}
$arr = $res->fetch(PDO::FETCH_ASSOC);
if ($_SESSION["id"] != $arr["userid"] && $_SESSION["delete_forum"] != "yes" && $_SESSION["edit_forum"] != "yes") {
Session::flashmsg('warning', Lang::T("FORUMS_DENIED"), 1);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$body = Input::get('body');
if ($body == "") {
Session::flashmsg('warning', "Body cannot be empty!", 1);
}
$body = $body;
$editedat = get_date_time();
DB::run("UPDATE forum_posts SET body=?, editedat=?, editedby=? WHERE id=?", [$body, $editedat, $_SESSION['id'], $postid]);
$returnto = Input::get("returnto");
if ($returnto != "") {
Redirect::to($returnto);
} else {
Session::flashmsg('warning', "Post was edited successfully.", 1);
}
}
$data = [
'postid' => $postid,
'arrbody' => $arr['body']
];
$this->view('forum/edit', $data, true);
die;
}
/**
* Confirm Post/Reply.
*/
public function submittopic()
{
dbconn();
global $config;
$this->validForumUser();
$forumid = Input::get("forumid");
$topicid = Input::get("topicid");
if (!is_valid_id($forumid) && !is_valid_id($topicid)) {
Session::flashmsg('warning', Lang::T("FORUM_ERROR"), 1);
}
$newtopic = $forumid > 0;
$subject = $_POST["subject"];
if ($newtopic) {
if (!$subject) {
Session::flashmsg('warning', "You must enter a subject.", 1);
}
$subject = trim($subject);
} else {
$forumid = get_topic_forum($topicid) or Session::flashmsg('warning', "Bad topic ID", 1);
}
// Make sure sure user has write access in forum
$arr = get_forum_access_levels($forumid) or Session::flashmsg('warning', "Bad forum ID", 1);
if ($_SESSION['class'] < $arr["write"]) {
Session::flashmsg('warning', Lang::T("FORUMS_NOT_PERMIT"), 1);
}
$body = trim($_POST["body"]);
if (!$body) {
Session::flashmsg('warning', "No body text.", 1);
}
if ($newtopic) { //Create topic
$subject = $subject;
DB::run("INSERT INTO forum_topics (userid, forumid, subject) VALUES(?,?,?)", [$_SESSION["id"], $forumid, $subject]);
$topicid = DB::lastInsertId() or Session::flashmsg('warning', "Topics id n/a", 1);
} else {
//Make sure topic exists and is unlocked
$res = DB::run("SELECT * FROM forum_topics WHERE id=?", [$topicid]);
$arr = $res->fetch(PDO::FETCH_ASSOC) or Session::flashmsg('warning', "Topic id n/a", 1);
if ($arr["locked"] == 'yes') {
Session::flashmsg('warning', "Topic locked", 1);
}
//Get forum ID
$forumid = $arr["forumid"];
}
//Insert the new post
$added = "'" . get_date_time() . "'";
$body = $body;
DB::run("INSERT INTO forum_posts (topicid, userid, added, body) VALUES(?, ?, ?, ?)", [$topicid, $_SESSION["id"], get_date_time(), $body]);
$postid = DB::lastInsertId() or Session::flashmsg('warning', "Post id n/a", 1);
//Update topic last post
update_topic_last_post($topicid);
//All done, redirect user to the post
if ($newtopic) {
Redirect::to(TTURL . "/topic?topicid=$topicid&page=last");
} else {
Redirect::to(TTURL . "/topic?topicid=$topicid&page=last#post$postid");
}
die;
}
/**
* View Forum Topic. still todo
*/
public function viewtopic()
{
require_once "helpers/bbcode_helper.php";
dbconn();
global $config, $THEME;
$this->validForumUser();
$postsperpage = 20;
$maxsubjectlength = 50;
$topicid = $_GET["topicid"];
$page = $_GET["page"];
if (!is_valid_id($topicid)) {
Session::flashmsg('warning', "Topic Not Valid", 1);
}
$userid = $_SESSION["id"];
//------ Get topic info
$res = DB::run("SELECT * FROM forum_topics WHERE id=?", [$topicid]);
$arr = $res->fetch(PDO::FETCH_ASSOC) or Session::flashmsg('warning', "Topic not found", 1);
$locked = ($arr["locked"] == 'yes');
$subject = stripslashes($arr["subject"]);
$sticky = $arr["sticky"] == "yes";
$forumid = $arr["forumid"];
// Check if user has access to this forum
$res2 = DB::run("SELECT minclassread, guest_read FROM forum_forums WHERE id=?", [$forumid]);
$arr2 = $res2->fetch(PDO::FETCH_ASSOC);
if (!$arr2 || get_user_class() < $arr2["minclassread"] && $arr2["guest_read"] == "no") {
Session::flashmsg('warning', "You do not have access to the forum this topic is in.", 1);
}
// Update Topic Views
$viewsq = DB::run("SELECT views FROM forum_topics WHERE id=$topicid");
$viewsa = $viewsq->fetch(PDO::FETCH_LAZY);
$views = $viewsa[0];
$new_views = $views + 1;
$uviews = DB::run("UPDATE forum_topics SET views = $new_views WHERE id=$topicid");
// End
//------ Get forum
$res = DB::run("SELECT * FROM forum_forums WHERE id=?", [$forumid]);
$arr = $res->fetch(PDO::FETCH_ASSOC) or showerror(Lang::T("FORUM_ERROR"), "Forum is empty");
$forum = stripslashes($arr["name"]);
//------ Get post count
$res = DB::run("SELECT COUNT(*) FROM forum_posts WHERE topicid=?", [$topicid]);
$arr = $res->fetch(PDO::FETCH_LAZY);
$postcount = $arr[0];
//------ Make page menu
$pagemenu = "<br /><small>\n";
$perpage = $postsperpage;
$pages = floor($postcount / $perpage);
if ($pages * $perpage < $postcount) {
++$pages;
}
if ($page == "last") {
$page = $pages;
} else {
if ($page < 1) {
$page = 1;
} elseif ($page > $pages) {
$page = $pages;
}
}
$offset = max(0, ($page * $perpage) - $perpage);
//
if ($page == 1) {
$pagemenu .= "<b><< Prev</b>";
} else {
$pagemenu .= "<a href='$config[SITEURL]/forums/viewtopic&topicid=$topicid&page=" . ($page - 1) . "'><b><< Prev</b></a>";
}
//
$pagemenu .= " ";
for ($i = 1; $i <= $pages; ++$i) {
if ($i == $page) {
$pagemenu .= "<b>$i</b>\n";
} else {
$pagemenu .= "<a href='$config[SITEURL]/forums/viewtopic&topicid=$topicid&page=$i'><b>$i</b></a>\n";
}
}
//
$pagemenu .= " ";
if ($page == $pages) {
$pagemenu .= "<b>Next >></b><br /><br />\n";
} else {
$pagemenu .= "<a href='$config[SITEURL]/forums/viewtopic&topicid=$topicid&page=" . ($page + 1) . "'><b>Next >></b></a><br /><br />\n";
}
$pagemenu .= "</small>";
//Get topic posts
$res = DB::run("SELECT * FROM forum_posts WHERE topicid=$topicid ORDER BY id LIMIT $offset,$perpage");
stdhead("View Topic: $subject");
begin_frame("$forum > $subject");
forumheader("<a href='$config[SITEURL]/forums/viewforum&forumid=$forumid'>$forum</a> <b style='font-size:16px; vertical-align:middle'>/</b> $subject");
print("<div style='padding: 6px'>");
$levels = get_forum_access_levels($forumid) or die;
if (get_user_class() >= $levels["write"]) {
$maypost = true;
} else {
$maypost = false;
}
if (!$locked && $maypost) {
print("<div align='right'><a href='#bottom'><img src='" . THEMEDIR . "button_reply.png' border='0' alt='' /></a></div>");
} else {
print("<div align='right'><img src='" . THEMEDIR . "button_locked.png' alt='" . Lang::T("FORUMS_LOCKED") . "' /></div>");
}
print("</div>");
//------ Print table of posts
$pc = $res->rowCount();
$pn = 0;
if ($_SESSION['loggedin'] == true) {
$r = DB::run("SELECT lastpostread FROM forum_readposts WHERE userid=? AND topicid=?", [$_SESSION['id'], $topicid]);
$a = $r->fetch(PDO::FETCH_LAZY);
$lpr = $a[0];
if (!$lpr) {
DB::run("INSERT INTO forum_readposts (userid, topicid) VALUES($userid, $topicid)");
}
}
while ($arr = $res->fetch(PDO::FETCH_ASSOC)) {
++$pn;
$postid = $arr["id"];
$posterid = $arr["userid"];
$added = utc_to_tz($arr["added"]) . "(" . (get_elapsed_time(sql_timestamp_to_unix_timestamp($arr["added"]))) . " ago)";
//---- Get poster details
$res4 = DB::run("SELECT COUNT(*) FROM forum_posts WHERE userid=?", [$posterid]);
$arr33 = $res4->fetch(PDO::FETCH_LAZY);
$forumposts = $arr33[0];
$res2 = DB::run("SELECT * FROM users WHERE id=?", [$posterid]);
$arr2 = $res2->fetch(PDO::FETCH_ASSOC);
$postername = class_user_colour($arr2["username"]);
if ($postername == "") {
$by = "Deluser";
$title = "Deleted Account";
$privacylevel = "strong";
$usersignature = "";
$userdownloaded = "0";
$useruploaded = "0";
$avatar = "";
$nposts = "-";
$tposts = "-";
} else {
$avatar = htmlspecialchars($arr2["avatar"]);
$userdownloaded = mksize($arr2["downloaded"]);
$useruploaded = mksize($arr2["uploaded"]);
$privacylevel = $arr2["privacy"];
$usersignature = stripslashes(format_comment($arr2["signature"]));
if ($arr2["downloaded"] > 0) {
$userratio = number_format($arr2["uploaded"] / $arr2["downloaded"], 2);
} else
if ($arr2["uploaded"] > 0) {
$userratio = "Inf.";
} else {
$userratio = "---";
}
if (!$arr2["country"]) {
$usercountry = "unknown";
} else {
$res4 = DB::run("SELECT name,flagpic FROM countries WHERE id=? LIMIT 1", [$arr2['country']]);
$arr4 = $res4->fetch(PDO::FETCH_ASSOC);
$usercountry = $arr4["name"];
}
$title = format_comment($arr2["title"]);
$donated = $arr2['donated'];
$by = "<a href='$config[SITEURL]/profile?id=$posterid'>$postername</a>" . ($donated > 0 ? "<img src='" . $config['SITEURL'] . "/images/star.png' alt='Donated' />" : "") . "";
}
if (!$avatar) {
$avatar = $config['SITEURL'] . "/images/default_avatar.png";
}
# print("<a name=$postid>\n");
print("<a id='post$postid'></a>");
if ($pn == $pc) {
print("<a name='last'></a>\n");
if ($postid > $lpr && $_SESSION['loggedin'] == true) {
DB::run("UPDATE forum_readposts SET lastpostread=$postid WHERE userid=? AND topicid=?", [$userid, $topicid]);
}
}
//Post Top
print("<div class='table'><table class='table table-striped'><thead>
<tr><th width='150'>$by</th><th align='left'><small>Posted at $added </small></th></tr></thead><tbody>");
//Post Middle
$body = stripslashes(format_comment($arr["body"]));
if (is_valid_id($arr['editedby'])) {
$res2 = DB::run("SELECT username FROM users WHERE id=?", [$arr['editedby']]);
if ($res2->rowCount() == 1) {
$arr2 = $res2->fetch(PDO::FETCH_ASSOC);
//edited by comment out if needed
$body .= "<br /><br /><small><i>Last edited by <a href='$config[SITEURL]/profile?id=$arr[editedby]'>$arr2[username]</b></a> on " . utc_to_tz($arr["editedat"]) . "</i></small><br />\n";
$body .= "\n";
}
}
$quote = htmlspecialchars($arr["body"]);
$postcount1 = DB::run("SELECT COUNT(forum_posts.userid) FROM forum_posts WHERE id=$posterid");
while ($row = $postcount1->fetch(PDO::FETCH_LAZY)) {
if ($privacylevel == "strong" && $_SESSION["control_panel"] != "yes") { //hide stats, but not from staff
$useruploaded = "---";
$userdownloaded = "---";
$userratio = "---";
$nposts = "-";
$tposts = "-";
}
print("<tr style='border: 1px solid black' valign='top''><td style='border: 1px solid black' width='150' align='left' class='comment-details'><center><i>$title</i></center><br /><center><img width='80' height='80' src='$avatar' alt='' /></center><br />Uploaded: $useruploaded<br />Downloaded: $userdownloaded<br />Posts: $forumposts<br /><br />Ratio: $userratio<br />Location: $usercountry<br /><br /></td>");
print("<td style='border: 1px solid black' class='comment'><br />$body<br />");
if (!$usersignature) {
print("<br /></td></tr>\n");
} else {
print("<br /><hr /><br /><div class='f-sig' align='center'>$usersignature</div></td></tr>\n");
}
}
//Post Bottom
print("<tr class='p-foot'><td width='150' align='center'><a href='$config[SITEURL]/profile?id=$posterid'><img src='" . THEMEDIR . "icon_profile.png' border='0' alt='' /></a> <a href='$config[SITEURL]/messages/create?id=$posterid'><img src='" . THEMEDIR . "icon_pm.png' border='0' alt='' /></a></td><td>");
print("<div style='float: left;'><a href='$config[SITEURL]/report/forum?forumid=$topicid&forumpost=$postid'><img src='" . THEMEDIR . "p_report.png' border='0' alt='" . Lang::T("FORUMS_REPORT_POST") . "' /></a> <a href='javascript:scroll(0,0);'><img src='" . THEMEDIR . "p_up.png' alt='" . Lang::T("FORUMS_GOTO_TOP_PAGE") . "' /></a></div><div align='right'>");
// Hide Reply Mod
if ($_SESSION["id"] !== $posterid) {
// say thanks
print("<a href='$config[SITEURL]/likes/likeforum?id=$topicid'><button class='btn btn-sm btn-success'>Say Thanks</button></a> ");
}
//define buttons and who can use them
if ($_SESSION["id"] == $posterid || $_SESSION["edit_forum"] == "yes" || $_SESSION["delete_forum"] == "yes") {
print("<a href='$config[SITEURL]/forums/editpost&postid=$postid'><img src='" . THEMEDIR . "p_edit.png' border='0' alt='' /></a> ");
}
if ($_SESSION["delete_forum"] == "yes") {
print("<a href='$config[SITEURL]/forums/deletepost&postid=$postid&sure=0'><img src='" . THEMEDIR . "p_delete.png' border='0' alt='' /></a> ");
}
if (!$locked && $maypost) {
print("<a href=\"javascript:SmileIT('$postername: $quote
', 'Form', 'body');\"><img src='" . THEMEDIR . "p_quote.png' border='0' alt='' /></a> ");
print("<a href='#bottom'><img src='" . THEMEDIR . "p_reply.png' alt='' /></a>");
}
print(" </div></td></tr></tbody></table></div>");
}
//-------- end posts table ---------//
print($pagemenu);
//quick reply
if (!$locked && $_SESSION['loggedin'] == true) {
//begin_frame("Reply", $newtopic = false);
print("<fieldset class='download'><legend><b>" . Lang::T("FORUMS_POST_REPLY") . "</b></legend>");
$newtopic = false;
print("<a name='bottom'></a>");
print("<form name='Form' method='post' action='$config[SITEURL]/forums/submittopic'>\n");
if ($newtopic) {
print("<input type='hidden' name='forumid' value='$id' />\n");
} else {
print("<input type='hidden' name='topicid' value='$topicid' />\n");
}
print("<table cellspacing='0' cellpadding='0' align='center'>");
if ($newtopic) {
print("<tr><td class='alt2'>" . Lang::T("FORUMS_SUBJECT") . "</td><td class='alt1' align='left' style='padding: 0px'><input type='text' size='100' maxlength='$maxsubjectlength' name='subject' style='border: 0px; height: 19px' /></td></tr>\n");
}
print("</table>");
textbbcode("Form", "body");
print("<center><br /><input type='image' src='" . THEMEDIR . "button_reply.png' alt='' /></center>");
print("</form>\n");
//end_frame();
print(" </fieldset>");
} else {
print("<img src='" . THEMEDIR . "button_locked.png' alt='" . Lang::T("FORUMS_LOCKED") . "' /><br />");
}
//end quick reply
if ($locked) {
print(Lang::T("FORUMS_TOPIC_LOCKED") . "\n");
} elseif (!$maypost) {
print("<i>" . Lang::T("FORUMS_YOU_NOT_PERM_POST_FORUM") . "</i>\n");
}
//insert page numbers and quick jump
// insert_quick_jump_menu($forumid);
// MODERATOR OPTIONS
if ($_SESSION["delete_forum"] == "yes" || $_SESSION["edit_forum"] == "yes") {
print("<div class='f-border f-mod_options' align='center'><table width='100%' cellspacing='0'><tr class='f-title'><th><center>" . Lang::T("FORUMS_MOD_OPTIONS") . "</center></th></tr>\n");
$res = DB::run("SELECT id,name,minclasswrite FROM forum_forums ORDER BY name");
print("<tr><td class='ttable_col2'>\n");
print("<form method='post' action='$config[SITEURL]/forums/renametopic'>\n");
print("<input type='hidden' name='topicid' value='$topicid' />\n");
print("<input type='hidden' name='returnto' value='forums/viewtopic&topicid=$topicid' />\n");
print("<div align='center' style='padding:3px'>Rename topic: <input type='text' name='subject' size='60' maxlength='$maxsubjectlength' value='" . stripslashes(htmlspecialchars($subject)) . "' />\n");
print("<input type='submit' value='Apply' />");
print("</div></form>\n");
print("<form method='post' action='$config[SITEURL]/forums/movetopic&topicid=$topicid'>\n");
print("<div align='center' style='padding:3px'>");
print("Move this thread to: <select name='forumid'>");
while ($arr = $res->fetch(PDO::FETCH_ASSOC)) {
if ($arr["id"] != $forumid && get_user_class() >= $arr["minclasswrite"]) {
print("<option value='" . $arr["id"] . "'>" . $arr["name"] . "</option>\n");
}
}
print("</select> <input type='submit' value='Apply' /></div></form>\n");
print("<div align='center'>\n");
if ($locked) {
print(Lang::T("FORUMS_LOCKED") . ": <a href='$config[SITEURL]/forums/unlocktopic&forumid=$forumid&topicid=$topicid&page=$page' title='Unlock'><img src='" . THEMEDIR . "topic_unlock.png' alt='UnLock Topic' /></a>\n");
} else {
print(Lang::T("FORUMS_LOCKED") . ": <a href='$config[SITEURL]/forums/locktopic&forumid=$forumid&topicid=$topicid&page=$page' title='Lock'><img src='" . THEMEDIR . "topic_lock.png' alt='Lock Topic' /></a>\n");
}
print("Delete Entire Topic: <a href='$config[SITEURL]/forums/deletetopic&topicid=$topicid&sure=0' title='Delete'><img src='" . THEMEDIR . "topic_delete.png' alt='Delete Topic' /></a>\n");
if ($sticky) {
print(Lang::T("FORUMS_STICKY") . ": <a href='$config[SITEURL]/forums/unsetsticky&forumid=$forumid&topicid=$topicid&page=$page' title='UnStick'><img src='" . THEMEDIR . "folder_sticky_new.png' alt='UnStick Topic' /></a>\n");
} else {
print(Lang::T("FORUMS_STICKY") . ": <a href='$config[SITEURL]/forums/setsticky&forumid=$forumid&topicid=$topicid&page=$page' title='Stick'><img src='" . THEMEDIR . "folder_sticky.png' alt='Stick Topic' /></a>\n");
}
print("</div></td></tr></table></div>\n");
}
end_frame();
stdfoot();
die;
}
/**
* Delete a Post.
*/
public function deletepost()
{
dbconn();
global $config;
$this->validForumUser();
$postid = Input::get("postid");
$sure = Input::get("sure");
if ($_SESSION["delete_forum"] != "yes" || !is_valid_id($postid)) {
Session::flashmsg('warning', Lang::T("FORUMS_DENIED"), 1);
}
// SURE ?
if ($sure == "0") {
Session::flashmsg('warning', $postid, 1);
}
// Get topic id
$res = DB::run("SELECT topicid FROM forum_posts WHERE id=?", [$postid]);
$arr = $res->fetch(PDO::FETCH_LAZY) or Session::flashmsg('warning', Lang::T("FORUMS_NOT_FOUND_POST"), 1);
$topicid = $arr[0];
// We can not delete the post if it is the only one of the topic
$res = DB::run("SELECT COUNT(*) FROM forum_posts WHERE topicid=?", [$topicid]);
$arr = $res->fetch(PDO::FETCH_LAZY);
if ($arr[0] < 2) {
Session::flashmsg('warning', $topicid, 1);
}
// Delete post
DB::run("DELETE FROM forum_posts WHERE id=?", [$postid]);
// Update topic
update_topic_last_post($topicid);
Redirect::to(TTURL . "/topic?topicid=$topicid");
die;
}
/**
* Delete a Topic.
*/
public function deletetopic()
{
dbconn();
global $config;
$this->validForumUser();
$topicid = Input::get("topicid");
if (!is_valid_id($topicid) || $_SESSION["delete_forum"] != "yes") {
Session::flashmsg('warning', Lang::T("FORUMS_DENIED"), 1);
}
$sure = Input::get("sure");
if ($sure == "0") {
Session::flashmsg('warning', $topicid, 1);
}
$this->forumModel->deltopic($topicid);
Redirect::to(TTURL . "/forums");
die;
}
/**
* Rename a Topic.
*/
public function renametopic()
{
dbconn();
global $config;
$this->validForumUser();
if ($_SESSION["delete_forum"] != "yes" && $_SESSION["edit_forum"] != "yes") {
Session::flashmsg('warning', Lang::T("FORUMS_DENIED"), 1);
}
$topicid = Input::get('topicid');
if (!is_valid_id($topicid)) {
Session::flashmsg('warning', Lang::T("FORUMS_DENIED"), 1);
}
$subject = Input::get('subject');
if ($subject == '') {
Session::flashmsg('warning', Lang::T("FORUMS_YOU_MUST_ENTER_NEW_TITLE"), 1);
}
$subject = $subject;
$this->forumModel->rename($subject, $topicid);
$returnto = Input::get('returnto');
if ($returnto) {
header("Location: $returnto");
}
die;
}
/**
* Move a Topic.
*/
public function movetopic()
{
dbconn();
global $config;
$this->validForumUser();
$forumid = Input::get("forumid");
$topicid = Input::get("topicid");
if (!is_valid_id($forumid) || !is_valid_id($topicid) || $_SESSION["delete_forum"] != "yes" || $_SESSION["edit_forum"] != "yes") {
Session::flashmsg('warning', $topicid, 1);
}
// Make sure topic and forum is valid
$res = DB::run("SELECT minclasswrite FROM forum_forums WHERE id=?", [$forumid]);
if ($res->rowCount() != 1) {
Session::flashmsg('warning', Lang::T("FORUMS_NOT_FOUND"), 1);
}
$arr = $res->fetch(PDO::FETCH_LAZY);
if ($_SESSION['class'] < $arr[0]) {
Session::flashmsg('warning', Lang::T("FORUMS_NOT_ALLOWED"), 1);
}
$res = DB::run("SELECT subject,forumid FROM forum_topics WHERE id=?", [$topicid]);
if ($res->rowCount() != 1) {
Session::flashmsg('warning', Lang::T("FORUMS_NOT_FOUND_TOPIC"), 1);
}
$arr = $res->fetch(PDO::FETCH_ASSOC);
if ($arr["forumid"] != $forumid) {
DB::run("UPDATE forum_topics SET forumid=$forumid, moved='yes' WHERE id=$topicid");
}
Redirect::to(TTURL . "/forums/viewforum&forumid=$forumid");
die;
}
/**
* Lock a Topic.
*/
public function locktopic()
{
dbconn();
global $config;
$this->validForumUser();
$forumid = Input::get("forumid");
$topicid = Input::get("topicid");
$page = Input::get("page");
if (!is_valid_id($topicid) || $_SESSION["delete_forum"] != "yes" || $_SESSION["edit_forum"] != "yes") {
Session::flashmsg('warning', Lang::T("FORUMS_DENIED"), 1);
}
$this->forumModel->lock($topicid, 'yes');
Redirect::to(TTURL . "/forums/viewforum&forumid=$forumid&page=$page");
die;
}
/**
* Unlock a Topic.
*/
public function unlocktopic()
{
dbconn();
global $config;
$this->validForumUser();
$forumid = Input::get("forumid");
$topicid = Input::get("topicid");
$page = Input::get("page");
if (!is_valid_id($topicid) || $_SESSION["delete_forum"] != "yes" || $_SESSION["edit_forum"] != "yes") {
Session::flashmsg('warning', Lang::T("FORUMS_DENIED"), 1);
}
$this->forumModel->lock($topicid, 'no');
Redirect::to(TTURL . "/forums/viewforum&forumid=$forumid&page=$page");
die;
}
/**
* Set Topic Sticky.
*/
public function setsticky()
{
dbconn();
global $config;
$this->validForumUser();
$forumid = Input::get("forumid");
$topicid = Input::get("topicid");
$page = Input::get("page");
if (!is_valid_id($topicid) || ($_SESSION["delete_forum"] != "yes" && $_SESSION["edit_forum"] != "yes")) {
Session::flashmsg('warning', Lang::T("FORUMS_DENIED"), 1);
}
$this->forumModel->sticky($topicid, 'yes');
Redirect::to(TTURL . "/forums/viewforum&forumid=$forumid&page=$page");
die;
}
/**
* Unstick a Topic.
*/
public function unsetsticky()
{
dbconn();
global $config;
$this->validForumUser();
$forumid = Input::get("forumid");
$topicid = Input::get("topicid");
$page = Input::get("page");
if (!is_valid_id($topicid) || ($_SESSION["delete_forum"] != "yes" && $_SESSION["edit_forum"] != "yes")) {
Session::flashmsg('warning', Lang::T("FORUMS_DENIED"), 1);
}
$this->forumModel->sticky($topicid, 'no');
Redirect::to(TTURL . "/forums/viewforum&forumid=$forumid&page=$page");
die;
}
} public static function echoCountry ()
{
$countries = "<option value=\"0\">---- " . Lang::T("NONE_SELECTED") . " ----</option>\n";
$ct_r = $this->db->run("SELECT id,name,domain from countries ORDER BY name")->fetchAll(PDO::FETCH_ASSOC);
foreach ($ct_r as $ct_a) {
$countries .= "<option value=\"$ct_a[id]\">$ct_a[name]</option>\n";
}
echo $countries;
} <td>
<select name="country" size="1">
<?php Countries::echoCountry(); ?>
</select>
</td>
<?php
class Views
{ // Load View (we add data with array $data[] )
public static function view($file, $data = [], $inc = false)
{
dbconn();
global $config, $THEME, $LANGUAGE;
// Check for view file
if (file_exists(' . $file . '.php')) {
if ($inc) {
stdhead('test');
require_once " . $file . ".php";
stdfoot();
} else {
require_once " . $file . ".php";
}
} else {
// View does not exist
die('View does not exist');
}
}
}####################### TEST #############################
$data = []
Views::view('test', $data, false); <?php
class Profile extends Controller
{
public function __construct()
{
$this->userModel = $this->model('User');
}
public function index()
{
dbconn();
global $config;
loggedinonly();
$id = (int) Input::get("id");
if (!is_valid_id($id)) {
Redirect::autolink(TTURL . "/home", "Bad ID.");
}
$user = User::getUserById($id);
if (!$user) {
Redirect::autolink(TTURL . "/home", Lang::T("NO_USER_WITH_ID") . " $id.");
}
// view own but not others
if ($_SESSION["view_users"] == "no" && $_SESSION["id"] != $id) {
Redirect::autolink(TTURL . "/home", Lang::T("NO_USER_VIEW"));
}
// user not ready to be seen yet
if (($user["enabled"] == "no" || ($user["status"] == "pending")) && $_SESSION["edit_users"] == "no") {
Redirect::autolink(TTURL . "/home", Lang::T("NO_ACCESS_ACCOUNT_DISABLED"));
}
// Start Blocked Users
$blocked = DB::run("SELECT id FROM friends WHERE userid=$user[id] AND friend='enemy' AND friendid=$_SESSION[id]");
$show = $blocked->rowCount();
if ($show != 0 && $_SESSION["control_panel"] != "yes") {
show_error_msg("Error", "<div style='margin-top:10px; margin-bottom:10px' align='center'><font size=2 color=#FF2000><b>You're blocked by this member and you can not see his profile!</b></font></div>", 1);
}
// $country
$res = DB::run("SELECT name FROM countries WHERE id=? LIMIT 1", [$user['country']]);
if ($res->rowCount() == 1) {
$arr = $res->fetch();
$country = "$arr[name]";
}
if (!$country) {
$country = "<b>Unknown</b>";
}
// $ratio
if ($user["downloaded"] > 0) {
$ratio = $user["uploaded"] / $user["downloaded"];
} else {
$ratio = "---";
}
$numtorrents = get_row_count("torrents", "WHERE owner = $id");
$numcomments = get_row_count("comments", "WHERE user = $id");
$numforumposts = get_row_count("forum_posts", "WHERE userid = $id");
$qry = DB::run("SELECT COUNT(`hnr`) FROM `snatched` WHERE `uid` = '$id' AND `hnr` = 'yes'");
$res = $qry->fetch(PDO::FETCH_ASSOC);
$numhnr = $res[0];
$avatar = htmlspecialchars($user["avatar"]);
if (!$avatar) {
$avatar = $config["SITEURL"] . "/images/default_avatar.png";
}
$usersignature = stripslashes($user["signature"]); // todo
$r = DB::run("SELECT id FROM friends WHERE userid=? AND friend=? AND friendid=?", [$_SESSION['id'], 'friend', $id]);
$friend = $r->rowCount();
$r = DB::run("SELECT id FROM friends WHERE userid=? AND friend=? AND friendid=?", [$_SESSION['id'], 'enemy', $id]);
$block = $r->rowCount();
$cardheader = sprintf(Lang::T("USER_DETAILS_FOR"), class_user_colour($user["username"]));
$user1 = $this->userModel->getAll($id);
$data = [
'title' => $cardheader,
'id' => $id,
'friend' => $friend,
'block' => $block,
'country' => $country,
'ratio' => $ratio,
'numhnr' => $numhnr,
'avatar' => $avatar,
'numtorrents' => $numtorrents,
'numcomments' => $numcomments,
'numforumposts' => $numforumposts,
'usersignature' => $usersignature,
'selectuser' => $user1,
];
$this->view('user/profile', $data, true);
}
public function edit()
{
dbconn();
global $config, $THEME, $tzs, $pdo;
loggedinonly();
$id = (int) $_GET["id"];
// Clear error
$stylesheets = '';
$tz = '';
if ($_SESSION['class'] < 5 && $id != $_SESSION['id']) {
autolink(TTURL . "/index", Lang::T("You dont have permission"));
} else {
// echo 'im staff or curuser';
}
$user = $this->userModel->getAll($id);
// Stylesheet
$ss_r = DB::run("SELECT * from stylesheets");
$ss_sa = array();
while ($ss_a = $ss_r->fetch(PDO::FETCH_LAZY)) {
$ss_id = $ss_a["uri"];
$ss_name = $ss_a["name"];
$ss_sa[$ss_name] = $ss_id;
}
ksort($ss_sa);
reset($ss_sa);
while (list($ss_name, $ss_id) = thisEach($ss_sa)) {
if ($ss_id == $user["stylesheet"]) {
$ss = " selected='selected'";
} else {
$ss = "";
}
$stylesheets .= "<option value='$ss_id'$ss>$ss_name</option>\n";
}
// Country
$countries = "<option value='0'>----</option>\n";
$ct_r = DB::run("SELECT id,name from countries ORDER BY name");
while ($ct_a = $ct_r->fetch(PDO::FETCH_LAZY)) {
$countries .= "<option value='$ct_a[id]'" . ($user['country'] == $ct_a['id'] ? " selected='selected'" : "") . ">$ct_a[name]</option>\n";
}
// Timezone
ksort($tzs);
reset($tzs);
while (list($key, $val) = thisEach($tzs)) {
if ($user["tzoffset"] == $key) {
$tz .= "<option value=\"$key\" selected='selected'>$val[0]</option>\n";
} else {
$tz .= "<option value=\"$key\">$val[0]</option>\n";
}
}
//Teams
$teams = "<option value='0'>--- " . Lang::T("NONE_SELECTED") . " ----</option>\n";
$sashok = DB::run("SELECT id,name FROM teams ORDER BY name");
while ($sasha = $sashok->fetch(PDO::FETCH_LAZY)) {
$teams .= "<option value='$sasha[id]'" . ($user['team'] == $sasha['id'] ? " selected='selected'" : "") . ">$sasha[name]</option>\n";
}
$gender = "<option value='Male'" . ($user['gender'] == "Male" ? " selected='selected'" : "") . ">" . Lang::T("MALE") . "</option>\n"
. "<option value='Female'" . ($user['gender'] == "Female" ? " selected='selected'" : "") . ">" . Lang::T("FEMALE") . "</option>\n";
$cardheader = sprintf(Lang::T("Edit Details"));
$user1 = $this->userModel->getAll($id);
$data = [
'title' => $cardheader,
'stylesheets' => $stylesheets,
'countries' => $countries,
'teams' => $teams,
'tz' => $tz,
'gender' => $gender,
'id' => $id,
'selectuser' => $user1,
];
$this->view('user/edit', $data, true);
}
public function submit()
{
dbconn();
global $config, $THEME, $tzs, $pdo;
loggedinonly();
$id = (int) $_GET["id"];
if ($_POST) {
$avatar = strip_tags($_POST["avatar"]);
$title = strip_tags($_POST["title"]);
$signature = $_POST["signature"];
$stylesheet = $_POST["stylesheet"];
$client = strip_tags($_POST["client"]);
$age = $_POST["age"];
$gender = $_POST["gender"];
$country = $_POST["country"];
$teams = $_POST["teams"];
$acceptpms = $_POST["acceptpms"];
$pmnotif = $_POST["pmnotif"];
$privacy = $_POST["privacy"];
$notifs = ($pmnotif == 'yes' ? "[pm]" : "");
if ($_POST['resetpasskey']) {
$passkey = '';
}
$timezone = (int) $_POST['tzoffset'];
if ($acceptpms == "yes") {
$acceptpms = 'yes';
} else {
$acceptpms = 'no';
}
$hideshoutbox = ($_POST["hideshoutbox"] == "yes") ? "yes" : "no";
// Save New details.
$pdo->run("UPDATE users
SET avatar=?, title=?, signature=?, stylesheet=?, client=?, age=?, gender=?, country=?, team=?, hideshoutbox=?, acceptpms=?, privacy=?, notifs=?, passkey=?, tzoffset=?
WHERE id =?", [$avatar, $title, $signature, $stylesheet, $client, $age, $gender, $country, $teams, $hideshoutbox, $acceptpms, $privacy, $notifs, $passkey, $timezone, $id]);
autolink(TTURL . "/profile/edit?id=$id", "Success");
}
}
public function admin()
{
dbconn();
global $config, $THEME, $pdo;
loggedinonly();
$id = (int) $_GET["id"];
if ($_SESSION['class'] < 5 && $id != $_SESSION['id']) {
autolink(TTURL . "/index", Lang::T("You dont have permission"));
} else {
// echo 'im staff or curuser';
}
if ($_POST) {
$userid = $_POST["userid"];
$downloaded = strtobytes($_POST["downloaded"]);
$uploaded = strtobytes($_POST["uploaded"]);
$ip = $_POST["ip"];
$class = (int) $_POST["class"];
$donated = (float) $_POST["donated"];
$password = $_POST["password"];
$warned = $_POST["warned"];
$forumbanned = $_POST["forumbanned"];
$downloadbanned = $_POST["downloadbanned"];
$shoutboxpos = $_POST["shoutboxpos"];
$modcomment = $_POST["modcomment"];
$enabled = $_POST["enabled"];
$invites = (int) $_POST["invites"];
$email = $_POST["email"];
$bonus = $_POST["bonus"];
if (!validemail($email)) {
show_error_msg(Lang::T("EDITING_FAILED"), Lang::T("EMAIL_ADDRESS_NOT_VALID"), 1);
}
//change user class
$arr = DB::run("SELECT class FROM users WHERE id=?", [$id])->fetch();
$uc = $arr['class'];
// skip if class is same as current
//if ($uc != $class && $class > 0) {
if ($uc <= get_others_class($id)) { // todo
show_error_msg(Lang::T("EDITING_FAILED"), Lang::T("11111111 YOU_CANT_DEMOTE_YOURSELF"), 1);
} elseif ($uc <= get_others_class($id)) {
show_error_msg(Lang::T("EDITING_FAILED"), Lang::T("222222 YOU_CANT_DEMOTE_SOMEONE_SAME_LVL"), 1);
} else {
DB::run("UPDATE users SET class=? WHERE id=?", [$class, $id]);
// Notify user
$prodemoted = ($class > $uc ? "promoted" : "demoted");
$msg = "You have been $prodemoted to " . get_user_class_name($class) . " by " . $_SESSION["username"] . "";
$added = get_date_time();
// DB::run("INSERT INTO messages (sender, receiver, msg, added) VALUES(0, $_SESSION[id], $msg, $added)");
}
// }
//continue updates
DB::run("UPDATE users
SET email=?, downloaded=?, uploaded=?, ip=?, donated=?, forumbanned=?, warned=?,
modcomment=?, enabled=?, invites=? , downloadbanned=?, shoutboxpos=?, seedbonus=?
WHERE id=?", [$email, $downloaded, $uploaded, $ip, $donated, $forumbanned, $warned, $modcomment,
$enabled, $invites, $downloadbanned, $shoutboxpos, $bonus, $id]);
write_log($_SESSION['username'] . " has edited user: $id details");
if ($_POST['resetpasskey'] == 'yes') {
DB::run("UPDATE users SET passkey=? WHERE id=?", ['', $uploaded]);
}
$chgpasswd = $_POST['chgpasswd'] == 'yes' ? true : false;
if ($chgpasswd) {
// $passreq = DB::run("SELECT password FROM users WHERE id=$userid");
$passres = DB::run("SELECT password FROM users WHERE id=?", [$id])->fetch();
if ($password != $passres['password']) {
$password = password_hash($password, PASSWORD_BCRYPT);
DB::run("UPDATE users SET password=? WHERE id=?", [$password, $id]);
write_log($_SESSION['username'] . " has changed password for user: $id");
}
}
autolink(TTURL . "/profile/admin?id=$id", Lang::T("SUCCESS"));
die;
}
$user = $this->userModel->getAll($id);
//$ratio
if ($user["downloaded"] > 0) {
$ratio = $user["uploaded"] / $user["downloaded"];
} else {
$ratio = "---";
}
$data = [
'id' => $id,
'selectuser' => $user,
];
$this->view('user/admin', $data, true);
}
}<div class="card">
<div class="card-header">
<?php echo $data['title']; ?>
</div>
<div class="card-body">
<?php foreach ($data['selectuser'] as $selectedid):
if ($selectedid["privacy"] != "strong" || ($_SESSION["control_panel"] == "yes") || ($_SESSION["id"] == $user["id"])) {
?>
<a href='<?php echo TTURL; ?>/profile?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Profile</button></a>
<?php if ($_SESSION["id"] == $data['id'] or $_SESSION["class"] > $config['Uploader']) {?>
<a href='<?php echo TTURL; ?>/profile/edit?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Edit</button></a>
<?php }?>
<?php if ($_SESSION["id"] == $data['id']) {?>
<a href='<?php echo TTURL; ?>/account/changepw?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Password</button></a>
<a href='<?php echo TTURL; ?>/account/email?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Email</button></a>
<a href='<?php echo TTURL; ?>/messages'><button type="button" class="btn btn-sm btn-primary">Messages</button></a>
<a href='<?php echo TTURL; ?>/bonus'><button type="button" class="btn btn-sm btn-primary">Seed Bonus</button></a>
<?php }?>
<?php if ($_SESSION["view_users"]) {?>
<a href='<?php echo TTURL; ?>/friends'><button type="button" class="btn btn-sm btn-primary">Your Friends</button></a>
<?php }?>
<?php if ($_SESSION["view_torrents"]) {?>
<a href='<?php echo TTURL; ?>/peers/seeding?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Seeding</button></a>
<a href='<?php echo TTURL; ?>/peers/uploaded?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Uploaded</button></a>
<?php }?>
<?php if ($_SESSION["class"] > $config['Uploader']) {?>
<a href='<?php echo TTURL; ?>/warning?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Warn</button></a>
<a href='<?php echo TTURL; ?>/profile/admin?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-success">Admin</button></a>
<?php }
?>
<table align="center" border="0" cellpadding="6" cellspacing="1" width="100%">
<tr>
<td width="50%"><b><?php echo Lang::T("PROFILE"); ?></b></td>
<td width="50%"><b><?php echo Lang::T("ADDITIONAL_INFO"); ?></b></td>
</tr>
<tr valign="top">
<td align="left">
<?php echo Lang::T("USERNAME"); ?>: <?php echo class_user_colour($selectedid["username"]) ?><br />
<?php echo Lang::T("EMAIL"); ?>: <?php echo $selectedid["email"]; ?><br />
<?php echo Lang::T("PASSKEY"); ?>: <?php echo $selectedid["passkey"]; ?><br />
<?php echo Lang::T("IP"); ?>: <?php echo $selectedid["ip"]; ?><br />
<?php echo Lang::T("USERCLASS"); ?>: <?php echo get_user_class_name($selectedid["class"]) ?><br />
<?php echo Lang::T("THEME_NAME"); ?>: <?php echo $selectedid["stylesheet"] ?><br />
<?php echo Lang::T("TITLE"); ?>: <i><?php echo format_comment($selectedid["title"]) ?></i><br />
<?php echo Lang::T("JOINED"); ?>: <?php echo htmlspecialchars(utc_to_tz($selectedid["added"])) ?><br />
<?php echo Lang::T("LAST_VISIT"); ?>: <?php echo htmlspecialchars(utc_to_tz($selectedid["last_access"])) ?><br />
<?php echo Lang::T("LAST_SEEN"); ?>: <?php echo htmlspecialchars($selectedid["page"]); ?><br />
</td>
<td align="left">
<?php echo Lang::T("AGE"); ?>: <?php echo htmlspecialchars($selectedid["age"]) ?><br />
<?php echo Lang::T("GENDER"); ?>: <?php echo Lang::T($selectedid["gender"]); ?><br />
<?php echo Lang::T("CLIENT"); ?>: <?php echo htmlspecialchars($selectedid["client"]) ?><br />
<?php echo Lang::T("COUNTRY"); ?>: <?php echo $data['country'] ?><br />
<?php echo Lang::T("DONATED"); ?> <?php echo $config['currency_symbol']; ?><?php echo number_format($selectedid["donated"], 2); ?><br />
<?php echo Lang::T("WARNINGS"); ?>: <?php echo htmlspecialchars($selectedid["warned"]) ?><br />
<?php if ($_SESSION["edit_users"] == "yes") {echo Lang::T("ACCOUNT_PRIVACY_LVL") . ": <b>" . Lang::T($selectedid["privacy"]) . "</b><br />";}?>
<?php echo Lang::T("SIGNATURE"); ?>:</b> <?php echo format_comment($data['usersignature']); ?><br />
</td>
</tr>
<tr>
<td width="50%"><b><?php echo Lang::T("STATISTICS"); ?></b></td>
<td width="50%"><b><?php echo Lang::T("OTHER"); ?></b></td>
</tr>
<tr valign="top">
<td align="left">
<?php echo Lang::T("UPLOADED"); ?>: <?php echo mksize($selectedid["uploaded"]); ?><br />
<?php echo Lang::T("DOWNLOADED"); ?>: <?php echo mksize($selectedid["downloaded"]); ?><br />
<?php echo Lang::T("RATIO"); ?>: <?php echo $data['ratio']; ?><br />
<?php echo Lang::T("Hit & Run"); ?>: <?php echo $data['numhnr']; ?><br />
<?php echo Lang::T("AVG_DAILY_DL"); ?>: <?php echo mksize($selectedid["downloaded"] / (DateDiff($selectedid["added"], time()) / 86400)); ?><br />
<?php echo Lang::T("AVG_DAILY_UL"); ?>: <?php echo mksize($selectedid["uploaded"] / (DateDiff($selectedid["added"], time()) / 86400)); ?><br />
<?php echo Lang::T("TORRENTS_POSTED"); ?>: <?php echo number_format($data['numtorrents']); ?><br />
<?php echo Lang::T("COMMENTS_POSTED"); ?>: <?php echo number_format($data['numcomments']); ?><br />
Forum Posts: <?php echo number_format($data['numforumposts']); ?><br />
</td>
<td align="left">
<?php if ($_SESSION["class"] >= 5 && $_SESSION["class"] > $selectedid["class"]) {?>[<a href="<?php echo $config['SITEURL'] ?>/invite/invitetree?id=<?php echo $selectedid["id"] ?>">Invite Tree</a>]<?php }?><br />
<img src="<?php echo $data['avatar']; ?>" alt="" title="<?php echo class_user_colour($selectedid["username"]); ?>" height="80" width="80" /><br />
<a href="<?php echo $config['SITEURL'] ?>/messages/create?&id=<?php echo $selectedid["id"] ?>"><button type='button' class='btn btn-sm btn-success'><?php echo Lang::T("SEND_PM") ?></button></a><br />
<a href="<?php echo $config['SITEURL'] ?>/report/user?user=<?php echo $selectedid["id"] ?>"><button type='button' class='btn btn-sm btn-danger'><?php echo Lang::T("REPORT_MEMBER") ?></button></a><br />
<?php if ($_SESSION["edit_users"] == "yes") {?>
<div style="margin-bottom:3px"><a href="<?php echo $config['SITEURL']; ?>/snatched?uid=<?php echo $selectedid["id"] ?>"><button type='button' class='btn btn-sm btn-warning'><?php echo Lang::T("SNATCHLIST") ?></button></a></div>
<?php }?>
</td>
</tr>
<?php if ($_SESSION["edit_users"] == "yes") {?>
<tr>
<td width="50%"><b><?php echo Lang::T("STAFF_ONLY_INFO"); ?></b></td>
</tr>
<tr valign="top">
<td align="left">
<?php
if ($user["invited_by"]) {
$invited = $selectedid['invited_by'];
$row = DB::run("SELECT username FROM users WHERE id=?", [$invited])->fetch();
echo "<b>" . Lang::T("INVITED_BY") . ":</b> <a href=\"$config[SITEURL]/profile?id=$selectedid[invited_by]\">" . class_user_colour($row['username']) . "</a><br />";
}
echo "<b>" . Lang::T("INVITES") . ":</b> " . number_format($selectedid["invites"]) . "<br />";
$invitees = array_reverse(explode(" ", $selectedid["invitees"]));
$rows = array();
foreach ($invitees as $invitee) {
$res = DB::run("SELECT id, username FROM users WHERE id=? and status=?", [$invitee, 'confirmed']);
if ($row = $res->fetch()) {
$rows[] = "<a href=\"$config[SITEURL]/profile?id=$row[id]\">" . class_user_colour($row['username']) . "</a>";
}
}
if ($rows) {
echo "<b>" . Lang::T("INVITEES") . ":</b> " . implode(", ", $rows) . "<br />";
}
?>
</td>
</tr>
<?php
}
//team
$res = DB::run("SELECT name,image FROM teams WHERE id=? LIMIT 1", [$selectedid['team']]);
if ($res->rowCount() == 1) {
$arr = $res->fetch();
echo "<tr><td colspan='2' align='left'><b>Team Member Of:</b><br />";
echo "<img src='" . htmlspecialchars($arr["image"]) . "' alt='' /><br />" . sqlesc($arr["name"]) . "<br /><br /><a href='$config[SITEURL]/teams'>[View " . Lang::T("TEAMS") . "]</a></td></tr>";
}
?>
</table>
<div style="margin-bottom:10px">
<?php
if ($_SESSION["id"] != $selectedid["id"]) {
if ($data['friend'] > 0) {
print("[<a href=$config[SITEURL]/friends/delete?type=friend&targetid=$selectedid[id]>Remove from Friends</a>]");
} elseif ($data['block'] > 0) {
print(" [<a href=$config[SITEURL]/friends/delete?type=block&targetid=$selectedid[id]>Remove from Blocked</a>]");
} else {
print("[<a href=$config[SITEURL]/friends/add?type=friend&targetid=$selectedid[id]><b>Add to Friends</b></a>] ");
print(" [<a href=$config[SITEURL]/friends/add?type=block&targetid=$selectedid[id]><b>Add to Blocked</b></a>]");
}
}
?>
</div><?php
} else {
echo sprintf(Lang::T("REPORT_MEMBER_MSG"), $selectedid["id"]);
}
endforeach;?>
</div>
</div>
<br /><div class="card">
<div class="card-header">
<?php echo $data['title']; ?>
</div>
<div class="card-body">
<a href='<?php echo TTURL; ?>/profile?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Profile</button></a>
<?php if ($_SESSION["id"] == $data['id'] or $_SESSION["class"] > $config['Uploader']) {?>
<a href='<?php echo TTURL; ?>/profile/edit?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Edit</button></a>
<?php }?>
<?php if ($_SESSION["id"] == $data['id']) {?>
<a href='<?php echo TTURL; ?>/account/changepw?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Password</button></a>
<a href='<?php echo TTURL; ?>/account/email?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Email</button></a>
<a href='<?php echo TTURL; ?>/messages'><button type="button" class="btn btn-sm btn-primary">Messages</button></a>
<a href='<?php echo TTURL; ?>/bonus'><button type="button" class="btn btn-sm btn-primary">Seed Bonus</button></a>
<?php }?>
<?php if ($_SESSION["view_users"]) {?>
<a href='<?php echo TTURL; ?>/friends'><button type="button" class="btn btn-sm btn-primary">Your Friends</button></a>
<?php }?>
<?php if ($_SESSION["view_torrents"]) {?>
<a href='<?php echo TTURL; ?>/peers/seeding?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Seeding</button></a>
<a href='<?php echo TTURL; ?>/peers/uploaded?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Uploaded</button></a>
<?php }?>
<?php if ($_SESSION["class"] > $config['Uploader']) {?>
<a href='<?php echo TTURL; ?>/warning?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Warn</button></a>
<a href='<?php echo TTURL; ?>/profile/admin?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-success">Admin</button></a>
<?php }
?><br>
<form action="<?php echo TTURL; ?>/profile/submit?id=<?php echo $data['id']; ?>" method="post">
<?php foreach ($data['selectuser'] as $selectedid): ?>
<table class="f-border" cellspacing="0" cellpadding="5" max-width="100%" align="center">
<?php
$acceptpms = $selectedid['acceptpms'] == "yes";
print("<tr><td align='right' class='alt2'><b>" . Lang::T("ACCEPT_PMS") . ":</b> </td><td class='alt2'><input type='radio' name='acceptpms'" . ($acceptpms ? " checked='checked'" : "") .
" value='yes' /><b>" . Lang::T("FROM_ALL") . "</b> <input type='radio' name='acceptpms'" .
($acceptpms ? "" : " checked='checked'") . " value='no' /><b>" . Lang::T("FROM_STAFF_ONLY") . "</b><br /><i>" . Lang::T("ACCEPTPM_WHICH_USERS") . "</i></td></tr>");
print("<tr><td align='right' class='alt3'><b>" . Lang::T("ACCOUNT_PRIVACY_LVL") . ":</b> </td><td align='left' class='alt3'>" . priv("normal", "<b>" . Lang::T("NORMAL") . "</b>") . " " . priv("low", "<b>" . Lang::T("LOW") . "</b>") . " " . priv("strong", "<b>" . Lang::T("STRONG") . "</b>") . "<br /><i>" . Lang::T("ACCOUNT_PRIVACY_LVL_MSG") . "</i></td></tr>");
print("<tr><td align='right' class='alt2'><b>" . Lang::T("EMAIL_NOTIFICATION") . ":</b> </td><td align='left' class='alt2'><input type='checkbox' name='pmnotif' " . (strpos($selectedid['notifs'], "[pm]") !== false ? " checked='checked'" : "") .
" value='yes' /><b>" . Lang::T("PM_NOTIFY_ME") . "</b><br /><i>" . Lang::T("EMAIL_WHEN_PM") . "</i></td></tr>");
print("<tr><td align='right' class='alt3'><b>" . Lang::T("THEME") . ":</b> </td><td align='left' class='alt3'><select name='stylesheet'>\n$data[stylesheets]\n</select></td></tr>");
print("<tr><td align='right' class='alt2'><b>" . Lang::T("PREFERRED_CLIENT") . ":</b> </td><td align='left' class='alt2'><input type='text' size='20' maxlength='20' name='client' value=\"" . htmlspecialchars($selectedid['client']) . "\" /></td></tr>");
print("<tr><td align='right' class='alt3'><b>" . Lang::T("AGE") . ":</b> </td><td align='left' class='alt3'><input type='text' size='3' maxlength='2' name='age' value=\"" . htmlspecialchars($selectedid['age']) . "\" /></td></tr>");
print("<tr><td align='right' class='alt2'><b>" . Lang::T("GENDER") . ":</b> </td><td align='left' class='alt2'><select size='1' name='gender'>\n$data[gender]\n</select></td></tr>");
print("<tr><td align='right' class='alt3'><b>" . Lang::T("COUNTRY") . ":</b> </td><td align='left' class='alt3'><select name='country'>\n$data[countries]\n</select></td></tr>");
if ($selectedid['class'] > 1) {
print("<tr><td align='right' class='alt2'><b>" . Lang::T("TEAM") . ":</b> </td><td align='left' class='alt2'><select name='teams'>\n$data[teams]\n</select></td></tr>");
}
print("<tr><td align='right' class='alt3'><b>" . Lang::T("AVATAR_UPLOAD") . ":</b> </td><td align='left' class='alt3'><input type='text' name='avatar' size='50' value=\"" . htmlspecialchars($selectedid["avatar"]) .
"\" /><br />\n<i>" . Lang::T("AVATAR_LINK") . "</i><br /></td></tr>");
print("<tr><td align='right' class='alt2'><b>" . Lang::T("CUSTOM_TITLE") . ":</b> </td><td align='left' class='alt2'><input type='text' name='title' size='50' value=\"" . strip_tags($selectedid["title"]) .
"\" /><br />\n <i>" . Lang::T("HTML_NOT_ALLOWED") . "</i></td></tr>");
print("<tr><td align='right' class='alt3' valign='top'><b>" . Lang::T("SIGNATURE") . ":</b> </td><td align='left' class='alt3'><textarea name='signature' cols='50' rows='10'>" . htmlspecialchars($selectedid["signature"]) .
"</textarea><br />\n <i>" . sprintf(Lang::T("MAX_CHARS"), 150) . ", " . Lang::T("HTML_NOT_ALLOWED") . "</i></td></tr>");
?>
<tr><td align='right' class='alt2'><b><?php echo Lang::T("RESET_PASSKEY"); ?>:</b> </td><td align='left' class='alt2'><input type='checkbox' name='resetpasskey' value='1' /> <i><?php echo Lang::T("RESET_PASSKEY_MSG"); ?></i></td></tr>
<?php
if ($config["SHOUTBOX"]) {
print("<tr><td align='right' class='table_col3'><b>" . Lang::T("HIDE_SHOUT") . ":</b></td><td align='left' class='table_col3'><input type='checkbox' name='hideshoutbox' value='yes' " . ($selectedid['hideshoutbox'] == 'yes' ? 'checked="checked"' : '') . " /> <i>" . Lang::T("HIDE_SHOUT") . "</i></td></tr> ");
}?>
<tr><td align='right' class='alt3'><b><?php echo Lang::T("TIMEZONE"); ?>:</b> </td><td align='left' class='alt3'><select name='tzoffset'><?php echo $data['tz']; ?></select></td></tr>
<tr><td colspan="2" align="center"><button type='submit' class='btn btn-sm btn-primary'><?php echo Lang::T("SUBMIT"); ?></button> <input type="reset" value="<?php echo Lang::T("REVERT"); ?>" /></td></tr>
</table>
<?php endforeach;?>
</form>
</div>
</div><br /> /**
* Post New Topic.
*/
public function newtopic()
{
dbconn();
global $config;
// todo add to valid class
if (!$config["FORUMS_GUESTREAD"]) {
loggedinonly();
}
if ($_SESSION["forumbanned"] == "yes" || $_SESSION["view_forum"] == "no") {
showerror(Lang::T("FORUM_BANNED"), Lang::T("FORUM_BANNED"));
}
//Here we decide if the forums is on or off
if ($config["FORUMS"]) {
$forumid = $_GET["forumid"];
if (!is_valid_id($forumid)) {
showerror(Lang::T("FORUM_ERROR"), "No Forum ID $forumid");
}
$data = [
'id' => $forumid,
];
$this->view('forum/newtopic', $data, true);
die;
}
}<div class="card">
<div class="card-header">
<?php echo Lang::T("New topic"); ?>
</div>
<div class="card-body">
<div>
<img src='<?php echo $config['SITEURL']; ?>/images/forum/help.png' alt='' />
<a href='<?php echo $config['SITEURL']; ?>/faq'><?php echo Lang::T("FORUM_FAQ"); ?></a>
<img src='<?php echo $config['SITEURL']; ?>/images/forum/search.png' alt='' />
<a href='<?php echo $config['SITEURL']; ?>/forums/search'><?php echo Lang::T("SEARCH"); ?></a>
<b><?php echo Lang::T("FORUM_CONTROL"); ?></b>
· <a href='<?php echo $config['SITEURL']; ?>/forums/viewunread'><?php echo Lang::T("FORUM_NEW_POSTS"); ?></a>
· <a href='<?php echo $config['SITEURL']; ?>/forums?catchup'><?php echo Lang::T("FORUM_MARK_READ"); ?></a>
</div><br>
<div><?php echo Lang::T("YOU_ARE_IN"); ?>: <a href='<?php echo $config['SITEURL']; ?>/forums'><?php echo Lang::T("FORUMS"); ?></a> <b style='vertical-align:middle'>/ Compose New Thread</b></div>
<?php require_once "helpers/bbcode_helper.php"; ?>
<?php insert_compose_frame($data['id']); ?>
</div>
</div> /**
* View Forum Index.
*/
public function index()
{
dbconn();
global $config;
// todo add to validation class
if (!$config["FORUMS_GUESTREAD"]) {
loggedinonly();
}
if ($_SESSION["forumbanned"] == "yes" || $_SESSION["view_forum"] == "no") {
Session::flashmsg('danger', Lang::T("FORUM_BANNED"), 1);
}
//Here we decide if the forums is on or off
if ($config["FORUMS"]) {
$themedir = $config['SITEURL'] . "/themes/" . ($_SESSION['stylesheet'] ?: $config['default_theme']) . "/forums/";
// Action: DEFAULT ACTION (VIEW FORUMS)
if (isset($_GET["catchup"])) {
catch_up();
}
// Action: SHOW MAIN FORUM INDEX
$forums_res = DB::run("SELECT forumcats.id AS fcid, forumcats.name AS fcname, forum_forums.* FROM forum_forums LEFT JOIN forumcats ON forumcats.id = forum_forums.category ORDER BY forumcats.sort, forum_forums.sort, forum_forums.name");
if ($forums_res->rowCount() == 0) {
Redirect::autolink1($config['SITEURL'] . '/index', 'danger', 'There is no Forums available');
}
//topic count and post counts
$postcount = number_format(get_row_count("forum_posts"));
$topiccount = number_format(get_row_count("forum_topics"));
$data = [
'mainquery' => $forums_res,
'themedir' => $themedir,
'postcount' => $postcount,
'topiccount' => $topiccount,
];
$this->view('forum/index', $data, true);
} else {
//HEY IF FORUMS ARE OFF, SHOW THIS FLASH MESSAGE
Session::flashmsg('warning', Lang::T("Unfortunatley the forums are not currently available."), 1);
}
}<div class="card">
<div class="card-header">
<?php echo Lang::T("Forum Home"); ?>
</div>
<div class="card-body">
<div>
<img src='$config[SITEURL]/images/forum/help.png' alt='' />
<a href='$config[SITEURL]/faq'><?php echo Lang::T("FORUM_FAQ"); ?></a>
<img src='<?php echo $config['SITEURL']; ?>/images/forum/search.png' alt='' />
<a href='<?php echo $config['SITEURL']; ?>/forums/search'><?php echo Lang::T("SEARCH"); ?></a>
<b><?php echo Lang::T("FORUM_CONTROL"); ?></b>
· <a href='<?php echo $config['SITEURL']; ?>/forums/viewunread'><?php echo Lang::T("FORUM_NEW_POSTS"); ?></a>
· <a href='<?php echo $config['SITEURL']; ?>/forums?catchup'><?php echo Lang::T("FORUM_MARK_READ"); ?></a>
</div><br>
<div><?php echo Lang::T("YOU_ARE_IN"); ?>: <a href='<?php echo $config['SITEURL']; ?>/forums'><?php echo Lang::T("FORUMS"); ?></a> <b style='vertical-align:middle'>/ index</b></div>
<?php
latestforumposts();
// MAIN LAYOUT
$fcid = 0;
while ($forums_arr = $data['mainquery']->fetch(PDO::FETCH_ASSOC)) {
if ($_SESSION['class'] < $forums_arr["minclassread"] && $forums_arr["guest_read"] == "no") {
continue;
}
if ($forums_arr['fcid'] != $fcid) {
?>
<div class='table'><table class='table table-striped'>
<thead><tr>
<th style='border: 1px solid black' align='left' colspan='2'><?php echo htmlspecialchars($forums_arr['fcname']); ?></th>
<th style='border: 1px solid black' width='37' align='right'>Topics</th>
<th style='border: 1px solid black' width='47' align='right'>Posts</th>
<th style='border: 1px solid black' align='right' width='180'>Last post</th>
</tr></thead><tbody>
<?php
$fcid = $forums_arr['fcid'];
}
$forumid = 0 + $forums_arr["id"];
$forumname = htmlspecialchars($forums_arr["name"]);
$forumdescription = htmlspecialchars($forums_arr["description"]);
$postcount = number_format(get_row_count("forum_posts", "WHERE topicid IN (SELECT id FROM forum_topics WHERE forumid=$forumid)"));
$topiccount = number_format(get_row_count("forum_topics", "WHERE forumid = $forumid"));
$lastpostid = get_forum_last_post($forumid);
// Get last post info
$post_res = DB::run("SELECT added,topicid,userid FROM forum_posts WHERE id=$lastpostid");
if ($post_res->rowCount() == 1) {
$post_arr = $post_res->fetch(PDO::FETCH_ASSOC) or showerror(Lang::T("ERROR"), "Bad forum last_post");
$lastposterid = $post_arr["userid"];
$lastpostdate = utc_to_tz($post_arr["added"]);
$lasttopicid = $post_arr["topicid"];
$user_res = DB::run("SELECT username FROM users WHERE id=$lastposterid");
$user_arr = $user_res->fetch(PDO::FETCH_ASSOC);
$lastposter = class_user_colour($user_arr["username"]);
$topic_res = DB::run("SELECT subject FROM forum_topics WHERE id=$lasttopicid");
$topic_arr = $topic_res->fetch(PDO::FETCH_ASSOC);
$lasttopic = stripslashes(htmlspecialchars($topic_arr['subject']));
//cut last topic
$latestleng = 10;
$lastpost = "<small><a href='$config[SITEURL]/forums/viewtopic&topicid=$lasttopicid&page=last#last'><b>" . CutName($lasttopic, $latestleng) . "</b></a> by <a href='$config[SITEURL]/profile?id=$lastposterid'><b>$lastposter</b></a><br />$lastpostdate</small>";
if ($_SESSION['loggedin'] == true) {
$a = DB::run("SELECT lastpostread FROM forum_readposts WHERE userid=$_SESSION[id] AND topicid=$lasttopicid")->fetch();
}
//define the images for new posts or not on index
if ($a && $a[0] == $lastpostid) {
$img = "folder";
} else {
$img = "folder_new";
}
} else {
$lastpost = "<span class='small'>No Posts</span>";
$img = "folder";
}
//following line is each forums display ?>
<tr>
<td style='border: 1px solid black' width='5%' >
<img src='<?php echo $data['themedir']; ?><?php echo $img; ?>.png' alt='' width='100% heigh= '100%' /></td>
<td style='border: 1px solid black' >
<a href='<?php echo $config['SITEURL']; ?>/forums/viewforum&forumid=<?php echo $forumid; ?>'><b><?php echo $forumname; ?></b></a><br>
<small>- <?php echo $forumdescription; ?></small></td>
<td style='border: 1px solid black' ><?php echo $topiccount; ?></td>
<td style='border: 1px solid black' ><?php echo $postcount; ?></td>
<td style='border: 1px solid black' ><b><?php echo $lastpost; ?></b></td></tr>
<?php } ?>
</tbody></table></div>
<table cellspacing='0' cellpadding='3'><tr valign='middle'>
<td><img src='<?php echo $data['themedir']; ?>folder_new.png' style='margin: 5px' alt='' /></td><td>New posts</td>
<td><img src='<?php echo $data['themedir']; ?>folder.png' style='margin: 5px' alt='' /></td><td>No New posts</td>;
<td><img src='<?php echo $data['themedir']; ?>folder_locked.png' style='margin: 5px' alt='' /></td><td><?php echo Lang::T("FORUMS_LOCKED"); ?> topic</td>
<td><img src='<?php echo $data['themedir']; ?>folder_sticky.png' style='margin: 5px' alt='' /></td><td><?php echo Lang::T("FORUMS_STICKY"); ?> topic</td>
</tr></table>
<center>Our members have made <?php echo $data[' $postcount']; ?> posts in <?php echo $data['topiccount']; ?> topics</center>
<?php insert_quick_jump_menu(); ?>
</div>
</div><br /> $forumid = 0 + $forums_arr["id"];
$forumname = htmlspecialchars($forums_arr["name"]);
$forumdescription = htmlspecialchars($forums_arr["description"]);
$postcount = number_format(get_row_count("forum_posts", "WHERE topicid IN (SELECT id FROM forum_topics WHERE forumid=$forumid)"));
$topiccount = number_format(get_row_count("forum_topics", "WHERE forumid = $forumid"));
$lastpostid = get_forum_last_post($forumid);
// Get last post info
$post_res = DB::run("SELECT added,topicid,userid FROM forum_posts WHERE id=$lastpostid");
if ($post_res->rowCount() == 1) {
$post_arr = $post_res->fetch(PDO::FETCH_ASSOC) or showerror(Lang::T("ERROR"), "Bad forum last_post");
$lastposterid = $post_arr["userid"];
$lastpostdate = utc_to_tz($post_arr["added"]);
$lasttopicid = $post_arr["topicid"];
$user_res = DB::run("SELECT username FROM users WHERE id=$lastposterid");
$user_arr = $user_res->fetch(PDO::FETCH_ASSOC);
$lastposter = class_user_colour($user_arr["username"]);
$topic_res = DB::run("SELECT subject FROM forum_topics WHERE id=$lasttopicid");
$topic_arr = $topic_res->fetch(PDO::FETCH_ASSOC);
$lasttopic = stripslashes(htmlspecialchars($topic_arr['subject']));
//cut last topic
$latestleng = 10;
$lastpost = "<small><a href='$config[SITEURL]/forums/viewtopic&topicid=$lasttopicid&page=last#last'><b>" . CutName($lasttopic, $latestleng) . "</b></a> by <a href='$config[SITEURL]/profile?id=$lastposterid'><b>$lastposter</b></a><br />$lastpostdate</small>";
if ($_SESSION['loggedin'] == true) {
$a = DB::run("SELECT lastpostread FROM forum_readposts WHERE userid=$_SESSION[id] AND topicid=$lasttopicid")->fetch();
}
//define the images for new posts or not on index
if ($a && $a[0] == $lastpostid) {
$img = "folder";
} else {
$img = "folder_new";
}
} else {
$lastpost = "<span class='small'>No Posts</span>";
$img = "folder";
} $ins_user = DB::run("INSERT INTO users
(username, password, secret, email, status, added, last_login, last_access, age, country, gender, client, stylesheet, language, class, ip)
VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
[$wantusername, $wantpassword, $secret, $email, $status, get_date_time(), get_date_time(), get_date_time(), $age, $country, $gender, $client, $config["default_theme"], $config["default_language"], $signupclass, getip()]);
$id = DB::lastInsertId()<?php
class Parse {
public function __construct() { }
private function __clone() { }
public function torr($filename = "")
{
$torrentInfo = array();
$array = array();
//check file type is a torrents
$torrent = explode(".", $filename);
// $fileend = end($torrent);
$fileend = strtolower(end($torrent));
if ($fileend == "torrent") {
$parse = file_get_contents("$filename");
if ($parse == false) {
echo "Parser Error: Error Opening torrents, unable to get contents.<br>";
}
if (!isset($parse)) {
echo "Parser Error: Error Opening torrent. Torrent file not chosen or could not be found.<br>";
} else {
$array = Newbencode::decode($parse);
if ($array === false) {
echo "Parser Error: Error Opening torrent, unable to decode.<br>";
} else {
if (array_key_exists("info", $array) === false) {
echo "Parser Error: Error opening torrents.<br>";
} else {
//Get Announce URL
$torrentInfo[0] = $array["announce"];
//Get Announce List Array
if (isset($array["announce-list"])) {
$torrentInfo[6] = $array["announce-list"];
}
//Read info, store as (infovariable)
$info = $array["info"];
//Calculates SHA1 Hash
$torrentInfo[1] = sha1(Newbencode::encode($info));
// Calculates date from UNIX Epoch
$torrentInfo[2] = date('r', $array["creation date"]);
// The name of the torrents is different to the file name
$torrentInfo[3] = $info['name'];
//Get file list
if (isset($info["files"]) && is_array($info["files"])) {
//Multi file torrents
$filecount = 0;
$torrentsize = 0;
//Get filenames here
$torrentInfo[8] = $info["files"];
foreach ($info["files"] as $file) {
$filecount = ++$filecount;
$torrentsize += $file['length'];
}
$torrentInfo[4] = $torrentsize;
$torrentInfo[5] = $filecount; //Get file count
} else {
// Single File Torrent
$torrentInfo[3] = $info['name'];
$torrentInfo[4] = $info['length'];
$torrentInfo[5] = 1;
}
//Get torrents comment
if (isset($array['comment'])) {
$torrentInfo[7] = $array['comment'];
}
}
}
}
}
return $torrentInfo;
//var_dump($torrentInfo);
}
}/*
$TorrentInfo = array();
$TorrentInfo = ParseTorrent("$torrent_dir/$fname");
$announce = $TorrentInfo[0];
$infohash = $TorrentInfo[1];
$creationdate = $TorrentInfo[2];
$internalname = $TorrentInfo[3];
$torrentsize = $TorrentInfo[4];
$filecount = $TorrentInfo[5];
$annlist = $TorrentInfo[6];
$comment = $TorrentInfo[7];
$filelist = $TorrentInfo[8];
*/
$torInfo = new Parse();
$tor = $torInfo->torr("$torrent_dir/$fname");
$announce = $tor[0];
$infohash = $tor[1];
$creationdate = $tor[2];
$internalname = $tor[3];
$torrentsize = $tor[4];
$filecount = $tor[5];
$annlist = $tor[6];
$comment = $tor[7];
$filelist = $tor[8]; <?php
/**
* Class Bencode
*
* Convert Map:
* - Dictionary (starts with d, ends with e, with key sort)
* - List (starts with l, ends with e)
* - Integer (starts with i, ends with e)
* - String (starts with number denoting number of characters followed by : and then the string)
*
* @package Rhilip\Bencode
* @author Rhilip
* @license MIT
*
* @see https://en.wikipedia.org/wiki/Bencode
* @see https://wiki.theory.org/index.php/BitTorrentSpecification
*/
class Newbencode
{
/**
* Decode bencoded data from string
*
* @param string $data
* @param int $pos
* @return mixed
* @throws Exception
*/
public static function decode($data, &$pos = 0)
{
$start_decode = ($pos === 0); // If it is the root call ?
if ($start_decode && (!is_string($data) || strlen($data) == 0)) {
throw new Exception('Decode Input is not valid String.');
}
if ($data[$pos] === 'd') {
$pos++;
$return = [];
while ($data[$pos] !== 'e') {
$key = self::decode($data, $pos);
$value = self::decode($data, $pos);
if ($key === null || $value === null) {
break;
}
if (!is_string($key)) {
throw new Exception('Non string key found in the dictionary.');
} elseif (array_key_exists($key, $return)) {
throw new Exception('Duplicate Dictionary key exist before: ' . $key);
}
$return[$key] = $value;
}
ksort($return, SORT_STRING);
$pos++;
} elseif ($data[$pos] === 'l') {
$pos++;
$return = [];
while ($data[$pos] !== 'e') {
$value = self::decode($data, $pos);
$return[] = $value;
}
$pos++;
} elseif ($data[$pos] === 'i') {
$pos++;
$digits = strpos($data, 'e', $pos) - $pos;
$value = substr($data, $pos, $digits);
$return = self::checkInteger($value);
$pos += $digits + 1;
} else {
$digits = strpos($data, ':', $pos) - $pos;
$len = self::checkInteger(substr($data, $pos, $digits));
if ($len < 0) {
throw new Exception('Cannot have non-digit values for String length');
}
$pos += ($digits + 1);
$return = substr($data, $pos, $len);
if (strlen($return) != $len) { // Check for String length is match or not
throw new ErrorException('String length is not match for: ' . $return . ', want ' . $len);
}
$pos += $len;
}
if ($start_decode && $pos !== strlen($data)) {
throw new ErrorException('Could not fully decode bencode string');
}
return $return;
}
/**
* This private function help us filter value like `-13` `13` will pass the filter and return it's int value
* Other value like ``,`-0`, `013`, `-013`, `2.127`, `six` will throw A ParseErrorException
*
* @param string $value
* @return int
* @throws ParseErrorException
*/
private static function checkInteger($value)
{
$int = (int)$value;
if ((string)$int !== $value) {
throw new ErrorException('Invalid integer format or integer overflow: ' . $value);
}
return $int;
}
/**
* Encode arbitrary data to bencode string
*
* @param mixed $data
* @return string
*/
public static function encode($data)
{
if (is_array($data)) {
$return = '';
$check = -1;
$list = true;
foreach ($data as $key => $value) {
if ($key !== ++$check) {
$list = false;
break;
}
}
if ($list) {
$return .= 'l';
foreach ($data as $value) {
$return .= self::encode($value);
}
} else {
$return .= 'd';
ksort($data, SORT_STRING);
foreach ($data as $key => $value) {
$return .= self::encode((string)$key);
$return .= self::encode($value);
}
}
$return .= 'e';
} elseif (is_integer($data)) {
$return = 'i' . $data . 'e';
} else {
$return = strlen($data) . ':' . $data;
}
return $return;
}
/**
* Load data from bencoded file
*
* @param string $path
* @return mixed
* @throws ParseErrorException
*/
public static function load($path)
{
return self::decode(file_get_contents($path));
}
/**
* Dump data to bencoded file
*
* @param string $path
* @param $data
* @return mixed
*/
public static function dump($path, $data)
{
return file_put_contents($path, self::encode($data));
}
}throw new ErrorException('Invalid integer format or integer overflow: ' . $value); if ($row["external"] != 'yes' && $CURUSER) { // local torrent so add passkey
// Bencode
$dict = Newbencode::decode(file_get_contents($fn));
$dict['announce'] = sprintf($config["PASSKEYURL"], $CURUSER["passkey"]);
unset($dict['announce-list']);
$data = Newbencode::encode($dict);
header('Content-Disposition: attachment; filename="' . $name . '"'); $stats = Newbencode::decode($fp);
//$stats = BDecode($fp); $array = Newbencode::decode($parse);
if ($array === false) {
echo "Parser Error: Error Opening torrent, unable to decode.<br>";
} else {
if (array_key_exists("info", $array) === false) {
echo "Parser Error: Error opening torrents.<br>";
} else {
//Get Announce URL
$torrentInfo[0] = $array["announce"];
//Get Announce List Array
if (isset($array["announce-list"])) {
$torrentInfo[6] = $array["announce-list"];
}
//Read info, store as (infovariable)
$info = $array["info"];
//Calculates SHA1 Hash
$torrentInfo[1] = sha1(Newbencode::encode($info));