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
banned download
Controls ·  Search New posts · Mark unread

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

2023-08-27 16:07:48
Hello, I'm looking for the code to add in the cleanup.php file to disable downloading only for members with a ratio lower than 0.20 and with a mp message to indicate that downloading on their account is disabled.


thank you in advance for your help 😊


I started to modify the original warning code of torrent trader and I modified in the file cleanup.php in the code this,...

warning with downloadbanned

and the downloadbanned box in account-detail.php is ticked and the member with a ratio under 0.20 can no longer download but the problem is that when the member has increased his ratio and has a ratio higher than 0.20 the downloadbanned box remains ticked and the member still can't download




the warning code I've modified in the conf.php file below;

//AUTO RATIO WARNING
$site_config["ratiowarn_enable"] = true; //Enable/Disable auto ratio warning
$site_config["ratiowarn_minratio"] = 0.2; //Min Ratio
$site_config["ratiowarn_mingigs"] = 50;  //Min GB Downloaded
$site_config["ratiowarn_daystowarn"] = 0; //Days to ban







the warning code I've modified in the cleanup.php file below;


//LEECHWARN USERS WITH LOW RATIO

if ($site_config["ratiowarn_enable"]){
$minratio = $site_config["ratiowarn_minratio"];
$downloaded = $site_config["ratiowarn_mingigs"]*1024*1024*1024;
$length = $site_config["ratiowarn_daystowarn"];

//ADD WARNING
$res = SQL_Query_exec("SELECT id,username FROM users WHERE class = 1 AND downloadbanned = 'no' AND enabled='yes' AND uploaded / downloaded < $minratio AND downloaded >= $downloaded");

if (mysqli_num_rows($res) > 0){
$timenow = get_date_time();
$reason = "Warning!!! You must obtain a sharing ratio of ".$minratio." minimum avant les ".$length." or you'll be banned from the download.";

$expiretime = gmdate("Y-m-d H:i:s", gmtime() + (86400 * $length));

while ($arr = mysqli_fetch_assoc($res)){
SQL_Query_exec("INSERT INTO warnings (userid, reason, added, expiry, warnedby, type) VALUES ('".$arr["id"]."','".$reason."','".$timenow."','".$expiretime."','0','Poor Ratio')");
SQL_Query_exec("UPDATE users SET downloadbanned='yes' WHERE id='".$arr["id"]."'");
SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES ('0', '".$arr["id"]."', '".$timenow."', '".$reason."', '0')");
write_log("Auto Leech warning has been <b>added</b> for: <a href='account-details.php?id=".$arr["id"]."'>".$arr["username"]."</a>");
}
}






   //REMOVE WARNING
$res1 = SQL_Query_exec("SELECT users.id, users.username FROM users INNER JOIN warnings ON users.id=warnings.userid WHERE type='Poor Ratio' AND active = 'yes' AND warned = 'yes'  AND enabled='yes' AND uploaded / downloaded >= $minratio AND downloaded >= $downloaded");
if (mysqli_num_rows($res1) > 0){
$timenow = get_date_time();
$reason = "Bravo the download is now active.\n";

while ($arr1 = mysqli_fetch_assoc($res1)){
write_log("Auto Leech warning has been removed for: <a href='account-details.php?id=".$arr1["id"]."'>".$arr1["username"]."</a>");

SQL_Query_exec("UPDATE users SET downloadbanned = 'no' WHERE id = '".$arr1["id"]."'");
SQL_Query_exec("UPDATE warnings SET expiry = '$timenow', active = 'no' WHERE userid = $arr1[id]");
SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES ('0', '".$arr1["id"]."', '".$timenow."', '".$reason."', '0')");
}
}

//BAN WARNED USERS
$res = SQL_Query_exec("SELECT users.id, users.username, UNIX_TIMESTAMP(warnings.expiry) AS expiry FROM users INNER JOIN warnings ON users.id=warnings.userid WHERE type='Poor Ratio' AND active = 'yes' AND class = 1 AND enabled='yes' AND downloadbanned = 'yes' AND uploaded / downloaded < $minratio AND downloaded >= $downloaded");

if (mysqli_num_rows($res) > 0){
$timenow = get_date_time();
$expires = (86400 * $length);
while ($arr = mysqli_fetch_assoc($res)){
if (gmtime() - $arr["expiry"] >= 0) {
SQL_Query_exec("UPDATE users SET enabled='no', downloadbanned='no' WHERE id='".$arr["id"]."'");
write_log("User <a href='account-details.php?id=".$arr["id"]."'>".$arr["username"]."</a> has been banned (Auto Leech warning).");
}
}
}

}//check if warning system is on
// REMOVE WARNINGS
$res = SQL_Query_exec("SELECT users.id, users.username, warnings.expiry FROM users INNER JOIN warnings ON users.id=warnings.userid WHERE type != 'Poor Ratio' AND downloadbanned = 'yes'  AND enabled='yes' AND warnings.active = 'yes' AND warnings.expiry < '".get_date_time()."'");
while ($arr1 = mysqli_fetch_assoc($res)){
SQL_Query_exec("UPDATE users SET downloadbanned = 'no' WHERE id = $arr1[id]");
SQL_Query_exec("UPDATE warnings SET active = 'no' WHERE userid = $arr1[id] AND expiry < '".get_date_time()."'");
write_log("Removed warning for $arr1[username]. Expiry: $arr1[expiry]");
}
// WARN USERS THAT STILL HAVE ACTIVE WARNINGS
SQL_Query_exec("UPDATE users SET downloadbanned = 'yes' WHERE warned = 'no' AND id IN (SELECT userid FROM warnings WHERE active = 'yes')");
//END//
Last edited by niki on 2023-08-29 09:45:52
2023-08-29 06:38:35
can you try this?


