From 183851b06bd6c52f3cae5375f433da720d410447 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 11 Oct 2006 18:12:39 +0000 Subject: MediaWiki 1.7.1 wiederhergestellt --- maintenance/wiki-mangleme.php | 553 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 553 insertions(+) create mode 100644 maintenance/wiki-mangleme.php (limited to 'maintenance/wiki-mangleme.php') diff --git a/maintenance/wiki-mangleme.php b/maintenance/wiki-mangleme.php new file mode 100644 index 00000000..6b180257 --- /dev/null +++ b/maintenance/wiki-mangleme.php @@ -0,0 +1,553 @@ +", +"\"", "'", +">", +"http://","https://","url://","ftp://","file://","irc://","javascript:", +"!", +"\n! ", +"!!", +"||", +".gif", +".png", +".jpg", +".jpeg", +"", +"", +"Image:", +"[[category:", +"{{REVISIONID}}", +"{{SUBPAGENAME}}", +"{{SUBPAGENAMEE}}", +"{{ns:0}}", +"[[:Image", +"[[Special:", +"{{fullurl:}}", +'__TOC__', +"", +"", +"", +"" +); + + +///////////////////// A CLASS THAT GENERATES RANDOM STRINGS OF DATA ////////////////////// + +class htmler { + var $maxparams = 4; + var $maxtypes = 40; + + function randnum($finish,$start=0) { + return mt_rand($start,$finish); + } + + function randstring() { + global $ext; + $thestring = ""; + + for ($i=0; $i<40; $i++) { + $what = $this->randnum(1); + + if ($what == 0) { // include some random wiki syntax + $which = $this->randnum(count($ext) - 1); + $thestring .= $ext[$which]; + } + else { // include some random text + $char = chr(INCLUDE_BINARY ? $this->randnum(255) : $this->randnum(126,32)); + if ($char == "<") $char = ""; // we don't want the '<' character, it stuffs us up. + $length = $this->randnum(8); + $thestring .= str_repeat ($char, $length); + } + } + return $thestring; + } + + function makestring() { + global $ints, $other; + $what = $this->randnum(2); + if ($what == 0) { + return $this->randstring(); + } + elseif ($what == 1) { + return $ints[$this->randnum(count($ints) - 1)]; + } + else { + return $other[$this->randnum(count($other) - 1)]; + } + } + + function loop() { + global $types, $data; + $string = ""; + $i = $this->randnum(count($types) - 1); + $t = $types[$i]; + $arr = $data[$t]; + $string .= "<" . $types[$i] . " "; + for ($z=0; $z<$this->maxparams; $z++) { + $badparam = $arr[$this->randnum(count($arr) - 1)]; + $badstring = $this->makestring(); + $string .= $badparam . "=" . $badstring . " "; + } + $string .= ">\n"; + return $string; + } + + function main() { + $page = ""; + for ($k=0; $k<$this->maxtypes; $k++) { + $page .= $this->loop(); + } + return $page; + } +} + + +//////////////////// SAVING OUTPUT ///////////////////////// + + +/** +** @desc: Utility function for saving a file. Currently has no error checking. +*/ +function saveFile($string, $name) { + $fp = fopen ( DIRECTORY . "/" . $name, "w"); + fwrite($fp, $string); + fclose ($fp); +} + + +//////////////////// MEDIAWIKI PREVIEW ///////////////////////// + +/* +** @desc: Asks MediaWiki for a preview of a string. Returns the HTML. +*/ +function wikiPreview($text) { + + $params = array ( + "action" => "submit", + "wpMinoredit" => "1", + "wpPreview" => "Show preview", + "wpSection" => "new", + "wpEdittime" => "", + "wpSummary" => "This is a test", + "wpTextbox1" => $text + ); + + if( function_exists('curl_init') ) { + $ch = curl_init(); + } else { + die("Could not found 'curl_init' function. Is curl extension enabled ?\n"); + } + + curl_setopt($ch, CURLOPT_POST, 1); // save form using a POST + curl_setopt($ch, CURLOPT_POSTFIELDS, $params); // load the POST variables + curl_setopt($ch, CURLOPT_URL, WIKI_URL); // set url to post to + curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable + + $result=curl_exec ($ch); + + // if we encountered an error, then log it, and exit. + if (curl_error($ch)) { + trigger_error("Curl error #: " . curl_errno($ch) . " - " . curl_error ($ch) ); + print "Curl error #: " . curl_errno($ch) . " - " . curl_error ($ch) . " - exiting.\n"; + exit(); + } + + curl_close ($ch); + + return $result; +} + + +//////////////////// HTML VALIDATION ///////////////////////// + +/* +** @desc: Asks the validator whether this is valid HTML, or not. +*/ +function validateHTML($text) { + + $params = array ("fragment" => $text); + + $ch = curl_init(); + + curl_setopt($ch, CURLOPT_POST, 1); // save form using a POST + curl_setopt($ch, CURLOPT_POSTFIELDS, $params); // load the POST variables + curl_setopt($ch, CURLOPT_URL, VALIDATOR_URL); // set url to post to + curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable + + $result=curl_exec ($ch); + + // if we encountered an error, then log it, and exit. + if (curl_error($ch)) { + trigger_error("Curl error #: " . curl_errno($ch) . " - " . curl_error ($ch) ); + print "Curl error #: " . curl_errno($ch) . " - " . curl_error ($ch) . " - exiting.\n"; + exit(); + } + + curl_close ($ch); + + $valid = (strpos($result, "Failed validation") === false ? true : false); + + return array($valid, $result); +} + + + +/** +** @desc: checks the string to see if tags are balanced. +*/ +function checkOpenCloseTags($string, $filename) { + $valid = true; + + $lines = explode("\n", $string); + + $num_lines = count($lines); + // print "Num lines: " . $num_lines . "\n"; + + foreach ($lines as $line_num => $line) { + + // skip mediawiki's own unbalanced lines. + if ($line_num == 15) continue; + if ($line == "\t\t