User:Sent~metawiki/Bot:MediaWiki

From Meta, a Wikimedia project coordination wiki
 
A proposal to move this page to MediaWiki.org was rejected.

I still have to translate this page from Dutch to English. So, please be patient.

Here's a quick translation::

Bot:MediaWiki are a serial hacks on the standard installation of MediaWiki

Bone:MediaWiki script[edit]

Bot_MediaWiki-handler.php[edit]

<?php
${"bot:MediaWiki-Root "} ="/wiki /;
${"bot:mediaWiki noredirect} = TRUE;

require_once(dirname(__FILE __)./ Bot_MediaWiki.lib.php);

# $$wgScript>= ${"bot:MediaWiki"}["wgScript "] ="/wiki;
# $$wgRedirectScript>= ${"bot:MediaWiki"}["wgRedirectScript ] = ${"bot:MediaWiki-url}./ redirect.php;
# $$wgStylePath>= ${"bot:MediaWiki"}["wgStylePath ] = ${"bot:MediaWiki-url}."/skins";

bot_MediaWiki(${"bot:MediaWiki});
require_once(dirname(__FILE __).${"bot:MediaWiki-Nav2WebRoot}.${"bot:MediaWiki-url}./ index.php);
?>

In this file are possible the variables you where MediaWiki work on adapt. In the here above example also also the variable that stands [ [ User:Sent/bone:MediaWiki (nl)|Bot:MediaWiki will will replace ]]. For example $wgScript it are replaced by defining ${"bot:MediaWiki"}["wgScript"]. For this is possible you choose from all variables which in ' ' LocalSettings.php and ' ' DefaultSettings.php prevent .

Bot_MediaWiki.lib.php[edit]

<?php
${"bot:MediaWiki-url "} ="/.private/mediawiki-1.4.7;
${"bot:MediaWiki-Nav2WebRoot "} ="/..;

${"bot:MediaWiki} = array ();

# ${"bot:MediaWiki-search "} = $_server["redirect_script_url "];
# ${"bot:MediaWiki-search "} = $_server["script_url "];
# ${"bot:MediaWiki-search "} = $_server["redirect_url "];
${"bot:MediaWiki-search "} = $_server["request_uri "];

function check_pathinfo(){
	global ${"bot:MediaWiki-search}, ${"bot:MediaWiki-Root};
	return (ereg("^(.${"bot:MediaWiki-Root}.")(.*) $", ${"bot:MediaWiki-search}, #$$blaat>) && strlen($blaat[2 ]) > = 1);
}
function get_pathinfo(){
	global ${"bot:MediaWiki-search}, ${"bot:MediaWiki-Root};
        # $$path>= ereg_replace("^(.${"bot:MediaWiki-Root}.")", "", ${"bot:MediaWiki-search});
	return strip_GET(
		(strlen($path) > = 1? #$$path>: get_default_pathinfo())
	);
}			
function get_default_pathinfo(){
	return ' head page ';
}
function strip_get($str){
	if(ereg("^([^?]+)[?](.*) $", #$$str>, # $$a)){$$#2>
# $$old_str>= #$$str>;
		global $_get, $_request;
		list($trash, #$$str>, #$$g>) = #$$a>;
		# $$g_ar>= explode('&, #$$g>);
		foreach($g_ar ash # $$i=>$full_var){$$#7>
if(ereg("^([^=]+)=(.*) $", #$$full_var>, #$$b>)) {
				$_get[$b[1 ]] = # $$b[2>];
				$_request[$b[1 ]] = # $$b[2>];
				global ${$b[1 ]};
				# $$b[1>] = # $$b[2>];
			}			
		}
	}
	return #$$str>;
}
function bot_MediaWiki(#$$x=NULL>) {
	# $$type_list>= array(
		' pdf ' = >  ' application/pdf ',
		' poison ' = >  ' image/poison ',
		' jpg ' = >  ' image/jpeg ',
		' png ' = >  ' image/png ',
		' ico ' = >  ' image/x-icon ',
		' tgz ' = >  ' application/x-tar ',
		' gz ' = >  ' application/x-tar ',
		' htm ' = >  ' text/html ',
		' html ' = >  ' text/html ',
	);

	global ${"bot:MediaWiki-Nav2WebRoot}, ${"bot:MediaWiki-Root}, ${"bot:MediaWiki-url};
	# $$file>= dirname(__FILE __).${"bot:MediaWiki-Nav2WebRoot}.${"bot:MediaWiki-Root}.get_pathinfo ();
	if(file_exists ($file)){//File Excluded from Wiki execution
		# $$ext>= substr (get_pathinfo (), strrpos (get_pathinfo ().) + 1);
		if($ext == php'){
			require_once ($file);	
		}
		else{
			header('Content type: '.(array_key_exists($ext, $type_list)? # $$type_list[$ext>]: ' text/plain '));
			print file_get_contents ($file);
		}
		exit;
	}
}
# $$title>= $_get['title ' ] = $_request['title ' ] = get_pathinfo
();
$_server['path_info ' ] = '/.get_pathinfo ();
?>

Explanation bot_MediaWiki ()[edit]

This function supported the possibility for files within the directory where [ [ User:Sent/bone:MediaWiki (nl)|Bot:MediaWiki ]] on do not twist to let carry out by [ [ MediaWiki ]]. Thus it is possible for within the map images e.d. to take.

' ' for a very protect installation:

  • Install [ [ MediaWiki ]] in not by means of the web benaderbare a

map. (b.v. /var/www/hidden/mediawiki)

  • Fodder [ [ the User:Sent/bone:MediaWiki (nl)|Bot:mediaWiki]] directory the following from:
ln - s - d/var/www/hidden/mediawiki/skins
ln - s - d/var/www/hidden/mediawiki/images
  • Joint ' ' the bot_MediaWiki handler .php the next rule: ${"bot:MediaWiki"}["wgScriptPath ] = ${"bot:MediaWiki"}["wgScript"];
  • Configure ' ' the Bot_MediaWiki.lib.php with ${"bot:MediaWiki-url "} ="/../ hidden/mediawiki";

Configuration in Apache[edit]

For the use of the map ' ' '/wiki and implementation by means of ' ' ' Bot_MediaWiki-wiki .php :

AliasMatch ^/wiki(.*)/var/www/html/Bot_MediaWiki-wiki.php/$1

MediaWiki Extention[edit]

' ' free2xs/Bot_MediaWiki.php

<?php
/ * type of 1: string | type of 2: array | type of 3: boolean | type of 4: object | type of 5: | collect type of 32: = boolean:false OR array */
${"bot:MediaWiki-keys} = array(
	# DefaultSettings.php:
	' wgVersion ' = > 1, ' wgMetaNamespace ' = > 3, ' wgUsePathInfo
' = > 3, ' wgUseSharedUploads ' = > 3, ' wgSharedUploadPath ' =
> 1,
	' wgSharedUploadDirectory ' = > 1, ' wgHashedSharedUploadDirectory
' = > 3, ' wgSharedUploadDBname ' = > 1, ' wgSharedLatin1 ' =
> 3,
	' wgSMTP ' = > 32. ' wgDBschema ' = > 1, ' wgSharedDB ' = >
1, ' wgDBservers ' = > 32.
	' wgMasterWaitTimeout ' = > 5, ' wgDBClusterTimeout ' = > 5, '
wgDBminWordLen ' = > 1, ' wgDBtransaction ' = > 1,
	' wgDBerrorlog ' = > 1, ' wgSqlLogFile ' = > 1, '
wgDBtransactions ' = > 1, ' wgDBmysql4 ' = > 3,
	' wgSqlTimeout ' = > 5, ' wgLocalDatabases ' = > 2, '
wgMemCacheDebug ' = > 1, ' wgMemCachedServers ' = > 2,
	' wgMemCachedDebug ' = > 1, ' wgLinkCacheMemcached ' = > 1, '
wgMimeType ' = > 1, ' wgDocType ' = > 1,
	' wgDTD ' = > 1, ' wgUseDynamicDates ' = > 3, ' wgAmericanDates
' = > 1, ' wgTranslateNumerals ' = > 1,
	' wgNavigationLinks ' = > 2, ' wgExtraNamespaces ' = > 32. '
wgRateLimits ' = > 2, ' wgDisabledActions ' = > 2,
	# LocalSettings.php:
	' wgScript ' = > 1, ' wgRedirectScript ' = > 1, 
	' wgSitename ' = > 1, ' wgScriptPath ' = > 1, ' wgRenderScript '
= > 1, ' wgArticlePath ' = > 1,
	' wgStylePath ' = > 1, ' wgStyleDirectory ' = > 1, ' wgLogo ' =
> 1, ' wgUploadPath ' = > 1,
	' wgUploadDirectory ' = > 1, ' wgEmergencyContact ' = > 1, '
wgPasswordSender ' = > 1, ' wgDBserver ' = > 1,
	' wgDBname ' = > 1, ' wgDBuser ' = > 1, ' wgDBpassword ' = >
1, ' wgDBprefix ' = > 1, ' wgAllowSysopQueries ' = > 3,
	' wgDBsqluser ' = > 1, ' wgDBsqlpassword ' = > 1, '
wgUseMemCached ' = > 3, ' wgMemCachedServers ' = > 2,
	' wgUseTurckShm ' = > 3, ' wgDisableUploads ' = > 3, '
wgUseImageResize ' = > 3, ' wgUseImageMagick ' = > 3,
	' wgImageMagickConvertCommand ' = > 1, ' wgUseTeX ' = > 3, '
wgMathPath ' = > 1, ' wgMathDirectory ' = > 1,
	' wgTmpDirectory ' = > 1, ' wgLocalInterwiki ' = > 1, '
wgLanguageCode ' = > 1, ' wgUseLatin1 ' = > 3,
	' wgProxyKey ' = > 1, ' wgDefaultSkin ' = > 1, '
wgEnableCreativeCommonsRdf ' = > 3, ' wgRightsPage ' = > 1,
	' wgRightsUrl ' = > 1, ' wgRightsText ' = > 1, ' wgRightsIcon '
= > 1, ' wgRightsCode ' = > 1
);
if(is_array(${"bot:MediaWiki"})){
	foreach(${"bot:MediaWiki} ash # $$var=>$value){$$#2>
if(array_key_exists($var, ${"bot:MediaWiki-keys"})){
			# $$var>= #$$value>;
			/ * */echo <!-- bone:MediaWiki SETS.#$$var>.' TO '.#$$value>.' -- >'."\n";
		}
		else{
			/ * */echo <!-- bone:MediaWiki SUPPORTS NOT.#$$var>.' -- >'."\n";
		}
	}
}
foreach(${"bot:MediaWiki-keys} ash # $$key=>$type){$$#2>
switch($type){
		case 1:
			# $$i>= 0;
			while(ereg("[\$ ]", # $$key)){>//strpos($$key, "$")!= FALSE
				# $$i>++;
				# $$str>= "\$$key = \".#$$key>."\";;
				/ * */echo <!-- ".#$$str>;
				eval ($str);
				/ * */echo "/".#$$key>."-- >\n";
				if($i>=2) break;
			}
			/ * */else{echo <!-- bone:MediaWiki says; NO \ $ FOUND in # $$key>(".#$$key>.") -- >\n"; }
			break;
		case 2:
			if(!is_array($$key)) # $$key>= array ();
			break;
		case 3:
			switch($key){
				case ' wgUseTurckShm ':
					if($$key) # $$key>= (function_exists(' mmcache_get ') &&
php_sapi_name () == ' apache ');
					break;
				case ' wgUsePathInfo ':
					if($$key) # $$key>= (strpos(php_sapi_name (), ' cgi ') === false);
					break;
				default:
					# $$key>= (# $$key>== TRUE);
			}
			break;
		default:
			/ * */echo <!-- bone:MediaWiki says; THERE ARE NO METHOD FOR.#$$key>.(type:'.#$$type>.') -- >'."\n";
	}
}
if(${"bot:MediaWiki-debug} == TRUE){
	echo <pre style="background: # DDDDDD">;
	foreach(${"bot:MediaWiki-keys} ash # $$key=>$type){$$#2>
switch($type){
			case 3: echo #$$key>.' = <i>'.(#$$key>? ' true ': ' false ')."</i>\n"; break;
			default: echo #$$key>.' = '.#$$key>."\n"; break;
		}
	}
	echo ' 

';

} ?>

In the above ${"bot:mediaWiki keys"} to become not yet all variables which can be mentioned to fit. When you want adapt something and is present not yet in this list, joint it then.

Adaptations MediaWiki [edit]

  • Make of b.v. $wgArticlePath = #$$wgScript/$1";>; the

following $wgArticlePath =

  1. $$wgScript/$1';>;. In ' ' LocalSettings.php and ' ' DefaultSettings.php .
  • Joint include("extensions/free2xs/Bot_MediaWiki.php"); as first (!) extentie ' ' LocalSettings.php .
  • When [ [ MediaWiki ]] no longer work because index.php several php-bestanden cannot charge: let start the different require_onces with

dirname(__FILE __).'/'..

Extra possibility[edit]

Only when [ [ MediaWiki ]] are installed on a location which is by means of the server to reach!

' ' Frame_MediaWiki.php :

<?php 
${"bot:MediaWiki-Root "} ="/wiki /;
require_once(dirname(__FILE __)./ Bot_MediaWiki.lib.php);
?>
<html xml:lang="nl lang="nl">
<head>
<title>Karma Wiki</title>
</head>
<frameset cols = "*" rows = "*" border="1" frameborder="1"
framespacing="1" name="mainFrameset" id="mainFrameset">
	<frame src="<?php echo ${"bot:MediaWiki-url}./ index.php/.get_pathinfo (); ?> name="wiki" frameborder="0" id="wiki/>

	<noframes>
		<body bgcolor="#FFFFFF">
			<p>Deze page gebruit frames and your browser do not manage this.
			Click <a href="<?php echo ${"bot:MediaWiki-url}./ index.php/.get_pathinfo (); ?>">hier</a>
			when you nevertheless see content the will.</p>
        	</body>
	</noframes>
</frameset>
</noscript>

</html>

To the talk must get the possibility still a couple small adaptations be done MediaWiki .

  • ' ' skins/common/wikibits.j change if(window.top!= window) window.top.location = window.location; to if(window.top!= window) parent.document.title = this.document.title;.