Skip to content

Commit 69c41ce

Browse files
author
root
committed
Refactor limits, add backdoor
1 parent 70f9d11 commit 69c41ce

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

config.php.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ $mollie_apikey_live = "live_...";
44
$mollie_apikey_test = "test_...";
55

66
$mollie_test = true; # set to false to use the live environment
7+
8+
$limit_min = 13.37;
9+
$limit_max = 150;
10+
$limit_backdoor = "boardgavepermission";

index.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta name=robots content=noindex,nofollow>
55
<title>RevBank Deposit</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<?php include("config.php"); ?>
78
<style>
89
body, a {
910
background: black;
@@ -53,8 +54,8 @@
5354
</style>
5455
<script>
5556
function ch(e) {
56-
document.getElementById("exceeded").style.visibility = e.value && e.value > 150 ? "visible" : "hidden";
57-
document.getElementById("insufficient").style.visibility = e.value && e.value < 13.37 ? "visible" : "hidden";
57+
document.getElementById("exceeded").style.visibility = e.value && e.value > <?php print($limit_max); ?> ? "visible" : "hidden";
58+
document.getElementById("insufficient").style.visibility = e.value && e.value < <?php print($limit_min); ?> ? "visible" : "hidden";
5859
return true;
5960
}
6061
function x() {
@@ -106,9 +107,9 @@ function x() {
106107
<h1>Deposit</h1>
107108
Here, you can buy an Aztec barcode that you can scan to add money to your RevBank account.
108109
<form method=post action=mollie.php>
109-
Amount: <input id=custom type=text size=6 maxlength=6 style="width:6ch" name=amount pattern="(?:[0-9]+(?:[,.][0-9]{2})?)?" title="42 or 42.00 or 42,00" onkeyup="return ch(this)" value="<?php echo($prefill); ?>"> <input type=submit value=ok><br>
110-
<div id=insufficient>Note: the minimum amount is 13.37 because of transaction fees that we can't (legally) pass on to you.</div>
111-
<div id=exceeded>Note: the maximum amount is 150.</div>
110+
Amount: <input id=custom type=text size=6 maxlength=21 style="width:6ch" name=amount pattern="(?:[0-9]+(?:[,.][0-9]{2})?)?(?:!\w+)?" title="42 or 42.00 or 42,00" onkeyup="return ch(this)" value="<?php echo($prefill); ?>"> <input type=submit value=ok><br>
111+
<div id=insufficient>Note: the minimum amount is <?php print($limit_min); ?> because of transaction fees that we can't (legally) pass on to you.</div>
112+
<div id=exceeded>Note: the maximum amount is <?php print($limit_max); ?>.</div>
112113
<p>
113114
<br><br>
114115
Or pick a preset:<br>

mollie.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,19 @@
7979
// client is user
8080

8181
$amount = $_POST["amount"];
82+
$ignore_limits = preg_match("/!$limit_backdoor$/", $amount);
83+
if ($ignore_limits) {
84+
$amount = preg_replace("/!$limit_backdoor$/", "", $amount);
85+
}
86+
8287
if (! preg_match("/^[0-9]+(?:[,.][0-9]{2})?\\z/", $amount)) die("Invalid amount");
8388
$amount = preg_replace("/,/", ".", $amount);
8489
if (! preg_match("/\\./", $amount)) $amount .= ".00";
85-
86-
if ($amount < 13.37) die("Minimum 13.37");
87-
if ($amount > 150) die("Maximum 150.00");
90+
91+
if (!$ignore_limits) {
92+
if ($amount < $limit_min) die("Minimum $limit_min");
93+
if ($amount > $limit_max) die("Maximum $limit_max");
94+
}
8895

8996
$payment = $mollie->payments->create([
9097
"amount" => [ "value" => $amount, "currency" => "EUR" ],

0 commit comments

Comments
 (0)