Location: PHPKode > projects > HuMo-gen > timelines.php
<?php
$kop="timeline";
include("header.php");
include("menu.php");
require_once("include/person_cls.php");
//require_once("include/date_place.php");
require_once("include/language_date.php");

if(isset($_GET['id'])) { $id=$_GET['id']; }
if(isset($_GET['database'])) { $database=$_GET['database']; }
$persoon=mysql_query("SELECT * FROM ".veilig($database)."person WHERE pers_gedcomnumber='".veilig($id)."'",$db);
@$persoonDb=mysql_fetch_object($persoon);

$isborn=0; $isdeath=0; $ismarr=0; $ischild=0;
$deathtext=''; $borntext=''; $bapttext=''; $burrtext=''; $marrtext='';
$privacy_filtered=false;

$bornyear=''; $borndate=''; $temp='';
if($persoonDb->pers_birth_date) {
	$borndate=$persoonDb->pers_birth_date;
	$temp=substr($borndate,-4);
	if($temp > 0 AND $temp < 2200) {
		$bornyear=$temp;
		$borntext= $language["tml_birth"].taaldatum($borndate);
		$isborn=1;
	}
}
$baptyear=''; $baptdate=''; $temp='';
if($persoonDb->pers_bapt_date) {
	$baptdate=$persoonDb->pers_bapt_date;
	$temp=substr($baptdate,-4);
	if($temp > 0 AND $temp < 2200) {
		$baptyear=$temp;
		$bapttext= $language["tml_bapt"].taaldatum($baptdate);
		$isborn=1;
	}
}
$deathyear=''; $deathdate=''; $temp='';
if($persoonDb->pers_death_date) {
	$deathdate=$persoonDb->pers_death_date;
	$temp=substr($deathdate,-4);
	if($temp > 0 AND $temp < 2200) {
		$deathyear=$temp;
		$deathtext= $language["tml_death"].taaldatum($deathdate);
		$isdeath=1;
	}
}
$burryear=''; $burrdate=''; $temp='';
if($persoonDb->pers_buried_date) {
	$burrdate=$persoonDb->pers_buried_date;
	$temp=substr($burrdate,-4);
	if($temp > 0 AND $temp < 2200) {
		$burryear=$temp;
		$burrtext= $language["tml_buried"].taaldatum($burrdate);
		$isdeath=1;
	}
}

