<?php
/**
*
* @author Benjamin Gillissen <hide@address.com>
*
* **************************************************************
Copyright (C) 2009 Benjamin Gillissen
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details at:
http://www.gnu.org/copyleft/gpl.html
* **************************************************************
*/
class rpconf_array {
public function __construct(){ }
public function isrpc($rid){ return is_array(configs::get('hellarpc', 'rpcs', $rid)); }
public function get_staTO($rid){ return $this->getconfarg($rid, 'staTO'); }
public function gethost($rid){ return $this->getconfarg($rid, 'host'); }
public function isactif($rid){ return $this->getconfarg($rid, 'actif'); }
public function getname($rid){ return $this->getconfarg($rid, 'rpc'); }
public function get_destrepo($rid){ return $this->getconfarg($rid, 'repo'); }
public function get_repobaseurl($rid){ return $this->getconfarg($rid, 'repobaseurl'); }
public function getpolicy($rid){ return $this->getconfarg($rid, 'cachepol'); }
public function getconninfo($rid){
$conninfo = Array('host', 'port', 'user', 'pass', "conTO");
foreach($conninfo as $k => &$info){ $o[$info] = $this->getconfarg($rid, $info); }
return $o;
}
private function getconfarg($rid, $arg){return configs::get('hellarpc', 'rpcs', Array($rid, $arg)); }
public function getfirst(){
$c = array_keys(configs::get('hellarpc', 'rpcs'));
return $c[0];
}
public function listall($start=NULL, $end=NULL){
$rpcs = configs::get('hellarpc', 'rpcs');
if ( $start === NULL OR $end === NULL ){
$start=0;
$end=count($rpcs);
}
$c=0;
foreach($rpcs as $RRef => &$conf){
if ( $c >= $start AND $c <= $end ){ $o[] = $RRef; }
$c++;
}
if ( isset($o) ){ return $o; }
return FALSE;
}
public function countall(){ return count(configs::get('hellarpc', 'rpcs')); }
}