diff --git a/application/classes/ormosb.php b/application/classes/ormosb.php index cd282b62..ba189453 100644 --- a/application/classes/ormosb.php +++ b/application/classes/ormosb.php @@ -19,7 +19,6 @@ abstract class ORMOSB extends ORM { protected $_created_column = array('column'=>'date_orig','format'=>TRUE); protected $_updated_column = array('column'=>'date_last','format'=>TRUE); - // @todo Rules are no longer used? public function rules() { return array( 'id'=>array( diff --git a/modules/service/classes/model/service/adsl.php b/modules/service/classes/model/service/adsl.php index d1b0e274..11b38de8 100644 --- a/modules/service/classes/model/service/adsl.php +++ b/modules/service/classes/model/service/adsl.php @@ -24,7 +24,6 @@ class Model_Service_ADSL extends Model_Service { 'service_connect_date'=>array( array('Config::date',array(':value')), ), - ); /** diff --git a/modules/service/classes/model/service/adsl/traffic.php b/modules/service/classes/model/service/adsl/traffic.php index 1ba0f8bb..9062208c 100644 --- a/modules/service/classes/model/service/adsl/traffic.php +++ b/modules/service/classes/model/service/adsl/traffic.php @@ -13,11 +13,16 @@ class Model_Service_ADSL_Traffic extends ORMOSB { protected $_table_name = 'service__adsl_traffic'; protected $_primary_key = 'service'; - protected $_callbacks = array( - 'site_id'=>array('set_site_id'), - ); protected $_created_column = FALSE; protected $_updated_column = FALSE; + + public function rules() { + return array( + 'site_id'=>array( + array('ORMOSB::set_site_id',array(':validation',':model',':field')), + ), + ); + } } ?> diff --git a/modules/service/classes/service/traffic/adsl.php b/modules/service/classes/service/traffic/adsl.php index 9a709d51..f4532897 100644 --- a/modules/service/classes/service/traffic/adsl.php +++ b/modules/service/classes/service/traffic/adsl.php @@ -89,7 +89,7 @@ class Service_Traffic_ADSL { $traffic = ORM::factory('service_adsl_traffic'); foreach ($data as $item) { - $traffic->values($item); + $traffic->values($item,array_keys($item)); $traffic->supplier_id = $this->so->id; if ($traffic->check()) diff --git a/modules/service/classes/service/traffic/adsl/exetelhspa.php b/modules/service/classes/service/traffic/adsl/exetelhspa.php index e2a3bc12..b478229e 100644 --- a/modules/service/classes/service/traffic/adsl/exetelhspa.php +++ b/modules/service/classes/service/traffic/adsl/exetelhspa.php @@ -33,25 +33,27 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL { if (! empty(Service_Traffic_ADSL_ExetelHSPA::$return[$date])) return Service_Traffic_ADSL_ExetelHSPA::$return[$date]; + include_once 'includes/kohana/modules/simplehtmldom/classes/simple_html_dom.php'; + // Find our services that need to be collected this way. $update = array(); + foreach ($this->so->services() as $so) { if ($so->service_adsl->service_stats_collect AND $so->service_adsl->service_stats_lastupdate < $date) { - $postfields = http_build_query(array( - $this->login_user_field=>$so->service_adsl->service_username, - $this->login_pass_field=>$so->service_adsl->service_password, - 'doLogin'=>1, - 'submit'=>'Login', - )); - // Start Session - Remote::clear(); - $data = Remote::get($this->so->stats_url, - $this->curlopts+array( - CURLOPT_POSTFIELDS=>$postfields, - CURLOPT_COOKIEJAR=>sprintf('/tmp/usage.cookies.%s.txt',$so->service_adsl->service_number), - ), - TRUE); + $request = Request::factory($this->so->stats_url) + ->method('POST') + ->post($this->login_user_field,$so->service_adsl->service_username) + ->post($this->login_pass_field,$so->service_adsl->service_password) + ->post('doLogin',1) + ->post('submit','Login'); + + $request->get_client()->options($this->curlopts+array( + CURLOPT_COOKIEJAR=>sprintf('/tmp/usage.cookies.%s.txt',$so->service_adsl->service_number), + )); + + $response = $request->execute(); + $data = $response->body(); if (! $data) { // @todo Log into a log file @@ -62,8 +64,6 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL { continue; } - include_once 'includes/kohana/modules/simplehtmldom/classes/simple_html_dom.php'; - for ($servicedate=date('Y-m-d',strtotime($this->so->stats_lastupdate.'+1 day')); $servicedate <= $this->today; $servicedate=date('Y-m-d',strtotime('+1 month',strtotime(date('Y-m',strtotime($servicedate)).'-01')))) { @@ -72,21 +72,26 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL { if (strtotime($lastday) > time()) $lastday = date('Y-m-d',strtotime('yesterday')); - $postfields = http_build_query(array( - 'year_search_key'=>date('Y',strtotime($servicedate)), - 'month_search_key'=>date('m',strtotime($servicedate)), - 'start_day_search_key'=>date('d',strtotime($servicedate)), - 'end_day_search_key'=>date('d',strtotime($lastday)), - 'do_usage_search'=>1, - )); - $html = new simple_html_dom(); $notdebug = TRUE; if ($notdebug) { - $result = Remote::get($this->so->stats_url.'usage_customize_query.php',$this->curlopts+array(CURLOPT_POSTFIELDS=>$postfields),TRUE); + $request = Request::factory($this->so->stats_url.'usage_customize_query.php') + ->method('POST') + ->post('year_search_key',date('Y',strtotime($servicedate))) + ->post('month_search_key',date('m',strtotime($servicedate))) + ->post('start_day_search_key',date('d',strtotime($servicedate))) + ->post('end_day_search_key',date('d',strtotime($lastday))) + ->post('do_usage_search',1); + + $request->get_client()->options($this->curlopts+array( + CURLOPT_COOKIEFILE=>sprintf('/tmp/usage.cookies.%s.txt',$so->service_adsl->service_number), + )); + + $response = $request->execute(); + $result = $response->body(); $html->load($result); - $html->save(sprintf('/afs/local/tmp/usage.%s.%s.html',$so->service_adsl->service_number,$servicedate)); + #$html->save(sprintf('/afs/local/tmp/usage.%s.%s.html',$so->service_adsl->service_number,$servicedate)); } else { $html->load_file(sprintf('/tmp/usage.%s.%s.txt',$so->service_adsl->service_number,$servicedate)); } diff --git a/modules/service/classes/service/traffic/adsl/exetelvisp.php b/modules/service/classes/service/traffic/adsl/exetelvisp.php index e3f602c8..b2071582 100644 --- a/modules/service/classes/service/traffic/adsl/exetelvisp.php +++ b/modules/service/classes/service/traffic/adsl/exetelvisp.php @@ -16,20 +16,23 @@ class Service_Traffic_ADSL_ExetelVisp extends Service_Traffic_ADSL { private $date_field = 'date'; protected function getdata($date) { + $return = array(); + // Assume we have a bad fetch, unless otherwise specified. $this->fetchresult = FALSE; - $return = array(); + $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); - $data = Remote::get($this->so->stats_url,$this->curlopts+array( + $request->get_client()->options($this->curlopts+array( CURLOPT_POST => TRUE, - CURLOPT_POSTFIELDS => http_build_query(array( - $this->login_user_field=>$this->so->stats_username, - $this->login_pass_field=>$this->so->stats_password, - $this->date_field=>$date, - ) - )) - ); + )); + + $response = $request->execute(); + $data = $response->body(); $resultarray = explode("\n",$data); diff --git a/themes/default/template.tpl b/themes/default/template.tpl index 69a31641..e33ea8ab 100644 --- a/themes/default/template.tpl +++ b/themes/default/template.tpl @@ -51,7 +51,8 @@ | {t}Logout{/t} {else} - | {t}Login{/t} + | {t}User Login{/t} + | {t}Admin Login{/t} | {t}Register{/t} {if $smarty.const.SHOW_CHECKOUT_LINK}| {t}Checkout{/t}{/if} {/if} @@ -78,7 +79,6 @@ {elseif $smarty.const.DEFAULT_PAGE != ''} {$block->display($smarty.const.DEFAULT_PAGE)} {else} - {$block->display('account:user_login')} {/if}