Location: PHPKode > projects > HuMo-gen > admin/include/install.php
<?php
// *** Safety line ***
if (!defined('ADMIN_PAGE')){ exit; }

echo '<h1 align=center>'.$language["install_name"].'</h1>';

echo $language["install_tables"];

if ($cms['cms_name']=='Joomla'){
	$path_tmp='index.php?option=com_humo-gen&amp;task=admin&amp;page=install';
}
else{
	$path_tmp=$_SERVER['PHP_SELF'];
}

if (isset($_POST['tabellen_installeren'])){
	echo '<form method="post" action="'.$path_tmp.'" style="display : inline;">';
	echo '<input type="hidden" name="page" value="'.$page.'">';

	$check=''; if (isset($_POST["instellingentabel"])){ $check=' checked'; }
	print '<p><input type="checkbox" name="instellingentabel" '.$check.'> '.$language["install_new_setting"].'<br>';
	$check=''; if (isset($_POST["stambomentabel"])){ $check=' checked'; }
	print '<input type="checkbox" name="stambomentabel" '.$check.'> '.$language["install_new_tree"].'<br>';
	$check=''; if (isset($_POST["stattabel"])){ $check=' checked'; }
	print '<input type="checkbox" name="stattabel" '.$check.'> '.$language["install_new_stat"].'<br>';
	$check=''; if (isset($_POST["gebruikerstabel"])){ $check=' checked'; }
	print '<input type="checkbox" name="gebruikerstabel" '.$check.'> '.$language["install_new_user"].'<br>';
	$check=''; if (isset($_POST["groepstabel"])){ $check=' checked'; }
	print '<input type="checkbox" name="groepstabel" '.$check.'> '.$language["install_new_group"].'<br>';
	$check=''; if (isset($_POST["logboektabel"])){ $check=' checked'; }
	print '<input type="checkbox" name="logboektabel" '.$check.'> '.$language["install_new_log"].'<br>';
	print '<p><b>'.$language["install_new_confirm"].'</b><br>';

	echo '<p>'.$language["install_new_button"].' ';
	echo '<input type="Submit" name="tabellen_installeren2" value="'.$language["admin_yes"].'" style="color : red; font-weight: bold;">';
	echo ' <input type="Submit" name="submit" value="'.$language["admin_no"].'" style="color : blue; font-weight: bold;">';
	echo '</form>';
}
elseif(!isset($_POST['tabellen_installeren2'])){
	print '<form method="post" action="'.$path_tmp.'">';
	echo '<input type="hidden" name="page" value="'.$page.'">';

	print '<p><input type="checkbox" name="instellingentabel" checked> '.$language["install_new_setting"].'<br>';
	print '<input type="checkbox" name="stambomentabel" checked> '.$language["install_new_tree"].'<br>';
	print '<input type="checkbox" name="stattabel" checked> '.$language["install_new_stat"].'<br>';
	print '<input type="checkbox" name="gebruikerstabel" checked> '.$language["install_new_user"].'<br>';
	print '<input type="checkbox" name="groepstabel" checked> '.$language["install_new_group"].'<br>';
	print '<input type="checkbox" name="logboektabel" checked> '.$language["install_new_log"].'<br>';
	print '<p><b>'.$language["install_new_confirm"].'</b><br>';
	print '<p><input type="Submit" name="tabellen_installeren" value='.$language["install_new_button"].'>';
	print "</form>";
}

if (isset($_POST['tabellen_installeren2'])){

	// *** Controleren welke tabellen aanwezig zijn, bij $waarde=1 wordt tabel overschreven ***
	$instellingentabel="1";
	$stambomentabel="1";
	$stattabel="1";
	$usertabel="1";
	$logboektabel="1";
	$grouptabel="1";

	/*
	// *** Lijst tabellen in database ***
	$qry = mysql_query("SELECT DATABASE()") or die(mysql_error());
	$test=mysql_result($qry,0);
	$result = mysql_list_tables($test);
	while ($row = mysql_fetch_row($result)) {
	*/

	$query = mysql_query("SHOW TABLES");
	while($row = mysql_fetch_array($query)){
		if ($row[0]=='humo_settings'){ $instellingentabel=""; }
		if ($row[0]=='humo_trees'){ $stambomentabel=""; }
		if ($row[0]=='humo_stat_date'){ $stattabel=""; }
		if ($row[0]=='humo_users'){ $usertabel=""; }
		if ($row[0]=='humo_user_log'){ $logboektabel=""; }
		if ($row[0]=='humo_groups'){ $grouptabel=""; }
	}

	if (isset($_POST["instellingentabel"])){ $instellingentabel='1'; }  //Optie instellingentabel toch opnieuw maken!
	if (isset($_POST["stambomentabel"])){ $stambomentabel='1'; }  //Optie stambomentabel toch opnieuw maken!
	if (isset($_POST["stattabel"])){ $stattabel='1'; }  //Optie stattabel toch opnieuw maken!
	if (isset($_POST["gebruikerstabel"])){ $usertabel='1'; }  //Optie gebruikerstabel toch opnieuw maken!
	if (isset($_POST["groepstabel"])){ $grouptabel='1'; }  //Optie groepstabel toch opnieuw maken!
	if (isset($_POST["logboektabel"])){ $logboektabel='1'; }  //Optie logboektabel toch opnieuw maken!
	
	//mysql_free_result($result);
	
	//*********************************************************************
	print '<p><b>'.$language["install_create_tables"].'</b><br>';
	
	if ($instellingentabel){
		$db_update = mysql_query("DROP TABLE humo_settings"); //Tabel volledig verwijderen.
		// *** Tabel opnieuw maken, handiger voor updates... ***
		print $language["install_create_settings"].'<br>';
		$db_update = mysql_query("CREATE TABLE humo_settings (
			setting_id smallint(5) unsigned NOT NULL auto_increment,
			setting_variabele varchar(50) CHARACTER SET utf8,
			setting_value text CHARACTER SET utf8,
			PRIMARY KEY (`setting_id`)
			) DEFAULT CHARSET=utf8") or die(mysql_error());
	
		print $language["install_fill_settings"].'<br>';
	
		$db_update = mysql_query("INSERT INTO humo_settings (setting_variabele,setting_value) values ('database_naam','Web Site')") or die(mysql_error());
		$db_update = mysql_query("INSERT INTO humo_settings (setting_variabele,setting_value) values ('homepage','http://www.humo-gen.huubmons.nl')") or die(mysql_error());
		$db_update = mysql_query("INSERT INTO humo_settings (setting_variabele,setting_value) values ('homepage_omschrijving','Website')") or die(mysql_error());
		$db_update = mysql_query("INSERT INTO humo_settings (setting_variabele,setting_value) values ('zoekmachine','n')") or die(mysql_error());
		$db_update = mysql_query("INSERT INTO humo_settings (setting_variabele,setting_value) values ('optierobots','<META NAME=\"robots\" CONTENT=\"noindex,nofollow\">')") or die(mysql_error());
	}
	
	if ($stambomentabel){
		$db_update = mysql_query("DROP TABLE humo_trees"); //Tabel volledig verwijderen.
		// *** Nieuwe tabel aanmaken ***
		print $language["install_create_trees"].'<br>';
	
		$db_update = mysql_query("CREATE TABLE humo_trees (
			tree_id smallint(5) unsigned NOT NULL auto_increment,
			tree_order smallint(5),
			tree_prefix varchar(10) CHARACTER SET utf8,
			tree_date varchar(20) CHARACTER SET utf8,
			tree_persons varchar(10) CHARACTER SET utf8,
			tree_families varchar(10) CHARACTER SET utf8,
			tree_email varchar(100) CHARACTER SET utf8,
			tree_owner varchar(100) CHARACTER SET utf8,
			tree_pict_path varchar (100) CHARACTER SET utf8,
			tree_privacy varchar (100) CHARACTER SET utf8,
			PRIMARY KEY  (`tree_id`)
			) DEFAULT CHARSET=utf8") or die(mysql_error());
	
		$datum=date("Y-m-d H:i");
		$sql="INSERT INTO humo_trees
		SET
		tree_order='1',
		tree_prefix='humo_',
		tree_date='".$datum."',
		tree_persons='0',
		tree_families='0',
		tree_email='',
		tree_owner='',
		tree_pict_path='../plaatjes/',
		tree_privacy=''
		";
		$db_update = mysql_query($sql) or die(mysql_error());
	
		$db_update = mysql_query("DROP TABLE humo_tree_texts"); //Tabel volledig verwijderen.
		// *** Nieuwe tabel aanmaken ***
		print $language["install_create_trees"].'<br>';
		$db_update = mysql_query("CREATE TABLE humo_tree_texts (
			treetext_id smallint(5) unsigned NOT NULL auto_increment,
			treetext_tree_id smallint(5),
			treetext_language varchar(100) CHARACTER SET utf8,
			treetext_name varchar(100) CHARACTER SET utf8,
			treetext_mainmenu_text text CHARACTER SET utf8,
			treetext_mainmenu_source text CHARACTER SET utf8,
			treetext_family_top text CHARACTER SET utf8,
			treetext_family_footer text CHARACTER SET utf8,
			PRIMARY KEY  (`treetext_id`)
			) DEFAULT CHARSET=utf8") or die(mysql_error());
	}
	
	if ($stattabel){
		$db_update = mysql_query("DROP TABLE humo_stat_date"); //Tabel volledig verwijderen.
		// *** Nieuwe tabel aanmaken ***
		print $language["install_create_stats"].'<br>';
	
		$db_update = mysql_query("CREATE TABLE humo_stat_date (
			stat_id int(10) NOT NULL auto_increment,
			stat_easy_id varchar(100) CHARACTER SET utf8,
			stat_ip_address varchar(20) CHARACTER SET utf8,
			stat_user_agent varchar(255) CHARACTER SET utf8,
			stat_tree_id varchar(5) CHARACTER SET utf8,
			stat_gedcom_fam varchar(20) CHARACTER SET utf8,
			stat_gedcom_man varchar(20) CHARACTER SET utf8,
			stat_gedcom_woman varchar(20) CHARACTER SET utf8,
			stat_date_stat datetime NOT NULL,
			stat_date_linux varchar(50) CHARACTER SET utf8,
			PRIMARY KEY (`stat_id`)
		) DEFAULT CHARSET=utf8") or die(mysql_error());
	}
	
	if ($grouptabel){
		$db_update = mysql_query("DROP TABLE humo_groups"); //Tabel volledig verwijderen.
		// *** Tabel opnieuw maken, handiger voor updates... ***
		print $language["install_create_groups"].'<br>';
		$db_update = mysql_query("CREATE TABLE humo_groups (
			group_id smallint(5) unsigned NOT NULL auto_increment,
			group_name varchar(25) CHARACTER SET utf8,
			group_privacy varchar(1) CHARACTER SET utf8,
			group_menu_places varchar(1) CHARACTER SET utf8,
			group_admin varchar(1) CHARACTER SET utf8,
			group_sources varchar(1) CHARACTER SET utf8,
			group_pictures varchar(1) CHARACTER SET utf8,
			group_gedcomnr varchar(1) CHARACTER SET utf8,
			group_living_place varchar(1) CHARACTER SET utf8,
			group_places varchar(1) CHARACTER SET utf8,
			group_religion varchar(1) CHARACTER SET utf8,
			group_place_date varchar(1) CHARACTER SET utf8,
			group_kindindex varchar(1) CHARACTER SET utf8,
			group_event varchar(1) CHARACTER SET utf8,
			group_addresses varchar(1) CHARACTER SET utf8,
			group_own_code varchar(1) CHARACTER SET utf8,
			group_work_text varchar(1) CHARACTER SET utf8,
			group_texts varchar(1) CHARACTER SET utf8,
			group_text_pers varchar(1) CHARACTER SET utf8,
			group_texts_pers varchar(1) CHARACTER SET utf8,
			group_texts_fam varchar(1) CHARACTER SET utf8,
			group_alive varchar(1) CHARACTER SET utf8,
			group_alive_date_act varchar(1) CHARACTER SET utf8,
			group_alive_date varchar(4) CHARACTER SET utf8,
			group_filter_death varchar(1) CHARACTER SET utf8,
			group_filter_total varchar(1) CHARACTER SET utf8,
			group_filter_name varchar(1) CHARACTER SET utf8,
			group_filter_fam varchar(1) CHARACTER SET utf8,
			group_filter_pers_show_act varchar(1) CHARACTER SET utf8,
			group_filter_pers_show varchar(50) CHARACTER SET utf8,
			group_filter_pers_hide_act varchar(1) CHARACTER SET utf8,
			group_filter_pers_hide varchar(50) CHARACTER SET utf8,
			PRIMARY KEY  (`group_id`)
			) DEFAULT CHARSET=utf8") or die(mysql_error());
	
		print $language["install_fill_groups"].'<br>';
	
		$sql="INSERT INTO humo_groups SET group_name='beheer', group_privacy='j', group_menu_places='j', group_admin='j'";
		$sql="$sql, group_sources='j', group_pictures='j', group_gedcomnr='j', group_living_place='j', group_places='j', group_religion='j'";
		$sql="$sql, group_place_date='n', group_kindindex='n', group_event='j', group_addresses='j', group_own_code='j', group_work_text='j'";
		$sql="$sql, group_texts='j', group_text_pers='j', group_texts_pers='j', group_texts_fam='j', group_alive='n', group_alive_date_act='n'";
		$sql="$sql, group_alive_date='1920', group_filter_death='n', group_filter_total='n', group_filter_name='j', group_filter_fam='j', group_filter_pers_show_act='j'";
		$sql="$sql, group_filter_pers_show='*', group_filter_pers_hide_act='n', group_filter_pers_hide='#'";
		$db_update = mysql_query($sql) or die(mysql_error());
	
		$sql="INSERT INTO humo_groups SET group_name='familie', group_privacy='n', group_menu_places='n', group_admin='n'";
		$sql="$sql, group_sources='n', group_pictures='n', group_gedcomnr='n', group_living_place='j', group_places='j', group_religion='n'";
		$sql="$sql, group_place_date='n', group_kindindex='n', group_event='j', group_addresses='j', group_own_code='j', group_work_text='j'";
		$sql="$sql, group_texts='j', group_text_pers='j', group_texts_pers='j', group_texts_fam='j', group_alive='n', group_alive_date_act='n'";
		$sql="$sql, group_alive_date='1920', group_filter_death='n', group_filter_total='n', group_filter_name='j', group_filter_fam='j', group_filter_pers_show_act='j'";
		$sql="$sql, group_filter_pers_show='*', group_filter_pers_hide_act='n', group_filter_pers_hide='#'";
		$db_update = mysql_query($sql) or die(mysql_error());
	
		$sql="INSERT INTO humo_groups SET group_name='gast', group_privacy='n', group_menu_places='n', group_admin='n'";
		$sql="$sql, group_sources='n', group_pictures='n', group_gedcomnr='n', group_living_place='n', group_places='j', group_religion='n'";
		$sql="$sql, group_place_date='n', group_kindindex='n', group_event='n', group_addresses='n', group_own_code='n', group_work_text='n'";
		$sql="$sql, group_texts='j', group_text_pers='j', group_texts_pers='j', group_texts_fam='j', group_alive='n', group_alive_date_act='j'";
		$sql="$sql, group_alive_date='1920', group_filter_death='n', group_filter_total='n', group_filter_name='j', group_filter_fam='j', group_filter_pers_show_act='j'";
		$sql="$sql, group_filter_pers_show='*', group_filter_pers_hide_act='n', group_filter_pers_hide='#'";
		$db_update = mysql_query($sql) or die(mysql_error());
	
		$sql="INSERT INTO humo_groups SET group_name='groep 4', group_privacy='n', group_menu_places='n', group_admin='n'";
		$sql="$sql, group_sources='n', group_pictures='n', group_gedcomnr='n', group_living_place='n', group_places='j', group_religion='n'";
		$sql="$sql, group_place_date='n', group_kindindex='n', group_event='n', group_addresses='n', group_own_code='n', group_work_text='n'";
		$sql="$sql, group_texts='j', group_text_pers='j', group_texts_pers='j', group_texts_fam='j', group_alive='n', group_alive_date_act='j'";
		$sql="$sql, group_alive_date='1920', group_filter_death='n', group_filter_total='n', group_filter_name='j', group_filter_fam='j', group_filter_pers_show_act='j'";
		$sql="$sql, group_filter_pers_show='*', group_filter_pers_hide_act='n', group_filter_pers_hide='#'";
		$db_update = mysql_query($sql) or die(mysql_error());
	
		$sql="INSERT INTO humo_groups SET group_name='groep 5', group_privacy='j', group_menu_places='n', group_admin='n'";
		$sql="$sql, group_sources='n', group_pictures='n', group_gedcomnr='n', group_living_place='n', group_places='j', group_religion='n'";
		$sql="$sql, group_place_date='n', group_kindindex='n', group_event='n', group_addresses='n', group_own_code='n', group_work_text='n'";
		$sql="$sql, group_texts='j', group_text_pers='j', group_texts_pers='j', group_texts_fam='j', group_alive='n', group_alive_date_act='j'";
		$sql="$sql, group_alive_date='1920', group_filter_death='n', group_filter_total='n', group_filter_name='j', group_filter_fam='j', group_filter_pers_show_act='j'";
		$sql="$sql, group_filter_pers_show='*', group_filter_pers_hide_act='n', group_filter_pers_hide='#'";
		$db_update = mysql_query($sql) or die(mysql_error());
	
		$sql="INSERT INTO humo_groups SET group_name='groep 6', group_privacy='n', group_menu_places='n', group_admin='n'";
		$sql="$sql, group_sources='n', group_pictures='n', group_gedcomnr='n', group_living_place='n', group_places='j', group_religion='n'";
		$sql="$sql, group_place_date='n', group_kindindex='n', group_event='n', group_addresses='n', group_own_code='n', group_work_text='n'";
		$sql="$sql, group_texts='j', group_text_pers='j', group_texts_pers='j', group_texts_fam='j', group_alive='n', group_alive_date_act='j'";
		$sql="$sql, group_alive_date='1920', group_filter_death='n', group_filter_total='n', group_filter_name='j', group_filter_fam='j', group_filter_pers_show_act='j'";
		$sql="$sql, group_filter_pers_show='*', group_filter_pers_hide_act='n', group_filter_pers_hide='#'";
		$db_update = mysql_query($sql) or die(mysql_error());
	}
	
	if ($usertabel){
		$db_update = mysql_query("DROP TABLE humo_users"); //Tabel volledig verwijderen.
		// *** Tabel opnieuw maken, handiger voor updates... ***
		print $language["install_create_users"].'<br>';
		$db_update = mysql_query("CREATE TABLE humo_users (
			user_id smallint(5) unsigned NOT NULL auto_increment,
			user_name varchar(25) CHARACTER SET utf8,
			user_password varchar(50) CHARACTER SET utf8,
			user_group_id varchar(1),
			PRIMARY KEY  (`user_id`)
			) DEFAULT CHARSET=utf8") or die(mysql_error());
	
		print $language["install_fill_users"].'<br>';
		$db_update = mysql_query("INSERT INTO humo_users (user_name, user_password, user_group_id) values ('beheer','".md5('humogen')."','1')") or die(mysql_error());
		$db_update = mysql_query("INSERT INTO humo_users (user_name, user_password, user_group_id) values ('familie','".md5('humogen')."','2')") or die(mysql_error());
		$db_update = mysql_query("INSERT INTO humo_users (user_name, user_password, user_group_id) values ('gast','".md5('gast')."','3')") or die(mysql_error());
	}
	
	if ($logboektabel){
		$db_update = mysql_query("DROP TABLE humo_user_log"); //Tabel volledig verwijderen.
		// *** Tabel opnieuw maken, handiger voor updates... ***
		print $language["install_create_log"].'<br>';
		$db_update = mysql_query("CREATE TABLE humo_user_log (
			log_username varchar(25) CHARACTER SET utf8,
			log_date varchar(20) CHARACTER SET utf8
			) DEFAULT CHARSET=utf8") or die(mysql_error());
	}
	
	print '<b>'.$language["install_tables_made"].'</b><br>';
}
?>
Return current item: HuMo-gen