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

None of this is correct. Let me in on this in an hour when I am at the keyboard.  :thumb
Ajax Shoutbox V3 — 2021-06-11 18:10:02 in v3 Mods in Progress
it’s strange I won’t deny that, reason. Most development goes like this:

<span class=“shoutbox <?=(class_user[$var] == 1) : ‘staff’ ? ‘member’?>”>class_user[$var]</span>

So your letting the class_user() function decide the style class. From there it should be in CSS file.

Otherwise, it’s 2 JOINs between groups and users table providing that hexadecimal colour value.
What you need to do, is check if that info hash already exists, and decide to proceed or decline with message to user about duplicated content.

We get this issue too, users reupload a torrent from myself, no checks in place so it just accepts it (no one connects).

I built a web seed generator, but that part can be removed. It mass imports files and torrents. Maybe this might be better. It’s a lot faster for me. But it’s written in PDO so it will need to rely on that. It’s very aware of what is in the /webseeds upload dir, the file names, this and that. Very useful, while you update TT.
U[dated Seed bonus to better iterate recent claimed users per row, rewrote a few queries to be more efficient and check more conditions, minor fixes here and there.


<?
if (session_status() == PHP_SESSION_NONE) { session_start(); }
require_once '../site.php';
$db->connect();
site_header();

// Seed Bonus - Reworked - Sep 19, 2020
// Updated/optimized + social/UI additions - Mar 21, 2021

if (!$account->sessionLogin()) {
header(sprintf('Location: %s/siginin/', $CONFIG['base_url']));
   die;
}

$errors = array();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
   
   $data = array();
   $keys = array('id', 'userid', 'torrentid');
   foreach ($keys as $key) {
       if (!array_key_exists($key, $_POST)) {
           $errors []= sprintf('Seed bonus item ID %s not valid.', $key);        
       }
       $data[$key] = $_POST[$key];
   }
   
   $res = $db->query_params('SELECT users.seedbonus, users.perk_avatar, users.username, users.slots, users.last_exchange, users.class, users.user_id, bonus.cost, bonus.descr, bonus.type, bonus.value, bonus.id FROM users, bonus WHERE users.user_id = :user_id AND bonus.id = :post_id', array('user_id' => $account->getId(), 'post_id' => $data['id'])) or die('db error');
   
if (!($row = $res->fetch())) {
if ($row['seedbonus'] < $row['cost'])
$errors []= 'Demand not valid.';
   }
   
   if (array_key_exists('id', $data) && $data['id'] == $row['id']) {
   
   if ($row['type'] == 'invite') {
        $query = $db->query_params("UPDATE users SET invites = invites + :value WHERE user_id = :user_id", array('value' => $row['value'], 'user_id' => $account->getid()));
printf('Your account has been <b>credited</b> for <b>%s</b> Extra Invites!', $row['value']);
}

if ($row['type'] == 'traffic') {
        $query = $db->query_params('UPDATE users SET uploaded = uploaded + :value, last_exchange = :bonus WHERE user_id = :user_id', array('bonus' => $row['value'], 'value' => $row['value'], 'user_id' => $account->getid()));
printf('Your account has been <b>credited</b> for <b>%s</b> bonus Upload Data!', format_size($row['value']));
}

if ($row['type'] == 'slots' && $data['id'] == $row['id']) {
        $query = $db->query_params('UPDATE users SET slots = :slots WHERE user_id = :user_id', array('slots' => $data_row['value'], 'user_id' => $account->getid()));
printf('Your account has been <b>credited</b> for <b>%s</b> Extra Download Slots!', $row['value']);
}
   
if ($row['type'] == 'feature' && $data['id'] == $row['id']) {
        $query = $db->query_params("UPDATE users SET perk_avatar = 'yes' WHERE user_id = :user_id", array('user_id' => $account->getid()));
printf('<span>Your site comments will be <b>featured</b> with a %s', '<img src="/themes/default/images/super_star.png" style="height: 50px; padding: 0;margin-bottom: -10px;position: relative;transform: rotate(-15deg);margin-left: -3px;margin-right: -30px;" /></span>');
}

if ($row['type'] == 'restore') {
        $query = $db->query_params("UPDATE users SET limited = 'no' WHERE user_id = :user_id", array('user_id' => $account->getid()));
$db->query_params("DELETE FROM warnings WHERE userid = :user_id", array('user_id' => $account->getid()));
printf('<span>Your account has been <b>restored</b>, and all warnings removed.</span>');
}

if ($query) {
    $db->query_params("UPDATE users SET seedbonus = seedbonus - :cost WHERE user_id = :user_id", array('cost' => $row['cost'], 'user_id' => $account->getid()));
$db->query_params("INSERT INTO bonus_users (user_id, added, type) VALUES (:user_id, NOW(), :type)", array('user_id' => $account->getId(), 'type' => $row['type']));
    }
   }
}

