fetchresult = FALSE; $result = array(); $url_suffix = sprintf('traffic_V34_%s.xml',date('Ymd',strtotime($date))); try { $data = Remote::get($this->so->stats_url.$url_suffix,$this->curlopts+array( CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => sprintf('%s:%s',$this->so->stats_username,$this->so->stats_password), )); } catch (Exception $e) { return; } $this->fetchresult = TRUE; foreach (XML::factory(NULL,NULL,$data)->get('user') as $user) { $attrs = array(); $userattrs = $user->attributes(); $attrs['service'] = $userattrs['username']; $attrs['date'] = $date; foreach ($user->year->month->day->get('hour') as $hour => $traffic) { foreach (array('external'=>'down_peak','internal'=>'internal','peering'=>'peer') as $t => $k) { $tatters = $traffic->$t->attributes(); // Traffic is in bytes, need to convert to MB if (empty($attrs[$k])) $attrs[$k] = $tatters['bytes']/1000/1000; else $attrs[$k] += $tatters['bytes']/1000/1000; } } array_push($result,$attrs); } return $result; } } ?>