forked from Bigjoos/U-232
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsitepot.php
More file actions
160 lines (124 loc) · 5.97 KB
/
sitepot.php
File metadata and controls
160 lines (124 loc) · 5.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
/**
* http://btdev.net:1337/svn/test/Installer09_Beta
* Licence Info: GPL
* Copyright (C) 2010 BTDev Installer v.1
* A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.
* Project Leaders: Mindless,putyn.
**/
/** sitepot.php by pdq for tbdev.net **/
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'bittorrent.php');
require_once(INCL_DIR.'user_functions.php');
dbconn();
loggedinorreturn();
$lang = array_merge( load_language('global') );
/** Size of Pot**/
$potsize = 6000;
/** Site Pot **/
$Pot_query = mysql_query("SELECT value_s, value_i, value_u FROM avps WHERE arg = 'sitepot'")
or sqlerr(__file__, __line__);
$SitePot = mysql_fetch_assoc($Pot_query) or stderr('ERROR', 'db error.');
if ($SitePot['value_u'] < TIME_NOW && $SitePot['value_s'] == '1')
{
mysql_query("UPDATE avps SET value_i = 0, value_s = '0' WHERE arg = 'sitepot'")
or sqlerr(__file__, __line__);
header('Location: sitepot.php');
die();
}
if ($SitePot['value_i'] == $potsize)
stderr('Site Pot is Full', 'Freeleech ends at: '.get_date($SitePot['value_u'], 'DATE').
' ('.mkprettytime($SitePot['value_u'] - TIME_NOW).' to go).');
$want_pot = (isset($_POST['want_pot']) ? (int)$_POST['want_pot'] : '');
/** Valid amounts can give **/
$pot_options = array(1 => 1, 5 => 5, 10 => 10, 25 => 25, 50 => 50, 100 => 100,
500 => 500, 1000 => 1000, 2500 => 2500, 5000 => 5000, 10000 => 10000, 50000 =>
50000);
if ($want_pot && (isset($pot_options[$want_pot])))
{
if ($CURUSER['seedbonus'] < $want_pot)
stderr('Error', 'Not enough karma.');
$give = ($SitePot['value_i'] + $want_pot);
if ($give > $potsize)
$want_pot = ($potsize - $SitePot['value_i']);
if (($SitePot['value_i'] + $want_pot) != $potsize)
{
$Remaining = $potsize - $give;
mysql_query("UPDATE users SET seedbonus = seedbonus - ".sqlesc($want_pot)."
WHERE id = ".sqlesc($CURUSER['id'])."")
or sqlerr(__file__, __line__);
write_log("Site Pot ".$CURUSER['username']." has donated ".$want_pot.
" karma points to the site pot. {$Remaining} karma points remaining.");
mysql_query("UPDATE avps SET value_i = value_i + ".sqlesc($want_pot)."
WHERE arg = 'sitepot'")
or sqlerr(__file__, __line__);
/** shoutbox announce **/
require_once(INCL_DIR.'bbcode_functions.php');
$msg = $CURUSER['username']. " put ".$want_pot." karma point".($want_pot > 1?'s':'')." into the site pot! * Only [b]".$Remaining."[/b] more karma point".($Remaining > 1?'s':'')." to go! * [color=green][b]Site Pot:[/b][/color] [url={$TBDEV['baseurl']}/sitepot.php]". $give ."/".$potsize.'[/url]';
autoshout($msg);
header('Location: sitepot.php');
die();
}
elseif (($SitePot['value_i'] + $want_pot) == $potsize)
{
//$bonuscomment = gmdate("Y-m-d") . " - User has donated ".$want_pot." to the site pot.\n" . $CURUSER["modcomment"];
//mysql_query("UPDATE users SET seedbonus = seedbonus - ".sqlesc($want_pot).", bonuscomment = concat(".sqlesc($bonuscomment).", bonuscomment) WHERE id = ".sqlesc($CURUSER['id'])."") or sqlerr(__FILE__, __LINE__);
mysql_query("UPDATE users SET seedbonus = seedbonus - ".sqlesc($want_pot)."
WHERE id = ".sqlesc($CURUSER['id'])."")
or sqlerr(__file__, __line__);
write_log("Site Pot ".$CURUSER['username']." has donated ".$want_pot.
" karma points to the site pot.");
mysql_query("UPDATE avps SET value_i = value_i + ".sqlesc($want_pot).",
value_u = '".(86400 + TIME_NOW)."',
value_s = '1' WHERE arg = 'sitepot'")
or sqlerr(__file__,__line__);
write_log("24 HR FREELEECH is now active! It was started on ".get_date(TIME_NOW, 'DATE').
".");
/** shoutbox announce **/
require_once(INCL_DIR.'bbcode_functions.php');
$msg = " [color=green][b]24 HR FREELEECH[/b][/color] is now active! It will end at ".get_date($SitePot['value_u'], 'DATE');
autoshout($msg);
header('Location: sitepot.php');
die();
}
else
stderr('Error', 'Something strange happened, reload the page and try again.');
}
// comment following if not use tbdev 09
$HTMLOUT = '';
// comment ALL '$HTMLOUT.=' and replace with 'echo' following if not use tbdev 09
$HTMLOUT .= "<table cellpadding='10' width='70%'>
<tr><td align='center' colspan='3'>Once the Site Pot has <b>".$potsize."</b> karma points,
Freeleech will be turned on for everybody for 24 hours.
<p align='center'><font size='+1'>
<b>Site Pot: ".$SitePot['value_i']."/".$potsize."</b>
</font></p>You have <b>".round($CURUSER['seedbonus'], 1)."</b> karma points.<br />
</td></tr>";
$HTMLOUT .= '<tr><td><b>Description</b></td><td><b>Amount</b></td><td><b>Exchange</b></td></tr>';
foreach ($pot_options as $Pot_option)
{
if (($CURUSER['seedbonus'] < $Pot_option))
{
$disabled = 'true';
} else
{
$disabled = 'false';
}
$HTMLOUT .= "<tr><td><b>Contribute ".$Pot_option." Karma Points</b><br /></td>
<td><strong>".$Pot_option."</strong></td>
<td>
<form action='' method='post'>
<div class=\"buttons\">
<input name='want_pot' type='hidden' value='".$Pot_option."' />
<button value='Exchange!' ".
($disabled == 'true' ? "disabled='disabled'" : '')." type=\"submit\" class=\"positive\">
<img src=\"pic/plus.gif\" alt=\"\" /> Exchange!
</button>
</div>
</form>
</td>
</tr>";
}
$HTMLOUT .= '</table>';
// comment following if not use tbdev 09
print stdhead('Site Pot').$HTMLOUT.stdfoot();
?>