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
New view counter for torrents
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / General / General Chat

2022-01-08 18:06:53
if your script is based on php session, then you can avoid multiple view count by same user.
in old script even if you refresh the page the view is counted. so by using the below script you can avoid it :)

//page views
$pvkey_var = "v_".$id;
if(!isset($_SESSION[$pvkey_var])){
$_SESSION[$pvkey_var] = 0;
}
if (is_valid_id($id) && isset($CURUSER)){    
if($_SESSION[$pvkey_var] == 1){ }
else {
 SQL_Query_exec("UPDATE torrents SET views = views + 1 WHERE id = $id");
   $_SESSION[$pvkey_var] = 1;
}
}

follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
Last edited by JohnHasher on 2022-01-08 18:16:53
2022-01-13 08:13:16
good idea  😊 my query's are different but manged to add.  useful for forum views &  download hits 👍

            $pvkey_var = "v_".$id;
           $views = $_SESSION[$pvkey_var] == 1 ? $row["views"] + 0 : $row["views"] + 1;
           $_SESSION[$pvkey_var] = 1;
           DB::update('torrents', ['views'=>$views], ['id'=>$id]);
 
2022-01-13 19:07:15
else every page refresh will be counted as views
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
2022-01-15 12:32:01

$pvkey_var = "v_".$id;
          $views = $_SESSION[$pvkey_var] == 1 ? $row["views"] + 0 : $row["views"] + 1;
if(isset($_SESSION[$pvkey_var]) && $_SESSION[$pvkey_var]!=1){
          DB::update('torrents', ['views'=>$views], ['id'=>$id]);
$_SESSION[$pvkey_var] = 1;
}


you can avoid unwanted db execution
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
Last edited by JohnHasher on 2022-01-15 12:54:58
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: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728