| @@ 111-127 (lines=17) @@ | ||
| 108 | return false; |
|
| 109 | } |
|
| 110 | ||
| 111 | public function sanitazeLinks($links = array()) |
|
| 112 | { |
|
| 113 | $hrefs = array(); |
|
| 114 | ||
| 115 | if (!empty($links)) { |
|
| 116 | foreach ($links as $keyLink => $valueLink) { |
|
| 117 | $validResultOfBlackList = Utils::checkBlacklist($valueLink); |
|
| 118 | if (!$validResultOfBlackList and $valueLink) { |
|
| 119 | $hrefs[] = $valueLink; |
|
| 120 | } |
|
| 121 | } |
|
| 122 | ||
| 123 | $hrefs = array_unique($hrefs); |
|
| 124 | } |
|
| 125 | ||
| 126 | return $hrefs; |
|
| 127 | } |
|
| 128 | ||
| 129 | public function getLinks($body) |
|
| 130 | { |
|
| @@ 17-35 (lines=19) @@ | ||
| 14 | ||
| 15 | class Utils |
|
| 16 | { |
|
| 17 | public static function sanitazeLinks($links = array()) |
|
| 18 | { |
|
| 19 | $hrefs = array(); |
|
| 20 | ||
| 21 | if (!empty($links)) { |
|
| 22 | foreach ($links as $keyLink => $valueLink) { |
|
| 23 | $url = static::clearLink($valueLink->getAttribute('href')); |
|
| 24 | $validResultOfBlackList = static::checkBlacklist($url); |
|
| 25 | ||
| 26 | if (!$validResultOfBlackList and $url) { |
|
| 27 | $hrefs[] = $url; |
|
| 28 | } |
|
| 29 | } |
|
| 30 | ||
| 31 | $hrefs = array_unique($hrefs); |
|
| 32 | } |
|
| 33 | ||
| 34 | return $hrefs; |
|
| 35 | } |
|
| 36 | ||
| 37 | public static function checkBlacklist($url = '') |
|
| 38 | { |
|