Ich habe die Funktion nun nur um einen USER_AGENT erweitert. Anscheinend sperrt WIKI nun alle Browser_USER_AGENT von PHP.
function get_wiki($image_wiki) {
global $user_info, $site_db, $session_info, $config;
ini_set('user_agent', '(Windows; U; Windows NT 6.1; de; rv:1.9.2) Gecko/20100115 Firefox/3.6');
// $image_name = preg_replace('/\\W/', '',$image_name);
$zeichen = array('#', '?', '§', '$', '%', '&', '/', '(', ')', '=', '^', '°', '*', '@');
$image_wiki = str_replace($zeichen,"",$image_wiki);
if(!$image_wiki) return false;
//Gesamter Test aus der Wiki-API nehmen
$url = "http://de.wikipedia.org/w/api.php?format=xml&action=parse&page=".$image_wiki;
$xml = simplexml_load_file($url);
$text = $xml->parse->text;
if(!$text) return false;
//Zusammenfassung suchen
$reg_exp = '/<p>(.*?)<\/p>/s';
preg_match_all($reg_exp, $text, $match);
$summary = $match[0][0];
$summary .= $match[0][1];
$summary .= $match[0][2];
$summary .= $match[0][3];
$summary .= $match[0][4];
$summary .= $match[0][5];
$summary .= $match[0][6];
$summary = utf8_decode($summary);
$summary = str_replace('?','"',$summary);
$image_wiki = str_replace(' ','_', $image_wiki);
$summary .= "<a href='http://de.wikipedia.org/wiki/$image_wiki' onclick=\"void(window.open(this.href, '', '')); return false;\" >Quelle:Wikipedia</a>";
//wenn Artikel nicht vorhanden
if($summary == "<p><b>Artikel verschwunden?</b></p>") return false;
//Links auf interne Seite ändern
$summary = str_replace('href="#',"href=\"http://de.wikipedia.org/wiki/$image_wiki#", $summary);
$summary = str_replace('href="/wiki/', 'href="http://de.wikipedia.org/wiki/', $summary);
// $summary = ereg_replace('</a>', '', $summary);
return $summary;
}
Damit klappt es nun bei mir, fraglich wie lange....... Wäre schön wenn das jemand mit dieser funktion, bzw mit der Erweiterung
ini_set('user_agent', '(Windows; U; Windows NT 6.1; de; rv:1.9.2) Gecko/20100115 Firefox/3.6');
bestätigen könnte.......
Gruß