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

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

//THIS FILE IS MADE BY Huub Mons
//IT IS PART OF THE HuMo-php PROGRAMM.

require ($cms['cms_path'].'include/database_name.php');

// *** Stambomen beheer ***
if (isset($_POST['wijzigen'])){
	$sql="UPDATE humo_trees SET
	tree_email='".veilig($_POST['email'])."',
	tree_owner='".veilig($_POST['eigenaar'])."',
	tree_pict_path='".veilig($_POST['afbpad'])."',
	tree_privacy='".veilig($_POST['privacy_stamboom'])."'
	WHERE tree_id=".veilig($_POST['stamboom_id']);
	$result=mysql_query($sql) or die(mysql_error());
}

if (isset($_POST['wijzig_teksten'])){
	$sql="UPDATE humo_tree_texts SET
	treetext_tree_id='".veilig($_POST['stamboom_id'])."',
	treetext_language='".veilig($_POST['language_tree'])."',
	treetext_name='".veilig($_POST['treetext_name'])."',
	treetext_mainmenu_text='".veilig($_POST['treetext_mainmenu_text'])."',
	treetext_mainmenu_source='".veilig($_POST['treetext_mainmenu_source'])."',
	treetext_family_top='".veilig($_POST['treetext_family_top'])."',
	treetext_family_footer='".veilig($_POST['treetext_family_footer'])."'
	WHERE treetext_id=".veilig($_POST['tekst_id']);
	$result=mysql_query($sql) or die(mysql_error());
}

if (isset($_POST['toevoegen'])){
	$sql="INSERT INTO humo_trees SET
	tree_order='".veilig($_POST['volgorde'])."',
	tree_prefix='".veilig($_POST['tree_prefix'])."',
	tree_persons='0',
	tree_families='0',
	tree_email='',
	tree_privacy='',
	tree_pict_path='../plaatjes/'
	";
	$result=mysql_query($sql) or die(mysql_error());
}

if (isset($_POST['toevoegen_leeg'])){
	$sql="INSERT INTO humo_trees SET
	tree_order='".veilig($_POST['volgorde'])."',
	tree_prefix='LEEG',
	tree_persons='LEEG',
	tree_families='LEEG',
	tree_email='LEEG',
	tree_privacy='LEEG',
	tree_pict_path='LEEG'
	";
	$result=mysql_query($sql) or die(mysql_error());
}

if (isset($_POST['toevoegen_teksten'])){
	$sql="INSERT INTO humo_tree_texts SET
	treetext_tree_id='".veilig($_POST['stamboom_id'])."',
	treetext_language='".veilig($_POST['language_tree'])."',
	treetext_name='".veilig($_POST['treetext_name'])."',
	treetext_mainmenu_text='".veilig($_POST['treetext_mainmenu_text'])."',
	treetext_mainmenu_source='".veilig($_POST['treetext_mainmenu_source'])."',
	treetext_family_top='".veilig($_POST['treetext_family_top'])."',
	treetext_family_footer='".veilig($_POST['treetext_family_footer'])."'";
	$result=mysql_query($sql) or die(mysql_error());
}