// ***********  MARRIAGES & CHILDREN
if($persoonDb->pers_fams) {
	$marriages=explode(";",$persoonDb->pers_fams);
	for($i=0; $i<count($marriages);$i++) {
		$children[$i]='';
		$marryear[$i]=''; $marrdate[$i]=''; $temp='';
		$thisfam=$marriages[$i];
		$family=mysql_query("SELECT * FROM ".veilig($database)."family WHERE fam_gedcomnumber='".veilig($thisfam)."'",$db);
		@$familyDb=mysql_fetch_object($family);

		if ($persoonDb->pers_gedcomnumber==$familyDb->fam_man){
			$spouse=$familyDb->fam_woman;
		}
		else{
			$spouse=$familyDb->fam_man;
		}
		$spouse2=mysql_query("SELECT * FROM ".veilig($database)."person WHERE pers_gedcomnumber='".veilig($spouse)."'",$db);
		@$spouse2Db=mysql_fetch_object($spouse2);

		$persoon_cls = New persoon_cls;
		$persoon_cls->construct($spouse2Db);
		$privacy=$persoon_cls->privacy;
		if ($privacy==''){

			if($spouse2Db->pers_death_date) {
				$spousedeathname[$i]=''; $spousedeathyear[$i]=''; $spousedeathtext[$i]='';
				$spousedeathdate[$i]=$spouse2Db->pers_death_date;
				$temp=substr($spousedeathdate[$i],-4);
				if($temp AND $temp > 0 AND $temp < 2200) {
					if($spouse2Db->pers_sexe=="M") { $spouse=$language["tml_spouse_male"]; }
					else { $spouse=$language["tml_spouse_female"]; }
						$spousedeathyear[$i]=$temp;
						if($spouse2Db->pers_firstname) {
							$spousedeathname[$i]=$spouse2Db->pers_firstname;
						}
						$spousedeathtext[$i]= $language["tml_death"].$spouse." ".$spousedeathname[$i]." ".$dirmark1.str_replace(" ","&nbsp;",taaldatum($spousedeathdate[$i]));
				}
			}

			$temp='';
			if($familyDb->fam_marr_date) {
				$marrdate[$i]=$familyDb->fam_marr_date;
				$text=$language["tml_marriage"];
			}
			elseif($familyDb->fam_marr_church_date) {
				$marrdate[$i]=$familyDb->fam_marr_church_date;
				$text=$language["tml_churchmarr"];
			}
			elseif($familyDb->fam_marr_notice_date) {
			$marrdate[$i]=$familyDb->fam_marr_notice_date;
				$text=$language["tml_marrnotice"];
			}
			elseif($familyDb->fam_marr_church_notice_date) {
				$marrdate[$i]=$familyDb->fam_marr_church_notice_date;
				$text=$language["tml_churmarrnotice"];
			}
			elseif($familyDb->fam_relation_date) {
				$marrdate[$i]=$familyDb->fam_relation_date;
				$text=$language["tml_partnership"];
			}
			if($marrdate[$i]) {
				$temp=substr($marrdate[$i],-4);
			}
			if($temp AND $temp > 0 AND $temp < 2200) {
				if($spouse2Db->pers_firstname) {
					$spousename=$spouse2Db->pers_firstname;
					$spousetext=$language["tml_with"].$spousename;
				}
				$marryear[$i]=$temp;
				//$marrtext[$i]= $text.$spousetext."<br>".taaldatum($marrdate[$i]);
				$marrtext[$i]= $text.$spousetext." ".$dirmark1.str_replace(" ","&nbsp;",taaldatum($marrdate[$i]));
				$ismarr=1;
			}

		}
		else{
			// *** Privacy filter activated ***
			$privacy_filtered=true;
		}

		if($familyDb->fam_children) {
			$children[$i]=explode(";",$familyDb->fam_children);
			for($m=0; $m<count($children[$i]); $m++) {
				$chmarriages[$i][$m]=''; // enter value so we wont get error messages in usbwserver
				$child=$children[$i][$m];
				$chld=mysql_query("SELECT * FROM ".veilig($database)."person WHERE pers_gedcomnumber='".veilig($child)."'",$db);
				@$chldDb=mysql_fetch_object($chld);

				if($chldDb->pers_sexe=="M") { $child=$language["rel_son"]; }
				else if ($chldDb->pers_sexe=="F") { $child=$language["rel_daughter"]; }
				else { $child=$language["tml_child"]; }

				$persoon2_cls = New persoon_cls;
				$persoon2_cls->construct($chldDb);
				$privacy=$persoon2_cls->privacy;
				if ($privacy==''){
					$chbornyear[$i][$m]=''; $chborndate[$i][$m]=''; $chborntext[$i][$m]='';
					$chdeathyear[$i][$m]=''; $chdeathdate[$i][$m]=''; $chdeathtext[$i][$m]='';
					$temp='';

					$childname[$i][$m]=$chldDb->pers_firstname;
					$chborndate[$i][$m]=$chldDb->pers_birth_date;
					$temp=substr($chborndate[$i][$m],-4);
					if($temp > 0 AND $temp < 2200) {

						$chbornyear[$i][$m]=$temp;
						$chborntext[$i][$m]=$language["tml_birth"].$child." ".$childname[$i][$m]." ".$dirmark1.str_replace(" ","&nbsp;",taaldatum($chborndate[$i][$m]));
						$ischild=1;
					}
					$chdeathdate[$i][$m]=$chldDb->pers_death_date;
					$temp='';
					$temp=substr($chdeathdate[$i][$m],-4);
					if($temp > 0 AND $temp < 2200) {
						$chdeathyear[$i][$m]=$temp;
						$chdeathtext[$i][$m]=$language["tml_death"].$child." ".$childname[$i][$m]." ".$dirmark1.str_replace(" ","&nbsp;",taaldatum($chdeathdate[$i][$m]));
					}
				}
				else{
					// *** Privacy filter activated ***
					$privacy_filtered=true;
				}
				if($chldDb->pers_fams) {
					$chmarriages[$i][$m]=explode(";",$chldDb->pers_fams);
					for($p=0; $p<count($chmarriages[$i][$m]);$p++) {
						$grchildren[$i][$m][$p]=''; // enter value so usbwebserver wont throw error messages
						$chmarryear[$i][$m][$p]=''; $chmarrdate[$i][$m][$p]=''; $temp='';
						$thischfam=$chmarriages[$i][$m][$p];
						$chfamily=mysql_query("SELECT * FROM ".veilig($database)."family WHERE fam_gedcomnumber='".veilig($thischfam)."'",$db);
						@$chfamilyDb=mysql_fetch_object($chfamily);

// CHILDREN'S MARRIAGES

		if ($chldDb->pers_gedcomnumber==$chfamilyDb->fam_man){
			$chspouse=$chfamilyDb->fam_woman;
		}
		else{
			$chspouse=$chfamilyDb->fam_man;
		}
		$chspouse2=mysql_query("SELECT * FROM ".veilig($database)."person WHERE pers_gedcomnumber='".veilig($chspouse)."'",$db);
		@$chspouse2Db=mysql_fetch_object($chspouse2);

		$persoon_cls = New persoon_cls;
		$persoon_cls->construct($chspouse2Db);
		$privacy=$persoon_cls->privacy;
		if ($privacy==''){
			if ($chfamilyDb->fam_marr_date) {
				$chmarrdate[$i][$m][$p]=$chfamilyDb->fam_marr_date;
				$chtext=$language["tml_marriage"];
			}
			elseif ($chfamilyDb->fam_marr_church_date) {
				$chmarrdate[$i][$m][$p]=$chfamilyDb->fam_marr_church_date;
				$chtext=$language["tml_churchmarr"];
			}
			elseif ($chfamilyDb->fam_marr_notice_date) {
			$chmarrdate[$i][$m][$p]=$chfamilyDb->fam_marr_notice_date;
				$chtext=$language["tml_marrnotice"];
			}
			elseif	($chfamilyDb->fam_marr_church_notice_date) {
				$chmarrdate[$i][$m][$p]=$chfamilyDb->fam_marr_church_notice_date;
				$chtext=$language["tml_churmarrnotice"];
			}
			elseif	($chfamilyDb->fam_relation_date) {
				$chmarrdate[$i][$m][$p]=$chfamilyDb->fam_relation_date;
				$chtext=$language["tml_partnership"];
			}
			if	($chmarrdate[$i][$m][$p]) {
				$temp=substr($chmarrdate[$i][$m][$p],-4);
			}
			if	($temp AND $temp > 0 AND $temp < 2200) {
				if	(isset($chspouse2Db->pers_firstname) AND $chspouse2Db->pers_firstname) {
					$chspousename=$chspouse2Db->pers_firstname;
					$chspousetext=$language["tml_with"].$chspousename;
				}
				$chmarryear[$i][$m][$p]=$temp;
				$chmarrtext[$i][$m][$p]= $chtext.$child." ".$childname[$i][$m].$chspousetext." ".$dirmark1.str_replace(" ","&nbsp;",taaldatum($chmarrdate[$i][$m][$p]));
				//$chismarr=1;
			}

		}
		else{
			// *** Privacy filter activated ***
			$privacy_filtered=true;
		}

// END CHILDREN'S MARRIAGES

						if($chfamilyDb->fam_children) {

							$grchildren[$i][$m][$p]=explode(";",$chfamilyDb->fam_children);
							for($g=0; $g<count($grchildren[$i][$m][$p]); $g++) {
								$grchild=$grchildren[$i][$m][$p][$g];
								$grchld=mysql_query("SELECT * FROM ".veilig($database)."person WHERE pers_gedcomnumber='".veilig($grchild)."'",$db);
								@$grchldDb=mysql_fetch_object($grchld);
								$persoon3_cls = New persoon_cls;
								$persoon3_cls->construct($grchldDb);
								$privacy=$persoon3_cls->privacy;
								if ($privacy==''){

									$grchbornyear[$i][$m][$p][$g]=''; $grchborndate[$i][$m][$p][$g]=''; $grchborntext[$i][$m][$p][$g]='';
									$grchdeathyear[$i][$m][$p][$g]=''; $grchdeathdate[$i][$m][$p][$g]=''; $grchdeathtext[$i][$m][$p][$g]='';
									$temp='';

									if($grchldDb->pers_sexe=="M") { $grchild=$language["tml_grson"]; }
									else if ($grchldDb->pers_sexe=="F") { $grchild=$language["tml_grdaughter"]; }
									else { $grchild=$language["tml_grchild"]; }

									$grchildname[$i][$m][$p][$g]=$grchldDb->pers_firstname;
									$grchborndate[$i][$m][$p][$g]=$grchldDb->pers_birth_date;
									$temp=substr($grchborndate[$i][$m][$p][$g],-4);
									if($temp > 0 AND $temp < 2200) {
										$grchbornyear[$i][$m][$p][$g]=$temp;
										$grchborntext[$i][$m][$p][$g]=$language["tml_birth"].$grchild." ".$grchildname[$i][$m][$p][$g]." ".$dirmark1.str_replace(" ","&nbsp;",taaldatum($grchborndate[$i][$m][$p][$g]));

									}
									$grchdeathdate[$i][$m][$p][$g]=$grchldDb->pers_death_date;
									$temp='';
									$temp=substr($grchdeathdate[$i][$m][$p][$g],-4);
									if($temp > 0 AND $temp < 2200) {
										$grchdeathyear[$i][$m][$p][$g]=$temp;
										$grchdeathtext[$i][$m][$p][$g]=$language["tml_death"].$grchild." ".$grchildname[$i][$m][$p][$g]."  ".$dirmark1.str_replace(" ","&nbsp;",taaldatum($grchdeathdate[$i][$m][$p][$g]));
									}
								} // end if privacy==''

								else{
								// *** Privacy filter activated ***
									$privacy_filtered=true;
								}
							} // end for grchildren
						}	// end if grchildren
					} // end for chmarriages
				} //end if chldDb->pers_fams
			} //end for
		} // end if children
	}
}
// *********** END MARRIAGES & CHILDREN

