File size: 625 Bytes
bf8c0ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<?php

// used in integration tests to see if POST method works.
// for security reasons we allow max 3 post vars, each key and value is only allowed to have max 6 hex characters

function accept($key)
{
    if (ctype_xdigit($key) && strlen($key) <= 6) {
        return $key;
    }
}

if (count($_POST) > 4) {
    exit;
}

$values = array();
foreach ($_POST as $key => $value) {
    if (accept($key) && accept($value)) {
        $values[$key] = $value;
    }
}

if (!empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) === 'post') {
    $values['method'] = 'post';
}

echo json_encode($values);
exit;