09 Add & Subtract Upload & Download

Started by Mindless, July 21, 2012, 09:45:46 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nam3less


spark

This is one cool Mod

It'll add two fields on the user profile which you can use (as an admin) to set the upload and download amount for any user




You may want to insert the first piece of code in Mindless' last post before the green commented line at the end of userdetails.php, but certainly not after the "submit".




Paste the second piece of code before "Change Custom Title" in modtask.php






Thanks Mindless & of course Retro




Daniel

my have to translate it so i better figure it out : )

Mindless

Post title; Add or Subract a members upload or download data from userdetails.

Daniel

what does this mod  do  , not sure i follow it  .

Mindless

Credits to Retro
Can also use a system similar to the following...

In userdetails.php, within the staff tools section.

Code (php) Select
$HTMLOUT .="<tr><td class='rowhead'>Amount Uploaded</td><td colspan='2' align='left'>"."<input type='text' size='40' name='uploaded' value=\"".htmlspecialchars($user["uploaded"])."\" />&nbsp;Bytes<input type='hidden' name='uploadbase' value=\"".htmlspecialchars($user["uploaded"])."\" /></td></tr><tr><td class='rowhead'>Amount Downloaded</td><td colspan='2' align='left'>"."<input type='text' size='40' name='downloaded' value=\"".htmlspecialchars($user["downloaded"])."\" />&nbsp;Bytes<input type='hidden' name='downloadbase' value=\"".htmlspecialchars($user["downloaded"])."\" /></td></tr>\n";

and in modtask.php...

   
Code (php) Select
// Change Uploaded Amount
if (((isset($_POST['uploaded'])) && (isset($_POST['uploadbase'])) && (($uploaded = $_POST['uploaded']) != ($uploadbase = $_POST['uploadbase']))))
{
if ($uploaded < $uploadbase)
$modcomment = get_date( time(), 'DATE', 1 ) . " - {$lang['modtask_upreduce']}Upload reduced to ".$uploaded." from ".$uploadbase." {$lang['modtask_by']} " . $CURUSER['username'] . ".\n" . $modcomment;
else
$modcomment = get_date( time(), 'DATE', 1 ) . " - {$lang['modtask_upincrease']}Upload increased to ".$uploaded." from ".$uploadbase." {$lang['modtask_by']} " . $CURUSER['username'] . ".\n" . $modcomment;

$updateset[] = "uploaded = " . sqlesc($uploaded);
}

// Change Downloaded Amount
if (((isset($_POST['downloaded'])) && (isset($_POST['downloadbase'])) && (($downloaded = $_POST['downloaded']) != ($downloadbase = $_POST['downloadbase']))))
{
if ($downloaded < $downloadbase)
$modcomment = get_date( time(), 'DATE', 1 ) . " - {$lang['modtask_dwreduce']}Download reduced to ".$downloaded." from ".$downloadbase."{$lang['modtask_by']}  " . $CURUSER['username'] . ".\n" . $modcomment;
else
$modcomment = get_date( time(), 'DATE', 1 ) . " - {$lang['modtask_dwincrese']}Download increased to ".$downloaded." from ".$downloadbase." {$lang['modtask_by']} " . $CURUSER['username'] . ".\n" . $modcomment;

$updateset[] = "downloaded = " . sqlesc($downloaded);
}

Mindless

Add subtract upload/download - posted by jaits - Updated for 09 :)
 
@ file userdetails under : 

Code (php) Select
$HTMLOUT='';

Add this :

Code (php) Select
$HTMLOUT .="<script type='text/javascript'>
function togglepic(bu, picid, formid){
var pic = document.getElementById(picid);
var form = document.getElementById(formid);

if(pic.src == bu + '/pic/plus.gif') {
pic.src = bu + '/pic/minus.gif';
form.value = 'minus';
}else{
pic.src = bu + '/pic/plus.gif';
form.value = 'plus';
}
}
</script>";


Add this into your admin tool section down the bottom

