PageRenderTime 42ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/depreciated/task.badformat.php

https://github.com/Dispositif/addbot
PHP | 45 lines | 38 code | 4 blank | 3 comment | 4 complexity | 4650ec0e67ec58746f749f62419a2de2 MD5 | raw file
  1. <?
  2. require 'bot.login.php';
  3. //Get the list
  4. $list = file_get_contents('http://toolserver.org/~nikola/grep.php?pattern=.pdf&lang=en&wiki=wikipedia&ns=6');
  5. $list = explode('<td><input type="reset"/></td>',$list);
  6. $list = explode('<table border="1">',$list[1]);
  7. preg_match_all('/\wiki\/(Image\:.*?)\"\>/i', $list[1], $images);
  8. $images = $images[1];
  9. foreach ($images as $pdf)
  10. {
  11. sleep(60);
  12. echo "Sleep 60\n";
  13. $text = $wiki->getpage("$pdf");
  14. if( preg_match("/\{\{(Bad(PDF|GIF| ?Format)|ShouldBe(Text|PNG|SVG)|Artifacts)\}\}/i",$text) || $wiki->nobots($pdf,$user,$text) == false)
  15. {
  16. echo "* - Skipping File:$pdf\n";
  17. }
  18. else
  19. {
  20. if(preg_match ("/== ?summary ?==/i",$text))
  21. {
  22. echo "2 - Tagging $pdf\n";
  23. //$pieces = explode("== Summary ==", $text);
  24. $pieces = preg_split("/== ?summary ?==/i",$text);
  25. $above = $pieces[0];
  26. $below = $pieces[1];
  27. $newtext = "$above==Summary==\n{{BadFormat}} $below";
  28. $edit_summary = "[[User:Addbot|Bot:]] Tagging PDF with {{BadFormat}}. [[User_Talk:Addbot|Report Errors]]";
  29. $wiki->edit($pdf,$newtext,$edit_summary,true);
  30. }
  31. else
  32. {
  33. echo "1 - Tagging $pdf\n";
  34. $newtext = "==Summary==\n{{BadFormat}}\n" .$text;
  35. $edit_summary = "[[User:Addbot|Bot:]] Tagging PDF with {{BadFormat}}. [[User_Talk:Addbot|Report Errors]]";
  36. $wiki->edit($pdf,$newtext,$edit_summary,true);
  37. }
  38. }
  39. }
  40. //$wpi-&gt;forcepost('User:'.$user.'/Pdfbot/list',"Please add a list of pdf's here from [http://toolserver.org/~nikola/grep.php?pattern=%5C.pdf&lang=en&wiki=wikipedia&ns=6 here].",'Automatic list blanking (task complete).');
  41. ?>