// *********** CHECK IF ANY DATES ARE AVAILABLE. IF PART ARE MISSING ESTIMATE BIRTH/DEATH

// *** Check privacy filter ***

$persoon_cls = New persoon_cls;
$persoon_cls->construct($persoonDb);
$privacy=$persoon_cls->privacy;
if($privacy==1) { // dit is een persoon met privacy beperkingenmarryear
	echo '<br><br>'.$language["privacy"];
	exit();
}

if($isborn==0 AND $isdeath==0 AND $ismarr==0 AND $ischild==0) {   // no birth or death dates available
	print "<br><br>".$language["tml_nodates"];
	exit();
}
if($isborn==1 AND $isdeath==0) {  // birth date but no death date: we show 80 years from birth
	if($bornyear!=0) {
		$deathyear=$bornyear+80;
	}
	else {
		$deathyear=$baptyear+80;
	}
	$deathtext=$language["tml_deathunknown"];
	if($deathyear > date("Y")) {  // if birth+80 goes beyond present, we stop there but of course don't mention death.... ;-)
		$deathyear=date("Y");
		$deathtext='';
	}
}
if($isborn==0 AND $isdeath==1) {  // death date but no birth date: we show 80 years prior to death
	if($deathyear!=0) {
		$bornyear=$deathyear-80;
	}
	else {
		$bornyear=$burryear-80;
	}
	$borntext=$language["tml_birthunknown"];
}
if($isborn==0 AND $isdeath==0 AND $ismarr==1) {
	// no birth or death date but there is a marriage date:
	// birth is estimated as 25 years prior to marriage date
	// death is estimated as 55 years after marriage date
	if($marryear[0]!=0){
		$bornyear=$marryear[0]-25;
		$deathyear=$marryear[0]+55;
	}
	$borntext=$language["tml_birthunknown"];
	$deathtext=$language["tml_deathunknown"];
}
if($isborn==0 AND $isdeath==0 AND $ismarr==0 and $ischild==1) {
	// no birth,death or marriage date but there is a childbirth date:
	// birth is estimated as 25 years prior to child birth date
	// death is estimated as 55 years after child birth date
	if($chbornyear[0][0]!=0) {
		$bornyear=$chbornyear[0][0]-25;
		$deathyear=$chbornyear[0][0]+55;
	}
	$borntext=$language["tml_birthunknown"];
	$deathtext=$language["tml_deathunknown"];
}

