Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
User Posts

Go to Profile

Template help — 2020-11-22 17:13:02 in M-BiTsy Support
It's a little easier for me because I use models and my pages/methods are tiny even the submit post code are moved like login/loginsubmit  but I could defo use the querys better so I can remove all the while

If I get the query right in the model I would write out a array eg (on phone at min)

$stmt = Sql query join etc user invite->fetch;
$stmt = [
'username' => $stmt[username],
'Invite' => $stmt[invitr]
          ]

I'll look at for this and post a few to get me started
rating — 2020-11-22 16:38:57 in v3 Support
You can try swap this part about in functions.php find
                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;
           }


I have put // before 3 lines
Remove the // one at a time maybe we get lucky
                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;
           }
Template help — 2020-11-22 13:23:55 in M-BiTsy Support
The goal for each page is query one in & one out at most, keeping everything working and all the functionality makes it a little harder but I'll use your tips moving forward
rating — 2020-11-22 11:53:57 in v3 Support
Try replace line in config.php with this I have added rating
$site_config["torrenttable_columns"] = "tube,category,cover,name,dl,uploader,comments,size,seeders,leechers,health,external,rating";


Now it should show on torrenttable
rating — 2020-11-22 06:18:14 in v3 Support
"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:


:unsure:  maybe we can be more clear
For torrent.php it would be in torrenttable correct, if so on config.php find
$site_config["torrenttable_columns"]


Add rating to end off that line  and it will show on index, torrents, search etc

If not torrenttable a image of location will help  (y)
rating — 2020-11-21 22:50:46 in v3 Support
Heres the current function already in v3
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\" />";
}


You just need to pass the rating number from the big query depending where you want it example
echo ratingpic($row['numratings']);
Template help — 2020-11-20 22:24:06 in M-BiTsy Support
heres the forum so far
<?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>&lt;&lt; Prev</b>";
       } else {
           $pagemenu .= "<a href='$config[SITEURL]/forums/viewtopic&amp;topicid=$topicid&amp;page=" . ($page - 1) . "'><b>&lt;&lt; Prev</b></a>";
       }

       //
       $pagemenu .= "&nbsp;&nbsp;";
       for ($i = 1; $i <= $pages; ++$i) {
           if ($i == $page) {
               $pagemenu .= "<b>$i</b>\n";
           } else {
               $pagemenu .= "<a href='$config[SITEURL]/forums/viewtopic&amp;topicid=$topicid&amp;page=$i'><b>$i</b></a>\n";
           }

       }
       //
       $pagemenu .= "&nbsp;&nbsp;";
       if ($page == $pages) {
           $pagemenu .= "<b>Next &gt;&gt;</b><br /><br />\n";
       } else {
           $pagemenu .= "<a href='$config[SITEURL]/forums/viewtopic&amp;topicid=$topicid&amp;page=" . ($page + 1) . "'><b>Next &gt;&gt;</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 &gt; $subject");
       forumheader("<a href='$config[SITEURL]/forums/viewforum&amp;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&amp;forumpost=$postid'><img src='" . THEMEDIR . "p_report.png' border='0' alt='" . Lang::T("FORUMS_REPORT_POST") . "' /></a>&nbsp;<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>&nbsp;");
           }

           //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&amp;postid=$postid'><img src='" . THEMEDIR . "p_edit.png' border='0' alt='' /></a>&nbsp;");
           }
           if ($_SESSION["delete_forum"] == "yes") {
               print("<a href='$config[SITEURL]/forums/deletepost&amp;postid=$postid&amp;sure=0'><img src='" . THEMEDIR . "p_delete.png' border='0' alt='' /></a>&nbsp;");
           }
           if (!$locked && $maypost) {
               print("<a href=\"javascript:SmileIT('
$postername:
$quote
', 'Form', 'body');\"><img src='" . THEMEDIR . "p_quote.png' border='0' alt='' /></a>&nbsp;");
               print("<a href='#bottom'><img src='" . THEMEDIR . "p_reply.png' alt='' /></a>");
           }
           print("&nbsp;</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&amp;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&amp;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&amp;forumid=$forumid&amp;topicid=$topicid&amp;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&amp;forumid=$forumid&amp;topicid=$topicid&amp;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&amp;topicid=$topicid&amp;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&amp;forumid=$forumid&amp;topicid=$topicid&amp;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&amp;forumid=$forumid&amp;topicid=$topicid&amp;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;
   }

}
Template help — 2020-11-20 17:54:50 in M-BiTsy Support
just writing as i go bit by bit ive done it so i can mass edit but it makes sense to do odd few pieces like the country drop down list on a country class
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;
}


then call it anywhere like, so all the code is easier to read
                <td>
                   <select name="country" size="1">
                   <?php Countries::echoCountry(); ?>
                   </select>
               </td>


some files and functions are more difficult
Template help — 2020-11-20 17:37:08 in M-BiTsy Support
you can try this m8 if your interested in templates, i know your using smarty at the minute but this can remove 3 party stuff

create file called Views.php and place in backend, in functions.php include the Views.php file near where include config and tz.php are (bottom of the include list may be best for test)

<?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');
       }
   }
}


create file called test.php and place in root
####################### TEST #############################


then anywhere on index.php try call the template

$data = []
Views::view('test', $data, false);
Template help — 2020-11-20 17:11:15 in M-BiTsy Support
this is progress with profile controller still need to merge edit and admin, so all edit for staff is on same page as members edit - using session (or curuser for v3) to hide the staff parts like email, ratio
the reset pass, confirm still have separate pages i did have it all on one controller but the job doesn't seem as bad with smaller files lol

notice the submit function, ive started moving all inputs (if $_post etc) to there own method
<?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);
   }

}


profile template
<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>&nbsp;
   <?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?&amp;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("&nbsp;[<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>]&nbsp;");
           print("&nbsp;[<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 />


edit template
<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>&nbsp;
   <?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' />&nbsp;<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"' : '') . " />&nbsp;<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 />
Template help — 2020-11-20 16:54:27 in M-BiTsy Support
Ill post my logic for the login fingerprint should be able to piece a mod together for v3 and members will be able to use remember me on login form
Template help — 2020-11-20 16:50:36 in M-BiTsy Support
For oop I splitt the account down into tiny pieces, for mvc it looks easier to have it all on one page I've just done the account side a few days ago
I renamed them profile lol profile edit etc
I removed modtask and all unneeded stuff I'll post my profile controller tomorrow with the templates
For the user class itself I separated the login and logout pages so I just use session
But I have been slower making 2 new classes
First the model class this includes stuff like the where function which can be called anywhere with one line ( static method)
Second is just a class for normal user interaction like loggedin, class color and the dbconn() logic for the curuser array (check cookie etc) has been moved there I check a fingerprint a hash of ip/browser and store that as cookie and session so if it doesnt match the ip browser it logs them out
Now I've added my classes got a bit more direction now, although I do just look at the screen sometimes for a hour scratching my head thinking where to start  ?
Template help — 2020-11-20 05:19:06 in M-BiTsy Support
cheers m8 i dont think my next release will be until the beginning of January so much to do but its taking shape now to be true mvc, might even change the name from TT

here is another example for show this one was easy, and yes another forum one
the controller method
    /**
    * 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;
       }
   }


and the html view
<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='' />&nbsp;
       <a href='<?php echo $config['SITEURL']; ?>/faq'><?php echo Lang::T("FORUM_FAQ"); ?></a>&nbsp; &nbsp;&nbsp;
       <img src='<?php echo $config['SITEURL']; ?>/images/forum/search.png' alt='' />&nbsp;
       <a href='<?php echo $config['SITEURL']; ?>/forums/search'><?php echo Lang::T("SEARCH"); ?></a>&nbsp; &nbsp;
       <b><?php echo Lang::T("FORUM_CONTROL"); ?></b>
        &middot; <a href='<?php echo $config['SITEURL']; ?>/forums/viewunread'><?php echo Lang::T("FORUM_NEW_POSTS"); ?></a>
        &middot; <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"); ?>: &nbsp;<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>
Template help — 2020-11-19 22:08:54 in M-BiTsy Support
Slowly making my way through sorting out all the spaghetti code on pdo version and moving all the html to views so if any one has experience and wouldnt mind having a look

heres the controller for forum page (the sql will be moved to model classes when im happy with it)
    /**
    * 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);
       }
   }


and here is the view/template
<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='' />&nbsp;
       <a href='$config[SITEURL]/faq'><?php echo Lang::T("FORUM_FAQ"); ?></a>&nbsp; &nbsp;&nbsp;
       <img src='<?php echo $config['SITEURL']; ?>/images/forum/search.png' alt='' />&nbsp;
       <a href='<?php echo $config['SITEURL']; ?>/forums/search'><?php echo Lang::T("SEARCH"); ?></a>&nbsp; &nbsp;
       <b><?php echo Lang::T("FORUM_CONTROL"); ?></b>
        &middot; <a href='<?php echo $config['SITEURL']; ?>/forums/viewunread'><?php echo Lang::T("FORUM_NEW_POSTS"); ?></a>
        &middot; <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"); ?>: &nbsp;<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&amp;topicid=$lasttopicid&amp;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&amp;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 />


its this part causing the headache if anyone has any ideas on how to move this out of the view, i was thinking of passing the $forums_arr array to a function but there might be a better way
    $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&amp;topicid=$lasttopicid&amp;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";
   }
I had a go with this mate bit more modern
[URL unfurl="true"]https://github.com/medariox/scrapeer[/url]

With that it was again tempermental - again a  setting something to do with the function socket_create() -   sockets is enabled

It would explain why it stopped working on different versions it's not code its server/host side im sure - xammp runs scraping perfect every time now on update I'm working on at minute with the old mod from here  :unsure:
On the next update the scraper is working (on some setups) it seems to be a setting in php.ini if you have any thoughts [USER=20382]@STorrents2020[/USER]  in check.php theres one setting for external I checked that and that's not it
Maybe a firewall, for that query I'll have a closer look when I get in
Try this around line 214 in controllers/account.php

Replace the query and lastinsert with
$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()


Before you signup remove any lines from the two error/exception_log.txt files when you signup any error will be written to these files which are more detailed, posting that will help but please check though first it will contain your email of the signup account

When you update sql sometimes the strict mode switches on have you check strict mode is off
New Bencode Class — 2020-11-14 21:39:41 in M-BiTsy Support
here is how i parse for now just wanted to make it a object - for v3 you must require the file where you need it

create file Parse.php place in backend
<?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);
   }

}


in torrent-upload.php
/*
               $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];
New Bencode Class — 2020-11-14 21:25:51 in M-BiTsy Support
Heres the bencode class i use for pdo/mvc for v3 you just need to include the file

search for bdecode.php & bencode.php replace these for require Newbencode.php
when making these edits where looking for the bdecode & bencode functions the old two classes can be removed
ill update with announce but fullys woks the announce still uses separate functions

create file Newbencode.php place in backend
<?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));
   }
}


You can always remove these lines for the autolink function - exceptions will be in your log
throw new ErrorException('Invalid integer format or integer overflow: ' . $value);


in download.php it should look like this
        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 . '"');


in functions (scrape function)
        $stats = Newbencode::decode($fp);
       //$stats = BDecode($fp);


Then in the parse function (i dont use this but should work)
                $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));
ratio — 2020-11-14 05:19:36 in v3 Support
If you use it mate will you test the other code, once I know the syntax works I can easily add it to the memberlist table for niki
Users online
Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 10

  • Online

  • Total online: 4
  • Members: 1
  • Guests online: 3
  • Comments: 3
  • Messages: 1,728