Ignore:
Timestamp:
03/21/10 11:14:13 (3 years ago)
Author:
nick_ramsay
Message:

[Branch 1.2] More work on system report formatting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.2/libs/Debug.php

    r1367 r1371  
    189189        $plugins = $h->db->get_results($h->db->prepare($sql)); 
    190190        if ($plugins) { 
    191 //            foreach ($plugins as $plugin) { 
    192 //                if (is_serialized($plugin->plugin_value)) { 
    193 //                    $plugin->plugin_value = unserialize($plugin->plugin_value); 
    194 //                    if (is_array($plugin->plugin_value)) { 
    195 //                        foreach ($plugin->plugin_value as $key => $value) { 
    196 //                            if (is_array($value)) { 
    197 //                                foreach ($value as $k => $v) { 
    198 //                                    if (is_array($v)) { 
    199 //                                        $v = serialize($v); 
    200 //                                        $plugin->plugin_value[$key][$k] = $this->aaa($v); 
    201 //                                    } else { 
    202 //                                        $plugin->plugin_value[$key][$k] = preg_replace("/[a-zA-Z0-9]/", "*", $v); 
    203 //                                    } 
    204 //                                } 
    205 //                            } else { 
    206 //                                $plugin->plugin_value[$key] = preg_replace("/[a-zA-Z0-9]/", "*", $value); 
    207 //                            } 
    208 //                        } 
    209 //                        $plugin->plugin_value = serialize($plugin->plugin_value); 
    210 //                    } 
    211 //                } else { 
    212 //                    $plugin->plugin_value = preg_replace("/[a-zA-Z0-9]/", "*", $plugin->plugin_value); 
    213 //                } 
    214 //                $report['hotaru_plugin_settings'][$plugin->plugin_folder][$plugin->plugin_setting] = $plugin->plugin_value; 
    215 //            } 
    216  
    217             print_r ($this->loop_through_array($h, $plugins)); 
    218              
     191            foreach ($plugins as $plugin) { 
     192                if (is_serialized($plugin->plugin_value)) { $plugin->plugin_value = unserialize($plugin->plugin_value); } 
     193                $report['hotaru_plugin_settings'][$plugin->plugin_folder][$plugin->plugin_setting] = $this->applyMaskToArrays($h, $plugin->plugin_value); 
     194            } 
    219195        } 
    220196         
     
    260236    } 
    261237 
    262      function loop_through_array ($h, $array, &$out = array () ) { 
    263         foreach ( (array) $array as $key => $value ) { 
    264             if ( ! is_array ( $value ) ) {                 
    265                 $value = serialize($value); 
    266                 array_push ( $out, preg_replace("/[a-zA-Z0-9]/", "*", $value) ); 
    267             } 
    268             else { 
    269                 $this->loop_through_array ( $value, &$out ); 
    270             } 
    271         } 
    272         return $out; 
     238 
     239    /** 
     240     * Recurse through arrays, applying * mask to all values, but not keys 
     241     * 
     242     * @param array $array 
     243     * @return array 
     244     */ 
     245     public function applyMaskToArrays($h, $array) 
     246     { 
     247        //echo "<pre>"; print_r($array); echo "</pre>"; exit; 
     248        if (!is_array($array) && !is_object($array)) { return false; } 
     249         
     250        foreach ($array as $key => $value) { 
     251            if (is_array($value) || is_object($value)) { 
     252                $array[$key] = $this->applyMaskToArrays($h, $value); 
     253            } else { 
     254                $array[$key] = preg_replace("/[a-zA-Z0-9]/", "*", $value); 
     255            } 
     256        } 
     257        return $array; 
    273258    } 
    274259 
     
    333318        $output .= "\n"; 
    334319 
    335         $output .= "Plugin Settings: \n\n"; 
     320        $output .= "Plugin Settings: \n"; 
    336321        if (isset($report['hotaru_plugin_settings'])) { 
    337322            foreach ($report['hotaru_plugin_settings'] as $key => $value) { 
    338323                foreach ($value as $k => $v) { 
    339                     if (!is_serialized($v)) { 
    340                         $output .= "Plugin settings for " . $key . ":\n" . $k . " = " . $v . " \n"; 
     324                    if (!is_array($v)) { 
     325                        $output .= "\nPlugin settings for " . $key . ":\n...." . $k . " = " . $v . " \n"; 
    341326                    } else { 
    342                         $output .= "Plugin settings for " . $key . ":\n"; 
    343                         $v = unserialize($v); 
    344                         foreach ($v as $y => $z) { 
    345                             $output .= "..... " . $y . ": " . $z . " \n"; 
    346                         } 
    347                         $output .= " \n"; 
     327                        $output .= "\nPlugin settings for " . $key . ":\n"; 
     328                        $output = $this->outputArrays($h, $v, $output); 
    348329                    } 
    349330                } 
     
    382363        return $output; 
    383364    } 
     365     
     366     
     367    /** 
     368     * Recurse through arrays, adding them to $output for display 
     369     * 
     370     * @param array $array 
     371     * @return array 
     372     */ 
     373     public function outputArrays($h, $array = array(), $output = '') 
     374     { 
     375        if (!is_array($array) && !is_object($array)) { return $output; } 
     376         
     377        foreach ($array as $key => $value) { 
     378            if (is_array($value) || is_object($array)) { 
     379                $output .= "..... " . $key . ":\n"; 
     380                $output = $this->outputArrays($h, $value, $output); 
     381            } else { 
     382                $output .= "..... " . $key . ": " . $value . " \n"; 
     383            } 
     384        } 
     385        return $output; 
     386    } 
    384387} 
    385388?> 
Note: See TracChangeset for help on using the changeset viewer.