update requirements
authorStricted <info@stricted.de>
Sat, 8 Aug 2015 05:48:06 +0000 (07:48 +0200)
committerStricted <info@stricted.de>
Sat, 8 Aug 2015 05:48:06 +0000 (07:48 +0200)
README.md
SpeedportHybrid.class.php

index 597266647f16b32e7566aed8a1efdb868a884592..c5a0abd460665fd6bd82081074c1ee8b91017515 100644 (file)
--- 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
index f8d6a0d57c950ff5bc81e7dd54d2899bfb87003d..1ab62070aff1b37840f55773266c02cda9b10d54 100644 (file)
@@ -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.');
+               }
        }
        
        /**