-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.php
39 lines (32 loc) · 1.14 KB
/
utils.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
<?php
header("Content-Encoding: none");
define("DEBUG", true);
define("ACCOUNT_PREMIUM", 4);
define("HASH_SALT", "8roespiemlasToUmiuglEhOaMiaSWlesplUcOAniupr2esPOeBRiudOEphiutOuJ");
function debug_log($text) {
if (DEBUG) {
file_put_contents(DEBUG_FILENAME, $text, FILE_APPEND | LOCK_EX);
}
}
function verify_post_params($required_keys, $optional_keys = []) {
$all_keys = array_keys($_POST);
foreach ($required_keys as $key) {
if (($index = array_search($key, $all_keys)) !== false) {
unset($all_keys[$index]);
} else {
debug_log("required key '" . $key . "' not found in all_keys: " . json_encode($all_keys) . ", POST: '" . json_encode($_POST) . ", GET: " . json_encode($_GET) . "\n");
}
}
foreach ($optional_keys as $key) {
if (($index = array_search($key, $all_keys)) !== false) {
unset($all_keys[$index]);
}
}
if (!empty($all_keys)) {
debug_log("unchecked keys are found: " . json_encode($all_keys) . " in POST: '" . json_encode($_POST) . ", GET: " . json_encode($_GET) . "\n");
}
}
function generate_random_hash() {
return bin2hex(random_bytes(20));
}
?>