if (isset($_GET['verwijder'])){
	echo '<div class="confirm">';
	echo '<b>'.$language["trees_selected"].' '.$_GET['treetext_name'].'</b> ';
	echo $language["trees_removetree"];
	echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'" style="display : inline;">';
	echo '<input type="hidden" name="page" value="'.$page.'">';
	echo '<input type="hidden" name="stamboom_id" value="'.$_GET['verwijder'].'">';
	echo ' <input type="Submit" name="verwijderen2" 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>';
	echo '</div>';
}
if (isset($_POST['verwijderen2'])){
	$wisqry='SELECT * FROM humo_trees WHERE tree_id="'.veilig($_POST['stamboom_id']).'"';
	@$wissql = mysql_query($wisqry,$db);
	@$wisDb=mysql_fetch_object($wissql);
	$wis=$wisDb->tree_prefix;

	// *** Volgorde herstellen van de hogere stambomen ***
	$herstel_volgorde=$wisDb->tree_order;
	$item=mysql_query("SELECT * FROM humo_trees WHERE tree_order>".$herstel_volgorde,$db);
	while($itemDb=mysql_fetch_object($item)){
		$sql="UPDATE humo_trees SET tree_order='".($itemDb->tree_order-1)."' WHERE tree_id=".$itemDb->tree_id;
		$result=mysql_query($sql) or die(mysql_error());
	}

	$sql="DROP TABLE ".$wis."person"; @$result=mysql_query($sql);
	$sql="DROP TABLE ".$wis."family"; @$result=mysql_query($sql);
	$sql="DROP TABLE ".$wis."texts"; @$result=mysql_query($sql);
	$sql="DROP TABLE ".$wis."sources"; @$result=mysql_query($sql);
	$sql="DROP TABLE ".$wis."addresses"; @$result=mysql_query($sql);
	$sql="DROP TABLE ".$wis."events"; @$result=mysql_query($sql);

	$sql="DELETE FROM humo_trees WHERE tree_id='".veilig($_POST['stamboom_id'])."'";
	$result=mysql_query($sql) or die(mysql_error());
	
	// *** Hier ook de desbetreffende items uit de tabel stambomen_tekst verwijderen. ***
	$sql="DELETE FROM humo_tree_texts WHERE treetext_tree_id='".veilig($_POST['stamboom_id'])."'";
	$result=mysql_query($sql) or die(mysql_error());

	// *** Ook de bijbehorende statistieken verwijderen ***
	$sql="DELETE FROM humo_stat_date WHERE stat_tree_id='".veilig($_POST['stamboom_id'])."'";
	$result=mysql_query($sql) or die(mysql_error());
	
	unset ($_POST['stamboom_id']);
}

if (isset($_GET['up'])){
	//vorige database zoeken
	$item=mysql_query("SELECT * FROM humo_trees WHERE tree_order=".($_GET['volgorde']-1),$db);
	$itemDb=mysql_fetch_object($item);
	//voorgaande database verhogen:
	$sql="UPDATE humo_trees SET tree_order='".veilig($_GET['volgorde'])."' WHERE tree_id=$itemDb->tree_id";
	$result=mysql_query($sql);
	//database verlagen
	$sql="UPDATE humo_trees SET tree_order='".($_GET['volgorde']-1)."' WHERE tree_id=".$_GET['id'];
	$result=mysql_query($sql) or die(mysql_error());
}
if (isset($_GET['down'])){
	//volgende database zoeken
	$item=mysql_query("SELECT * FROM humo_trees WHERE tree_order=".($_GET['volgorde']+1),$db);
	$itemDb=mysql_fetch_object($item);
	//voorgaande database verlagen:
	$sql="UPDATE humo_trees SET tree_order='".veilig($_GET['volgorde'])."' WHERE tree_id=$itemDb->tree_id";
	$result=mysql_query($sql);
	//database verhogen
	$sql="UPDATE humo_trees SET tree_order='".($_GET['volgorde']+1)."' WHERE tree_id=".$_GET['id'];
	$result=mysql_query($sql) or die(mysql_error());
}

// ***************************************************************
// *** Start weergave ***
// ***************************************************************

// *** Talen in array zetten en taalkeuze. ***
// *** Taal Nederlands vooraan zetten als ***
if (file_exists($cms['cms_path'].'languages/nl/language.php')){ $language_file[]='nl'; }
$map=opendir($cms['cms_path'].'languages/');
while (false!==($file = readdir($map))) {
	if (strlen($file)<5 AND $file!='.' AND $file!='..'){
		// *** Nederlands is vooraan gezet ***
		if ($file!='nl'){
			$language_file[]=$file;
		}
	}
}
closedir($map);

