Index: trunk/extensions/CongressLookup/maintenance/checkContacts.php |
— | — | @@ -44,13 +44,30 @@ |
45 | 45 | } |
46 | 46 | |
47 | 47 | protected function checkContactLink( $name, $url, &$countOk ) { |
48 | | - $req = MWHttpRequest::factory( $url, array( |
49 | | - 'method' => 'GET', |
50 | | - 'timeout' => 8, |
51 | | - 'sslVerifyHost' => false, // just check if it can be reached |
52 | | - 'sslVerifyCert' => false, // just check if it can be reached |
53 | | - ) ); |
54 | | - if ( $req->execute()->isOK() ) { |
| 48 | + global $wgVersion; |
| 49 | + |
| 50 | + $ok = false; |
| 51 | + if ( Sanitizer::validateEmail( $url ) ) { |
| 52 | + $ok = true; // assume OK |
| 53 | + } else { |
| 54 | + $bits = wfParseUrl( $url ); |
| 55 | + if ( $bits && isset( $bits['scheme'] ) ) { |
| 56 | + if ( $bits['scheme'] == 'mailto' ) { |
| 57 | + $ok = true; // assume OK |
| 58 | + } elseif ( in_array( $bits['scheme'], array( 'http', 'https' ) ) ) { |
| 59 | + $req = MWHttpRequest::factory( $url, array( |
| 60 | + 'method' => 'GET', |
| 61 | + 'timeout' => 8, |
| 62 | + 'sslVerifyHost' => false, // just check if it can be reached |
| 63 | + 'sslVerifyCert' => false, // just check if it can be reached |
| 64 | + ) ); |
| 65 | + $req->setUserAgent( "MediaWiki {$wgVersion}, CheckCongressLinks Checker" ); |
| 66 | + $ok = $req->execute()->isOK(); |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + if ( $ok ) { |
55 | 72 | ++$countOk; |
56 | 73 | } else { |
57 | 74 | $this->output( "Broken: [$name] [$url]\n" ); |