From df90c7bf6e42f2b24720a9b58de96c79ee3b04a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Wed, 29 Apr 2020 13:51:54 +0200 Subject: added corinavitus counter --- main.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'main.php') diff --git a/main.php b/main.php index 4a6f1b4..d6c5649 100644 --- a/main.php +++ b/main.php @@ -137,7 +137,20 @@ Errors: $ch = $this->ch; if($flair == null) { $dnevi = array("drekek", "ponedeljek", "torek", "sreda", "cetrtek", "petek", "sobota", "nedelja"); - $flair = $dnevi[date("N")].", ".date("j.n.Y H:i:s"); + $wiki = file_get_contents("https://en.wikipedia.org/wiki/Template:2019%E2%80%9320_coronavirus_pandemic_data"); + $xmlDoc = new DOMDocument($wiki); + $xmlDoc->loadHTML( $wiki ); + $searchNode = $xmlDoc->getElementById( "thetable" )->getElementsByTagName("tr"); + foreach( $searchNode as $sn ) { + if (strpos(DOMinnerHTML($sn), 'Slovenia') !== false) { + $ok = trim(str_replace(",", "", DOMinnerHTML($sn->getElementsByTagName("td")[0]))); + $um = trim(str_replace(",", "", DOMinnerHTML($sn->getElementsByTagName("td")[1]))); + $oz = trim(str_replace(",", "", DOMinnerHTML($sn->getElementsByTagName("td")[2]))); + echo 'true'; + break; + } + } + $flair = $dnevi[date("N")].", ".date("j.n.Y H:i")." | okuž.: ".$ok." umr.: ".$um." ozd.: ".$oz; } if($magic == null) { if($post) { -- cgit v1.2.3