09 Privilege Mods - Download/Upload/Forum..

Started by Mindless, July 26, 2012, 10:23:49 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mindless

Credits to pdq :)
Xhtml valid where applicable :)
Outstanding - Language entrys to be completed.

Download, Upload, Forumposting, Shoutbox, Immunity, Leechwarn mods with disable duration using 1 (int) sql field per mod :)

Ok six mods here posted in one shot to save several posts or threads for the same type of system - Use what you want its easy to see each piece of code per mod,
If you have the original posted mods then drop and replace the sql and replace the code as indicated otherwise just follow the post :)

Code (sq) Select
ALTER TABLE users ADD `uploadpos` int(11) NOT NULL default '1';
ALTER TABLE users ADD `forumpost` int(11) NOT NULL default '1';
ALTER TABLE users ADD `downloadpos` int(11) NOT NULL default '1';
ALTER TABLE users ADD `chatpost` int(11) NOT NULL default '1';
ALTER TABLE users ADD `immunity` int(11) NOT NULL default '0';
ALTER TABLE users ADD `leechwarn` int(11) NOT NULL default '0';


@File userdetails.php admin tools section under warning code add or replace the old with :

     //==Download disable
     if ($CURUSER['class'] >= UC_MODERATOR) {
   $downloadpos = $user['downloadpos'] != 1;
     $HTMLOUT .= "<tr><td class='rowhead'".(!$downloadpos ? ' rowspan="2"' : '').">Download Status</td>
   <td align='left' width='20%'>".($downloadpos ? "<input name='downloadpos' value='42' type='radio' />Remove download disablement" : "No disablement Status Set")."</td>\n";

     if ($downloadpos)
     {
     if ($user['downloadpos'] == 0)
     $HTMLOUT .= '<td align="center">(Unlimited Duration)</td></tr>';
     else
     $HTMLOUT .= "<td align='center'>Until ".get_date($user['downloadpos'], 'DATE'). " (".mkprettytime($user['downloadpos'] - time()). " to go)</td></tr>";
     } else
     {
     $HTMLOUT .= '<td>Disable for <select name="downloadpos">
     <option value="0">------</option>
     <option value="1">1 week</option>
     <option value="2">2 weeks</option>
     <option value="4">4 weeks</option>
     <option value="8">8 weeks</option>
     <option value="255">Unlimited</option>
     </select>       </td></tr>
     <tr><td colspan="2" align="left">PM comment:<input type="text" size="60" name="disable_pm" /></td></tr>';
     }
     }
     //==Upload disable
     if ($CURUSER['class'] >= UC_MODERATOR) {
   $uploadpos = $user['uploadpos'] != 1;
     $HTMLOUT .= "<tr><td class='rowhead'".(!$uploadpos ? ' rowspan="2"' : '').">Upload Status</td>
   <td align='left' width='20%'>".($uploadpos ? "<input name='uploadpos' value='42' type='radio' />Remove upload disablement" : "No disablement Status Set")."</td>\n";

     if ($uploadpos)
     {
     if ($user['uploadpos'] == 0)
     $HTMLOUT .= '<td align="center">(Unlimited Duration)</td></tr>';
     else
     $HTMLOUT .= "<td align='center'>Until ".get_date($user['uploadpos'], 'DATE'). " (".mkprettytime($user['uploadpos'] - time()). " to go)</td></tr>";
     } else
     {
     $HTMLOUT .= '<td>Disable for <select name="uploadpos">
     <option value="0">------</option>
     <option value="1">1 week</option>
     <option value="2">2 weeks</option>
     <option value="4">4 weeks</option>
     <option value="8">8 weeks</option>
     <option value="255">Unlimited</option>
     </select>       </td></tr>
     <tr><td colspan="2" align="left">PM comment:<input type="text" size="60" name="updisable_pm" /></td></tr>';
     }
     }
     //==Posting disable
     if ($CURUSER['class'] >= UC_MODERATOR) {
   $forumpost = $user['forumpost'] != 1;
     $HTMLOUT .= "<tr><td class='rowhead'".(!$forumpost ? ' rowspan="2"' : '').">Forum Posting Status</td>
   <td align='left' width='20%'>".($forumpost ? "<input name='forumpost' value='42' type='radio' />Remove posting disablement" : "No disablement Status Set")."</td>\n";

     if ($forumpost)
     {
     if ($user['forumpost'] == 0)
     $HTMLOUT .= '<td align="center">(Unlimited Duration)</td></tr>';
     else
     $HTMLOUT .= "<td align='center'>Until ".get_date($user['forumpost'], 'DATE'). " (".mkprettytime($user['forumpost'] - time()). " to go)</td></tr>";
     } else
     {
     $HTMLOUT .= '<td>Disable for <select name="forumpost">
     <option value="0">------</option>
     <option value="1">1 week</option>
     <option value="2">2 weeks</option>
     <option value="4">4 weeks</option>
     <option value="8">8 weeks</option>
     <option value="255">Unlimited</option>
     </select>       </td></tr>
     <tr><td colspan="2" align="left">PM comment:<input type="text" size="60" name="forumdisable_pm" /></td></tr>';
     }
     }
     //==Shoutbox disable
     if ($CURUSER['class'] >= UC_MODERATOR) {
   $chatpost = $user['chatpost'] != 1;
     $HTMLOUT .= "<tr><td class='rowhead'".(!$chatpost ? ' rowspan="2"' : '').">Shout Status</td>
   <td align='left' width='20%'>".($chatpost ? "<input name='chatpost' value='42' type='radio' />Remove Shout disablement" : "No disablement Status Set")."</td>\n";

     if ($chatpost)
     {
     if ($user['chatpost'] == 0)
     $HTMLOUT .= '<td align="center">(Unlimited Duration)</td></tr>';
     else
     $HTMLOUT .= "<td align='center'>Until ".get_date($user['chatpost'], 'DATE'). " (".mkprettytime($user['chatpost'] - time()). " to go)</td></tr>";
     } else
     {
     $HTMLOUT .= '<td>Disable for <select name="chatpost">
     <option value="0">------</option>
     <option value="1">1 week</option>
     <option value="2">2 weeks</option>
     <option value="4">4 weeks</option>
     <option value="8">8 weeks</option>
     <option value="255">Unlimited</option>
     </select>       </td></tr>
     <tr><td colspan="2" align="left">PM comment:<input type="text" size="60" name="chatdisable_pm" /></td></tr>';
     }
     }
     //==Immunity
     if ($CURUSER['class'] >= UC_MODERATOR) {
    $free_switch = $user['immunity'] != 1;
      $HTMLOUT .= "<tr><td class='rowhead'".(!$immunity ? ' rowspan="2"' : '').">Immunity Status</td>
    <td align='left' width='20%'>".($immunity ? "<input name='immunity' value='42' type='radio' />Remove immune Status" : "No immunity Status Set")."</td>\n";

      if ($immunity)
      {
      if ($user['immunity'] == 0)
      $HTMLOUT .= '<td align="center">(Unlimited Duration)</td></tr>';
      else
      $HTMLOUT .= "<td align='center'>Until ".get_date($user['immunity'], 'DATE'). " (".
            mkprettytime($user['immunity'] - time()). " to go)</td></tr>";
     } else
     {
     $HTMLOUT .= '<td>Immunity for <select name="immunity">
     <option value="0">------</option>
     <option value="1">1 week</option>
     <option value="2">2 weeks</option>
     <option value="4">4 weeks</option>
     <option value="8">8 weeks</option>
     <option value="255">Unlimited</option>
     </select>       </td></tr>
     <tr><td colspan="2" align="left">PM comment:<input type="text" size="60" name="immunity_pm" /></td></tr>';
     }
     }
     //==Leech Warnings
     if ($CURUSER['class'] >= UC_MODERATOR) {
   $leechwarn = $user['leechwarn'] != 0;
     $HTMLOUT .= "<tr><td class='rowhead'".(!$leechwarn ? ' rowspan="2"' : '').">Leech Warn Status</td>
   <td align='left' width='20%'>".($leechwarn ? "<input name='leechwarn' value='42' type='radio' />Remove Leechwarn Status" : "No leech warning Status Set")."</td>\n";

      if ($leechwarn)
      {
      if ($user['leechwarn'] == 1)
      $HTMLOUT .= '<td align="center">(Unlimited Duration)</td></tr>';
      else
      $HTMLOUT .= "<td align='center'>Until ".get_date($user['leechwarn'], 'DATE'). " (".
            mkprettytime($user['leechwarn'] - time()). " to go)</td></tr>";
     } else
     {
     $HTMLOUT .= '<td>leechwarn for <select name="leechwarn">
     <option value="0">------</option>
     <option value="1">1 week</option>
     <option value="2">2 weeks</option>
     <option value="4">4 weeks</option>
     <option value="8">8 weeks</option>
     <option value="255">Unlimited</option>
     </select>       </td></tr>
     <tr><td colspan="2" align="left">PM comment:<input type="text" size="60" name="leechwarn_pm" /></td></tr>';
     }
     }
     //==End

     
