1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
14:
15: 16: 17:
18: class cLinkcheckerSearchLinks
19: {
20: 21: 22:
23: private $mode = '';
24:
25: 26: 27:
28: public function __construct()
29: {
30: $this->setMode("text");
31: }
32:
33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43:
44: public function setMode($mode)
45: {
46: return $this->mode = cSecurity::toString($mode);
47: }
48:
49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65:
66: public function search($value, $idart, $nameart, $idcat, $namecat, $idlang, $idartlang, $idcontent = 0)
67: {
68: global $aUrl, $aSearchIDInfosNonID, $aWhitelist;
69:
70:
71: if (preg_match_all('~(?:(?:action|data|href|src)=["\']((?:file|ftp|http|ww)[^\s]*)["\'])~i', $value, $aMatches)
72: && $_GET['mode'] != 1
73: ) {
74: for ($i = 0; $i < count($aMatches[1]); $i++) {
75: if (!in_array($aMatches[1][$i], $aWhitelist)) {
76: $aSearchIDInfosNonID[] = [
77: "url" => $aMatches[1][$i],
78: "idart" => $idart,
79: "nameart" => $nameart,
80: "idcat" => $idcat,
81: "namecat" => $namecat,
82: "idcontent" => $idcontent,
83: "idartlang" => $idartlang,
84: "lang" => $idlang,
85: "urltype" => "extern",
86: ];
87: }
88: }
89: }
90:
91:
92: if ($this->mode == "redirect"
93: && (preg_match('!(' . preg_quote($aUrl['cms']) . '[^\s]*)!i', $value, $aMatches)
94: || (preg_match('~(?:file|ftp|http|ww)[^\s]*~i', $value, $aMatches) && $_GET['mode'] != 1))
95: && (cString::findFirstPosCI($value, 'front_content.php') === false)
96: && !in_array($aMatches[0], $aWhitelist)
97: ) {
98: $aSearchIDInfosNonID[] = [
99: "url" => $aMatches[0],
100: "idart" => $idart,
101: "nameart" => $nameart,
102: "idcat" => $idcat,
103: "namecat" => $namecat,
104: "idcontent" => 0,
105: "idartlang" => $idartlang,
106: "lang" => $idlang,
107: "urltype" => "unknown",
108: "redirect" => true,
109: ];
110: }
111:
112:
113: if (preg_match_all(
114: '~(?:(?:action|data|href|src)=["\'])(?!file://)(?!ftp://)(?!http://)(?!https://)(?!ww)(?!mailto)(?!\#)(?!/\#)([^"\']+)(?:["\'])~i',
115: $value,
116: $aMatches
117: )
118: && $_GET['mode'] != 2
119: ) {
120: for ($i = 0; $i < count($aMatches[1]); $i++) {
121: if (cString::findFirstPos($aMatches[1][$i], "front_content.php") === false
122: && !in_array(
123: $aMatches[1][$i],
124: $aWhitelist
125: )
126: ) {
127: $aSearchIDInfosNonID[] = [
128: "url" => $aMatches[1][$i],
129: "idart" => $idart,
130: "nameart" => $nameart,
131: "idcat" => $idcat,
132: "namecat" => $namecat,
133: "idcontent" => $idcontent,
134: "idartlang" => $idartlang,
135: "lang" => $idlang,
136: "urltype" => "intern",
137: ];
138: }
139: }
140: }
141:
142: return $aSearchIDInfosNonID;
143: }
144: }
145: