PageRenderTime 28ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/tenpercent.php

https://github.com/Bigjoos/U-232-V3
PHP | 98 lines | 88 code | 0 blank | 10 comment | 14 complexity | cea4bf1c8a7605553f43799fa4e236a4 MD5 | raw file
  1. <?php
  2. /**
  3. * https://github.com/Bigjoos/
  4. * Licence Info: GPL
  5. * Copyright (C) 2010 U-232 v.3
  6. * A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.
  7. * Project Leaders: Mindless, putyn.
  8. *
  9. */
  10. require_once (dirname(__FILE__).DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'bittorrent.php');
  11. require_once (INCL_DIR.'user_functions.php');
  12. dbconn();
  13. loggedinorreturn();
  14. $HTMLOUT = '';
  15. $lang = array_merge(load_language('global'));
  16. $uploaded = 0 + $CURUSER["uploaded"];
  17. $downloaded = 0 + $CURUSER["downloaded"];
  18. $newuploaded = 0 + ($uploaded * 1.1);
  19. if ($downloaded > 0) {
  20. $ratio = number_format($uploaded / $downloaded, 3);
  21. $newratio = number_format($newuploaded / $downloaded, 3);
  22. $ratiochange = number_format(($newuploaded / $downloaded) - ($uploaded / $downloaded) , 3);
  23. } elseif ($uploaded > 0) $ratio = $newratio = $ratiochange = "Inf.";
  24. else $ratio = $newratio = $ratiochange = "---";
  25. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  26. if ($CURUSER["tenpercent"] == "yes") stderr("Used", "It appears that you have already used your 10% addition.");
  27. $sure = (isset($_POST['sure']) ? intval($_POST['sure']) : '');
  28. 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.");
  29. $time = TIME_NOW;
  30. $subject = "10% Addition";
  31. $msg = "Today, ".get_date($time, 'LONG', 0, 1).", 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].";
  32. $res = sql_query("UPDATE users SET uploaded = uploaded * 1.1, tenpercent = 'yes' WHERE id = ".sqlesc($CURUSER['id'])) or sqlerr(__FILE__, __LINE__);
  33. $update['uploaded'] = ($CURUSER['uploaded'] * 1.1);
  34. $mc1->begin_transaction('userstats_'.$CURUSER['id']);
  35. $mc1->update_row(false, array(
  36. 'uploaded' => $update['uploaded']
  37. ));
  38. $mc1->commit_transaction($INSTALLER09['expires']['u_stats']);
  39. $mc1->begin_transaction('user_stats_'.$CURUSER['id']);
  40. $mc1->update_row(false, array(
  41. 'uploaded' => $update['uploaded']
  42. ));
  43. $mc1->commit_transaction($INSTALLER09['expires']['user_stats']);
  44. $mc1->begin_transaction('user'.$CURUSER['id']);
  45. $mc1->update_row(false, array(
  46. 'tenpercent' => 'yes'
  47. ));
  48. $mc1->commit_transaction($INSTALLER09['expires']['user_cache']);
  49. $mc1->begin_transaction('MyUser_'.$CURUSER['id']);
  50. $mc1->update_row(false, array(
  51. 'tenpercent' => 'yes'
  52. ));
  53. $mc1->commit_transaction($INSTALLER09['expires']['user_cache']);
  54. $res1 = sql_query("INSERT INTO messages (sender, poster, receiver, subject, msg, added) VALUES (0, 0, ".sqlesc($CURUSER['id']).", ".sqlesc($subject).", ".sqlesc($msg).", '".TIME_NOW."')") or sqlerr(__FILE__, __LINE__);
  55. $mc1->delete_value('inbox_new_'.$CURUSER['id']);
  56. $mc1->delete_value('inbox_new_sb_'.$CURUSER['id']);
  57. if (!$res) stderr("Error", "It appears that something went wrong while trying to add 10% to your upload amount.");
  58. 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>.");
  59. }
  60. if ($CURUSER["tenpercent"] == "no") {
  61. $HTMLOUT.= "
  62. <script type='text/javascript'>
  63. /*<![CDATA[*/
  64. function enablesubmit() {
  65. document.tenpercent.submit.disabled = document.tenpercent.submit.checked;
  66. }
  67. function disablesubmit() {
  68. document.tenpercent.submit.disabled = !document.tenpercent.submit.checked;
  69. }
  70. /*]]>*/
  71. </script>";
  72. }
  73. if ($CURUSER["tenpercent"] == "yes") {
  74. stderr("Oops", "It appears that you have already used your 10% addition");
  75. exit();
  76. }
  77. $HTMLOUT.= "<h1>10&#37;</h1>
  78. <table width='700' border='0' cellspacing='0' cellpadding='5'>
  79. <tr>
  80. <td style='padding-bottom: 0px'>
  81. <p><b>How it works:</b></p>
  82. <p class='sub'>From this page you can <b>add 10&#37;</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>
  83. <br /><p><b>However, there are some things you should know first:</b></p><b>
  84. &#8226;&nbsp;This can only be done <b>once</b>, so chose your moment wisely.<br />
  85. &#8226;&nbsp;The staff will <b>not</b> reset your 10&#37; addition for any reason.<br /><br />
  86. </b></td></tr></table>
  87. <table width='650' class='main' align='center' border='0' cellspacing='0' cellpadding='5'>
  88. <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>
  89. <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>
  90. <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>
  91. </table>
  92. <form name='tenpercent' method='post' action='tenpercent.php'>
  93. <table align='center' border='0' cellspacing='0' cellpadding='5'>
  94. <tr><td align='center'><b>Yes please </b><input type='checkbox' name='sure' value='1' onclick='if (this.checked) enablesubmit(); else disablesubmit();' /></td></tr>
  95. <tr><td align='center'><input type='submit' name='submit' value='Add 10%' class='btn' disabled='disabled' /></td></tr>
  96. </table></form>\n";
  97. echo stdhead("Ten Percent").$HTMLOUT.stdfoot();
  98. ?>