This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/adsl/classes/service/traffic/adsl/exetelvisp.php
Deon George 130a87aa9a Major work to domain and hosting
Minor updates for ADSL services
Updates to Sort::MAsort()
Move core OSB items under application/
Moved ACCOUNT functions under application
Minor updates to task
2012-01-12 19:53:55 +11:00

69 lines
1.8 KiB
PHP

<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is able to collect traffic information for Exetel VISP
*
* @package OSB
* @subpackage Service
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Service_Traffic_ADSL_ExetelVisp extends Service_Traffic_ADSL {
private $login_user_field = 'username';
private $login_pass_field = 'password';
private $date_field = 'date';
protected function getdata($date) {
$return = array();
// Assume we have a bad fetch, unless otherwise specified.
$this->fetchresult = FALSE;
$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);
$request->get_client()->options($this->curlopts+array(
CURLOPT_POST => TRUE,
));
$response = $request->execute();
$data = $response->body();
$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;
}
}
?>