This repository has been archived by the owner on Feb 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnormalize.php
executable file
·71 lines (48 loc) · 1.94 KB
/
normalize.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
function normalize_position($value) {
$value = trim(strtolower($value));
// global normalization
$value=str_replace('.','', $value);
// phd
$value=str_replace('professor', 'prof', $value);
$value=str_replace('profesor', 'prof', $value);
$value=str_replace('proffesor', 'prof', $value);
$value=str_replace('laboratory', ' lab', $value);
// final normalization
$value=str_replace('phd student', 'phd', $value);
$value=str_replace('doctor', 'dr', $value);
// phd
$value=str_replace('prof', 'professor', $value);
$value=str_replace('head of lab', 'head of laboratory', $value);
$value=str_replace('research officer', 'research assistant', $value);
$value=str_replace('assistant researcher', 'research assistant', $value);
// final normalization
$value=str_replace('phd', 'phd student', $value);
$value=str_replace('dr', 'doctor', $value);
$value = preg_replace('/\b(\w)/e', 'strtoupper("$1")', $value);
return $value;
}
function normalize_country($value) {
$value = trim($value);
// global normalization
$value=str_replace('.','', $value);
return $value;
}
function sanitize_input($value) {
//$value = mysql_real_escape_string($value);
//the use of addslashes() for string escaping in MySQL queries can lead to SQL injection
//through the abuse of multibyte character sets. In his example he relies on addslashes()
//to convert an invalid multibyte sequence into a valid one, which also has an embedded ' that
//is not escaped. And in an ironic twist, the function intended to protect against SQL injection
// is used to actually trigger it.
// lame security
$value=str_replace('drop','', $value);
$value=str_replace('select','', $value);
$value=str_replace('update','', $value);
$value=str_replace('delete','', $value);
$value = addcslashes($value, '%_');
$value = trim($value);
$value = htmlspecialchars($value);
return $value;
}
?>