00001 <?php
00169
00170
00171
00172 require('commandLine.inc');
00173
00174
00175 if ( isset( $options["help"] ) ) {
00176 print <<<ENDS
00177 MediaWiki $wgVersion fuzz tester
00178 Usage: php {$_SERVER["SCRIPT_NAME"]} [--quiet] [--base-url=<url-to-test-wiki>]
00179 [--directory=<failed-test-path>] [--include-binary]
00180 [--w3c-validate] [--delete-passed-retests] [--help]
00181 [--user=<username>] [--password=<password>]
00182 [--rerun-failed-tests] [--max-errors=<int>]
00183 [--max-runtime=<num-minutes>]
00184 [--specific-test=<test-name>]
00185
00186 Options:
00187 --quiet : Hides passed tests, shows only failed tests.
00188 --base-url : URL to a wiki on which to run the tests.
00189 The "http://" is optional and can be omitted.
00190 --directory : Full path to directory for storing failed tests.
00191 Will be created if it does not exist.
00192 --include-binary : Includes non-alphanumeric characters in the tests.
00193 --w3c-validate : Validates pages using the W3C's web validator.
00194 Slow. Currently many pages fail validation.
00195 --user : Login name of a valid user on your test wiki.
00196 --password : Password for the valid user on your test wiki.
00197 --delete-passed-retests : Will delete retests that now pass.
00198 Requires --rerun-failed-tests to be meaningful.
00199 --rerun-failed-tests : Whether to rerun any previously failed tests.
00200 --max-errors : Maximum number of errors to report before exiting.
00201 Does not include errors from --rerun-failed-tests
00202 --max-runtime : Maximum runtime, in minutes, to run before exiting.
00203 Only applies to new tests, not --rerun-failed-tests
00204 --specific-test : Runs only the specified fuzz test.
00205 Only applies to new tests, not --rerun-failed-tests
00206 --keep-passed-tests : Saves all test files, even those that pass.
00207 --help : Show this help message.
00208
00209 Example:
00210 If you wanted to fuzz test a nightly MediaWiki checkout using cron for 1 hour,
00211 and only wanted to be informed of errors, and did not want to redo previously
00212 failed tests, and wanted a maximum of 100 errors, then you could do:
00213 php {$_SERVER["SCRIPT_NAME"]} --quiet --max-errors=100 --max-runtime=60
00214
00215
00216 ENDS;
00217
00218 exit( 0 );
00219 }
00220
00221
00222 // if we got command line options, check they look valid.
00223 $validOptions = array ("quiet", "base-url", "directory", "include-binary",
00224 "w3c-validate", "user", "password", "delete-passed-retests",
00225 "rerun-failed-tests", "max-errors",
00226 "max-runtime", "specific-test", "keep-passed-tests", "help" );
00227 if (!empty($options)) {
00228 $unknownArgs = array_diff (array_keys($options), $validOptions);
00229 foreach ($unknownArgs as $invalidArg) {
00230 print "Ignoring invalid command-line option: --$invalidArg\n";
00231 }
00232 }
00233
00234
00236
00237 // URL to some wiki on which we can run our tests.
00238 if (!empty($options["base-url"])) {
00239 define("WIKI_BASE_URL", $options["base-url"]);
00240 } else {
00241 define("WIKI_BASE_URL", $wgServer . $wgScriptPath . '/');
00242 }
00243
00244 // The directory name where we store the output.
00245 // Example for Windows: "c:\\temp\\wiki-fuzz"
00246 if (!empty($options["directory"])) {
00247 define("DIRECTORY", $options["directory"] );
00248 } else {
00249 define("DIRECTORY", "{$wgUploadDirectory}/fuzz-tests");
00250 }
00251
00252 // Should our test fuzz data include binary strings?
00253 define("INCLUDE_BINARY", isset($options["include-binary"]) );
00254
00255 // Whether we want to validate HTML output on the web.
00256 // At the moment very few generated pages will validate, so not recommended.
00257 define("VALIDATE_ON_WEB", isset($options["w3c-validate"]) );
00258 // URL to use to validate our output:
00259 define("VALIDATOR_URL", "http://validator.w3.org/check");
00260
00261 // Location of Tidy standalone executable.
00262 define("PATH_TO_TIDY", "/usr/bin/tidy");
00263
00264 // The name of a user who has edited on your wiki. Used
00265 // when testing the Special:Contributions and Special:Userlogin page.
00266 if (!empty($options["user"])) {
00267 define("USER_ON_WIKI", $options["user"] );
00268 } else {
00269 define("USER_ON_WIKI", "nickj");
00270 }
00271
00272 // The password of the above user. Used when testing the login page,
00273 // and to do this we sometimes need to login successfully.
00274 if (!empty($options["password"])) {
00275 define("USER_PASSWORD", $options["password"] );
00276 } else {
00277 // And no, this is not a valid password on any public wiki.
00278 define("USER_PASSWORD", "nickj");
00279 }
00280
00281 // If we have a test that failed, and then we run it again, and it passes,
00282 // do you want to delete it or keep it?
00283 define("DELETE_PASSED_RETESTS", isset($options["delete-passed-retests"]) );
00284
00285 // Do we want to rerun old saved tests at script startup?
00286 // Set to true to help catch regressions, or false if you only want new stuff.
00287 define("RERUN_OLD_TESTS", isset($options["rerun-failed-tests"]) );
00288
00289 // File where the database errors are logged. Should be defined in LocalSettings.php.
00290 define("DB_ERROR_LOG_FILE", $wgDBerrorLog );
00291
00292 // Run in chatty mode (all output, default), or run in quiet mode (only prints out details of failed tests)?
00293 define("QUIET", isset($options["quiet"]) );
00294
00295 // Keep all test files, even those that pass. Potentially useful to tracking input that causes something
00296 // unusual to happen, if you don't know what "unusual" is until later.
00297 define("KEEP_PASSED_TESTS", isset($options["keep-passed-tests"]) );
00298
00299
00300 if (!empty($options["max-runtime"]) && intval($options["max-runtime"])>0) {
00301 define("MAX_RUNTIME", intval($options["max-runtime"]) );
00302 }
00303
00304
00305 if (!empty($options["max-errors"]) && intval($options["max-errors"])>0) {
00306 define("MAX_ERRORS", intval($options["max-errors"]) );
00307 }
00308
00309
00310 if (!empty($options["specific-test"])) {
00311 if (class_exists($options["specific-test"]) && get_parent_class($options["specific-test"])=="pageTest") {
00312 define("SPECIFIC_TEST", $options["specific-test"] );
00313 }
00314 else {
00315 print "Ignoring invalid --specific-test\n";
00316 }
00317 }
00318
00319
00320 define("PHP_TEST" , ".test.php");
00321 define("CURL_TEST", ".curl.sh" );
00322 define("DATA_FILE", ".data.bin");
00323 define("INFO_FILE", ".info.txt");
00324 define("HTML_FILE", ".wiki_preview.html");
00325
00326
00327 error_reporting(E_ALL | E_STRICT);
00328
00330
00331 class wikiFuzz {
00332
00333
00334
00335 public static $data = array(
00336 "B" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00337 "CAPTION" => array("CLASS", "ID", "STYLE", "align", "lang", "dir", "title"),
00338 "CENTER" => array("CLASS", "STYLE", "ID", "lang", "dir", "title"),
00339 "DIV" => array("CLASS", "STYLE", "ID", "align", "lang", "dir", "title"),
00340 "FONT" => array("CLASS", "STYLE", "ID", "lang", "dir", "title", "face", "size", "color"),
00341 "H1" => array("STYLE", "CLASS", "ID", "align", "lang", "dir", "title"),
00342 "H2" => array("STYLE", "CLASS", "ID", "align", "lang", "dir", "title"),
00343 "HR" => array("STYLE", "CLASS", "ID", "WIDTH", "lang", "dir", "title", "size", "noshade"),
00344 "LI" => array("CLASS", "ID", "STYLE", "lang", "dir", "title", "type", "value"),
00345 "TABLE" => array("STYLE", "CLASS", "ID", "BGCOLOR", "WIDTH", "ALIGN", "BORDER", "CELLPADDING",
00346 "CELLSPACING", "lang", "dir", "title", "summary", "frame", "rules"),
00347 "TD" => array("STYLE", "CLASS", "ID", "BGCOLOR", "WIDTH", "ALIGN", "COLSPAN", "ROWSPAN",
00348 "VALIGN", "abbr", "axis", "headers", "scope", "nowrap", "height", "lang",
00349 "dir", "title", "char", "charoff"),
00350 "TH" => array("STYLE", "CLASS", "ID", "BGCOLOR", "WIDTH", "ALIGN", "COLSPAN", "ROWSPAN",
00351 "VALIGN", "abbr", "axis", "headers", "scope", "nowrap", "height", "lang",
00352 "dir", "title", "char", "charoff"),
00353 "TR" => array("CLASS", "STYLE", "ID", "BGCOLOR", "ALIGN", "VALIGN", "lang", "dir", "title", "char", "charoff"),
00354 "UL" => array("CLASS", "STYLE", "ID", "lang", "dir", "title", "type"),
00355 "P" => array("style", "class", "id", "align", "lang", "dir", "title"),
00356 "blockquote" => array("CLASS", "ID", "STYLE", "lang", "dir", "title", "cite"),
00357 "span" => array("CLASS", "ID", "STYLE", "align", "lang", "dir", "title"),
00358 "code" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00359 "tt" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00360 "small" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00361 "big" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00362 "s" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00363 "u" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00364 "del" => array("CLASS", "ID", "STYLE", "lang", "dir", "title", "datetime", "cite"),
00365 "ins" => array("CLASS", "ID", "STYLE", "lang", "dir", "title", "datetime", "cite"),
00366 "sub" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00367 "sup" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00368 "ol" => array("CLASS", "ID", "STYLE", "lang", "dir", "title", "type", "start"),
00369 "br" => array("CLASS", "ID", "STYLE", "title", "clear"),
00370 "cite" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00371 "var" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00372 "dl" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00373 "ruby" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00374 "rt" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00375 "rp" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00376 "dt" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00377 "dl" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00378 "em" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00379 "strong" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00380 "i" => array("CLASS", "ID", "STYLE", "lang", "dir", "title"),
00381 "thead" => array("CLASS", "ID", "STYLE", "lang", "dir", "title", 'align', 'char', 'charoff', 'valign'),
00382 "tfoot" => array("CLASS", "ID", "STYLE", "lang", "dir", "title", 'align', 'char', 'charoff', 'valign'),
00383 "tbody" => array("CLASS", "ID", "STYLE", "lang", "dir", "title", 'align', 'char', 'charoff', 'valign'),
00384 "colgroup" => array("CLASS", "ID", "STYLE", "lang", "dir", "title", 'align', 'char', 'charoff', 'valign', 'span', 'width'),
00385 "col" => array("CLASS", "ID", "STYLE", "lang", "dir", "title", 'align', 'char', 'charoff', 'valign', 'span', 'width'),
00386 "pre" => array("CLASS", "ID", "STYLE", "lang", "dir", "title", "width"),
00387
00388
00389 "sort" => array("order", "class"),
00390 "ref" => array("name"),
00391 "categorytree" => array("hideroot", "mode", "style"),
00392 "chemform" => array("link", "wikilink", "query"),
00393 "section" => array("begin", "new"),
00394
00395
00396 "transclude" => array("page"),
00397 );
00398
00399
00400
00401
00402 public static $types;
00403
00404
00405
00406 static private $other = array("&","=",":","?","\"","\n","%n%n%n%n%n%n%n%n%n%n%n%n","\\");
00407 static private $ints = array(
00408
00409 "0","-1","127","-7897","89000","808080","90928345",
00410 "0xfffffff","ffff",
00411
00412
00413 "'",
00414 "'",
00415 "'",
00416 "§",
00417
00418
00419 """,
00420 """,
00421 """,
00422 "¢",
00423
00424
00425 "<",
00426 "<",
00427 "<",
00428 "<",
00429 "<",
00430 "¼",
00431 "<",
00432 "<",
00433
00434
00435 ">",
00436 ">",
00437 ">",
00438 ">",
00439 "¾",
00440
00441
00442 "[",
00443 "[",
00444 "[",
00445
00446
00447 "{{",
00448 "{{",
00449 "{{",
00450
00451
00452 "|",
00453 "|",
00454 "|",
00455 "ü",
00456
00457
00458 "‌"
00459 );
00460
00461
00462
00463 static private $ext = array(
00464
00465 "[[", "]]", "{{", "}}", "|", "[", "]", "{{{", "}}}", "|]]",
00466
00467
00468 "\n{|", "\n|}",
00469 "!",
00470 "\n!",
00471 "!!",
00472 "||",
00473 "\n|-", "| ", "\n|",
00474
00475
00476 "=", "==", "===", "====", "=====", "======",
00477
00478
00479 "\n*", "*", "\n:", ":",
00480 "\n#", "#",
00481
00482
00483 "\n;", ";", "\n ",
00484
00485
00486 "\n", "\t", " ",
00487
00488
00489 "	",
00490 "
",
00491 "
",
00492 "\0",
00493 "  ",
00494 "'';!--\"<XSS>=&{()}",
00495
00496
00497 "%00",
00498 "�",
00499 "\0",
00500
00501
00502 "-----", "\n-----",
00503
00504
00505 "~~~~", "#REDIRECT [[", "'''", "''",
00506
00507
00508 "<!--", "-->",
00509
00510
00511 "\"", "'",
00512
00513
00514 "<", ">",
00515
00516
00517 "http://",
00518 "https://",
00519 "ftp://",
00520 "irc://",
00521 "news:",
00522 'gopher://',
00523 'telnet://',
00524 'nntp://',
00525 'worldwind://',
00526 'mailto:',
00527
00528
00529 "[[image:",
00530 ".gif",
00531 ".png",
00532 ".jpg",
00533 ".jpeg",
00534 'thumbnail=',
00535 'thumbnail',
00536 'thumb=',
00537 'thumb',
00538 'right',
00539 'none',
00540 'left',
00541 'framed',
00542 'frame',
00543 'enframed',
00544 'centre',
00545 'center',
00546 "Image:",
00547 "[[:Image",
00548 'px',
00549 'upright=',
00550 'border',
00551
00552
00553 '%08X',
00554 '/',
00555 ":x{|",
00556 "\n|+",
00557 "<noinclude>",
00558 "</noinclude>",
00559 " \302\273",
00560 " :",
00561 " !",
00562 " ;",
00563 "\302\253",
00564 "[[category:",
00565 "?=",
00566 "(",
00567 ")",
00568 "]]]",
00569 "../",
00570 "{{{{",
00571 "}}}}",
00572 "[[Special:",
00573 "<includeonly>",
00574 "</includeonly>",
00575 "<!--MWTEMPLATESECTION=",
00576 '<!--MWTOC-->',
00577
00578
00579 "ISBN 2",
00580 "RFC 000",
00581 "PMID 000",
00582 "ISBN ",
00583 "RFC ",
00584 "PMID ",
00585
00586
00587 '__NOTOC__',
00588 '__FORCETOC__',
00589 '__NOEDITSECTION__',
00590 '__START__',
00591 '__NOTITLECONVERT__',
00592 '__NOCONTENTCONVERT__',
00593 '__END__',
00594 '__TOC__',
00595 '__NOTC__',
00596 '__NOCC__',
00597 "__FORCETOC__",
00598 "__NEWSECTIONLINK__",
00599 "__NOGALLERY__",
00600
00601
00602 '{{PAGENAME}}',
00603 '{{PAGENAMEE}}',
00604 '{{NAMESPACE}}',
00605 "{{MSG:",
00606 "}}",
00607 "{{MSGNW:",
00608 "}}",
00609 "{{INT:",
00610 "}}",
00611 '{{SITENAME}}',
00612 "{{NS:",
00613 "}}",
00614 "{{LOCALURL:",
00615 "}}",
00616 "{{LOCALURLE:",
00617 "}}",
00618 "{{SCRIPTPATH}}",
00619 "{{GRAMMAR:gentiv|",
00620 "}}",
00621 "{{REVISIONID}}",
00622 "{{SUBPAGENAME}}",
00623 "{{SUBPAGENAMEE}}",
00624 "{{ns:0}}",
00625 "{{fullurle:",
00626 "}}",
00627 "{{subst::",
00628 "}}",
00629 "{{UCFIRST:",
00630 "}}",
00631 "{{UC:",
00632 '{{SERVERNAME}}',
00633 '{{SERVER}}',
00634 "{{RAW:",
00635 "}}",
00636 "{{PLURAL:",
00637 "}}",
00638 "{{LCFIRST:",
00639 "}}",
00640 "{{LC:",
00641 "}}",
00642 '{{CURRENTWEEK}}',
00643 '{{CURRENTDOW}}',
00644 "{{INT:{{LC:contribs-showhideminor}}|",
00645 "}}",
00646 "{{INT:googlesearch|",
00647 "}}",
00648 "{{BASEPAGENAME}}",
00649 "{{CONTENTLANGUAGE}}",
00650 "{{PAGESINNAMESPACE:}}",
00651 "{{#language:",
00652 "}}",
00653 "{{#special:",
00654 "}}",
00655 "{{#special:emailuser",
00656 "}}",
00657
00658
00659 "{{NUMBEROFPAGES:R",
00660 "}}",
00661 "{{NUMBEROFUSERS:R",
00662 "}}",
00663 "{{NUMBEROFARTICLES:R",
00664 "}}",
00665 "{{NUMBEROFFILES:R",
00666 "}}",
00667 "{{NUMBEROFADMINS:R",
00668 "}}",
00669 "{{padleft:",
00670 "}}",
00671 "{{padright:",
00672 "}}",
00673 "{{DEFAULTSORT:",
00674 "}}",
00675
00676
00677 "<math>",
00678 "</math>",
00679
00680
00681 "{{#expr:",
00682 "{{#if:",
00683 "{{#ifeq:",
00684 "{{#ifexist:",
00685 "{{#ifexpr:",
00686 "{{#switch:",
00687 "{{#time:",
00688 "}}",
00689
00690
00691 "<references/>",
00692
00693
00694 "UNIQ25f46b0524f13e67NOPARSE",
00695 "UNIQ17197916557e7cd6-HTMLCommentStrip46238afc3bb0cf5f00000002",
00696 "\x07UNIQ17197916557e7cd6-HTMLCommentStrip46238afc3bb0cf5f00000002-QINU",
00697
00698
00699 "<inputbox>\ntype=search\nsearchbuttonlabel=\n",
00700 "</inputbox>",
00701
00702
00703 "<charInsert>",
00704 "</charInsert>",
00705
00706
00707 "<hiero>",
00708 "</hiero>",
00709
00710
00711 "<gallery>",
00712 "</gallery>",
00713
00714
00715 "<fundraising/>",
00716
00717
00718
00719
00720 "<nOwIkI>",
00721 "</nowiki>",
00722
00723
00724 "http://debian.org/Pics/debian.png",
00725
00726
00727 "{{#lstx:",
00728 "}}",
00729 "{{#lst:",
00730 "}}",
00731 "{{#lst:Main Page|",
00732 "}}"
00733 );
00734
00738 static public function chooseInput(array $input) {
00739 $randindex = wikiFuzz::randnum(count($input) - 1);
00740 return $input[$randindex];
00741 }
00742
00743
00744 static private $maxparams = 10;
00745
00749 static public function randnum($finish,$start=0) {
00750 return mt_rand($start,$finish);
00751 }
00752
00756 static private function randstring() {
00757 $thestring = "";
00758
00759 for ($i=0; $i<40; $i++) {
00760 $what = wikiFuzz::randnum(1);
00761
00762 if ($what == 0) {
00763 $which = wikiFuzz::randnum(count(wikiFuzz::$ext) - 1);
00764 $thestring .= wikiFuzz::$ext[$which];
00765 }
00766 else {
00767 $char = INCLUDE_BINARY
00768
00769
00770
00771 ? "&#x" . str_pad(dechex(wikiFuzz::randnum(255)), wikiFuzz::randnum(2, 7), "0", STR_PAD_LEFT) . ";"
00772
00773
00774 : chr(wikiFuzz::randnum(126,32));
00775
00776 $length = wikiFuzz::randnum(8);
00777 $thestring .= str_repeat ($char, $length);
00778 }
00779 }
00780 return $thestring;
00781 }
00782
00787 static private function makestring() {
00788 $what = wikiFuzz::randnum(2);
00789 if ($what == 0) {
00790 return wikiFuzz::randstring();
00791 }
00792 elseif ($what == 1) {
00793 return wikiFuzz::$ints[wikiFuzz::randnum(count(wikiFuzz::$ints) - 1)];
00794 }
00795 else {
00796 return wikiFuzz::$other[wikiFuzz::randnum(count(wikiFuzz::$other) - 1)];
00797 }
00798 }
00799
00800
00805 static public function makeTitleSafe($str) {
00806 $legalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF";
00807 return preg_replace_callback(
00808 "/([^$legalTitleChars])/",
00809 create_function(
00810
00811
00812 '$matches',
00813 'return sprintf( "\\x%02x", ord( $matches[1] ) );'
00814 ),
00815 $str );
00816 }
00817
00821 static private function loop() {
00822 switch ( wikiFuzz::randnum(3) ) {
00823 case 1:
00824 $string = "";
00825 $i = wikiFuzz::randnum(count(wikiFuzz::$types) - 1);
00826 $t = wikiFuzz::$types[$i];
00827 $arr = wikiFuzz::$data[$t];
00828 $string .= "<" . $t . " ";
00829 $num_params = min(wikiFuzz::$maxparams, count($arr));
00830 for ($z=0; $z<$num_params; $z++) {
00831 $badparam = $arr[wikiFuzz::randnum(count($arr) - 1)];
00832 $badstring = wikiFuzz::makestring();
00833 $string .= $badparam . "=" . wikiFuzz::getRandQuote() . $badstring . wikiFuzz::getRandQuote() . " ";
00834 }
00835 $string .= ">\n";
00836 return $string;
00837 case 2:
00838 $i = wikiFuzz::randnum(count(wikiFuzz::$types) - 1);
00839 return "</". wikiFuzz::$types[$i] . ">";
00840 case 3:
00841 return wikiFuzz::makeString();
00842 }
00843 return "";
00844 }
00845
00849 static private function getRandQuote() {
00850 switch ( wikiFuzz::randnum(3) ) {
00851 case 1 : return "'";
00852 case 2 : return "\"";
00853 default: return "";
00854 }
00855 }
00856
00860 static public function makeFuzz($maxtypes = 2) {
00861 $page = "";
00862 for ($k=0; $k<$maxtypes; $k++) {
00863 $page .= wikiFuzz::loop();
00864 }
00865 return $page;
00866 }
00867 }
00868
00869
00871
00881 abstract class pageTest {
00882 protected $params;
00883 protected $pagePath;
00884 protected $cookie = "";
00885 protected $tidyValidate = true;
00886
00887 public function getParams() {
00888 return $this->params;
00889 }
00890
00891 public function getPagePath() {
00892 return $this->pagePath;
00893 }
00894
00895 public function getCookie() {
00896 return $this->cookie;
00897 }
00898
00899 public function tidyValidate() {
00900 return $this->tidyValidate;
00901 }
00902 }
00903
00904
00908 class editPageTest extends pageTest {
00909 function __construct() {
00910 $this->pagePath = "index.php?title=WIKIFUZZ";
00911
00912 $this->params = array (
00913 "action" => "submit",
00914 "wpMinoredit" => wikiFuzz::makeFuzz(2),
00915 "wpPreview" => wikiFuzz::makeFuzz(2),
00916 "wpSection" => wikiFuzz::makeFuzz(2),
00917 "wpEdittime" => wikiFuzz::makeFuzz(2),
00918 "wpSummary" => wikiFuzz::makeFuzz(2),
00919 "wpScrolltop" => wikiFuzz::makeFuzz(2),
00920 "wpStarttime" => wikiFuzz::makeFuzz(2),
00921 "wpAutoSummary" => wikiFuzz::makeFuzz(2),
00922 "wpTextbox1" => wikiFuzz::makeFuzz(40)
00923 );
00924
00925
00926 if (wikiFuzz::randnum(6) == 0) unset($this->params["wpSection"]);
00927 if (wikiFuzz::randnum(6) == 0) unset($this->params["wpEdittime"]);
00928 if (wikiFuzz::randnum(6) == 0) unset($this->params["wpSummary"]);
00929 if (wikiFuzz::randnum(6) == 0) unset($this->params["wpScrolltop"]);
00930 if (wikiFuzz::randnum(6) == 0) unset($this->params["wpStarttime"]);
00931 if (wikiFuzz::randnum(6) == 0) unset($this->params["wpAutoSummary"]);
00932 if (wikiFuzz::randnum(6) == 0) unset($this->params["wpTextbox1"]);
00933 }
00934 }
00935
00936
00940 class listusersTest extends pageTest {
00941 function __construct() {
00942 $this->pagePath = "index.php?title=Special:Listusers";
00943
00944 $this->params = array (
00945 "title" => wikiFuzz::makeFuzz(2),
00946 "group" => wikiFuzz::makeFuzz(2),
00947 "username" => wikiFuzz::makeFuzz(2),
00948 "Go" => wikiFuzz::makeFuzz(2),
00949 "limit" => wikiFuzz::chooseInput( array("0", "-1", "---'----------0", "+1", "8134", wikiFuzz::makeFuzz(2)) ),
00950 "offset" => wikiFuzz::chooseInput( array("0", "-1", "--------'-----0", "+1", "81343242346234234", wikiFuzz::makeFuzz(2)) )
00951 );
00952 }
00953 }
00954
00955
00959 class searchTest extends pageTest {
00960 function __construct() {
00961 $this->pagePath = "index.php?title=Special:Search";
00962
00963 $this->params = array (
00964 "action" => "index.php?title=Special:Search",
00965 "ns0" => wikiFuzz::makeFuzz(2),
00966 "ns1" => wikiFuzz::makeFuzz(2),
00967 "ns2" => wikiFuzz::makeFuzz(2),
00968 "ns3" => wikiFuzz::makeFuzz(2),
00969 "ns4" => wikiFuzz::makeFuzz(2),
00970 "ns5" => wikiFuzz::makeFuzz(2),
00971 "ns6" => wikiFuzz::makeFuzz(2),
00972 "ns7" => wikiFuzz::makeFuzz(2),
00973 "ns8" => wikiFuzz::makeFuzz(2),
00974 "ns9" => wikiFuzz::makeFuzz(2),
00975 "ns10" => wikiFuzz::makeFuzz(2),
00976 "ns11" => wikiFuzz::makeFuzz(2),
00977 "ns12" => wikiFuzz::makeFuzz(2),
00978 "ns13" => wikiFuzz::makeFuzz(2),
00979 "ns14" => wikiFuzz::makeFuzz(2),
00980 "ns15" => wikiFuzz::makeFuzz(2),
00981 "redirs" => wikiFuzz::makeFuzz(2),
00982 "search" => wikiFuzz::makeFuzz(2),
00983 "offset" => wikiFuzz::chooseInput( array("", "0", "-1", "--------'-----0", "+1", "81343242346234234", wikiFuzz::makeFuzz(2)) ),
00984 "fulltext" => wikiFuzz::chooseInput( array("", "0", "1", "--------'-----0", "+1", wikiFuzz::makeFuzz(2)) ),
00985 "searchx" => wikiFuzz::chooseInput( array("", "0", "1", "--------'-----0", "+1", wikiFuzz::makeFuzz(2)) )
00986 );
00987 }
00988 }
00989
00990
00994 class recentchangesTest extends pageTest {
00995 function __construct() {
00996 $this->pagePath = "index.php?title=Special:Recentchanges";
00997
00998 $this->params = array (
00999 "action" => wikiFuzz::makeFuzz(2),
01000 "title" => wikiFuzz::makeFuzz(2),
01001 "namespace" => wikiFuzz::chooseInput( range(-1, 15) ),
01002 "Go" => wikiFuzz::makeFuzz(2),
01003 "invert" => wikiFuzz::chooseInput( array("-1", "---'----------0", "+1", "8134", wikiFuzz::makeFuzz(2)) ),
01004 "hideanons" => wikiFuzz::chooseInput( array("-1", "------'-------0", "+1", "8134", wikiFuzz::makeFuzz(2)) ),
01005 'limit' => wikiFuzz::chooseInput( array("0", "-1", "---------'----0", "+1", "81340909772349234", wikiFuzz::makeFuzz(2)) ),
01006 "days" => wikiFuzz::chooseInput( array("-1", "----------'---0", "+1", "8134", wikiFuzz::makeFuzz(2)) ),
01007 "hideminor" => wikiFuzz::chooseInput( array("-1", "-----------'--0", "+1", "8134", wikiFuzz::makeFuzz(2)) ),
01008 "hidebots" => wikiFuzz::chooseInput( array("-1", "---------'----0", "+1", "8134", wikiFuzz::makeFuzz(2)) ),
01009 "hideliu" => wikiFuzz::chooseInput( array("-1", "-------'------0", "+1", "8134", wikiFuzz::makeFuzz(2)) ),
01010 "hidepatrolled" => wikiFuzz::chooseInput( array("-1", "-----'--------0", "+1", "8134", wikiFuzz::makeFuzz(2)) ),
01011 "hidemyself" => wikiFuzz::chooseInput( array("-1", "--'-----------0", "+1", "8134", wikiFuzz::makeFuzz(2)) ),
01012 'categories_any'=> wikiFuzz::chooseInput( array("-1", "--'-----------0", "+1", "8134", wikiFuzz::makeFuzz(2)) ),
01013 'categories' => wikiFuzz::chooseInput( array("-1", "--'-----------0", "+1", "8134", wikiFuzz::makeFuzz(2)) ),
01014 'feed' => wikiFuzz::chooseInput( array("-1", "--'-----------0", "+1", "8134", wikiFuzz::makeFuzz(2)) )
01015 );
01016 }
01017 }
01018
01019
01023 class prefixindexTest extends pageTest {
01024 function __construct() {
01025 $this->pagePath = "index.php?title=Special:Prefixindex";
01026
01027 $this->params = array (
01028 "title" => "Special:Prefixindex",
01029 "namespace" => wikiFuzz::randnum(-10,101),
01030 "Go" => wikiFuzz::makeFuzz(2)
01031 );
01032
01033
01034 if (wikiFuzz::randnum(3) == 0) {
01035 $this->params["prefix"] = wikiFuzz::chooseInput( array("-1", "-----'--------0", "+++--+1",
01036 wikiFuzz::randnum(-10,8134), wikiFuzz::makeFuzz(2)) );
01037 }
01038 if (wikiFuzz::randnum(3) == 0) {
01039 $this->params["from"] = wikiFuzz::chooseInput( array("-1", "-----'--------0", "+++--+1",
01040 wikiFuzz::randnum(-10,8134), wikiFuzz::makeFuzz(2)) );
01041 }
01042 }
01043 }
01044
01045
01049 class mimeSearchTest extends pageTest {
01050 function __construct() {
01051 $this->pagePath = "index.php?title=Special:MIMEsearch";
01052
01053 $this->params = array (
01054 "action" => "index.php?title=Special:MIMEsearch",
01055 "mime" => wikiFuzz::makeFuzz(3),
01056 'limit' => wikiFuzz::chooseInput( array("0", "-1", "-------'------0", "+1", "81342321351235325", wikiFuzz::makeFuzz(2)) ),
01057 'offset' => wikiFuzz::chooseInput( array("0", "-1", "-----'--------0", "+1", "81341231235365252234324", wikiFuzz::makeFuzz(2)) )
01058 );
01059 }
01060 }
01061
01062
01066 class specialLogTest extends pageTest {
01067 function __construct() {
01068 $this->pagePath = "index.php?title=Special:Log";
01069
01070 $this->params = array (
01071 "type" => wikiFuzz::chooseInput( array("", wikiFuzz::makeFuzz(2)) ),
01072 "par" => wikiFuzz::makeFuzz(2),
01073 "user" => wikiFuzz::makeFuzz(2),
01074 "page" => wikiFuzz::makeFuzz(2),
01075 "from" => wikiFuzz::makeFuzz(2),
01076 "until" => wikiFuzz::makeFuzz(2),
01077 "title" => wikiFuzz::makeFuzz(2)
01078 );
01079 }
01080 }
01081
01082
01086 class successfulUserLoginTest extends pageTest {
01087 function __construct() {
01088 $this->pagePath = "index.php?title=Special:Userlogin&action=submitlogin&type=login&returnto=" . wikiFuzz::makeFuzz(2);
01089
01090 $this->params = array (
01091 "wpName" => USER_ON_WIKI,
01092
01093 'wpPassword' => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz(2), USER_PASSWORD ) ),
01094 'wpRemember' => wikiFuzz::makeFuzz(2)
01095 );
01096
01097 $this->cookie = "wikidb_session=" . wikiFuzz::chooseInput( array("1" , wikiFuzz::makeFuzz(2) ) );
01098 }
01099 }
01100
01101
01105 class userLoginTest extends pageTest {
01106 function __construct() {
01107
01108 $this->pagePath = "index.php?title=Special:Userlogin";
01109
01110 $this->params = array (
01111 'wpRetype' => wikiFuzz::makeFuzz(2),
01112 'wpRemember' => wikiFuzz::makeFuzz(2),
01113 'wpRealName' => wikiFuzz::makeFuzz(2),
01114 'wpPassword' => wikiFuzz::makeFuzz(2),
01115 'wpName' => wikiFuzz::makeFuzz(2),
01116 'wpMailmypassword'=> wikiFuzz::makeFuzz(2),
01117 'wpLoginattempt' => wikiFuzz::makeFuzz(2),
01118 'wpEmail' => wikiFuzz::makeFuzz(2),
01119 'wpDomain' => wikiFuzz::chooseInput( array("", "local", wikiFuzz::makeFuzz(2)) ),
01120 'wpCreateaccountMail' => wikiFuzz::chooseInput( array("", wikiFuzz::makeFuzz(2)) ),
01121 'wpCreateaccount' => wikiFuzz::chooseInput( array("", wikiFuzz::makeFuzz(2)) ),
01122 'wpCookieCheck' => wikiFuzz::chooseInput( array("", wikiFuzz::makeFuzz(2)) ),
01123 'type' => wikiFuzz::chooseInput( array("signup", "login", "", wikiFuzz::makeFuzz(2)) ),
01124 'returnto' => wikiFuzz::makeFuzz(2),
01125 'action' => wikiFuzz::chooseInput( array("", "submitlogin", wikiFuzz::makeFuzz(2)) )
01126 );
01127
01128 $this->cookie = "wikidb_session=" . wikiFuzz::chooseInput( array("1" , wikiFuzz::makeFuzz(2) ) );
01129 }
01130 }
01131
01132
01136 class ipblocklistTest extends pageTest {
01137 function __construct() {
01138 $this->pagePath = "index.php?title=Special:Ipblocklist";
01139
01140 $this->params = array (
01141 'wpUnblockAddress'=> wikiFuzz::makeFuzz(2),
01142 'ip' => wikiFuzz::chooseInput( array("20398702394", "", "Nickj2", wikiFuzz::makeFuzz(2),
01143
01144 ( wikiFuzz::randnum(300,-20) . "." . wikiFuzz::randnum(300,-20) . "."
01145 . wikiFuzz::randnum(300,-20) . "." .wikiFuzz::randnum(300,-20) ) ) ),
01146 'id' => wikiFuzz::makeFuzz(2),
01147 'wpUnblockReason' => wikiFuzz::makeFuzz(2),
01148 'action' => wikiFuzz::chooseInput( array(wikiFuzz::makeFuzz(2), "success", "submit", "unblock") ),
01149 'wpEditToken' => wikiFuzz::makeFuzz(2),
01150 'wpBlock' => wikiFuzz::chooseInput( array(wikiFuzz::makeFuzz(2), "") ),
01151 'limit' => wikiFuzz::chooseInput( array("0", "-1", "--------'-----0", "+1",
01152 "09700982312351132098234", wikiFuzz::makeFuzz(2)) ),
01153 'offset' => wikiFuzz::chooseInput( array("0", "-1", "------'-------0", "+1",
01154 "09700980982341535324234234", wikiFuzz::makeFuzz(2)) )
01155 );
01156
01157
01158 if (wikiFuzz::randnum(4) == 0) unset($this->params["action"]);
01159 if (wikiFuzz::randnum(3) == 0) unset($this->params["ip"]);
01160 if (wikiFuzz::randnum(2) == 0) unset($this->params["id"]);
01161 if (wikiFuzz::randnum(3) == 0) unset($this->params["wpUnblockAddress"]);
01162 }
01163 }
01164
01165
01169 class newImagesTest extends pageTest {
01170 function __construct() {
01171 $this->pagePath = "index.php?title=Special:Newimages";
01172
01173 $this->params = array (
01174 'hidebots' => wikiFuzz::chooseInput( array(wikiFuzz::makeFuzz(2), "1", "", "-1") ),
01175 'wpIlMatch' => wikiFuzz::makeFuzz(2),
01176 'until' => wikiFuzz::makeFuzz(2),
01177 'from' => wikiFuzz::makeFuzz(2)
01178 );
01179
01180
01181 if (wikiFuzz::randnum(6) == 0) unset($this->params["until"]);
01182 if (wikiFuzz::randnum(6) == 0) unset($this->params["from"]);
01183 }
01184 }
01185
01186
01190 class imagelistTest extends pageTest {
01191 function __construct() {
01192 $this->pagePath = "index.php?title=Special:Imagelist";
01193
01194 $this->params = array (
01195 'sort' => wikiFuzz::chooseInput( array("bysize", "byname" , "bydate", wikiFuzz::makeFuzz(2)) ),
01196 'limit' => wikiFuzz::chooseInput( array("0", "-1", "--------'-----0", "+1", "09700982312351132098234", wikiFuzz::makeFuzz(2)) ),
01197 'offset' => wikiFuzz::chooseInput( array("0", "-1", "------'-------0", "+1", "09700980982341535324234234", wikiFuzz::makeFuzz(2)) ),
01198 'wpIlMatch' => wikiFuzz::makeFuzz(2)
01199 );
01200 }
01201 }
01202
01203
01207 class specialExportTest extends pageTest {
01208 function __construct() {
01209 $this->pagePath = "index.php?title=Special:Export";
01210
01211 $this->params = array (
01212 'action' => wikiFuzz::chooseInput( array("submit", "", wikiFuzz::makeFuzz(2)) ),
01213 'pages' => wikiFuzz::makeFuzz(2),
01214 'curonly' => wikiFuzz::chooseInput( array("", "0", "-1", wikiFuzz::makeFuzz(2)) ),
01215 'listauthors' => wikiFuzz::chooseInput( array("", "0", "-1", wikiFuzz::makeFuzz(2)) ),
01216 'history' => wikiFuzz::chooseInput( array("0", "-1", "------'-------0", "+1", "09700980982341535324234234", wikiFuzz::makeFuzz(2)) ),
01217
01218 );
01219
01220
01221 if ($this->params['action'] == 'submit') $this->params['action'] = '';
01222
01223
01224 if (wikiFuzz::randnum(2) == 0) unset($this->params["history"]);
01225
01226
01227 $this->tidyValidate = false;
01228 }
01229 }
01230
01231
01235 class specialBooksourcesTest extends pageTest {
01236 function __construct() {
01237 $this->pagePath = "index.php?title=Special:Booksources";
01238
01239 $this->params = array (
01240 'go' => wikiFuzz::makeFuzz(2),
01241
01242 'isbn' => "0X0" . wikiFuzz::makeFuzz(2)
01243 );
01244 }
01245 }
01246
01247
01251 class specialAllpagesTest extends pageTest {
01252 function __construct() {
01253 $this->pagePath = "index.php?title=Special%3AAllpages";
01254
01255 $this->params = array (
01256 'from' => wikiFuzz::makeFuzz(2),
01257 'namespace' => wikiFuzz::chooseInput( range(-1, 15) ),
01258 'go' => wikiFuzz::makeFuzz(2)
01259 );
01260 }
01261 }
01262
01263
01267 class pageHistoryTest extends pageTest {
01268 function __construct() {
01269 $this->pagePath = "index.php?title=Main_Page&action=history";
01270
01271 $this->params = array (
01272 'limit' => wikiFuzz::chooseInput( array("-1", "0", "-------'------0", "+1", "8134", wikiFuzz::makeFuzz(2)) ),
01273 'offset' => wikiFuzz::chooseInput( array("-1", "0", "------'-------0", "+1", "9823412312312412435", wikiFuzz::makeFuzz(2)) ),
01274 "go" => wikiFuzz::chooseInput( array("first", "last", wikiFuzz::makeFuzz(2)) ),
01275 "dir" => wikiFuzz::chooseInput( array("prev", "next", wikiFuzz::makeFuzz(2)) ),
01276 "diff" => wikiFuzz::chooseInput( array("-1", "--------'-----0", "+1", "8134", wikiFuzz::makeFuzz(2)) ),
01277 "oldid" => wikiFuzz::chooseInput( array("prev", "-1", "+1", "8134", wikiFuzz::makeFuzz(2)) ),
01278 "feed" => wikiFuzz::makeFuzz(2)
01279 );
01280 }
01281 }
01282
01283
01287 class contributionsTest extends pageTest {
01288 function __construct() {
01289 $this->pagePath = "index.php?title=Special:Contributions/" . USER_ON_WIKI;
01290
01291 $this->params = array (
01292 'target' => wikiFuzz::chooseInput( array(wikiFuzz::makeFuzz(2), "newbies", USER_ON_WIKI) ),
01293 'namespace' => wikiFuzz::chooseInput( array(-1, 15, 1, wikiFuzz::makeFuzz(2)) ),
01294 'offset' => wikiFuzz::chooseInput( array("0", "-1", "------'-------0", "+1", "982342131232131231241", wikiFuzz::makeFuzz(2)) ),
01295 'bot' => wikiFuzz::chooseInput( array("", "-1", "0", "1", wikiFuzz::makeFuzz(2)) ),
01296 'go' => wikiFuzz::chooseInput( array("-1", 'prev', 'next', wikiFuzz::makeFuzz(2)) )
01297 );
01298 }
01299 }
01300
01301
01305 class viewPageTest extends pageTest {
01306 function __construct() {
01307 $this->pagePath = "index.php?title=Main_Page";
01308
01309 $this->params = array (
01310 "useskin" => wikiFuzz::chooseInput( array("chick", "cologneblue", "myskin",
01311 "nostalgia", "simple", "standard", wikiFuzz::makeFuzz(2)) ),
01312 "uselang" => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz(2),
01313 "ab", "af", "an", "ar", "arc", "as", "ast", "av", "ay", "az", "ba",
01314 "bat-smg", "be", "bg", "bm", "bn", "bo", "bpy", "br", "bs", "ca",
01315 "ce", "cs", "csb", "cv", "cy", "da", "de", "dv", "dz", "el", "en",
01316 "eo", "es", "et", "eu", "fa", "fi", "fo", "fr", "fur", "fy", "ga",
01317 "gn", "gsw", "gu", "he", "hi", "hr", "hu", "ia", "id", "ii", "is",
01318 "it", "ja", "jv", "ka", "km", "kn", "ko", "ks", "ku", "kv", "la",
01319 "li", "lo", "lt", "lv", "mk", "ml", "ms", "nah", "nap", "nds",
01320 "nds-nl", "nl", "nn", "no", "non", "nv", "oc", "or", "os", "pa",
01321 "pl", "pms", "ps", "pt", "pt-br", "qu", "rmy", "ro", "ru", "sc",
01322 "sd", "sk", "sl", "sq", "sr", "sr-ec", "sr-el",
01323 "su", "sv", "ta", "te", "th", "tlh", "tr", "tt", "ty", "tyv", "udm",
01324 "ug", "uk", "ur", "utf8", "vec", "vi", "wa", "xal", "yi", "za",
01325 "zh", "zh-cn", "zh-hk", "zh-sg", "zh-tw", "zh-tw") ),
01326 "returnto" => wikiFuzz::makeFuzz(2),
01327 "feed" => wikiFuzz::chooseInput( array("atom", "rss", wikiFuzz::makeFuzz(2)) ),
01328 "rcid" => wikiFuzz::makeFuzz(2),
01329 "action" => wikiFuzz::chooseInput( array("view", "raw", "render", wikiFuzz::makeFuzz(2), "markpatrolled") ),
01330 "printable" => wikiFuzz::makeFuzz(2),
01331 "oldid" => wikiFuzz::makeFuzz(2),
01332 "redirect" => wikiFuzz::makeFuzz(2),
01333 "diff" => wikiFuzz::makeFuzz(2),
01334 "search" => wikiFuzz::makeFuzz(2),
01335 "rdfrom" => wikiFuzz::makeFuzz(2),
01336 "token" => wikiFuzz::makeFuzz(2),
01337 "tbid" => wikiFuzz::makeFuzz(2),
01338 "action" => wikiFuzz::chooseInput( array("purge", wikiFuzz::makeFuzz(2)) ),
01339 "wpReason" => wikiFuzz::makeFuzz(2),
01340 "wpEditToken" => wikiFuzz::makeFuzz(2),
01341 "from" => wikiFuzz::makeFuzz(2),
01342 "bot" => wikiFuzz::makeFuzz(2),
01343 "summary" => wikiFuzz::makeFuzz(2),
01344 "direction" => wikiFuzz::chooseInput( array("next", "prev", wikiFuzz::makeFuzz(2)) ),
01345 "section" => wikiFuzz::makeFuzz(2),
01346 "preload" => wikiFuzz::makeFuzz(2),
01347
01348 );
01349
01350
01351 if ($this->params["feed"] == "atom") { unset($this->params["feed"]); }
01352 else if ($this->params["feed"] == "rss") { unset($this->params["feed"]); }
01353
01354
01355 if ($this->params["action"] == "raw") unset($this->params["action"]);
01356
01357
01358 if (wikiFuzz::randnum(6) == 0) unset($this->params["rcid"]);
01359 if (wikiFuzz::randnum(6) == 0) unset($this->params["diff"]);
01360 if (wikiFuzz::randnum(6) == 0) unset($this->params["rdfrom"]);
01361 if (wikiFuzz::randnum(3) == 0) unset($this->params["oldid"]);
01362
01363
01364 if (wikiFuzz::randnum(6) > 1) unset($this->params["action"]);
01365 }
01366 }
01367
01368
01372 class specialAllmessagesTest extends pageTest {
01373 function __construct() {
01374 $this->pagePath = "index.php?title=Special:Allmessages";
01375
01376
01377 $this->params = array (
01378 "ot" => wikiFuzz::chooseInput( array("php", "html", wikiFuzz::makeFuzz(2)) )
01379 );
01380 }
01381 }
01382
01386 class specialNewpages extends pageTest {
01387 function __construct() {
01388 $this->pagePath = "index.php?title=Special:Newpages";
01389
01390 $this->params = array (
01391 "namespace" => wikiFuzz::chooseInput( range(-1, 15) ),
01392 "feed" => wikiFuzz::chooseInput( array("atom", "rss", wikiFuzz::makeFuzz(2)) ),
01393 'limit' => wikiFuzz::chooseInput( array("-1", "0", "-------'------0", "+1", "8134", wikiFuzz::makeFuzz(2)) ),
01394 'offset' => wikiFuzz::chooseInput( array("-1", "0", "------'-------0", "+1", "9823412312312412435", wikiFuzz::makeFuzz(2)) )
01395 );
01396
01397
01398 if ($this->params["feed"] == "atom") { unset($this->params["feed"]); }
01399 else if ($this->params["feed"] == "rss") { unset($this->params["feed"]); }
01400 }
01401 }
01402
01406 class redirectTest extends pageTest {
01407 function __construct() {
01408 $this->pagePath = "redirect.php";
01409
01410 $this->params = array (
01411 "wpDropdown" => wikiFuzz::makeFuzz(2)
01412 );
01413
01414
01415 if (wikiFuzz::randnum(6) == 0) unset($this->params["wpDropdown"]);
01416 }
01417 }
01418
01419
01423 class confirmEmail extends pageTest {
01424 function __construct() {
01425
01426 $this->pagePath = "index.php?title=Special:Confirmemail" . wikiFuzz::chooseInput( array("", "/" . wikiFuzz::makeTitleSafe(wikiFuzz::makeFuzz(1)) ) );
01427
01428 $this->params = array (
01429 "token" => wikiFuzz::makeFuzz(2)
01430 );
01431 }
01432 }
01433
01434
01439 class watchlistTest extends pageTest {
01440 function __construct() {
01441 $this->pagePath = "index.php?title=Special:Watchlist";
01442
01443 $this->params = array (
01444 "remove" => wikiFuzz::chooseInput( array("Remove checked items from watchlist", wikiFuzz::makeFuzz(2))),
01445 'days' => wikiFuzz::chooseInput( array(0, -1, -230, "--", 3, 9, wikiFuzz::makeFuzz(2)) ),
01446 'hideOwn' => wikiFuzz::chooseInput( array("", "0", "1", wikiFuzz::makeFuzz(2)) ),
01447 'hideBots' => wikiFuzz::chooseInput( array("", "0", "1", wikiFuzz::makeFuzz(2)) ),
01448 'namespace'=> wikiFuzz::chooseInput( array("", "0", "1", wikiFuzz::makeFuzz(2)) ),
01449 'action' => wikiFuzz::chooseInput( array("submit", "clear", wikiFuzz::makeFuzz(2)) ),
01450 'id[]' => wikiFuzz::makeFuzz(2),
01451 'edit' => wikiFuzz::makeFuzz(2),
01452 'token' => wikiFuzz::chooseInput( array("", "1243213", wikiFuzz::makeFuzz(2)) )
01453 );
01454
01455
01456 if (wikiFuzz::randnum(3) == 0) $this->params["reset"] = wikiFuzz::chooseInput( array("", "0", "1", wikiFuzz::makeFuzz(2)) );
01457 }
01458 }
01459
01460
01464 class specialBlockmeTest extends pageTest {
01465 function __construct() {
01466 $this->pagePath = "index.php?title=Special:Blockme";
01467
01468 $this->params = array ( );
01469
01470
01471 if (wikiFuzz::randnum(1) == 0) {
01472 $this->params["ip"] = wikiFuzz::chooseInput( array("10.12.41.213", wikiFuzz::randnum(-10,8134), wikiFuzz::makeFuzz(2)) );
01473 }
01474 }
01475 }
01476
01477
01481 class specialMovePage extends pageTest {
01482 function __construct() {
01483 $this->pagePath = "index.php?title=Special:Movepage";
01484
01485 $this->params = array (
01486 "action" => wikiFuzz::chooseInput( array("success", "submit", "", wikiFuzz::makeFuzz(2)) ),
01487 'wpEditToken' => wikiFuzz::chooseInput( array('', 0, 34987987, wikiFuzz::makeFuzz(2)) ),
01488 'target' => wikiFuzz::chooseInput( array("x", wikiFuzz::makeTitleSafe(wikiFuzz::makeFuzz(2)) ) ),
01489 'wpOldTitle' => wikiFuzz::chooseInput( array("z", wikiFuzz::makeTitleSafe(wikiFuzz::makeFuzz(2)), wikiFuzz::makeFuzz(2) ) ),
01490 'wpNewTitle' => wikiFuzz::chooseInput( array("y", wikiFuzz::makeTitleSafe(wikiFuzz::makeFuzz(2)), wikiFuzz::makeFuzz(2) ) ),
01491 'wpReason' => wikiFuzz::chooseInput( array(wikiFuzz::makeFuzz(2)) ),
01492 'wpMovetalk' => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01493 'wpDeleteAndMove' => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01494 'wpConfirm' => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01495 'talkmoved' => wikiFuzz::chooseInput( array("1", wikiFuzz::makeFuzz(2), "articleexists", 'notalkpage') ),
01496 'oldtitle' => wikiFuzz::makeFuzz(2),
01497 'newtitle' => wikiFuzz::makeFuzz(2),
01498 'wpMovetalk' => wikiFuzz::chooseInput( array("1", "0", wikiFuzz::makeFuzz(2)) )
01499 );
01500
01501
01502 if (wikiFuzz::randnum(2) == 0) unset($this->params["wpEditToken"]);
01503 if (wikiFuzz::randnum(3) == 0) unset($this->params["target"]);
01504 if (wikiFuzz::randnum(3) == 0) unset($this->params["wpNewTitle"]);
01505 if (wikiFuzz::randnum(4) == 0) unset($this->params["wpReason"]);
01506 if (wikiFuzz::randnum(4) == 0) unset($this->params["wpOldTitle"]);
01507 }
01508 }
01509
01510
01514 class specialUndelete extends pageTest {
01515 function __construct() {
01516 $this->pagePath = "index.php?title=Special:Undelete";
01517
01518 $this->params = array (
01519 "action" => wikiFuzz::chooseInput( array("submit", "", wikiFuzz::makeFuzz(2)) ),
01520 'wpEditToken' => wikiFuzz::chooseInput( array('', 0, 34987987, wikiFuzz::makeFuzz(2)) ),
01521 'target' => wikiFuzz::chooseInput( array("x", wikiFuzz::makeTitleSafe(wikiFuzz::makeFuzz(2)) ) ),
01522 'timestamp' => wikiFuzz::chooseInput( array("125223", wikiFuzz::makeFuzz(2) ) ),
01523 'file' => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01524 'restore' => wikiFuzz::chooseInput( array("0", "1", wikiFuzz::makeFuzz(2)) ),
01525 'preview' => wikiFuzz::chooseInput( array("0", "1", wikiFuzz::makeFuzz(2)) ),
01526 'wpComment' => wikiFuzz::makeFuzz(2)
01527 );
01528
01529
01530 if (wikiFuzz::randnum(2) == 0) unset($this->params["wpEditToken"]);
01531 if (wikiFuzz::randnum(4) == 0) unset($this->params["target"]);
01532 if (wikiFuzz::randnum(1) == 0) unset($this->params["restore"]);
01533 if (wikiFuzz::randnum(1) == 0) unset($this->params["preview"]);
01534 }
01535 }
01536
01537
01541 class specialUnlockdb extends pageTest {
01542 function __construct() {
01543 $this->pagePath = "index.php?title=Special:Unlockdb";
01544
01545 $this->params = array (
01546 "action" => wikiFuzz::chooseInput( array("submit", "success", "", wikiFuzz::makeFuzz(2)) ),
01547 'wpEditToken' => wikiFuzz::chooseInput( array("20398702394", "", wikiFuzz::makeFuzz(2)) ),
01548 'wpLockConfirm' => wikiFuzz::chooseInput( array("0", "1", wikiFuzz::makeFuzz(2)) )
01549 );
01550
01551
01552 if (wikiFuzz::randnum(4) == 0) unset($this->params["wpEditToken"]);
01553 if (wikiFuzz::randnum(4) == 0) unset($this->params["action"]);
01554 if (wikiFuzz::randnum(4) == 0) unset($this->params["wpLockConfirm"]);
01555 }
01556 }
01557
01558
01562 class specialLockdb extends pageTest {
01563 function __construct() {
01564 $this->pagePath = "index.php?title=Special:Lockdb";
01565
01566 $this->params = array (
01567 "action" => wikiFuzz::chooseInput( array("submit", "success", "", wikiFuzz::makeFuzz(2)) ),
01568 'wpEditToken' => wikiFuzz::chooseInput( array("20398702394", "", wikiFuzz::makeFuzz(2)) ),
01569 'wpLockReason' => wikiFuzz::makeFuzz(2),
01570 'wpLockConfirm'=> wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) )
01571 );
01572
01573
01574 if (wikiFuzz::randnum(4) == 0) unset($this->params["wpEditToken"]);
01575 if (wikiFuzz::randnum(4) == 0) unset($this->params["action"]);
01576 if (wikiFuzz::randnum(4) == 0) unset($this->params["wpLockConfirm"]);
01577 }
01578 }
01579
01580
01584 class specialUserrights extends pageTest {
01585 function __construct() {
01586 $this->pagePath = "index.php?title=Special:Userrights";
01587
01588 $this->params = array (
01589 'wpEditToken' => wikiFuzz::chooseInput( array("20398702394", "", wikiFuzz::makeFuzz(2)) ),
01590 'user-editname' => wikiFuzz::chooseInput( array("Nickj2", "Nickj2\n<xyz>", wikiFuzz::makeFuzz(2)) ),
01591 'ssearchuser' => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01592 'saveusergroups'=> wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)), "Save User Groups"),
01593 'member[]' => wikiFuzz::chooseInput( array("0", "bot", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01594 "available[]" => wikiFuzz::chooseInput( array("0", "sysop", "bureaucrat", "1", "++--34234", wikiFuzz::makeFuzz(2)) )
01595 );
01596
01597
01598 if (wikiFuzz::randnum(3) == 0) unset($this->params['ssearchuser']);
01599 if (wikiFuzz::randnum(3) == 0) unset($this->params['saveusergroups']);
01600 }
01601 }
01602
01603
01607 class pageProtectionForm extends pageTest {
01608 function __construct() {
01609 $this->pagePath = "index.php?title=Main_Page";
01610
01611 $this->params = array (
01612 "action" => "protect",
01613 'wpEditToken' => wikiFuzz::chooseInput( array("20398702394", "", wikiFuzz::makeFuzz(2)) ),
01614 "mwProtect-level-edit" => wikiFuzz::chooseInput( array('', 'autoconfirmed', 'sysop', wikifuzz::makeFuzz(2)) ),
01615 "mwProtect-level-move" => wikiFuzz::chooseInput( array('', 'autoconfirmed', 'sysop', wikifuzz::makeFuzz(2)) ),
01616 "mwProtectUnchained" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01617 'mwProtect-reason' => wikiFuzz::chooseInput( array("because it was there", wikifuzz::makeFuzz(2)) )
01618 );
01619
01620
01621
01622 if (wikiFuzz::randnum(3) == 0) unset($this->params["mwProtectUnchained"]);
01623 if (wikiFuzz::randnum(3) == 0) unset($this->params['mwProtect-reason']);
01624 }
01625 }
01626
01627
01631 class specialBlockip extends pageTest {
01632 function __construct() {
01633 $this->pagePath = "index.php?title=Special:Blockip";
01634
01635 $this->params = array (
01636 "action" => wikiFuzz::chooseInput( array("submit", "", wikiFuzz::makeFuzz(2)) ),
01637 'wpEditToken' => wikiFuzz::chooseInput( array("20398702394", "", wikiFuzz::makeFuzz(2)) ),
01638 "wpBlockAddress" => wikiFuzz::chooseInput( array("20398702394", "", "Nickj2", wikiFuzz::makeFuzz(2),
01639
01640 ( wikiFuzz::randnum(300,-20) . "." . wikiFuzz::randnum(300,-20) . "."
01641 . wikiFuzz::randnum(300,-20) . "." .wikiFuzz::randnum(300,-20) ) ) ),
01642 "ip" => wikiFuzz::chooseInput( array("20398702394", "", "Nickj2", wikiFuzz::makeFuzz(2),
01643
01644 ( wikiFuzz::randnum(300,-20) . "." . wikiFuzz::randnum(300,-20) . "."
01645 . wikiFuzz::randnum(300,-20) . "." .wikiFuzz::randnum(300,-20) ) ) ),
01646 "wpBlockOther" => wikiFuzz::chooseInput( array('', 'Nickj2', wikifuzz::makeFuzz(2)) ),
01647 "wpBlockExpiry" => wikiFuzz::chooseInput( array("other", "2 hours", "1 day", "3 days", "1 week", "2 weeks",
01648 "1 month", "3 months", "6 months", "1 year", "infinite", wikiFuzz::makeFuzz(2)) ),
01649 "wpBlockReason" => wikiFuzz::chooseInput( array("because it was there", wikifuzz::makeFuzz(2)) ),
01650 "wpAnonOnly" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01651 "wpCreateAccount" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01652 "wpBlock" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) )
01653 );
01654
01655
01656 if (wikiFuzz::randnum(4) == 0) unset($this->params["wpBlockOther"]);
01657 if (wikiFuzz::randnum(4) == 0) unset($this->params["wpBlockExpiry"]);
01658 if (wikiFuzz::randnum(4) == 0) unset($this->params["wpBlockReason"]);
01659 if (wikiFuzz::randnum(4) == 0) unset($this->params["wpAnonOnly"]);
01660 if (wikiFuzz::randnum(4) == 0) unset($this->params["wpCreateAccount"]);
01661 if (wikiFuzz::randnum(4) == 0) unset($this->params["wpBlockAddress"]);
01662 if (wikiFuzz::randnum(4) == 0) unset($this->params["ip"]);
01663 }
01664 }
01665
01666
01670 class imagepageTest extends pageTest {
01671 function __construct() {
01672 $this->pagePath = "index.php?title=Image:Small-email.png";
01673
01674 $this->params = array (
01675 "image" => wikiFuzz::chooseInput( array("Small-email.png", wikifuzz::makeFuzz(2)) ),
01676 "wpReason" => wikifuzz::makeFuzz(2),
01677 "oldimage" => wikiFuzz::chooseInput( array("Small-email.png", wikifuzz::makeFuzz(2)) ),
01678 "wpEditToken" => wikiFuzz::chooseInput( array("20398702394", "", wikiFuzz::makeFuzz(2)) ),
01679 );
01680
01681
01682 if (wikiFuzz::randnum(6) == 0) unset($this->params["image"]);
01683 if (wikiFuzz::randnum(6) == 0) unset($this->params["wpReason"]);
01684 if (wikiFuzz::randnum(6) == 0) unset($this->params["oldimage"]);
01685 if (wikiFuzz::randnum(6) == 0) unset($this->params["wpEditToken"]);
01686 }
01687 }
01688
01689
01693 class pageDeletion extends pageTest {
01694 function __construct() {
01695 $this->pagePath = "index.php?title=Main_Page&action=delete";
01696
01697 $this->params = array (
01698 "wpEditToken" => wikiFuzz::chooseInput( array("20398702394", "", wikiFuzz::makeFuzz(2)) ),
01699 "wpReason" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01700 "wpConfirm" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01701 );
01702
01703
01704 if (wikiFuzz::randnum(5) == 0) unset($this->params["wpReason"]);
01705 if (wikiFuzz::randnum(5) == 0) unset($this->params["wpEditToken"]);
01706 if (wikiFuzz::randnum(5) == 0) unset($this->params["wpConfirm"]);
01707 }
01708 }
01709
01710
01711
01715 class specialRevisionDelete extends pageTest {
01716 function __construct() {
01717 $this->pagePath = "index.php?title=Special:Revisiondelete";
01718
01719 $this->params = array (
01720 "target" => wikiFuzz::chooseInput( array("Main Page", wikifuzz::makeFuzz(2)) ),
01721 "oldid" => wikifuzz::makeFuzz(2),
01722 "oldid[]" => wikifuzz::makeFuzz(2),
01723 "wpReason" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01724 "revdelete-hide-text" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01725 "revdelete-hide-comment" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01726 "revdelete-hide-user" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01727 "revdelete-hide-restricted" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01728 );
01729
01730
01731 if (wikiFuzz::randnum(3) == 0) unset($this->params["target"]);
01732 if (wikiFuzz::randnum(6) == 0) unset($this->params["oldid"]);
01733 if (wikiFuzz::randnum(6) == 0) unset($this->params["oldid[]"]);
01734 if (wikiFuzz::randnum(6) == 0) unset($this->params["wpReason"]);
01735 if (wikiFuzz::randnum(6) == 0) unset($this->params["revdelete-hide-text"]);
01736 if (wikiFuzz::randnum(6) == 0) unset($this->params["revdelete-hide-comment"]);
01737 if (wikiFuzz::randnum(6) == 0) unset($this->params["revdelete-hide-user"]);
01738 if (wikiFuzz::randnum(6) == 0) unset($this->params["revdelete-hide-restricted"]);
01739 }
01740 }
01741
01742
01746 class specialImport extends pageTest {
01747 function __construct() {
01748 $this->pagePath = "index.php?title=Special:Import";
01749
01750 $this->params = array (
01751 "action" => "submit",
01752 "source" => wikiFuzz::chooseInput( array("upload", "interwiki", wikifuzz::makeFuzz(2)) ),
01753 "MAX_FILE_SIZE" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikifuzz::makeFuzz(2)) ),
01754 "xmlimport" => wikiFuzz::chooseInput( array("/var/www/hosts/mediawiki/wiki/AdminSettings.php", "1", "++--34234", wikiFuzz::makeFuzz(2)) ),
01755 "namespace" => wikiFuzz::chooseInput( array(wikiFuzz::randnum(30,-6), wikiFuzz::makeFuzz(2)) ),
01756 "interwiki" => wikiFuzz::makeFuzz(2),
01757 "interwikiHistory" => wikiFuzz::makeFuzz(2),
01758 "frompage" => wikiFuzz::makeFuzz(2),
01759 );
01760
01761
01762 if (wikiFuzz::randnum(6) == 0) unset($this->params["action"]);
01763 if (wikiFuzz::randnum(6) == 0) unset($this->params["source"]);
01764 if (wikiFuzz::randnum(6) == 0) unset($this->params["MAX_FILE_SIZE"]);
01765 if (wikiFuzz::randnum(6) == 0) unset($this->params["xmlimport"]);
01766 if (wikiFuzz::randnum(6) == 0) unset($this->params["interwiki"]);
01767 if (wikiFuzz::randnum(6) == 0) unset($this->params["interwikiHistory"]);
01768 if (wikiFuzz::randnum(6) == 0) unset($this->params["frompage"]);
01769
01770
01771 }
01772 }
01773
01774
01778 class thumbTest extends pageTest {
01779 function __construct() {
01780 $this->pagePath = "thumb.php";
01781
01782 $this->params = array (
01783 "f" => wikiFuzz::chooseInput( array("..", "\\", "small-email.png", wikifuzz::makeFuzz(2)) ),
01784 "w" => wikiFuzz::chooseInput( array("80", wikiFuzz::randnum(6000,-200), wikifuzz::makeFuzz(2)) ),
01785 "r" => wikiFuzz::chooseInput( array("0", wikifuzz::makeFuzz(2)) ),
01786 );
01787
01788
01789 if (wikiFuzz::randnum(6) == 0) unset($this->params["f"]);
01790 if (wikiFuzz::randnum(6) == 0) unset($this->params["w"]);
01791 if (wikiFuzz::randnum(6) == 0) unset($this->params["r"]);
01792 }
01793 }
01794
01795
01799 class trackbackTest extends pageTest {
01800 function __construct() {
01801 $this->pagePath = "trackback.php";
01802
01803 $this->params = array (
01804 "url" => wikifuzz::makeFuzz(2),
01805 "blog_name" => wikiFuzz::chooseInput( array("80", wikiFuzz::randnum(6000,-200), wikifuzz::makeFuzz(2)) ),
01806 "article" => wikiFuzz::chooseInput( array("Main Page", wikifuzz::makeFuzz(2)) ),
01807 "title" => wikiFuzz::chooseInput( array("Main Page", wikifuzz::makeFuzz(2)) ),
01808 "excerpt" => wikifuzz::makeFuzz(2),
01809 );
01810
01811
01812 if (wikiFuzz::randnum(3) == 0) unset($this->params["title"]);
01813 if (wikiFuzz::randnum(3) == 0) unset($this->params["excerpt"]);
01814
01815
01816 $this->tidyValidate = false;
01817 }
01818 }
01819
01820
01824 class profileInfo extends pageTest {
01825 function __construct() {
01826 $this->pagePath = "profileinfo.php";
01827
01828 $this->params = array (
01829 "expand" => wikifuzz::makeFuzz(2),
01830 "sort" => wikiFuzz::chooseInput( array("time", "count", "name", wikifuzz::makeFuzz(2)) ),
01831 "filter" => wikiFuzz::chooseInput( array("Main Page", wikifuzz::makeFuzz(2)) ),
01832 );
01833
01834
01835 if (wikiFuzz::randnum(3) == 0) unset($this->params["sort"]);
01836 if (wikiFuzz::randnum(3) == 0) unset($this->params["filter"]);
01837 }
01838 }
01839
01840
01844 class specialCite extends pageTest {
01845 function __construct() {
01846 $this->pagePath = "index.php?title=Special:Cite";
01847
01848 $this->params = array (
01849 "page" => wikiFuzz::chooseInput( array("\" onmouseover=\"alert(1);\"", "Main Page", wikifuzz::makeFuzz(2)) ),
01850 "id" => wikiFuzz::chooseInput( array("-1", "0", "------'-------0", "+1", "-9823412312312412435", wikiFuzz::makeFuzz(2)) ),
01851 );
01852
01853
01854 if (wikiFuzz::randnum(6) == 0) unset($this->params["page"]);
01855 if (wikiFuzz::randnum(6) == 0) unset($this->params["id"]);
01856 }
01857 }
01858
01859
01863 class specialFilepath extends pageTest {
01864 function __construct() {
01865 $this->pagePath = "index.php?title=Special:Filepath";
01866
01867 $this->params = array (
01868 "file" => wikiFuzz::chooseInput( array("Small-email.png", "Small-email.png" . wikifuzz::makeFuzz(1), wikiFuzz::makeFuzz(2)) ),
01869 );
01870 }
01871 }
01872
01873
01877 class specialMakebot extends pageTest {
01878 function __construct() {
01879 $this->pagePath = "index.php?title=Special:Makebot";
01880
01881 $this->params = array (
01882 "username" => wikiFuzz::chooseInput( array("Nickj2", "192.168.0.2", wikifuzz::makeFuzz(1) ) ),
01883 "dosearch" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikifuzz::makeFuzz(2)) ),
01884 "grant" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikifuzz::makeFuzz(2)) ),
01885 "comment" => wikiFuzz::chooseInput( array("20398702394", "", wikiFuzz::makeFuzz(2)) ),
01886 "token" => wikiFuzz::chooseInput( array("20398702394", "", wikiFuzz::makeFuzz(2)) ),
01887 );
01888
01889
01890 if (wikiFuzz::randnum(2) == 0) unset($this->params["dosearch"]);
01891 if (wikiFuzz::randnum(2) == 0) unset($this->params["grant"]);
01892 if (wikiFuzz::randnum(5) == 0) unset($this->params["token"]);
01893 }
01894 }
01895
01896
01900 class specialMakesysop extends pageTest {
01901 function __construct() {
01902 $this->pagePath = "index.php?title=Special:Makesysop";
01903
01904 $this->params = array (
01905 "wpMakesysopUser" => wikiFuzz::chooseInput( array("Nickj2", "192.168.0.2", wikifuzz::makeFuzz(1) ) ),
01906 "action" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikifuzz::makeFuzz(2)) ),
01907 "wpMakesysopSubmit" => wikiFuzz::chooseInput( array("0", "1", "++--34234", wikifuzz::makeFuzz(2)) ),
01908 "wpEditToken" => wikiFuzz::chooseInput( array("20398702394", "", wikiFuzz::makeFuzz(2)) ),
01909 "wpSetBureaucrat" => wikiFuzz::chooseInput( array("20398702394", "", wikiFuzz::makeFuzz(2)) ),
01910 );
01911
01912
01913 if (wikiFuzz::randnum(3) == 0) unset($this->params["wpMakesysopSubmit"]);
01914 if (wikiFuzz::randnum(3) == 0) unset($this->params["wpEditToken"]);
01915 if (wikiFuzz::randnum(3) == 0) unset($this->params["wpSetBureaucrat"]);
01916 }
01917 }
01918
01919
01923 class specialRenameuser extends pageTest {
01924 function __construct() {
01925 $this->pagePath = "index.php?title=Special:Renameuser";
01926
01927 $this->params = array (
01928 "oldusername" => wikiFuzz::chooseInput( array("Nickj2", "192.168.0.2", wikifuzz::makeFuzz(1) ) ),
01929 "newusername" => wikiFuzz::chooseInput( array("Nickj2", "192.168.0.2", wikifuzz::makeFuzz(1) ) ),
01930 "token" => wikiFuzz::chooseInput( array("20398702394", "", wikiFuzz::makeFuzz(2)) ),
01931 );
01932 }
01933 }
01934
01935
01939 class specialLinksearch extends pageTest {
01940 function __construct() {
01941 $this->pagePath = "index.php?title=Special%3ALinksearch";
01942
01943 $this->params = array (
01944 "target" => wikifuzz::makeFuzz(2),
01945 );
01946
01947
01948 if (wikiFuzz::randnum(10) == 0) unset($this->params["target"]);
01949 }
01950 }
01951
01952
01956 class specialCategoryTree extends pageTest {
01957 function __construct() {
01958 $this->pagePath = "index.php?title=Special:CategoryTree";
01959
01960 $this->params = array (
01961 "target" => wikifuzz::makeFuzz(2),
01962 "from" => wikifuzz::makeFuzz(2),
01963 "until" => wikifuzz::makeFuzz(2),
01964 "showas" => wikifuzz::makeFuzz(2),
01965 "mode" => wikiFuzz::chooseInput( array("pages", "categories", "all", wikifuzz::makeFuzz(2)) ),
01966 );
01967
01968
01969 if (wikiFuzz::randnum(5) == 0) $this->params["notree"] = wikiFuzz::chooseInput( array("1", 0, "", wikiFuzz::makeFuzz(2)) );
01970 }
01971 }
01972
01973
01977 class specialChemicalsourcesTest extends pageTest {
01978 function __construct() {
01979 $this->pagePath = "index.php?title=Special:Chemicalsources";
01980
01981
01982 $format = wikiFuzz::chooseInput(
01983 array( 'go',
01984 'CAS',
01985 'EINECS',
01986 'CHEBI',
01987 'PubChem',
01988 'SMILES',
01989 'InChI',
01990 'ATCCode',
01991 'KEGG',
01992 'RTECS',
01993 'ECNumber',
01994 'DrugBank',
01995 'Formula',
01996 'Name'
01997 )
01998 );
01999
02000
02001 switch ($format) {
02002 case 'Name' : $value = "A"; break;
02003 case 'InChI' :
02004 case 'SMILES' :
02005 case 'Formula': $value = "C"; break;
02006 default : $value = "0"; break;
02007 }
02008
02009
02010 $this->params = array ($format => $value . wikifuzz::makeFuzz(2) );
02011 }
02012 }
02013
02014
02024 class api extends pageTest {
02025
02026
02027 private static function loginMode() {
02028 $arr = array ( "lgname" => wikifuzz::makeFuzz(2),
02029 "lgpassword" => wikifuzz::makeFuzz(2),
02030 );
02031
02032 if (wikiFuzz::randnum(3) == 0) {
02033 $arr["lgdomain"] = wikiFuzz::chooseInput( array("1", 0, "", wikiFuzz::makeFuzz(2)) );
02034 }
02035
02036 return $arr;
02037 }
02038
02039
02040 private static function opensearchMode() {
02041 return array ("search" => wikifuzz::makeFuzz(2));
02042 }
02043
02044
02045 private static function feedwatchlistMode() {
02046
02047 return array ("feedformat" => wikiFuzz::chooseInput( array("rss", "atom") ) );
02048 }
02049
02050
02051 private static function queryMode() {
02052
02053
02054 $params = array (
02055
02056 "titles" => wikiFuzz::chooseInput( array("Main Page")),
02057
02058 "pageids" => 1,
02059 "prop" => wikiFuzz::chooseInput( array("info", "revisions", "watchlist")),
02060 "list" => wikiFuzz::chooseInput( array("allpages", "logevents", "watchlist", "usercontribs", "recentchanges", "backlinks", "embeddedin", "imagelinks") ),
02061 "meta" => wikiFuzz::chooseInput( array("siteinfo")),
02062 "generator" => wikiFuzz::chooseInput( array("allpages", "logevents", "watchlist", "info", "revisions") ),
02063 "siprop" => wikiFuzz::chooseInput( array("general", "namespaces", "general|namespaces") ),
02064 );
02065
02066
02067 switch ($params["list"]) {
02068 case "usercontribs" : self::addListParams ($params, "uc", array("limit", "start", "end", "user", "dir") ); break;
02069 case "allpages" : self::addListParams ($params, "ap", array("from", "prefix", "namespace", "filterredir", "limit") ); break;
02070 case "watchlist" : self::addListParams ($params, "wl", array("allrev", "start", "end", "namespace", "dir", "limit", "prop") ); break;
02071 case "logevents" : self::addListParams ($params, "le", array("limit", "type", "start", "end", "user", "dir") ); break;
02072 case "recentchanges": self::addListParams ($params, "rc", array("limit", "prop", "show", "namespace", "start", "end", "dir") ); break;
02073 case "backlinks" : self::addListParams ($params, "bl", array("continue", "namespace", "redirect", "limit") ); break;
02074 case "embeddedin" : self::addListParams ($params, "ei", array("continue", "namespace", "redirect", "limit") ); break;
02075 case "imagelinks" : self::addListParams ($params, "il", array("continue", "namespace", "redirect", "limit") ); break;
02076 }
02077
02078 if ($params["prop"] == "revisions") {
02079 self::addListParams ($params, "rv", array("prop", "limit", "startid", "endid", "end", "dir") );
02080 }
02081
02082
02083 if (wikiFuzz::randnum(3) == 0) {
02084 $params["redirects"] = wikiFuzz::chooseInput( array("1", 0, "", wikiFuzz::makeFuzz(2)) );
02085 }
02086
02087 return $params;
02088 }
02089
02090
02091 private static function addListParams(&$array, $prefix, $elements) {
02092 foreach ($elements as $element) {
02093 $array[$prefix . $element] = self::getParamDetails($element);
02094 }
02095 }
02096
02097
02098 private static function getParamDetails($element) {
02099 switch ($element) {
02100 case 'startid' :
02101 case 'endid' :
02102 case 'start' :
02103 case 'end' :
02104 case 'limit' : return wikiFuzz::chooseInput( array("0", "-1", "---'----------0", "+1", "8134", "320742734234235", "20060230121212", wikiFuzz::randnum(9000, -100), wikiFuzz::makeFuzz(2)) );
02105 case 'dir' : return wikiFuzz::chooseInput( array("newer", "older", wikifuzz::makeFuzz(2) ) );
02106 case 'user' : return wikiFuzz::chooseInput( array(USER_ON_WIKI, wikifuzz::makeFuzz(2) ) );
02107 case 'namespace' : return wikiFuzz::chooseInput( array(-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 200000, wikifuzz::makeFuzz(2)) );
02108 case 'filterredir': return wikiFuzz::chooseInput( array("all", "redirects", "nonredirectsallpages", wikifuzz::makeFuzz(2)) );
02109 case 'allrev' : return wikiFuzz::chooseInput( array("1", 0, "", wikiFuzz::makeFuzz(2)) );
02110 case 'prop' : return wikiFuzz::chooseInput( array("user", "comment", "timestamp", "patrol", "flags", "user|user|comment|flags", wikifuzz::makeFuzz(2) ) );
02111 case 'type' : return wikiFuzz::chooseInput( array("block", "protect", "rights", "delete", "upload", "move", "import", "renameuser", "newusers", "makebot", wikifuzz::makeFuzz(2) ) );
02112 case 'hide' : return wikiFuzz::chooseInput( array("minor", "bots", "anons", "liu", "liu|bots|", wikifuzz::makeFuzz(2) ) );
02113 case 'show' : return wikiFuzz::chooseInput( array('minor', '!minor', 'bot', '!bot', 'anon', '!anon', wikifuzz::makeFuzz(2) ) );
02114 default : return wikifuzz::makeFuzz(2);
02115 }
02116 }
02117
02118
02119 function __construct() {
02120 $this->pagePath = "api.php";
02121
02122 $modes = array ("help",
02123 "login",
02124 "opensearch",
02125 "feedwatchlist",
02126 "query");
02127 $action = wikiFuzz::chooseInput( array_merge ($modes, array(wikifuzz::makeFuzz(2))) );
02128
02129 switch ($action) {
02130 case "login" : $this->params = self::loginMode();
02131 break;
02132 case "opensearch" : $this->params = self::opensearchMode();
02133 break;
02134 case "feedwatchlist" : $this->params = self::feedwatchlistMode();
02135 break;
02136 case "query" : $this->params = self::queryMode();
02137 break;
02138 case "help" :
02139 default :
02140 $random_mode = wikiFuzz::chooseInput( $modes ) . "Mode";
02141
02142 if ($random_mode == "helpMode") $random_mode = "queryMode";
02143 $this->params = self::$random_mode();
02144 break;
02145 }
02146
02147
02148 $this->params["action"] = $action;
02149
02150
02151
02152 $this->cookie = "wikidbUserID=10001; wikidbUserName=Test; wikidb_session=178df0fe68c75834643af65dec9ec98a; wikidbToken=1adc6753d62c44aec950c024d7ae0540";
02153
02154
02155 $this->params["format"] = wikiFuzz::chooseInput( array("json", "jsonfm", "php", "phpfm",
02156 "wddx", "wddxfm", "xml", "xmlfm",
02157 "yaml", "yamlfm", "raw", "rawfm",
02158 wikifuzz::makeFuzz(2) ) );
02159
02160
02161 $this->tidyValidate = false;
02162 }
02163 }
02164
02165
02169 class GeSHi_Test extends pageTest {
02170
02171 private function getGeSHiContent() {
02172 return "<source lang=\"" . $this->getLang() . "\" "
02173 . (wikiFuzz::randnum(2) == 0 ? "line " : "")
02174 . (wikiFuzz::randnum(2) == 0 ? "strict " : "")
02175 . "start=" . wikiFuzz::chooseInput( array(wikiFuzz::randnum(-6000,6000), wikifuzz::makeFuzz(2)) )
02176 . ">"
02177 . wikiFuzz::makeFuzz(2)
02178 . "</source>";
02179 }
02180
02181 private function getLang() {
02182 return wikiFuzz::chooseInput( array( "actionscript", "ada", "apache", "applescript", "asm", "asp", "autoit", "bash", "blitzbasic", "bnf", "c", "c_mac", "caddcl", "cadlisp",
02183 "cfdg", "cfm", "cpp", "cpp-qt", "csharp", "css", "d", "delphi", "diff", "div", "dos", "eiffel", "fortran", "freebasic", "gml", "groovy", "html4strict", "idl",
02184 "ini", "inno", "io", "java", "java5", "javascript", "latex", "lisp", "lua", "matlab", "mirc", "mpasm", "mysql", "nsis", "objc", "ocaml", "ocaml-brief", "oobas",
02185 "oracle8", "pascal", "perl", "php", "php-brief", "plsql", "python", "qbasic", "rails", "reg", "robots", "ruby", "sas", "scheme", "sdlbasic", "smalltalk", "smarty",
02186 "sql", "tcl", "text", "thinbasic", "tsql", "vb", "vbnet", "vhdl", "visualfoxpro", "winbatch", "xml", "xpp", "z80", wikifuzz::makeFuzz(1) ) );
02187 }
02188
02189 function __construct() {
02190 $this->pagePath = "index.php?title=WIKIFUZZ";
02191
02192 $this->params = array (
02193 "action" => "submit",
02194 "wpMinoredit" => "test",
02195 "wpPreview" => "test",
02196 "wpSection" => "test",
02197 "wpEdittime" => "test",
02198 "wpSummary" => "test",
02199 "wpScrolltop" => "test",
02200 "wpStarttime" => "test",
02201 "wpAutoSummary" => "test",
02202 "wpTextbox1" => $this->getGeSHiContent()
02203 );
02204 }
02205 }
02206
02207
02211 function selectPageTest($count) {
02212
02213
02214 if (defined("SPECIFIC_TEST")) {
02215 $testType = SPECIFIC_TEST;
02216 return new $testType ();
02217 }
02218
02219
02220
02221 switch ($count % 100) {
02222 case 0 : return new successfulUserLoginTest();
02223 case 1 : return new listusersTest();
02224 case 2 : return new searchTest();
02225 case 3 : return new recentchangesTest();
02226 case 4 : return new prefixindexTest();
02227 case 5 : return new mimeSearchTest();
02228 case 6 : return new specialLogTest();
02229 case 7 : return new userLoginTest();
02230 case 8 : return new ipblocklistTest();
02231 case 9 : return new newImagesTest();
02232 case 10: return new imagelistTest();
02233 case 11: return new specialExportTest();
02234 case 12: return new specialBooksourcesTest();
02235 case 13: return new specialAllpagesTest();
02236 case 14: return new pageHistoryTest();
02237 case 15: return new contributionsTest();
02238 case 16: return new viewPageTest();
02239 case 17: return new specialAllmessagesTest();
02240 case 18: return new specialNewpages();
02241 case 19: return new searchTest();
02242 case 20: return new redirectTest();
02243 case 21: return new confirmEmail();
02244 case 22: return new watchlistTest();
02245 case 23: return new specialBlockmeTest();
02246 case 24: return new specialUndelete();
02247 case 25: return new specialMovePage();
02248 case 26: return new specialUnlockdb();
02249 case 27: return new specialLockdb();
02250 case 28: return new specialUserrights();
02251 case 29: return new pageProtectionForm();
02252 case 30: return new specialBlockip();
02253 case 31: return new imagepageTest();
02254 case 32: return new pageDeletion();
02255 case 33: return new specialRevisionDelete();
02256 case 34: return new specialImport();
02257 case 35: return new thumbTest();
02258 case 36: return new trackbackTest();
02259 case 37: return new profileInfo();
02260 case 38: return new specialCite();
02261 case 39: return new specialFilepath();
02262 case 40: return new specialMakebot();
02263 case 41: return new specialMakesysop();
02264 case 42: return new specialRenameuser();
02265 case 43: return new specialLinksearch();
02266 case 44: return new specialCategoryTree();
02267 case 45: return new api();
02268 case 45: return new specialChemicalsourcesTest();
02269 default: return new editPageTest();
02270 }
02271 }
02272
02273
02275
02279 function saveFile($data, $name) {
02280 file_put_contents($name, $data);
02281 }
02282
02283
02289 function getAsURL(pageTest $test) {
02290 $used_question_mark = (strpos($test->getPagePath(), "?") !== false);
02291 $retval = "http://get-to-post.nickj.org/?" . WIKI_BASE_URL . $test->getPagePath();
02292 foreach ($test->getParams() as $param => $value) {
02293 if (!$used_question_mark) {
02294 $retval .= "?";
02295 $used_question_mark = true;
02296 }
02297 else {
02298 $retval .= "&";
02299 }
02300 $retval .= $param . "=" . urlencode($value);
02301 }
02302 return $retval;
02303 }
02304
02305
02309 function saveTestAsText(pageTest $test, $filename) {
02310 $str = "Test: " . $test->getPagePath();
02311 foreach ($test->getParams() as $param => $value) {
02312 $str .= "\n$param: $value";
02313 }
02314 $str .= "\nGet-to-post URL: " . getAsURL($test) . "\n";
02315 saveFile($str, $filename);
02316 }
02317
02318
02323 function saveTestAsPHP(pageTest $test, $filename) {
02324 $str = "<?php\n"
02325 . "\$params = " . var_export(escapeForCurl($test->getParams()), true) . ";\n"
02326 . "\$ch = curl_init();\n"
02327 . "curl_setopt(\$ch, CURLOPT_POST, 1);\n"
02328 . "curl_setopt(\$ch, CURLOPT_POSTFIELDS, \$params );\n"
02329 . "curl_setopt(\$ch, CURLOPT_URL, " . var_export(WIKI_BASE_URL . $test->getPagePath(), true) . ");\n"
02330 . "curl_setopt(\$ch, CURLOPT_RETURNTRANSFER,1);\n"
02331 . ($test->getCookie() ? "curl_setopt(\$ch, CURLOPT_COOKIE, " . var_export($test->getCookie(), true) . ");\n" : "")
02332 . "\$result=curl_exec(\$ch);\n"
02333 . "curl_close (\$ch);\n"
02334 . "print \$result;\n"
02335 . "?>\n";
02336 saveFile($str, $filename);
02337 }
02338
02339
02345 function escapeForCurl(array $input_params) {
02346 $output_params = array();
02347 foreach ($input_params as $param => $value) {
02348 if (strlen($value) > 0 && ( $value[0] == "@" || $value[0] == "<")) {
02349 $value = "\\" . $value;
02350 }
02351 $output_params[$param] = $value;
02352 }
02353 return $output_params;
02354 }
02355
02356
02361 function saveTestAsCurl(pageTest $test, $filename) {
02362 $str = "#!/bin/bash\n"
02363 . "curl --silent --include --globoff \\\n"
02364 . ($test->getCookie() ? " --cookie " . escapeshellarg($test->getCookie()) . " \\\n" : "");
02365 foreach (escapeForCurl($test->getParams()) as $param => $value) {
02366 $str .= " -F " . escapeshellarg($param) . "=" . escapeshellarg($value) . " \\\n";
02367 }
02368 $str .= " " . escapeshellarg(WIKI_BASE_URL . $test->getPagePath());
02369 $str .= "\n";
02370 saveFile($str, $filename);
02371 chmod($filename, 0755);
02372 }
02373
02374
02378 function saveTestData (pageTest $test, $filename) {
02379 saveFile(serialize($test), $filename);
02380 }
02381
02382
02386 function saveTest(pageTest $test, $testname) {
02387 $base_name = DIRECTORY . "/" . $testname;
02388 saveTestAsText($test, $base_name . INFO_FILE);
02389 saveTestAsPHP ($test, $base_name . PHP_TEST );
02390 saveTestAsCurl($test, $base_name . CURL_TEST);
02391 saveTestData ($test, $base_name . DATA_FILE);
02392 }
02393
02394
02396
02400 function wikiTestOutput(pageTest $test) {
02401
02402 $ch = curl_init();
02403
02404
02405 if ($test->getCookie()) curl_setopt($ch, CURLOPT_COOKIE, $test->getCookie());
02406 curl_setopt($ch, CURLOPT_POST, 1);
02407
02408 $params = escapeForCurl($test->getParams());
02409 curl_setopt($ch, CURLOPT_POSTFIELDS, $params );
02410
02411 curl_setopt($ch, CURLOPT_URL, WIKI_BASE_URL . $test->getPagePath() );
02412 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
02413
02414 $result=curl_exec ($ch);
02415
02416
02417 if (curl_error($ch)) {
02418 print "\nCurl error #: " . curl_errno($ch) . " - " . curl_error ($ch);
02419 $result = "";
02420 }
02421
02422 curl_close ($ch);
02423
02424 return $result;
02425 }
02426
02427
02429
02430
02431
02432
02433 function validateHTML($text) {
02434
02435 $params = array ("fragment" => $text);
02436
02437 $ch = curl_init();
02438
02439 curl_setopt($ch, CURLOPT_POST, 1);
02440 curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
02441 curl_setopt($ch, CURLOPT_URL, VALIDATOR_URL);
02442 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
02443
02444 $result=curl_exec ($ch);
02445
02446
02447 if (curl_error($ch)) {
02448 trigger_error("Curl error #: " . curl_errno($ch) . " - " . curl_error ($ch) );
02449 print "Curl error #: " . curl_errno($ch) . " - " . curl_error ($ch) . " - exiting.\n";
02450 exit();
02451 }
02452
02453 curl_close ($ch);
02454
02455 $valid = (strpos($result, "Failed validation") === false ? true : false);
02456
02457 return array($valid, $result);
02458 }
02459
02460
02464 function tidyCheckFile($name) {
02465 $file = DIRECTORY . "/" . $name;
02466 $command = PATH_TO_TIDY . " -output /tmp/out.html -quiet $file 2>&1";
02467 $x = `$command`;
02468
02469
02470 if ( strpos($x,"end of file while parsing attributes") !== false
02471 || strpos($x,"attribute with missing trailing quote mark") !== false
02472 || strpos($x,"missing '>' for end of tag") !== false
02473 || strpos($x,"Error:") !== false) {
02474 print "\nTidy found something - view details with: $command";
02475 return false;
02476 } else {
02477 return true;
02478 }
02479 }
02480
02481
02486 function dbErrorLogged() {
02487 static $filesize;
02488
02489
02490 if (!isset($filesize)) {
02491
02492 if (!file_exists(DB_ERROR_LOG_FILE)) {
02493 saveFile("", DB_ERROR_LOG_FILE);
02494 }
02495 $filesize = filesize(DB_ERROR_LOG_FILE);
02496 return false;
02497 }
02498
02499 $newsize = filesize(DB_ERROR_LOG_FILE);
02500
02501 if ($newsize != $filesize) {
02502 $filesize = $newsize;
02503 return true;
02504 }
02505
02506 return false;
02507 }
02508
02510
02515 function runWikiTest(pageTest $test, &$testname, $can_overwrite = false) {
02516
02517
02518 while ( ! $can_overwrite && file_exists(DIRECTORY . "/" . $testname . DATA_FILE)) {
02519 $testname .= "-" . mt_rand(0,9);
02520 }
02521
02522 $filename = DIRECTORY . "/" . $testname . DATA_FILE;
02523
02524
02525 $before = microtime(true);
02526
02527
02528 $wiki_preview = wikiTestOutput($test);
02529
02530 $after = microtime(true);
02531
02532
02533 if ($wiki_preview == "") {
02534 print "\nNo response received for: $filename";
02535 return false;
02536 }
02537
02538
02539 $html_file = DIRECTORY . "/" . $testname . HTML_FILE;
02540 saveFile($wiki_preview, $html_file);
02541
02542
02543 if ( strpos($wiki_preview, "<b>Warning</b>: " ) !== false
02544 || strpos($wiki_preview, "<b>Fatal error</b>: " ) !== false
02545 || strpos($wiki_preview, "<b>Notice</b>: " ) !== false
02546 || strpos($wiki_preview, "<b>Error</b>: " ) !== false
02547 || strpos($wiki_preview, "<b>Strict Standards:</b>") !== false
02548 ) {
02549 $error = substr($wiki_preview, strpos($wiki_preview, "</b>:") + 7, 50);
02550
02551 if ($error != "Unknown: The session id contains illegal character") {
02552 print "\nPHP error/warning/notice in HTML output: $html_file ; $error";
02553 return false;
02554 }
02555 }
02556
02557
02558 if( strpos($wiki_preview, "Backtrace:") !== false ) {
02559 print "\nInternal MediaWiki error in HTML output: $html_file";
02560 return false;
02561 }
02562
02563
02564 if( strpos($wiki_preview, "!-- ERR") !== false ) {
02565 print "\nParser Error comment in HTML output: $html_file";
02566 return false;
02567 }
02568
02569
02570 if( dbErrorLogged() ) {
02571 print "\nDatabase Error logged for: $filename";
02572 return false;
02573 }
02574
02575
02576 $valid = true;
02577 if( VALIDATE_ON_WEB ) {
02578 list ($valid, $validator_output) = validateHTML($wiki_preview);
02579 if (!$valid) print "\nW3C web validation failed - view details with: html2text " . DIRECTORY . "/" . $testname . ".validator_output.html";
02580 }
02581
02582
02583 if( $test->tidyValidate() ) {
02584 $valid = tidyCheckFile( $testname . HTML_FILE ) && $valid;
02585 }
02586
02587
02588 if (($after - $before) >= 2) {
02589 print "\nParticularly slow to render (" . round($after - $before, 2) . " seconds): $filename";
02590 return false;
02591 }
02592
02593 if( $valid ) {
02594
02595 unlink( $html_file );
02596 } elseif( VALIDATE_ON_WEB ) {
02597 saveFile($validator_output, DIRECTORY . "/" . $testname . ".validator_output.html");
02598 }
02599
02600 return $valid;
02601 }
02602
02603
02605
02610 function rerunPreviousTests() {
02611 print "Retesting previously found problems.\n";
02612
02613 $dir_contents = scandir (DIRECTORY);
02614
02615
02616 natsort ($dir_contents);
02617
02618 foreach ($dir_contents as $file) {
02619
02620
02621
02622 $matches = array();
02623 if (!ereg("(.*)" . str_replace(".", "\.", DATA_FILE) . "$", $file, $matches)) continue;
02624
02625
02626 $full_path = DIRECTORY . "/" . $file;
02627 $test = unserialize(file_get_contents($full_path));
02628
02629
02630 if (! $test instanceof pageTest) {
02631 print "\nSkipping invalid test - $full_path";
02632 continue;
02633 }
02634
02635
02636
02637
02638 if (!QUIET) print "[" . date ("D M d H:i:s Y") . "] Retesting $file (" . get_class($test) . ")";
02639
02640
02641 $testname = $matches[1];
02642 $valid = runWikiTest($test, $testname, true);
02643
02644 if (!$valid) {
02645 saveTest($test, $testname);
02646 if (QUIET) {
02647 print "\nTest: " . get_class($test) . " ; Testname: $testname\n------";
02648 } else {
02649 print "\n";
02650 }
02651 }
02652 else {
02653 if (!QUIET) print "\r";
02654 if (DELETE_PASSED_RETESTS) {
02655 $prefix = DIRECTORY . "/" . $testname;
02656 if (is_file($prefix . DATA_FILE)) unlink($prefix . DATA_FILE);
02657 if (is_file($prefix . PHP_TEST )) unlink($prefix . PHP_TEST );
02658 if (is_file($prefix . CURL_TEST)) unlink($prefix . CURL_TEST);
02659 if (is_file($prefix . INFO_FILE)) unlink($prefix . INFO_FILE);
02660 }
02661 }
02662 }
02663
02664 print "\nDone retesting.\n";
02665 }
02666
02667
02669
02670
02671
02672 if( ! function_exists('curl_init') ) {
02673 die("Could not find 'curl_init' function. Is the curl extension compiled into PHP?\n");
02674 }
02675
02676
02677
02678 wikiFuzz::$types = array_keys(wikiFuzz::$data);
02679
02680
02681 if (!is_dir(DIRECTORY)) {
02682 mkdir (DIRECTORY, 0700 );
02683 }
02684
02685 else if (RERUN_OLD_TESTS) {
02686 rerunPreviousTests();
02687 }
02688
02689
02690 $start_time = date("U");
02691 $num_errors = 0;
02692 if (!QUIET) {
02693 print "Beginning main loop. Results are stored in the " . DIRECTORY . " directory.\n";
02694 print "Press CTRL+C to stop testing.\n";
02695 }
02696
02697 for ($count=0; true; $count++) {
02698 if (!QUIET) {
02699
02700 switch( $count % 4 ) {
02701 case '0': print "\r/"; break;
02702 case '1': print "\r-"; break;
02703 case '2': print "\r\\"; break;
02704 case '3': print "\r|"; break;
02705 }
02706 print " $count";
02707 }
02708
02709
02710 $test = selectPageTest($count);
02711
02712 $mins = ( date("U") - $start_time ) / 60;
02713 if (!QUIET && $mins > 0) {
02714 print ". $num_errors poss errors. "
02715 . floor($mins) . " mins. "
02716 . round ($count / $mins, 0) . " tests/min. "
02717 . get_class($test);
02718 }
02719
02720
02721 $testname = $count;
02722 $valid = runWikiTest($test, $testname, false);
02723
02724
02725 if ( ! $valid ) {
02726 if (QUIET) {
02727 print "\nTest: " . get_class($test) . " ; Testname: $testname\n------";
02728 } else {
02729 print "\n";
02730 }
02731 saveTest($test, $testname);
02732 $num_errors += 1;
02733 } else if ( KEEP_PASSED_TESTS ) {
02734
02735 print " " . date("H:i:s.") . substr(current(explode(" ", microtime())), 2) . " " . $testname;
02736 saveTest($test, $testname);
02737 }
02738
02739
02740 if (defined("MAX_ERRORS") && $num_errors>=MAX_ERRORS) {
02741 break;
02742 }
02743
02744
02745 if (defined("MAX_RUNTIME") && $mins>=MAX_RUNTIME) {
02746 break;
02747 }
02748 }
02749
02750