Okay, so I need a fresh set of eyes. If you would kindly go over to:
my website and just generally look at the layout. Nothing out of place, everything is good.
Now, at the top (where it says "Home Blog Gallery..." click on "Gallery".
Now, notice how the top navigation gets FUBAR? I don't understand why. It's the same include call. Here's the relevant code:
index.php
<?php /* Fix for code highlighter */ ?>
<!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" xml:lang="en" >
<head>
<title>bPatteson.net :: Under Construction</title>
<link rel="stylesheet" type="text/css" href="styles/default/screen.css" />
<link rel="shortcut icon" href="/favicon.ico" />
</head>
<body>
<div id="navigation">
<div id="bar">
<span id="date"><?php echo date('l F d, Y'); ?></span>
</div>
<div id="tabs">
<ul id="nav">
<?php include_once('includes/site_nav.php'); ?>
</ul>
</div>
</div>
<div id="wrap">
<div id="header">
</div>
<div id="content">
<p>Fear not, my site is under construction. While some of the links may seem to work, more than likely they will not for a while. Since I'm doing this in my free time, it will be a while before it's done. But as pieces finish, I'll list them here.</p>
<p>But for now, please enjoy this graphic :)</p>
<div id="inDev"></div>
</div>
</div>
</body>
</html>
gallery.php
<?php /* fix for code highlighter */ ?>
<!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" xml:lang="en" >
<head>
<title>bPatteson.net :: Photo Gallery</title>
<link rel="stylesheet" type="text/css" href="styles/default/screen.css" />
<link rel="shortcut icon" href="/favicon.ico" />
</head>
<body>
<div id="navigation">
<div id="bar">
<span id="date"><?php echo date('l F d, Y'); ?></span>
</div>
<div id="tabs">
<ul id="nav">
<?php include_once('includes/site_nav.php'); ?>
</ul>
</div>
</div>
<div id="wrap">
<div id="header"></div>
<div id="content">
<?php
$evt = (!isset($_GET['evt']) ? '' : $_GET['evt']);
$pic = (!isset($_GET['pic']) ? '' : $_GET['pic']);
define('IN_BPAT', md5('somestring'));
include_once('includes/class.photogallery.php');
$pix = new PhotoGallery();
$pix->setRoot($_SERVER['DOCUMENT_ROOT'].'/photos');
$pix->setPagination(25);
$pix->displayImages($evt, $pic);
?>
</div>
</div>
</body>
</html>
site_nav.php
<?php
$nav = array(
'home' => array(
'text' => 'Home',
'href' => 'www.bpatterson.net',
'page' => array('/', '/index.php'),
),
'about' => array(
'text' => 'About',
'href' => 'www.bpatterson.net',
'page' => '/about.php',
),
'blog' => array(
'text' => 'Blog',
'href' => 'blog.bpatterson.net',
'page' => '/index.php',
),
'gallery' => array(
'text' => 'Gallery',
'href' => 'www.bpatterson.net',
'page' => '/gallery.php',
),
'poetry' => array(
'text' => 'Poetry',
'href' => 'www.bpatterson.net',
'page' => '/poetry.php',
),
'random' => array(
'text' => 'Random',
'href' => 'www.bpatterson.net',
'page' => '/random.php',
),
'contact' => array(
'text' => 'Contact',
'href' => 'www.bpatterson.net',
'page' => '/contact.php',
),
);
$out = '';
foreach($nav as $key=>$ary){
$out .= '
<li'.checkPage($ary).'><a href="http://'.$ary['href'].(is_array($ary['page']) ? $ary['page'][0] : $ary['page']).'">'.$ary['text'].'</a></li>';
}
echo $out.'
';
function checkPage($ary, $tmp='') {
$req_page = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$uri = $_SERVER['REQUEST_URI'];
$host = $_SERVER['HTTP_HOST'];
$page = $ary['page'];
if(is_array($page) && in_array($uri, $page) && $host == $ary['href'])
$tmp = ' id="active"';
if($uri == $page && $host == $ary['href'])
$tmp = ' id="active"';
return $tmp;
}
?>
I'm not seeing where it could come from... but I've been up way too long....
EDIT
I guess my photogallery class would help 😉
<?php
if(/* security measures not met */) {
return 'Hacking Attempt. Shame on You!!';
exit;
}
class PhotoGallery {
var $_root='';
var $icons=array();
var $pix=array();
var $perpage=50;
var $cols=5;
function setRoot($dir) {
$this->_root = $dir;
}
function setPagination($num) {
$this->perpage = $num;
}
function setCols($num) {
$this->cols = $num;
}
function displayImages($evt, $pic) {
// We need to get the images first before we do anything.
if(empty($this->pix) || !is_array($this->pix))
$this->pix = $this->traverseDirs($cat, $evt, $pic);
if (empty($evt) && empty($pic))
$view = 'events';
else if (!empty($evt) && empty($pic))
$view = 'pics';
else
$view = 'pic';
switch($view) {
case 'events':
foreach($this->pix AS $evt=>$ary) {
echo '
<a href="?evt='.$evt.'">'.str_replace('_', ' ', $evt).'</a><br />';
}
break;
case 'pics':
break;
case 'pic':
break;
}
}
function traverseDirs($dir='') {
$tmp = array();
$path = (empty($dir) ? $this->_root : $dir);
$dh = @dir($path);
if(!$dh)
die('Unable to open directory for reading.');
while(false !== ($entry = $dh->read())) {
if($entry != '.' && $entry != '..' && $entry != 'thumbs') {
if(is_dir($path.'/'.$entry)) {
$tmp[$entry] = $this->traverseDirs($path.'/'.$entry);
}
else
$tmp[] = $entry;
}
}
$dh->close();
asort($tmp);
return $tmp;
}
}
?>