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

I converted this today to PDO and tested, and worked great while taking away the msqli code. I really can't remember if I ever shared this to the site of my own work but in case not, ignore bits go to code block 2.
You will need JQuery 2.1.1 +

And replace with (or create this as useronline.php):

require_once 'dbConfig.php';

$query = "SELECT * FROM users ORDER BY last_access DESC LIMIT 8";
$result = $db->query($query);

// Generate users data array
$userData = array();
if($result->num_rows > 0){
   while($row = $result->fetch_assoc()){
     
       $data['id']     = $row['id'];
       $data['value']  = $row['username'];
       $data['avatar'] = $row['avatar'];
           
       array_push($userData, $data);
   }
}

// Return results as json encoded array
echo json_encode($userData);


Now create dbConfig.php with:

<?
// Access security check
if (preg_match('/dbConfig.php/i',$_SERVER['PHP_SELF'])) {
   die;
}

// Database configuration
$dbHost     = "localhost";
$dbUsername = "user";
$dbPassword = "password";
$dbName     = "db";

// Create database connection
$db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);

// Check connection
if ($db->connect_error) {
   die("Connection failed: " . $db->connect_error);
}
?>



And place this in your [color=rgb(226, 80, 65)]header.php[/color] / [color=rgb(226, 80, 65)]footer.php[/color] file

<script>
function fetchOnlineUsers() {
   $(document).ready(function () {
       $.ajax({
           url: "usersonline.php",
           method: "GET",
           dataType: 'JSON',
           success: function (data) {
               var html_to_append = '';
               $.each(data, function (i, item) {
                   html_to_append +=
                       '<a title="' + item.value + '" href="/user/?id=' + item.id + '"><img style="width:45px;height:45px;border-radius:50%;margin-right:10px;" src="[color=rgb(226, 80, 65)]https://www.YOUR_URL.com/'[/color] + item.avatar + '" /></a>';
               });
               $("#online").html(html_to_append);
           }
       });
   });
}

fetchOnlineUsers(); // This will run on page load

setInterval(function(){
   fetchOnlineUsers() // this will run after every 15 seconds
}, 15000);
</script>


And put this somewhere you like in your theme:

  <!-- AJAX Users Online - 15sec interval -->
 <div id="online" style="height:45px;width:470px;padding-bottom:10px"></div>


** First code section is if i've already posted it, I've updated this away since to be secure.
Peer User ID - Bug — 2020-03-17 00:03:22 in v3 Support
Your query (corrected above) is working like a charm, I commented vars in the loop and directed the rest to $query outside the loop, nice! thnx - this is a optimization though no?
Peer User ID - Bug — 2020-03-16 23:59:46 in v3 Support
SELECT peers.*, users.* FROM peers LEFT JOIN users ON (peers.userid = users.id) WHERE peers.torrent = $id ORDER BY peers.seeder DESC
Peer User ID - Bug — 2020-03-16 23:59:03 in v3 Support
SELECT peers.*, users.* FROM peers LEFT JOIN users ON (peers.userid = users.id) WHERE peers.torrent = $id ORDER BY peers.seeder DESC
Peer User ID - Bug — 2020-03-16 02:00:56 in v3 Support
We have this bit of code on our torrents-details.php that works great, it resolves peer data very well, but usernames/avatars are completely incorrect. I can't figure this out, but this is our code:


