inside owphp:
getting value:
if ($parse_php_type && $get_type!=OWNET_MSG_DIR_ALL){
$tmp =explode('/',$path);$c=count($tmp)-1;
if ($c>0){ // must be something like '/dir/file' array('dir', 'file'),
count()-1 = 1 > 0
$variavel =$tmp[$c]; // get last two uri args
$ow =$tmp[$c-1];
unset($tmp);
if (preg_match('/([0-9A-F]{2})[\.]{0,1}[0-9A-F]{12}/',$ow,$tmp)){ // check
if ow is an OW id ("XX.ZZZZZZZZZZZZ or XXZZZZZZZZZZZZ")
$tmp=$tmp[1];
if (!isset($OWNET_GLOBAL_CACHE_STRUCTURE[$tmp.'/'.$variavel])){ // check if
we have structure information
$tmp_v=@$this->get("/structure/$tmp/$variavel",OWNET_MSG_READ,false,false); //
get estrutucture information
if ($tmp_v!==NULL){
$tmp_v=explode(',',$tmp_v); // ok :D we will get real php values now!
$OWNET_GLOBAL_CACHE_STRUCTURE[$tmp.'/'.$variavel]=$tmp_v;
$type=$tmp_v;
}
}else
$type=$OWNET_GLOBAL_CACHE_STRUCTURE[$tmp.'/'.$variavel];
}
}
unset($tmp,$tmp_v,$variavel,$ow,$c);
}
'casting' value:
if ($type!==false){
// get real php values
$ret['data_php']=$ret['data'];
if($type[0]=='i'){
$ret['data_php']=bcadd($ret['data_php'],0,0); // integer (using bcmath for
bigger precision)
}elseif($type[0]=='u'){
$ret['data_php']=bcadd($ret['data_php'],0,0); // unsigned integer (using
bcmath for bigger precision)
if (bccmp($ret['data_php'],0,0)==-1){
$ret['data_php']=substr($ret['data_php'],1); // be shure that it's unsigned
}
}elseif(in_array($type[0],array('f','t',chr(152)))){
$ret['data_php']=(double)$ret['data_php']; // using float (double) values,
maybe sprinf("%.50f",$value) could get an string representation
if ($return_full_info_array){
if ($type[0]=='t'){ // temperature (last owserver versions... maybe an 'v'
for volts and 'A' for amps could be implemented)
// we can't cache cause server may restart or change configurations while
we have old cache information, here we will have +- .1 seconds of
performace lost, set return full information off if you don't want it
$tmp_v=@$this->get("/settings/units/temperature_scale",OWNET_MSG_READ,false,false);
//
get server current scale
if ($tmp_v!==NULL) // just for compatible with old owservers
$ret['unit']=$tmp_v; // use unit if return full information
}
}
}elseif(in_array($type[0],array('a','b','d'))){
$ret['data_php']=(string)$ret['data_php']; // string (maybe without it
could work too, but's it's pretty :D )
}elseif($type[0]=='y'){
$ret['data_php']=($ret['data_php']==1?true:false); // boolean content
} // another contents are parsed as string too
}else{
$ret['data_php']=&$ret['data']; // we will use not parsed values (we use it
when getting structure information! or setting $parse_php_type=false)
}
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers