2010-11-29 22:41:08 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class is able to collect traffic information for Exetel VISP
|
|
|
|
*
|
2013-03-19 22:35:19 +00:00
|
|
|
* @package ADSL
|
|
|
|
* @category Service
|
2010-11-29 22:41:08 +00:00
|
|
|
* @author Deon George
|
2013-03-19 22:35:19 +00:00
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
2010-11-29 22:41:08 +00:00
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
2013-01-11 10:51:37 +00:00
|
|
|
class Service_Traffic_Adsl_Exetelvisp extends Service_Traffic_Adsl {
|
2010-11-29 22:41:08 +00:00
|
|
|
private $login_user_field = 'username';
|
|
|
|
private $login_pass_field = 'password';
|
|
|
|
private $date_field = 'date';
|
|
|
|
|
|
|
|
protected function getdata($date) {
|
2011-08-03 14:24:38 +00:00
|
|
|
$return = array();
|
|
|
|
|
2010-11-29 22:41:08 +00:00
|
|
|
// Assume we have a bad fetch, unless otherwise specified.
|
|
|
|
$this->fetchresult = FALSE;
|
|
|
|
|
2011-08-03 14:24:38 +00:00
|
|
|
$request = Request::factory($this->so->stats_url)
|
|
|
|
->method('POST')
|
|
|
|
->post($this->login_user_field,$this->so->stats_username)
|
|
|
|
->post($this->login_pass_field,$this->so->stats_password)
|
|
|
|
->post($this->date_field,$date);
|
2010-11-29 22:41:08 +00:00
|
|
|
|
2012-11-09 23:13:57 +00:00
|
|
|
$request->client()->options($this->curlopts+array(
|
2010-11-29 22:41:08 +00:00
|
|
|
CURLOPT_POST => TRUE,
|
2011-09-28 06:46:22 +00:00
|
|
|
));
|
2011-08-03 14:24:38 +00:00
|
|
|
|
|
|
|
$response = $request->execute();
|
|
|
|
$data = $response->body();
|
2010-11-29 22:41:08 +00:00
|
|
|
|
|
|
|
$resultarray = explode("\n",$data);
|
|
|
|
|
|
|
|
// The first field should be a header, so we can ignore it:
|
|
|
|
if (preg_match('/^Login/',$resultarray[0])) {
|
|
|
|
array_shift($resultarray);
|
|
|
|
$this->fetchresult = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we got the expected data, we can parse it.
|
|
|
|
if ($this->fetchresult)
|
|
|
|
foreach ($resultarray as $details) {
|
|
|
|
if (! trim($details))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
$valuesarray = explode(',',$details);
|
|
|
|
|
|
|
|
// Extel VISP stores data in MB's*100.
|
|
|
|
$attrs = array();
|
|
|
|
$attrs['service'] = $valuesarray[0];
|
|
|
|
$attrs['date'] = $valuesarray[1];
|
|
|
|
$attrs['up_peak'] = $valuesarray[2]/100;
|
|
|
|
$attrs['down_peak'] = $valuesarray[3]/100;
|
|
|
|
$attrs['up_offpeak'] = $valuesarray[4]/100;
|
|
|
|
$attrs['down_offpeak'] = $valuesarray[5]/100;
|
|
|
|
|
|
|
|
array_push($return,$attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|