From 0d814efc43f845a49e3dfd6357991242dfb48b6f Mon Sep 17 00:00:00 2001 From: Stricted Date: Sat, 8 Aug 2015 07:48:06 +0200 Subject: [PATCH] update requirements --- README.md | 5 +++++ SpeedportHybrid.class.php | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) 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.'); + } } /** -- 2.20.1