// Get exchange item list    
$res = $db->query_params('SELECT * FROM bonus ORDER BY type');
$bonusid = $res->fetch();
$rowid = $bonusid['id'];


// Get users seed bonus points - Sep 2, 2020
$points = $db->query_params('SELECT seedbonus, user_id FROM users WHERE user_id = :user_id', array('user_id' => $account->getId()));
$userpoints = $points->fetch();
?>
 
<h1 itemprop="name">
<i class="material-icons" style="color:#7FB335;font-size:45px;vertical-align:bottom;padding-right:10px">eco</i> Seed Bonus
<?=(!empty($userpoints['seedbonus']))
? "<span style=\"font-size:27px;font-weight:400;padding:5px;border-radius:7px;background:#ED2324;text-align:center;color:#FFF;box-shadow: inset 1px 5px 7px -6px #000000;float:right\">" . $userpoints['seedbonus'] . "</span>"
: "<span style=\"font-size:27px;font-weight:400;padding:5px;border-radius:7px;background:#ED2324;text-align:center;color:#FFF;box-shadow: inset 1px 5px 7px -6px #000000;margin-right:15px\">0</span>";
?>
</h1>

<div itemprop="description">Explore options that you can redeem from accumulated <b>points</b> against depending on the share of torrents.</div>  

<center>
<div class="card-action ng-scope">
<!-- Rundown -->
<?
$retrieve = $db->query_params("SELECT (SELECT COUNT(torrent_id) FROM peers WHERE user_id = p.user_id AND seeder = 'yes') AS total, GROUP_CONCAT(p.torrent_id) AS torrent_id FROM peers p WHERE p.user_id = :user_id GROUP BY p.torrent_id DESC LIMIT 12", array('user_id' => $account->getId()));
$seeding = $retrieve->fetchAll();
?>
<div itemprop="description">You are seeding:</div>
<div style="padding:10px 0 10px 0">
<?
// Currently seeding torrents - Mar 21, 2021
if ($seeding) {
foreach ($seeding as $row) {
$query           = $db->query_params("SELECT name, cover1, torrent_id FROM torrents WHERE torrent_id IN ($row[torrent_id])");
$data['avatars'] = $query->fetchAll();
foreach ($data['avatars'] as $title) {
print("<a id=\"tips\" title=\"$title[name]\" href=\"/details/$title[torrent_id]/\"><img itemprop=\"image\" class=\"responsive-img\" src=\"/images/covers/$title[cover1]\" alt=\"$title[name]\" style=\"width: 107px; height: 176px; margin-left: 10px\" border=\"0\" /></a>");
}
}
}else{
print("<div style=\"margin-bottom:4px;padding:5px;background:#D2D2D2;text-align:center;color:#242424;font-size:20px;max-width:300px;border-radius:7px\">No (0 found)</div>");
}
?>
<div style="padding-top:7px">You receive <b><?=$CONFIG['bonuspertime']?></b> points per <b>every 10 minutes</b> the system registers you as a seeder by torrent.</div></div>
</center>

