-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdisguise.php
63 lines (52 loc) · 1.53 KB
/
disguise.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
<?php
// DISGUISE FUNCTION
// this function takes 1 input (a string) and replaces anything in brackets [ ] with ****
// the idea is to obscure waterbody names or other stuff users want to keep secret
// disguiseBrackets
// USAGE:
// $notes = disguiseBrackets($notes);
function disguiseBrackets($string)
{
$regex = "/\[(.*?)\]/";
preg_match_all($regex, $string, $matches);
for($i = 0; $i < count($matches[1]); $i++)
{
$match = $matches[1][$i];
$array = explode('~', $match);
// $newValue = $array[0] . " - " . $array[1] . " - " . $array[2] . " - " . $array[3];
$newValue = "<span class='blurry-text'>top secret</span>";
$string = str_replace($matches[0][$i], $newValue, $string);
}
return $string;
}
// disguise
// USAGE:
// $notes = disguise($anything);
function disguise($input)
{
$input = "<span class='blurry-text'>top secret</span>";
return $input;
}
// disguiseWaterbody
// USAGE:
// $notes = disguise($nameofbodyofwater)
function disguiseWaterbody($waterbodyinput)
{
$waterbodyinput = "<span class='blurry-text'>$watertype</span>";
return $waterbodyinput;
}
// highlight
function highlight($target,$sometext)
{
$regex = "$something";
preg_match_all($regex, $target, $matches);
for($i = 0; $i < count($matches[1]); $i++)
{
$match = $matches[1][$i];
$array = explode('~', $match);
// $newValue = $array[0] . " - " . $array[1] . " - " . $array[2] . " - " . $array[3];
$newValue = "<span class='highlight'>$target</span>";
$sometext = str_replace($matches[0][$i], $newValue, $target);
}
return $sometext;
}