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
[Updated] Who's Where
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods Completed

2020-02-02 08:07:55
I have updated the admin function for "Who's Where". The original was not at all accurate and never logged a lot of pages. Ive updated this so you will know where your users are as long as their active so you can better optimize concentrated pages or monitor user trend across your site.

Open /backend/functions.php and find:

function where($scriptname = "index", $userid, $update=1){
...
}


Replace entire function block with this:

function where($scriptname = "index", $userid, $update=1){
   if (!is_valid_id($userid))
       die;
   if (preg_match("/torrents-details.php/i", $scriptname))
       $where = "Browsing Torrent Details (ID $_GET[id])";
   elseif (preg_match("/torrents.php/i", $scriptname))
       $where = "Browsing Torrents";
   elseif (preg_match("/account-details.php/i", $scriptname))
       $where = "Browsing Account Details (ID $_GET[id])";
   elseif (preg_match("/torrents-upload.php/i", $scriptname))
       $where = "Uploading Torrent";
   elseif (preg_match("/account.php/i", $scriptname))
       $where = "Browsing User Control Panel";
   elseif (preg_match("/torrents-search/i", $scriptname))
       $where = "Searching For Torrents";
   elseif (preg_match("/forums.php/i", $scriptname))
       $where = "Viewing Forums";
   elseif (preg_match("/index/i", $scriptname))
       $where = "Browsing Homepage";
   elseif (preg_match("/mailbox.php/i", $scriptname))
       $where = "Viewing Messages";
   elseif (preg_match("/comments.php/i", $scriptname))
       $where = "Viewing Comments";
   elseif (preg_match("/account-recover.php/i", $scriptname))
       $where = "Recovering Account";
   elseif (preg_match("/bookmarks.php/i", $scriptname))
       $where = "Viewing Bookmarks";
   elseif (preg_match("/download.php/i", $scriptname))
       $where = "Downloaded Torrent (ID $_GET[id])";
   elseif (preg_match("/faq.php/i", $scriptname))
       $where = "Reading FAQ Page";
   elseif (preg_match("/friends.php/i", $scriptname))
       $where = "Viewing Friends";
   elseif (preg_match("/admincp.php/i", $scriptname))
       $where = "Managing Admin Panel"; // Fixes the "Unknown Location" for Admin when viewing Who's Where
   else
       $where = "Unknown Location";

   if ($update) {
       $query = sprintf("UPDATE users SET page=".sqlesc($where)." WHERE id ='%s'", mysql_real_escape_string($userid));
       $result = SQL_Query_exec($query);
   }
       return $where;
}
2020-02-02 13:51:21
thanks you...but it has duplicates ;)

   elseif (preg_match("/friends.php/i", $scriptname))
       $where = "Viewing Friends";
   elseif (preg_match("/bookmarks.php/i", $scriptname))
       $where = "Viewing Bookmarks";

2020-02-02 16:31:13
This line in your code
$query = sprintf("UPDATE users SET page=".sqlesc($where)." WHERE id ='%s'", mysql_real_escape_string($userid));

should be this way
$query = sprintf("UPDATE users SET page=".sqlesc($where)." WHERE id ='%s'", mysqli_real_escape_string($GLOBALS["DBconnector"], $userid));


My copy of TT looks like this in backend/functions.php
// WHO IS WHERE FUNCTION
function where ($where, $userid, $update=1){
       if (!is_valid_id($userid))
               die;

       if(empty($where))
               $where = "Unknown Location...";

       if ($update)
               SQL_Query_exec("UPDATE users SET last_access='" . get_date_time() . "', page=".sqlesc($where)." WHERE id=" . $userid);

       if (!$update){
               return $where;
               }else{
               return;
               }
}
//END THE DAMN FUNCTION

it will list whatever is in the stdhead of any given page
like this for example
[ATTACH type="full"]5352[/ATTACH]

stdhead(T_("WATCHING")." " . $arr["name"] . " ");

or a simpler version
[ATTACH type="full"]5353[/ATTACH]

   stdhead("Where are members");
Capture.PNG
Capture.PNG
Capture.PNG
Capture.PNG

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2020-02-02 18:24:15
"spiritblue, post: 67814, member: 401":

thanks you...but it has duplicates ;)

   elseif (preg_match("/friends.php/i", $scriptname))
       $where = "Viewing Friends";
   elseif (preg_match("/bookmarks.php/i", $scriptname))
       $where = "Viewing Bookmarks";



I was testing against rewrites and script names using both and comparing, thank you I’ll update post.
2020-02-19 21:48:48
The default where() function seems to have broke on me, maybe due to a minor mysql version update. So this code does works, but the problem is its sending the direct file system path to the page into the database, instead of page name. I've used your code correctly or it would not be updating record at all, maybe even a white page.

I can't seem to figure it out. While the old function died suddenly, this one seems to be more efficient. Any thoughts?


function where($where, $userid, $update = 1)
{
   if (!is_valid_id($userid)) die;
   if (empty($where)) $where  = "Unknown Location...";
   if ($update) SQL_Query_exec("UPDATE users SET last_access='" . get_date_time() . "', page=" . sqlesc($where) . " WHERE id=" . $userid);
   if (!$update)
   {
       return $where;
   }
   else
   {
       return;
   }
}


I've used different combinations of stdhead() but yours and all others fail. It is inserting a error 404 file path to exactly that, to the database. Is something wrong with this function block?
2020-05-07 21:16:51
i noticed mircomonkeys function does full script with url rewrites but you can replace server global in userlogin function
$where = where($_SERVER['REQUEST_URI'], $row["id"], 0);
This helps with mod rewrite or like me running everything through index
2020-05-10 00:08:50

function where($where)
{
   $where                          = substr($where, 1);
   $files['torrents-upload.php/']  = 'Uploading Torrent';
   $files['torrents-details.php/'] = 'Viewing Torrent ID ' . $_GET["id"];
   $files['account.php/']          = 'Viewing Account';
   $files['torrents-search.php/']  = 'Searching Torrents: ' . $_GET["search"];
   $files['forums.php/']           = 'Browsing Forums';
   $files['mailbox.php/']          = 'Viewing Messages';
   $files['comments.php']          = 'Viewing Comments';
   $files['bookmarks.php']         = 'Viewing Bookmarks';
   $files['download.php/']         = 'Downloaded Torrent ' . $_GET["name"];
   $files['faq.php/']              = 'Reading FAQ';
   $files['friends.php/']          = 'Viewing Friends';
   $files['admincp.php']           = 'Managing Admin Panel';
   $files['torrents.php/']         = 'Browsing Torrents';
   $files['tags/']                 = 'Browsing Tags: ' . $_GET["search"];
   $result                         = null;
   foreach ($files as $file => $descr) {
       if (0 === strpos($where, $file)) {
           $result = urldecode($descr);
           break;
}
}
   if ($result === null) {
       $result = sprintf('Browsing Homepage %s', $where);
   }
   return $result;
   SQL_Query_exec("UPDATE users SET last_access='" . get_date_time() . "', page=" . sqlesc($where) . " WHERE id=" . $userid);
}


Update loggedinonly()

function loggedinonly() {
   global $CURUSER;
   if (!$CURUSER) {
       header("Refresh: 0; url=" . $site_config["SITEURL"] . "/account-login.php?returnto=" . urlencode($_SERVER["REQUEST_URI"]));
       exit();
   }
}
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: 2
  • Members: 0
  • Guests online: 2
  • Comments: 3
  • Messages: 1,728