Location: PHPKode > projects > HuMo-gen > admin/include/update.php
<?php
@set_time_limit(3000);

echo '<h2>UPDATE PROCEDURE</h2>';

echo 'Er worden meerdere updates gedaan! Het is aan te raden om eerst een database backup te maken!<br>';
echo '<b>Wacht tot de melding dat de update voltooid is!</b><br>';

echo '<br>Multiple updates will be done. It is recommended to do a database backup!<br>';
echo '<b>Please wait until the notice that the update has been completed!</b>';

if (!isset($_GET['proceed'])){
	echo '<p><a href="index.php?page=update&proceed=1">START UPDATE PROCEDURE</a>';
}
else{

	echo '<table class="humo">';
		echo '<tr class="tabel_kop"><th colspan="2">'.$language["index_status"].'</th></tr>';

	// *** UPDATE PROCEDURES ****************************************************************
	$update='';

	if (isset($_SESSION['save_humo_update'])){
		$humo_update=$_SESSION['save_humo_update'];
	}
	else{
		$humo_update=0;
	}

	// ********************************
	// *** HuMo-gen update 1 (V3.1) ***
	// ********************************
	$controle_update = mysql_query("SELECT * FROM humo_stambomen_tekst",$db);
	if ($controle_update){
		if ($humo_update==0){ $humo_update=1; }
	}
	if ($humo_update>0){
		echo '<tr><td>HuMo-gen update V3.1</td><td style="background-color:#00FF00">OK</td></tr>';
	}
	else{
		echo '<tr><td>HuMo-gen update V3.1</td><td style="background-color:#00FF00">'.$language["index_update"].'<br>';
		$db_update = mysql_query("CREATE TABLE humo_stambomen_tekst (
			tekst_id smallint(5) unsigned NOT NULL auto_increment,
			stamboom_id smallint(5),
			taal varchar(100),
			stamboom_naam varchar(100),
			hoofdmenu_tekst text,
			hoofdmenu_bron text,
			gezin_kop text,
			gezin_voet text,
			PRIMARY KEY  (`tekst_id`)
			)") or die(mysql_error());
		// *** Nieuwe controle ***
		$controle_update2 = mysql_query("SELECT * FROM humo_stambomen_tekst",$db);
		if ($controle_update2){
			echo $language["index_update_ok"];
		}
		else{
			echo $language["index_update_failed"];
		}
		
		// TABEL VULLEN
		// UPDATE PROCEDURE VOOR STAMBOOM TEKSTEN
		$datasql = mysql_query("SELECT * FROM humo_stambomen ORDER BY volgorde",$db);
		if ($datasql){
			// *** Aantal regels in querie ***
			//$aantal=mysql_num_rows($datasql);
			while ($dataDb=mysql_fetch_object($datasql)){
				$sql="INSERT INTO humo_stambomen_tekst SET
				stamboom_id='".$dataDb->id."',
				taal='talen/taal-nederlands.php',
				stamboom_naam='".$dataDb->naam."',
				hoofdmenu_tekst='".$dataDb->tekst."',
				hoofdmenu_bron='".$dataDb->bron."',
				gezin_kop='Gezinsblad'
				";
				$db = mysql_query($sql) or die(mysql_error());
			}
		}
		echo '</td></tr>';

		// *** Update 1 completed ***
		$_SESSION['save_humo_update']=1;
	}

	// ********************************
	// *** HuMo-gen update 2 (V3.2) ***
	// ********************************
	$controle_update = mysql_query("SELECT * FROM humo_stat_datum",$db);
	if ($controle_update){
		if ($humo_update==1) { $humo_update=2; }
	}
	if ($humo_update>1){
		echo '<tr><td>HuMo-gen update V3.2</td><td style="background-color:#00FF00">OK</td></tr>';
	}
	else{
		echo '<tr><td>HuMo-gen update V3.2</td><td style="background-color:#00FF00">'.$language["index_update"].'<br>';
		$db_update = mysql_query("CREATE TABLE humo_stat_datum (
			id int(10) NOT NULL auto_increment,
			samengesteld_id varchar(100) NOT NULL,
			ip_adres varchar(20) NOT NULL,
			stamboom_id varchar(5) NOT NULL,
			gedcom_gezin varchar(20) NOT NULL,
			gedcom_man varchar(20) NOT NULL,
			gedcom_vrouw varchar(20) NOT NULL,
			datum_stat datetime NOT NULL,
			datum_linux varchar(50) NOT NULL,
			PRIMARY KEY  (`id`)
		)") or die(mysql_error());

		// *** Nieuwe controle ***
		$controle_update2 = mysql_query("SELECT * FROM humo_stat_datum",$db);
		if ($controle_update2){
			echo $language["index_update_ok"];
		}
		else{
			echo $language["index_update_failed"];
		}
		echo '</td></tr>';

		// *** Update 2 completed ***
		$_SESSION['save_humo_update']=2;
	}

	// *********************************
	// *** HuMo-gen update 3 (V 4.3) ***
	// *********************************
	if ($humo_update>2){
		echo '<tr><td>HuMo-gen update V4.2</td><td style="background-color:#00FF00">OK</td></tr>';
	}
	else{
		echo '<tr><td>HuMo-gen update V3.2</td><td style="background-color:#00FF00">'.$language["index_update"].'<br>';

		$sql='UPDATE humo_stambomen_tekst SET taal="nl" WHERE taal="talen/taal-nederlands.php"';
		$result=mysql_query($sql) or die(mysql_error());

		$sql='UPDATE humo_stambomen_tekst SET taal="de" WHERE taal="talen/taal-deutsch.php"';
		$result=mysql_query($sql) or die(mysql_error());

		$sql='UPDATE humo_stambomen_tekst SET taal="en" WHERE taal="talen/taal-english.php"';
		$result=mysql_query($sql) or die(mysql_error());

		$sql='UPDATE humo_stambomen_tekst SET taal="fr" WHERE taal="talen/taal-francais.php"';
		$result=mysql_query($sql) or die(mysql_error());

		$sql='UPDATE humo_instellingen SET waarde="nl" WHERE waarde="languages/nederlands.php"';
		$result=mysql_query($sql) or die(mysql_error());

		$sql='UPDATE humo_instellingen SET waarde="en" WHERE waarde="languages/english.php"';
		$result=mysql_query($sql) or die(mysql_error());

		$sql='UPDATE humo_instellingen SET waarde="en" WHERE waarde="talen/taal-english.php"';
		$result=mysql_query($sql) or die(mysql_error());

		$sql='UPDATE humo_instellingen SET waarde="de" WHERE waarde="talen/taal-deutsch.php"';
		$result=mysql_query($sql) or die(mysql_error());

		$sql='UPDATE humo_instellingen SET waarde="fr" WHERE waarde="talen/taal-francais.php"';
		$result=mysql_query($sql) or die(mysql_error());

		$sql='UPDATE humo_instellingen SET waarde="nl" WHERE waarde="talen/taal-nederlands.php"';
		$result=mysql_query($sql) or die(mysql_error());

		echo '</td></tr>';

		// *** Update 3 completed ***
		$_SESSION['save_humo_update']=3;
	}



	// ********************************
	// *** HuMo-gen update 4 (V4.6) ***
	// ********************************

	$update_check_sql = mysql_query("SELECT * FROM humo_instellingen",$db);
	if ($update_check_sql){
		echo '<tr><td>HuMo-gen update V4.6 - 1</td><td style="background-color:#00FF00">'.$language["index_update"].'</td></tr>';

		// *** Translate dutch table name into english ***
		$sql='ALTER TABLE humo_instellingen RENAME humo_settings';
		$update_Db = mysql_query($sql);

		$sql='ALTER TABLE humo_settings
			CHANGE id setting_id smallint(5) unsigned NOT NULL auto_increment,
			CHANGE variabele setting_variabele varchar(50) CHARACTER SET utf8,
			CHANGE waarde setting_value text CHARACTER SET utf8
			';
		$update_Db = mysql_query($sql) or die(mysql_error());

		// *** Update 4 completed ***
		$_SESSION['save_humo_update']=4;
	}
	else{
		echo '<tr><td>HuMo-gen update V4.6 - 1</td><td style="background-color:#00FF00">OK</td></tr>';
	}


	$update_check_sql = mysql_query("SELECT * FROM humo_stambomen",$db);
	if ($update_check_sql){
		// *** Translate dutch table name into english ***
		$sql='ALTER TABLE humo_stambomen RENAME humo_trees';
		$update_Db = mysql_query($sql);

		$sql='ALTER TABLE humo_trees
			CHANGE id tree_id smallint(5) unsigned NOT NULL auto_increment,
			CHANGE volgorde tree_order smallint(5),
			CHANGE voorvoegsel tree_prefix varchar(10) CHARACTER SET utf8,
			CHANGE datum tree_date varchar(20) CHARACTER SET utf8,
			CHANGE personen tree_persons varchar(10) CHARACTER SET utf8,
			CHANGE gezinnen tree_families varchar(10) CHARACTER SET utf8,
			CHANGE email tree_email varchar(100) CHARACTER SET utf8,
			CHANGE eigenaar tree_owner varchar(100) CHARACTER SET utf8,
			CHANGE afbpad tree_pict_path varchar(100) CHARACTER SET utf8,
			CHANGE privacy_stamboom tree_privacy varchar(100) CHARACTER SET utf8
			';
		$update_Db = mysql_query($sql) or die(mysql_error());
	}

	$update_check_sql = mysql_query("SELECT * FROM humo_stambomen_tekst",$db);
	if ($update_check_sql){
		// *** Translate dutch table name into english ***
		$sql='ALTER TABLE humo_stambomen_tekst RENAME humo_tree_texts';
		$update_Db = mysql_query($sql);

		$sql='ALTER TABLE humo_tree_texts
			CHANGE tekst_id treetext_id smallint(5) unsigned NOT NULL auto_increment,
			CHANGE stamboom_id treetext_tree_id smallint(5),
			CHANGE taal treetext_language varchar(100) CHARACTER SET utf8,
			CHANGE stamboom_naam treetext_name varchar(100) CHARACTER SET utf8,
			CHANGE hoofdmenu_tekst treetext_mainmenu_text text CHARACTER SET utf8,
			CHANGE hoofdmenu_bron treetext_mainmenu_source text CHARACTER SET utf8,
			CHANGE gezin_kop treetext_family_top text CHARACTER SET utf8,
			CHANGE gezin_voet treetext_family_footer text CHARACTER SET utf8
			';
		$update_Db = mysql_query($sql) or die(mysql_error());
	}

	$update_check_sql = mysql_query("SELECT * FROM humo_stat_datum",$db);
	if ($update_check_sql){

//NEW
		// *** Automatic installation or update datafield stat_user_agent ***
		$tabel_controleDb=mysql_fetch_object($update_check_sql);
		if (!isset($tabel_controleDb->stat_user_agent)){
			$sql="ALTER TABLE humo_stat_datum
			ADD stat_user_agent VARCHAR( 255 ) NOT NULL;";
			$result=mysql_query($sql) or die(mysql_error());
		}

		// *** Translate dutch table name into english ***
		$sql='ALTER TABLE humo_stat_datum RENAME humo_stat_date';
		$update_Db = mysql_query($sql);

		$sql='ALTER TABLE humo_stat_date
			CHANGE id stat_id int(10) NOT NULL auto_increment,
			CHANGE samengesteld_id stat_easy_id varchar(100) CHARACTER SET utf8,
			CHANGE ip_adres stat_ip_address varchar(20) CHARACTER SET utf8,
			CHANGE stat_user_agent stat_user_agent varchar(255) CHARACTER SET utf8,
			CHANGE stamboom_id stat_tree_id varchar(5) CHARACTER SET utf8,
			CHANGE gedcom_gezin stat_gedcom_fam varchar(20) CHARACTER SET utf8,
			CHANGE gedcom_man stat_gedcom_man varchar(20) CHARACTER SET utf8,
			CHANGE gedcom_vrouw stat_gedcom_woman varchar(20) CHARACTER SET utf8,
			CHANGE datum_stat stat_date_stat datetime NOT NULL,
			CHANGE datum_linux stat_date_linux varchar(50) CHARACTER SET utf8
			';
		$update_Db = mysql_query($sql) or die(mysql_error());

		// Update of other tables, in this check.
		// so it's possible to rerun the update procedure...

		//update groups	
//NEW
		$groepsql="SELECT * FROM humo_groups";
		$groepresult=mysql_query($groepsql,$db);
		$groepDb=mysql_fetch_object($groepresult);
		// *** Automatic installation or update ***
		if (!isset($groepDb->group_editor)){
			$sql_update="ALTER TABLE `humo_groups` ADD `group_editor` VARCHAR( 1 ) NOT NULL DEFAULT 'n';";
			$result=mysql_query($sql_update) or die(mysql_error());
		}
		
		$sql='ALTER TABLE humo_groups
			CHANGE id group_id smallint(5) unsigned NOT NULL auto_increment,
			CHANGE groepsnaam group_name varchar(25) CHARACTER SET utf8,
			CHANGE privacy group_privacy varchar(1) CHARACTER SET utf8,
			CHANGE plaatsen group_menu_places varchar(1) CHARACTER SET utf8,
			CHANGE beheer group_admin varchar(1) CHARACTER SET utf8,
			CHANGE bronnen group_sources varchar(1) CHARACTER SET utf8,
			CHANGE afbeeldingen group_pictures varchar(1) CHARACTER SET utf8,
			CHANGE gedcomnummer group_gedcomnr varchar(1) CHARACTER SET utf8,
			CHANGE woonplaats group_living_place varchar(1) CHARACTER SET utf8,
			CHANGE plaats group_places varchar(1) CHARACTER SET utf8,
			CHANGE religie group_religion varchar(1) CHARACTER SET utf8,
			CHANGE plaatsdatum group_place_date varchar(1) CHARACTER SET utf8,
			CHANGE soortindex group_kindindex varchar(1) CHARACTER SET utf8,
			CHANGE gebeurtenis group_event varchar(1) CHARACTER SET utf8,
			CHANGE adressen group_addresses varchar(1) CHARACTER SET utf8,
			CHANGE eigencode group_own_code varchar(1) CHARACTER SET utf8,
			CHANGE werktekst group_work_text varchar(1) CHARACTER SET utf8,
			CHANGE teksten group_texts varchar(1) CHARACTER SET utf8,
			CHANGE tekstpersoon group_text_pers varchar(1) CHARACTER SET utf8,
			CHANGE tekstpersgeg group_texts_pers varchar(1) CHARACTER SET utf8,
			CHANGE tekstgezgeg group_texts_fam varchar(1) CHARACTER SET utf8,
			CHANGE levend group_alive varchar(1) CHARACTER SET utf8,
			CHANGE levenddatum group_alive_date_act varchar(1) CHARACTER SET utf8,
			CHANGE levenddatum2 group_alive_date varchar(4) CHARACTER SET utf8,
			CHANGE filterovl group_filter_death varchar(1) CHARACTER SET utf8,
			CHANGE filtertotaal group_filter_total varchar(1) CHARACTER SET utf8,
			CHANGE filternaam group_filter_name varchar(1) CHARACTER SET utf8,
			CHANGE gezinfilter group_filter_fam varchar(1) CHARACTER SET utf8,
			CHANGE persoonfilter group_filter_pers_show_act varchar(1) CHARACTER SET utf8,
			CHANGE filterkarakter group_filter_pers_show varchar(50) CHARACTER SET utf8,
			CHANGE persoonfilter2 group_filter_pers_hide_act varchar(1) CHARACTER SET utf8,
			CHANGE filterkarakter2 group_filter_pers_hide varchar(50) CHARACTER SET utf8,
			CHANGE group_editor group_editor varchar(1) CHARACTER SET utf8 NOT NULL DEFAULT \'n\',
			CHANGE group_statistics group_save_statistics varchar(1) CHARACTER SET utf8 NOT NULL DEFAULT \'j\',
			CHANGE verjaardagen_rss group_birthday_rss varchar(1) CHARACTER SET utf8 NOT NULL DEFAULT \'j\',
			CHANGE verjaardagen_lijst group_birthday_list varchar(1) CHARACTER SET utf8 NOT NULL DEFAULT \'j\',
			CHANGE filterdatum group_filter_date varchar(1) CHARACTER SET utf8 NOT NULL DEFAULT \'n\',
			CHANGE gen_protection group_gen_protection varchar(1) CHARACTER SET utf8 NOT NULL DEFAULT \'n\',
			CHANGE persoonfilter3 group_pers_hide_totally_act varchar(1) CHARACTER SET utf8 NOT NULL DEFAULT \'n\',
			CHANGE filterkarakter3 group_pers_hide_totally varchar(50) CHARACTER SET utf8 NOT NULL DEFAULT \'X\',
			CHANGE photobook group_photobook varchar(1) CHARACTER SET utf8 NOT NULL DEFAULT \'n\',
			CHANGE hide_trees group_hide_trees varchar(200) CHARACTER SET utf8 NOT NULL DEFAULT \'\'
		';
		$update_Db = mysql_query($sql) or die(mysql_error());

		//update users
		$sql='ALTER TABLE humo_users
			CHANGE id user_id smallint(5) NOT NULL auto_increment,
			CHANGE username user_name varchar(25) CHARACTER SET utf8,
			CHANGE paswoord user_password varchar(50) CHARACTER SET utf8,
			CHANGE groeps_id user_group_id varchar(1) CHARACTER SET utf8
			';
		$update_Db = mysql_query($sql) or die(mysql_error());
	}


	$update_check_sql = mysql_query("SELECT * FROM humo_logboek",$db);
	if ($update_check_sql){
		// *** Translate dutch table name into english ***
		$sql='ALTER TABLE humo_logboek RENAME humo_user_log';
		$update_Db = mysql_query($sql);

		$sql='ALTER TABLE humo_user_log
			CHANGE username log_username varchar(25) CHARACTER SET utf8,
			CHANGE datum log_date varchar(20) CHARACTER SET utf8
			';
		$update_Db = mysql_query($sql) or die(mysql_error());
	}

	//if ($controle_update2){
	//	echo $language["index_update_ok"];
	//}
	//else{
	//	echo $language["index_update_failed"];
	//}
	//echo '</td></tr>';


	echo '<tr><td>HuMo-gen update V4.6 - 2</td><td style="background-color:#00FF00">'.$language["index_update"].'<br>';

	// *** Read all family trees from database ***
	$update_sql = mysql_query("SELECT * FROM humo_trees
		WHERE tree_prefix!='LEEG' ORDER BY tree_order",$db);
	while ($updateDb=mysql_fetch_object($update_sql)){

	echo '<b>UPDATE: '.$updateDb->tree_prefix.'</b><br>';

	// *** Rename old tables, rename fields, convert html to utf-8 ***
	$update_check_sql = mysql_query("SELECT * FROM ".$updateDb->tree_prefix."persoon",$db);
	if ($update_check_sql){

		// *** Translate dutch table name into english ***
		$sql='ALTER TABLE '.$updateDb->tree_prefix.'persoon
			RENAME '.$updateDb->tree_prefix.'person';
		$update_Db = mysql_query($sql) or die(mysql_error());

		// *** Translate dutch table name into english ***
		$sql='ALTER TABLE '.$updateDb->tree_prefix.'gezin
			RENAME '.$updateDb->tree_prefix.'family';
		$update_Db = mysql_query($sql) or die(mysql_error());

		// *** Convert tables into utf-8 ***
		//$sql="SHOW TABLES";
		$get_tables = mysql_query("SHOW TABLES");
		while($x = mysql_fetch_array($get_tables)) {
			if (substr($x[0],0,strlen($updateDb->tree_prefix))==$updateDb->tree_prefix){
				// *** Change table into UTF-8 ***
				$update_char='ALTER TABLE '.$x[0].' DEFAULT CHARACTER SET utf8';
				$update_charDb = mysql_query($update_char) or die(mysql_error());
			}
		}

		$sql='ALTER TABLE '.$updateDb->tree_prefix. 'person
			CHANGE id pers_id	mediumint(6) unsigned NOT NULL auto_increment,
			CHANGE gedcomnummer pers_gedcomnumber	varchar(20) CHARACTER SET utf8,
			CHANGE voorvoegsel pers_tree_prefix	varchar(10) CHARACTER SET utf8,
			CHANGE famc pers_famc varchar(50) CHARACTER SET utf8,
			CHANGE fams pers_fams varchar(100) CHARACTER SET utf8,
			CHANGE indexnr pers_indexnr varchar(20) CHARACTER SET utf8,
			CHANGE indexdoop pers_index_bapt text CHARACTER SET utf8,
			CHANGE indexovl pers_index_death text CHARACTER SET utf8,
			CHANGE voornaam pers_firstname varchar(50) CHARACTER SET utf8,
			CHANGE roepnaam pers_callname varchar(50) CHARACTER SET utf8,
			CHANGE voorzetsel pers_prefix varchar(20) CHARACTER SET utf8,
			CHANGE achternaam pers_lastname varchar(50) CHARACTER SET utf8,
			CHANGE patroniem pers_patronym varchar(50) CHARACTER SET utf8,
			CHANGE naamtekst pers_name_text text CHARACTER SET utf8,
			CHANGE naambron pers_name_source text CHARACTER SET utf8,
			CHANGE sexe pers_sexe varchar(1) CHARACTER SET utf8,
			CHANGE eigencode pers_own_code varchar(100) CHARACTER SET utf8,
			CHANGE geboorteplaats pers_birth_place varchar(50) CHARACTER SET utf8,
			CHANGE geboortedatum pers_birth_date varchar(35) CHARACTER SET utf8,
			CHANGE geboortetijd pers_birth_time varchar(25) CHARACTER SET utf8,
			CHANGE geboortetekst pers_birth_text text CHARACTER SET utf8,
			CHANGE geboortebron pers_birth_source text CHARACTER SET utf8,
			CHANGE doopplaats pers_bapt_place varchar(50) CHARACTER SET utf8,
			CHANGE doopdatum pers_bapt_date varchar(35) CHARACTER SET utf8,
			CHANGE dooptekst pers_bapt_text text CHARACTER SET utf8,
			CHANGE doopbron pers_bapt_source text CHARACTER SET utf8,
			CHANGE religie pers_religion varchar(50) CHARACTER SET utf8,
			CHANGE overlijdensplaats pers_death_place varchar(50) CHARACTER SET utf8,
			CHANGE overlijdensdatum pers_death_date varchar(35) CHARACTER SET utf8,
			CHANGE overlijdenstijd pers_death_time varchar(25) CHARACTER SET utf8,
			CHANGE overlijdenstekst pers_death_text text CHARACTER SET utf8,
			CHANGE overlijdensbron pers_death_source text CHARACTER SET utf8,
			CHANGE oorzaak pers_death_cause varchar(50) CHARACTER SET utf8,
			CHANGE begrafenisplaats pers_buried_place varchar(50) CHARACTER SET utf8,
			CHANGE begrafenisdatum pers_buried_date varchar(35) CHARACTER SET utf8,
			CHANGE begrafenistekst pers_buried_text text CHARACTER SET utf8,
			CHANGE begrafenisbron pers_buried_source text CHARACTER SET utf8,
			CHANGE crematie pers_cremation varchar(1) CHARACTER SET utf8,
			CHANGE plaatsindex pers_place_index text CHARACTER SET utf8,
			CHANGE tekst pers_text text CHARACTER SET utf8,
			CHANGE person_text_source pers_text_source text CHARACTER SET utf8,
			CHANGE levend pers_alive varchar(20) CHARACTER SET utf8,
			CHANGE person_favorite pers_favorite varchar(1) CHARACTER SET utf8,
			CHANGE person_new_date pers_new_date varchar(35) CHARACTER SET utf8,
			CHANGE person_new_time pers_new_time varchar(25) CHARACTER SET utf8,
			CHANGE person_changed_date pers_changed_date varchar(35) CHARACTER SET utf8,
			CHANGE person_changed_time pers_changed_time varchar(25) CHARACTER SET utf8
			';
		$update_Db = mysql_query($sql) or die(mysql_error());
		//$update.=$sql.'<br>';

		$sql='ALTER TABLE '.$updateDb->tree_prefix. 'family
			CHANGE id fam_id	mediumint(6) unsigned NOT NULL auto_increment,
			CHANGE gedcomnummer fam_gedcomnumber varchar(20) CHARACTER SET utf8,
			CHANGE man fam_man varchar(20) CHARACTER SET utf8,
			CHANGE vrouw fam_woman varchar(20) CHARACTER SET utf8,
			CHANGE kinderen fam_children text CHARACTER SET utf8,
			CHANGE soort fam_kind varchar(50) CHARACTER SET utf8,
			CHANGE samendatum fam_relation_date varchar(35) CHARACTER SET utf8,
			CHANGE samenplaats fam_relation_place varchar(50) CHARACTER SET utf8,
			CHANGE samentekst fam_relation_text text CHARACTER SET utf8,
			CHANGE samenbron fam_relation_source text CHARACTER SET utf8,
			CHANGE einddatum fam_relation_end_date varchar(35) CHARACTER SET utf8,
			CHANGE ondertrdatum fam_marr_notice_date varchar(35) CHARACTER SET utf8,
			CHANGE ondertrplaats fam_marr_notice_place varchar(50) CHARACTER SET utf8,
			CHANGE ondertrtekst fam_marr_notice_text text CHARACTER SET utf8,
			CHANGE ondertrbron fam_marr_notice_source text CHARACTER SET utf8,
			CHANGE trdatum fam_marr_date varchar(35) CHARACTER SET utf8,
			CHANGE trplaats fam_marr_place varchar(50) CHARACTER SET utf8,
			CHANGE trtekst fam_marr_text text CHARACTER SET utf8,
			CHANGE trbron fam_marr_source text CHARACTER SET utf8,
			CHANGE trinstantie fam_marr_authority text CHARACTER SET utf8,
			CHANGE kerkondertrdatum fam_marr_church_notice_date varchar(35) CHARACTER SET utf8,
			CHANGE kerkondertrplaats fam_marr_church_notice_place varchar(50) CHARACTER SET utf8,
			CHANGE kerkondertrtekst fam_marr_church_notice_text text CHARACTER SET utf8,
			CHANGE kerkondertrbron fam_marr_church_notice_source text CHARACTER SET utf8,
			CHANGE kerktrdatum fam_marr_church_date varchar(35) CHARACTER SET utf8,
			CHANGE kerktrplaats fam_marr_church_place varchar(50) CHARACTER SET utf8,
			CHANGE kerktrtekst fam_marr_church_text text CHARACTER SET utf8,
			CHANGE kerktrbron fam_marr_church_source text CHARACTER SET utf8,
			CHANGE religie fam_religion varchar(50) CHARACTER SET utf8,
			CHANGE scheidingsdatum fam_div_date varchar(35) CHARACTER SET utf8,
			CHANGE scheidingsplaats fam_div_place varchar(50) CHARACTER SET utf8,
			CHANGE scheidingstekst fam_div_text text CHARACTER SET utf8,
			CHANGE scheidingsbron fam_div_source text CHARACTER SET utf8,
			CHANGE scheidingsinstantie fam_div_authority text CHARACTER SET utf8,
			CHANGE huwtekst fam_text text CHARACTER SET utf8,
			CHANGE family_text_source fam_text_source text CHARACTER SET utf8,
			CHANGE levend fam_alive int(1),
			CHANGE teller fam_counter mediumint(8),
			CHANGE family_new_date fam_new_date varchar(35) CHARACTER SET utf8,
			CHANGE family_new_time fam_new_time varchar(25) CHARACTER SET utf8,
			CHANGE family_changed_date fam_changed_date varchar(35) CHARACTER SET utf8,
			CHANGE family_changed_time fam_changed_time varchar(25) CHARACTER SET utf8
			';
		@$update_Db = mysql_query($sql) or die(mysql_error());
		//$update.=$sql.'<br>';

		$sql='ALTER TABLE '.$updateDb->tree_prefix. 'texts
			CHANGE text_gedcomnr text_gedcomnr varchar(20) CHARACTER SET utf8,
			CHANGE text_text text_text text CHARACTER SET utf8,
			CHANGE text_new_date text_new_date varchar(35) CHARACTER SET utf8,
			CHANGE text_new_time text_new_time varchar(25) CHARACTER SET utf8,
			CHANGE text_changed_date text_changed_date varchar(35) CHARACTER SET utf8,
			CHANGE text_changed_time text_changed_time varchar(25) CHARACTER SET utf8
			';
		@$update_Db = mysql_query($sql) or die(mysql_error());
		//$update.=$sql.'<br>';

		$sql='ALTER TABLE '.$updateDb->tree_prefix. 'sources
			CHANGE source_gedcomnr source_gedcomnr varchar(20) CHARACTER SET utf8,
			CHANGE source_title source_title text CHARACTER SET utf8,
			CHANGE source_abbr source_abbr varchar(50) CHARACTER SET utf8,
			CHANGE source_date source_date varchar(35) CHARACTER SET utf8,
			CHANGE source_publ source_publ varchar(150) CHARACTER SET utf8,
			CHANGE source_place source_place varchar(50) CHARACTER SET utf8,
			CHANGE source_refn source_refn varchar(50) CHARACTER SET utf8,
			CHANGE source_auth source_auth varchar(50) CHARACTER SET utf8,
			CHANGE source_subj source_subj varchar(50) CHARACTER SET utf8,
			CHANGE source_item source_item varchar(30) CHARACTER SET utf8,
			CHANGE source_kind source_kind varchar(50) CHARACTER SET utf8,
			CHANGE source_text source_text text CHARACTER SET utf8,
			CHANGE source_photo source_photo text CHARACTER SET utf8,
			CHANGE source_repo_name source_repo_name varchar(50) CHARACTER SET utf8,
			CHANGE source_repo_caln source_repo_caln varchar(50) CHARACTER SET utf8,
			CHANGE source_repo_page source_repo_page varchar(50) CHARACTER SET utf8,
			CHANGE source_new_date source_new_date varchar(35) CHARACTER SET utf8,
			CHANGE source_new_time source_new_time varchar(25) CHARACTER SET utf8,
			CHANGE source_changed_date source_changed_date varchar(35) CHARACTER SET utf8,
			CHANGE source_changed_time source_changed_time varchar(25) CHARACTER SET utf8
			';
		@$update_Db = mysql_query($sql) or die(mysql_error());
		//$update.=$sql.'<br>';

		$sql='ALTER TABLE '.$updateDb->tree_prefix. 'addresses
			CHANGE address_gedcomnr address_gedcomnr varchar(20) CHARACTER SET utf8,
			CHANGE address_person_id address_person_id varchar(20) CHARACTER SET utf8,
			CHANGE address_family_id address_family_id varchar(20) CHARACTER SET utf8,
			CHANGE address_address address_address text CHARACTER SET utf8,
			CHANGE address_zip address_zip varchar(20) CHARACTER SET utf8,
			CHANGE address_place address_place varchar(50) CHARACTER SET utf8,
			CHANGE address_phone address_phone varchar(20) CHARACTER SET utf8,
			CHANGE address_date address_date varchar(35) CHARACTER SET utf8,
			CHANGE address_source address_source text CHARACTER SET utf8,
			CHANGE address_text address_text text CHARACTER SET utf8,
			CHANGE address_photo address_photo text CHARACTER SET utf8,
			CHANGE address_new_date address_new_date varchar(35) CHARACTER SET utf8,
			CHANGE address_new_time address_new_time varchar(25) CHARACTER SET utf8,
			CHANGE address_changed_date address_changed_date varchar(35) CHARACTER SET utf8,
			CHANGE address_changed_time address_changed_time varchar(25) CHARACTER SET utf8
			';
		@$update_Db = mysql_query($sql) or die(mysql_error());

		$sql='ALTER TABLE '.$updateDb->tree_prefix. 'events
			CHANGE event_person_id event_person_id varchar(20) CHARACTER SET utf8,
			CHANGE event_family_id event_family_id varchar(20) CHARACTER SET utf8,
			CHANGE event_kind event_kind varchar(20) CHARACTER SET utf8,
			CHANGE event_event event_event text CHARACTER SET utf8,
			CHANGE event_gedcom event_gedcom varchar(10) CHARACTER SET utf8,
			CHANGE event_date event_date varchar(35) CHARACTER SET utf8,
			CHANGE event_place event_place varchar(50) CHARACTER SET utf8,
			CHANGE event_source event_source text CHARACTER SET utf8,
			CHANGE event_text event_text text CHARACTER SET utf8,
			CHANGE event_new_date event_new_date varchar(35) CHARACTER SET utf8,
			CHANGE event_new_time event_new_time varchar(25) CHARACTER SET utf8,
			CHANGE event_changed_date event_changed_date varchar(35) CHARACTER SET utf8,
			CHANGE event_changed_time event_changed_time varchar(25) CHARACTER SET utf8	
			';
		@$update_Db = mysql_query($sql) or die(mysql_error());

}



		// *** Update person table (html to utf-8) ***
		$read_pers_sql = mysql_query("SELECT * FROM ".$updateDb->tree_prefix."person",$db);
		while ($read_persDb=mysql_fetch_object($read_pers_sql)){
			$sql='UPDATE '.$updateDb->tree_prefix.'person SET
				pers_index_bapt="'.veilig($read_persDb->pers_index_bapt).'",
				pers_index_death="'.veilig($read_persDb->pers_index_death).'",
				pers_firstname="'.veilig($read_persDb->pers_firstname).'",
				pers_callname="'.veilig($read_persDb->pers_callname).'",
				pers_prefix="'.veilig($read_persDb->pers_prefix).'",
				pers_lastname="'.veilig($read_persDb->pers_lastname).'",
				pers_patronym="'.veilig($read_persDb->pers_patronym).'",
				pers_name_text="'.veilig($read_persDb->pers_name_text).'",
				pers_name_source="'.veilig($read_persDb->pers_name_source).'",
				pers_own_code="'.veilig($read_persDb->pers_own_code).'",
				pers_birth_place="'.veilig($read_persDb->pers_birth_place).'",
				pers_birth_text="'.veilig($read_persDb->pers_birth_text).'",
				pers_birth_source="'.veilig($read_persDb->pers_birth_source).'",
				pers_bapt_place="'.veilig($read_persDb->pers_bapt_place).'",
				pers_bapt_text="'.veilig($read_persDb->pers_bapt_text).'",
				pers_bapt_source="'.veilig($read_persDb->pers_bapt_source).'",
				pers_religion="'.veilig($read_persDb->pers_religion).'",
				pers_death_place="'.veilig($read_persDb->pers_death_place).'",
				pers_death_text="'.veilig($read_persDb->pers_death_text).'",
				pers_death_source="'.veilig($read_persDb->pers_death_source).'",
				pers_death_cause="'.veilig($read_persDb->pers_death_cause).'",
				pers_buried_place="'.veilig($read_persDb->pers_buried_place).'",
				pers_buried_text="'.veilig($read_persDb->pers_buried_text).'",
				pers_buried_source="'.veilig($read_persDb->pers_buried_source).'",
				pers_place_index="'.veilig($read_persDb->pers_place_index).'",
				pers_text="'.veilig($read_persDb->pers_text).'",
				pers_text_source="'.veilig($read_persDb->pers_text_source).'"
				WHERE pers_id="'.$read_persDb->pers_id.'"';
			//$sql = html_entity_decode($sql, ENT_QUOTES, 'UTF-8');
			$sql = html_entity_decode($sql, ENT_NOQUOTES, 'UTF-8');
			//$sql = str_replace("<br>\n", "\n", $sql);
			$sql = str_replace("<br>", "", $sql);

			//$update.=$sql.'<br>';
//echo $sql.'<br>';
			$update_Db = mysql_query($sql,$db) or die(mysql_error());
		}

		// *** Update family table (html to utf-8) ***
		$read_pers_sql = mysql_query("SELECT * FROM ".$updateDb->tree_prefix."family",$db);
		while ($read_persDb=mysql_fetch_object($read_pers_sql)){
			$sql='UPDATE '.$updateDb->tree_prefix.'family SET
				fam_id="'.$read_persDb->fam_id.'",
				fam_relation_place="'.veilig($read_persDb->fam_relation_place).'",
				fam_relation_text="'.veilig($read_persDb->fam_relation_text).'",
				fam_relation_source="'.veilig($read_persDb->fam_relation_source).'",
				fam_marr_notice_place="'.veilig($read_persDb->fam_marr_notice_place).'",
				fam_marr_notice_text="'.veilig($read_persDb->fam_marr_notice_text).'",
				fam_marr_notice_source="'.veilig($read_persDb->fam_marr_notice_source).'",
				fam_marr_place="'.veilig($read_persDb->fam_marr_place).'",
				fam_marr_text="'.veilig($read_persDb->fam_marr_text).'",
				fam_marr_source="'.veilig($read_persDb->fam_marr_source).'",
				fam_marr_authority="'.veilig($read_persDb->fam_marr_authority).'",
				fam_marr_church_notice_place="'.veilig($read_persDb->fam_marr_church_notice_place).'",
				fam_marr_church_notice_text="'.veilig($read_persDb->fam_marr_church_notice_text).'",
				fam_marr_church_notice_source="'.veilig($read_persDb->fam_marr_church_notice_source).'",
				fam_marr_church_place="'.veilig($read_persDb->fam_marr_church_place).'",
				fam_marr_church_text="'.veilig($read_persDb->fam_marr_church_text).'",
				fam_marr_church_source="'.veilig($read_persDb->fam_marr_church_source).'",
				fam_religion="'.veilig($read_persDb->fam_religion).'",
				fam_div_place="'.veilig($read_persDb->fam_div_place).'",
				fam_div_text="'.veilig($read_persDb->fam_div_text).'",
				fam_div_source="'.veilig($read_persDb->fam_div_source).'",
				fam_div_authority="'.veilig($read_persDb->fam_div_authority).'",
				fam_text="'.veilig($read_persDb->fam_text).'",
				fam_text_source="'.veilig($read_persDb->fam_text_source).'"
				WHERE fam_id="'.$read_persDb->fam_id.'"';
			//$sql = html_entity_decode($sql, ENT_QUOTES, 'UTF-8');
			$sql = html_entity_decode($sql, ENT_NOQUOTES, 'UTF-8');
			//$sql = str_replace("<br>\n", "\n", $sql);
			$sql = str_replace("<br>", "", $sql);
			//$update.=$sql.'<br>';
			$update_Db = mysql_query($sql,$db) or die(mysql_error());
		}

		// *** Update text table (html to utf-8) ***
		$read_pers_sql = mysql_query("SELECT * FROM ".$updateDb->tree_prefix."texts",$db);
		while ($read_persDb=mysql_fetch_object($read_pers_sql)){
			$sql='UPDATE '.$updateDb->tree_prefix.'texts SET
				text_text="'.veilig($read_persDb->text_text).'"
				WHERE text_id="'.$read_persDb->text_id.'"';
			//$sql = html_entity_decode($sql, ENT_QUOTES, 'UTF-8');
			$sql = html_entity_decode($sql, ENT_NOQUOTES, 'UTF-8');
			//$sql = str_replace("<br>\n", "\n", $sql);
			$sql = str_replace("<br>", "", $sql);
			//$update.=$sql.'<br>';
			$update_Db = mysql_query($sql,$db) or die(mysql_error());
		}

		// *** Update source table (html to utf-8) ***
		$read_pers_sql = mysql_query("SELECT * FROM ".$updateDb->tree_prefix."sources",$db);
		while ($read_persDb=mysql_fetch_object($read_pers_sql)){
			$sql='UPDATE '.$updateDb->tree_prefix.'sources SET
				source_title="'.veilig($read_persDb->source_title).'",
				source_abbr="'.veilig($read_persDb->source_abbr).'",
				source_publ="'.veilig($read_persDb->source_publ).'",
				source_place="'.veilig($read_persDb->source_place).'",
				source_refn="'.veilig($read_persDb->source_refn).'",
				source_auth="'.veilig($read_persDb->source_auth).'",
				source_subj="'.veilig($read_persDb->source_subj).'",
				source_item="'.veilig($read_persDb->source_item).'",
				source_kind="'.veilig($read_persDb->source_kind).'",
				source_text="'.veilig($read_persDb->source_text).'",
				source_repo_name="'.veilig($read_persDb->source_repo_name).'",
				source_repo_caln="'.veilig($read_persDb->source_repo_caln).'",
				source_repo_page="'.veilig($read_persDb->source_repo_page).'"
				WHERE source_id="'.$read_persDb->source_id.'"';
			//$sql = html_entity_decode($sql, ENT_QUOTES, 'UTF-8');
			$sql = html_entity_decode($sql, ENT_NOQUOTES, 'UTF-8');
			//$sql = str_replace("<br>\n", "\n", $sql);
			$sql = str_replace("<br>", "", $sql);
			//$update.=$sql.'<br>';
			$update_Db = mysql_query($sql,$db) or die(mysql_error());
		}


		// *** Update address table (html to utf-8) ***
		$read_pers_sql = mysql_query("SELECT * FROM ".$updateDb->tree_prefix."addresses",$db);
		while ($read_persDb=mysql_fetch_object($read_pers_sql)){
			$sql='UPDATE '.$updateDb->tree_prefix.'addresses SET
				address_address="'.veilig($read_persDb->address_address).'",
				address_zip="'.veilig($read_persDb->address_zip).'",
				address_place="'.veilig($read_persDb->address_place).'",
				address_phone="'.veilig($read_persDb->address_phone).'",
				address_date="'.veilig($read_persDb->address_date).'",
				address_source="'.veilig($read_persDb->address_source).'",
				address_text="'.veilig($read_persDb->address_text).'",
				address_photo="'.veilig($read_persDb->address_photo).'"	
				WHERE address_id="'.$read_persDb->address_id.'"';
			//$sql = html_entity_decode($sql, ENT_QUOTES, 'UTF-8');
			$sql = html_entity_decode($sql, ENT_NOQUOTES, 'UTF-8');
			//$sql = str_replace("<br>\n", "\n", $sql);
			$sql = str_replace("<br>", "", $sql);
			//$update.=$sql.'<br>';
			$update_Db = mysql_query($sql,$db) or die(mysql_error());
		}

		// *** Update event table (html to utf-8) ***
		$read_pers_sql = mysql_query("SELECT * FROM ".$updateDb->tree_prefix."events",$db);
		while ($read_persDb=mysql_fetch_object($read_pers_sql)){
			$sql='UPDATE '.$updateDb->tree_prefix.'events SET
				event_person_id="'.veilig($read_persDb->event_person_id).'",
				event_family_id="'.veilig($read_persDb->event_family_id).'",
				event_kind="'.veilig($read_persDb->event_kind).'",
				event_event="'.veilig($read_persDb->event_event).'",
				event_gedcom="'.veilig($read_persDb->event_gedcom).'",
				event_date="'.veilig($read_persDb->event_date).'",
				event_place="'.veilig($read_persDb->event_place).'",
				event_source="'.veilig($read_persDb->event_source).'",
				event_text="'.veilig($read_persDb->event_text).'"
				WHERE event_id="'.$read_persDb->event_id.'"';
			//$sql = html_entity_decode($sql, ENT_QUOTES, 'UTF-8');
			$sql = html_entity_decode($sql, ENT_NOQUOTES, 'UTF-8');
			//$sql = str_replace("<br>\n", "\n", $sql);
			$sql = str_replace("<br>", "", $sql);
			//$update.=$sql.'<br>';
			$update_Db = mysql_query($sql,$db) or die(mysql_error());
		}

//	} // *** End of tabel check ***
	} // End of reading family trees ***

	echo '</td></tr>';

	echo '<table><br>';

	echo 'Update voltooid. / Update completed.';
	
	// *** END OF UPDATE PROCEDURES *******************************************************
}
?>
Return current item: HuMo-gen