-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpecialRedirectWarning.php
More file actions
38 lines (36 loc) · 964 Bytes
/
SpecialRedirectWarning.php
File metadata and controls
38 lines (36 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
class SpecialRedirectWarning extends SpecialPage {
function __construct() {
parent::__construct( 'RedirectWarning' );
}
function execute( $par ) {
$validSchemes = array( 'http', 'https' );
$request = $this->getRequest();
$output = $this->getOutput();
$this->setHeaders();
$parsed = parse_url( $par );
if ( isset( $parsed['scheme'] ) ) {
if ( in_array( $parsed['scheme'], $validSchemes ) ) {
throw new ErrorPageError( 'redirectwarning-goodurl',
'redirectwarning-goodurltext', $par
);
}
}
$title = Title::newFromText( $par );
if ( $title ) {
if ( !$title->isExternal() ) {
$this->throwInvalid( $par );
}
throw new ErrorPageError( 'redirectwarning-goodinterwiki',
'redirectwarning-goodinterwikitext',
$par
);
} else {
$this->throwInvalid( $par );
}
}
function throwInvalid( $par ) {
throw new ErrorPageError( 'redirectwarning-invalid',
'redirectwarning-invalidtext', $par );
}
}