<? while ($row = $res->fetch()): ?>

<article itemprop="itemListElement" itemscope="" itemtype="http://schema.org/Article" class="card">

<form method="post" class="cd-form floating-labels" action="/mybonus.php">
<input type="hidden" name="id" value="<?=intval($row['id'])?>" />
<div class="card-action ng-scope" style="font-size:22px">
<!-- Seeder exchange -->
<span style="font-size:27px;font-weight:400;padding: 7px 5px 5px 10px;border-radius:7px;background:#EC2324;text-align:center;color:#FFF;box-shadow: inset 1px 5px 7px -6px #000000;margin-right:15px">
<?=str_replace('Uploaded', '', html_escape($row['title']))?>
</span>
<?=$row['descr']?>
<span style="float:right;margin-right:-125px">
<button class="btn btn-danger" onclick="this.form.submit();" style="font-size:15px" <?=($userpoints['seedbonus'] < $row['cost'] ? 'disabled' : null)?>>
<?=($userpoints['seedbonus'] < $row['cost']) ? 'Not Enough' : 'Exchange'?>
</button>
</span>
  </div>
  <div class="card-action ng-scope" style="font-size:18px;width:700px">
  <?
  // Get item's recent users - Mar 21, 2021 - Query rewritten to support accurate claims per row/type, June 10, 2021
  $claimed = $db->query_params("SELECT b.title, b.type, bu.user_id, u.username, u.avatar, bu.added FROM bonus_users bu LEFT JOIN users u ON u.user_id = bu.user_id LEFT JOIN bonus b ON b.type = b.type WHERE b.id = :bonus_id AND b.value = u.last_exchange ORDER BY bu.added DESC LIMIT 11", array(
  'bonus_id' => $row['id']
  ));
  foreach ($claimed as $bonususer) {
  if (!file_exists($bonususer['avatar'])) {
  $avatar = 'images/noavatar.png';
  }else{
  $avatar = $bonususer['avatar'];
  }
  printf('<div style="float:left;font-size:22px;font-weight:400;padding:5px 5px 5px 7px;border-radius:7px;background:#D2D2D2;text-align:center;color:#FFF;_box-shadow: inset 1px 5px 7px -6px #000000;margin-right:7px;margin-bottom:15px;margin-top:0px"><a href="/user/?id=%s"><img src="/%s" style="height:29px;width:29px;vertical-align:middle;border-radius:7px" /></a>%s</div>', $bonususer['user_id'], $avatar, str_replace('Uploaded', '', $bonususer['title']));
}
?>
</div>
</form>
</article>

<? endwhile; ?>

<article itemprop="itemListElement" itemscope="" itemtype="http://schema.org/Article" class="card">

<div class="card-action ng-scope">
<!-- Rundown -->
<span>
To get bonus points you need to have the complete torrent which includes all txt/nfo documents, samples, and subtitles. Keep the torrent open in your torrent client and your bonus points will start to increase.
<br><br>
It means, when you download a torrent 100% (completely), share back and every hour you will earn bonus points, (up to a maximum of 15 torrents) you keep sharing back. Just download the torrent 100% and don't close your torrent client, keep sharing with others. Even if no one downloads from you, you will still get bonus points for them.
<br><br>Once you accumulate loads of points you can use them on any of the options listed above. You get points even if there are no leechers on the torrent and you can seed as many torrents as you want. Yet another way to help out your ratio!
<br><br>
Keep Seeding! Plus Enjoy Being with us!
</span>
</div>
 
</article>

<div>You receive <?=$CONFIG['bonuspertime']?> points per <?=floor($CONFIG['autoclean_interval'] / 10)?> minutes the system registers you as a seeder by torrent.</div>

<?
$db->query_params("UPDATE users SET page = 'Seed Bonus', last_access = NOW() WHERE user_id = :user_id", array('user_id' => $account->getId()));
site_footer();


in BETA. Some useful code here for creative minds.

Learning shorter code, better counting methods, sub-queries to make things easier. Markup hand-written, no fancy frameworks just PHP and HTML.

<?
if (session_status() == PHP_SESSION_NONE) { session_start(); }
require_once '../site.php';
$db->connect();
site_header();

// Account Profiles - New - June 7, 2021
if (isset($_GET['id'])) {

// Get user data
$profile_data = $db->query_params('SELECT * FROM users WHERE user_id = :user_id', array(
'user_id' => isset($_GET['id']) ? intval($_GET['id']) : 0
));
// Check & insert/update views
$checkrow = $db->query_params('SELECT userid FROM profileviews WHERE userid = :user_id', array(
'user_id' => isset($_GET['id']) ? intval($_GET['id']) : 0
));
/*
$db->query_params('INSERT INTO profileviews (userid, userviewed, viewed, times) VALUES (:user_id_cur, :user_id, NOW(), 1)', array(
'user_id_cur' => $account->getId(),
'user_id' => intval($_GET['id'])
));
*/
if (!$profile_data) {
echo 'Invalid User ID';
}

} else {
echo 'Invalid request';
}
if ($profile_data) {
foreach ($profile_data as $row):
// User country flag
$country_flag = $db->query_params('SELECT name, flagpic FROM countries WHERE id = :country', array(
'country' => intval($row['country'])
));
// User level
$groups = $db->query_params('SELECT g.level FROM users u LEFT JOIN groups g ON g.group_id = u.class WHERE u.user_id = :user_id', array(
'user_id' => intval($row['user_id'])
));
$ulevel = '';
if ($level = $groups->fetch()) {
$ulevel = strval($level['level']);
}
// Get user views
$profile_views = $db->query_params('SELECT p.userid, p.userviewed, p.times, u.user_id, u.avatar_thumb AS avatar FROM users u LEFT JOIN profileviews p ON p.userviewed = u.user_id WHERE p.userid = :user_id ORDER BY p.viewed DESC', array(
'user_id' => intval($row['user_id'])
));
// Get friends
$friends = $db->query_params('SELECT (SELECT COUNT(*) FROM friends WHERE userid = f.userid) AS total, u.user_id, u.avatar_thumb AS avatar, f.userid FROM friends f LEFT JOIN users u ON u.user_id = f.friendid WHERE f.userid = :user_id', array(
'user_id' => isset($_GET['id']) ? intval($_GET['id']) : 0
));
// Get users recent downloads
$recentdl = $db->query_params("SELECT (SELECT COUNT(torrentid) FROM users_downloaded WHERE userid = u.user_id) AS total, ud.userid, u.avatar_thumb AS avatar, t.torrent_id, t.cover1, t.name FROM users u LEFT JOIN users_downloaded ud ON ud.userid = u.user_id LEFT JOIN torrents t ON t.torrent_id = ud.torrentid WHERE ud.userid = :user_id AND torrent_id != 'NULL'", array(
'user_id' => $row['user_id']
));
// Get user ratio
$ratio = 0;
if ($row['downloaded'] > 0) {
    $ratio = number_format($row['uploaded'] / $row['downloaded'], 2);
}
// Check blocked
if ($account->sessionLogin()) {
$blocked = $db->query_params('SELECT id FROM blocked WHERE userid = :user_id AND blockid = :user_id_cur', array(
'user_id' => $row['user_id'],
'user_id_cur' => $account->getId()
));
if ($blocked->fetchAll()) {
    echo 'You are blocked by this user.';
    }
   }
   // Get moods
$res = $db->query_params('SELECT name, moodspic FROM moods WHERE id = :user_mood LIMIT 1', array(
'user_mood' => $row['moods']
));
if ($arr = $res->fetch()) {
$moods = '';
}
?>

<!-- Profile buttons -->
<div style="display:inline;float:left;padding-top:17px">

<?
if ($account->sessionlogin()): ?>
<button type='button' class='btn btn-danger' onclick="location.href='/message/?compose&id=<?=intval($row['user_id'])?>'">Message</button>
<? endif;
if ($account->getId() !== $row['user_id']) {
   $f = $db->query_params('SELECT id, userid FROM friends WHERE userid = :user_id_cur AND friendid = :friend_id', array(
    'user_id_cur' => $account->getId(),
    'friend_id' => $row['user_id']
   ));
   $b = $db->query_params('SELECT id, userid FROM blocked WHERE userid = :user_id_cur AND blockid = :block_id', array(
    'user_id_cur' => $account->getId(),
    'block_id' => $row['user_id']
   ));

if ($friend = $f->fetch()) {
       echo "<button type=\"button\" style=\"margin-right:5px\" class='btn btn-danger' onclick=\"location.href='/friends.php?action=delete&type=friend&targetid=$friend[userid]'\">Unfriend</button>";
   }
   if ($block = $b->fetch()) {
       echo "<button type=\"button\" class='btn btn-danger' onclick=\"location.href='/friends.php?action=delete&type=block&targetid=$block[userid]'\">Unblock</button>";
   } else {
   echo "<button type=\"button\" style=\"margin-right:5px\" class=\"btn btn-danger\" onclick=\"location.href='/friends.php?action=add&type=friend&targetid=$row[user_id]'\">+ Friend</button>";
   echo "<button type=\"button\" class=\"btn btn-danger\" onclick=\"location.href='/friends.php?action=add&type=block&targetid=$row[user_id]'\">Block</button>";
   }
}
?>

<!-- Left side content -->
<div style="display:inline;float:left">
<h1 itemprop="name">
     @<?=html_escape($row['username'])?>      
   </h1>
<div>
<!-- Left column -->
<article itemprop="itemListElement" itemscope="" itemtype="http://schema.org/Article" class="card" style="max-width:300px">
<div class="card-action ng-scope" ng-if="item.comment_count">
<!-- Profile picture --><span itemprop="interactionCount" class="comments">
           <span style="text-align:center;padding-bottom:23px">
              <center><img class="responsive-img" src="/<?=$row['avatar_thumb']?>" style="border-radius:100%;width:150px;height:150px;border:5px solid #ECECEC" /></center>
           </span></span>
<!-- Profile views -->
<div style="text-align:center;padding-top:15px;padding-bottom:20px;border-bottom:1px solid #ECECEC">
<div style="color:#D2D2D2;padding-bottom:7px">Profile Views:</div>
<?
$n = 0;
foreach ($profile_views as $vuser) {
$n++;
        echo (!empty($vuser['avatar']) && file_exists($vuser['avatar']))
        ? printf('<a href="/user/?id=%s"><img src="/%s" style="width:23px;height:23px;border-radius:100px" /></a>', $vuser['user_id'], $vuser['avatar'])
: printf('<a href="/user/?id=%s"><img src="/images/noavatar.png" style="width:23px;height:23px;border-radius:100px" /></a>', $vuser['user_id'], $vuser['avatar']);        
        $total = count($row);
           if ($n === 24) break;
        }
        ?>
        </div>
        <div style="color:#242424;float:right;font-size:15px;padding-top:12px"><b><?=intval($n)?></b> out of <b><?=(isset($total) ? $total : 0)?></b> total visitors</div>
        <div style="clear:both"></div>
        <!-- User info -->
        <div style="text-align:center;padding-top:15px;padding-bottom:20px;border-bottom:1px solid #ECECEC">
        <div style="font-size:22px"><?=html_escape($row['username'])?>, <?=html_escape($row['gender'])?>
        <?
       if ($flag = $country_flag->fetch()) {
printf('<img title="%s" src="/images/countries/%s" style="width:20px;height:20px;vertical-align:middle" />', $flag['name'], $flag['flagpic']);
}
?>
</div>
        <div style="color:#C0C0C0">Joined <?=time_ago($row['added'])?></div>
        <div style="color:#C0C0C0">Last online: <?=time_ago($row['last_access'])?></div>
        <div style="color:#242424;padding-top:7px">Total Ratio: <b><?=$ratio?></b></div>
        <div style="background:#D2D2D2;padding:4px;text-align:center;color:#242424;border-radius:7px;margin-top:13px">Account: <?=$ulevel?></div>
        </div>
</div>
</article>
</div>
</div>

<!-- Friends list -->
<div style="display:inline;float:left;padding-left:20px;padding-top:70px">
<h1 itemprop="name">
     Friends (<?=($total = $friends->fetch()) ? $total['total'] : 0 ?>)
   </h1>
<article itemprop="itemListElement" itemscope="" itemtype="http://schema.org/Article" class="_card" style="max-width:300px">
<div class="card-action ng-scope" ng-if="item.comment_count">
<!-- Friends -->
<div style="padding-top:15px;padding-bottom:20px;border-bottom:1px solid #ECECEC">
<?
$position = 'left';
$count = 0;
foreach ($friends as $fuser) {
$count++;
        echo (!empty($fuser['avatar']) && file_exists($fuser['avatar']))
        ? printf('<a href="/user/?id=%s"><img src="/%s" style="border:2px solid #E3E3E3;margin:2px;width:45px;height:45px;border-radius:100px;float:%s" /></a>', $fuser['user_id'], $fuser['avatar'], $position, $fuser['user_id'])
: printf('<a href="/user/?id=%s"><img src="/images/noavatar.png" style="border:2px solid #E3E3E3;margin:2px;width:45px;height:45px;border-radius:100px;float:%s" /></a>', $fuser['user_id'], $position, $fuser['user_id']);
        if ($count === 40) break;
        }
        if ($count === 0) printf('No recent friends.');
        ?>  
        </div>
</div>
</article>
<!-- BEGIN recents -->
<div style="display:inline;float:left;_padding-top:70px">
<h1 itemprop="name">
     Recent's (<?=($title = $recentdl->fetch()) ? intval($title['total']) - 1 : 0 ?>)
   </h1>
<article itemprop="itemListElement" itemscope="" itemtype="http://schema.org/Article" class="_card" style="max-width:450px">
<div class="card-action ng-scope" ng-if="item.comment_count">
<!-- Titles -->
<div style="padding-top:15px;padding-bottom:20px;border-bottom:1px solid #ECECEC">
<?
// Get item's recent downloads - June 10, 2021
$n=0;
foreach ($recentdl as $item) {
  $n++;
  printf('<a href="/details/%s/" title="%s"><img src="/%s" style="width:80px;height:120px;margin-right:10px" /></a>', $item['torrent_id'], html_escape($item['name']), file_exists('images/covers/'.$item['cover1']) ? 'images/covers/'.$item['cover1'] : 'images/switch_cover_none.png');
  if ($n === 10) break;
  $total = $item['total'];
}
if ($total > 0) {
printf('<span style="float:right;padding-right:10px"><a href="#">Browse all</a> - Showing %s of <b>%s</b></span>', $n, $total - 1);
} else {
printf('<span style="float:right;padding-right:10px">No recent titles.');
}
        ?>
        </div>
</div>
</article>
</div>
<!-- END recents -->
</div>
<div style="clear:both"></div>
<!-- Profile bio -->
<div>
<h1 itemprop="name">
     about me
   </h1>
<article itemprop="itemListElement" itemscope="" itemtype="http://schema.org/Article" class="card">
<div class="card-action ng-scope" ng-if="item.comment_count">
<p><?=(!empty($row['profile_bio'])) ? html_escape($row['profile_bio']) : 'No info has been added yet :(';?></p>        
</div>
</article>
</div>
<!-- Uploads -->
<div>
<h1 itemprop="name">
     uploads
   </h1>
<article itemprop="itemListElement" itemscope="" itemtype="http://schema.org/Article">
<div class="card-action ng-scope" ng-if="item.comment_count">
<p>Coming soon.</p>        
</div>
</article>
</div>

<?
endforeach;
}
if ($account->sessionLogin()){
$db->query_params("UPDATE users SET page = 'Browsing User Profile', last_access = NOW() WHERE user_id = :user_id", array('user_id' => $account->getId()));
}
site_footer();
exclude some parts — 2021-06-11 02:36:46 in General Chat
This will do what you need. It will filter those tags and return the rest of the description.

echo preg_replace('/\[img\](.+?)\[\/img\]/', '', $row['descr']);
Bug Tracker — 2021-06-10 21:33:31 in M-BiTsy Support
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().
Bug Tracker — 2021-06-10 18:37:40 in M-BiTsy Support
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).
Auto-Promote Users — 2021-06-10 05:40:13 in v3 Mods Completed
Was this ever resolved? I’ve had it worked for almost a year now
update sql — 2021-06-10 00:38:14 in v3 Support
Provide a WHERE clause, otherwise it expects every single row.
Bug Tracker — 2021-06-09 22:14:02 in M-BiTsy Support
I'll give you a solution for the LAZY params, you dont need to declare that every time.. let PHP decide. I'll share that shortly.

Now, for the iteration block. Im reviewing now.

Can you provide me the output of
print_r($data['topicsres'])


And to clarify, you want to push each query result set into the primary array that is pushed to a variable and called from the first block of code correct?

If so, we expect to adopt this code:


<?
$myarray1 = [];
foreach ($data['topicsres'] as $topicarr) {
   $data['topicid']      = $topicarr["id"];
   $data['topic_userid'] = $topicarr["userid"];
   $data['locked']       = $topicarr["locked"] == "yes";
   array_push($myarray1, $data);
}

print_r($myarray1);


Again, we need to get that print_r output.
Bug Tracker — 2021-06-09 22:05:52 in M-BiTsy Support
I've become really good with arrays, carrying skills I've learned from official hired freelancers. I can help here. Let me review the code and see if I can recommend a better way.
Your domain is very slow. I almost closed my tab, you don't want users on the brink of that decision in tenfold. Revenue goes way down.

Your next step is: installing mysqltuner

Making recommended changes to my.cnf, restart mysql processes.

You can add microtime() at the beginning of your header.php <?php microtime(); and before the very last ?> in footer.php and output the timing. Get this number as low as possible, with respect to the initial "slow" value.
Ahh fellow Canadian, Vancouver here ;)

174% CPU for MySQL process is INSANE. I wonder if this is TorrentTrader, but then again I ran V3 on a old IBM tower desktop for a year, it became overloaded (crappy Pentium 4 HT), got a Xeon 1U server chassis and went all out on Supermicro's gear.. I have never had that problem since.

Your invested in PHP5, most people are as its a larger situation in updating the code, even if you update the code.. the code is still very logically slow, and uses old routines that are slow to todays standards. But past that, yes you can follow forward with MySQL(i) and a few updates to a function or 2 in /backend/functions.php

I'm on PHP 8.0.2, expecting to update to 8.0.7 - I run the V3 stock scripts (updated for PDO manually), and they work perfectly fine. I find, many of these scripts (2009-2012-times) utilize excessive print or echo functions, rather than binding parameter-based calls in just 1 function (like printf/sprintf). Echo has overhead, because there are a lot of additional checks taking place (every single time). So calling echo 11 times in a single script, will slow things down considerably. This is easy to resolve, using printf().