// ****** OPEN TIMELINE DIRECTORY FOR READING AVAILABLE FILES

$dh  = opendir("languages/".$Taalkeuze."/timelines"); // we know directory exists - otherwise the timelines options would not be displayed
$counter=0;
while (false !== ($filename = readdir($dh))) {
	if (strtolower(substr($filename, -3)) == "txt"){
		$counter++;
		$filenames[$counter-1][0]="languages/".$Taalkeuze."/timelines/".$filename;
		$filenames[$counter-1][1]=substr($filename,0,-4);
	}
}
sort($filenames);
$step=5; // default step - user can choose 1 or 10 instead
if(isset($_POST['step'])) { $step=$_POST['step']; }
$tml=3;  // default timeline file
if(isset($_POST['tml'])) { $tml=$_POST['tml']; }

// **** SHOW MENU ****

print "<div style='position:absolute;top:30px;left:5px;padding:15px'>";
print "<table class='humo'><tr><td>";
print '<form name="tmlstep" method="post" action="timelines.php?id='.$id.'&amp;database='.$database.'" style="display:inline;">';

// Steps of years in display: 1, 5 or 10
print $language["tml_steps"]."<br>";
print '<input type="radio" name="step" value="1"';
if ($step==1) print ' checked="checked"';
print ' >1 '.$language["tml_year"];
print '<br><input type="radio" name="step" value="5"';
if ($step==5) print ' checked="checked"';
print ' >5 '.$language["tml_years"];
print '<br><input type="radio" name="step" value="10"';
if ($step==10) print ' checked="checked"';
print ' >10 '.$language["tml_years"];

