Quelltext der Datei: http://www.michaelster.ch/jsTestFolder/array_map/ArrayMap.php

Dateigrösse: 4.71 kb

[Anzeige ohne Zeilennummern]


  1 <?php
  2 class ArrayMap{
  3         public static function anvroutine($aroutine,$vroutine,$array=null,&$reference=null)
  4         {
  5             if($reference) 
  6                 $array=&$reference;
  7             
  8             $c=count($array);
  9             
 10             if(!is_array($array)) 
 11                 return false;
 12             
 13             if(!is_string($aroutine)||!is_string($vroutine)) 
 14                 return false;
 15             
 16             $aroutine=str_replace('%key%','$k',str_replace('%placeholder%','$array[$k]',$aroutine));
 17             $vroutine=str_replace('%key%','$k',str_replace('%placeholder%','$array[$k]',$vroutine));
 18             
 19             reset($array);
 20             $i=0;
 21             while(list($k,$v)=each($array)){
 22                 if(is_array($array[$k]))
 23                 {
 24                     ob_start();
 25                     $debug=eval($aroutine);
 26 
 27                     if(ob_get_length()>1)
 28                         $msg=trim(strip_tags(ob_get_contents()));
 29                     ob_end_clean();
 30 
 31                     if(false===$debug){
 32                         ob_start();
 33                         debug_print_backtrace();
 34                         $called_at=ob_get_contents();
 35                         ob_end_clean();
 36                         $called_at=substr($called_at,strrpos($called_at,'called'));
 37                         
 38                         throw new 
 39                         Exception
 40                         (
 41                             PHP_EOL . substr($msg,0,strpos($msg,'eval')).
 42                             ' in your aroutine '.
 43                             substr($msg,strrpos($msg,'on')) .
 44                             PHP_EOL .
 45                             $called_at.
 46                             PHP_EOL
 47                         );
 48                     }
 49                     
 50                     if(!empty($msg)){
 51                         ob_start();
 52                         debug_print_backtrace();
 53                         $called_at=ob_get_contents();
 54                         ob_end_clean();
 55                         $called_at=substr($called_at,strrpos($called_at,'called at'));
 56                         trigger_error
 57                         (
 58                             PHP_EOL . substr($msg,0,strpos($msg,'eval')).
 59                             ' in your aroutine '.
 60                             substr($msg,strrpos($msg,'on')) .
 61                             PHP_EOL .
 62                             $called_at.
 63                             PHP_EOL,
 64                             E_USER_WARNING
 65                         );
 66                         
 67                     }
 68                         unset($debug,$msg);
 69                     if(is_array($array[$k]))
 70                     foreach($array[$k] as &$vl)
 71                     {
 72                         $array[]=&$vl;    
 73                     }
 74                     unset($vl);
 75                     unset($debug);
 76                     unset($msg);
 77                     unset($called_at);
 78                 }
 79                 
 80                 else
 81                 {
 82                     ob_start();
 83                     $debug=eval($vroutine);
 84                     if(ob_get_length()>1)
 85                         $msg=trim(strip_tags(ob_get_contents()));
 86                     ob_end_clean();
 87 
 88                     if(false===$debug){
 89                         ob_start();
 90                         debug_print_backtrace();
 91                         $called_at=ob_get_contents();
 92                         ob_end_clean();
 93                         $called_at=substr($called_at,strrpos($called_at,'called at'));
 94                         throw new 
 95                         Exception
 96                         (
 97                             PHP_EOL . substr($msg,0,strpos($msg,'eval')).
 98                             ' in your vroutine '.
 99                             substr($msg,strrpos($msg,'on')) .
100                             PHP_EOL .
101                             $called_at.
102                             PHP_EOL
103                         );
104                     }
105                     if(!empty($msg)){
106                         ob_start();
107                         debug_print_backtrace();
108                         $called_at=ob_get_contents();
109                         ob_end_clean();
110                         $called_at=substr($called_at,strrpos($called_at,'called at'));
111                         trigger_error
112                         (
113                             PHP_EOL . substr($msg,0,strpos($msg,'eval')).
114                             ' in your vroutine '.
115                             substr($msg,strrpos($msg,'on')) .
116                             PHP_EOL .
117                             $called_at.
118                             PHP_EOL,
119                             E_USER_WARNING
120                         );
121                     }
122                     unset($debug);
123                     unset($msg);
124                     unset($called_at);
125                     
126                 }
127                 if($i>=$c) 
128                     unset($array[$k]);
129                 $i++;
130             }
131 
132             return $array;
133         }
134         
135         public static function aroutine($vroutine,$array=null,&$reference=null)
136         {
137             if($reference) 
138                 $array=&$reference;
139             
140             
141             if(!is_array($array)) 
142                 return false;
143             
144             if(!is_string($vroutine)) 
145                 return false;
146             
147             $vroutine=str_replace('%key%','$k',str_replace('%placeholder%','$array[$k]',$vroutine));
148             
149             reset($array);
150 
151             while(list($k,$v)=each($array)){
152                 
153                     ob_start();
154                     $debug=eval($vroutine);
155                     if(ob_get_length()>1)
156                         $msg=trim(strip_tags(ob_get_contents()));
157                     ob_end_clean();
158                     
159                     if(false===$debug){
160                         ob_start();
161                         debug_print_backtrace();
162                         $called_at=ob_get_contents();
163                         ob_end_clean();
164                         $called_at=substr($called_at,strrpos($called_at,'called at'));
165                         throw new 
166                         Exception
167                         (
168                             PHP_EOL . substr($msg,0,strpos($msg,'eval')).
169                             ' in your vroutine '.
170                             substr($msg,strrpos($msg,'on')) .
171                             PHP_EOL .
172                             $called_at.
173                             PHP_EOL
174                         );
175                     }
176                     if(!empty($msg)){
177                         ob_start();
178                         debug_print_backtrace();
179                         $called_at=ob_get_contents();
180                         ob_end_clean();
181                         $called_at=substr($called_at,strrpos($called_at,'called at'));
182                         trigger_error
183                         (
184                             PHP_EOL . substr($msg,0,strpos($msg,'eval')).
185                             ' in your vroutine '.
186                             substr($msg,strrpos($msg,'on')) .
187                             PHP_EOL .
188                             $called_at.
189                             PHP_EOL,
190                             E_USER_WARNING
191                         );
192                     }
193                     unset($debug,$msg,$called_at);
194             
195             }
196 
197             return $array;
198         }
199 
200 
201 }
202 ?>