// Unwarned
$timenow = gmtime();


SQL_Query_exec("UPDATE warnings SET active = 'no' WHERE active = 'yes' AND expiry < '".get_date_time()."'");

$res = SQL_Query_exec("SELECT users.id, users.username, warnings.expiry FROM users INNER JOIN warnings ON users.id = warnings.userid WHERE warned = 'yes' AND enabled = 'yes' AND warnings.active = 'yes' AND warnings.type = 'Poor Ratio'");

while ($arr1 = mysqli_fetch_assoc($res)) {
   $user = $arr1["id"];

   $subject = "Your poor ratio warning has been removed";
   $msg = "Congratulations! Your poor ratio warning has been removed. You can now download again.";

   // Get the user's current ratio
   $query = "SELECT users.uploaded, users.downloaded
             FROM users
             WHERE users.id = $user";

   $result = SQL_Query_exec($query);
   $data = mysqli_fetch_assoc($result);

   $uploaded = $data['uploaded'];
   $downloaded = $data['downloaded'];

   if ($downloaded > 0) {
       $userRatio = $uploaded / $downloaded;
   } else {
       $userRatio = 0;
   }

 
   $minRatio = $site_config['ratiowarn_minratio'];

   if ($userRatio >= $minRatio) {
       
       SQL_Query_exec("UPDATE users SET warned = 'no' WHERE id = $user");

       
       if ($site_config["ratiowarn_enable"] && $site_config["ratiowarn_daystowarn"] > 0) {
           SQL_Query_exec("UPDATE users SET downloadbanned = 'no' WHERE id = $user");
       }

       // Insert a message to notify the user
       SQL_Query_exec("INSERT INTO messages (sender, receiver, added, subject, msg, poster) VALUES (0, $user, '".get_date_time()."', ".sqlesc($subject).", ".sqlesc($msg).", 1)");
   }
}
2023-08-29 09:37:12
thank you for your help djlive but it does not work for me and in the meantime I found this code below which works but the problem with this code is that you have to wait several hours before the cleanup function refreshes the site and face the changes on the class of the member?? there may be a way to update faster, ..

I added this piece of code in the code below but like this but it does not work??

$minratio = 0.10;
$site_config['autoclean_interval'] = 600; // time to cleanup (10 minutes)


##########################
# BANN DOWNLOAD FAIBLE RATIO#
##########################

// ban download if ratio 0.10
$minratio = 0.10;
$stmt = SQL_Query_exec("SELECT id FROM users WHERE uploaded / downloaded < $minratio");
while ($arr = mysqli_fetch_assoc($stmt)) {
    // now we link download banned mod
     SQL_Query_exec("UPDATE users SET downloadbanned = 'yes' WHERE id = $arr[id]");
}

##########################
# END BANN DOWNLOAD FAIBLE RATIO#
##########################


##########################
# NO DOWNLOAD FAIBLE RATIO#
##########################

// allow download if ratio 0.11
$minratio = 0.11;
$stmt = SQL_Query_exec("SELECT id FROM users WHERE uploaded / downloaded > $minratio");
while ($arr = mysqli_fetch_assoc($stmt)) {
    // now we link download banned mod
     SQL_Query_exec("UPDATE users SET downloadbanned = 'no' WHERE id = $arr[id]");
}

##########################
# END NO DOWNLOAD FAIBLE RATIO#
##########################
Last edited by niki on 2023-08-29 09:42:38
2023-09-08 19:20:03
The code is wrong, because it is using division against a float value. None of that makes sense in the context of INT / FLOAT.

I actually need this code, so I will post a working copy that is fast.
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: 3
  • Members: 0
  • Guests online: 3
  • Comments: 3
  • Messages: 1,728