Client.php 984 Bytes
Newer Older
Carsten  Rose's avatar
Carsten Rose committed
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
<?php
/**
 * Created by PhpStorm.
 * User: crose
 * Date: 7/9/17
 * Time: 3:14 PM
 */

namespace qfq;

use qfq;

require_once(__DIR__ . '/../../qfq/helper/Sanitize.php');


class Client {

    public static function getParam() {

        // copy GET and POST and SERVER Parameter. Priority: SERVER, POST, GET
        $post = array();
        $cookie = array();
        $server = array();

        $get = \qfq\Sanitize::urlDecodeArr($_GET);

        if (isset($_POST)) {
            $post = $_POST;
        }

        if (isset($_COOKIE[SESSION_NAME])) {
            $cookie[CLIENT_COOKIE_QFQ] = $_COOKIE[SESSION_NAME];
        }

        // It's important to merge the SERVER array last: those entries shall overwrite client values.
        if (isset($_SERVER)) {
            $server = Sanitize::htmlentitiesArr($_SERVER); // $_SERVER values might be compromised.
        }

        $arr = array_merge($get, $post, $cookie, $server);

        return Sanitize::normalize($arr);
    }
}