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
Auto promote users!
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2 Only Mods Complete

Unknown User
2010-01-12 02:10:58
Can you do like ratio 2.50 ex and 50 go up and 3 torrent in seed when promoted
Unknown User
2010-01-12 09:25:32
"TorrentialStorm, post: 39989":
	$gigs = 25*1073741824; // 25 GB

$res = mysql_query("SELECT id FROM users WHERE class = 1 AND uploaded >= $gigs AND uploaded >= downloaded");

$time = get_date_time();

while ($arr = mysql_fetch_assoc($res)) {

mysql_query("UPDATE users SET class = 2 WHERE id = $arr[id]");

mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'You have been automatically promoted from User to Power User, If your ratio drops below 1.00 you will be demoted.', 'You have been promoted to: Power User')");

}



$res = mysql_query("SELECT id FROM users WHERE class = 2 AND uploaded >= $gigs AND uploaded < downloaded");

while ($arr = mysql_fetch_assoc($res)) {

mysql_query("UPDATE users SET class = 1 WHERE id = $arr[id]");

mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'You have been automatically demoted from Power User to User.', 'You have been demoted to User')");

}




I try with 250GB, promote works fine, but demote dont work  ;) . Any help?

Are you sure that this code counting upload gigs, because its feels like it count only ratio?



// promote to power users

$gigs = 250*1073741824; // 250 GB

$res = mysql_query("SELECT id FROM users WHERE class = 1 AND uploaded >= $gigs AND uploaded >= downloaded");

$time = get_date_time();

while ($arr = mysql_fetch_assoc($res)) {

mysql_query("UPDATE users SET class = 2 WHERE id = $arr[id]");

mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'You have been automatically promoted from User to Power User. If your ratio drops below 1.00 you will be demoted.', 'You have been promoted to: Power User')");

}



$res = mysql_query("SELECT id FROM users WHERE class = 2 AND uploaded >= $gigs AND uploaded < downloaded");

while ($arr = mysql_fetch_assoc($res)) {

mysql_query("UPDATE users SET class = 1 WHERE id = $arr[id]");

mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'You have been automatically demoted from Power User to User.', 'You have been demoted to User')");

}







mu cleanup.php:



<?php



function do_cleanup() {

global $site_config;



//LOCAL TORRENTS - GET PEERS DATA AND UPDATE BROWSE STATS



$torrents = array();

$res = mysql_query("SELECT torrent, seeder, COUNT(*) AS c FROM peers GROUP BY torrent, seeder");



while ($row = mysql_fetch_assoc($res)) {

if ($row["seeder"] == "yes")

$key = "seeders";

else

$key = "leechers";

$torrents[$row["torrent"]][$key] = $row["c"];



}







$fields = explode(":", "comments:leechers:seeders");

$res = mysql_query("SELECT id, seeders, leechers FROM torrents WHERE external !='yes'");



while ($row = mysql_fetch_assoc($res)) {



$id = $row["id"];

$torr = $torrents[$id];

foreach ($fields as $field) {

if (!isset($torr[$field]))

$torr[$field] = 0;



}



$update = array();

foreach ($fields as $field) {



if ($torr[$field] != $row[$field])

$update[] = "$field = " . $torr[$field];



}



if (count($update))



mysql_query("UPDATE torrents SET " . implode(",", $update) . " WHERE id = $id AND external !='yes'");



}







//LOCAL TORRENTS - MAKE NON-ACTIVE/OLD TORRENTS INVISIBLE



$deadtime = gmtime() - $site_config["max_dead_torrent_time"];



mysql_query("UPDATE torrents SET visible='no' WHERE visible='yes' AND last_action < FROM_UNIXTIME($deadtime) AND external !='yes'");







////////Update Seederbonus/////////

  $res = mysql_query("SELECT DISTINCT userid FROM peers WHERE seeder = 'yes'") or die (mysql_error());

  if (mysql_num_rows($res) > 0)

  {

  while ($arr = mysql_fetch_assoc($res))

  {

  mysql_query("UPDATE users SET seedbonus = seedbonus+0.5 WHERE id = $arr[userid]") or die (mysql_error());

  }

  }

/////////////////////////////////////////









//DELETE OLD NON-ACTIVE PEERS



$res = mysql_query("DELETE FROM peers WHERE ".gmtime()."-UNIX_TIMESTAMP(last_action) >= 2400");







//DELETE PENDING USER ACCOUNTS OVER TIMOUT AGE



$deadtime = gmtime() - $site_config["signup_timeout"];



mysql_query("DELETE FROM users WHERE status = 'pending' AND added < FROM_UNIXTIME($deadtime)");







// promote to power users

$gigs = 250*1073741824; // 250 GB

$res = mysql_query("SELECT id FROM users WHERE class = 1 AND uploaded >= $gigs AND uploaded >= downloaded");

$time = get_date_time();

while ($arr = mysql_fetch_assoc($res)) {

mysql_query("UPDATE users SET class = 2 WHERE id = $arr[id]");

mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'You have been automatically promoted from User to Power User. If your ratio drops below 1.00 you will be demoted.', 'You have been promoted to: Power User')");

}



