-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.php
608 lines (542 loc) · 16.3 KB
/
index.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
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
<?php
// Get functions
require_once './inc/functions.php';
// Frontend stuff
// We're using ob_start to safely send headers while we're processing the script initially.
ob_start();
// Start session with user if we got a valid cookie.
startSessionIfNotStarted();
$c = new RememberCookieHandler();
if ($c->Check()) {
$v = $c->Validate();
switch ($v) {
case ValidateValue::UserBanned:
addError("You are banned, as such you've been logged out of your account automatically.");
break;
// /shrugs
}
}
// Redirect to 2FA block page if needed
redirect2FA();
// CONTROLLER SYSTEM v2
$model = 'old';
if (isset($_GET['p'])) {
$found = false;
foreach ($pages as $page) {
if (defined(get_class($page).'::PageID') && $page::PageID == $_GET['p']) {
$found = true;
$model = $page;
$title = '<title>'.$page::Title.'</title>';
$p = $page::PageID;
if (defined(get_class($page).'::LoggedIn')) {
if ($page::LoggedIn) {
clir();
} else {
clir(true, 'index.php?p=1&e=1');
}
}
break;
}
}
if (!$found) {
if (isset($_GET['p']) && !empty($_GET['p'])) {
$p = $_GET['p'];
} else {
$p = 1;
}
$title = setTitle($p);
}
} elseif (isset($_GET['u']) && !empty($_GET['u'])) {
/*if (!is_numeric($_GET['u'])) {
die('invalid user id');
}*/
redirect($URL["server"] . "/u/" . $_GET['u']);
die();
} elseif (isset($_GET['__PAGE__'])) {
$pages_split = explode('/', $_GET['__PAGE__']);
if (count($_GET['__PAGE__']) < 2) {
$title = '<title>Ripple</title>';
$p = 1;
}
$found = false;
foreach ($pages as $page) {
if ($page::URL == $pages_split[1]) {
$found = true;
$model = $page;
$title = '<title>'.$page::Title.'</title>';
break;
}
}
if (!$found) {
$p = 1;
$title = '<title>Ripple</title>';
}
} else {
$p = 1;
$title = '<title>Ripple</title>';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="author" content="">
<!-- Dynamic title -->
<?php echo $title; ?>
<!-- Bootstrap Core CSS -->
<link href="./css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap select CSS -->
<link href="./css/bootstrap-select.min.css" rel="stylesheet">
<!-- Slider CSS -->
<link href="./css/slider.css" rel="stylesheet">
<!-- Bootstrap Font Awesome Picker CSS -->
<link href="./css/fontawesome-iconpicker.min.css" rel="stylesheet">
<!-- Bootstrap Color Picker CSS -->
<link href="./css/bootstrap-colorpicker.min.css" rel="stylesheet">
<!-- SCEditor CSS -->
<link rel="stylesheet" href="./css/themes/default.css" type="text/css" media="all" />
<!-- Datepicker CSS -->
<link href="./css/bootstrap-datepicker3.min.css" rel="stylesheet">
<!-- Animate CSS -->
<link rel="stylesheet" href="./css/animate.css">
<!-- Custom CSS -->
<link href="./css/style-desktop.css" rel="stylesheet">
<!-- Favicon -->
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=xQQWRwyGed">
<link rel="icon" type="image/png" href="/favicon-32x32.png?v=xQQWRwyGed" sizes="32x32">
<link rel="icon" type="image/png" href="/favicon-16x16.png?v=xQQWRwyGed" sizes="16x16">
<link rel="manifest" href="/manifest.json?v=xQQWRwyGed">
<link rel="mask-icon" href="/safari-pinned-tab.svg?v=xQQWRwyGed" color="#5bbad5">
<link rel="shortcut icon" href="/favicon.ico?v=xQQWRwyGed">
<meta name="theme-color" content="#ffffff">
<meta name=viewport content="width=device-width, initial-scale=1">
<script src='https://www.google.com/recaptcha/api.js'></script>
<?php
if ($isBday && $p == 1) {
echo '
<script src="palloncini/palloncini.js"></script>
<script type="text/javascript">
particlesJS.load("palloncini", "palloncini/palloncini.conf");
</script>';
}
?>
</head>
<body>
<!-- Navbar -->
<?php printNavbar(); ?>
<!-- Page content (< 100: Normal pages, >= 100: Admin CP pages) -->
<?php
$status = '';
if ($model !== 'old') {
P::Messages();
}
if ($p < 100) {
// Normal page, print normal layout (will fix this in next commit, dw)
echo '
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">';
echo '<div id="content">';
if ($model === 'old') {
printPage($p);
} else {
echo $status;
checkMustHave($model);
$model->P();
}
echo '
</div>
</div>
</div>
</div>';
if ($isBday && $p == 1) echo '<div id="palloncini"></div>';
} else {
// Admin cp page, print admin cp layout
if ($model === 'old') {
printPage($p);
} else {
echo $status;
$model->P();
}
}
?>
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-migrate-3.0.0.js"></script>
<!-- User lookup -->
<?php
APITokens::PrintScript();
echo '<script src="/js/typeahead.min.js"></script>
<script src="/js/userlookup.js"></script>';
?>
<!-- Bootstrap Core JavaScript -->
<script src="./js/bootstrap.min.js"></script>
<!-- Bootstrap Select JavaScript -->
<script src="./js/bootstrap-select.min.js"></script>
<!-- Slider JavaScript -->
<script src="./js/bootstrap-slider.js"></script>
<!-- Bootstrap Font Awesome Picker JavaScript -->
<script src="./js/fontawesome-iconpicker.min.js"></script>
<!-- Bootstrap Color Picker JavaScript -->
<script src="./js/bootstrap-colorpicker.min.js"></script>
<!-- SCEditor JavaScript -->
<script src="./js/jquery.sceditor.bbcode.js"></script>
<!-- Datepicker -->
<script src="./js/bootstrap-datepicker.min.js"></script>
<!-- Custom JavaScript for every page -->
<script type="text/javascript">
// Escape function
function escapeHtml(unsafe) {
// utterly disgusting
if (typeof unsafe !== 'string' || unsafe instanceof String) {
return escapeHtml(String(unsafe));
}
return unsafe
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
// Are you sure window
function sure(redr, pre)
{
var msg = ""
if (typeof pre !== "undefined") {
msg += pre+"\n";
}
msg += "Are you sure?";
var r = confirm(msg);
if (r == true) window.location.replace(redr);
}
function reallysuredialog()
{
var r = confirm("This action cannot be undone. Are you sure you want to continue?");
if (r == true)
r = confirm("Are you REALLY sure?");
return r == true;
}
function reallysure(redr) {
reallysuredialog() && window.location.replace(redr)
}
function play(id) {
var audio = $('#audio_'+id)[0];
if (audio.currentTime <= 0) {
$.each($('audio'), function () {
this.pause();
this.currentTime = 0;
});
$.each($("i[id^=icon_]"), function () {
this.className = "fa fa-play";
});
audio.play();
$('#icon_'+id)[0].className = "fa fa-stop";
} else {
audio.pause();
audio.currentTime = 0;
$('#icon_'+id)[0].className = "fa fa-play";
}
}
function updateResolution () {
document.isMobile = window.matchMedia('(max-width: 768px)').matches
}
function updateNukeText(d, t) {
d.text(d.data("text") + " (" + (d.data("times")) + ")");
}
$(document).ready(function () {
// Initialize stuff
$('.icp-auto').iconpicker();
$('.colorpicker').colorpicker({format:"hex"});
$('.sceditor').sceditor({plugins: "bbcode", resizeEnabled: false, toolbarExclude: "font,table,code,quote,ltr,rtl" , style: "css/jquery.sceditor.default.css"});
$(".spoiler-trigger").click(function() {$(this).parent().next().collapse('toggle');});
$("[data-toggle=popover]").popover();
$(".nuke-button").each(function() {
$(this).data("text", $(this).text());
updateNukeText($(this));
})
$(".nuke-button").click(function() {
var t = $(this).data("times");
if (t <= 1) {
if (reallysuredialog()) {
$(this).parent("form").submit();
}
} else {
t = t - 1;
$(this).data("times", t);
updateNukeText($(this));
$(this).addClass("disabled");
var o = $(this);
setTimeout(() => {
$(this).removeClass("disabled");
}, 1000);
}
});
$(window).resize(function () {
updateResolution()
})
updateResolution()
})
$(".getcountry").click(function() {
var i = $(this);
$.get("https://ip.zxq.co/" + $(this).data("ip") + "/country", function(data) {
data = (data === "" ? "dunno" : data);
i.text("(" + data + ")");
});
});
$('[data-toggle="tooltip"]').tooltip();
</script>
<!-- Custom JavaScript for this page here -->
<?php
switch ($p) {
// Admin cp - edit user
case 100: echo '<script src="./js/pipoli.js"></script>'; break;
case 141: echo '<script src="./secret/js/ornella.js"></script>'; break;
case 103:
echo '
<script type="text/javascript">
function censorUserpage()
{
document.getElementsByName("up")[0].value = "[i]:peppy:Userpage reset by an admin.:peppy:[/i]";
}
function removeSilence()
{
document.getElementsByName("se")[0].value = 0;
document.getElementsByName("sr")[0].value = "";
}
function updatePrivileges(meme = true) {
var result = 0;
$("input:checkbox[name=privilege]:checked").each(function(){
result = Number(result) + Number($(this).val());
});
// Remove donor if needed
var selectValue;
if (result != '. (Privileges::UserDonor | Privileges::UserNormal | Privileges::UserPublic).') {
selectValue = result & ~'.Privileges::UserDonor.'
} else {
selectValue = result;
}
$("#privileges-value").val(result);
$("#privileges-group").val(selectValue);
// bootstrap-select is a dank meme
$("#privileges-group").selectpicker("refresh");
}
function groupUpdated() {
var privileges = $("#privileges-group option:selected").val();
if (privileges > -1) {
$("input:checkbox[name=privilege]").each(function(){
if ( ($(this).val() & privileges) > 0) {
$(this).prop("checked", true);
} else {
$(this).prop("checked", false);
}
});
}
updatePrivileges();
}
function scheduleSaveReminderFadeOut () {
setTimeout(function () {
if (document.isMobile) {
return
}
$(".bottom-fixed.enabled>.alert").fadeOut(1000);
}, 1500)
}
$(".unpin").click(function () {
$(".bottom-fixed").toggleClass("enabled")
$(".bottom-padded").toggleClass("enabled")
$(".bottom-fixed>.alert").fadeIn(250)
var pinned = $(".bottom-fixed").hasClass("enabled")
if (pinned) {
scheduleSaveReminderFadeOut()
}
window.localStorage.setItem("editUserPinned", pinned.toString())
})
$(document).ready(function () {
if (window.localStorage.getItem("editUserPinned") === null) {
window.localStorage.setItem("editUserPinned", "true")
}
var pinned = window.localStorage.getItem("editUserPinned") === "true"
if (pinned) {
$(".bottom-fixed").addClass("enabled");
$(".bottom-padded").addClass("enabled");
scheduleSaveReminderFadeOut()
}
});
</script>
';
break;
// Supporter page
case 34:
echo '
<!-- <script src="./js/money.min.js"></script> -->
<script src="./js/bitcoinprices.js"></script>
<script type="text/javascript">
// Called when slider changes
function onSlide() {
updatePrice(slider.getValue());
};
// Updates price in EUR/USD/GBP, months number and paypal.me link
var updatePrice = function (months) {
try {
var priceEUR = Math.pow(months * 30 * 0.2, 0.70).toFixed(2);
var str = "<b>"+months+"</b> months = <b>"+priceEUR+"€</b>"+"<br>";
var priceUSD = bitcoinprices.convert(priceEUR, "EUR", "USD").toFixed(2);
var priceMBTC = (bitcoinprices.convert(priceEUR, "EUR", "BTC")*1000).toFixed(4);
str += "<i>("+priceUSD+"$ USD/"+priceMBTC+" mBTC)</i>"
$("#supporter-btc").show();
} catch(err) {
var str = "<b>Move the slider above to show the price</b>";
$("#supporter-btc").hide();
}
$("#supporter-prices").html(str);
$("#supporter-btc-price").html(priceMBTC);
$("#paypal-supporter-period").val(months+" months");
$("#pay").attr("href", "https://paypal.me/ripplemoe/"+priceEUR);
$("#paypal-price").html(priceEUR);
};
// Slider
var slider = $(".slider").slider().on("slide", onSlide).data("slider");
// Load currencies
bitcoinprices.init({
url: "https://api.bitcoinaverage.com/ticker/all",
marketRateVariable: "24h_avg",
currencies: ["BTC", "USD", "EUR"],
defaultCurrency: "BTC",
});
// Initialize price for 1 month
updatePrice(1);
</script>
';
break;
case 119:
echo '
<script type="text/javascript">
function updatePrivileges() {
var result = 0;
$("input:checkbox[name=privileges]:checked").each(function(){
result = Number(result) + Number($(this).val());
});
$("#privileges-value").attr("value", result);
}
</script>
';
break;
case 37:
echo '<script type="text/javascript">
$(document).ready (function() {
setInterval(function() {
$("*").not(".container").not("head").not("body").not("#content").each(function() {
var animations = [
"bounce",
"flash",
"pulse",
"rubberBand",
"shake",
"swing",
"tada",
"wobble",
"jello",
"hinge",
];
var meme = animations[Math.floor(Math.random() * animations.length)];
$(this).addClass("animated infinite "+meme);
$(".carroponte").each(function() {
$(this).show();
});
});
},5500);
});
</script>';
break;
case 38:
echo '
<script type="text/javascript">';
if (isset($_GET["u"]) && !empty($_GET["u"])) {
echo 'setInterval(function() {
var ajaxResponse = $.ajax({
url: "'.URL::Bancho().'/api/v1/verifiedStatus?u='.$_GET["u"].'",
dataType: "jsonp",
}).done(function(data) {
console.log(data["result"]);
if (data["result"] == 1 || data["result"] == 0) {
window.location.replace("index.php?p=39&u='.$_GET["u"].'");
}
});
}, 5000);';
}
echo '</script>';
break;
case 6:
echo '<script>
$(".icp").on("iconpickerSelected", function(e) {
var faClass = $("#badge-icon-input").val();
if (!faClass.startsWith("fa-")) {
return;
}
$("#badge-icon").attr("class", "fa "+faClass+" fa-2x").html();
});
$("#badge-name-input").keyup(function() {
$("#badge-name").text($("#badge-name-input").val()).html();
});
</script>';
break;
case 124:
$force = (isset($_GET["force"]) && !empty($_GET["force"])) ? '1' : '0';
echo '<script type="text/javascript">
var bsid='.htmlspecialchars($_GET["bsid"]).';
var force='.$force.';
</script>
<input id="csrf" type="hidden" value="' . csrfToken() . '">
<script src="/js/rankbeatmap.js"></script>';
break;
case 127:
echo '<script>
$(document).ready(function() {
$("[data-target=#silenceUserModal]").click(function() {
$("#silenceUserModal").find("input[name=u]").val($(this).data("who"));
$("#silenceUserModal").find("input[name=c]").val("10");
$("#silenceUserModal").find("select[name=un]").selectpicker("val", "60");
});
});
</script>';
break;
case 134:
case 137:
echo "<script>
$(document).ready(function() {
$('.datepicker').datepicker({
orientation: 'bottom',
format: 'yyyy-mm-dd',
autoclose: true,
clearBtn: true
})
})
</script>";
if ($p == 137) {
echo "<script>
function toggleDatepickers() {
$('.datepicker').prop('disabled', $('#susleakat').val() !== 'dates')
}
$(document).ready(function() {
toggleDatepickers();
$('#susleakat').change(toggleDatepickers)
})
</script>";
}
break;
}
// Userpage JS
if (isset($_GET["u"]) && !isset($_GET["p"])) {
echo '<script src="/js/user.js"></script>';
}
?>
</body>
</html>
<?php
// clear redirpage if we're not on login page
if ($p != 2) {
unset($_SESSION['redirpage']);
}
ob_end_flush();