-
Notifications
You must be signed in to change notification settings - Fork 2
/
functions567.php
83 lines (71 loc) · 2.08 KB
/
functions567.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
72
73
74
75
76
77
78
79
80
81
82
83
<?php
function strip_all($in) {
$in = trim($in);
$in = stripslashes($in);
$in = htmlspecialchars($in);
return $in;
}
function validate_tnam1($in) {
if (empty($in)) {
return false;
}
$in = strip_all($in);
if (strlen($in) <> 45) {return false;}
$reg_tnam1 = '/tnam1[a-zA-Z0-9]{40}$/i';
return preg_match($reg_tnam1, $in);
}
function return_part_tnam1($in) {
if (empty($in)) {
return false;
}
$in = strip_all($in);
$reg_tnam1 = '/tnam1[a-zA-Z0-9]{40}/i';
$pattern_matches = '';
preg_match($reg_tnam1, $in, $pattern_matches);
if (empty($pattern_matches)) {
return false;
} else {
return($pattern_matches[0]);
}
}
function validate_integer($in) {
if (empty($in)) {
return false;
}
$in = strip_all($in);
if (strlen($in) > 25) {return false;}
$reg_int = '/\d+$/i';
return preg_match($reg_int, $in);
}
function validate_proposal_id($in) {
return validate_integer($in);
}
function validate_double($in) {
if (empty($in)) {return false;}
$in = strip_all($in);
if (strlen($in) > 25) {return false;}
$reg_double = '/^\d*\.?\d+$/i';
return preg_match($reg_double, $in);
}
function hyperlink_address($in, $mode_arg) {
$in = strip_all($in);
$mode_arg = strip_all($mode_arg);
$return_tnam = return_part_tnam1($in);
if (!$return_tnam) {die('wrong internal parameter call');}
$uri = strip_all($_SERVER['REQUEST_URI']);
$uri_parts = explode('?', $uri);
$uri = array_shift($uri_parts);
$servername = strip_all($_SERVER['HTTP_HOST']);
$newlink = 'https://' . $servername . $uri . '?address=' . $return_tnam . '&mode=' . $mode_arg . '&threshold=<gt=gt';
$returnstring = '<a href="' . $newlink . '" style="text-decoration: none">' . $in . '</a>';
return $returnstring;
}
function hyperlink_proposal($in, $mode_arg) {
$uri = strip_all($_SERVER['REQUEST_URI']);
$uri = array_shift(explode('?', $uri));
$servername = strip_all($_SERVER['HTTP_HOST']);
$newlink = 'https://' . $servername . $uri . '?proposal_id=' . $in;
$returnstring = '<a href="' . $newlink . '">' . $in . '</a>';
return $returnstring;
}
?>