php - Need some guidance regarding a licensing script (BoxBilling) -
i'm pretty new boxbilling licensing , fair, not providing support!
i have code check license working correctly however, if license invalid, shows word "array" , if valid, shows nothing @ all.
i need know how can set different message rather "array" if license invalid , how can kill page (via die() or similar).
thanks in advance guys!
<?php include("config.php"); include("opendb.php"); function getlicensedetails($key) { $systeminfo = mysql_query("select * `systeminfo`"); $systeminfo = mysql_fetch_array($systeminfo); $url = 'http://clients.pbtechsupport.com/index.php/api/guest/servicelicense/check'; $params = array(); $params['license'] = $systeminfo[licensekey]; $params['host'] = 'localhost'; $params['path'] = dirname(__file__); $params['version'] = '1.0'; $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_verbose, 0); curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_ssl_verifyhost, false); curl_setopt($ch, curlopt_returntransfer,1); curl_setopt($ch, curlopt_connecttimeout, 20); curl_setopt($ch, curlopt_timeout, 20); curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_postfields, json_encode($params)); $result = curl_exec($ch); $code = curl_getinfo($ch, curlinfo_http_code); if($code != 200) { error_log('curlinfo_http_code: '.$code); } return json_decode($result, true); } $json = getlicensedetails('test'); if(!$json['valid']) { print $json['error']; } include("closedb.php"); ?>
print_r($json['error'])
see what's in array, use contents output more intelligent based on that. presumably returning information particular error encountered in json.
based on comment, doing print $json['error']['message'];
display error encountered. if($json['error']['code'] == 1006) { print 'your own custom error license here.'; }
if you'd prefer not use own text.
Comments
Post a Comment