Code (php) Select
if ($CURUSER['class']>= UC_ADMINISTRATOR){
      $HTMLOUT .="<tr>
      <td class='rowhead'>{$lang['userdetails_addupload']}</td>
      <td align='center'>
      <img src='{$TBDEV['pic_base_url']}plus.gif' alt='Change Ratio' title='Change Ratio !' id='uppic' onclick=\"togglepic('{$TBDEV['baseurl']}', 'uppic','upchange')\" />
      <input type='text' name='amountup' size='10' />
      </td>
      <td>
      <select name='formatup'>\n
      <option value='mb'>{$lang['userdetails_MB']}</option>\n
      <option value='gb'>{$lang['userdetails_GB']}</option></select>\n
      </td>
      </tr>
      <tr>
      <td class='rowhead'>{$lang['userdetails_adddownload']}</td>
      <td align='center'>
      <img src='{$TBDEV['pic_base_url']}plus.gif' alt='Change Ratio' title='Change Ratio !' id='downpic' onclick=\"togglepic('{$TBDEV['baseurl']}','downpic','downchange')\" />
      <input type='text' name='amountdown' size='10' />
      </td>
      <td>
      <select name='formatdown'>\n
      <option value='mb'>{$lang['userdetails_MB']}</option>\n
      <option value='gb'>{$lang['userdetails_GB']}</option></select>\n
      <input type='hidden' id='upchange' name='upchange' value='plus' />
      <input type='hidden' id='downchange' name='downchange' value='plus' />
      </td></tr>";
      }


@ file modtask.php add :

Code (php) Select
/// Add remove uploaded
  if ($CURUSER['class'] >= UC_ADMINISTRATOR) {
$uploadtoadd = 0 + $_POST["amountup"];
$downloadtoadd = 0 +  $_POST["amountdown"];
$formatup = $_POST["formatup"];
$formatdown = $_POST["formatdown"];
$mpup = $_POST["upchange"];
$mpdown = $_POST["downchange"];
if($uploadtoadd > 0) {
if($mpup == "plus"){
$newupload = $user["uploaded"] + ($formatup == 'mb' ? ($uploadtoadd * 1048576) : ($uploadtoadd * 1073741824));
$modcomment = get_date( time(), 'DATE', 1 ) . " {$lang['modtask_add_upload']} (".$uploadtoadd." ".$formatup .") {$lang['modtask_by']} " . $CURUSER['username'] ."\n" . $modcomment;
}
else{
$newupload = $user["uploaded"] - ($formatup == 'mb' ? ($uploadtoadd * 1048576) : ($uploadtoadd * 1073741824));
if ($newupload >= 0)
$modcomment =  get_date( time(), 'DATE', 1 ) . " {$lang['modtask_subtract_upload']} (".$uploadtoadd." ".$formatup .") {$lang['modtask_by']} " . $CURUSER['username'] ."\n" . $modcomment;
}
if ($newupload >= 0)
$updateset[] =  "uploaded = ".sqlesc($newupload)."";
}

if($downloadtoadd > 0) {
if($mpdown == "plus"){
$newdownload = $user["downloaded"] + ($formatdown == 'mb' ? ($downloadtoadd * 1048576) : ($downloadtoadd * 1073741824));
$modcomment = get_date( time(), 'DATE', 1 ) . " {$lang['modtask_added_download']} (".$downloadtoadd." ".$formatdown .") {$lang['modtask_by']} " . $CURUSER['username'] ."\n" . $modcomment;
}
else{
$newdownload = $user["downloaded"] - ($formatdown == 'mb' ? ($downloadtoadd * 1048576) : ($downloadtoadd * 1073741824));
if ($newdownload >= 0)
$modcomment = get_date( time(), 'DATE', 1 ) . " {$lang['modtask_subtract_download']} (".$downloadtoadd." ".$formatdown .") {$lang['modtask_by']} " . $CURUSER['username'] ."\n" . $modcomment;
}
if ($newdownload >= 0)
$updateset[] =  "downloaded = ".sqlesc($newdownload)."";
}
}
/// End add/remove upload

   
@ file lang/en/lang_modtask.php add :   
   
Code (php) Select
'modtask_subtract_download' => " - Subtracted Download",
'modtask_added_download' => " - Added Download",
'modtask_add_upload' => " - Added Upload",
'modtask_subtract_upload' => " - Subtracted Upload",


@ file lang/en/lang_userdetails.php add :   

Code (php) Select
'userdetails_addupload' => "Change Upload",
'userdetails_adddownload' => "Change Download",
'userdetails_GB' => "GB",
'userdetails_MB' => "MB",