<?
// Updated Stats & table with avatar and cleaner design - Feb 28, 2020
if ($row["external"] != 'yes') {
   echo "<br /><span style='margin-left:-10px'><b>" . T_("PEERS_LIST") . "</b> <small><span style='color:#ED2324'>beta</span></small></b></span><br />";
   $query  = SQL_Query_exec("SELECT * FROM peers WHERE torrent = $id ORDER BY seeder DESC");
   $result = mysql_num_rows($query);
   if ($result == 0) {
       echo "<span style='font-weight:normal;margin-left:-10px'>No active peers on the network</span><br />";
   } elseif ($row["external"] = 'yes' && $CURUSER) {
?>
       <!-- Stats Table Styling -->
       <style>.table_col1, .table_tr { border-top:1px solid #fff; background:#F5F5F5; font-weight: normal; text-align:center; margin-left:-20px } .table_head { font-weight: normal; text-align:left; padding-left:10px }</style>
       <div style="margin-left:-20px;width:100%">
           <table border="0" cellpadding="0" cellspacing="0" width="100%" class="table_table">
           <tr>
               <th class="table_head"><? echo T_("PORT"); ?></th>
               <th class="table_head">UL</th>
               <th class="table_head">DL</th>
               <!--<th class="table_head"><? echo T_("RATIO"); ?></th>-->
               <th class="table_head"><? echo T_("_LEFT_"); ?></th>
               <th class="table_head"><? echo "%"; ?></th>
               <th class="table_head"><? echo T_("SEED"); ?></th>
               <th class="table_head"><? echo T_("CONNECTED_SHORT"); ?></th>
               <th class="table_head"><? echo T_("CLIENT"); ?></th>
               <th class="table_head"><? echo T_("USER_SHORT"); ?></th>
           </tr>

<?
       while ($row1 = mysql_fetch_assoc($query)) {
           if ($row1["downloaded"] > 0) {
               $ratio = $row1["uploaded"] / $row1["downloaded"];
               $ratio = number_format($ratio, 3);
           } else {
               $ratio = "---";
           }
           $percentcomp = sprintf("%.2f", 100 * (1 - ($row1["to_go"] / $row["size"])));
           //if ($site_config["MEMBERSONLY"]) {
             //$res             = SQL_Query_exec("SELECT users.id, users.username, users.avatar, users.privacy FROM users LEFT JOIN peers ON peers.userid = users.id WHERE users.id=" . $row1["userid"]); // Testing, seems to work as-is?
               $res             = SQL_Query_exec("SELECT id, username, avatar, privacy FROM users WHERE id=" . $row1["userid"]);
               $arr             = mysql_fetch_array($res);
               //$arr["username"] = "<a href='/user/?id=$arr[id]'>" . class_user($arr[username]) . "</a>";
               $arr["username"] = "<a href='$site_config[SITEURL]/user/?id=$arr[id]'><img src='$site_config[SITEURL]/$arr[avatar]' style='border-radius:50%;height:45px;width:45px'></a>";
           //}
           if (!$arr["username"])
               //$arr["username"] = "Unknown User";
               $arr["username"] = "<img src='" . $site_config['SITEURL'] . "/images/noavatar.png' style='border-radius:50%;height:45px;width:45px' />";
           if ($arr["privacy"] != "strong" || ($CURUSER["control_panel"] == "yes")) { // If Admin, show the extended details, or else show basic details to everyone else
               print("<tr class='table_tr'><td class='table_col2'>66" . $row1["port"] . "</td><td class='table_col1' style='width:300px'>" . mksize($row1["uploaded"]) . "</td><td class='table_col2' style='width:300px'>" . mksize($row1["downloaded"]) . "</td><td class='table_col1' style='display:none'>" . $ratio . "</td><td class='table_col2' style='width:300px'>" . mksize($row1["to_go"]) . "</td><td class='table_col1'>" . $percentcomp . "%</td><td class='table_col2'>$row1[seeder]</td><td class='table_col1' style='text-transform:capitalize;font-weight:bold'>$row1[connectable]</td><td class='table_col2' style='padding-left:15px;padding-right:15px'>" . htmlspecialchars($row1["client"]) . "</td><td class='table_col1' width='90' align='right'>$arr[username]</td></tr>");
           } else {
               print("<tr><td class='table_col2'>" . $row1["port"] . "</td><td class='table_col1'>" . mksize($row1["uploaded"]) . "</td><td class='table_col2'>" . mksize($row1["downloaded"]) . "</td><td class='table_col1'>" . $ratio . "</td><td class='table_col2'>" . mksize($row1["to_go"]) . "</td><td class='table_col1'>" . $percentcomp . "%</td><td class='table_col2'>$row1[seeder]</td><td class='table_col1'>$row1[connectable]</td><td class='table_col2'>" . htmlspecialchars($row1["client"]) . "</td><td class='table_col1'>Private</td></tr>");
           }
       }
       echo "</table></div>";
   }
}
?>


I've tried playing with

SQL_Query_exec("SELECT id, username, avatar, privacy FROM users WHERE id=" . $row1["userid"]);


And trying available variables, but it only takes $row1. So I went to see about JOINing tables, since the code is taking the long way around to perform this anyway:

$res = SQL_Query_exec("SELECT users.id, users.username, users.avatar, users.privacy FROM users LEFT JOIN peers ON peers.userid = users.id WHERE users.id=" . $row1["userid"]);


Still no luck. Has this little feature even worked for anybody using TorrentTrader? If so, its safe to assume I've done something to announce.php - I just need confirmation on if this was originally a "experimental" feature or not. I can start overwriting files and crossing my fingers but that doesn't play nice with a actively updated 'peers' table and just causing problems.

Seems easier to just write-off this and get rid of it but.. hey the code in there, why not utilize it?

[ATTACH type="full"]5397[/ATTACH]
Sounds to me like its a issue with auto incremented unique ids. Make a full db backup, and then run this against forums_posts and try to reproduce the symptoms on PHP 5.3.X

Query:
SET @reset = 0; UPDATE forum_posts SET id = @reset:= @reset + 1;


This resets all mismatched IDs to regular order. Never run this against torrents, as you will lose media (screenshots, .torrents, etc).
Sounds to me like its a issue with auto incremented unique ids. Make a full db backup, and then run this against forums_posts and try to reproduce the symptoms on PHP 5.3.X

Query:
SET @reset = 0; UPDATE messages SET id = @reset:= @reset + 1;


This resets all mismatched IDs to regular order. Never run this against torrents, as you will lose media (screenshots, .torrents, etc).
"shadows, post: 68092, member: 20311":

Exactly this is meant to be used on static pages. i.e top torrents, faq, homepage, everywhere except dynamic pages such as torrent lists, commenttable, torrent details.

The pager works fine, but every page = new file in the memory.

I found a workaround to have all together, do not use md5 on name, just set the optional name for example:
return $this->obj->set('cache_all_torrents', $val, $expire);

It will always include new data and read the data from the file cache_all_torrents file from memcached (but the read / write will be consistently used) which is still not a good way.


Well, it might be a step in the right direction..
— 2020-03-04 03:16:33 in
Always good to run a SMTP mail test script as you set this up. It takes so much time out of refreshing email list, crossing fingers etc.. thats how I got it going on a new ISP.
I appreciate all the response!
"xblade, post: 68058, member: 20395":

i install servers for owners and sell them also cpans


And yet no one seems to have any feedback on rewrite methods, forwarding or rules. I do both physical hardware and the OS from it’s core, and believe CPanel is training wheels and doesn’t teach the end user how it actually works. Like phpmyadmin, for those who dont know how to use a real client or SSH term.
I think I’m taking the script too far beyond it’s built core, so I’m seeing methodology errors (MEMBERSONLY for example), broken code references and incomplete sections.

This is why it’s my own version, branding and design. It’s been stretched beyond stock, and that means very lack of feedback from the community.. because no one is ”in the same house”, so to speak. Will keep doing research on Apache.org
It’s been nothing but flex in communication with you not to mention a insulting PM on here from you, so whatever buddy. CPanel teaches you nothing like compiling Apache source, compiling/configuring PHP modules and simply knowing “make” all together. I wish my setup was as easy and installing training wheels too for “clients”, because I’ve seen no input on rewrite rules which implies lack of hands-on so this is irrelevant to my OP.
"xblade, post: 68047, member: 20395":

You will fined out this is seedbox error on announce And yes the announce works on https too so someone is not coding very well...movie-torrentz the owner is a very good mate of mine too good site


Its nothing to do with coding, its the Apache/NGINX rewrite rules on HTTPS requests. If you set up a server by yourself on your own hardware you will know what I mean. It isn't easy. Someone had some help. The script doesn't tunnel SSL announce requests by default and it takes effort to get that going. If anyone has any input on that process, I would be quite pleased.
"xblade, post: 68047, member: 20395":

You will fined out this is seedbox error on announce And yes the announce works on https too so someone is not coding very well...movie-torrentz the owner is a very good mate of mine too good site


Its nothing to with coding, its the Apache/NGINX rewrite rules on https requests. If you set up a server by yourself on your own hardware you will know what I mean. It isn't easy. Someone had some help.
Im using both private and public torrents, and merging stats over both so dead torrents populate all the same, in fact it did that by itself without modification so TT was nice with that. Sign up, make an account and see what I did here with stats:

[URL unfurl="true"]https://www.switch-torrents.com/details/321/[/url]

Pretty nice to dive into the old code, update it and plug it in. Works really well, although sometimes avatars don't get the peer table update so it tends to fail on the image for user but thats pretty minor. I can cache it for a time and call it a day.
And I see https is working on announce with invalid passkey, nice! I would be very interested in their server rewrite rules. I couldn't figure it out
???? ?

[ATTACH type="full" alt="5387"]5387[/ATTACH]
Your trying to establish a http(s) announce url, which is not supported in clients. It will timeout forever. That strange bit about this script, is announce.php

if ($MEMBERSONLY){
...
}

This literally shuts off common features needed for private torrents (announce.php), if MEMBERSONLY = false in config.php (it assumes a strictly-private-only site. Not always the case for people. Comment out the lines above in 2 occurrences and try again. You'll start to see actual pear stats instantly, and Missing Passkey is due to a improper url to the client. It is looking for a passkey, which is not available. if you pass /announce.php?passkey=123456, this will work in any combination because of the code above is not allowing clients to check the passkey, so returns true which is actually not working the way it was designed.

I figured this out the hard way, and really assumed my SSL was the problem. announce.php was the problem. Now it validates all passkeys perfectly (I used random string to verify, it checks out). Ensure http is strictly used for announce. HTTPS is not supported, nor any other announce url out there with that prefix. If one does work, please message me with the link.
To further extend this and make friendly, add to htaccess:

RewriteEngine On
RewriteRule ^passkey\/([^/]*)$ /announce.php?passkey=$1 [L]

Which will produce: http://website.com/passkey/04178cba17a1972     <--- This passkey is just a example, you can generate any you like. In this case, we are grabbing it from the torrent.

Add this to torrents-details.php

print("<a href='" . $site_config['SITEURL'] . "/passkey/".str_replace("http://website.com/announce?passkey=", "",($row["announce"]))."'>" . $site_config['SITEURL'] . "/passkey/".str_replace("http://website.com/announce?passkey=", "",($row["announce"]))."</a>");


All of that can just be called from a variable like $passkeyurl but this is for readability. This just grabs the passkey from the torrent, and puts it into the new url. This can be extended to grab the users passkey, like website.com/user/Jenny/passkey_<PASSKEY>

If that line seems like overkill, its because its modified away from what it actually does for me, renders the passkey through GD to high res image, which is then base64 encoded. So I had to do some trickery since Apache rewrite doesn't allow http:// after a rewritten forward slash (not without some Jedi skills), so I'm stripping the full announce url, leaving only passkey and rendering it to image. So we trick it by pre-appending the url in the GD script & only pass over the passkey to the rewritten url parameter (/passkey/YOURKEY). My situation is dynamic and very self aware, due to the user volume lately but once I fully figure out this system, a mod should come under way to set up  the process for users.

Example usage: https://www.switch-torrents.com/passkey/04178cba87a1172
And I do like so to detect the cases for the announce url


// Detect Public/Private trackers - Fixed - Feb 27, 2020
$matches = [];  
if ($row["external"] = 'yes' && !preg_match('{^http://[\w\.]*website.com/}i', $row["announce"], $matches)) {
   print("<p>Public Tracker <span style='color:#C0C0C0;padding-left:10px'>" . htmlspecialchars($row['announce']) . "</span></p>");
}
if ($row["external"] = 'no' && $CURUSER && preg_match('{^http://[\w\.]*website.com/}i', $row["announce"], $matches)) {
   print("<p><img src='/images/q_block_private.png' style='height:22px;width:22px;vertical-align:top;margin-right:7px' /> Private Tracker <br /><span style='color:#808080;padding-top:15px'>" . $row['announce'] . "</span></p>");
}
if ($row["external"] = 'no' && !$CURUSER && preg_match('{^http://[\w\.]*website.com/}i', $row["announce"], $matches)) {
   print("<p><img src='/images/q_block_private.png' style='height:22px;width:22px;vertical-align:top;margin-right:7px;color:#C0C0C0' /> Private Tracker (<a href='" . $site_config['SITEURL'] . "/signin/?returnto=/details/$id/'>sign in</a> for access key)</p>");
}
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