ACCES INTERZIS | blog de programare si securitate IT


Nu o sa zic nimic despre acest meniu de navigare in interiorul unui site decat ca designul este realizat de Dr. Freak iar programarea PHP si redactarea HTML/CSS de mine. Enjoy studying the code! ;)

index.php, about.php, gallery.php, offerts.php, hotels.php, contact.php

<?php
$php_self = htmlentities(strip_tags($_SERVER['PHP_SELF']), ENT_QUOTES, 'utf-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Travel agency</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Travel agency" />
<meta name="keywords" content="travel,agency" />
<meta name="abstract" content="Travel agency" />
<meta name="author" content="AccesInterzis" />
<meta name="copyright" content="AccesInterzis" />
<meta name="robots" content="noindex,nofollow" />
<meta name="revisit-after" content="7 days" />

<link rel="stylesheet" type="text/css" href="css/nav-menu.css.php" media="screen" />
<script type="text/javascript" src="js/load-images.js.php"></script>
</head>

<body onload="download_images()">
<?php include('includes/nav-menu.inc.php'); ?>

<p id="content">
<?php echo basename($php_self).' page is under construction.'; ?>
</p>

<?php include('includes/footer.inc.php'); ?>
</body>
</html>

nav-menu.inc.php

<ul id="nav_menu">
	<?php
	$nav_menu = array('home'    => 'index.php',
					  'about'   => 'about.php',
					  'gallery' => 'gallery.php',
					  'offerts' => 'offerts.php',
					  'hotels'  => 'hotels.php',
					  'contact' => 'contact.php');

	foreach ($nav_menu as $k => $v) {
		echo '<li id="'.$k.'-item">';
		echo '<a href="'.$v.'" title="'.ucfirst($k).'" id="'.$k.'-btn"';
		echo (basename($php_self) == $v) ? ' style="background:url(\'images/'.$k.'-hover.png\') no-repeat 0 0">' : '>';
		echo '<span>'.ucfirst($k).'</span>';
		echo '</a>';
		echo '</li>';
	}
	?>
</ul>

nav-menu.css.php

<?php
header("Content-type: text/css; charset=utf-8");
?>
* {
	margin:0;
	padding:0;
	outline:none;
}

html {
	color:black;
	background:#00c3ff url('../images/content-repeat-x.jpg') repeat-x 0 0;
	/*background-color background-image background-repeat background-attachment background-position*/
	font: normal normal normal 12px  Verdana;
	/*font-style font-variant font-weight font-size font-family*/
}

body {
	/*
	E important ca body sa nu aiba nicio culoare de fundal deoarece daca ar avea
	nu s-ar mai vedea repeat-x-ul de pe fundalul html-ului.
	*/
	background:url('../images/header-travel-agency.jpg') no-repeat top;
	height:567px;
}

/***********begin - navigation menu***********/

ul#nav_menu {
	width:816px;
	margin:0 auto;
	list-style-type:none;
	overflow:hidden;
	padding-top:360px;
}

ul#nav_menu li {
	float:left;
	margin-right:30px;
}

ul#nav_menu li#contact-item {
	margin-right:0;
}

ul#nav_menu a {
	display:block;
	width:111px;
	height:56px;
}

ul#nav_menu li a span {
	display:none;
}

<?php
$btns = array('home', 'about', 'gallery', 'offerts', 'hotels', 'contact');

foreach ($btns as $item) {
	echo 'ul#nav_menu a#'.$item.'-btn {
		background:url(\'../images/'.$item.'.png\') no-repeat 0 0;
	}

	ul#nav_menu a#'.$item.'-btn:hover {
		background:url(\'../images/'.$item.'-hover.png\') no-repeat 0 0;
	}';
}
?>

/***********end - navigation menu***********/

p#content {
	color:white;
	text-align:center;
	font-size:32px;
	margin-top:150px;
}

p#footer {
	width:100%;
	position:absolute;
	bottom:5px;
	text-align:center;
	font-size:10px;
}

p#footer  a {
	color:white;
	text-decoration:none;
}

p#footer  a:hover {
	text-decoration:underline;
}

load-images.js.php

<?php
header("content-type: application/x-javascript");

function load_images($folder) {
	$result = 'objImage = new Image();'."\r\n";

	$result .= 'function download_images(){'."\r\n";
	$allowed_extensions = array ('.jpg', '.jpeg', '.png', '.gif');
	$open = opendir ($folder);	

	$i = 0;
	while ($filename = readdir($open)) {
		if ($filename != '.' && $filename != '..') {
			$extension = substr($filename, strrpos($filename,'.'),100);
			$extension = strtolower($extension);

			if (in_array($extension, $allowed_extensions)) {
				$result .= 'objImage'.$i.'.src="'.$folder.'/'.$filename.'"'."\r\n";
				$i++;
			}
		}
	}
	$result .= '}';

	return($result);
}

echo load_images('../images');
?>

Post to Twitter Publica acest articol pe Twitter

Articole asemanatoare:

Publicat de: admin
Ultima modificare: 14, 2010, 08:57

Etichete
Etichete: , ,
Categorii: programare, web design


 

Comentarii lasate » (0)

 
Lasa un comentariu

XHTML: Poti folosi urmatoarele taguri HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>