PageRenderTime 53ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/enwiki/list.pdf.php

https://github.com/Dispositif/addbot
PHP | 39 lines | 26 code | 7 blank | 6 comment | 1 complexity | 8bffdfde019f3cd0d93671dbce061888 MD5 | raw file
  1. <?
  2. // load the classes and stuff
  3. require '/data/project/addbot/classes/botclasses.php';
  4. require '/data/project/addbot/classes/database.php';
  5. require '/data/project/addbot/classes/template.php';
  6. require 'config.php';
  7. // initialise the wiki
  8. $wiki = new wikipedia;
  9. $wiki->url = 'http://'.$config['url'].'/w/api.php';
  10. global $wiki;
  11. // perform the login
  12. $wiki->login($config['user'],$config['password']);
  13. unset($config['password']);
  14. echo "done";
  15. //Get the list
  16. $list = file_get_contents('http://toolserver.org/~nikola/grep.php?pattern=.pdf&lang=en&wiki=wikipedia&ns=6');
  17. $list = explode('<td><input type="reset"/></td>',$list);
  18. $list = explode('<table border="1">',$list[1]);
  19. preg_match_all('/\wiki\/(Image\:.*?)\"\>/i', $list[1], $images);
  20. $images = $images[1];
  21. echo "Connecting to DB...\n";
  22. // connect to the database
  23. $db = new Database( $config['dbhost'], $config['dbport'], $config['dbuser'], $config['dbpass'], $config['dbname'], false);
  24. foreach ($images as $pdf)
  25. {
  26. usleep(1000);
  27. $res = $db->insert($config['tblist'],array('article' => $item,) ); // inset to database table
  28. if( !$res ){echo $db->errorStr()."\n";} // if no result then break as we have an error ($db->errorStr())
  29. else{echo "Added ".$item." to database\n";}
  30. }
  31. //$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).');
  32. ?>