Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class EstimateIt{
- function rate(){
- // ....
- if($rate===false){
- $this->log("Log Description",$data,array('response','request'));//no ampersand/live link to variable
- $this->log_xml("response",$data->response);//LOGS **OMITTED**
- $this->log_xml("request",$data->request);//LOGS **OMITTED**
- }
- // ....
- }
- function log($desc,$dataIn,$badkeys=array()){//no ampersand/live link to variable
- $_str =$desc."\n\n";
- $_str.=log_clean($dataIn,$badkeys);//no ampersand/live link to variable
- file_put_contents(session_id().'__'.date('Ymd_His').'.txt', $_str);
- }
- function log_xml($filename,$xml_str){
- file_put_contents($filename.'.xml',$xml_str);
- }
- }
- function log_clean(&$obj, $exclude_keys, $omit_str='**OMMITTED**'){//DOES NOT WORK CORRECTLY
- $_type=gettype($obj);
- if($_type!='object' && $_type!='array'){return false;}
- if(array_check($exclude_keys)){
- foreach($obj as $k => $v){
- if(@in_array($k,$exclude_keys,true)){
- if($_type=='object'){
- if(!basic_check($omit_str)){unset($obj->$k);}
- else{$obj->$k=$omit_str;}
- }else if($_type=='array'){
- if(!basic_check($omit_str)){unset($obj[$k]);}
- else{$obj[$k]=$omit_str;}
- }
- }else{
- if(gettype($v)=='object' && ($v instanceof Traversable)){//
- log_clean($obj->$k,$exclude_keys,$omit_str);}
- else if(gettype($v)=='array'){
- log_clean($obj[$k],$exclude_keys,$omit_str);}
- }
- }
- }
- }
- // ======= THE FIX! ======= \\
- function log_clean(&$obj, $exclude_keys, $omit_str='**OMMITTED**'){//WORKS CORRECTLY
- $_type=gettype($obj);
- if($_type!='object' && $_type!='array'){return false;}
- if(array_check($exclude_keys)){
- foreach($obj as $k => $v){
- if(@in_array($k,$exclude_keys,true)){
- if($_type=='object'){
- if(!basic_check($omit_str)){unset($v);}
- else{$v=$omit_str;}
- }else if($_type=='array'){
- if(!basic_check($omit_str)){unset($v);}
- else{$v=$omit_str;}
- }
- }else{
- if(gettype($v)=='object' && ($v instanceof Traversable)){//
- log_clean($v,$exclude_keys,$omit_str);}
- else if(gettype($v)=='array'){
- log_clean($v,$exclude_keys,$omit_str);}
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement