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
Bug Tracker
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / M-BiTsy / M-BiTsy Support

2021-06-10 13:49:24
here is the controller method, pretty small

   /**
    * View Forum.
    */
   public function viewforum()
   {
       $this->validForumUser();
       $forumid = Input::get("forumid");
       if (!$this->valid->validId($forumid)) {
           Session::flash('info', Lang::T("FORUMS_DENIED"), URLROOT . "/forums");
       }
       // 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::flash('info', Lang::T("FORUMS_NOT_PERMIT"), URLROOT . "/forums");
       }
       // Pagination
       $count = get_row_count("forum_topics", "WHERE forumid=$forumid");
       list($pagertop, $pagerbottom, $limit) = pager(25, $count, URLROOT . "/forums/viewforum&forumid=$forumid&");

       // Get topics data and display category
       $topicsres = DB::run("SELECT * FROM forum_topics WHERE forumid=$forumid ORDER BY sticky, lastpost  DESC $limit")->fetchAll();
       $data = [
           'title' => 'Forums',
           'topicsres' => $topicsres,
           'forumname' => $forumname,
           'forumid' => $forumid,
           'pagerbottom' => $pagerbottom,
       ];
       $this->view('forum/viewforum', $data, 'user');
   }


the query passed to template (topicsres)

array(1) { [0]=> array(9) {
["id"]=> int(2)
["userid"]=> int(1)
["subject"]=> string(11) "subject name"
["locked"]=> string(2) "no"
["forumid"]=> int(3)
["lastpost"]=> int(8)
["moved"]=> string(2) "no"
["sticky"]=> string(2) "no"
["views"]=> int(65) } }


so far so good but in the template you will see the big php code block with 6 query's in. Only html should be in there. This is the biggest block in the templates - for most of the others i can use a join and be a little creative. Just wonder whats the best way before i start working through them all


