From: Stricted Date: Sat, 8 Aug 2015 05:48:06 +0000 (+0200) Subject: update requirements X-Git-Tag: 1.0.5~6 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0d814efc43f845a49e3dfd6357991242dfb48b6f;p=GitHub%2FStricted%2Fspeedport-hybrid-php-api.git update requirements --- diff --git a/README.md b/README.md index 5972666..c5a0abd 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,11 @@ known endpoints for getData() and sentRequest(): PHP requirements ============= * PHP >= 5.4.0 + * PHP extension `hash` + * PHP extension `curl` + * PHP extension `json` + * PHP extension `pcre` + * PHP extension `ctype` * PHP extension `rrd` (optional, for rrd graphs) rrdtool integration diff --git a/SpeedportHybrid.class.php b/SpeedportHybrid.class.php index f8d6a0d..1ab6207 100644 --- a/SpeedportHybrid.class.php +++ b/SpeedportHybrid.class.php @@ -43,6 +43,31 @@ class SpeedportHybrid { */ public function __construct ($url = 'http://speedport.ip/') { $this->url = $url; + $this->checkRequirements(); + } + + /** + * check php requirements + */ + private function checkRequirements () { + if (!extension_loaded('curl')) { + throw new Exception("The PHP Extension 'curl' is missing."); + } + else if (!extension_loaded('json')) { + throw new Exception("The PHP Extension 'json' is missing."); + } + else if (!extension_loaded('pcre')) { + throw new Exception("The PHP Extension 'pcre' is missing."); + } + else if (!extension_loaded('ctype')) { + throw new Exception("The PHP Extension 'ctype' is missing."); + } + else if (!extension_loaded('hash')) { + throw new Exception("The PHP Extension 'hash' is missing."); + } + else if (!in_array('sha256', hash_algos())) { + throw new Exception('SHA-256 algorithm is not Supported.'); + } } /**