<?php

/*
 * ***********************************************************************************************
 * Filename:     index.php
 * Module:       Main display unit
 * Subcategory:  -
 * Description:  Controls the complete User-Interface. Calls various other display Units on demand
 * ***********************************************************************************************
 *
 *
 * Project:     yappa-ng : yet another php photo album - next generation
 * Author:      Fritz Berger <wizard@zirkon.at>
 * Copyright:   2003 Fritz Berger
 * $Header: /cvsroot/yappa-ng/yappa-ng/index.php,v 1.51 2004/08/29 12:46:50 zirkon13 Exp $
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * You may contact the author of yappa-ng by e-mail at:
 *    wizard@zirkon.at
 *
 * The latest version of yappa-ng can be obtained from:
 *    http://www.zirkon.at/zirkon/scripts/yappa-ng/yappa-ng_main_ger.html (german)
 *    http://www.zirkon.at/zirkon/scripts/yappa-ng/yappa-ng_main_eng.html (english)
 *
 * ***********************************************************************************************
 * ***********************************************************************************************
 * ***                                                                                         ***
 * ***   yappa-ng is based on "YAPPA v1.7 devel - 22.April 2002"                               ***
 * ***                         released on http://sourceforge.net/projects/yappa/              ***
 * ***   YAPPA is Copyright Federico 'pix' Feroldi (pix@pixzone.com)                           ***
 * ***   YAPPA is released under the GNU GPL                                                   ***
 * ***                                                                                         ***
 * ***********************************************************************************************
 * ***********************************************************************************************
 */
require("config.inc.php");


/* Give 'MAINTENANCE-MODE' - Output and exit ************************************************************************ */
if ((!isset($config['title'])) || (trim($config['title']) == "")) {
	$config['title'] = "yappa-ng";
}
if($config['maintenance_mode']) {
	?>
	<h1 align="center">
	<br>
	-- <?php print $config['title']; ?> -- <br>
	<br>
	wurde ins interne ASB Forum uebernommen,
	<br>
	<br>
	und ist ab sofort dort abrufbar unter fotos
	<br>
	mfg</h1>
	<?php
	exit();
}

// set quick debug!
//$config['error_rep'] = "1";

include_once($config['path_src_include'] . "common.inc.php");
include_once($config['path_src_include'] . "check_basic.inc.php");
include_once($config['path_src_include'] . "main.inc.php");
include_once(singleslash($config['path_lang_include'] . "language_selection.inc.php"));
include_once($config['path_src_include'] . "passwd.inc.php");
include_once(singleslash($config['path_themes_include'] . "themes_support.inc.php"));

header("Content-Type: text/html; charset=" . $lang_akt["charset"]);

$print_footer = true;

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?php print $config["title"]; ?></title>
<link rel="SHORTCUT ICON" href="./images/favicon.ico">
<meta http-equiv="expires" content="0">
<link rel=stylesheet type="text/css" href="<?php print $theme["css"]; ?>">
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $lang_akt["charset"]; ?> ">
<meta name="author" content="Fritz Berger">
<meta name="description" content="yappa-ng (Yet Another PHP Photo Album - Next Generation) is a powerful PHP Gallery in release <?php print $config['release']; ?>
 with automatic thumbnail creation, automatic resizing and many, many other features. 
 Homepage on http://www.zirkon.at/zirkon/scripts/yappa-ng/yappa-ng_main_eng.html">
<meta name="keywords" content="yappa-ng, <?php print $config['title']; ?>" >
<?php
if(($global_var['adminlogin'] == "yes") && ($admin_ok != 1)) {
	print "<script type='text/javascript'> \n";
	print "<!-- \n";
	print " function GiveMeTheFocus() { \n";
	print " document.PasswdQuery.passwd_admin_in.focus(); \n";
	print "} \n";
	print "//--> \n";
	print "</script> \n";
} elseif(($passwd_needed  == 1) && ($global_var['adminlogin'] != "yes")) {
	print "<script type='text/javascript'> \n";
	print "<!-- \n";
	print " function GiveMeTheFocus() { \n";
	print " document.PasswdQuery.passwd_in.focus(); \n";
	print "} \n";
	print "//--> \n";
	print "</script> \n";
} ?>
</head>
<body bgcolor="#FFFFFF" <?php
if(($global_var['adminlogin'] == "yes") && ($admin_ok != 1)) { print "admin_ok = '" . $admin_ok . "'";
	print " onLoad='GiveMeTheFocus()'";
} elseif(($passwd_needed  == 1) && ($global_var['adminlogin'] != "yes")) { 
	print " onLoad='GiveMeTheFocus()'"; 
} ?>>
<!-- Maintainance Mode -->
<?php


/* TOP main selection bar - theme (Include) ************************************************************************** */
require($theme['head']);

