diff --git a/includes/config.inc.php b/includes/config.inc.php index da5de1b..1e67e23 100644 --- a/includes/config.inc.php +++ b/includes/config.inc.php @@ -14,6 +14,8 @@ $debug=False; // SMS Gateway $smsgw_url="http://192.168.8.28:8080"; $smsgw_ssl_verify=true; +$smsgw_ws_connect_timeout=5; +$smsgw_ws_timeout=5; // Database diff --git a/includes/core.php b/includes/core.php index c89ae45..c0ef413 100644 --- a/includes/core.php +++ b/includes/core.php @@ -17,6 +17,6 @@ require_once('logging.php'); require_once('functions.php'); require_once('sms_gw_api.php'); -$smsgw = new sms_gw_api($smsgw_url, $smsgw_ssl_verify); +$smsgw = new sms_gw_api($smsgw_url, $smsgw_ssl_verify, $smsgw_ws_connect_timeout, $smsgw_ws_timeout); require('db.php'); diff --git a/includes/sms_gw_api.php b/includes/sms_gw_api.php index 9e56bb2..420e99d 100644 --- a/includes/sms_gw_api.php +++ b/includes/sms_gw_api.php @@ -6,9 +6,14 @@ Class sms_gw_api { private $ws_url = null; private $ws_ssl_verify = true; - function sms_gw_api($ws_url, $ws_ssl_verify=true){ + private $ws_connect_timeout = 5; + private $ws_timeout = 10; + + function sms_gw_api($ws_url, $ws_ssl_verify = true, $ws_connect_timeout = 5, $ws_timeout = 10){ $this -> ws_url = $ws_url; $this -> ws_ssl_verify = $ws_ssl_verify; + $this -> ws_connect_timeout = $ws_connect_timeout; + $this -> ws_timeout = $ws_timeout; } /* @@ -45,6 +50,10 @@ Class sms_gw_api { curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1); } + // Set timeouts + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $this -> ws_connect_timeout); + curl_setopt($curl, CURLOPT_TIMEOUT, $this -> ws_timeout); + $complete_url=$this -> ws_url.'/'.$url; curl_setopt($curl, CURLOPT_URL, $complete_url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);