---

Okay, so the rest of your database is optimal performance, but torrents table is taking 10-15 seconds to read 24 rows?? So your "table seek time" is extremely effected. Have you ran mysqltuner? Im afraid, it may know more about this situation than I do (I don't run TT, just portions. Long story).
Bug Tracker — 2021-06-09 20:14:56 in M-BiTsy Support
Sounds like template inheritance by using traits. Very different from my system, themes are the only "TT old world" feature still at the core for some reason, I didn't let everything go.. lol
:unsure
Files in description! — 2021-06-09 00:05:18 in General Chat
implode() is the way.
Additionally, in the reverse situation in SQL to delimitate results you do this

GROUP_CONCAT(ids)

and to read them off (in another query) is IN(, , ,)

Example:

$var1 = SELECT GROUP_CONCAT(user.id) FROM users

$myarray1 = [];
foreach ($var1 as $row) {
  $var2 = SELECT username, id, avatar FROM users WHERE id IN($row[id])
  // Now you get results for each user ID easily. No JOINs, no extra code.
  // How to push the data out and work with it? array_push(), but there are many ways.
  // Array push allows you push all of your looped results outside of the loop, so you can
  // access it later.
  $data['id']  =  $row['id'];
  array_push($myarray1, $data);
}

There is more, like appending a query and fetch as a data item, and pushing that array out in itself, and merging results, you can push $var2 into a array (or JSON) and work with both result sets side by side, merge, modify, filter..

Is database column empty??
if (empty($row['xyz']))

$var = !empty($row['xyz']) ? $row['xyz'] : 'Column looks empty!'


So you know what implode does. Explode does the opposite, and is usually called from outside of foreach() as it allows to iterate each comma separated result.

If you just want to call on a specific index from the array, use like this explode()[3]
where "5" is the 5th result you want to capture (excluding the rest).  - (1, 2, 3, 4, 5)

I'll try to answer where I can. It helps to understand arrays, the typical functions for most cases and knowing the little tips and "one-liner" solutions.
Thank you, lastly we need to know which processes are spiking and for how long. Do you have SSH access? If so, run:  
# top -P

That will show top processes, and give insight into what is slowing down based on metrics.  Reply with the 3-4 top relevant processes with high CPU (%) and post those here (names).

Additionally, if you are not using php-fpm.. I highly recommend it! Your site will be blazing fast after that update alone.
Bug Tracker — 2021-06-08 23:28:41 in M-BiTsy Support
I solved this long ago. The login page in this MVC release, contains BCRYPT password hashing, but does not include the next step: Rehashing.

If this is a hot topic, I'll add solution code to login script from the GIT. I added support for this in our account class last year. Thousands of passwords have been rehashed, we forgot its even happening.

Ours looks like this ($row is your user table)


if (is_array($row)) {
           
           if (password_verify($passwd, $row['password'])) {
       
           /* Check if password needs rehashing, if so then continue  */
           if (password_needs_rehash(sha1($row['password']), PASSWORD_DEFAULT)) {
               
               /* Rehash existing password algorithm to BCRYPT and update */
               $newhash = password_hash($passwd, PASSWORD_BCRYPT);
               
try {
$stmt    = $pdo->prepare("UPDATE users SET password = ?, last_access = NOW(), last_login = NOW() WHERE user_id = ?");
$stmt->execute([$newhash, $row['user_id']]);
}
catch (PDOException $e) {

/* If there is a PDO exception, throw a STAccountsException exception. */
$STe = new STAccountsException($e);
$STe->setVarData(['query' => 'UPDATE users SET password = ?, last_access = NOW(), last_login = NOW() WHERE user_id = ?', 'values' => [$newhash, $row['user_id']]]);
throw $STe;
}
           }
           
}
You should look into installing and running as root “mysqltuner”. It will show you what you need to know, and what to change in config under “Recommended” to achieve optimal performance based on your hardware (it probes CPU/RAM) for advisories.
What database server are you using?

Example, MariaDB 10.5

If not then we assume MyISAM if not using PostgreSQL.
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: 3
  • Members: 1
  • Guests online: 2
  • Comments: 3
  • Messages: 1,728