Index: trunk/tools/web-scripts/missing.php |
— | — | @@ -1,163 +1,210 @@ |
2 | 2 | <?php |
3 | | -header("HTTP/1.x 404 Not Found"); // don't cache me |
4 | | -header("Content-Type: text/html; charset=utf-8"); |
5 | | -?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
6 | | -<!-- Sysops: Please do not edit the main template directly; update /temp and synchronise. --> |
7 | | -<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> |
8 | | - <head> |
9 | | - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
10 | | - <meta http-equiv="Content-Language" content="en" /> |
11 | | - <meta http-equiv="Content-Style-Type" content="text/css" /> |
12 | | - <meta http-equiv="Content-Script-Type" content="text/javascript" /> |
13 | | - <!--[if lt IE 7]> |
14 | | - <meta http-equiv="imagetoolbar" content="no" /> |
15 | | - <![endif]--> |
16 | | - <title>Wiki does not exist</title> |
17 | | - <meta name="title" content="Wiki does not exist" /> |
18 | | - <meta name="description" content="Wikimedia Foundation site error page when a wiki does not exist." /> |
19 | | - <meta name="author" content="The Wikimedia Foundation" /> |
20 | | - <meta name="copyright" content="Creative Commons Attribution-Share Alike 3.0"/> |
21 | | - <meta name="publisher" content="The Wikimedia Foundation" /> |
22 | | - <meta name="language" content="English" /> |
23 | | - <meta name="robots" content="index, follow" /> |
24 | | - <meta name="MSSmartTagsPreventParsing" content="true" /> |
25 | | - <link rel="shortcut icon" href="http://wikimediafoundation.org/favicon.ico" /> |
26 | | - <link rel="apple-touch-icon" href="http://wikimediafoundation.org/favicon.ico" /> |
27 | | - <link rel="copyright" href="http://creativecommons.org/licenses/by-sa/3.0/" /> |
28 | | - <link rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/" /> |
29 | | - <style type="text/css"> |
30 | | -body |
31 | | -{ |
32 | | - background-color: White; |
| 3 | + |
| 4 | +/** |
| 5 | + * Missing wiki redirect / 404 page |
| 6 | + * |
| 7 | + * This file redirects non-existing languages of Wikipedia, Wiktionary, Wikiquote, |
| 8 | + * Wikibooks and Wikinews to the Wikimedia Incubator. Non-existing languages of |
| 9 | + * Wikisource and Wikiversity show static 404 page. |
| 10 | + * |
| 11 | + * There is a specific extension on Incubator used to make nice "welcome pages" |
| 12 | + * (adapted to each language, project and translatable). |
| 13 | + * |
| 14 | + * These redirects allow the usage of interwiki links from existing language |
| 15 | + * subdomains to Incubator, e.g. [[xyz:Page]] on en.wikipedia links to |
| 16 | + * http://incubator.wikimedia.org/wiki/Wp/xyz/Page |
| 17 | + * |
| 18 | + * @copyright Copyright © 2011, Danny B., SPQRobin |
| 19 | + * |
| 20 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 21 | + */ |
| 22 | + |
| 23 | + |
| 24 | +/** |
| 25 | + * Obtaining the full self URL |
| 26 | + * @return string Actual URL except for fragment part |
| 27 | + */ |
| 28 | +function getSelfUrl() { |
| 29 | + |
| 30 | + /* faking https on secure.wikimedia.org - thanks Ryan for hint */ |
| 31 | + if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) { |
| 32 | + |
| 33 | + $_SERVER['HTTPS'] = 'on'; |
| 34 | + |
| 35 | + } |
| 36 | + |
| 37 | + $s = empty( $_SERVER['HTTPS'] ) ? '' : ( $_SERVER['HTTPS'] == 'on' ) ? 's' : ''; |
| 38 | + |
| 39 | + $protocol = substr( strtolower( $_SERVER['SERVER_PROTOCOL'] ), 0, strpos( strtolower( $_SERVER['SERVER_PROTOCOL'] ), '/' ) ) . $s; |
| 40 | + |
| 41 | + $port = ( $_SERVER['SERVER_PORT'] == '80') ? '' : ( ':' . $_SERVER['SERVER_PORT'] ); |
| 42 | + |
| 43 | + return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI']; |
| 44 | + |
33 | 45 | } |
34 | | - |
35 | | -a |
36 | | -{ |
37 | | - text-decoration: none; |
| 46 | + |
| 47 | + |
| 48 | +$projects = array( |
| 49 | + 'wikibooks' => 'b', |
| 50 | + 'wikinews' => 'n', |
| 51 | + 'wikipedia' => 'p', |
| 52 | + 'wikiquote' => 'q', |
| 53 | + 'wikisource' => 's', // forward compatiblity, unused ATM |
| 54 | + 'wikiversity' => 'v', // forward compatiblity, unused ATM |
| 55 | + 'wiktionary' => 't', |
| 56 | +); |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +$url = parse_url( getSelfUrl() ); |
| 61 | + |
| 62 | +if( $url['host'] == 'secure.wikimedia.org' ) { |
| 63 | + |
| 64 | + # https://secure.wikimedia.org/$project/$language/wiki/$page |
| 65 | + $tmp = explode( '/', ltrim( $url['path'], '/' ) ); |
| 66 | + $project = $tmp[0]; |
| 67 | + $language = $tmp[1]; |
| 68 | + $base = 'secure.wikimedia.org/wikipedia/incubator/wiki/'; |
| 69 | + $page = implode( array_slice( $tmp, 2 ) ); |
| 70 | + |
| 71 | +} else { |
| 72 | + |
| 73 | + # http(s)://$language.$project.org/wiki/$page |
| 74 | + $tmp = explode( '.', $url['host'] ); |
| 75 | + $project = $tmp[1]; |
| 76 | + $language = $tmp[0]; |
| 77 | + $base = 'incubator.wikimedia.org/wiki/'; |
| 78 | + $page = preg_replace( '/^\/wiki\//', '', $url['path'] ); |
| 79 | + |
38 | 80 | } |
39 | | - |
40 | | -a:hover |
41 | | -{ |
42 | | - text-decoration: underline; /* moot */ |
| 81 | + |
| 82 | +$project = strtolower( $project ); |
| 83 | +$projectcode = $projects[$project]; |
| 84 | +$project = ucfirst( $project ); // for 404 pages message |
| 85 | + |
| 86 | +$location = $url['scheme'] . '://' . $base . 'W' . $projectcode . '/' . $language . ( $page ? '/' . $page : '?goto=mainpage' ); |
| 87 | + |
| 88 | +$redir = false; |
| 89 | + |
| 90 | +switch( $projectcode ) { |
| 91 | + |
| 92 | + # Wikisource |
| 93 | + case 's': |
| 94 | + $logo = 'http://upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Wikisource-logo.svg/280px-Wikisource-logo.svg.png'; |
| 95 | + $home = 'http://wikisource.org'; |
| 96 | + $name = 'Multilingual Wikisource'; |
| 97 | + break; |
| 98 | + |
| 99 | + # Wikiversity |
| 100 | + case 'v': |
| 101 | + $logo = 'http://upload.wikimedia.org/wikipedia/commons/thumb/9/91/Wikiversity-logo.svg/300px-Wikiversity-logo.svg.png'; |
| 102 | + $home = 'http://beta.wikiversity.org'; |
| 103 | + $name = 'Beta Wikiversity'; |
| 104 | + break; |
| 105 | + |
| 106 | + # Wikipedia, Wiktionary, Wikiquote, Wikibooks and Wikinews |
| 107 | + default: |
| 108 | + $redir = true; |
| 109 | + |
43 | 110 | } |
44 | | - |
45 | | -img |
46 | | -{ |
47 | | - border: 0; |
| 111 | + |
| 112 | +# OUTPUT |
| 113 | +# @fixme replace heredoc by better approach |
| 114 | +if( $redir ) { |
| 115 | + |
| 116 | + header( 'Location: ' . $location ); |
| 117 | + exit(); |
| 118 | + |
| 119 | +} else { |
| 120 | + |
| 121 | + header( 'HTTP/1.x 404 Not Found' ); |
| 122 | + header( 'Content-Type: text/html; charset=utf-8'); |
| 123 | + |
| 124 | + echo <<< EOT |
| 125 | +<html> |
| 126 | + |
| 127 | +<head> |
| 128 | + |
| 129 | +<title>$language $project does not exist</title> |
| 130 | + |
| 131 | +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 132 | + |
| 133 | +<link rel="shortcut icon" href="$home/favicon.ico"> |
| 134 | + |
| 135 | +<style type="text/css"> |
| 136 | +/* <![CDATA[ */ |
| 137 | +* { |
| 138 | + font-family: 'Gill Sans', 'Gill Sans MT', sans-serif; |
| 139 | + margin: 0; |
| 140 | + padding: 0; |
48 | 141 | } |
49 | | - |
50 | | -table#content |
51 | | -{ |
52 | | - width: 75%; |
53 | | - margin-left: auto; |
54 | | - margin-right: auto; |
| 142 | + |
| 143 | +body { |
| 144 | + background: #fff url('http://upload.wikimedia.org/wikipedia/commons/9/96/Errorbg.png') repeat-x; |
| 145 | + color: #333; |
| 146 | + margin: 0; |
| 147 | + padding: 0; |
55 | 148 | } |
56 | | - |
57 | | -table#content th, |
58 | | -table#content td |
59 | | -{ |
60 | | - padding: 0.5em 1em; |
61 | | - text-align: center; |
62 | | - vertical-align: middle; |
| 149 | + |
| 150 | +#page { |
| 151 | + background: url('$logo') center left no-repeat; |
| 152 | + height: 300px; |
| 153 | + left: 50%; |
| 154 | + margin: -150px 0 0 -360px; |
| 155 | + overflow: visible; |
| 156 | + position: absolute; |
| 157 | + top: 50%; |
| 158 | + width: 720px; |
63 | 159 | } |
64 | | - |
65 | | -table#content th |
66 | | -{ |
67 | | - font-family: "Lucida Sans", Verdana, sans-serif; |
| 160 | + |
| 161 | +#message { |
| 162 | + background: url('http://upload.wikimedia.org/wikipedia/commons/9/97/Errorline.png') center left no-repeat; |
| 163 | + margin-left: 300px; |
| 164 | + padding-left: 15px; |
68 | 165 | } |
69 | | - |
70 | | -table#content th h1 |
71 | | -{ |
72 | | - font-size: 190%; |
73 | | - font-weight: bold; |
74 | | - margin: 0 0 .3em 0; |
| 166 | + |
| 167 | +h1, h2, p { |
| 168 | + margin-bottom: 1em; |
75 | 169 | } |
76 | | - |
77 | | -table#content th p |
78 | | -{ |
79 | | - font-size: 110%; |
80 | | - font-weight: normal; |
81 | | - margin: .3em 0; |
| 170 | + |
| 171 | +a:link, a:visited { |
| 172 | + color: #005b90; |
82 | 173 | } |
83 | | - </style> |
84 | | - <!-- commonPrint.css? --> |
85 | | - <style type="text/css" media="print"> |
86 | | -/*<![CDATA[*/ |
87 | | -body |
88 | | -{ |
89 | | - background-color: transparent; |
| 174 | + |
| 175 | +a:hover, a:active { |
| 176 | + color: #900; |
90 | 177 | } |
91 | | - |
92 | | -table#content |
93 | | -{ |
94 | | - width: 100%; |
95 | | -} |
96 | | - |
97 | | -a |
98 | | -{ |
99 | | - color: Black !important; |
100 | | -} |
101 | | -/*]]>*/ |
102 | | - </style> |
103 | | - </head> |
104 | | - <body id="www-wikimedia-org"> |
105 | | - <table id="content" cellspacing="2" cellpadding="2"> |
106 | | - <tr> |
107 | | - <th colspan="3" style="text-align: left; vertical-align: top; width: 75%;"> |
108 | | - <h1> |
109 | | - Welcome to Wikimedia |
110 | | - </h1> |
111 | | - <p> |
112 | | - Unfortunately, this wiki does not exist yet, or it has been closed. You may be looking for one of our other projects below. If you would like to request that this wiki be created, see the <a href="http://meta.wikimedia.org/wiki/Requests_for_new_languages" title="Requests for new languages - Meta">requests for new languages</a> page on Meta-Wiki. |
113 | | - </p> |
114 | | - </th> |
115 | | - <td style="width: 25%;"> |
116 | | - <a href="http://wikimediafoundation.org/" title="Wikimedia Foundation"><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/12/Wikimedia_logo_text_RGB.svg/135px-Wikimedia_logo_text_RGB.svg.png" alt="Wikimedia Foundation" title="Wikimedia Foundation" /></a> |
117 | | - </td> |
118 | | - </tr> |
119 | | - <tr> |
120 | | - <td> |
121 | | - <a href="http://www.wikipedia.org/" title="Wikipedia — The Free Encyclopedia"><img src="http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png" width="135" height="155" alt="Wikipedia" title="Wikipedia — The Free Encyclopedia" /></a> |
122 | | - </td> |
123 | | - <td> |
124 | | - <a href="http://www.wiktionary.org/" title="Wiktionary"><img src="http://wiktionary.org/images/wiktionary-en.png" width="135" height="135" alt="Wiktionary" title="Wiktionary" /></a> |
125 | | - </td> |
126 | | - <td> |
127 | | - <a href="http://www.wikiquote.org/" title="Wikiquote"><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/1a/Wikiquote-logo-en.png/120px-Wikiquote-logo-en.png" width="120" height="120" alt="Wikiquote" title="Wikiquote" /></a> |
128 | | - </td> |
129 | | - <td> |
130 | | - <a href="http://www.wikibooks.org/" title="Wikibooks"><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Wikibooks-logo-en-noslogan.svg/140px-Wikibooks-logo-en-noslogan.svg.png" width="140" height="140" alt="Wikibooks" title="Wikibooks" /></a> |
131 | | - </td> |
132 | | - </tr> |
133 | | - <tr> |
134 | | - <td> |
135 | | - <a href="http://www.wikisource.org/" title="Wikisource"><img src="http://upload.wikimedia.org/wikipedia/sources/b/bc/Wiki.png" alt="Wikisource" title="Wikisource" /></a> |
136 | | - </td> |
137 | | - <td> |
138 | | - <a href="http://www.wikinews.org/" title="Wikinews"><img src="http://upload.wikimedia.org/wikinews/en/b/bc/Wiki.png" width="135" height="104" alt="Wikinews" title="Wikinews" /></a> |
139 | | - </td> |
140 | | - <td> |
141 | | - <a href="http://www.wikiversity.org/" title="Wikiversity"><img src="http://upload.wikimedia.org/wikiversity/en/b/bc/Wiki.png" width="135" height="119" alt="Wikiversity" title="Wikiversity" /></a> |
142 | | - </td> |
143 | | - <td> |
144 | | - <a href="http://species.wikimedia.org/" title="Wikispecies, a free directory of life!"><img src="http://upload.wikimedia.org/wikipedia/species/b/bc/Wiki.png" width="125" height="177" alt="Wikispecies" title="Wikispecies, a free directory of life!" /></a> |
145 | | - </td> |
146 | | - </tr> |
147 | | - <tr> |
148 | | - <td> |
149 | | - <a href="http://mediawiki.org/" title="MediaWiki"><img src="http://upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png" alt="MediaWiki" title="MediaWiki" /></a> |
150 | | - </td> |
151 | | - <td> |
152 | | - <a href="http://meta.wikimedia.org/" title="Wikimedia project coordination"><img src="http://upload.wikimedia.org/wikipedia/meta/b/bc/Wiki.png" alt="Meta-Wiki" title="Wikimedia project coordination" /></a> |
153 | | - </td> |
154 | | - <td> |
155 | | - <a href="http://commons.wikimedia.org/" title="Wikimedia Commons — Free media repository"><img src="http://upload.wikimedia.org/wikipedia/commons/7/79/Wiki-commons.png" width="135" height="155" alt="Wikimedia Commons" title="Wikimedia Commons — Free media repository" /></a> |
156 | | - </td> |
157 | | - <td> |
158 | | - <a href="http://incubator.wikimedia.org/" title="Wikimedia Incubator"><img src="http://upload.wikimedia.org/wikipedia/incubator/b/bc/Wiki.png" alt="Wikimedia Incubator" title="Wikimedia Incubator" /></a> |
159 | | - </td> |
160 | | - </tr> |
161 | | - </table> |
162 | | - </body> |
| 178 | + |
| 179 | +/* ]]> */ |
| 180 | +</style> |
| 181 | + |
| 182 | +</head> |
| 183 | + |
| 184 | +<body> |
| 185 | + |
| 186 | +<div id="page"> |
| 187 | + |
| 188 | + <div id="message"> |
| 189 | + |
| 190 | + <h1>This wiki does not exist</h1> |
| 191 | + |
| 192 | + <h2>Welcome to $project</h2> |
| 193 | + |
| 194 | + <p>Unfortunately, $project in "$language" does not exist on its own domain yet, or it has been closed.</p> |
| 195 | + |
| 196 | + <p>You may like to visit <a href="$home">$name</a> to start or improve <em>$language $project</em> there.</p> |
| 197 | + |
| 198 | + <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> |
| 199 | + |
| 200 | + <p style="font-size: smaller;">A project of the <a href="http://wikimediafoundation.org" title="Wikimedia Foundation">Wikimedia Foundation</a></p> |
| 201 | + |
| 202 | + </div> |
| 203 | + |
| 204 | +</div> |
| 205 | + |
| 206 | +</body> |
| 207 | + |
163 | 208 | </html> |
| 209 | +EOT; |
164 | 210 | |
| 211 | +} |