2){
$name = getContent($data[$i],"FN:");
if($anonymize){
$names = explode(" ",$name);
foreach($names as &$name){
$name = substr($name,0,1);
}
$name = join("",$names)." (Kontakt)";
$name = "Kontakt $i";
}
if($name!=""){
//$id_name = findInArray($nodes,$name);
//if($id_name===false){
$id_name = array_push($nodes,array("name"=>$name,"group"=>0)) - 1;
//}
}
}
//echo "$notes
";
if($notes!="" && strlen($notes)>2){
$notes = str_replace(array("(",")","/",";","\\n","\\",",",";"," mich "," den "," gab "," dem ")," ",$notes);
$notes = str_replace(array(". ","- ")," ",$notes);
$notes = explode(" ",$notes);
foreach($notes as $note){
if($note!="" && strlen($note)>2){
$note = trim($note);
if($anonymize){
$note_md5 = md5($note);
$note_normal = $note;
$note = $note_md5;
}
//$links_temp = addLink($links_temp,$note,$id_name);
$id_note = findInArray($nodes,$note);
if ($id_note===false) {
$id_note = array_push($nodes,array("name"=>$note,"group"=>50)) - 1;
if($anonymize){
array_push($notes_temp,array($note_md5,$note_normal));
}
}
else{
$nodes[$id_note]["group"]+=1;
}
$link_id = array_push($links,array("info"=>$note,"source"=>$id_name,"target"=>$id_note,"value"=>1)) - 1;
//array_push($link_ids,)
}
}
}
}
echo "nodes: ".count($nodes)." (davon $i Kontakte)
links: ".count($links)."
";
//echo "".print_r($nodes,true)."
";
//echo "".print_r($links,true)."
";
$content = '{
"nodes":'.str_replace("},","},\r\n",json_encode($nodes)).',
"links":'.str_replace("},","},\r\n",json_encode($links)).'}';
if($anonymize){
for ($i=0;$i";
$content = str_replace($tmp[0],"Notiz $i",$content);
}
}
file_put_contents("miserables2.json",$content);
echo "$content
";
function getContent($data,$marker){
$content = "";
if(strpos($data,$marker)===false) return false;
$content = substr($data,(strpos($data,$marker)+strlen($marker)));
$content = trim(substr($content,0,strpos($content,"\r\n")));
return $content;
}
function addLink($links,$name,$node_id){
if(is_array($links[$name])) array_push($links[$name],$node_id);
else $links[$name] = Array($node_id);
return $links;
}
function findInArray($haystack,$subject){
foreach($haystack as $key => $value){
if($value["name"]==$subject) return $key;
}
return false;
}
?>