From Wikipedia, the free encyclopedia
<?php
include("SxWiki.php");
include("config.php");
$outputpage = 'User:SQL/BRedir';
$output = "==Broken Redirects==\r\n";
$fp = fsockopen("en.wikipedia.org", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)\n";
} else {
$out = "GET /w/index.php?title=Special:BrokenRedirects&limit=500&offset=0 HTTP/1.1\r\n";
$out .= "Host: en.wikipedia.org\r\n";
$out .= "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
$f_input = fgets($fp, 512);
if (preg_match('/<li><a href=.*redirect.*title=".*".*<\/a>.*<\/li>/', $f_input)) {
preg_match('/title="(.+?)">[^\(].*<\/a>/', $f_input, $matches2);
$outtofile = "*[[" . $matches2[1] . "]]" . "\r\n";
$output = $output . $outtofile;
}
}
fclose($fp);
sxPutPage($outputpage, "Posting daily broken redir search, using [[User:SQL/SxWiki|SxWiki]]", $output, "0");
}
?>