1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
15:
16: 17: 18: 19: 20: 21:
22: class LinkcheckerRepair {
23:
24: 25: 26: 27: 28:
29: private $errorTypes = array(
30: 'htp://',
31: 'htttp://',
32: 'htps://',
33: 'htttps://',
34: 'ww',
35: 'www',
36: 'wwww'
37: );
38:
39: 40: 41: 42: 43: 44:
45: private $correctTypes = array(
46: 'http://',
47: 'http://',
48: 'https://',
49: 'https://',
50: 'http://www',
51: 'http://www',
52: 'http://www'
53: );
54:
55: 56: 57: 58: 59:
60: public function checkLink($link) {
61:
62: foreach ($this->errorTypes as $errorTypeKey => $errorType) {
63: if (substr($link, 0, strlen($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: return @fopen($repaired_link, 'r');
83: }
84:
85: }
86: ?>