-
Notifications
You must be signed in to change notification settings - Fork 10
/
casino.php
540 lines (531 loc) · 29.2 KB
/
casino.php
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
<?php
/**
* ------- U-232 Codename Trinity ----------*
* ---------------------------------------------*
* -------- @authors U-232 Team --------------*
* ---------------------------------------------*
* ----- @site https://u-232.duckdns.org/ ----*
* ---------------------------------------------*
* ----- @copyright 2020 U-232 Team ----------*
* ---------------------------------------------*
* ------------ @version V6 ------------------*
*/
require_once(__DIR__.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'bittorrent.php');
require_once(INCL_DIR.'user_functions.php');
require_once INCL_DIR.'html_functions.php';
//== Updated casino.php by Bigjoos
dbconn(false);
loggedinorreturn();
$lang = array_merge(load_language('global'), load_language('casino'));
//== Config
$amnt = $nobits = $abcdefgh = 0;
$dummy = '';
$player = UC_USER;
$mb_basic = 1024 * 1024;
$max_download_user = $mb_basic * 1024 * 1024; //= 255 Gb
$max_download_global = $mb_basic * $mb_basic * 1; //== 10.0 Tb
$required_ratio = 0.5; //== Min ratio
$user_everytimewin_mb = $mb_basic * 20; //== Means users that wins under 70 mb get a cheat_value of 0 -> win every time
$cheat_value = 8; //== Higher value -> less winner
$cheat_breakpoint = 10; //== Very important value -> if (win MB > max_download_global/cheat_breakpoint)
$cheat_value_max = 2; //== Then cheat_value = cheat_value_max -->> i hope you know what i mean. ps: must be higher as cheat_value.
$cheat_ratio_user = .4; //== If casino_ratio_user > cheat_ratio_user -> $cheat_value = rand($cheat_value,$cheat_value_max)
$cheat_ratio_global = .4; //== Same as user just global
$win_amount = 3; //== How much do the player win in the first game eg. bet 300, win_amount=3 ---->>> 300*3= 900 win
$win_amount_on_number = 6; //== Same as win_amount for the number game
$show_real_chance = false; //== Shows the user the real chance true or false
$bet_value1 = 1024 * 1024 * 200; //== This is in MB but you can also choose gb or tb
$bet_value2 = 1024 * 1024 * 500;
$bet_value3 = 1024 * 1024 * 1020;
$bet_value4 = 1024 * 1024 * 2560;
$bet_value5 = 1024 * 1024 * 5120;
$bet_value6 = 1024 * 1024 * 10240;
$bet_value7 = 1024 * 1024 * 20480;
$minclass = $player; //== Lowest class allowed to play
$maxusrbet = 4; //==Amount of bets to allow per person
$maxtotbet = 30; //== Amount of total open bets allowed
$alwdebt = 0; //== Allow users to get into debt
$writelog = 1; //== Writes results to log
$delold = 1; //== Clear bets once finished
$sendfrom = 2; //== The id of the user which notification PM's are noted as sent from
$casino = 'casino.php'; //== Name of file
//== End of Config
if ($CURUSER["game_access"] == 0 || $CURUSER["game_access"] > 1 || $CURUSER['suspended'] == 'yes') {
stderr($lang['gl_error'], $lang['casino_your_gaming_rights_have_been_disabled']);
exit();
}
($sql = sql_query('SELECT uploaded, downloaded '.'FROM users '.'WHERE id = '.sqlesc($CURUSER['id']))) || sqlerr(__FILE__, __LINE__);
$User = $sql->fetch_assoc();
$User['uploaded'] = $User['uploaded'];
$User['downloaded'] = $User['downloaded'];
//== Reset user gamble stats!
$hours = 2; //== Hours to wait after using all tries, until they will be restarted
$dt = TIME_NOW - $hours * 3600;
$res = sql_query("SELECT userid, trys, date, enableplay FROM casino WHERE date < $dt AND trys >= '51' AND enableplay = 'yes'");
while ($arr = $res->fetch_assoc()) {
sql_query("UPDATE casino SET trys='0' WHERE userid=".sqlesc($arr['userid'])) || sqlerr(__FILE__, __LINE__);
}
if ($CURUSER['class'] < $player) {
stderr($lang['gl_sorry'],
"".htmlsafechars($CURUSER["username"])." {$lang['casino_the_moderators_do_not_allow_your_class']} ".get_user_class_name($player)." {$lang['casino_to_play_casino']}");
}
$query = "SELECT * from casino where userid = ".sqlesc($CURUSER['id'])."";
($result = sql_query($query)) || sqlerr(__FILE__, __LINE__);
if ($mysqli->affected_rows != 1) {
sql_query("INSERT INTO casino (userid, win, lost, trys, date) VALUES(".sqlesc($CURUSER["id"]).", 0, 0, 0,".TIME_NOW.")") || sqlerr(__FILE__,
__LINE__);
($result = sql_query($query)) || sqlerr(__FILE__, __LINE__);
}
$row = $result->fetch_assoc();
$user_win = $row["win"] ?? '';
$user_lost = $row["lost"] ?? '';
$user_trys = isset($row["trys"]) ? (int)$row["trys"] : '';
$user_date = isset($row["date"]) ? (int)$row["date"] : '';
$user_deposit = $row["deposit"] ?? '';
$user_enableplay = isset($row["enableplay"]) ? htmlsafechars($row["enableplay"]) : '';
if ($user_enableplay == "no") {
stderr($lang['gl_sorry'], "".htmlsafechars($CURUSER["username"])." {$lang['casino_your_banned_from_casino']}");
}
if (is_numeric($user_win) && is_numeric($user_lost) && ($user_win - $user_lost) > $max_download_user) {
stderr($lang['gl_sorry'], "".htmlsafechars($CURUSER["username"])." {$lang['casino_you_have_reached_the_max_dl_for_a_single_user']}");
}
if ($CURUSER["downloaded"] > 0) {
$ratio = number_format($CURUSER["uploaded"] / $CURUSER["downloaded"], 2);
} elseif ($CURUSER["uploaded"] > 0) {
$ratio = 999;
} else {
$ratio = 0;
}
if ($TRINITY20['ratio_free'] === false && $ratio < $required_ratio) {
stderr($lang['gl_sorry'], "".htmlsafechars($CURUSER["username"])." {$lang['casino_your_ratio_is_under']} {$required_ratio}");
}
($global_down2 = sql_query("SELECT (sum(win)-sum(lost)) AS globaldown,(sum(deposit)) AS globaldeposit, sum(win) AS win, sum(lost) AS lost FROM casino")) || sqlerr(__FILE__,
__LINE__);
$row = $global_down2->fetch_assoc();
$global_down = $row["globaldown"];
$global_win = $row["win"];
$global_lost = $row["lost"];
$global_deposit = $row["globaldeposit"];
if ($user_win > 0) {
$casino_ratio_user = number_format($user_lost / $user_win, 2);
} elseif ($user_lost > 0) {
$casino_ratio_user = 999;
} else {
$casino_ratio_user = 0.00;
}
if ($global_win > 0) {
$casino_ratio_global = number_format($global_lost / $global_win, 2);
} elseif ($global_lost > 0) {
$casino_ratio_global = 999;
} else {
$casino_ratio_global = 0.00;
}
if ($user_win < $user_everytimewin_mb) {
$cheat_value = 8;
} else {
if ($global_down > ($max_download_global / $cheat_breakpoint)) {
$cheat_value = $cheat_value_max;
}
if ($casino_ratio_global < $cheat_ratio_global) {
$cheat_value = random_int($cheat_value, $cheat_value_max);
}
if (($user_win - $user_lost) > ($max_download_user / $cheat_breakpoint)) {
$cheat_value = $cheat_value_max;
}
if ($casino_ratio_user < $cheat_ratio_user) {
$cheat_value = random_int($cheat_value, $cheat_value_max);
}
}
if ($global_down > $max_download_global) {
stderr($lang['gl_sorry'],
"".htmlsafechars($CURUSER["username"])." {$lang['casino_but_global_max_win_is_above']} ".htmlsafechars(mksize($max_download_global)));
}
//== Updated post color/number by pdq
$goback = "<a href='$casino'>{$lang['casino_go_back']}</a>";
$color_options = [
'red' => 1,
'black' => 2,
];
$number_options = [
1 => 1,
2 => 1,
3 => 1,
4 => 1,
5 => 1,
6 => 1,
];
$betmb_options = [
$bet_value1 => 1,
$bet_value2 => 1,
$bet_value3 => 1,
$bet_value4 => 1,
$bet_value5 => 1,
$bet_value6 => 1,
$bet_value7 => 1,
];
$post_color = ($_POST['color'] ?? '');
$post_number = ($_POST['number'] ?? '');
$post_betmb = ($_POST['betmb'] ?? '');
if (isset($color_options[$post_color], $number_options[$post_number]) || isset($betmb_options[$post_betmb])) {
$betmb = $_POST["betmb"];
if (isset($_POST["number"])) {
$win_amount = $win_amount_on_number;
$cheat_value += 5;
$winner_was = (int)$_POST["number"];
} else {
$winner_was = htmlsafechars($_POST["color"]);
}
$win = $win_amount * $betmb;
if ($CURUSER["uploaded"] < $betmb) {
stderr($lang['gl_sorry'],
"".htmlsafechars($CURUSER["username"])." {$lang['casino_but_you_have_not_uploaded']} ".htmlsafechars(mksize($betmb)));
}
if (random_int(0, $cheat_value) === $cheat_value) {
sql_query("UPDATE users SET uploaded = uploaded + ".sqlesc($win)." WHERE id=".sqlesc($CURUSER["id"])) || sqlerr(__FILE__, __LINE__);
sql_query("UPDATE casino SET date = '".TIME_NOW."', trys = trys + 1, win = win + ".sqlesc($win)." WHERE userid=".sqlesc($CURUSER["id"])) || sqlerr(__FILE__,
__LINE__);
$update['uploaded'] = ($User['uploaded'] + $win);
//==stats
$cache->update_row($cache_keys['user_stats'].$CURUSER['id'], [
'uploaded' => $update['uploaded'],
], $TRINITY20['expires']['u_stats']);
$cache->update_row($cache_keys['user_statss'].$CURUSER['id'], [
'uploaded' => $update['uploaded'],
], $TRINITY20['expires']['user_stats']);
stderr($lang['casino_yes'],
"".htmlsafechars($winner_was)." {$lang['casino_is_the_result']} ".htmlsafechars($CURUSER["username"])." {$lang['casino_you_got_it_and_win']} ".htmlsafechars(mksize($win))." $goback");
} else {
if (isset($_POST["number"])) {
do {
$fake_winner = random_int(1, 6);
} while ($_POST["number"] == $fake_winner);
} elseif ($_POST["color"] == "black") {
$fake_winner = "red";
} else {
$fake_winner = "black";
}
sql_query("UPDATE users SET uploaded = uploaded - ".sqlesc($betmb)." WHERE id=".sqlesc($CURUSER["id"])) || sqlerr(__FILE__, __LINE__);
sql_query("UPDATE casino SET date = ".TIME_NOW.", trys = trys + 1 ,lost = lost + ".sqlesc($betmb)." WHERE userid=".sqlesc($CURUSER["id"])) || sqlerr(__FILE__,
__LINE__);
$update['uploaded_loser'] = ($User['uploaded'] - $betmb);
//==stats
$cache->update_row($cache_keys['user_stats'].$CURUSER['id'], [
'uploaded' => $update['uploaded_loser'],
], $TRINITY20['expires']['u_stats']);
$cache->update_row($cache_keys['user_statss'].$CURUSER['id'], [
'uploaded' => $update['uploaded_loser'],
], $TRINITY20['expires']['user_stats']);
stderr($lang['gl_sorry'],
"".htmlsafechars($fake_winner)." {$lang['casino_is_the_winner_and_not']} ".htmlsafechars($winner_was).", ".htmlsafechars($CURUSER["username"])." {$lang['casino_you_lost']} ".htmlsafechars(mksize($betmb))." $goback");
}
} else {
//== Get user stats
$betsp = sql_query("SELECT challenged FROM casino_bets WHERE proposed =".sqlesc($CURUSER['username']));
$openbet = 0;
while ($tbet2 = $betsp->fetch_assoc()) {
if ($tbet2['challenged'] == 'empty') {
$openbet++;
}
}
//== Convert bet amount into bits
if (isset($_POST['unit'])) {
$nobits = 0 + $_POST["unit"] == 1 ? $amnt * $mb_basic : $amnt * $mb_basic * 1024;
}
if ($CURUSER['uploaded'] == 0 || $CURUSER['downloaded'] == 0) {
$ratio = '0';
} else {
$ratio = number_format(($CURUSER['uploaded'] - $nobits) / $CURUSER['downloaded'], 2);
}
$time = TIME_NOW;
//== Take Bet
if (isset($_GET["takebet"])) {
$betid = 0 + $_GET["takebet"];
$random = random_int(0, 1);
$loc = sql_query("SELECT * FROM casino_bets WHERE id = ".sqlesc($betid));
$tbet = $loc->fetch_assoc();
$nogb = isset($tbet['amount']) ? mksize($tbet['amount']) : '';
$tbet_userid = isset($tbet['userid']) ? (int)$tbet['userid'] : "";
$tbet_challenged = $tbet['challenged'] ?? "";
if ($CURUSER['id'] == $tbet_userid) {
stderr($lang['gl_sorry'], "{$lang['casino_you_want_to_bet_against_yourself_lol']} ? $goback");
} elseif ($tbet_challenged != "empty") {
stderr($lang['gl_sorry'], "{$lang['casino_someone_has_already_taken_that_bet']}! $goback");
}
if ($CURUSER['uploaded'] < $tbet['amount']) {
$debt = $tbet['amount'] - $CURUSER['uploaded'];
$newup = $CURUSER['uploaded'] - $debt;
}
if (isset($debt) && $alwdebt != 1) {
stderr($lang['gl_sorry'],
"<h2>{$lang['casino_you_are']} ".htmlsafechars(mksize($nobits - $CURUSER['uploaded']))." {$lang['casino_short_of_making_that_bet']} !</h2> $goback");
}
if ($random == 1) {
sql_query("UPDATE users SET uploaded = uploaded+".sqlesc($tbet['amount'])." WHERE id = ".sqlesc($CURUSER['id'])) || sqlerr(__FILE__,
__LINE__);
sql_query("UPDATE casino SET deposit = deposit-".sqlesc($tbet['amount'])." WHERE userid = ".sqlesc($tbet['userid'])) || sqlerr(__FILE__,
__LINE__);
$update['uploaded'] = ($User['uploaded'] + $tbet['amount']);
//==stats
$cache->update_row($cache_keys['user_stats'].$CURUSER['id'], [
'uploaded' => $update['uploaded'],
], $TRINITY20['expires']['u_stats']);
$cache->update_row($cache_keys['user_statss'].$CURUSER['id'], [
'uploaded' => $update['uploaded'],
], $TRINITY20['expires']['user_stats']);
if ($mysqli->affected_rows == 0) {
sql_query("INSERT INTO casino (userid, date, deposit) VALUES (".sqlesc($tbet['userid']).", $time, -".sqlesc($tbet['amount']).")") || sqlerr(__FILE__,
__LINE__);
}
sql_query("UPDATE casino_bets SET challenged = ".sqlesc($CURUSER['username']).", winner = ".sqlesc($CURUSER['username'])." WHERE id =".sqlesc($betid)) || sqlerr(__FILE__,
__LINE__);
$subject = sqlesc($lang['casino_casino_results']);
$msg = sqlesc("You lost a bet ! ".htmlsafechars($CURUSER['username'])." just won ".htmlsafechars($nogb)." of your upload credit !");
sql_query("INSERT INTO messages (subject, sender, receiver, added, msg, unread, poster) VALUES ($subject, $sendfrom, ".sqlesc($tbet['userid']).", $time, $msg, 'yes', $sendfrom)") || sqlerr(__FILE__,
__LINE__);
$cache->delete($cache_keys['inbox_new'].$tbet['userid']);
$cache->delete($cache_keys['inbox_new_sb'].$tbet['userid']);
if ($writelog === 1) {
write_log($CURUSER['username']." won $nogb {$lang['casino_of_upload_credit_off']} ".htmlsafechars($tbet['proposed']));
}
if ($delold === 1) {
sql_query("DELETE FROM casino_bets WHERE id =".sqlesc($tbet['id'])) || sqlerr(__FILE__, __LINE__);
}
stderr($lang['casino_you_got_it'],
"<h2>{$lang['casino_you_won_the_bet']}, ".htmlsafechars($nogb)." {$lang['casino_has_been_credited_to_your_account']}, at <a href='userdetails.php?id=".(int)$tbet['userid']."'>".htmlsafechars($tbet['proposed'])."'s</a> {$lang['casino_expense']} !</h2> $goback");
exit();
}
if (empty($newup)) {
$newup = $User['uploaded'] - $tbet['amount'];
}
$newup2 = $tbet['amount'] * 2;
sql_query("UPDATE users SET uploaded = ".sqlesc($newup)." WHERE id =".sqlesc($CURUSER['id'])) || sqlerr(__FILE__, __LINE__);
sql_query("UPDATE users SET uploaded = uploaded + ".sqlesc($newup2)." WHERE id = ".sqlesc($tbet['userid'])) || sqlerr(__FILE__, __LINE__);
sql_query("UPDATE casino SET deposit = deposit-".sqlesc($tbet['amount'])." WHERE userid = ".sqlesc($tbet['userid']));
$update['uploaded'] = ($newup);
//==stats
$cache->update_row($cache_keys['user_stats'].$CURUSER['id'], [
'uploaded' => $update['uploaded'],
], $TRINITY20['expires']['u_stats']);
$cache->update_row($cache_keys['user_statss'].$CURUSER['id'], [
'uploaded' => $update['uploaded'],
], $TRINITY20['expires']['user_stats']);
$update['uploaded_2'] = ($User['uploaded'] + $newup2);
//==stats
$cache->update_row($cache_keys['user_stats'].$tbet['userid'], [
'uploaded' => $update['uploaded_2'],
], $TRINITY20['expires']['u_stats']);
$cache->update_row($cache_keys['user_statss'].$tbet['userid'], [
'uploaded' => $update['uploaded_2'],
], $TRINITY20['expires']['user_stats']);
if ($mysqli->affected_rows == 0) {
sql_query("INSERT INTO casino (userid, date, deposit) VALUES (".sqlesc($tbet['userid']).", $time, -".sqlesc($tbet['amount']).")") || sqlerr(__FILE__,
__LINE__);
}
sql_query("UPDATE casino_bets SET challenged = ".sqlesc($CURUSER['username']).", winner = ".sqlesc($tbet['proposed'])." WHERE id = ".sqlesc($betid)) || sqlerr(__FILE__,
__LINE__);
$subject = sqlesc($lang['casino_casino_results']);
$msg = sqlesc("{$lang['casino_you_just_won']} ".htmlsafechars($nogb)." {$lang['casino_of_upload_credit_from']} ".$CURUSER['username']." !");
sql_query("INSERT INTO messages (subject, sender, receiver, added, msg, unread, poster) VALUES ($subject, $sendfrom, ".sqlesc($tbet['userid']).", $time, $msg, 'yes', $sendfrom)") || sqlerr(__FILE__,
__LINE__);
$cache->delete($cache_keys['inbox_new'].$tbet['userid']);
$cache->delete($cache_keys['inbox_new_sb'].$tbet['userid']);
if ($writelog === 1) {
write_log("".htmlsafechars($tbet['proposed'])." won $nogb {$lang['casino_of_upload_credit_off']} ".$CURUSER['username']);
}
if ($delold === 1) {
sql_query("DELETE FROM casino_bets WHERE id =".sqlesc($tbet['id'])) || sqlerr(__FILE__, __LINE__);
}
stderr($lang['casino_damn_it'],
"<h2>{$lang['casino_you_lost_the_bet']} <a href='userdetails.php?id=".(int)$tbet['userid']."'>".htmlsafechars($tbet['proposed'])."</a> {$lang['casino_has_won']} ".htmlsafechars($nogb)." {$lang['casino_of_your_hard_earnt_upload_credit']} !</h2> $goback");
exit();
}
//== Add a new bet
($loca = sql_query("SELECT * FROM casino_bets WHERE challenged ='empty'")) || sqlerr(__FILE__, __LINE__);
$totbets = $loca->num_rows;
if (isset($_POST['unit'])) {
$nobits = 0 + $_POST["unit"] == '1' ? 0 + $_POST["amnt"] * $mb_basic : 0 + $_POST["amnt"] * $mb_basic * 1024;
}
if (isset($_POST["unit"])) {
if ($openbet >= $maxusrbet) {
stderr($lang['gl_sorry'],
"{$lang['casino_there_are_already']} ".htmlsafechars($openbet)." {$lang['casino_bets_open_take_an_open_bet']} !");
}
if ($nobits <= 0) {
stderr($lang['gl_sorry'], " {$lang['casino_this_wont_work_enter_a_pos_val']}?");
}
if ($nobits == ".") {
stderr($lang['gl_sorry'], " {$lang['casino_this_wont_work_enter_without_a_dec']}?");
}
$newups = $CURUSER['uploaded'] - $nobits;
$debt = $nobits - $CURUSER['uploaded'];
if ($CURUSER['uploaded'] < $nobits && $alwdebt != 1) {
stderr($lang['gl_sorry'],
"<h2>{$lang['casino_thats']} ".htmlsafechars(mksize($debt))." {$lang['casino_more_than_you_got']}!</h2>$goback");
}
($betsp = sql_query("SELECT id, amount FROM casino_bets WHERE userid = ".sqlesc($CURUSER['id'])." ORDER BY time ASC")) || sqlerr(__FILE__,
__LINE__);
$tbet2 = $betsp->fetch_row();
$dummy = "<h2>{$lang['casino_bet_added_you_will_receive_a_pm_notify']}</h2>";
$user = $CURUSER['username'];
$bet = mksize($nobits);
$message = "[color=green][b]{$user}[/b][/color] {$lang['casino_has_just_placed_a']} [color=red][b]{$bet}[/b][/color] {$lang['casino_bet_in_the_casino']}";
$messages = "{$user} {$lang['casino_has_just_placed_a']} {$bet} {$lang['casino_bet_in_the_casino']}";
sql_query("INSERT INTO casino_bets ( userid, proposed, challenged, amount, time) VALUES (".sqlesc($CURUSER['id']).",".sqlesc($CURUSER['username']).", 'empty', $nobits, $time)") || sqlerr(__FILE__,
__LINE__);
sql_query("UPDATE users SET uploaded = ".sqlesc($newups)." WHERE id = ".sqlesc($CURUSER['id'])) || sqlerr(__FILE__, __LINE__);
sql_query("UPDATE casino SET deposit = deposit + ".sqlesc($nobits)." WHERE userid = ".sqlesc($CURUSER['id'])) || sqlerr(__FILE__, __LINE__);
$update['uploaded'] = ($newups);
//==stats
$cache->update_row($cache_keys['user_stats'].$CURUSER['id'], [
'uploaded' => $update['uploaded'],
], $TRINITY20['expires']['u_stats']);
$cache->update_row($cache_keys['user_statss'].$CURUSER['id'], [
'uploaded' => $update['uploaded'],
], $TRINITY20['expires']['user_stats']);
if ($TRINITY20['autoshout_on'] == 1) {
autoshout($message);
}
if ($mysqli->affected_rows == 0) {
sql_query("INSERT INTO casino (userid, date, deposit) VALUES (".sqlesc($CURUSER['id']).", $time, ".sqlesc($nobits).")") || sqlerr(__FILE__,
__LINE__);
}
}
$loca = sql_query("SELECT * FROM casino_bets WHERE challenged ='empty'");
$totbets = $loca->num_rows;
//== Output html begin
$HTMLOUT = '';
$HTMLOUT .= "<table class='table table-bordered'>
<tr>
<td align='center'>";
$HTMLOUT = $dummy;
//== Place bet table
if ($openbet < $maxusrbet) {
if ($totbets >= $maxtotbet) {
$HTMLOUT .= "<br>{$lang['casino_there_are_already']} ".htmlsafechars($maxtotbet)." {$lang['casino_bets_open_take_an_open_bet']} !<br>";
} else {
$HTMLOUT .= "<br>
<form class=\"form-horizontal\" name=\"p2p\" method=\"post\" action=\"casino.php\">
<div class='card'>
<div class='card-divider'>
<h1 class='col-sm-offset-3'>{$TRINITY20['site_name']} {$lang['casino_stdhead']} - {$lang['casino_bet_p2p_with_other_users']}:</h1></div>
<div class='card-section'>
<div class='row'><div class='col-sm-6 col-sm-offset-3'><div class='card'><table class='table'>";
$HTMLOUT .= "<tr><td align=\"center\" colspan=\"2\" class=\"colhead\">{$lang['casino_place_bet']}</td></tr>";
$HTMLOUT .= "<tr><td align=\"center\"><b>{$lang['casino_amount_to_bet']}</b>
<div class='row'><div class='col-sm-3 col-sm-offset-3'><input class=\"form-control input-small\" type=\"text\" name=\"amnt\" size=\"5\" value=\"1\"></div>
<div class='col-sm-3'><select class=\"form-control\" name=\"unit\">
<option value=\"1\">MB</option>
<option value=\"2\">GB</option>
</select></div></div></td></tr>";
$HTMLOUT .= "<tr><td align=\"center\" colspan=\"2\"><input class='btn btn-default' type=\"submit\" value=\"{$lang['casino_gamble']}!\">";
$HTMLOUT .= "</td></tr></table></div></form></div></div></div></div><br>";
}
} else {
$HTMLOUT .= "<b>{$lang['casino_you_already_have']} ".htmlsafechars($maxusrbet)." {$lang['casino_open_bets_wait_until_they_are_comp']}.</b><br><br>";
}
//== Open Bets table
$HTMLOUT .= "<div class='card'>
<table class='table table-bordered'>";
$HTMLOUT .= "<tr><td align=\"center\" class=\"colhead\" colspan=\"4\">{$lang['casino_open_bets']}</td></tr></div>";
$HTMLOUT .= "<tr>
<td align=\"center\" width=\"15%\"><b>{$lang['casino_name']}</b></td><td width=\"15%\" align=\"center\"><b>{$lang['casino_amount']}</b></td>
<td width=\"45%\" align=\"center\"><b>{$lang['casino_time']}</b></td><td align=\"center\"><b>{$lang['casino_take_bet']}</b></td>
</tr>";
while ($res = $loca->fetch_assoc()) {
$HTMLOUT .= "<tr>
<td align=\"center\">".htmlsafechars($res['proposed'])."</td>
<td align=\"center\">".htmlsafechars(mksize($res['amount']))."</td>
<td align=\"center\">".get_date($res['time'], 'LONG', 0, 1)."</td>
<td align=\"center\"><b><a href='{$casino}?takebet=".(int)$res['id']."'>{$lang['casino_this']}</a></b></td>
</tr>";
$abcdefgh = 1;
}
if ($abcdefgh == false) {
$HTMLOUT .= "<tr><td align='center' colspan='4'>{$lang['casino_sorry_no_bets_currently']}.</td></tr>";
}
$HTMLOUT .= "</table></div><br>";
//== Bet on color table
$HTMLOUT .= "<div class='row'>
<div class='col-sm-6'>";
$HTMLOUT .= "<div class='card'>
<form class=\"form-horizontal\" name=\"casino\" method=\"post\" action=\"casino.php\">
<table class=\"message table table-bordered\" cellspacing=\"0\">\n";
$HTMLOUT .= "<tr><td align=\"center\" class=\"colhead\" colspan=\"2\">{$lang['casino_bet_on_a_colour']}</td></tr>";
$HTMLOUT .= tr($lang['casino_black'], "<input name=\"color\" type=\"radio\" checked=\"checked\" value=\"black\">", 1);
$HTMLOUT .= tr($lang['casino_red'], "<input name=\"color\" type=\"radio\" checked=\"checked\" value=\"red\">", 1);
$HTMLOUT .= tr($lang['casino_how_much'], "
<select class-\"form-control\" name=\"betmb\">
<option value=\"{$bet_value1}\">".mksize($bet_value1)."</option>
<option value=\"{$bet_value2}\">".mksize($bet_value2)."</option>
<option value=\"{$bet_value3}\">".mksize($bet_value3)."</option>
<option value=\"{$bet_value4}\">".mksize($bet_value4)."</option>
<option value=\"{$bet_value5}\">".mksize($bet_value5)."</option>
<option value=\"{$bet_value6}\">".mksize($bet_value6)."</option>
<option value=\"{$bet_value7}\">".mksize($bet_value7)."</option>
</select>", 1);
$real_chance = $show_real_chance ? $cheat_value + 1 : 2;
$HTMLOUT .= tr($lang['casino_your_chance'], "1 : ".$real_chance, 1);
$HTMLOUT .= tr($lang['casino_you_can_win'], $win_amount." * stake", 1);
$HTMLOUT .= tr($lang['casino_bet_on_color'], "<input class='btn btn-default' type=\"submit\" value=\"{$lang['casino_do_it']}!\">", 1);
$HTMLOUT .= "</table></form></div></div>";
//== Bet on number table
$HTMLOUT .= "<div class='col-sm-6'>";
$HTMLOUT .= "<div class='card'>
<form class=\"form-horizontal\" name=\"casino\" method=\"post\" action=\"casino.php\">
<table class=\"message table table-bordered\" cellspacing=\"0\">\n";
$HTMLOUT .= "<tr><td align=\"center\" class=\"colhead\" colspan=\"2\">{$lang['casino_bet_on_a_number']}</td></tr>";
$HTMLOUT .= tr($lang['casino_number'],
'<input name="number" type="radio" checked="checked" value="1">1 <input name="number" type="radio" value="2">2 <input name="number" type="radio" value="3">3',
1);
$HTMLOUT .= tr("",
'<input name="number" type="radio" value="4">4 <input name="number" type="radio" value="5">5 <input name="number" type="radio" value="6">6',
1);
$HTMLOUT .= tr($lang['casino_how_much'], "
<select class=\"form-control\" name=\"betmb\">
<option value=\"{$bet_value1}\">".mksize($bet_value1)."</option>
<option value=\"{$bet_value2}\">".mksize($bet_value2)."</option>
<option value=\"{$bet_value3}\">".mksize($bet_value3)."</option>
<option value=\"{$bet_value4}\">".mksize($bet_value4)."</option>
<option value=\"{$bet_value5}\">".mksize($bet_value5)."</option>
<option value=\"{$bet_value6}\">".mksize($bet_value6)."</option>
<option value=\"{$bet_value7}\">".mksize($bet_value7)."</option>
</select>", 1);
$real_chance = $show_real_chance ? $cheat_value + 5 : 6;
$HTMLOUT .= tr($lang['casino_your_chance'], "1 : ".$real_chance, 1);
$HTMLOUT .= tr($lang['casino_you_can_win'], $win_amount_on_number." * stake", 1);
$HTMLOUT .= tr($lang['casino_bet_on_a_number'], "<input class='btn btn-default' type=\"submit\" value=\"{$lang['casino_do_it']}!\">", 1);
$HTMLOUT .= "</table></form></div></div></div>";
//== User stats table
$HTMLOUT .= "<div class='card'><table class='table table-bordered'>";
$HTMLOUT .= "<tr><td align=\"center\" class=\"colhead\" colspan=\"3\">{$CURUSER['username']}'s {$lang['casino_details']}</td></tr>
<tr><td align='center'>
<h1>User @ {$TRINITY20['site_name']} {$lang['casino_stdhead']}</h1>
<table class='message table table-bordered' cellspacing='0'>";
$HTMLOUT .= tr($lang['casino_you_can_win'], mksize($max_download_user), 1);
$HTMLOUT .= tr($lang['casino_won'], mksize($user_win), 1);
$HTMLOUT .= tr($lang['casino_lost'], mksize($user_lost), 1);
if (is_numeric($casino_ratio_user)) {
$HTMLOUT .= tr($lang['casino_ratio'], $casino_ratio_user, 1);
}
if (is_numeric($user_deposit) && is_numeric($nobits)) {
$HTMLOUT .= tr($lang['casino_deposit_on_p2p'], mksize($user_deposit + $nobits));
}
$HTMLOUT .= "</table>
</td><td align='center'>
<h1>{$lang['casino_global_stats']}</h1>
<table class='message table table-bordered' cellspacing='0'>";
$HTMLOUT .= tr($lang['casino_users_can_win'], mksize($max_download_global), 1);
$HTMLOUT .= tr($lang['casino_won'], mksize($global_win), 1);
$HTMLOUT .= tr($lang['casino_lost'], mksize($global_lost), 1);
$HTMLOUT .= tr($lang['casino_ratio'], $casino_ratio_global, 1);
$HTMLOUT .= tr($lang['casino_deposit'], mksize($global_deposit));
$HTMLOUT .= "</table>";
$HTMLOUT .= "</td><td align='center'>
<h1>{$lang['casino_user_stats']}</h1>
<table class='message table table-bordered' cellspacing='0'>";
$HTMLOUT .= tr($lang['casino_uploaded'], mksize($User['uploaded'] - $nobits));
$HTMLOUT .= tr($lang['casino_downloaded'], mksize($User['downloaded']));
$HTMLOUT .= tr($lang['casino_ratio'], $ratio);
$HTMLOUT .= "</table></td></tr></table></div>";
}
echo stdhead("{$TRINITY20['site_name']} {$lang['casino_stdhead']}").$HTMLOUT.stdfoot();