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: 19:
20: class cLinkcheckerRepair
21: {
22: 23: 24: 25: 26:
27: private $errorTypes = [
28: 'htp://',
29: 'htttp://',
30: 'htps://',
31: 'htttps://',
32: 'ww',
33: 'www',
34: 'wwww',
35: ];
36:
37: 38: 39: 40: 41: 42:
43: private $correctTypes = [
44: 'http://',
45: 'http://',
46: 'https://',
47: 'https://',
48: 'http://www',
49: 'http://www',
50: 'http://www',
51: ];
52:
53: 54: 55: 56: 57: 58: 59:
60: public function checkLink($link)
61: {
62: foreach ($this->errorTypes as $errorTypeKey => $errorType) {
63: if (cString::getPartOfString($link, 0, cString::getStringLength($errorType)) == $errorType) {
64: $repaired_link = str_replace($errorType, $this->correctTypes[$errorTypeKey], $link);
65: if ($this->_pingRepairedLink($repaired_link) == true) {
66: return $repaired_link;
67: } else {
68: return false;
69: }
70: }
71: }
72: }
73:
74: 75: 76: 77: 78: 79: 80:
81: private function _pingRepairedLink($repaired_link)
82: {
83: $repaired_link = cSecurity::escapeString($repaired_link);
84:
85: return @fopen($repaired_link, 'r');
86: }
87: }
88: