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