View difference between Paste ID: Fu50kp4n and MkfyARmD
SHOW: | | - or go back to the newest paste.
1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <title></title>
5
    <style>
6
        label, textarea, input {
7
            display: block;
8
        }
9
        textarea {
10
            width: 300px;
11
            height: 200px;
12
        }
13
    </style>
14
</head>
15
<body>
16
<form method="get" action="">
17
    <label>Text:</label>
18
    <textarea name="text">Hi, I'm an air-conditioner technician, so if you need any assistance you can contact me at [email protected] .
19
        Secondary email: [email protected] or at [email protected] OR [email protected]</textarea>
20
    <label>Blacklist:</label>
21
    <textarea name="blacklist">*.bg
22
        [email protected]
23
        *.com</textarea>
24
    <input type="submit" />
25
</form>
26
<?php
27
function getReplacement($match , $blacklist) {
28
    preg_match("/(\\..*)/" , $match , $domain); // get domain from current match
29
    $dom = "*" . $domain[0]; // get domain with * before it
30
    if (in_array($dom, $blacklist) || in_array($match , $blacklist)) {
31
        return str_pad('', strlen($match), '*'); // encode domain/match from blacklist
32
    }
33
    else {
34
        return "<a href=\"mailto:" . $match . "\">$match</a>";
35
    }
36
}
37
    if (isset($_GET['text']) && isset($_GET['blacklist'])) {
38
        $textArea = $_GET['text'];
39
        $bl = $_GET['blacklist']; // get value from text area with name "blacklist"
40
        //var_dump($bl) . "</br>";
41-
41+
42-
        function getReplacement($match , $blacklist) {
42+
43-
            preg_match("/(\\..*)/" , $match , $domain); // get domain from current match
43+
44-
            $dom = "*" . $domain[0]; // get domain with * before it
44+
45-
            if (in_array($dom, $blacklist) || in_array($match , $blacklist)) {
45+
46-
                return str_pad('', strlen($match), '*'); // encode domain/match from blacklist
46+
47-
            }
47+
48-
            else {
48+
49-
                return "<a href=\"mailto:" . $match . "\">$match</a>";
49+
50-
            }
50+
51
    }
52
?>
53
</body>
54
</html>