<?php
forumheader($data['forumname']);
if ($_SESSION['loggedin'] == true) {
   ?>
   <table class='table table-striped'><tr><td>
   <div align='right'><a href='<?php echo URLROOT; ?>/forums/newtopic&forumid=<?php echo $data['forumid']; ?>'>
   <button type='submit' class='btn btn-sm btn-warning'>New Post</button></a></div>
   </td></tr></table>
   <?php
}
if ($data['topicsres'] > 0) {
   ?>
   <div class="row">
   <div class="col-lg-12">
   <div class="wrapper wrapper-content animated fadeInRight">

   <div class="row card-header">
   <div class="col-md-1">
   Read
   </div>
   <div class="col-md-4">
   Topic
   </div>
   <div class="col-md-1 d-none d-sm-block">
   Replies
   </div>
   <div class="col-md-1 d-none d-sm-block">
   Views
   </div>
   <div class="col-md-1 d-none d-sm-block">
   Author
   </div>
   <div class="col-md-2 d-none d-sm-block">
   Last Post
   </div>
   <?php
   if ($_SESSION["edit_forum"] == "yes" || $_SESSION["delete_forum"] == "yes") {
       ?>
       <div class="col-md-2 d-none d-sm-block">
       Moderate
       </div>
       <?php
   }
   print("</div>");

   foreach ($data['topicsres'] as $topicarr) {

//////// ALL THIS ////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
       $topicid = $topicarr["id"];
       $topic_userid = $topicarr["userid"];
       $locked = $topicarr["locked"] == "yes";
       $moved = $topicarr["moved"] == "yes";
       $sticky = $topicarr["sticky"] == "yes";
       //---- Get reply count
       $res = DB::run("SELECT COUNT(*) FROM forum_posts WHERE topicid=$topicid");
       $arr = $res->fetch(PDO::FETCH_LAZY);
       $posts = $arr[0];
       $replies = max(0, $posts - 1);
       //---- Get userID and date of last post
       $res = DB::run("SELECT * FROM forum_posts WHERE topicid=$topicid ORDER BY id DESC LIMIT 1");
       $arr = $res->fetch(PDO::FETCH_ASSOC);
       $lppostid = $arr["id"];
       $lpuserid = (int) $arr["userid"];
       $lpadded = TimeDate::utc_to_tz($arr["added"]);
       //------ Get name of last poster
       if ($lpuserid > 0) {
           $res = DB::run("SELECT * FROM users WHERE id=$lpuserid");
           if ($res->rowCount() == 1) {
               $arr = $res->fetch(PDO::FETCH_ASSOC);
               $lpusername = "<a href='" . URLROOT . "/profile?id=$lpuserid'>" . Users::coloredname($arr['username']) . "</a>";
           } else {
               $lpusername = "Deluser";
           }
       } else {
           $lpusername = "Deluser";
       }
       //------ Get author
       if ($topic_userid > 0) {
           $res = DB::run("SELECT username FROM users WHERE id=$topic_userid");
           if ($res->rowCount() == 1) {
               $arr = $res->fetch(PDO::FETCH_ASSOC);
               $lpauthor = "<a href='" . URLROOT . "/profile?id=$topic_userid'>" . Users::coloredname($arr['username']) . "</a>";
           } else {
               $lpauthor = "Deluser";
           }
       } else {
           $lpauthor = "Deluser";
       }
       // Topic Views
       $viewsq = DB::run("SELECT views FROM forum_topics WHERE id=$topicid");
       $viewsa = $viewsq->fetch(PDO::FETCH_LAZY);
       $views = $viewsa[0];
       // End
       //---- Print row
       if ($_SESSION) {
           $r = DB::run("SELECT lastpostread FROM forum_readposts WHERE userid=$_SESSION[id] AND topicid=$topicid");
           $a = $r->fetch(PDO::FETCH_LAZY);
       }
       $new = !$a || $lppostid > $a[0];
       $topicpic = ($locked ? ($new ? "folder_locked_new" : "folder_locked") : ($new ? "folder_new" : "folder"));
       $subject = ($sticky ? "<b>" . Lang::T("FORUMS_STICKY") . ": </b>" : "") . "<a href='" . URLROOT . "/topic?topicid=$topicid'><b>" .
       encodehtml(stripslashes($topicarr["subject"])) . "</b></a>$topicpages";
       ?>
       <div class="row border border-primary">
       <div class="col-md-1 d-none d-sm-block">
       <img src='<?php echo URLROOT; ?>/assets/images/forum/<?php echo $topicpic ?>.png' alt='' />
       </div>
       <div class="col-md-4">
       <?php echo $subject; ?>
       </div>
       <div class="col-md-1 d-none d-sm-block">
       <?php echo $replies; ?>
       </div>
       <div class="col-md-1 d-none d-sm-block">
       <?php echo $views; ?>
       </div>
       <div class="col-md-1 d-none d-sm-block">
       <?php echo $lpauthor; ?>
       </div>
       <div class="col-md-2">
       <span class='small'>by <?php echo $lpusername; ?><br /><span style='white-space: nowrap'><?php echo $lpadded; ?></span></span>
       </div>
       <?php
   
       if ($_SESSION["edit_forum"] == "yes" || $_SESSION["delete_forum"] == "yes") {
           print("<div class='col-md-2 d-none d-sm-block'>");
           if ($locked) {
               print("<a href='" . URLROOT . "/forums/unlocktopic&forumid=$data[forumid]&topicid=$topicid&page=$page' title='Unlock'><img src='" . URLROOT . "/assets/images/forum/topic_unlock.png' alt='UnLock Topic' /></a>\n");
           } else {
               print("<a href='" . URLROOT . "/forums/locktopic&forumid=$data[forumid]&topicid=$topicid&page=$page' title='Lock'><img src='" . URLROOT . "/assets/images/forum/topic_lock.png' alt='Lock Topic' /></a>\n");
           }
           print("<a href='" . URLROOT . "/forums/deletetopic&topicid=$topicid&sure=0' title='Delete'><img src='" . URLROOT . "/assets/images/forum/topic_delete.png' alt='Delete Topic' /></a>\n");
           if ($sticky) {
               print("<a href='" . URLROOT . "/forums/unsetsticky&forumid=$data[forumid]&topicid=$topicid&page=$page' title='UnStick'><img src='" . URLROOT . "/assets/images/forum/older_sticky_new.png' alt='Unstick Topic' /></a>\n");
           } else {
               print("<a href='" . URLROOT . "/forums/setsticky&forumid=$data[forumid]&topicid=$topicid&page=$page' title='Stick'><img src='" . URLROOT . "/assets/images/forum/folder_sticky.png' alt='Stick Topic' /></a>\n");
           }
           print("</div>");
       }
       print("</div>");
   }

   print("</div></div></div>");
   print ($data['pagerbottom']);
} else {
   print("<p align='center'>No topics found</p>\n");
}