$language_tree='nl';
//if (isset($_POST['language_tree'])){ $language_tree=$_POST['language_tree']; }
if (isset($_GET['language_tree'])){ $language_tree=$_GET['language_tree']; }

include ("trees_cls.php");
$tree_cls = New tree_cls;

// *** Selected family tree ***
if (isset($_POST['toevoegen'])){
	// *** Select new family tree if a new family tree is added ***
	$data2sql = mysql_query("SELECT * FROM humo_trees ORDER BY tree_order DESC LIMIT 0,1",$db);
}
else{
	$data2sql = mysql_query("SELECT * FROM humo_trees ORDER BY tree_order LIMIT 0,1",$db);
}
$data2Db=mysql_fetch_object($data2sql);
if ($data2Db){
	$stamboom_id=$data2Db->tree_id;
}
if (isset($_POST['stamboom_id'])){ $stamboom_id=$_POST['stamboom_id']; }
if (isset($_GET['stamboom_id'])){ $stamboom_id=$_GET['stamboom_id']; }
//if (isset($_POST['admin_tree_id'])){ $stamboom_id=$_POST['admin_tree_id']; }
//if (isset($_GET['stamboom_id'])){ $stamboom_id=$_GET['stamboom_id']; }

// ************************************************
// *** Teksten van geselecteerde taal weergeven ***
// ************************************************