// Choice of timeline files available

if(count($filenames) > 1) { // only show timelines menu if there are more than 1 timeline files

	print '<br><br>'.$language["tml_choosetml"];
	print '<div style="direction:ltr">';
	for ($i=0; $i<count($filenames); $i++){
		print '<input type="radio" name="tml" value="'.$i.'"';
		if ($tml==$i) {
			print ' checked="checked"';
		}
		print ' >'.$filenames[$i][1].'<br>';
	}
	print '</div>';
}
print '<br><br><input type="submit" value="'.$language["tml_changedisplay"].'" >';
print '<br><br>';


//======== HELP POPUP ========================

echo '<div class="fonts weergave '.$rtlmarker.'sddm" style="display:inline">';
echo '<a href="#"';
echo ' style="display:inline" ';
echo 'onmouseover="mopen(event,\'hulpmenu\',10,150)"';
echo 'onmouseout="mclosetime()">';
echo '&nbsp;&nbsp;&nbsp;<strong>'.$language["main_help"].'</strong>';
echo '</a>&nbsp;';
echo '<div class="sddm_fixed" style="z-index:40; text-align:'.$alignmarker.'; padding:4px; direction:'.$rtlmarker.'" id="hulpmenu" onmouseover="mcancelclosetime()" onmouseout="mclosetime()">';

print $language["tml_help1"].'<br>';
print '<ul><li>'.$language["tml_help2"];
print '<li>'.$language["tml_help3"].'<br>'.$language["tml_help4"].'<br>'.$language["tml_help5"].'</li>';
print '<li>'.$language["tml_help6"].'</li></ul>';

print $language["tml_help7"].'<br>';
print '<ul><li>'.$language["tml_help8"].'<br>'.$language["tml_help9"].'<br>'.$language["tml_help10"].'<br>'.$language["tml_help11"].'</li>';
print '<li>'.$language["tml_help12"].'</li>';
print '<li><strong>'.$language["tml_help13"].'</strong></li></ul>';
echo '</div>';
echo '</div>';

//=================================

print '</form>';
print '</td></tr></table>';
print '</div>';

// **** END MENU ****
if(file_exists($filenames[0][0])) {
	$handle = fopen($filenames[$tml][0], "r");
}
$beginyear=$bornyear-(($bornyear % $step) + $step);    // if beginyear=1923 and step is 5 this makes it 1915
$endyear=$deathyear+(($step-($deathyear % $step)))+($step); // if endyear=1923 and step is 5 this makes it 1929
if($endyear>date("Y")) { $endyear=date("Y"); }
$flag=0; // flags a first entry of timeline event in a specific year. is set to 1 when at least one entry has been made

// ****** DISPLAY

print "<div style='position:absolute;top:30px;left:150px;right:10px'>";

if ($privacy_filtered==true){
	echo $language["tml_privacy"].'<br>';
}