$res = mysql_query("SELECT id FROM users WHERE class = 2 AND uploaded >= $gigs AND uploaded < downloaded");

while ($arr = mysql_fetch_assoc($res)) {

mysql_query("UPDATE users SET class = 1 WHERE id = $arr[id]");

mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'You have been automatically demoted from Power User to User.', 'You have been demoted to User')");

}











//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 = mysql_query("SELECT id,username FROM users WHERE class = 1 AND warned = 'no' AND enabled='yes' AND uploaded / downloaded < $minratio AND downloaded >= $downloaded");



if (mysql_num_rows($res) > 0){



$timenow = get_date_time();

$reason = "You have been warned because of having low ratio. You need to get a ".$minratio." before next ".$length." days or your account may be banned.";

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



while ($arr = mysql_fetch_assoc($res)){



mysql_query("INSERT INTO warnings (userid, reason, added, expiry, warnedby, type) VALUES ('".$arr["id"]."','".$reason."','".$timenow."','".$expiretime."','0','Poor Ratio')");

mysql_query("UPDATE users SET warned='yes' WHERE id='".$arr["id"]."'");

mysql_query("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 = mysql_query("SELECT id,username FROM users WHERE warned = 'yes' AND enabled='yes' AND uploaded / downloaded >= $minratio AND downloaded >= $downloaded");





if (mysql_num_rows($res1) > 0){

$timenow = get_date_time();

$reason = "Your warning of low ratio has been removed. We highly recommend you to keep a your ratio up to not be warned again.\n";







while ($arr1 = mysql_fetch_assoc($res1)){

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







mysql_query("UPDATE users SET warned = 'no' WHERE id = '".$arr1["id"]."'");

mysql_query("UPDATE warnings SET expiry = '".$timenow."' WHERE userid = '".$arr1["id"]."'");

mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES ('0', '".$arr1["id"]."', '".$timenow."', '".$reason."', '0')");



}



}







//BAN WARNED USERS



$res = mysql_query("SELECT id,username FROM users WHERE class = 1 AND enabled='yes' AND warned = 'yes' AND uploaded / downloaded < $minratio AND downloaded >= $downloaded");







if (mysql_num_rows($res) > 0){

$timenow = get_date_time();

$expires = (86400 * $length);







while ($arr = mysql_fetch_assoc($res)){

$r = mysql_query("SELECT id, UNIX_TIMESTAMP(expiry) as expiry FROM warnings WHERE userid=$arr[id]");

$row = mysql_fetch_assoc($r);







if (gmtime() - $row["expiry"] >= 0) {

mysql_query("UPDATE users SET enabled='no', warned='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



//END//





//OPTIMISE TABLES

mysql_query("OPTIMIZE TABLE `peers` , `torrents` , `tasks` , `guests` , `users` , `messages` , `comments` , `addedrequests` , `bookmarks` , `blackjack`; ");

}//end func







// START LOTTERY

dbconn();

$res = mysql_query("SELECT * FROM lottery_config") or sqlerr(__FILE__, __LINE__);

while ($arr = mysql_fetch_assoc($res))

$arr_config[$arr['name']] = $arr['value'];



if ($arr_config['enable'] == 1)

{

if (get_date_time() > $arr_config['end_date'])

{

if ($arr_config["ticket_amount_type"] == GB)

$arr_config['ticket_amount'] = 1024 * 1024 * 1024 * $arr_config['ticket_amount'];

else if ($arr_config["ticket_amount_type"] == MB)

$arr_config['ticket_amount'] = 1024 * 1024 * $arr_config['ticket_amount'];

$size = $arr_config['ticket_amount'];



if ($arr_config["ticket_amount_type"] == GB)

$arr_config['prize_fund'] = 1024 * 1024 * 1024 * $arr_config['prize_fund'];

else if ($arr_config["ticket_amount_type"] == MB)

$arr_config['prize_fund'] = 1024 * 1024 * $arr_config['prize_fund'];

$prize_fund = $arr_config['prize_fund'];



$total = mysql_num_rows(mysql_query("SELECT * FROM tickets"));

if ($arr_config["use_prize_fund"])

{

$pot = $prize_fund / $arr_config['total_winners'];

$res = mysql_query("SELECT user FROM tickets ORDER BY RAND() LIMIT $arr_config[total_winners]") or sqlerr();

$who_won = array();

$msg = sqlesc("Congratulations, You have won: <b>".mksize($pot)."</b>.<br /><br />This has been added to your upload amount<br /><br />Thanks for playing Lottery.");

while ($arr = mysql_fetch_assoc($res))

{

$res2 = mysql_query("SELECT modcomment FROM users WHERE id = $arr[user]") or sqlerr(__FILE__, __LINE__);

$arr2 = mysql_fetch_assoc($res2);

$modcomment = $arr2['modcomment'];

$modcom = sqlesc("User won the lottery: " . mksize($pot) . " at " . get_date_time() . "\n" . $modcomment);

mysql_query("UPDATE users SET uploaded = uploaded + $pot, modcomment = $modcom WHERE id = $arr[user]") or sqlerr();

mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[user], NOW(), $msg, 0)") or sqlerr(__FILE__, __LINE__);

$who_won[] = $arr['user'];

}

}

else

{

$pot = $total * $size / $arr_config['total_winners'];

$res = mysql_query("SELECT user FROM tickets ORDER BY RAND() LIMIT $arr_config[total_winners]") or sqlerr();

$who_won = array();

$msg = sqlesc("Congratulations, You have won: ".mksize($pot).".\n\nThis has been added to your upload amount.\n\nThanks for playing Lottery.");

while ($arr = mysql_fetch_assoc($res))

{

$res2 = mysql_query("SELECT modcomment FROM users WHERE id = $arr[user]") or sqlerr(__FILE__, __LINE__);

$arr2 = mysql_fetch_assoc($res2);

$modcomment = $arr2['modcomment'];

$modcom = sqlesc("User won the lottery: " . mksize($pot) . " at " . get_date_time() . "\n" . $modcomment);

mysql_query("UPDATE users SET uploaded = uploaded + $pot WHERE id = $arr[user]") or sqlerr();

mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[user], NOW(), $msg, 0)") or sqlerr(__FILE__, __LINE__);

$who_won[] = $arr['user'];

}

}

$who_won = implode("|", $who_won);

$who_won_date = get_date_time();

$who_won_prize = $pot;

mysql_query("TRUNCATE TABLE tickets") or sqlerr(__FILE__, __LINE__);

if ($who_won != '')

{

mysql_query("UPDATE lottery_config SET value = '$who_won' WHERE name = 'lottery_winners'") or sqlerr(__FILE__, __LINE__);

mysql_query("UPDATE lottery_config SET value = '$who_won_prize' WHERE name = 'lottery_winners_amount'") or sqlerr(__FILE__, __LINE__);

mysql_query("UPDATE lottery_config SET value = '$who_won_date' WHERE name = 'lottery_winners_time'") or sqlerr(__FILE__, __LINE__);

}

mysql_query("UPDATE lottery_config SET value = '0' WHERE name = 'enable'") or sqlerr(__FILE__, __LINE__);

}

}

// END LOTTERY



//UPDATE CASINO TRYS

$deadtimec = gmtime() - 18000;

mysql_query("UPDATE casino SET trys='0' WHERE date < FROM_UNIXTIME($deadtimec)");



?>
Unknown User
2010-01-12 22:43:59
I set it up in this way it seems, that the do arithmetics well.

Version 2.5

cleanup.php

//Ryb
Unknown User
2010-01-13 09:31:46
"Diverjh, post: 61736":
config.php
$site_config["ratiowarn_promote"] = true; //Promote Ryb

Unknown User
2010-01-13 14:27:18
I'm lama, I I cannot make tail of it.   ;)
Unknown User
2010-01-14 02:03:43
Hum did he have the option (2 torrent in seed when promoted) ??
Unknown User
2010-02-13 23:10:46
add to cleanup.php

add near the end



//heres another take on demote/promote auto



//promote member to power user

$limit = 25*1024*1024*1024;

$minratio = 1.05;

$maxdt = sqlesc(get_date_time(gmtime() - 86400*28));

$res = mysql_query("SELECT id, username FROM users WHERE class = 1 AND uploaded >= $limit AND uploaded / downloaded >= $minratio AND added < $maxdt") or sqlerr(__FILE__, __LINE__);

if (mysql_num_rows($res) > 0)

{

$dt = sqlesc(get_date_time());

$msg = sqlesc("Congratulations, you have been auto-promoted to Power User by SYSTEM.");

while ($arr = mysql_fetch_assoc($res))

{

mysql_query("UPDATE users SET class = 2 WHERE id = $arr[id]") or sqlerr(__FILE__, __LINE__);

mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES (0, $arr[id], $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);

write_log("User <a href=account-details.php?id=".$arr["id"].">".$arr["username"]."</a> Was automatically promoted to POWERUSER by SYSTEM.");

}

}



//Demote power-users to members and disable account

$limit = 25*1024*1024*1024;

$minratio = 0.75;

$maxdt = sqlesc(get_date_time(gmtime() - 86400*28));

$res = mysql_query("SELECT id, username FROM users WHERE class = 2 AND uploaded <= $limit AND uploaded / downloaded <= $minratio AND added < $maxdt") or sqlerr(__FILE__, __LINE__);



if (mysql_num_rows($res) > 0)

{

$dt = sqlesc(get_date_time());

//$msg = sqlesc("Congratulations, you have been auto-demoted to Member and account disabled by SYSTEM. Probably due to low ratio or account inactivity.");

while ($arr = mysql_fetch_assoc($res))

{

mysql_query("UPDATE users SET class = 1, enabled = 'No' WHERE id = $arr[id]") or sqlerr(__FILE__, __LINE__);

//mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES (0, $arr[id], $dt, $msg, 0)")or sqlerr(__FILE__, __LINE__);

  write_log("User <a href=account-details.php?id=".$arr["id"].">".$arr["username"]."</a> Was automatically demoted to member and disabled by SYSTEM. Messages purged.");

//remove any records belonging to this user in messages

 mysql_query("DELETE FROM messages WHERE receiver = $arr[id]")or sqlerr(__FILE__, __LINE__);

}

}



//Demote Uploaders to power users

$limit = 25*1024*1024*1024;

$minratio = 1.50;

$maxdt = sqlesc(get_date_time(gmtime() - 86400*28));

$res = mysql_query("SELECT id, username FROM users WHERE class = 4 AND uploaded >= $limit AND uploaded / downloaded >= $minratio AND last_access <= $maxdt") or sqlerr(__FILE__, __LINE__);



if (mysql_num_rows($res) > 0)

{

$dt = sqlesc(get_date_time());

$msg = sqlesc("Congratulations, you have been auto-demoted to Power User by SYSTEM. Probably due to inactivity.");

while ($arr = mysql_fetch_assoc($res))

{

mysql_query("UPDATE users SET class = 2 WHERE id = $arr[id]") or sqlerr(__FILE__, __LINE__);

mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES (0, $arr[id], $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);

write_log("User <a href=account-details.php?id=".$arr["id"].">".$arr["username"]."</a> Was automatically demoted to POWERUSER by SYSTEM. Probably due to lack of activity.");

}

}
Unknown User
2010-06-09 17:32:11
Is it possible to do the same thing with the number of messages and topics posted in the forum. For example if he has 100 messages posted it is automatically promoted
2010-10-18 01:48:48
Thank you very much WazzaUK  :D

V.2.6
Unknown User
2011-08-19 04:57:39
"TorrentialStorm, post: 39989":
	$gigs = 25*1073741824; // 25 GB

$res = mysql_query("SELECT id FROM users WHERE class = 1 AND uploaded >= $gigs AND uploaded >= downloaded");

$time = get_date_time();

while ($arr = mysql_fetch_assoc($res)) {

mysql_query("UPDATE users SET class = 2 WHERE id = $arr[id]");

mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'You have been automatically promoted from User to Power User, If your ratio drops below 1.00 you will be demoted.', 'You have been promoted to: Power User')");

}



$res = mysql_query("SELECT id FROM users WHERE class = 2 AND uploaded >= $gigs AND uploaded < downloaded");

while ($arr = mysql_fetch_assoc($res)) {

mysql_query("UPDATE users SET class = 1 WHERE id = $arr[id]");

mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'You have been automatically demoted from Power User to User.', 'You have been demoted to User')");

}


that should work for any User that has uploaded 25+GBs and has a ratio over 1
Thank you, its ok for 2.07
Unknown User
2011-10-10 17:40:05
moved to Mod Completed
Unknown User
2011-10-13 18:16:00
Uploaded: 23.00 GB

Downloaded: 30.00 GB

Ratio: 0.766666666667

but no demote from P.User to Member

i have the code

$gigs = 25*1073741824; // 25 GB

$res = mysql_query("SELECT id FROM users WHERE class = 1 AND uploaded >= $gigs AND uploaded >= downloaded");

$time = get_date_time();

while ($arr = mysql_fetch_assoc($res)) {

mysql_query("UPDATE users SET class = 2 WHERE id = $arr[id]");

mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'You have been automatically promoted from User to Power User, If your ratio drops below 1.00 you will be demoted.', 'You have been promoted to: Power User')");

}



$res = mysql_query("SELECT id FROM users WHERE class = 2 AND uploaded >= $gigs AND uploaded < downloaded");

while ($arr = mysql_fetch_assoc($res)) {

mysql_query("UPDATE users SET class = 1 WHERE id = $arr[id]");

mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'You have been automatically demoted from Power User to User.', 'You have been demoted to User')");

}
Unknown User
2011-10-13 18:51:36
SELECT id FROM users WHERE class = 2 AND uploaded >= $gigs AND uploaded < downloaded

that means if there uploaded is equal or greater than 25GB and there upload is less than download
Unknown User
2011-10-13 19:07:05
ok i understand now..thanks again
Unknown User
2011-10-13 19:22:00
Erm. try this for promoting users.

SELECT id FROM users WHERE class = 1 AND uploaded >= $gigs AND (uploaded / downloaded) >= 1.0
and for demoting maybe this...




SELECT id FROM users WHERE class = 2 AND uploaded >= $gigs AND (uploaded / downloaded) <= 1.0



i haven't tested it as i dont have a live site to test it on.
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