-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.php
More file actions
59 lines (51 loc) · 1.49 KB
/
util.php
File metadata and controls
59 lines (51 loc) · 1.49 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/*
Cleans GET and POST inputs.
Input an array with strings in the keys a values.
Returns an array with clean key and value strings.
*/
function clean($elem)
{
if(!is_array($elem))
$elem = htmlentities(trim($elem),ENT_QUOTES,"UTF-8");
else
foreach ($elem as $key => $value)
$elem[clean($key)] = clean($value);
return $elem;
}
function getSurveyQuestions($config){
$surveyKeys = array();
foreach ($config as $key => $valye) {
if (!strncasecmp("Likert:", $key, 7)) {
$surveyKeys[] = trim(substr($key, 7));
}
}
return $surveyKeys;
}
function isHumanBoolean($str) {
$test = strtolower(substr(trim($str), 0, 1));
return ($test == "1" or $test == "y" or $test == "t") ? True : False;
}
function end_session() {
// Unset all of the session variables.
$_SESSION = array();
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
// Finally, destroy the session.
session_destroy();
}
function glob_recursive($pattern, $flags = 0) {
$files = glob($pattern, $flags);
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
$files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags));
}
return $files;
}
?>