print "<table class='humo' style='border:1px'>";
print "<tr><th class='tekstgezinsblad' style='border:1px solid blue;' colspan='3'>".$persoonDb->pers_firstname." ".$persoonDb->pers_lastname."</th></tr>";
print "<tr><td style='text-align:center;font-weight:bold'>".$language["tml_lifeevents"]."</td>";
print "<td style='text-align:center;font-weight:bold'>".$language["tml_yearheader"]."</td>";
$nofiles='';
if(!file_exists($filenames[0][0])) {
	$nofiles="<br>".$language["tml_notimelines"];
}
print "<td style='text-align:center;font-weight:bold'>".$language["tml_histevents"].$nofiles."</td></tr>";
$step==1?$yearwidth=60:$yearwidth=120; // when step is 1 the column can be much shorter
$flag_isbuffer=0;
$eventdir="ltr"; // default direction of timeline file is ltr (set to rtl later in the script if necessary
for($yr=$beginyear; $yr<$endyear; $yr+=$step) {  // range of years for lifespan

	// DISPLAY LIFE EVENTS FOR THIS YEAR/PERIOD (1st column)

	print "<tr><td style='width:250px;padding:4px;vertical-align:top;font-weight:bold;color:red'>";
	$br_flag=0;
	for($tempyr=$yr; $tempyr<$yr+$step; $tempyr++) {

		if ($bornyear!='' AND $bornyear == $tempyr) {
			if($br_flag==1) { print "<br>"; }
			print $borntext;
			$br_flag=1;
		}
		else if ($baptyear!='' AND $baptyear == $tempyr) {
			if($br_flag==1) { print "<br>"; }
			print $bapttext;
			$br_flag=1;
		}
		if(isset($marryear)) {
			for($i=0;$i<count($marryear);$i++) {
				if ($marryear[$i]!='' AND $marryear[$i] == $tempyr) {
					if($br_flag==1) { print "<br>"; }
					print $marrtext[$i];
					$br_flag=1;
				}
			}
		}
		if(isset($spousedeathyear)) {
			for($i=0;$i<count($spousedeathyear);$i++) {
				if ($spousedeathyear[$i]!='' AND $spousedeathyear[$i] == $tempyr) {
					if($br_flag==1) { print "<br>"; }
					print $spousedeathtext[$i];
					$br_flag=1;
				}
			}
		}
		if(isset($chbornyear)) {
			for($i=0; $i<count($marriages);$i++) {
				for($m=0; $m<count($children[$i]);$m++) {
					if (isset($chbornyear[$i][$m]) AND $chbornyear[$i][$m] == $tempyr) {
						if($br_flag==1) { print "<br>"; }
						print "<span style='color:green;font-weight:normal'>".$chborntext[$i][$m]."</span>";
						$br_flag=1;
					}
				}
			}
		}
		if(isset($chdeathyear)) {
			for($i=0; $i<count($marriages);$i++) {
				for($m=0; $m<count($children[$i]);$m++) {
					if (isset($chdeathyear[$i][$m]) AND $chdeathyear[$i][$m] == $tempyr) {
						if($br_flag==1) { print "<br>"; }
						print "<span style='color:green;font-weight:normal'>".$chdeathtext[$i][$m]."</span>";
						$br_flag=1;
					}
				}
			}
		}
		if(isset($chmarryear)) {
			for($i=0; $i<count($marriages);$i++) {
				for($m=0; $m<count($children[$i]);$m++) {
					if(isset($chmarriages[$i][$m])) {
						for($p=0; $p<count($chmarriages[$i][$m]);$p++) {
							if (isset($chmarryear[$i][$m][$p]) AND $chmarryear[$i][$m][$p]!='' AND $chmarryear[$i][$m][$p] == $tempyr) {
								if($br_flag==1) { print "<br>"; }
								print "<span style='color:green;font-weight:normal'>".$chmarrtext[$i][$m][$p]."</span>";
								$br_flag=1;
							}
						}
					}
				}
			}
		}
		if(isset($grchbornyear)) {
			for($i=0; $i<count($marriages);$i++) {
				for($m=0; $m<count($children[$i]);$m++) {
					if(isset($chmarriages[$i][$m])) {
					for($p=0; $p<count($chmarriages[$i][$m]);$p++) {
						if(isset($grchildren[$i][$m][$p])) {
						for($g=0; $g<count($grchildren[$i][$m][$p]);$g++) {
							if (isset($grchbornyear[$i][$m][$p][$g]) AND $grchbornyear[$i][$m][$p][$g]!='' AND $grchbornyear[$i][$m][$p][$g] == $tempyr) {
								if($br_flag==1) { print "<br>"; }
								print "<span style='color:blue;font-weight:normal'>".$grchborntext[$i][$m][$p][$g]."</span>";
								$br_flag=1;
							}
						}
						}
					}
					}
				}
			}
		} 
		if(isset($grchdeathyear)) {
			for($i=0; $i<count($marriages);$i++) {
				for($m=0; $m<count($children[$i]);$m++) {
					if(isset($chmarriages[$i][$m])) {
					for($p=0; $p<count($chmarriages[$i][$m]);$p++) {
						if(isset($grchildren[$i][$m][$p])) {
						for($g=0; $g<count($grchildren[$i][$m][$p]);$g++) {
							if (isset($grchdeathyear[$i][$m][$p][$g]) AND $grchdeathyear[$i][$m][$p][$g]!='' AND $grchdeathyear[$i][$m][$p][$g] == $tempyr) {
								if($br_flag==1) { print "<br>"; }
								print "<span style='color:blue;font-weight:normal'>".$grchdeathtext[$i][$m][$p][$g]."</span>";
								$br_flag=1;
							}
						}
						}
					}
					}
				}
			}
		}
		if ($deathyear!='' AND $deathyear == $tempyr) {
			if($br_flag==1) { print "<br>"; }
			print $deathtext;
			$br_flag=1;
		}
		else if ($burryear!='' AND $burryear == $tempyr) {
			if($br_flag==1) { print "<br>"; }
			print $burrtext;
			$br_flag=1;
		}
	} // end life events loop

	print "</td>";

	// DISPLAY YEAR/PERIOD (2nd column)
	$period='';
	if($step!=1) {
		$period="-".($yr+$step)+1;
	}
	print "<td style='width:".$yearwidth."px;padding:4px;text-align:center;vertical-align:top;font-weight:bold;font-size:120%'>".$yr.$period."</td>";

	// DISPLAY HISTORIC EVENTS FOR THIS YEAR/PERIOD (3rd column)
	print "<td style='vertical-align:top'>";

	if(file_exists($filenames[0][0])) {
		$flag_br=0;
		//while (!feof($handle)) {
		while (!feof($handle) OR (feof($handle) AND $flag_isbuffer==1) ) {  	
			$eventyear=''; $eventdata='';
			if($flag_isbuffer!=1) {
				$buffer = fgets($handle, 4096);
				$temp=substr($buffer,0,4);
			}
			else {
				$flag_isbuffer=0;
			} 

			if($temp>0 AND $temp <2200) { // valid year
				if($temp < $yr){ // we didn't get to the lifespan yet - take next line
					continue;
				}
				else if($temp >= $yr+$step) { // event year is beyond the year/period checked, flag existence of buffer and break out of while loop
					$flag_isbuffer=1;
					//print "</td></tr>";
					break;
				}
				else if($temp>=$yr AND $temp<$yr+$step) {
					if($flag_br==0) { // first entry in this year/period. if a "rtl" was read before the first text entry make direction rtl
						print '<div style="direction:'.$eventdir.'">';
					}
					$thisyear='';
					if($step!=1) {
						$thisyear=$temp." ";
					}
					if(substr($buffer,4,1)=='-') {
						$temp2=substr($buffer,5,4);
						if($temp2 >0 AND $temp2 < 2200) {
							$tillyear=$temp2;
							$eventdata="(".$language["tml_till"]." ".$tillyear.") ".substr($buffer,10);
							if($flag_br==1) { print "<br>"; }
							print $thisyear.$eventdata;
							$flag_br=1;
						}
					}
					else {
						$eventdata=substr($buffer,5);
						if($flag_br==1) { print "<br>"; }
						print $thisyear.$eventdata;
						$flag_br=1;
					}
				}
			}
			else { // line doesn't start with valid year - take next line
				if(substr($temp,0,3)=="rtl") {  //the timeline file is a rtl file (the word rtl was on one of the first lines in the file)
					$eventdir="rtl";
				}
				continue;
			}

		} // end while loop
		if($flag_br!=0) {
			print '</div>';
		}
	}
	print "</td></tr>";
} // end total lifespan loop

print "</table>";
print "<br><br><br><br>";
print "</div>";

// END DISPLAY
if(file_exists($filenames[0][0])) {
	fclose($handle);
}
include("footer.php");
?>
Return current item: HuMo-gen