Hello,
I need some help by my extensions. I don't know why I get this output on the page: 1 2 0 (http://wiki.keb-vogelsberg.de/index.php?title=Hauptseite) by the input <toolserver_poll id=2></toolserver_poll>
Zu Deutsch:
Hallo,
Ich brauche Hilfe bei meiner Mediawiki-Erweiterung. Ich kann mir nicht erklären, warum ich dieses Ergebnis auf der Seite erhalte: 1 2 0 (http://wiki.keb-vogelsberg.de/index.php?title=Hauptseite)
Code of the Extensions:
<?php
/**
* Toolserver Poll - Include the Toolserver-Poll-Skript(http://toolserver.org/~jan/poll/index.php)
*
* To activate this extension, add the following into your LocalSettings.php file:
* require_once("$IP/extensions/Toolserver_Poll/toolserver_poll.php");
*
* @ingroup Extensions
* @author Jan Luca jan@toolserver.org
* @version 1.0 Alpha
* @link http://www.mediawiki.org/wiki/Extension:MyExtension Documentation
* @license http://creativecommons.org/licenses/by-sa/3.0/ Attribution-Share Alike 3.0 Unported or later
*/
/**
* Protect against register_globals vulnerabilities.
* This line must be present before any global variable is referenced.
*/
if( !defined( 'MEDIAWIKI' ) ) {
echo( "This is an extension to the MediaWiki package and cannot be run standalone.\n" );
die( -1 );
}
// Extension credits that will show up on Special:Version
$wgExtensionCredits['parserhook'][] = array(
'name' => 'Toolserver Poll',
'version' => '1.0 Alpha',
'author' => 'Jan Luca',
'url' => 'http://www.mediawiki.org/wiki/Extension:Toolserver_poll',
'descriptionmsg'=> 'descript_msg'
);
//Avoid unstubbing $wgParser on setHook() too early on modern (1.12+) MW versions, as per r35980
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
$wgHooks['ParserFirstCallInit'][] = 'eftoolserver_pollSetup';
} else { // Otherwise do things the old fashioned way
$wgExtensionFunctions[] = 'eftoolserver_pollSetup';
}
$wgExtensionMessagesFiles['toolserver_poll'] = dirname( __FILE__ ) . '/toolserver_poll.i18n.php';
function eftoolserver_pollSetup() {
global $wgParser;
$wgParser->setHook( 'toolserver_poll', 'eftoolserver_pollRender' );
return true;
}
function get_request($server,$page,$ignore_redir=false,$it=0) {
global $count;
$count++;
//$cookies=cookiestring($server);
$fp = fsockopen ($server, 80, $errno, $errstr, 10);
if (!$fp) {
if($it < 4) { get_request($server,$page,$ignore_redir,$it+1); } else { echo "get_request($server,$page) fehlgeschlagen: $errstr!<br />\n"; }
} else {
fputs ($fp,"GET $page HTTP/1.1
Host: $server
Cookie: $cookies
User-Agent: ".USERAGENT."
\r\n\r\n");
while (!feof($fp)) {
$buf.= fgets($fp,128);
}
fclose($fp);
$buf2=getheaders($buf);
preg_match('@Location: http://(.*)/(.*)%5Cr%5Cn@iU%27,$buf2,$hit);
if($hit[1]!="" && (!$ignore_redir)) {
$buf=get_request($hit[1],"/".$hit[2]);
}
//update_cookies(getheaders($buf),$server);
flush();
return $buf;
}
}
function getheaders($buf) {
preg_match ("/^(.*)\r\n\r\n/is",$buf,$hit);
return $hit[1];
}
function removeheaders($buf) {
preg_match ("/\r\n\r\n(.*)$/is",$buf,$hit);
return $hit[1];
}
function eftoolserver_pollRender( $input, $args, $parser ) {
foreach( $args as $name => $value )
$id = htmlspecialchars( $value );
$get_server = removeheaders(get_request('toolserver.org','/~jan/poll/dev/main.php?page=wik i_output&id='.$id.''));
if(isset($get_server)) {
return $get_server;
}
else {
return "nicht funktioniert";
}
}
Code von main.php:
$page = $_GET['page'];
...
if($page == "wiki_output") {
$wiki_id = $_GET['id'];
echo $wiki_id;
}
MfG
Jan Luca
mediawiki-l@lists.wikimedia.org