1 | <?php |
||
2 | /** |
||
3 | * Get value from GET variable or return default value. |
||
4 | * |
||
5 | * @param string $key to look for |
||
6 | * @param mixed $default value to set if key does not exists |
||
7 | * |
||
8 | * @return mixed value from GET or the default value |
||
9 | */ |
||
10 | function getGet($key, $default = null) |
||
11 | { |
||
12 | return isset($_GET[$key]) |
||
13 | ? $_GET[$key] |
||
14 | : $default; |
||
15 | } |
||
16 | |||
17 | |||
18 | /** |
||
19 | * Get value from POST variable or return default value. |
||
20 | * |
||
21 | * @param mixed $key to look for, or value array |
||
22 | * @param mixed $default value to set if key does not exists |
||
23 | * |
||
24 | * @return mixed value from POST or the default value |
||
25 | */ |
||
26 | function getPost($key, $default = null) |
||
27 | { |
||
28 | if (is_array($key)) { |
||
29 | $key = array_flip($key); |
||
30 | return array_replace($key, array_intersect_key($_POST, $key)); |
||
31 | } |
||
32 | |||
33 | return isset($_POST[$key]) |
||
34 | ? $_POST[$key] |
||
35 | : $default; |
||
36 | } |
||
37 | |||
38 | |||
39 | /** |
||
40 | * Function to create links for sorting. |
||
41 | * |
||
42 | * @param string $column the name of the database column to sort by |
||
43 | * @param string $route prepend this to the anchor href |
||
44 | * |
||
45 | * @return string with links to order by column. |
||
46 | */ |
||
47 | function orderby($column, $route) |
||
48 | { |
||
49 | return <<<EOD |
||
50 | <span class="orderby"> |
||
51 | <a href="{$route}orderby={$column}&order=asc">↑</a> |
||
52 | <a href="{$route}orderby={$column}&order=desc">↓</a> |
||
53 | </span> |
||
54 | EOD; |
||
55 | } |
||
56 | |||
57 | |||
58 | |||
59 | /** |
||
60 | * Function to create links for sorting and keeping the original querystring. |
||
61 | * |
||
62 | * @param string $column the name of the database column to sort by |
||
63 | * @param string $route prepend this to the anchor href |
||
64 | * |
||
65 | * @return string with links to order by column. |
||
66 | */ |
||
67 | function orderby2($column, $route) |
||
68 | { |
||
69 | $asc = mergeQueryString(["orderby" => $column, "order" => "asc"], $route); |
||
70 | $desc = mergeQueryString(["orderby" => $column, "order" => "desc"], $route); |
||
71 | |||
72 | return <<<EOD |
||
73 | <span class="orderby"> |
||
74 | <a href="$asc">↑</a> |
||
75 | <a href="$desc">↓</a> |
||
76 | </span> |
||
77 | EOD; |
||
78 | } |
||
79 | |||
80 | |||
81 | |||
82 | /** |
||
83 | * Use current querystring as base, extract it to an array, merge it |
||
84 | * with incoming $options and recreate the querystring using the |
||
85 | * resulting array. |
||
86 | * |
||
87 | * @param array $options to merge into exitins querystring |
||
88 | * @param string $prepend to the resulting query string |
||
89 | * |
||
90 | * @return string as an url with the updated query string. |
||
91 | */ |
||
92 | function mergeQueryString($options, $prepend = "?") |
||
93 | { |
||
94 | // Parse querystring into array |
||
95 | $query = []; |
||
96 | parse_str($_SERVER["QUERY_STRING"], $query); |
||
97 | |||
98 | // Merge query string with new options |
||
99 | $query = array_merge($query, $options); |
||
100 | |||
101 | // Build and return the modified querystring as url |
||
102 | return $prepend . http_build_query($query); |
||
103 | } |
||
104 | |||
105 | |||
106 | /** |
||
107 | * Check if key is set in POST. |
||
108 | * |
||
109 | * @param mixed $key to look for |
||
110 | * |
||
111 | * @return boolean true if key is set, otherwise false |
||
112 | */ |
||
113 | function hasKeyPost($key) |
||
114 | { |
||
115 | return array_key_exists($key, $_POST); |
||
116 | } |
||
117 | |||
118 | |||
119 | |||
120 | /** |
||
121 | * Sanitize value for output in view. |
||
122 | * |
||
123 | * @param string $value to sanitize |
||
124 | * |
||
125 | * @return string beeing sanitized |
||
126 | */ |
||
127 | function esc($value) |
||
128 | { |
||
129 | return htmlentities($value); |
||
130 | } |
||
131 | |||
132 | |||
133 | |||
134 | /** |
||
135 | * Create a slug of a string, to be used as url. |
||
136 | * |
||
137 | * @param string $str the string to format as slug. |
||
138 | * |
||
139 | * @return str the formatted slug. |
||
140 | */ |
||
141 | function slugify($str) |
||
142 | { |
||
143 | $str = mb_strtolower(trim($str)); |
||
144 | $str = str_replace(['å','ä'], 'a', $str); |
||
145 | $str = str_replace('ö', 'o', $str); |
||
146 | $str = preg_replace('/[^a-z0-9-]/', '-', $str); |
||
147 | $str = trim(preg_replace('/-+/', '-', $str), '-'); |
||
148 | return $str; |
||
149 | } |
||
150 | |||
151 | /** |
||
152 | * Get either a Gravatar URL or complete image tag for a specified email address. |
||
153 | * |
||
154 | * @param string $email The email address |
||
155 | * @param string $sportSize in pixels, defaults to 80px [ 1 - 2048 ] |
||
156 | * @param string $d Default imageset to use [ 404 | mp | identicon | monsterid | wavatar ] |
||
157 | * @param string $r Maximum rating (inclusive) [ g | pg | r | x ] |
||
158 | * @param boole $img True to return a complete IMG tag False for just the URL |
||
0 ignored issues
–
show
|
|||
159 | * @param array $atts Optional, additional key/value attributes to include in the IMG tag |
||
160 | * @return String containing either just a URL or a complete image tag |
||
161 | * @source https://gravatar.com/site/implement/images/php/ |
||
162 | */ |
||
163 | function get_gravatar($email, $sport = 80, $dport = 'mp', $rport = 'g', $img = false, $atts = array()) |
||
164 | { |
||
165 | $url = 'https://www.gravatar.com/avatar/'; |
||
166 | $url .= md5(strtolower(trim($email))); |
||
167 | $url .= "?s=$sport&d=$dport&r=$rport"; |
||
168 | if ($img) { |
||
169 | $url = '<img src="' . $url . '"'; |
||
170 | foreach ($atts as $key => $val) { |
||
171 | $url .= ' ' . $key . '="' . $val . '"'; |
||
172 | $url .= ' />'; |
||
173 | } |
||
174 | } |
||
175 | return $url; |
||
176 | } |
||
177 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths