Thread: 10%
View Single Post
  #1  
Old 11th November 2010, 18:04
lafouine022 lafouine022 is offline
Senior Member
 
Join Date: Feb 2010
P2P
Posts: 120
Smile 10%
This allows users to add 10% of their current upload amount to their upload amount once, at any time they chose.

SQL:
PHP Code:
ALTER TABLE `usersADD `tenpercentENUM('yes','no'NOT NULL default 'no'
and tenpercent.php:

PHP Code:
<?
include_once("global.php");
dbconn();
loggedinorreturn();

$uploaded $CURUSER["uploaded"];
$downloaded $CURUSER["downloaded"];
$newuploaded = ($uploaded 1.1);

if (
$downloaded 0) {
  
$ratio number_format($uploaded $downloaded3);
  
$newratio number_format($newuploaded $downloaded3);
  
$ratiochange number_format(($newuploaded $downloaded) - ($uploaded $downloaded), 3);
} elseif (
$uploaded 0)
  
$ratio $newratio $ratiochange "Inf.";
else
  
$ratio $newratio $ratiochange "---";

if (
$_SERVER["REQUEST_METHOD"] == "POST") {

  if (
$CURUSER["tenpercent"] == "yes")
    
stderr("Used""It appears that you have already used your 10% addition.");

  
$sure $_POST["sure"];

  if (!
$sure)
    
stderr("Are you sure?""It appears that you are not yet sure whether you want to add 10% to your upload or not. Once you are sure you can <a href=tenpercent.php>return</a> to the 10% page.");

  
$time date("F j Y");
  
$subject "10% Addition";
  
$msg "Today, $time, you have increased your total upload amount by 10% from [b]".mksize($uploaded)."[/b] to [b]".mksize($newuploaded)."[/b], which brings your ratio to [b]".$newratio."[/b].";

  
$res mysql_query("UPDATE users SET uploaded = uploaded * 1.1, tenpercent = 'yes' WHERE id = $CURUSER[id]") or sqlerr(__FILE____LINE__);
  
$res1 mysql_query("INSERT INTO messages (sender, poster, receiver, subject, msg, added) VALUES (0, 0, $CURUSER[id], ".sqlesc($subject).", ".sqlesc($msg).", '".get_date_time()."')") or sqlerr(__FILE____LINE__);

  if (!
$res)
    
stderr("Error""It appears that something went wrong while trying to add 10% to your upload amount.");
  else
    
stderr("10% Added""Your total upload amount has been increased by 10% from <b>".mksize($uploaded)."</b> to <b>".mksize($newuploaded)."</b>, which brings your ratio to <b>$newratio</b>.");
}

?>
<style type=text/css>
  td.normal {
    background: #990000;
  }

  td.normalrowhead {
    font-weight: bold;
    text-align: right;
    background: #990000;
  }
</style>
<?

if ($CURUSER["tenpercent"] == "no") {
  
?>
  <script language=javascript>
  function enablesubmit() {
    document.tenpercent.submit.disabled = document.tenpercent.submit.checked;
  }
  function disablesubmit() {
    document.tenpercent.submit.disabled = !document.tenpercent.submit.checked;
  }
  </script>
  <?
}

stdhead("10%");
begin_table (true);
if (
$CURUSER["tenpercent"] == "yes")
  print(
"<h2>It appears that you have already used your 10% addition</h2>\n");
 
print(
"<div align=center><table border=6 width=100% cellspacing=0 cellpadding=5><tr><td class=thead align=center><font size=2>10%</font>
 </td></tr></div><td class=subheader align=left>
 
 <font size=2><b>add 10%</b></font></td></table>"
);
 
 
print (
'<table cellpadding="1" cellspacing="0" width="100%" align="center" >
    
    <tr>
        <td rowspan="'
.$rowspan.'" align="center" valign="top" width="100%">');

print(
"<p><table width=750 border=0 cellspacing=0 cellpadding=5><tr><td\n");
print(
"<table width=100% border=0 cellspacing=0 cellpadding=10><tr><td style='padding-bottom: 0px'>\n");
print(
"<p><b>How it works:</b></p>");
print(
"<p class=sub>From this page you can <b>add 10%</b> of your current upload amount to your upload amount bringing it it to <b>110%</b> of its current amount. More details about how this would work out for you can be found in the tables below.</p>");
print(
"<br><p><b>However, there are some things you should know first:</b></p>");
print(
"<li>This can only be done <b>once</b>, so chose your moment wisely.");
print(
"<li>The staff will <b>not</b> reset your 10% addition for any reason.");
print(
"</td></tr></table>\n");
print(
"</td></tr></table></p>\n");
print(
"<p><table width=650 class=main align=center border=0 cellspacing=0 cellpadding=5>\n");
print(
"<tr><td class=normalrowhead>Current&nbsp;upload&nbsp;amount:</td><td class=normal>".str_replace(" ""&nbsp;"mksize($uploaded))."</td><td class=embedded width=5%></td><td class=normalrowhead>Increase:</td><td class=normal>".str_replace(" ""&nbsp;"mksize($newuploaded $uploaded))."</td><td class=embedded width=5%></td><td class=normalrowhead>New&nbsp;upload&nbsp;amount:</td><td class=normal>".str_replace(" ""&nbsp;"mksize($newuploaded))."</td></tr>\n");
print(
"<tr><td class=normalrowhead>Current&nbsp;download&nbsp;amount:</td><td class=normal>".str_replace(" ""&nbsp;"mksize($downloaded))."</td><td class=embedded width=5%></td><td class=normalrowhead>Increase:</td><td class=normal>".str_replace(" ""&nbsp;"mksize(0))."</td><td class=embedded width=5%></td><td class=normalrowhead>New&nbsp;download&nbsp;amount:</td><td class=normal>".str_replace(" ""&nbsp;"mksize($downloaded))."</td></tr>\n");
print(
"<tr><td class=normalrowhead>Current&nbsp;ratio:</td><td class=normal>$ratio</td><td class=embedded width=5%></td><td class=normalrowhead>Increase:</td><td class=normal>$ratiochange</td><td class=embedded width=5%></td><td class=normalrowhead>New&nbsp;ratio:</td><td class=normal>$newratio</td></tr>\n");
print(
"</table></p>\n");
print(
"<p><table align=center border=0 cellspacing=0 cellpadding=5><form name=tenpercent method=post action=tenpercent.php>\n");
print(
"<tr><td align=center><b>Yes please </b><input type=checkbox name=sure value=yes onclick='if (this.checked) enablesubmit(); else disablesubmit();'></td></tr>\n");
print(
"<tr><td align=center><input type=submit name=submit value='Add 10%' class=btn disabled></td></tr>\n");
print(
"</form></table></p></td></tr></table>\n");
end_table ();
stdfoot ();
?>
Enjoy! :bubble:
Attached Thumbnails
10 pour.png  
Reply With Quote
The Following 5 Users Say Thank You to lafouine022 For This Useful Post:
FENIX (27th January 2013), Fynnon (12th November 2010), ghostrider2k (12th November 2010), Tingull (28th December 2010), Tory (12th November 2010)