<?php
// ===============================================================
// Security and PHP 8 Compatibility Safeguards
// ===============================================================

// Ensure $pageTitle is always defined to prevent undefined variable warnings
if (!isset($pageTitle)) {
    $pageTitle = 'ConnVerge, Inc.';
}

// Ensure $pageStyle is always defined (fixes line 19 undefined variable bug)
if (!isset($pageStyle)) {
    $pageStyle = null;
}

// Sanitize output to prevent XSS attacks
$pageTitle = htmlspecialchars($pageTitle, ENT_QUOTES, 'UTF-8');

// ===============================================================
?>
<!DOCTYPE html>
<html lang="en">
<!-- begin header -->

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo $pageTitle; ?></title>
<link rel="stylesheet" type="text/css" href="https://media.connverge.com/stylesheet.css">
<?php
// ===============================================================

// This captures any page-specific CSS style overrides

if ($pageStyle !== null && $pageStyle !== '') {
	// Sanitize the CSS to prevent injection attacks
	$sanitizedStyle = htmlspecialchars($pageStyle, ENT_QUOTES, 'UTF-8');
	echo "<style type=\"text/css\">\n" . $sanitizedStyle . "\n</style>\n";
}

// ===============================================================
?>
</head>

<body>

<table cellspacing="0" style="width: 100%; background: #175E8F">
<tr>
<td><a href="/"><img src="https://media.connverge.com/images/logo.gif" alt="ConnVerge, Inc." style="width: 227px; height: 62px;"></a></td>
<td style="font-size: 8pt; font-weight: bold; color: #FFFFFF; text-align: right; padding-right: 20px">Consultants in human resources, compensation, benefits<br>
and retirement plans since 1986</td>
</tr>
</table>

<!-- end header --> 
<!-- begin navbar --> 

<table cellspacing="0" style="width: 100%; background: #76BEE9; margin-bottom: 30px;">
<tr>
<td style="background: url('https://media.connverge.com/images/navbar_top_shadow.gif'); height: 4px;"></td>
</tr>
<tr>
<td>

<?php
// ===============================================================

// The navbar script assumes a constant naming convention for files.
// If you change either the destination or image filenames, you need to update this script accordingly.

$navbarHomeState = "navbar_home_off.gif";
$navbarOverviewState = "navbar_overview_off.gif";
$navbarProjectsState = "navbar_projects_off.gif";
$navbarClientListState = "navbar_client_list_off.gif";
$navbarPartnersState = "navbar_partners_off.gif";
$navbarLibraryState = "navbar_library_off.gif";
$navbarContactUsState = "navbar_contact_us_off.gif";

// Security: Use null coalescing operator (PHP 7+) to safely access SERVER variables
$scriptName = $_SERVER["SCRIPT_NAME"] ?? '';

// Extract filename more safely
$pageFileName = basename($scriptName, '.php');

// Whitelist approach for security - only allow expected page names
$validPages = ['index', 'overview', 'projects', 'client_list', 'partners', 'library', 'contact_us'];

if (in_array($pageFileName, $validPages, true)) {
	switch ($pageFileName) {
		case 'index':
			$navbarHomeState = "navbar_home_on.gif";
			break;

		case 'overview':
			$navbarOverviewState = "navbar_overview_on.gif";
			break;

		case 'projects':
			$navbarProjectsState = "navbar_projects_on.gif";
			break;

		case 'client_list':
			$navbarClientListState = "navbar_client_list_on.gif";
			break;

		case 'partners':
			$navbarPartnersState = "navbar_partners_on.gif";
			break;

		case 'library':
			$navbarLibraryState = "navbar_library_on.gif";
			break;

		case 'contact_us':
			$navbarContactUsState = "navbar_contact_us_on.gif";
			break;
	}
}

// ===============================================================
?>

<table cellspacing="0">
<tr>
<td valign="top" class="navbarcell"><a href="/"><img src="https://media.connverge.com/images/<?php echo htmlspecialchars($navbarHomeState, ENT_QUOTES, 'UTF-8'); ?>" alt="Home" style="width: 47px; height: 16px;"></a></td>
<td valign="top" class="navbarcell"><a href="overview.php"><img src="https://media.connverge.com/images/<?php echo htmlspecialchars($navbarOverviewState, ENT_QUOTES, 'UTF-8'); ?>" alt="Overview" style="width: 74px; height: 16px;"></a></td>
<td valign="top" class="navbarcell"><a href="projects.php"><img src="https://media.connverge.com/images/<?php echo htmlspecialchars($navbarProjectsState, ENT_QUOTES, 'UTF-8'); ?>" alt="Projects" style="width: 62px; height: 19px;"></a></td>
<td valign="top" class="navbarcell"><a href="client_list.php"><img src="https://media.connverge.com/images/<?php echo htmlspecialchars($navbarClientListState, ENT_QUOTES, 'UTF-8'); ?>" alt="Client List" style="width: 74px; height: 16px;"></a></td>
<td valign="top" class="navbarcell"><a href="partners.php"><img src="https://media.connverge.com/images/<?php echo htmlspecialchars($navbarPartnersState, ENT_QUOTES, 'UTF-8'); ?>" alt="Partners" style="width: 66px; height: 16px;"></a></td>
<!-- <td valign="top" class="navbarcell"><a href="library.php"><img src="https://media.connverge.com/images/<?php echo htmlspecialchars($navbarLibraryState, ENT_QUOTES, 'UTF-8'); ?>" alt="Library" style="width: 56px; height: 19px;"></a></td> -->
<td valign="top" class="navbarcell"><a href="contact_us.php"><img src="https://media.connverge.com/images/<?php echo htmlspecialchars($navbarContactUsState, ENT_QUOTES, 'UTF-8'); ?>" alt="Contact Us" style="width: 82px; height: 16px;"></a></td>
</tr>
</table>

</td>
</tr>
<tr>
<td style="background: url('https://media.connverge.com/images/navbar_bottom_shadow.gif'); height: 4px;"></td>
</tr>
</table>

<!-- end navbar --> 
<!-- begin page content -->