the logic here should not be so different from your own based on the TT original forum and here is the viewforum page https://torrenttrader.uk/forums/viewforum&forumid=110
Last edited by M-jay warn on 2021-06-10 13:53:43
2021-06-10 18:37:40
Perfect, with that array we have everything we need. We can use ternary in there one by one, to switch from value to zero or null (plays nice with database column types).
2021-06-10 21:33:31
This is what I got so far


<?
$forumid = 11; // foRUM id
// Get forum name
$res = DB::run("SELECT name, minclassread, guest_read FROM forum_forums WHERE id = $forumid");

// Get forum topics
$gettopicres = DB::run("SELECT * FROM forum_topics WHERE forumid=$forumid ORDER BY sticky, lastpost DESC");
$topicres = $gettopicres->fetchAll();

$array = ['title' => 'Forums', 'forumname' => ($arr = $res->fetch()) ? $arr['name'] : 0, 'forumid' => $forumid, 'pagerbottom' => ''];
foreach ($topicres as $topicarr)
{
   $data['level'] = ($_SESSION['edit_forum'] == 'yes' || $_SESSION['delete_forum'] == 'yes') ? 'Moderator' : 'Member';
   $data['topicid'] = $topicarr['id'];
   $data['topic_userid'] = $topicarr['userid'];
   $data['locked'] = $topicarr['locked'] ?? 'yes'; // PHP 7 - Null Coalescing Operator
   $data['moved'] = $topicarr['moved'] ?? 'yes'; // PHP 7 - Null Coalescing Operator
   $data['sticky'] = $topicarr['sticky'] ?? 'yes'; // PHP 7 - Null Coalescing Operator
   $replies = DB::run("SELECT COUNT(*) as total FROM forum_posts WHERE topicid=$topicarr[id]");
   $data['replies'] = max(0, ($arr = $replies->fetchAll() ? count($arr) - 1 : 0));
   $forumposts = DB::run("SELECT * FROM forum_posts WHERE topicid = $topicarr[id] ORDER BY id DESC LIMIT 1");
   if ($arr = $forumposts->fetchAll())
   {
       $data['lppostid'] = intval($arr['id']);
       $data['lpuserid'] = intval($arr['userid']);
       $data['lpadded'] = $arr['added'];
       if (intval($arr['userid']) > 0)
       {
           $users = DB::run("SELECT * FROM users WHERE user_id = $arr[userid]");
           $data['lpusername'] = ($arr = $res->fetchAll()) ? "<a href='/profile?id=$arr[userid]'>$arr[username]</a>" : "Deluser";
           if ($topicarr['id'] > 0)
           {
               $data['lpauthor'] = ($arr = $users->fetchAll()) ? "<a href='/profile?id=$topicarr[userid]'>$arr[username]</a>" : null;
           }
       }
       array_push($data, $arr);
   }
   $viewsq = DB::run("SELECT views FROM forum_topics WHERE id = $topicarr[id]");
   $data['views'] = ($v = $viewsq->fetch()) ? intval($v['views']) : 0;

   $r = DB::run("SELECT lastpostread FROM forum_readposts WHERE userid = 1 AND topicid = $topicarr[id]");
   isset($_SESSION) ? ($a = $r->fetch()) : false;

   $data['topicpic'] = ($locked ? ((!$a || intval($arr['id']) > $a['lastpostread']) ? "folder_locked_new" : "folder_locked") : ((!$a || intval($arr['id']) > $a['lastpostread']) ? "folder_new" : "folder"));
   $data['subject'] = ($data['sticky'] ? "<b>FORUMS_STICKY</b>" : "") . "<a href='/topic?topicid=$topicarr[id]'><b>" . trim($topicarr["subject"]) . "</b></a>";

   // Push array
   array_push($data, $array);
}

$this->view('forum/viewforum', $data, 'user');


Pulls everything up for that forum ID.

Now your view code should be something like this
<?
forumheader($data['forumname']);
if ($_SESSION['loggedin'] == true): ?>

  <table class='table table-striped'><tr><td>
  <div align='right'><a href='<?=URLROOT?>/forums/newtopic&forumid=<?=$data['forumid']?>'>
  <button type='submit' class='btn btn-sm btn-warning'>New Post</button></a></div>
  </td></tr></table>