@File modtask.php add this under the $res user query at the top of the file if you use immunity :
     
     if (($user['immunity'] >= 1) && ($CURUSER['class'] < UC_SYSOP))
    stderr("Error", "This user is immune to your commands !");

     
@File modtask.php add or replace the old with :
     
    /// Set upload possible Time based
    if (isset($_POST['uploadpos']) && ($uploadpos =
    0 + $_POST['uploadpos']))
    {
    unset($updisable_pm);
    if (isset($_POST['updisable_pm']))
        $updisable_pm = $_POST['updisable_pm'];
    $subject = sqlesc('Notification!');
    $added = time();
   
    if ($uploadpos == 255)
    {
        $modcomment = get_date($added, 'DATE', 1)." - Upload disablement by ".
$CURUSER['username'].".\nReason: $updisable_pm\n".$modcomment;
        $msg = sqlesc("Your Uploading rights have been disabled by ".$CURUSER['username'].($updisable_pm ?
            "\n\nReason: $updisable_pm" : ''));
        $updateset[] = 'uploadpos = 0';
    } elseif ($uploadpos == 42)
    {
        $modcomment = get_date($added, 'DATE', 1)." - Upload disablement status removed by ".
$CURUSER['username'].".\n".$modcomment;
        $msg = sqlesc("Your Uploading rights have been restored by ".
$CURUSER['username'].".");
$updateset[] = 'uploadpos = 1';
    } else
    {
        $uploadpos_until = ($added + $uploadpos * 604800);
        $dur = $uploadpos.' week'.($uploadpos > 1 ? 's' : '');
        $msg = sqlesc("You have received $dur Upload disablement from ".
$CURUSER['username'].($updisable_pm ? "\n\nReason: $updisable_pm" : ''));
        $modcomment = get_date($added, 'DATE', 1)." - Upload disablement for $dur by ".
$CURUSER['username'].".\nReason: $updisable_pm\n".$modcomment;
        $updateset[] = "uploadpos = ".$uploadpos_until;
    }

    mysql_query("INSERT INTO messages (sender, receiver, subject, msg, added)
             VALUES (0, $userid, $subject, $msg, $added)") or sqlerr(__file__, __line__);
   }
    /// Set download possible Time based
    if (isset($_POST['downloadpos']) && ($downloadpos =
    0 + $_POST['downloadpos']))
    {
    unset($disable_pm);
    if (isset($_POST['disable_pm']))
        $disable_pm = $_POST['disable_pm'];
    $subject = sqlesc('Notification!');
    $added = time();
   
    if ($downloadpos == 255)
    {
        $modcomment = get_date($added, 'DATE', 1)." - Download disablement by ".
$CURUSER['username'].".\nReason: $disable_pm\n".$modcomment;
        $msg = sqlesc("Your Downloading rights have been disabled by ".$CURUSER['username'].($disable_pm ?
            "\n\nReason: $disable_pm" : ''));
        $updateset[] = 'downloadpos = 0';
    } elseif ($downloadpos == 42)
    {
        $modcomment = get_date($added, 'DATE', 1)." - Download disablement status removed by ".
$CURUSER['username'].".\n".$modcomment;
        $msg = sqlesc("Your Downloading rights have been restored by ".
$CURUSER['username'].".");
$updateset[] = 'downloadpos = 1';
    } else
    {
        $downloadpos_until = ($added + $downloadpos * 604800);
        $dur = $downloadpos.' week'.($downloadpos > 1 ? 's' : '');
        $msg = sqlesc("You have received $dur Download disablement from ".
$CURUSER['username'].($disable_pm ? "\n\nReason: $disable_pm" : ''));
        $modcomment = get_date($added, 'DATE', 1)." - Download disablement for $dur by ".
$CURUSER['username'].".\nReason: $disable_pm\n".$modcomment;
        $updateset[] = "downloadpos = ".$downloadpos_until;
    }

    mysql_query("INSERT INTO messages (sender, receiver, subject, msg, added)
             VALUES (0, $userid, $subject, $msg, $added)") or sqlerr(__file__, __line__);
   }
    /// Set Forum posting possible Time based
    if (isset($_POST['forumpost']) && ($forumpost =
    0 + $_POST['forumpost']))
    {
    unset($forumdisable_pm);
    if (isset($_POST['forumdisable_pm']))
        $forumdisable_pm = $_POST['forumdisable_pm'];
    $subject = sqlesc('Notification!');
    $added = time();
   
    if ($forumpost == 255)
    {
        $modcomment = get_date($added, 'DATE', 1)." - Forum Posting disablement by ".
$CURUSER['username'].".\nReason: $forumdisable_pm\n".$modcomment;
        $msg = sqlesc("Your posting rights have been disabled by ".$CURUSER['username'].($forumdisable_pm ?
            "\n\nReason: $forumdisable_pm" : ''));
        $updateset[] = 'forumpost = 0';
    } elseif ($forumpost == 42)
    {
        $modcomment = get_date($added, 'DATE', 1)." - Posting disablement status removed by ".
$CURUSER['username'].".\n".$modcomment;
        $msg = sqlesc("Your posting rights have been restored by ".
$CURUSER['username'].".");
$updateset[] = 'forumpost = 1';
    } else
    {
        $forumpost_until = ($added + $forumpost * 604800);
        $dur = $forumpost.' week'.($forumpost > 1 ? 's' : '');
        $msg = sqlesc("You have received $dur Posting disablement from ".
$CURUSER['username'].($forumdisable_pm ? "\n\nReason: $forumdisable_pm" : ''));
        $modcomment = get_date($added, 'DATE', 1)." - Forum posting disablement for $dur by ".
$CURUSER['username'].".\nReason: $forumdisable_pm\n".$modcomment;
        $updateset[] = "forumpost = ".$forumpost_until;
    }

    mysql_query("INSERT INTO messages (sender, receiver, subject, msg, added)
             VALUES (0, $userid, $subject, $msg, $added)") or sqlerr(__file__, __line__);
   }
   /// Set shoutbox posssible Time based
    if (isset($_POST['chatpost']) && ($chatpost =
    0 + $_POST['chatpost']))
    {
    unset($chatdisable_pm);
    if (isset($_POST['chatdisable_pm']))
        $chatdisable_pm = $_POST['chatdisable_pm'];
    $subject = sqlesc('Notification!');
    $added = time();
   
    if ($chatpost == 255)
    {
        $modcomment = get_date($added, 'DATE', 1)." - Shout disablement by ".
$CURUSER['username'].".\nReason: $chatdisable_pm\n".$modcomment;
        $msg = sqlesc("Your Shoutbox rights have been disabled by ".$CURUSER['username'].($chatdisable_pm ?
            "\n\nReason: $chatdisable_pm" : ''));
        $updateset[] = 'chatpost = 0';
    } elseif ($chatpost == 42)
    {
        $modcomment = get_date($added, 'DATE', 1)." - Shoutbox disablement status removed by ".
$CURUSER['username'].".\n".$modcomment;
        $msg = sqlesc("Your Shoutbox rights have been restored by ".
$CURUSER['username'].".");
$updateset[] = 'chatpost = 1';
    } else
    {
        $chatpost_until = ($added + $chatpost * 604800);
        $dur = $chatpost.' week'.($chatpost > 1 ? 's' : '');
        $msg = sqlesc("You have received $dur Shoutbox disablement from ".
$CURUSER['username'].($chatdisable_pm ? "\n\nReason: $chatdisable_pm" : ''));
        $modcomment = get_date($added, 'DATE', 1)." - Shoutbox disablement for $dur by ".
$CURUSER['username'].".\nReason: $chatdisable_pm\n".$modcomment;
        $updateset[] = "chatpost = ".$chatpost_until;
    }

    mysql_query("INSERT INTO messages (sender, receiver, subject, msg, added)
             VALUES (0, $userid, $subject, $msg, $added)") or sqlerr(__file__, __line__);
   }
   /// Set Immunity Status Time based
    if (isset($_POST['immunity']) && ($immunity =
    0 + $_POST['immunity']))
    {
    unset($immunity_pm);
    if (isset($_POST['immunity_pm']))
        $immunity_pm = $_POST['immunity_pm'];
    $subject = sqlesc('Notification!');
    $added = time();

    if ($immunity == 255)
    {
        $modcomment = get_date($added, 'DATE', 1)." - Immune Status enabled by ".
$CURUSER['username'].".\nReason: $immunity_pm\n".$modcomment;
        $msg = sqlesc("You have received immunity Status from ".$CURUSER['username'].($immunity_pm ?
            "\n\nReason: $immunity_pm" : ''));
        $updateset[] = 'immunity = 1';
    } elseif ($immunity == 42)
    {
        $modcomment = get_date($added, 'DATE', 1)." - Immunity Status removed by ".
$CURUSER['username'].".\n".$modcomment;
        $msg = sqlesc("Your Immunity Status has been removed by ".
$CURUSER['username'].".");
$updateset[] = 'immunity = 0';
    } else
    {
        $immunity_until = ($added + $immunity * 604800);
        $dur = $immunity.' week'.($immunity > 1 ? 's' : '');
        $msg = sqlesc("You have received $dur Immunity Status from ".
$CURUSER['username'].($immunity_pm ? "\n\nReason: $immunity_pm" : ''));
        $modcomment = get_date($added, 'DATE', 1)." - Immunity Status for $dur by ".
$CURUSER['username'].".\nReason: $immunity_pm\n".$modcomment;
        $updateset[] = "immunity = ".$immunity_until;
    }

    mysql_query("INSERT INTO messages (sender, receiver, subject, msg, added)
             VALUES (0, $userid, $subject, $msg, $added)") or sqlerr(__file__, __line__);
   }
   /// Set leechwarn Status Time based
   if (isset($_POST['leechwarn']) && ($leechwarn =
   0 + $_POST['leechwarn']))
   {
   unset($leechwarn_pm);
    if (isset($_POST['leechwarn_pm']))
        $leechwarn_pm = $_POST['leechwarn_pm'];
    $subject = sqlesc('Notification!');
    $added = time();

    if ($leechwarn == 255)
    {
        $modcomment = get_date($added, 'DATE', 1)." - leechwarn Status enabled by ".
$CURUSER['username'].".\nReason: $leechwarn_pm\n".$modcomment;
        $msg = sqlesc("You have received leechwarn Status from ".$CURUSER['username'].($leechwarn_pm ?
            "\n\nReason: $leechwarn_pm" : ''));
        $updateset[] = 'leechwarn = 1';
    } elseif ($leechwarn == 42)
    {
        $modcomment = get_date($added, 'DATE', 1)." - leechwarn Status removed by ".
$CURUSER['username'].".\n".$modcomment;
        $msg = sqlesc("Your leechwarn Status has been removed by ".
$CURUSER['username'].".");
$updateset[] = 'leechwarn = 0';
    } else
    {
        $leechwarn_until = ($added + $leechwarn * 604800);
        $dur = $leechwarn.' week'.($leechwarn > 1 ? 's' : '');
        $msg = sqlesc("You have received $dur leechwarn Status from ".
$CURUSER['username'].($leechwarn_pm ? "\n\nReason: $leechwarn_pm" : ''));
        $modcomment = get_date($added, 'DATE', 1)." - leechwarn Status for $dur by ".
$CURUSER['username'].".\nReason: $leechwarn_pm\n".$modcomment;
        $updateset[] = "leechwarn = ".$leechwarn_until;
    }

    mysql_query("INSERT INTO messages (sender, receiver, subject, msg, added)
             VALUES (0, $userid, $subject, $msg, $added)") or sqlerr(__file__, __line__);
   }

   
   
@File download.php add :

,owner

to the query.

@File download.php add or replace the old with - add it under your user query :

if (!($CURUSER["id"] == $row["owner"])) {
if ($CURUSER["downloadpos"] == 0 || $CURUSER["downloadpos"] > 1 )
stderr("Error","Your download rights have been disabled.");
}

 
@File forums.php under :
 
$lang = array_merge( load_language('global'), load_language('forums') );
 
Add or replace the old with :

if ($CURUSER["forumpost"] == 0|| $CURUSER["forumpost"] > 1)
{
stderr($lang['forums_sorry'], $lang['forums_no_auth']);
}


@File upload.php under :
     
$HTMLOUT = '';
     
Add or replace the old with :

if ($CURUSER['class'] < UC_UPLOADER OR $CURUSER["uploadpos"] == 0|| $CURUSER["uploadpos"] > 1 )
stderr($lang['upload_sorry'], $lang['upload_no_auth']);


@File takeupload.php under :      
      
$lang = array_merge( load_language('global'), load_language('takeupload') );
   
Add or replace the old with :   
   
if ($CURUSER['class'] < UC_UPLOADER OR $CURUSER["uploadpos"] == 0|| $CURUSER["uploadpos"] > 1 )
header( "Location: {$TBDEV['baseurl']}/upload.php" );

      
@File shoutbox.php add or replace the old with  :

//==Shout disabled
if ($CURUSER['chatpost'] == 0|| $CURUSER['chatpost'] > 1)
{
$HTMLOUT .="<div class='error' align='center'><br /><font color='red'>Sorry, you are not authorized to Shout.</font>  (<a href=\"./rules.php\" target=\"_blank\"><font color='red'>Contact Site Admin For The Reason Why</font></a>)<br /><br /></div></body></html>";
exit;
}
//=End

      
@File details.php find :

$HTMLOUT .= "<tr><td class='rowhead' width='1%'>{$lang['details_download']}</td><td width='99%' align='left'><a class='index' href='download.php?torrent=$id'>" . htmlspecialchars($row["filename"]) . "</a></td></tr>";

Above it add or replace the old code with :

if (!($CURUSER["downloadpos"] == 0 && $CURUSER["id"] != $row["owner"] OR $CURUSER["downloadpos"] > 1)) {

Under :

$HTMLOUT .= tr("{$lang['details_info_hash']}", preg_replace_callback('/./s', "hex_esc", hash_pad($row["info_hash"])));
}[code]

Add :

[code]else {
$HTMLOUT .= tr("{$lang['details_download']}", "{$lang['details_dloadpos']}");
}


@File lang/en/lang_details.php add :

'details_dloadpos' => "You are not allowed to download !",
      
@File announce.php add :   
      
, downloadpos

Into the $user_query

@File announce.php change :      
      
if ($user["downloadpos"] == "no")
err("Your downloading priviledges have been disabled! (Read the rules)");

      
To :      
      
if ($user["downloadpos"] == 0 OR $user["downloadpos"] > 1 )
err("Your downloading priviledges have been disabled! (Read the rules)");

      
@File cleanup.php add :      
      
mysql_query("UPDATE `users` SET `downloadpos` = 1 WHERE `downloadpos` > 1 AND `downloadpos` < ".TIME_NOW) or sqlerr(__FILE__, __LINE__);
mysql_query("UPDATE `users` SET `uploadpos` = 1 WHERE `uploadpos` > 1 AND `uploadpos` < ".TIME_NOW) or sqlerr(__FILE__, __LINE__);
mysql_query("UPDATE `users` SET `forumpost` = 1 WHERE `forumpost` > 1 AND `forumpost` < ".TIME_NOW) or sqlerr(__FILE__, __LINE__);
mysql_query("UPDATE `users` SET `chatpost` = 1 WHERE `chatpost` > 1 AND `chatpost` < ".TIME_NOW) or sqlerr(__FILE__, __LINE__);
mysql_query("UPDATE `users` SET `immunity` = 0 WHERE `immunity` > 1 AND `immunity` < ".TIME_NOW) or sqlerr(__FILE__, __LINE__);
mysql_query("UPDATE `users` SET `leechwarn` = 0 WHERE `leechwarn` > 1 AND `leechwarn` < ".TIME_NOW) or sqlerr(__FILE__, __LINE__);
   
      
@File cleanup for Leech warnings add or replace old code with this :
   
    //09 Auto leech warn
    // /==Updated/modified autoleech warning script////
    $minratio = 0.3; // ratio < 0.4
    $downloaded = 10 * 1024 * 1024 * 1024; // + 10 GB
    $length = 3 * 7; // Give 3 weeks to let them sort there shit
    $res = mysql_query("SELECT id FROM users WHERE enabled='yes' AND class = ".UC_USER." AND leechwarn = '0' AND uploaded / downloaded < $minratio AND downloaded >= $downloaded AND immunity = '0'") or sqlerr(__FILE__, __LINE__);
    $msgs_buffer = $users_buffer = array();
    if (mysql_num_rows($res) > 0) {
        $dt = sqlesc(time());
        $subject = "Auto leech warned";
        $msg = "You have been warned and your download rights have been removed due to your low ratio. You need to get a ratio of 0.5 within the next 3 weeks or your Account will be disabled.";
        $leechwarn = sqlesc(time() + ($length * 86400));
        while ($arr = mysql_fetch_assoc($res)) {
            $modcomment = sqlesc(get_date( time(), 'DATE', 1 ) . " - Automatically Leech warned and downloads disabled By System\n");
            $msgs_buffer[] = '(0,' . $arr['id'] . ', '.time().', ' . sqlesc($msg) . ', ' . sqlesc($subject) . ')';
            $users_buffer[] = '(' . $arr['id'] . ',' . $leechwarn . ',\'0\', ' . $modcomment . ')';
        }
        if (sizeof($msgs_buffer) > 0) {
            mysql_query("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer)) or sqlerr(__FILE__, __LINE__);
            mysql_query("INSERT INTO users (id, leechwarn, downloadpos, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE leechwarn=values(leechwarn),
            downloadpos=values(downloadpos),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__);
            $count = mysql_affected_rows();
            write_log("Cleanup: System applied auto leech Warning(s) to  " . $count / 2 . " Member(s)");
        }
        unset ($users_buffer);
        unset ($msgs_buffer);
    }
    //End
    //09 Auto leech warn
    // ==Updated/Modified autoleech warn system - Remove warning and enable downloads
    $minratio = 0.5; // ratio > 0.5
    $res = mysql_query("SELECT id FROM users WHERE downloadpos = '0' AND leechwarn > '1' AND uploaded / downloaded >= $minratio") or sqlerr(__FILE__, __LINE__);
    $msgs_buffer = $users_buffer = array();
    if (mysql_num_rows($res) > 0) {
       $subject = "Auto leech warning removed";
        $msg = "Your warning for a low ratio has been removed and your downloads enabled. We highly recommend you to keep your ratio positive to avoid being automatically warned again.\n";
        while ($arr = mysql_fetch_assoc($res)) {
            $modcomment = sqlesc(get_date( time(), 'DATE', 1 ) . " - Leech warn removed and download enabled By System\n");
            $msgs_buffer[] = '(0,' . $arr['id'] . ','.time().', ' . sqlesc($msg) . ',  ' . sqlesc($subject) . ')';
            $users_buffer[] = '(' . $arr['id'] . ', \'0\', \'1\', ' . $modcomment . ')';
        }
        if (sizeof($msgs_buffer) > 0) {
            mysql_query("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer)) or sqlerr(__FILE__, __LINE__);
            mysql_query("INSERT INTO users (id, leechwarn, downloadpos, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE leechwarn=values(leechwarn),
            downloadpos=values(downloadpos),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__);
            $count = mysql_affected_rows();
            write_log("Cleanup: System removed auto leech Warning(s) and renabled download(s) - " . $count / 2 . " Member(s)");
        }
        unset ($users_buffer);
        unset ($msgs_buffer);
    }
    //==End
    //09 Auto leech warn
    //==Disabled expired leechwarns
    $res = mysql_query("SELECT id FROM users WHERE leechwarn > '1' AND leechwarn < ".TIME_NOW." AND leechwarn <> '0' ") or sqlerr(__FILE__, __LINE__);
    $users_buffer = array();
    if (mysql_num_rows($res) > 0) {
        while ($arr = mysql_fetch_assoc($res)) {
            $modcomment = sqlesc(get_date( time(), 'DATE', 1 ) . " - User disabled - Low ratio\n");
            $users_buffer[] = '(' . $arr['id'] . ' , \'0\', \'no\', ' . $modcomment . ')';
        }
        if (sizeof($users_buffer) > 0) {
            mysql_query("INSERT INTO users (id, leechwarn, enabled, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE class=values(class),
            leechwarn=values(leechwarn),enabled=values(enabled),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__);
            $count = mysql_affected_rows();
            write_log("Cleanup: Disabled " . $count / 2 . " Member(s) - Leechwarns expired");
        }
        unset ($users_buffer);
    }
    //==End

   
And thats it - Remember to back up your scripts before doing this modification - Refer to the upload/download/forum Priviliges mod for 09 if you get stuck as this is a rewrite of that full system with other options included as well.