Index: trunk/tools/web-scripts/missing.php |
— | — | @@ -25,22 +25,19 @@ |
26 | 26 | * @return string Actual URL except for fragment part |
27 | 27 | */ |
28 | 28 | function getSelfUrl() { |
29 | | - |
| 29 | + |
30 | 30 | /* faking https on secure.wikimedia.org - thanks Ryan for hint */ |
31 | 31 | if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) { |
32 | | - |
33 | 32 | $_SERVER['HTTPS'] = 'on'; |
34 | | - |
35 | 33 | } |
36 | | - |
| 34 | + |
37 | 35 | $s = empty( $_SERVER['HTTPS'] ) ? '' : ( $_SERVER['HTTPS'] == 'on' ) ? 's' : ''; |
38 | | - |
| 36 | + |
39 | 37 | $protocol = substr( strtolower( $_SERVER['SERVER_PROTOCOL'] ), 0, strpos( strtolower( $_SERVER['SERVER_PROTOCOL'] ), '/' ) ) . $s; |
40 | | - |
| 38 | + |
41 | 39 | $port = ( $_SERVER['SERVER_PORT'] == '80') ? '' : ( ':' . $_SERVER['SERVER_PORT'] ); |
42 | | - |
| 40 | + |
43 | 41 | return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI']; |
44 | | - |
45 | 42 | } |
46 | 43 | |
47 | 44 | |
— | — | @@ -59,81 +56,78 @@ |
60 | 57 | $url = parse_url( getSelfUrl() ); |
61 | 58 | |
62 | 59 | if( $url['host'] == 'secure.wikimedia.org' ) { |
63 | | - |
| 60 | + |
64 | 61 | # https://secure.wikimedia.org/$project/$language/wiki/$page |
65 | 62 | $tmp = explode( '/', ltrim( $url['path'], '/' ) ); |
66 | 63 | $project = $tmp[0]; |
67 | 64 | $language = $tmp[1]; |
68 | 65 | $base = 'secure.wikimedia.org/wikipedia/incubator/wiki/'; |
69 | 66 | $page = implode( array_slice( $tmp, 3 ) ); |
70 | | - |
| 67 | + |
71 | 68 | } else { |
72 | | - |
| 69 | + |
73 | 70 | # http(s)://$language.$project.org/wiki/$page |
74 | 71 | $tmp = explode( '.', $url['host'] ); |
75 | 72 | $project = $tmp[1]; |
76 | 73 | $language = $tmp[0]; |
77 | 74 | $base = 'incubator.wikimedia.org/wiki/'; |
78 | 75 | $page = preg_replace( '/^\/wiki\//', '', $url['path'] ); |
79 | | - |
| 76 | + |
80 | 77 | } |
81 | 78 | |
82 | 79 | $project = strtolower( $project ); |
83 | 80 | $projectcode = $projects[$project]; |
84 | 81 | $project = ucfirst( $project ); // for 404 pages message |
85 | 82 | |
86 | | -$location = $url['scheme'] . '://' . $base . 'W' . $projectcode . '/' . $language . ( $page ? '/' . $page : '?goto=mainpage' ); |
| 83 | +$location = $url['scheme'] . '://' . $base . 'W' . $projectcode . '/' . $language; |
| 84 | +# Go to the page if specified (look out for slashes), otherwise go to |
| 85 | +# the main page Wx/xyz?goto=mainpage (WikimediaIncubator extension takes care of that) |
| 86 | +$location .= $page && $page !== '/' ? '/' . $page : '?goto=mainpage'; |
87 | 87 | |
88 | 88 | $redir = false; |
89 | 89 | |
90 | 90 | switch( $projectcode ) { |
91 | | - |
| 91 | + |
92 | 92 | # Wikisource |
93 | 93 | case 's': |
94 | 94 | $logo = 'http://upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Wikisource-logo.svg/280px-Wikisource-logo.svg.png'; |
95 | 95 | $home = 'http://wikisource.org'; |
96 | 96 | $name = 'Multilingual Wikisource'; |
97 | 97 | break; |
98 | | - |
| 98 | + |
99 | 99 | # Wikiversity |
100 | 100 | case 'v': |
101 | 101 | $logo = 'http://upload.wikimedia.org/wikipedia/commons/thumb/9/91/Wikiversity-logo.svg/300px-Wikiversity-logo.svg.png'; |
102 | 102 | $home = 'http://beta.wikiversity.org'; |
103 | 103 | $name = 'Beta Wikiversity'; |
104 | 104 | break; |
105 | | - |
| 105 | + |
106 | 106 | # Wikipedia, Wiktionary, Wikiquote, Wikibooks and Wikinews |
107 | 107 | default: |
108 | 108 | $redir = true; |
109 | | - |
| 109 | + |
110 | 110 | } |
111 | 111 | |
112 | 112 | # OUTPUT |
113 | 113 | # @fixme replace heredoc by better approach |
114 | 114 | if( $redir ) { |
115 | | - |
| 115 | + |
116 | 116 | header( 'Location: ' . $location ); |
117 | 117 | exit(); |
118 | | - |
| 118 | + |
119 | 119 | } else { |
120 | | - |
| 120 | + |
121 | 121 | header( 'HTTP/1.x 404 Not Found' ); |
122 | 122 | header( 'Content-Type: text/html; charset=utf-8'); |
123 | | - |
124 | | - echo <<< EOT |
125 | | -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
126 | 123 | |
127 | | -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> |
128 | | - |
| 124 | + echo <<< EOT |
| 125 | +<!DOCTYPE html> |
| 126 | +<html lang="en" dir="ltr"> |
129 | 127 | <head> |
130 | | - |
131 | | -<title>$language $project does not exist</title> |
132 | | - |
133 | | -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
134 | | - |
135 | | -<link rel="shortcut icon" href="$home/favicon.ico" /> |
136 | | - |
137 | | -<style type="text/css"> |
| 128 | + <title>$language $project does not exist</title> |
| 129 | + <meta charset="UTF-8" /> |
| 130 | + <link rel="shortcut icon" href="$home/favicon.ico" /> |
| 131 | + <style type="text/css"> |
138 | 132 | /* <![CDATA[ */ |
139 | 133 | * { |
140 | 134 | font-family: 'Gill Sans', 'Gill Sans MT', sans-serif; |
— | — | @@ -142,7 +136,7 @@ |
143 | 137 | } |
144 | 138 | |
145 | 139 | body { |
146 | | - background: #fff url('http://upload.wikimedia.org/wikipedia/commons/9/96/Errorbg.png') repeat-x; |
| 140 | + background: #fff url('//upload.wikimedia.org/wikipedia/commons/9/96/Errorbg.png') repeat-x; |
147 | 141 | color: #333; |
148 | 142 | margin: 0; |
149 | 143 | padding: 0; |
— | — | @@ -160,7 +154,7 @@ |
161 | 155 | } |
162 | 156 | |
163 | 157 | #message { |
164 | | - background: url('http://upload.wikimedia.org/wikipedia/commons/9/97/Errorline.png') center left no-repeat; |
| 158 | + background: url('//upload.wikimedia.org/wikipedia/commons/9/97/Errorline.png') center left no-repeat; |
165 | 159 | margin-left: 300px; |
166 | 160 | padding-left: 15px; |
167 | 161 | } |
— | — | @@ -178,34 +172,27 @@ |
179 | 173 | } |
180 | 174 | |
181 | 175 | /* ]]> */ |
182 | | -</style> |
183 | | - |
| 176 | + </style> |
184 | 177 | </head> |
185 | | - |
186 | 178 | <body> |
| 179 | + <div id="page"> |
| 180 | + <div id="message"> |
187 | 181 | |
188 | | -<div id="page"> |
189 | | - |
190 | | - <div id="message"> |
191 | | - |
192 | | - <h1>This wiki does not exist</h1> |
193 | | - |
194 | | - <h2>Welcome to $project</h2> |
195 | | - |
196 | | - <p>Unfortunately, $project in "$language" does not exist on its own domain yet, or it has been closed.</p> |
197 | | - |
198 | | - <p>You may like to visit <a href="$home">$name</a> to start or improve <em>$language $project</em> there.</p> |
199 | | - |
200 | | - <p>If you would like to request that this wiki be created, see the <a href="http://meta.wikimedia.org/wiki/Requests_for_new_languages">requests for new languages</a> page on Meta-Wiki.</p> |
201 | | - |
202 | | - <p style="font-size: smaller;">A project of the <a href="http://wikimediafoundation.org" title="Wikimedia Foundation">Wikimedia Foundation</a></p> |
203 | | - |
204 | | - </div> |
205 | | - |
206 | | -</div> |
| 182 | + <h1>This wiki does not exist</h1> |
207 | 183 | |
208 | | -</body> |
| 184 | + <h2>Welcome to $project</h2> |
209 | 185 | |
| 186 | + <p>Unfortunately, $project in "$language" does not exist on its own domain yet, or it has been closed.</p> |
| 187 | + |
| 188 | + <p>You may like to visit <a href="$home">$name</a> to start or improve <em>$language $project</em> there.</p> |
| 189 | + |
| 190 | + <p>If you would like to request that this wiki be created, see the <a href="https://www.mediawiki.org//meta.wikimedia.org/wiki/Requests_for_new_languages">requests for new languages</a> page on Meta-Wiki.</p> |
| 191 | + |
| 192 | + <p style="font-size: smaller;">A project of the <a href="https://www.mediawiki.org//wikimediafoundation.org" title="Wikimedia Foundation">Wikimedia Foundation</a></p> |
| 193 | + |
| 194 | + </div> |
| 195 | + </div> |
| 196 | +</body> |
210 | 197 | </html> |
211 | 198 | EOT; |
212 | 199 | |