<? endif; if ($data['topicsres'] > 0): ?>
  <div class="row">
  <div class="col-lg-12">
  <div class="wrapper wrapper-content animated fadeInRight">

  <div class="row card-header">
  <div class="col-md-1">
  Read
  </div>
  <div class="col-md-4">
  Topic
  </div>
  <div class="col-md-1 d-none d-sm-block">
  Replies
  </div>
  <div class="col-md-1 d-none d-sm-block">
  Views
  </div>
  <div class="col-md-1 d-none d-sm-block">
  Author
  </div>
  <div class="col-md-2 d-none d-sm-block">
  Last Post
  </div>
  <?=($data['level'] == 'Moderator') ? '<div class="col-md-2 d-none d-sm-block">Moderate</div>' : ''?>
  </div>

      <div class="row border border-primary">
      <div class="col-md-1 d-none d-sm-block">
      <img src='<?=URLROOT?>/assets/images/forum/<?=$data['topicpic']?>.png' alt='' />
      </div>
      <div class="col-md-4">
      <?=$data['subject']?>
      </div>
      <div class="col-md-1 d-none d-sm-block">
      <?=$data['replies']?>
      </div>
      <div class="col-md-1 d-none d-sm-block">
      <?=$data['views']?>
      </div>
      <div class="col-md-1 d-none d-sm-block">
      <?=$data['lpauthor']?>
      </div>
      <div class="col-md-2">
      <span class='small'>by <?=$data['lpusername']?><br /><span style='white-space: nowrap'><?=$data['lpadded']?></span></span>
      </div>
      <?
  if ($_SESSION["edit_forum"] == "yes" || $_SESSION["delete_forum"] == "yes") {
          print("<div class='col-md-2 d-none d-sm-block'>");
          if ($locked) {
              print("<a href='" . URLROOT . "/forums/unlocktopic&forumid=$data[forumid]&topicid=$topicid&page=$page' title='Unlock'><img src='" . URLROOT . "/assets/images/forum/topic_unlock.png' alt='UnLock Topic' /></a>\n");
          } else {
              print("<a href='" . URLROOT . "/forums/locktopic&forumid=$data[forumid]&topicid=$topicid&page=$page' title='Lock'><img src='" . URLROOT . "/assets/images/forum/topic_lock.png' alt='Lock Topic' /></a>\n");
          }
          print("<a href='" . URLROOT . "/forums/deletetopic&topicid=$topicid&sure=0' title='Delete'><img src='" . URLROOT . "/assets/images/forum/topic_delete.png' alt='Delete Topic' /></a>\n");
          if ($sticky) {
              print("<a href='" . URLROOT . "/forums/unsetsticky&forumid=$data[forumid]&topicid=$topicid&page=$page' title='UnStick'><img src='" . URLROOT . "/assets/images/forum/older_sticky_new.png' alt='Unstick Topic' /></a>\n");
          } else {
              print("<a href='" . URLROOT . "/forums/setsticky&forumid=$data[forumid]&topicid=$topicid&page=$page' title='Stick'><img src='" . URLROOT . "/assets/images/forum/folder_sticky.png' alt='Stick Topic' /></a>\n");
          }
          print("</div>");
      }
      print("</div>");
  }

  print("</div></div></div>");
  print ($data['pagerbottom']);
else:
  print("<p align='center'>No topics found</p>\n");
endif;


Its no different than AJAX, when working with structured data. i've done about 17 of these files, its gets way more complicated.. like polls.. that is a 3 day trip on that code!  :grin

array_push() is faster than array_merge().
Last edited by STorrents2020 on 2021-06-11 17:58:24
2021-06-12 09:07:23
Dear M-Jay,

Noticed you worked on the edit function of a forum topic.
Please also look at the quote option, both here and also in latest code does not appear to work for me.

Also, when I tried to delete the newly created topic, I was not able to.
"1 is the last post in topic" was the response - and then refreshed without deleting the actual topic.
If It Ain't Dutch, It Ain't Much!!
Last edited by Propaganda on 2021-06-12 09:54:13
2021-06-12 10:49:00
Propaganda:
Dear M-Jay,Noticed you worked on the edit function of a forum topic.Please also look at the quote option, both here and also in latest code does not appear to work for me.Also, when I tried to delete the newly created topic, I was not able to. "1 is the last post in topic" was the response - and then refreshed without deleting the actual topic.


all fixed on forum controller https://github.com/M-jay84/Torrent-Trader-MVC-PDO/blob/master/TorrentTraderMVC/app/controllers/Forums.php
Last edited by M-jay warn on 2021-06-12 10:52:42
2021-06-12 12:55:28
M-jay:
 
Propaganda:
Dear M-Jay,Noticed you worked on the edit function of a forum topic.Please also look at the quote option, both here and also in latest code does not appear to work for me.Also, when I tried to delete the newly created topic, I was not able to. "1 is the last post in topic" was the response - and then refreshed without deleting the actual topic.
all fixed on forum controller https://github.com/M-jay84/Torrent-Trader-MVC-PDO/blob/master/TorrentTraderMVC/app/controllers/Forums.php


Yeah...now the "quote" works ;-)

If It Ain't Dutch, It Ain't Much!!
2021-06-17 08:36:26


Ahhh...so the share link for BBcode forums is different ;-) lol

Beside a Seeding menu item, will there also be a Leeching menu item (in the user profile)
If It Ain't Dutch, It Ain't Much!!
Last edited by Propaganda on 2021-06-17 14:16:45
2021-06-17 13:33:21
For imgur upload you can use link above smilies and select get share links



Then bbcode forums




All torrents user is currently seeding
All torrents user has uploaded
Last edited by M-jay warn on 2021-06-17 13:34:16
2021-06-17 14:16:59
Leeching being the ones currently actively being download by that user.

Or will the "seeding" show both seeding and leeching torrents (meaning current activity).
If It Ain't Dutch, It Ain't Much!!
2021-06-17 17:44:14
not really paid much attention to the querys for them so before i check im up for another opinion

uploaded (maybe change to torrents) this is like upload history
Show all users uploaded torrents including any dead or old ones

seeding (maybe change to active)
Show all current active torrents - seeding & leeching ?

Or the two can be combined - as admin we can view all dead torrents and remove them if necessary in the admincp i dont see point keeping old torrents it depends what we want to show do we want a users upload history ? - bare in mind other users with permission will see these

Tracking everything can be done in admincp - so what do we want to show other members
2021-06-18 01:38:42
For the user profile it could be as follows:

Seeding: The torrents completed download, and still active in uploading/seeding
Leeching: The torrents in process of being downloaded by the user, not yet completed.

Both can be combined in one page (tracker activity), just that the leeched torrents once completed should move to the "seeding" table.

Uploaded: These should show all the torrents uploaded by that user to the tracker. Including dead or old ones.
If It Ain't Dutch, It Ain't Much!!
2021-06-18 02:14:01
All of this is very easy and I’ve already coded most of what’s requested here for profiles. All but “user’s uploads” which is a really quick query.

Have a look at the V4 section for profile post. Easy to port for V3/MVC.

If you guys need any SQL work let me know! Just show me the table structure and I can generate a structure scheme and get results without any database
2021-06-18 17:50:11


Editing the line in the shoutbox does not work at the moment.
It will force you to refresh the page. It overlays the screen with...
If It Ain't Dutch, It Ain't Much!!
Last edited by Propaganda on 2021-06-18 17:53:34
2021-06-18 18:09:40
The user menu >>

This is what it looks like in the Default theme at this moment >>



This is what it looks in my U2 themed at this moment using default code and making some small font adjustments.



And this is what it looks like on our current active site ;-)



For the new code below will be the new "user-bar" , for my theme





In the user-bar, from left to right:
Username, Downloaded, Uploaded, Ratio, Bonus Points, Donated, Slots, Downloading, Uploading, Connectable, Messages, Staff Panel, Logout



2021-07-02: cleaned up spacings
2021-07-19: cleaned up clickables and changed some colors.  Gonna use Icons from current site, maybe change their colors
2021-07-20: wanna include new messages as icon, new messages when admin (these should not be in navbar)
2021-07-24: Format most complete. Only wanna fine tune the icons and colors a bit for my theme.
2021-08-06: Instead of having text colored, I worked out to have the bootstrap icons colored. Looks better I think.

Ps: Looking for nice icons of the font-awesome 4.7 class, especially for the bonus/donate/ratio options
If It Ain't Dutch, It Ain't Much!!
Last edited by Propaganda on 2021-08-06 18:58:37
2021-07-05 04:21:28
I see loads about editing the style or so and so but bugs ?

On mobile darktheme hamburger menu icon no show, but works in default theme,

Suggestion

In theme folder / header.php and footer.php    where is left and right columns change that 180 or 170 with 15% that way will remain the same on any resolution

They look to strangled  on my desktop.

Again why can't all files and folders when you install be in public_html ?

For example my configuration is
/home/web/sitename/public_html
So I could install v4 should I put some folders in /site name and some in /public_html?

Thank you for your great work I love it!




Hope that , what I said will not offend anyone .
Users online

No 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: 9

  • Online

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