a.binder 8 anos atrás
pai
commit
cbe2449d93
1 arquivos alterados com 167 adições e 166 exclusões
  1. 167 166
      SE/dev/audit_krs_con_digger/audit_krs_con_digger.php

+ 167 - 166
SE/dev/audit_krs_con_digger/audit_krs_con_digger.php

@@ -107,179 +107,180 @@ function dig_next($hist_loop,$prev_tbl,$prev_dig,$loop,$hist_time) {
 	 global $db,$tables;
 	 $loop++;
 	 echo "\n<hr>###LOOP ".$loop;
-	 if($loop>20) die(' loop '.$loop);
-	//detect next ref tbls
-	 $sql = array();
-	 $sql_RELAND = array();
-	 foreach($tables['Z'] as $Z=>$z) {
-		 	//rels in tbls
-		 	foreach($z['rel'] as $z_rel_from=>$z_rel_to) {
-		 	//	echo "110 test z_rel_fr ".$z_rel_from." to z_rel_to ".$z_rel_to ;
-		 		if( isset($prev_tbl['rel'][$z_rel_from])) {
-			 		if( strlen($prev_dig->$prev_tbl['rel'][$z_rel_from]) > 1  ) {
-				 		$sql[$Z]['rel'][$z_rel_to]= $prev_dig->$prev_tbl['rel'][$z_rel_from];
-			 		}
-		 		}
-		 	}
-		 	//search addr
-		 	if(isset($z['rel_and'])) {
-			 	foreach($z['rel_and'] as $z_rel_and=>$z_rel_and_name) {
-				 	$rel_and_ok=1;
-
-				 	foreach($z_rel_and_name as $z_rel_and_name_cur=>$z_rel_and_name_col_to) {
-					 	if(isset($prev_dig->$z_rel_and_name_cur) and strlen($prev_dig->$z_rel_and_name_cur) > 2) {
-						 	$rel_and_ok=2;
-						// 	echo "<br>121 rel_and OK for tbl ".$Z." z_rel_and_name_col_to: ".$z_rel_and_name_col_to." value:".$prev_dig->$z_rel_and_name_cur." rel_and_ok=".$rel_and_ok;
-						}
-					 	else {
-					//	 	echo "<br> #127 UNSET ".$prev_dig->$z_rel_and_name_cur." / ".$z_rel_and_name_col_to." ";
+	 if($loop<20) {
+			//detect next ref tbls
+			 $sql = array();
+			 $sql_RELAND = array();
+			 foreach($tables['Z'] as $Z=>$z) {
+				 	//rels in tbls
+				 	foreach($z['rel'] as $z_rel_from=>$z_rel_to) {
+				 	//	echo "110 test z_rel_fr ".$z_rel_from." to z_rel_to ".$z_rel_to ;
+				 		if( isset($prev_tbl['rel'][$z_rel_from])) {
+					 		if( strlen($prev_dig->$prev_tbl['rel'][$z_rel_from]) > 1  ) {
+						 		$sql[$Z]['rel'][$z_rel_to]= $prev_dig->$prev_tbl['rel'][$z_rel_from];
+					 		}
+				 		}
+				 	}
+				 	//search addr
+				 	if(isset($z['rel_and'])) {
+					 	foreach($z['rel_and'] as $z_rel_and=>$z_rel_and_name) {
 						 	$rel_and_ok=1;
+		
+						 	foreach($z_rel_and_name as $z_rel_and_name_cur=>$z_rel_and_name_col_to) {
+							 	if(isset($prev_dig->$z_rel_and_name_cur) and strlen($prev_dig->$z_rel_and_name_cur) > 2) {
+								 	$rel_and_ok=2;
+								// 	echo "<br>121 rel_and OK for tbl ".$Z." z_rel_and_name_col_to: ".$z_rel_and_name_col_to." value:".$prev_dig->$z_rel_and_name_cur." rel_and_ok=".$rel_and_ok;
+								}
+							 	else {
+							//	 	echo "<br> #127 UNSET ".$prev_dig->$z_rel_and_name_cur." / ".$z_rel_and_name_col_to." ";
+								 	$rel_and_ok=1;
+								 	}
 						 	}
+						  
+						  if($rel_and_ok==2) {
+							  //echo "<br>#133 Z=".$Z."/z=".$z." ok rel_and_ok=".$rel_and_ok;
+							  foreach($z_rel_and_name as $z_rel_and_name_cur=>$z_rel_and_name_col_to) {
+							//	  echo "<br> 135... ok. Z=".$Z."/ z_rel_and_name=".$z_rel_and_name_cur."/ z_rel_and_name_col_to=".$z_rel_and_name_col_to."/ prev_dig-z_rel_and_name_cur=".$prev_dig->$z_rel_and_name_cur;
+							  	$sql_rel_and[$Z][$z_rel_and][$z_rel_and_name_col_to]=$prev_dig->$z_rel_and_name_cur;
+		
+							  }
+						  } else {
+							//  echo "<br>#137 error rel_and_ok=".$rel_and_ok;
+						  }
+					 	}
+					 	
 				 	}
-				  
-				  if($rel_and_ok==2) {
-					  //echo "<br>#133 Z=".$Z."/z=".$z." ok rel_and_ok=".$rel_and_ok;
-					  foreach($z_rel_and_name as $z_rel_and_name_cur=>$z_rel_and_name_col_to) {
-					//	  echo "<br> 135... ok. Z=".$Z."/ z_rel_and_name=".$z_rel_and_name_cur."/ z_rel_and_name_col_to=".$z_rel_and_name_col_to."/ prev_dig-z_rel_and_name_cur=".$prev_dig->$z_rel_and_name_cur;
-					  	$sql_rel_and[$Z][$z_rel_and][$z_rel_and_name_col_to]=$prev_dig->$z_rel_and_name_cur;
-
-					  }
-				  } else {
-					//  echo "<br>#137 error rel_and_ok=".$rel_and_ok;
-				  }
-			 	}
-			 	
-		 	}
-	 }
-	 
-	 
-	// echo "<br>135:sql_rel_and <pre>";
-	//		 	print_r($sql_rel_and);
-	//		 	echo " .EOF</pre>";
-	if( isset($sql_rel_and)) {
-	foreach($sql_rel_and as $T=>$z_rel_and_arr) {
-		foreach($z_rel_and_arr as $z_rel_and_name=>$z_rel_and_name_col) {
-			//echo "<br>156 z_rel_and_name=".$z_rel_and_name." ";
-			$sql_rel_and_sql[$T][$z_rel_and_name]="select * from ".$T." where ( ";
-			$and=0;
-			foreach($z_rel_and_name_col as $z_rel_and_name_cur=>$z_rel_and_name_col_to) {
-				if( $and==1) $sql_rel_and_sql[$T][$z_rel_and_name].=" and SOUNDEX(`".$z_rel_and_name_cur."`) = SOUNDEX('.".$z_rel_and_name_col_to."') and `".$z_rel_and_name_cur."` not like '%--%' " ;
-				else $sql_rel_and_sql[$T][$z_rel_and_name].="  SOUNDEX(`".$z_rel_and_name_cur."`) = SOUNDEX('".$z_rel_and_name_col_to."') and `".$z_rel_and_name_cur."` not like '%--%' " ;
-				$and=1;
+			 }
+			 
+			 
+			// echo "<br>135:sql_rel_and <pre>";
+			//		 	print_r($sql_rel_and);
+			//		 	echo " .EOF</pre>";
+			if( isset($sql_rel_and)) {
+			foreach($sql_rel_and as $T=>$z_rel_and_arr) {
+				foreach($z_rel_and_arr as $z_rel_and_name=>$z_rel_and_name_col) {
+					//echo "<br>156 z_rel_and_name=".$z_rel_and_name." ";
+					$sql_rel_and_sql[$T][$z_rel_and_name]="select * from ".$T." where ( ";
+					$and=0;
+					foreach($z_rel_and_name_col as $z_rel_and_name_cur=>$z_rel_and_name_col_to) {
+						if( $and==1) $sql_rel_and_sql[$T][$z_rel_and_name].=" and SOUNDEX(`".$z_rel_and_name_cur."`) = SOUNDEX('.".$z_rel_and_name_col_to."') and `".$z_rel_and_name_cur."` not like '%--%' " ;
+						else $sql_rel_and_sql[$T][$z_rel_and_name].="  SOUNDEX(`".$z_rel_and_name_cur."`) = SOUNDEX('".$z_rel_and_name_col_to."') and `".$z_rel_and_name_cur."` not like '%--%' " ;
+						$and=1;
+					}
+					$sql_rel_and_sql[$T][$z_rel_and_name].="  ) " ;
+					if( isset($hist_loop[$T])) {
+					 	 foreach($hist_loop[$T] as $hist_rec) {
+						 	 $sql_rel_and_sql[$T][$z_rel_and_name].=" and ID!='".$hist_rec->ID."' ";
+					 	 }
+				 	 }
+					$sql_rel_and_sql[$T][$z_rel_and_name].=" ; " ;
+				 	 dig_arr_cur($hist_loop,$T,$sql_rel_and_sql[$T][$z_rel_and_name],$hist_time,$loop);
+				}
+			}
 			}
-			$sql_rel_and_sql[$T][$z_rel_and_name].="  ) " ;
-			if( isset($hist_loop[$T])) {
-			 	 foreach($hist_loop[$T] as $hist_rec) {
-				 	 $sql_rel_and_sql[$T][$z_rel_and_name].=" and ID!='".$hist_rec->ID."' ";
+			 
+			 //echo "<br>164:sql_rel_and_sql <pre>";
+				//	 	print_r($sql_rel_and_sql);
+				//	 	echo " .EOF</pre>";
+			
+			 //X test
+			 
+			 //echo " <br> 129 prev <pre>";
+			 // print_r($prev_dig);
+			 // echo "<br> prevtbl";
+			  //	  print_r($prev_tbl);
+			 
+			//  echo "</pre>";
+			 
+			 foreach($tables['X'] as $X=>$x) {
+				 	//rels in tbls
+				 	foreach($x['rel'] as $x_rel_from=>$x_rel_to) {
+				 		//echo "\n<br> #133test tbl ".$X." z_rel_fr ".$x_rel_from." to z_rel_to ".$x_rel_to." prev tbl " ;
+				 		if( isset($prev_tbl['rel'][$x_rel_from]) ) { //isset($prev_dig->$prev_tbl['rel'][$x_rel_to])  
+					// 	echo "<br>141 rel from ".$x_rel_from." exists .. testing field ".$prev_tbl['rel'][$x_rel_from]." <br>";//strlen(".$prev_dig->$prev_tbl['rel'][$x_rel_to].") 
+		
+					 		if( isset($prev_dig->$prev_tbl['rel'][$x_rel_from])  and strlen($prev_dig->$prev_tbl['rel'][$x_rel_from]) > 1 ) { // 
+						 		$sql_X[$X]['rel'][$x_rel_to]= $prev_dig->$prev_tbl['rel'][$x_rel_from];
+					 		}
+				 		}		 	 
+				 	}
+			 }
+			 
+			  flush();
+		//	 echo "\n<br>sql_X<pre>";
+		//	 print_r($sql_X);
+		//	 echo "</pre>";
+			 if( isset($sql_X)) {
+			 foreach($sql_X as $T => $rel) {
+				 	 $sql_x[$T]=" select * from ".$T." where ( ";
+				 	 foreach($rel['rel'] as $col=>$val) {
+					 	 if( isset($sql_x_str[$T]))  $sql_x_str[$T].=" or `".$col."` = '".$val."' " ;
+					 	 else $sql_x_str[$T]=" `".$col."` = '".$val."' " ;
+				 	 }
+				 	 $sql_x[$T].=$sql_x_str[$T]." ) ";
+				 	 //not loop
+				 	 if( isset($hist_loop[$T])) {
+					 	 foreach($hist_loop[$T] as $hist_rec) {
+						 	 $sql_t[$T].=" and ID!='".$hist_rec->ID."' ";
+					 	 }
+				 	 }
 			 	 }
-		 	 }
-			$sql_rel_and_sql[$T][$z_rel_and_name].=" ; " ;
-		 	 dig_arr_cur($hist_loop,$T,$sql_rel_and_sql[$T][$z_rel_and_name],$hist_time,$loop);
-		}
-	}
-	}
-	 
-	 //echo "<br>164:sql_rel_and_sql <pre>";
-		//	 	print_r($sql_rel_and_sql);
-		//	 	echo " .EOF</pre>";
-	
-	 //X test
-	 
-	 //echo " <br> 129 prev <pre>";
-	 // print_r($prev_dig);
-	 // echo "<br> prevtbl";
-	  //	  print_r($prev_tbl);
-	 
-	//  echo "</pre>";
-	 
-	 foreach($tables['X'] as $X=>$x) {
-		 	//rels in tbls
-		 	foreach($x['rel'] as $x_rel_from=>$x_rel_to) {
-		 		//echo "\n<br> #133test tbl ".$X." z_rel_fr ".$x_rel_from." to z_rel_to ".$x_rel_to." prev tbl " ;
-		 		if( isset($prev_tbl['rel'][$x_rel_from]) ) { //isset($prev_dig->$prev_tbl['rel'][$x_rel_to])  
-			// 	echo "<br>141 rel from ".$x_rel_from." exists .. testing field ".$prev_tbl['rel'][$x_rel_from]." <br>";//strlen(".$prev_dig->$prev_tbl['rel'][$x_rel_to].") 
-
-			 		if( isset($prev_dig->$prev_tbl['rel'][$x_rel_from])  and strlen($prev_dig->$prev_tbl['rel'][$x_rel_from]) > 1 ) { // 
-				 		$sql_X[$X]['rel'][$x_rel_to]= $prev_dig->$prev_tbl['rel'][$x_rel_from];
-			 		}
-		 		}		 	 
-		 	}
-	 }
-	 
-	  flush();
-//	 echo "\n<br>sql_X<pre>";
-//	 print_r($sql_X);
-//	 echo "</pre>";
-	 if( isset($sql_X)) {
-	 foreach($sql_X as $T => $rel) {
-		 	 $sql_x[$T]=" select * from ".$T." where ( ";
-		 	 foreach($rel['rel'] as $col=>$val) {
-			 	 if( isset($sql_x_str[$T]))  $sql_x_str[$T].=" or `".$col."` = '".$val."' " ;
-			 	 else $sql_x_str[$T]=" `".$col."` = '".$val."' " ;
-		 	 }
-		 	 $sql_x[$T].=$sql_x_str[$T]." ) ";
-		 	 //not loop
-		 	 if( isset($hist_loop[$T])) {
-			 	 foreach($hist_loop[$T] as $hist_rec) {
-				 	 $sql_t[$T].=" and ID!='".$hist_rec->ID."' ";
+			 }
+			// echo "<br> sql_x" ;
+			 //print_r($sql_x);
+			 
+			 if( isset($sql_x)) {
+				 foreach($sql_x as $X => $sql_ext) {
+					 echo "\n<br>174 Querying :".$sql_ext ;
+					  $res=$db->query($sql_ext) or die('175 blad');
+					  while($h=$db->fetch($res)) {
+						  echo "\n<hr> #177 POWIAZANIE ZNALEZIONE DLA X <pre>";
+						  print_r($h);
+						  echo "<br> Historia sledzen:";
+						  print_r($hist_time);
+						  echo "#177 eof </pre>";
+					  }
+				 }
+			 }
+			 //X test eof
+			 
+			 
+			 
+			 	 foreach($sql as $T => $rel) {
+				 	 $sql_t[$T]=" select * from ".$T." where ( ";
+				 	 foreach($rel['rel'] as $col=>$val) {
+					 	 if( isset($sql_t_str[$T]))  $sql_t_str[$T].=" or `".$col."` = '".$val."' " ;
+					 	 else $sql_t_str[$T]=" `".$col."` = '".$val."' " ;
+				 	 }
+				 	 $sql_t[$T].=$sql_t_str[$T]." ) ";
+				 	 //not loop
+				 	 if( isset($hist_loop[$T])) {
+					 	 echo "<br> hist loop cnt: ". count($hist_loop[$T]);
+					 	 foreach($hist_loop[$T] as $hist_rec) {
+						 	 $sql_t[$T].=" and ID!='".$hist_rec->ID."' ";
+					 	 }
+				 	 }
+				 	 
 			 	 }
-		 	 }
-	 	 }
-	 }
-	// echo "<br> sql_x" ;
-	 //print_r($sql_x);
-	 
-	 if( isset($sql_x)) {
-		 foreach($sql_x as $X => $sql_ext) {
-			 echo "\n<br>174 Querying :".$sql_ext ;
-			  $res=$db->query($sql_ext) or die('175 blad');
-			  while($h=$db->fetch($res)) {
-				  echo "\n<hr> #177 POWIAZANIE ZNALEZIONE DLA X <pre>";
-				  print_r($h);
-				  echo "<br> Historia sledzen:";
-				  print_r($hist_time);
-				  echo "#177 eof </pre>";
+			 	 
+			// echo "<br> 202 hist  loop cnt: <pre> ". count($hist_loop);
+			//	 	  print_r($hist_loop);
+			//	 	 echo "</pre>";
+			 echo "<pre>sql_t";
+			  print_r($sql);
+			 echo "<br>sql_t ";
+			  print_r($sql_t);
+			 echo "</pre>";
+			  
+			  if( isset($sql_t)) {
+				  foreach($sql_t as $T => $sql_ext)  { 
+					  dig_arr_cur($hist_loop,$T,$sql_ext,$hist_time,$loop);
+				  }
 			  }
-		 }
-	 }
-	 //X test eof
-	 
-	 
-	 
-	 	 foreach($sql as $T => $rel) {
-		 	 $sql_t[$T]=" select * from ".$T." where ( ";
-		 	 foreach($rel['rel'] as $col=>$val) {
-			 	 if( isset($sql_t_str[$T]))  $sql_t_str[$T].=" or `".$col."` = '".$val."' " ;
-			 	 else $sql_t_str[$T]=" `".$col."` = '".$val."' " ;
-		 	 }
-		 	 $sql_t[$T].=$sql_t_str[$T]." ) ";
-		 	 //not loop
-		 	 if( isset($hist_loop[$T])) {
-			 	 echo "<br> hist loop cnt: ". count($hist_loop[$T]);
-			 	 foreach($hist_loop[$T] as $hist_rec) {
-				 	 $sql_t[$T].=" and ID!='".$hist_rec->ID."' ";
-			 	 }
-		 	 }
-		 	 
-	 	 }
-	 	 
-	// echo "<br> 202 hist  loop cnt: <pre> ". count($hist_loop);
-	//	 	  print_r($hist_loop);
-	//	 	 echo "</pre>";
-	 echo "<pre>sql_t";
-	  print_r($sql);
-	 echo "<br>sql_t ";
-	  print_r($sql_t);
-	 echo "</pre>";
-	  
-	  if( isset($sql_t)) {
-		  foreach($sql_t as $T => $sql_ext)  { 
-			  dig_arr_cur($hist_loop,$T,$sql_ext,$hist_time,$loop);
-		  }
-	  }
-	  //todo look in Y and die()
-	  echo "<br>#243 glebokosc:".$loop;
-	
+			  //todo look in Y and die()
+			  
+	}	
+	echo "<br>#243 glebokosc:".$loop;
 }