1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* /classes/DomainMOD/Format.php |
4
|
|
|
* |
5
|
|
|
* This file is part of DomainMOD, an open source domain and internet asset manager. |
6
|
|
|
* Copyright (c) 2010-2020 Greg Chetcuti <[email protected]> |
7
|
|
|
* |
8
|
|
|
* Project: http://domainmod.org Author: http://chetcuti.com |
9
|
|
|
* |
10
|
|
|
* DomainMOD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public |
11
|
|
|
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later |
12
|
|
|
* version. |
13
|
|
|
* |
14
|
|
|
* DomainMOD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
15
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU General Public License along with DomainMOD. If not, see |
18
|
|
|
* http://www.gnu.org/licenses/. |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
//@formatter:off |
22
|
|
|
namespace DomainMOD; |
23
|
|
|
|
24
|
|
|
class Format |
25
|
|
|
{ |
26
|
|
|
public $sanitize; |
27
|
|
|
|
28
|
|
|
public function __construct() |
29
|
|
|
{ |
30
|
|
|
$this->sanitize = new Sanitize(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function stripSpacing($input) |
34
|
|
|
{ |
35
|
|
|
return trim(preg_replace("/^\n+|^[\t\s]*\n+/m", "", $input)); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function replaceBreaks($input_notes) |
39
|
|
|
{ |
40
|
|
|
$output_notes = trim($input_notes); |
41
|
|
|
$output_notes = str_replace("\n\n", "<BR><BR>", $output_notes); |
42
|
|
|
return str_replace("\n", "<BR>", $output_notes); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function cleanAndSplitDomains($raw_domain_list) |
46
|
|
|
{ |
47
|
|
|
$clean_domain_list = $this->stripSpacing($raw_domain_list); |
48
|
|
|
$domain_list = explode("\r\n", $clean_domain_list); |
49
|
|
|
$new_domain_list = array(); |
50
|
|
|
foreach ($domain_list as $value) { |
51
|
|
|
$new_domain_list[] = $this->sanitize->text($this->stripSpacing($value)); |
52
|
|
|
} |
53
|
|
|
return array_unique($new_domain_list); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function formatForMysql($domain_list) |
57
|
|
|
{ |
58
|
|
|
$new_domain_list = array(); |
59
|
|
|
foreach ($domain_list as $value) { |
60
|
|
|
$new_domain_list[] = $value; |
61
|
|
|
} |
62
|
|
|
$list_formatted = implode("\r\n", $new_domain_list); |
63
|
|
|
$list_formatted = "'" . $list_formatted; |
64
|
|
|
$list_formatted = $list_formatted . "'"; |
65
|
|
|
$list_formatted = preg_replace("/\r\n/", "','", $list_formatted); |
66
|
|
|
$list_formatted = str_replace(" ", "", $list_formatted); |
67
|
|
|
return trim($list_formatted); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function obfusc($input) |
71
|
|
|
{ |
72
|
|
|
return str_repeat("*", strlen($input)); |
73
|
|
|
} |
74
|
|
|
} //@formatter:on |
75
|
|
|
|