forked from wikimedia/operations-mediawiki-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract2.php
34 lines (29 loc) · 1.05 KB
/
extract2.php
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
<?php
$lang = 'meta';
putenv( "MW_LANG={$lang}" ); // notify MWMultiVersion
require '/srv/mediawiki/w/MWVersion.php';
require getMediaWiki( 'includes/WebStart.php' );
$allowed_templates = array(
'Www.wikimedia.org_template',
'Www.wikipedia.org_template',
'Www.wikinews.org_template',
'Www.wiktionary.org_template',
'Www.wikiquote.org_template',
'Www.wikiversity.org_template',
'Www.wikibooks.org_template',
'Www.wikivoyage.org_template',
);
$template = $wgRequest->getText( 'template', 'Www.wikipedia.org_template' );
if ( !in_array( $template, $allowed_templates ) ) {
header( 'Content-Type: text/plain; charset=utf-8' );
echo 'Invalid parameters...';
exit;
}
$wgTitle = Title::newFromText( $template );
$wgArticle = new Article( $wgTitle );
$rawHtml = $wgArticle->getContent( false );
$lastmod = gmdate( 'D, j M Y H:i:s', wfTimestamp( TS_UNIX, $wgArticle->getTouched() ) ) . ' GMT';
header( 'Content-Type: text/html; charset=utf-8' );
header( 'Cache-Control: s-maxage=3600, must-revalidate, max-age=0' );
header( "Last-modified: $lastmod" );
echo $rawHtml;