<?php

$bgcolor1 = "#d1f3ff"; // blue Clair
$bgcolor2 = "#7fd2fe"; // blue moyen
$bgcolor3 = "#efefef";
$bgcolor4 = "#FF7F00";
$bgcolor0 = "#0957c6"; // bleu fonc�$textcolor1 = "#ffffff";
$textcolor2 = "#0957c6";
if (is_file('admin/themes/admin_Kmax/tables.php')) {
include_once('admin/themes/admin_Kmax/tables.php');
}

function themeheader() {
global $admin_file, $admin, $cookie, $prefix, $urle, $mmStyle, $menuVars, $mmMenu;

echo '<body>';

if ( !defined('ADMINLOG') ) {
    $sql = "SELECT `user_id` from `".TABLE_USERS."` ";
if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(GENERAL_ERROR, 'Could not obtain users admin template', '', __LINE__, __FILE__, $sql);}
$numusers = $GLOBALS['db']->sql_numrows($result);
$raw      = $GLOBALS['db']->sql_fetchrow($result);
$uid      = $GLOBALS['db']->XMFnum($raw['user_id']);

if ( is_active("Forums")) {
	$sql2 = "SELECT `privmsgs_to_userid` FROM `".$prefix."_bbprivmsgs` WHERE `privmsgs_to_userid`='$uid' AND `privmsgs_type`='0'";
	if ( !($result2 = $GLOBALS['db']->sql_query($sql2)) ){
		$oldpms = 0 ;
		} else {
		$oldpms = $GLOBALS['db']->sql_numrows($result2);
	}
	$sql1 = "SELECT `privmsgs_to_userid` FROM `".$prefix."_bbprivmsgs` WHERE `privmsgs_to_userid`='$uid' AND (`privmsgs_type`='5' OR `privmsgs_type`='1')";
	if ( !($result1 = $GLOBALS['db']->sql_query($sql1)) ){
        	$newpms = 0; 
		} else {
		$newpms = $GLOBALS['db']->sql_numrows($result1); 
	}
	if ( $newpms == 0) { $newpms = " $oldpms <a href='modules.php?name=Private_Messages'><img src='admin/themes/admin_Kmax/images/nomail.png' border='0' alt='"._MESSAGES."' title='"._MESSAGES."' /></a>"; } else { $newpms = "( $newpms ) $oldpms <a href='modules.php?name=Private_Messages'><img src='admin/themes/admin_Kmax/images/nomail.png' alt='"._MESSAGES."' title='"._MESSAGES."' /></a>"; }
}

//include_once("admin/themes/admin_Kmax/pre_menu.php");
echo "<table cellspacing='0' cellpadding='0' width='99%' height='20' align='center' border='0'><tr>"
    ."<td valign='top' align='left' bgcolor='#45a1ec' width='85%' height='20'>";

include_once('admin/themes/admin_Kmax/light_menu.php');

echo "</td><td valign='top' align='right' bgcolor='#45a1ec'>$newpms <font size='3'> $numusers </font><img src='admin/themes/admin_Kmax/images/users.png' alt='' /></td></tr></table>";

$tmpl_file = 'admin/themes/admin_Kmax/header.html';
	} else {
   	$tmpl_file = 'admin/themes/admin_Kmax/header2.html';
}

    $thefile = implode("", file($tmpl_file));
    $thefile = addslashes($thefile);
    $thefile = "\$r_file=\"".$thefile."\";";
    eval("$thefile");
    print $r_file;

if ( !defined('ADMINLOG') ) {
    NavBarAdmin('home','manager','kmax','back','reload','next','cancel','support','tuto');
}

$GLOBALS['db']->sql_freeresult($result);
$GLOBALS['db']->sql_freeresult($result1);
$GLOBALS['db']->sql_freeresult($result2);
}

function themefooter() {
   global $total_time, $start_time, $CopyrightAdmin, $admin_file ;
    $tmpl_file = 'admin/themes/admin_Kmax/footer.html';
    $thefile = implode("", file($tmpl_file));
    $thefile = addslashes($thefile);
    $thefile = "\$r_file=\"".$thefile."\";";
    eval($thefile);
    print $r_file;
   }