Location: PHPKode > projects > HuMo-gen > source.php
<?php
@set_time_limit(300);

function source_display($sourcenum) {

global $db, $user, $pdf, $screen_mode, $language;
global $dataDb;

if($screen_mode!="PDF") {
	$kop="bron";
	include("header.php");
	include ("menu.php");
}

// *** Controle van gebruiker ***
if ($user["bronnen"]!='j'){
	echo $language["lng_no_authority"];
	exit();
}
if($screen_mode!="PDF") {
	include ("include/language_date.php");
	include('include/person_cls.php');
	print '<table class="humo bron">';
	print "<tr><td><h2>".$language["source_sources"]."</h2>";
}

	@$bron=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."sources
		WHERE source_gedcomnr='".$sourcenum."'",$db);
	@$bronDb=mysql_fetch_object($bron) or die("Geen geldig bronnummer.");

	if ($bronDb->source_title){
		if($screen_mode=="PDF") {
			$pdf->SetFont('Arial','B',10);
			$pdf->Write(6,$language["source_title"]." ");
			$pdf->SetFont('Arial','',10);
			$pdf->Write(6,$bronDb->source_title."\n");
		}
		else {
			print '<b>'.$language["source_title"]."</b> $bronDb->source_title<br>";
		}
	}
	if ($bronDb->source_date){
		if($screen_mode=="PDF") {
			$pdf->SetFont('Arial','B',10);
			$pdf->Write(6,$language["source_date"]." ");
			$pdf->SetFont('Arial','',10);
			$pdf->Write(6,taaldatum(strtolower($bronDb->source_date))."\n");

		}
		else {
			print '<b>'.$language["source_date"]."</b> ".taaldatum(strtolower($bronDb->source_date))."<br>";
		}
	}
	if ($bronDb->source_publ){
		$source_publ=$bronDb->source_publ;

		$pdflink=0;
		if (substr($source_publ,0,7)=='http://'){
			$link=$source_publ;
			$source_publ='<a href="'.$link.'">'.$link.'</a>';
			$pdflink=1;
		}
		if (substr($source_publ,0,8)=='https://'){
			$link=$source_publ;
			$source_publ='<a href="'.$link.'">'.$link.'</a>';
			$pdflink=1;
		}

		if($screen_mode=="PDF") {
			$pdf->SetFont('Arial','B',10);
			$pdf->Write(6,$language["source_publication"]." ");
			$pdf->SetFont('Arial','',10);
			if($pdflink==1) {
				$pdf->SetFont('Arial','U',10);  $pdf->SetTextColor(28,28,255);
				$pdf->Write(6,strip_tags($source_publ)."\n",strip_tags($source_publ));
				$pdf->SetFont('Arial','',10);  $pdf->SetTextColor(0);
			}
			else {
				$pdf->Write(6,strip_tags($source_publ)."\n");
			}
		}
		else {
			print '<b>'.$language["source_publication"]."</b> $source_publ<br>";
		}
	}
	if ($bronDb->source_place){
		if($screen_mode=="PDF") {
			$pdf->SetFont('Arial','B',10);
			$pdf->Write(6,$language["source_place"]." ");
			$pdf->SetFont('Arial','',10);
			$pdf->Write(6,$bronDb->source_place."\n");
		}
		else {
			print '<b>'.$language["source_place"]."</b> $bronDb->source_place<br>";
		}
	}
	if ($bronDb->source_refn){
		if($screen_mode=="PDF") {
			$pdf->SetFont('Arial','B',10);
			$pdf->Write(6,$language["source_own_code"]." ");
			$pdf->SetFont('Arial','',10);
			$pdf->Write(6,$bronDb->source_refn."\n");
		}
		else {
			print '<b>'.$language["source_own_code"]."</b> $bronDb->source_refn<br>";
		}
	}
	if ($bronDb->source_auth){
		if($screen_mode=="PDF") {
			$pdf->SetFont('Arial','B',10);
			$pdf->Write(6,$language["source_author"]." ");
			$pdf->SetFont('Arial','',10);
			$pdf->Write(6,$bronDb->source_auth."\n");
		}
		else {
			print '<b>'.$language["source_author"]."</b> $bronDb->source_auth<br>";
		}
	}
	if ($bronDb->source_subj){
		if($screen_mode=="PDF") {
			$pdf->SetFont('Arial','B',10);
			$pdf->Write(6,$language["source_subject"]." ");
			$pdf->SetFont('Arial','',10);
			$pdf->Write(6,$bronDb->source_subj."\n");
		}
		else {
			print '<b>'.$language["source_subject"]."</b> $bronDb->source_subj<br>";
		}
	}
	if ($bronDb->source_item){
		if($screen_mode=="PDF") {
			$pdf->SetFont('Arial','B',10);
			$pdf->Write(6,$language["source_nr"]." ");
			$pdf->SetFont('Arial','',10);
			$pdf->Write(6,$bronDb->source_item."\n");
		}
		else {
			print '<b>'.$language["source_nr"]."</b> $bronDb->source_item<br>";
		}
	}
	if ($bronDb->source_kind){
		if($screen_mode=="PDF") {
			$pdf->SetFont('Arial','B',10);
			$pdf->Write(6,$language["source_kind"]." ");
			$pdf->SetFont('Arial','',10);
			$pdf->Write(6,$bronDb->source_kind."\n");
		}
		else {
			print '<b>'.$language["source_kind"]."</b> $bronDb->source_kind<br>";
		}
	}
	if ($bronDb->source_repo_caln){
		if($screen_mode=="PDF") {
			$pdf->SetFont('Arial','B',10);
			$pdf->Write(6,$language["source_archive"]." ");
			$pdf->SetFont('Arial','',10);
			$pdf->Write(6,$bronDb->source_repo_caln."\n");
		}
		else {
			print '<b>'.$language["source_archive"]."</b> $bronDb->source_repo_caln<br>"; }
		}
	if ($bronDb->source_repo_page){
		if($screen_mode=="PDF") {
			$pdf->SetFont('Arial','B',10);
			$pdf->Write(6,$language["source_page"]." ");
			$pdf->SetFont('Arial','',10);
			$pdf->Write(6,$bronDb->source_repo_page."\n");
		}
		else {
			print '<b>'.$language["source_page"]."</b> $bronDb->source_repo_page<br>";
		}
	}
	if ($bronDb->source_text){
		if($screen_mode=="PDF") {
			$source_text=$bronDb->source_text;
			$source_text=str_replace('<br>', '', $source_text);
			//$pdf->Write(6,html_entity_decode($source_text)."\n");
			$pdf->Write(6,$source_text."\n");
		}
		else {
			print '</td></tr><tr><td>'.nl2br($bronDb->source_text);
		}
	}

// *** AFBEELDINGEN bij bron nog niet in gebruik... ***

if($screen_mode!="PDF") { // we do not want all persons in the database as given online so
						              // in the pdf file so we'll take just the above details
						              // and leave references to persons

print '</td></tr>';

	$persoon_cls = New persoon_cls;

	// *** Deze bron zoeken in tabel personen ***
	$persoon=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person",$db);
	print '<tr><td>';
	while (@$personDb=mysql_fetch_object($persoon)){

		// *** Bron bij naam ***
		$bronid=explode(";",$personDb->pers_name_source);
		for ($i=0; $i<=substr_count($personDb->pers_name_source, ';'); $i++){
			if (substr($bronid[$i],1,-1)==$bronDb->source_gedcomnr){
				print $language["source_by_name"].' <a href="gezin.php?id='.$personDb->pers_indexnr.'&amp;hoofdpersoon='.$personDb->pers_gedcomnumber.'">';
				echo $persoon_cls->naam($personDb);
				print '</a><br>';
			}
		}

		// *** Bron bij geboorte ***
		$bronid=explode(";",$personDb->pers_birth_source);
		for ($i=0; $i<=substr_count($personDb->pers_birth_source, ';'); $i++){
			if (substr($bronid[$i],1,-1)==$bronDb->source_gedcomnr){
				print $language["source_by_birth"].' <a href="gezin.php?id='.$personDb->pers_indexnr.'&amp;hoofdpersoon='.$personDb->pers_gedcomnumber.'">';
				echo $persoon_cls->naam($personDb);
				print '</a><br>';
			}
		}

		// *** Bron bij doop ***
		$bronid=explode(";",$personDb->pers_bapt_source);
		for ($i=0; $i<=substr_count($personDb->pers_bapt_source, ';'); $i++){
			if (substr($bronid[$i],1,-1)==$bronDb->source_gedcomnr){
				print $language["source_by_baptise"].' <a href="gezin.php?id='.$personDb->pers_indexnr.'&amp;hoofdpersoon='.$personDb->pers_gedcomnumber.'">';
				echo $persoon_cls->naam($personDb);
				print '</a><br>';
			}
		}

		// *** Bron bij overlijden ***
		$bronid=explode(";",$personDb->pers_death_source);
		for ($i=0; $i<=substr_count($personDb->pers_death_source, ';'); $i++){
			if (substr($bronid[$i],1,-1)==$bronDb->source_gedcomnr){
				print $language["source_by_death"].' <a href="gezin.php?id='.$personDb->pers_indexnr.'&amp;hoofdpersoon='.$personDb->pers_gedcomnumber.'">';
				echo $persoon_cls->naam($personDb);
				print '</a><br>';
			}
		}

		// *** Bron bij begraven ***
		$bronid=explode(";",$personDb->pers_buried_source);
		for ($i=0; $i<=substr_count($personDb->pers_buried_source, ';'); $i++){
			if (substr($bronid[$i],1,-1)==$bronDb->source_gedcomnr){
				print $language["source_by_buried"].' <a href="gezin.php?id='.$personDb->pers_indexnr.'&amp;hoofdpersoon='.$personDb->pers_gedcomnumber.'">';
				echo $persoon_cls->naam($personDb);
				print '</a><br>';
			}
		}

	}

	// *** Deze bron zoeken in tabel vermeldingen ***
	$vermeldingsql="SELECT * FROM ".veilig($_SESSION['tree_prefix'])."events WHERE event_source NOT LIKE ''";
	$vermeldingqry=mysql_query($vermeldingsql,$db);
	while (@$vermeldingDb=mysql_fetch_object($vermeldingqry)){
		$bronid=explode(";",$vermeldingDb->event_source);
		for ($i=0; $i<=substr_count($vermeldingDb->event_source, ';'); $i++){
			if (substr($bronid[$i],1,-1)==$bronDb->source_gedcomnr){
				// *** Person source ***
				if ($vermeldingDb->event_person_id){
					$persoon=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person
						WHERE pers_gedcomnumber='$vermeldingDb->event_person_id'",$db);
					$personDb=mysql_fetch_object($persoon);
					print $language["source_by_person"].' <a href="gezin.php?id='.$personDb->pers_indexnr.'&amp;hoofdpersoon='.$personDb->pers_gedcomnumber.'">';
					echo $persoon_cls->naam($personDb).'</a>';
					if ($vermeldingDb->event_event){ echo ' '.$vermeldingDb->event_event; }
					echo '<br>';
				}
				// *** Family source ***
				if ($vermeldingDb->event_family_id){
					print $language["source_by_family"].' <a href="gezin.php?id='.$vermeldingDb->event_family_id.'">';
					echo $vermeldingDb->event_family_id.'</a>';
					echo '<br>';
				}
			}
		}
	}

	// *** Deze bron zoeken in tabel adressen ***
	$adressensql="SELECT * FROM ".veilig($_SESSION['tree_prefix'])."adressen WHERE address_source NOT LIKE ''";
	$adressenqry=mysql_query($adressensql,$db);
	while (@$adressenDb=mysql_fetch_object($adressenqry)){
		$bronid=explode(";",$adressenDb->address_source);
		for ($i=0; $i<=substr_count($adressenDb->address_source, ';'); $i++){
			if (substr($bronid[$i],1,-1)==$bronDb->source_gedcomnr){
				$persoon=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person
					WHERE pers_gedcomnumber='$adressenDb->address_person_id'",$db);
				$personDb=mysql_fetch_object($persoon);
				print $language["source_by_address"].' <a href="gezin.php?id='.$personDb->pers_indexnr.'&amp;hoofdpersoon='.$personDb->pers_gedcomnumber.'">';
				echo $persoon_cls->naam($personDb);
				print '</a><br>';
			}
		}
	}

	// *** Persoonsgegevens zoeken ***
	// *** Door dit apart te zetten, wordt een bron veel sneller opgevraagd ***
	function persoon_gegevens($gezinDb){
		global $db;
		if ($gezinDb->fam_man){
			$persoon=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person
			WHERE pers_gedcomnumber='$gezinDb->fam_man'",$db);
		}
		else{
			$persoon=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person
			WHERE pers_gedcomnummer='$gezinDb->fam_woman'",$db);
		}
		@$personDb=mysql_fetch_object($persoon);
		return $personDb;
	}

	// *** Deze bron zoeken in tabel gezinnen ***
	$gezin=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."family",$db);
	while (@$gezinDb=mysql_fetch_object($gezin)){
		// *** Bron bij samenwonen ***
		$bronid=explode(";",$gezinDb->fam_relation_source);
		for ($i=0; $i<=substr_count($gezinDb->fam_relation_source, ';'); $i++){
			if (substr($bronid[$i],1,-1)==$bronDb->source_gedcomnr){
				$personDb=persoon_gegevens($gezinDb);
				print $language["source_by_living_together"].' <a href="gezin.php?id='.$personDb->pers_indexnr.'">';
				echo $persoon_cls->naam($personDb);
				print '</a><br>';
			}
		}

		$bronid=explode(";",$gezinDb->fam_marr_notice_source);
		for ($i=0; $i<=substr_count($gezinDb->fam_marr_notice_source, ';'); $i++){
			if (substr($bronid[$i],1,-1)==$bronDb->source_gedcomnr){
				$personDb=persoon_gegevens($gezinDb);
				print $language["source_by_married_notice"].' <a href="gezin.php?id='.$personDb->pers_indexnr.'">';
				echo $persoon_cls->naam($personDb);
				print '</a><br>';
			}
		}

		$bronid=explode(";",$gezinDb->fam_marr_source);
		for ($i=0; $i<=substr_count($gezinDb->fam_marr_source, ';'); $i++){
			if (substr($bronid[$i],1,-1)==$bronDb->source_gedcomnr){
				$personDb=persoon_gegevens($gezinDb);
				print $language["source_by_married"].' <a href="gezin.php?id='.$personDb->pers_indexnr.'">';
				echo $persoon_cls->naam($personDb);
				print '</a><br>';
			}
		}

		$bronid=explode(";",$gezinDb->fam_marr_church_notice_source);
		for ($i=0; $i<=substr_count($gezinDb->fam_marr_church_notice_source, ';'); $i++){
			if (substr($bronid[$i],1,-1)==$bronDb->source_gedcomnr){
				$personDb=persoon_gegevens($gezinDb);
				print $language["source_by_married_notice_church"].' <a href="gezin.php?id='.$personDb->pers_indexnr.'">';
				echo $persoon_cls->naam($personDb);
				print '</a><br>';
			}
		}

		$bronid=explode(";",$gezinDb->fam_marr_church_source);
		for ($i=0; $i<=substr_count($gezinDb->fam_marr_church_source, ';'); $i++){
			if (substr($bronid[$i],1,-1)==$bronDb->source_gedcomnr){
				$personDb=persoon_gegevens($gezinDb);
				print $language["source_by_married_church"].' <a href="gezin.php?id='.$personDb->pers_indexnr.'">';
				echo $persoon_cls->naam($personDb);
				print '</a><br>';
			}
		}

		$bronid=explode(";",$gezinDb->fam_div_source);
		for ($i=0; $i<=substr_count($gezinDb->fam_div_source, ';'); $i++){
			if (substr($bronid[$i],1,-1)==$bronDb->source_gedcomnr){
				$personDb=persoon_gegevens($gezinDb);
				print $language["source_by_divorced"].' <a href="gezin.php?id='.$personDb->pers_indexnr.'">';
				echo $persoon_cls->naam($personDb);
				print '</a><br>';
			}
		}

	}

print '</td></tr>';

print '</table>';

//mysql_close($db); //databaseverbinding sluiten.
include("footer.php");

} // end if not PDF

} // end function source_display

if(isset($_GET["id"])) { // source.php is called from show_sources.php, sources.php
	$sourcenumber=$_GET["id"];
	source_display($sourcenumber);
}

?>
Return current item: HuMo-gen