diff --git a/HISTORY b/HISTORY new file mode 100644 index 0000000..48ede65 --- /dev/null +++ b/HISTORY @@ -0,0 +1,6 @@ +0.1 - 2014-07-28 + First release of wie + +0.2 - 2014-07-31 + Changed 'shell_exec(curl -s $URL)' to PHP5 cURL function + Added HISTORY file diff --git a/README.md b/README.md index bd35cfa..21274f9 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,9 @@ Or run it with 'php wie.php'. To display the help, type: ./wie.php --help +## Requirements ## +The script requires PHP5 and the PHP5 cURL module (php5-curl on Debian systems). + ## Thanks ## Many thanks goes to flinga who came up with the idea for this script, please see the THANKS file for more information. diff --git a/wie.php b/wie.php index c4dacaa..84dce4c 100755 --- a/wie.php +++ b/wie.php @@ -22,7 +22,7 @@ $defaultLang = "en"; // default language $progName = $argv[0]; function usage() { - print "Wikipedia ingress extractor (wie), version 0.1\n"; + print "Wikipedia ingress extractor (wie), version 0.2\n"; print "Usage: $GLOBALS[progName] [--lang=sv] article\n"; print "Default language if none specified is $GLOBALS[defaultLang].\n"; print "Remember to quote the article if there's more than one word,\n"; @@ -58,7 +58,14 @@ else $article = ucwords($article); // uppercase article $article = preg_replace("/\s/", "_" ,$article); // make spaces to underscore $url = "http://$lang.wikipedia.org/wiki/$article"; -$data = shell_exec("curl -s $url"); // retrive the page + +// get the wiki page +$ch = curl_init("$url"); +curl_setopt($ch, CURLOPT_HEADER, 0); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +$data = curl_exec($ch); +curl_close($ch); + preg_match("/\(.*)\<\/p\>/", $data, $match); // fetch text inside first

// check is we had a match