Location: PHPKode > projects > HuMo-gen > header.php
<?php
//error_reporting(E_ALL | E_STRICT);
//error_reporting(E_ALL);
//error_reporting(0);

// *** Check if HuMo-gen is in a CMS system ***
if (!isset($cms['cms'])){
	// *** In CMS system? ***	
	$cms['cms']=false;
}
if (!isset($cms['cms_name'])){
	// *** Name of CMS, made for CMS specific items. ***	
	$cms['cms_name']=''; 
}
if (!isset($cms['cms_path'])){
	// *** CMS path to HuMo-gen files ***
	$cms['cms_path']='';
}

ini_set('url_rewriter.tags','');

session_cache_limiter ('private, must-revalidate');
if (!$cms['cms']){
	session_start();
}

if (isset($_GET['uitloggen'])){
	if (isset($_SESSION["gebruikersnaam_admin"]) AND $_SESSION["gebruikersnaam_admin"]=="beheer") {
		// *** DO NOT REMOVE data if logged in as administrator! ***
		unset($_SESSION['gebruikersnaam']);
		unset($_SESSION['gebruikersid']);
		unset($_SESSION['groeps_id']);
		unset($_SESSION['tree_prefix']);
	}
	else{
		session_unset(); // alle variabelen vrijgeven
		session_destroy(); // sessie afsluiten
		session_write_close();
		session_start();
	}
}

//if (!$cms['cms']){
	include("include/db_login.php"); //Inloggen database.
//}

// *** Use UTF-8 database connection ***
mysql_query("SET NAMES 'utf8'", $db);

include ('include/database_name.php');

