<?php
/*
 * This file is part of Web Pro Manager.
 * 
 * Web Pro Manager 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 3 of the License, or
 * (at your option) any later version.
 * 
 * Web Pro Manager 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 Web Pro Manager.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * @author The Web Pro Miami, Inc. <info@thewebpro.com>
 * @copyright The Web Pro Miami, Inc. <info@thewebpro.com>, http://www.thewebpro.com/
 * @license http://www.gnu.org/licenses/gpl.html GNU GPL
 * @package WebProManager
*/
?>
		<!--[if !IE]>start head<![endif]-->
		<div id="head">
			<div class="inner">
				<h1 id="logo"><a href="#"><?php echo _("Web Pro Manager"); ?></a></h1>
				<!--[if !IE]>start user details<![endif]-->
				<div id="user_details">
					<ul id="user_details_menu">
						<li class="first"><?php echo nGetUserName();?></li>
						<!-- <li><a href="#">My Account</a></li> //-->
						<li class="last"><a href="process_logout.php"><?php echo _("Log out"); ?></a></li>
					</ul>
					<div id="server_details">
						<dl>
							<dt><?php echo _("Server time"); ?>:</dt>
							<dd><?php echo date('h:i A'); ?></dd>
						</dl>
						<dl>
							<dt><?php echo _("Last login IP"); ?>:</dt>
							<dd><?php $ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; echo $ip; ?></dd>
						</dl>
					</div>
				</div>
				<!--[if !IE]>end user details<![endif]-->

				<!--[if !IE]>start main menu<![endif]-->
				<div id="main_menu">
					<ul>
						<li>
<?php
$nUserLink = nGetUserLinkFromName($ValidUser);

$nThisPath = $_SERVER["PHP_SELF"]; $nPathParts = Explode('/', $nThisPath); $nThisPath = $nPathParts[count($nPathParts)-1];
$nNavARRAY = array();
if($nAdminAccess){
	$nSubNavHomeARRAY = array(_("Welcome").",home.php",_("Site Settings").",settings_edit.php",_("System Settings").",sys_settings_edit.php");
	$nSubNavPageARRAY = array(_("View &amp; Edit Pages").",pages.php",_("Page Templates").",page_templates.php",_("Edit Page").",page_edit.php,1");
} else {
	$nSubNavHomeARRAY = array(_("Welcome").",home.php");
	$nSubNavPageARRAY = array(_("View &amp; Edit Pages").",pages.php",_("Edit Page").",page_edit.php,1");
}
$nNavARRAY[] = array(_("Home").",home.php",$nSubNavHomeARRAY);
$nNavARRAY[] = array(_("Sections").",sections.php",
	array(_("View &amp; Edit Sections").",sections.php",_("Edit Section").",section_edit.php,1")
);
$nNavARRAY[] = array(_("Pages").",pages.php",$nSubNavPageARRAY);
if($nAdminAccess){
	$nNavARRAY[] = array(_("Library").",library_image.php",
		array(_("Images").",library_image.php",_("Documents").",library_docs.php",_("Components").",components.php",_("Themes").",library_theme.php")
	);
	$nNavARRAY[] = array(_("Users").",users.php",
		array(_("View &amp; Edit Users").",users.php",_("Edit User").",user_modify.php,1")
	);
} else {
	$nNavARRAY[] = array(_("Library").",library_image.php",
		array(_("Image Library").",library_image.php",_("Document Library").",library_docs.php")
	);
	$nNavARRAY[] = array(_("Account").",$nUserLink",
		array(_("View &amp; Edit My Account").",$nUserLink")
	);
}
// Build nav
$nNavCODE = "";
foreach($nNavARRAY AS $nNavItemARRAY){
	$nChildSelected=0;
	$nSubNavCODE="";
	$nNamePathARRAY = explode(",",$nNavItemARRAY[0]);
	$nParentName = $nNamePathARRAY[0];
	$nParentPath = $nNamePathARRAY[1];
	if($nNavItemARRAY[1]){
		$nChildARRAY = $nNavItemARRAY[1];
		$nSubNavCODE.= "<ul>";
		foreach($nChildARRAY AS $nChildItem){
			$nChildNamePathARRAY = explode(",",$nChildItem);
			if(isset($nChildNamePathARRAY[0])){ $nChildName = $nChildNamePathARRAY[0]; } else { $nChildName = ""; }
			if(isset($nChildNamePathARRAY[1])){ $nChildPath = $nChildNamePathARRAY[1]; } else { $nChildPath = ""; }
			if(isset($nChildNamePathARRAY[2])){ $nHide = $nChildNamePathARRAY[2]; } else { $nHide = ""; }
			if($nThisPath==parse_url($nChildPath,PHP_URL_PATH)){ $nChildClass="class=\"selected\""; $nChildSelected=1; } else { $nChildClass=""; }
			if(!$nHide){ $nSubNavCODE.= "<li><a href=\"$nChildPath\" $nChildClass><span><span>$nChildName</span></span></a></li>\n"; }
		}
		$nSubNavCODE.= "</ul>";
	}
	if($nThisPath==parse_url($nParentPath,PHP_URL_PATH) || $nChildSelected){ $nParentClass="class=\"selected\""; } else { $nParentClass=""; }
	
	$nNavCODE.= "<li><a href=\"$nParentPath\" $nParentClass><span><span>$nParentName</span></span></a>";
	if($nSubNavCODE && ($nThisPath==$nParentPath || $nChildSelected)){ $nNavCODE.=$nSubNavCODE."</li>\n"; } else { $nNavCODE.="</li>\n"; }
}
echo $nNavCODE;
?>
					</ul>
				</div>
				<!--[if !IE]>end main menu<![endif]-->
				
			</div>
		</div>
		<!--[if !IE]>end head<![endif]-->
<?php
function nGetUserName(){
	global $DBName,$Link,$ValidUser;
	$nUserLink = nGetUserLinkFromName($ValidUser);
	if($nUserLink){
		$nUserText = "<a href=\"$nUserLink\"><strong>$ValidUser</strong></a>";
	} else {
		$nUserText = "<strong>$ValidUser</strong>";
	}
	return $nUserText;
}
function nGetUserLinkFromName($nUserName){
	global $DBName,$Link;
	if(!$nUserName){ return; }
	$Query = "SELECT nID FROM nEditor WHERE nUser='$nUserName' LIMIT 1";
	mysql_select_db($DBName); $Result = mysql_query($Query,$Link);
	if($Row = mysql_fetch_array($Result)) {
		$nUserID = $Row["nID"];
	}
	if($nUserID){ $nUserLink = "user_modify.php?usr=$nUserID"; } else { $nUserLink = ""; }
	return $nUserLink;
}
?>