?>
<!-- themes_header -->
<?php
/* ALBUM Mode START *********************************************************************************** */
if($page["mode"] == "album") {
	/* Top-10 Ranking selected */
	if($global_var['top10image'] == "yes") {
		if ( $passwd_needed  == 1) {
			/* User - Password Query Screen - language-specific */
			include($config['path_src_include'] . "index_passwd-query.inc.php");
		} else {
			include($config['path_src_include'] . "index_top10_images.inc.php");
		}
	/* Album-Info selected */
	} elseif($global_var['album_info'] == "yes") {
		if ( $passwd_needed  == 1) {
			/* User - Password Query Screen - language-specific */
			include($config['path_src_include'] . "index_passwd-query.inc.php");
		} else {
			include_once($config['path_src_include'] . "index_album_info.inc.php");
		}
	/* Slideshow Options selected */
	} elseif($global_var['slides'] == "yes") {
		if ( $passwd_needed  == 1) {
			/* User - Password Query Screen - language-specific */
			include($config['path_src_include'] . "index_passwd-query.inc.php");
		} else {
			include($config['path_src_include'] . "slideshow_options.inc.php");
		}
	/* "overview" selected */
	} elseif($global_var['overview'] == "yes") {
		include_once($config['path_src_include'] . "index_overview.inc.php");
	/* "Admin - Login" selected
	 * If the login is correct (Password correct or cookie already set) it switches automatically further to the Admin-Menu */
	} elseif($global_var['adminlogin'] == "yes") {
		include_once($config['path_src_include'] . "index_passwd-admin.inc.php");
	/* ok - no special view selected - so go on with thumbnail page */
	} else {
		/* LEFT Album Navigation Bar */
		 /* user-password-query  */
		if($passwd_needed == 1) {
			/* User - Password Query Screen - language-specific */
			include($config['path_src_include'] . "index_passwd-query.inc.php");
		} else {
			/* LEFT Album Navigation Bar */
			/* table opens in index_leftnavbar.inc.php.
			* Gets closed at the end of index_thumbs.inc.php.
			* If index_thumbs.inc.php is not activated close the table here in this script !!
			*/
			include($config['path_src_include'] . "index_leftnavbar.inc.php");
			if($page["thumbnails_tot"] > 0) {
				/* Thumbnail Array START ********************************************************************* */

				/* user-password-query  */
				if($passwd_needed == 1) {
					/* User - Password Query Screen - language-specific */
					include($config['path_src_include'] . "index_passwd-query.inc.php");
					/* index_thumbs.inc.php not activatedand -> close table */
					?>
					</td></tr></table>
					<?php
				} else {
					/* no user - password required or user - password already sent */

					/* Thumbnail page including the INFO table above thumbnailarray */
					include($config['path_src_include'] . "index_thumbs.inc.php");
				}
			} else {
				if((count($page["album_path"]) == 1) && ($global_var['overview'] != "yes") && ($global_var['adminlogin'] != "yes")) {
					/* This is the Main Gallery Page!
					* If there is a global news file in the yappa-ng source directory -> display it! */
					@include($lang_akt["news"]);
					// print $lang_akt["news"];
					/* index_thumbs.inc.php not activatedand -> close table */
					?>
					</td></tr></table>
					<?php
				} elseif(count($page["subalbums"]) == 0) { 
					/* here are no more subalbums AND no images -> print "no images in this album" and close table! */
					?>
					<table cellspacing="3" cellpadding="10" width="100%">
					<tr><td align="center" class="adminStatus"><?php echo $lang_akt["admin_modules_noimage"]; ?></td></tr>
					</table>
					</td></tr></table>
				<?php } else { 
					/* here are only subalbums - no images.

					/* If there is an album news file within this album -> display it */
					@include($lang_akt["news"]);
					/* index_thumbs.inc.php not activatedand -> close table */
					?>
					</td></tr></table>
				<?php }
			}
		}
	}
}

if(($page["mode"] == "image") || ($page["mode"] == "video")) {

	/* user-password-query ***************************************************************************************** */
	/* Slideshow Options selected */
	if($global_var['slides'] == "yes") {
		if ( $passwd_needed  == 1) {
			/* User - Password Query Screen - language-specific */
			include($config['path_src_include'] . "index_passwd-query.inc.php");
		} else {
			include($config['path_src_include'] . "slideshow_options.inc.php");
		}
	} else {
		if($passwd_needed == 1) {
			include($config['path_src_include'] . "index_passwd-query.inc.php");
		} else {
			/* no userpassword needed *****************************************************************************************
			* load the single-image
			*/
			include($config['path_src_include'] . "index_image.inc.php");
		}
	}
} ?>


<?php
if($theme["use_footer"] != "no") {
	if($print_footer){
		include($theme["footer"]);
	}
}

/* This program is free to use - all work done by me in my free time for no money.
 * Please be so kind and leave this copyright-footer in and do not edit it!
 * Thank you!
 */
if($print_footer){
	require($theme["copyright-footer"]);
}

?>

</body>
</html>