// *** Show a message at NEW installation. ***
$result = mysql_query("SELECT * FROM humo_settings",$db);
@$row = mysql_fetch_row($result) or die("Installatie van HuMo-gen is nog niet voltooid.<br>
Installation of HuMo-gen is not yet completed.");

include($cms['cms_path']."include/safe.php"); //Variabelen
include($cms['cms_path']."include/settings_global.php"); //Variabelen
include($cms['cms_path']."include/settings_user.php"); // USER variabelen

// *** Check if visitor is a bot or crawler ***
$bot_visit=preg_match('/bot|spider|crawler|curl|Yahoo|Google|^$/i', $_SERVER['HTTP_USER_AGENT']);
// *** Line for bot test! ***
// $bot_visit=true;

$map=opendir($cms['cms_path'].'languages/');
while (false!==($file = readdir($map))) {
	if (strlen($file)<5 AND $file!='.' AND $file!='..'){	
		$languagebestand[]=$file;

		// *** Save choice of language ***
		$languagekeuze='';
		if (isset($_POST["taalkeuze"])){ $languagekeuze=$_POST["taalkeuze"]; }
		if (isset($_GET["language"])){ $languagekeuze=$_GET["language"]; }

		if ($languagekeuze!=''){
			// Check if file exists (IMPORTANT DO NOT REMOVE THESE LINES)
			// ONLY save an existing language file.
			if ($languagekeuze==$file){ $_SESSION['Taal'] = $file; }
		}
	}
}
closedir($map);

include("languages/language.php"); //Taal

// *** Process LTR and RTL variables ***
$dirmark1="&#x200E;";  //ltr marker
$dirmark2="&#x200F;";  //rtl marker
$rtlmarker="ltr";
$alignmarker="left";
// *** Switch direction markers if language is RTL ***
if($language["dir"]=="rtl") {
	$dirmark1="&#x200F;";  //rtl marker
	$dirmark2="&#x200E;";  //ltr marker
	$rtlmarker="rtl";
	$alignmarker="right";
}
if(isset($screen_mode) AND $screen_mode=="PDF") {
	$dirmark1='';
	$dirmark2='';
}

// *** Log in ***
if (isset($_POST["username"]) && isset($_POST["paswoord"])){
	$query = "SELECT * FROM humo_users
	  WHERE user_name='" . veilig($_POST["username"]) ."'
	  AND user_password='".MD5(veilig($_POST["paswoord"]))."'";
	$result = mysql_query($query) or die("FOUT : " . mysql_error());
	if (mysql_num_rows($result) > 0){
		@$resultDb=mysql_fetch_object($result);
		$_SESSION['gebruikersnaam'] = veilig($_POST["username"]);
		$_SESSION['gebruikersid'] = $resultDb->user_id;
		$_SESSION['groeps_id'] = $resultDb->user_group_id;

		// Save log!
		$date=date("Y-m-d H:i");
		$sql="INSERT INTO humo_user_log SET log_date='$date', log_username='".veilig($_POST["username"])."'";
		mysql_query($sql, $db) or die(mysql_error());

		// *** Send to secured page ***
		//session_write_close();
		//header("Location: index.php?menukeuze=hoofdindex");
		if ($cms['cms_name']=='Joomla'){
			header("Location: index.php?option=com_humo-gen&amp;menukeuze=hoofdindex");	
		}
		else{
			header("Location: index.php?menukeuze=hoofdindex");	
		}

		exit();
	}
	else{
		// *** No valid user found ***
		$fout='<div class="centreren"><font color="red"><b>'.$language["main_no_valid_username"].'</b></font></div>';
	}
	//mysql_close($db);
}

// *** Page title ***
if ($kop=='database_naam'){
	$kop=$humo_option["database_naam"];
}
else{
	// *** Controleren of titel in het taalbestand staat ***
	if (isset($language[$kop])){
		$kop=$language[$kop];
	}
	else{
		$kop=$humo_option["database_naam"];
	}
}

// *** For PDF reports: remove html tags en decode ' characters ***
function pdf_convert($tekst){
	$tekst=html_entity_decode(strip_tags($tekst),ENT_QUOTES);
	$tekst=iconv("UTF-8","cp1252//IGNORE//TRANSLIT",$tekst);
	return $tekst;
}

// *** Don't generate a HTML header in a PDF report ***
if (isset($screen_mode) AND $screen_mode=='PDF'){
	require('fpdf16/fpdf.php');
	require('fpdf16/fpdfextend.php');
}
else{

	if (!$cms['cms']){
		// *** Generate header of HTML pages ***
		echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
		 "http://www.w3.org/TR/html4/loose.dtd">';

		//echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
		//      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
		//  <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">';

		//Validator fouten te voorkomen. Dit werkt niet goed. Alle & tekens in linken vervangen door &amp;
		//ini_set('arg_separator.output','&amp;');

		// ----------- changed by Dr Maleki ------------------ start
		$html_text="\n<html>\n";
		if($language["dir"]=="rtl") {   // right to left language
			$html_text="\n<html dir='rtl'>\n";
		}
		if (isset($screen_mode) AND ($screen_mode=="STAR" OR $screen_mode=="STARSIZE")){
			$html_text="\n<html>\n";
		}
		echo $html_text;

		print "<head>\n";
		echo '<meta http-equiv="content-type" content="text/html; charset=utf-8">'; //to support all of the unicode scripts.
		// --------------------------------------------------- end

		print "<title>".$kop."</title>\n";

		if ($humo_option["zoekmachine"]=="j"){ print $humo_option["optierobots"]; }
	}

	// *** BASE HREF genereren t.b.v. url_rewrite ***
	// SERVER_NAME   127.0.0.1
	//     PHP_SELF: /url_test/index/1abcd2345/
	// OF: PHP_SELF: /url_test/index.php
	// REQUEST_URI: /url_test/index/1abcd2345/
	// REQUEST_URI: /url_test/index.php?variabele=1
	// *** Zonder url_rewrite ***
	$url_pad=$_SERVER['PHP_SELF'];
	$positie=strrpos($_SERVER['PHP_SELF'],'/');
	$uri_pad= substr($_SERVER['PHP_SELF'],0,$positie).'/';
	// *** Met url_rewrite ***
	if ($humo_option["url_rewrite"]=="j"){
		$uri_pad=$_SERVER['REQUEST_URI'];

		if (substr_count($uri_pad, 'index')>0){
			$uri_pad = str_replace("index", "!", $uri_pad);
			$url_pad='index.php';
		}

		if (substr_count($uri_pad, 'lijst')>0){
			$uri_pad = str_replace("lijst", "!", $uri_pad);
			$url_pad='lijst.php';
		}

		if (substr_count($uri_pad, 'lijst_namen')>0){
			$uri_pad = str_replace("lijst_namen", "!", $uri_pad);
			$url_pad='lijst_namen.php';
		}

		if (substr_count($uri_pad, 'gezin')>0){
			$uri_pad = str_replace("gezin", "!", $uri_pad);
			$url_pad='gezin.php';  // *** nodig voor bronweergave ***
		}

		if (substr_count($uri_pad, 'kwartierstaat')>0){
			$uri_pad = str_replace("kwartierstaat", "!", $uri_pad);
			$url_pad='report_ancestor.php';  // *** nodig voor bronweergave ***
		}

		$urlpositie=strpos($uri_pad,'!');
		if ($urlpositie){
			$uri_pad= 'http://'.$_SERVER['SERVER_NAME'].substr($uri_pad,0,$urlpositie);
			echo '<base href="'.$uri_pad.'">';

			$url_pad=$uri_pad.$url_pad;
		}
		else{
			// *** Standaard uri gebruiken ***
			$uri_pad= substr($_SERVER['PHP_SELF'],0,$positie).'/';
		}
	}

	//echo '<link href="gedcom.css" rel="stylesheet" type="text/css">';
	if ($cms['cms_name']=='Joomla'){
		// Lay-out gaat fout met het gedcom.css bestand.
		JHTML::stylesheet('gedcom_joomla.css', $cms['cms_path']);
	}
	else{
		echo '<link href="gedcom.css" rel="stylesheet" type="text/css">';
	}

	echo '<link href="print.css" rel="stylesheet" type="text/css" media="print">';

	echo '<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">';
	if (isset($user["group_birthday_rss"]) AND $user["group_birthday_rss"]=="j"){
		$language_rss='nl'; if (isset($_SESSION['Taal'])){ $language_rss=$_SESSION['Taal']; }
		echo '<link rel="alternate" type="application/rss+xml" title="Verjaardagen" href="birthday_rss.php?lang='.$language_rss.'">';
	}

	// *** url_rewrite variabele ***
	// *** urlpart[0] = (family) database, urlpart[1] = next variabale, etc. ***
	if ($humo_option["url_rewrite"]=="j"){
		// *** Variabelen zoeken in: http://127.0.0.1/humo-php/gezin/F100/humo2_/I10 ***
		$urlpad2=$_SERVER['REQUEST_URI'];
		$urlpad2 = str_replace("/gezin/", "~!", $urlpad2);
		$urlpad2 = str_replace("/index/", "~!", $urlpad2);
		$urlpad2 = str_replace("/lijst/", "~!", $urlpad2);
		$urlpad2 = str_replace("/lijst_namen/", "~!", $urlpad2);
		$urlpositie=strpos($urlpad2,'!');
		if ($urlpositie){
			$deel1=substr($urlpad2,$urlpositie+1,-1);   //    humo2_/F100/I10
			$urlpart = explode("/", $deel1);
		}
	}

	// *** Family tree choice ***
	$database='';
	if (isset($urlpart[0]) AND $urlpart[0]!='standaard'){ $database=$urlpart[0]; } // *** url_rewrite ***
	if (isset($_GET["database"])){ $database=$_GET["database"]; }
	if (isset($_POST["database"])){ $database=$_POST["database"]; }
	if (isset($database) AND $database){
		// *** Check if family tree really exists ***
		$datasql = mysql_query("SELECT * FROM humo_trees
			WHERE tree_prefix='".veilig($database)."'",$db);
		if (@mysql_num_rows($datasql)==1) { $_SESSION['tree_prefix']=$database; }
	}
	// *** No family tree selected yet ***
	if (!isset($_SESSION["tree_prefix"]) OR $_SESSION['tree_prefix']=='' ){
		$_SESSION['tree_prefix']=''; // *** If all trees are blocked then session is empty ***

		$datasql = mysql_query("SELECT * FROM humo_trees ORDER BY tree_order",$db);

		// *** Find first family tree that's not blocked for this usergroup ***
		while(@$dataDb=mysql_fetch_object($datasql)){
			// *** Check is family tree is showed or hidden for user group ***
			$hide_tree_array=explode(";",$user['group_hide_trees']);
			$hide_tree=false;
			for ($x=0; $x<=count($hide_tree_array)-1; $x++){
				if ($hide_tree_array[$x]==$dataDb->tree_id){ $hide_tree=true; }
			}
			if ($hide_tree==false){	
				$_SESSION['tree_prefix']=$dataDb->tree_prefix;
				break;
			}
		}
	}

	/*
	// **************************************************************
	// Met onderstaande regels is het mogelijk om PER DATABASE
	// een eigen achtergrond afbeelding te tonen
	// **************************************************************
	print '<style type="text/css">';
	$afbeelding= "plaatjes/".$_SESSION['tree_prefix'].".jpg";
	print " body { background-image: url($afbeelding);}";
	print "</style>";
	*/

	echo '<script type="text/javascript" src="'.$cms['cms_path'].'sliderbar/slider.js"></script>';
	echo '<script type="text/javascript" src="'.$cms['cms_path'].'fontsize.js"></script>';

	// *** Style sheet select ***
	include($cms['cms_path']."styles/sss1.php");

	// *** Pop-up menu ***
	echo '<script type="text/javascript" src="'.$cms['cms_path'].'popup_menu/popup_menu.js"></script>';
	//echo '<link rel="stylesheet" type="text/css" href="popup_menu/popup_menu.css">';
	if ($cms['cms_name']=='Joomla'){
		JHTML::stylesheet('popup_menu.css', $cms['cms_path'].'popup_menu/');
	}
	else{
		echo '<link rel="stylesheet" type="text/css" href="popup_menu/popup_menu.css">';
	}

	// *** Photo lightbox effect ***
	if ($user["afbeeldingen"]=='j'){
		echo '<script type="text/javascript" src="'.$cms['cms_path'].'lightbox/js/mootools.js"></script>';
		echo '<script type="text/javascript" src="'.$cms['cms_path'].'lightbox/js/slimbox.js"></script>';
// Nog aanpassen voor Joomla.
		//echo '<link rel="stylesheet" href="lightbox/css/slimbox.css" type="text/css" media="screen" />';
		echo '<link rel="stylesheet" href="lightbox/css/slimbox.css" type="text/css" media="screen">';
	}

	if (!$cms['cms']){
		print "</head>\n";
		print "<body onload='checkCookie()'>\n";
	}

} // *** End of PDF export check ***
?>
Return current item: HuMo-gen