$data2sql = mysql_query("SELECT * FROM humo_tree_texts where
	treetext_tree_id='".$stamboom_id."' AND treetext_language='".$language_tree."'",$db);
$data2Db=mysql_fetch_object($data2sql);
if ($data2Db){
	$tekst_id=$data2Db->treetext_id;
	$treetext_name=$data2Db->treetext_name;
	$treetext_mainmenu_text=$data2Db->treetext_mainmenu_text;
	$treetext_mainmenu_source=$data2Db->treetext_mainmenu_source;
	$treetext_family_top=$data2Db->treetext_family_top;
	$treetext_family_footer=$data2Db->treetext_family_footer;
}
else{
	$treetext_name=$language["main_tree_no_name"];
	$treetext_mainmenu_text='';
	$treetext_mainmenu_source='';
	//$treetext_family_top='Gezinsblad';
	$treetext_family_top='';
	$treetext_family_footer='';
}

$menu_admin='tree_main';
if (isset($_POST['menu_admin'])){ $menu_admin=$_POST['menu_admin']; }
if (isset($_GET['menu_admin'])){ $menu_admin=$_GET['menu_admin']; }

// *** Select family tree ***
$tree_prefix_sql = "SELECT * FROM humo_trees WHERE tree_prefix!='LEEG' ORDER BY tree_order";
$tree_prefix_result = mysql_query($tree_prefix_sql,$db);
echo $language["editor_tree"].': ';
echo '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" style="display : inline;">';
echo '<input type="hidden" name="page" value="'.$page.'">';
echo '<select size="1" name="stamboom_id">';
	while ($tree_prefixDb=mysql_fetch_object($tree_prefix_result)){
		$selected='';
		if ($tree_prefixDb->tree_id==$stamboom_id){ $selected=' SELECTED'; }
		$treetext_name2=database_name($tree_prefixDb->tree_prefix, $Taalkeuze);
		echo '<option value="'.$tree_prefixDb->tree_id.'"'.$selected.'>'.@$treetext_name2.'</option>';
	}
echo '</select>';
echo ' <input type="Submit" name="submit" value="'.$language["admin_select"].'">';
echo '</form>';

/*
// *** Select family tree ***
$tree_prefix_sql = "SELECT * FROM humo_trees WHERE tree_prefix!='LEEG' ORDER BY tree_order";
$tree_prefix_result = mysql_query($tree_prefix_sql,$db);
$treetext_name3='';
echo $language["editor_tree"].': ';
echo '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" style="display : inline;">';
echo '<input type="hidden" name="page" value="'.$page.'">';
echo '<select size="1" name="stamboom_id">';
	while ($tree_prefixDb=mysql_fetch_object($tree_prefix_result)){
		$treetext_name2=database_name($tree_prefixDb->tree_prefix, $Taalkeuze);
		$selected='';
		if ($tree_prefixDb->tree_id==$stamboom_id){
			$selected=' SELECTED';
			$treetext_name3=$treetext_name2;
		}
		echo '<option value="'.$tree_prefixDb->tree_id.'"'.$selected.'>'.@$treetext_name2.'</option>';
	}
echo '</select>';
echo ' <input type="Submit" name="submit" value="'.$language["admin_select"].'">';
echo "</form>\n";
*/
//echo '&nbsp;<h3 style="display : inline; color: red;">'.$language["trees_selected"].' '.$treetext_name3.'</h3>';

//tree_selection_form($page);

echo '<div id="tree_menu">';
echo '<ul>';
	$selecteer=''; if ($menu_admin=='tree_main'){ $selecteer=' id="current"'; }
	echo '<li'.$selecteer.'><a href="index.php?page='.$page.'&amp;stamboom_id='.$stamboom_id.'">'.$language["trees_name"]."</a></li>";

	$data2sql = mysql_query("SELECT * FROM humo_trees WHERE tree_id=".$stamboom_id,$db);
	$data2Db=mysql_fetch_object($data2sql);

	// *** Gedcom bestand inlezen ***
	$selecteer=''; if ($menu_admin=='tree_gedcom'){ $selecteer=' id="current"'; }
	echo '<li'.$selecteer.'><a href="index.php?page='.$page.'&amp;menu_admin=tree_gedcom&amp;stamboom_id='.$stamboom_id.'&amp;tree_prefix='.$data2Db->tree_prefix.'&amp;stap1=read_gedcom">'.$language["trees_readgedcom"]."</a></li>";

	// *** Stamboom gegevens ***
		$selecteer=''; if ($menu_admin=='tree_data'){ $selecteer=' id="current"'; }
	echo '<li'.$selecteer.'><a href="index.php?page='.$page.'&amp;menu_admin=tree_data'.'&amp;stamboom_id='.$stamboom_id.'">'.$language["trees_treedata"]."</a></li>";

	// *** Stamboom teksten ***
	$selecteer=''; if ($menu_admin=='tree_text'){ $selecteer=' id="current"'; }
	echo '<li'.$selecteer.'><a href="index.php?page='.$page.'&amp;menu_admin=tree_text&amp;stamboom_id='.$stamboom_id.'">'.$language["trees_treetext"]."</a></li>";

echo '</ul>';

//echo '&nbsp;<h3 style="display : inline; color: red;">'.$language["trees_selected"].' '.$treetext_name.'</h3>';

echo '</div>';
// *** Align content to the left ***
echo '<div style="float: left;">';

// *** Show main tree screen ***
if (isset($menu_admin) AND $menu_admin=='tree_main'){
	$tree_cls->tree_main();
}

// *** Show main tree screen ***
if (isset($menu_admin) AND $menu_admin=='tree_gedcom'){
	//$tree_cls->tree_main();
	include ("gedcom.php");
}

// ***************************************************************************************
// *** Geselecteerde stamboom weergeven                                                ***
// ***************************************************************************************
// *** Moet op deze plaats om de radio button meteen goed weer te geven na wijzigen. ***
// include("../include/settings_global.php"); //Variabelen

$data2sql = mysql_query("SELECT * FROM humo_trees WHERE tree_id=".$stamboom_id,$db);
$data2Db=mysql_fetch_object($data2sql);

$languagekeuze='talen/taal-nederlands.php';
if (isset($_POST['taalkeuze'])){ $languagekeuze=$_POST['taalkeuze']; }

// *** Show tree data ***
if ($menu_admin=='tree_data'){
	$tree_cls->tree_data();
}

// *** Show tree text ***
if ($menu_admin=='tree_text'){
	$tree_cls->tree_text();
}

echo '</div>'; // *** div voor menu ***
?>
Return current item: HuMo-gen