Thank you! That worked (I just changed User_id to User_name), the only thing is I don't see how to customise the style of it.
So based on what functions already existed, I tried adding a second function, for when people are logged in, called function loggedin() , like this:
function loginForm() {
$loginFormHtml = <<<EOT
<form action="login.php" method="post" name="loginbox" style="margin:0px">
<table class="class" align="center" border="0" width="440" cellpadding="0" cellspacing="0">
<tr>
<td width="80" align="center">
<b>Username :</b>
</td>
<td width="120" align="left">
<input type="text" class="textinput" name="username" style="width: 100px" />
</td>
<td width="240">
<a href="forgot_passwd.php">Lost Password</a>|<a href="register.php">Register</a>|<label for="remember_me">Remember me</label>
<input name="remember_me" type="checkbox" class="checkbox" value="1" />
</td>
</tr>
<tr>
<td width="80" align="center">
<b>Password :</b>
</td>
<td width="120" align="left">
<input type="password" class="textinput" name="password" style="width: 100px" />
</td>
<td width="240">
<input name="submitted" type="submit" class="button" value="Login" />
</td>
</tr>
</table>
</form>
EOT;
return $loginFormHtml;
}
function loggedin() {
$loggedinHtml = <<<EOT
<table class="class" border="0" width="360" cellpadding="0" cellspacing="0">
<tr>
<td width="120">
Welcome {USER_NAME}
</td>
<td width="240">
<a href="logout.php">Log me out</a>
</td>
</tr>
</table>
EOT;
return $loggedinHtml;
}
function pageheader($section, $meta = '')
{
global $CONFIG, $THEME_DIR;
global $template_header, $lang_charset, $lang_text_dir;
$custom_header = cpg_get_custom_include($CONFIG['custom_header_path']);
header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
user_save_profile();
if(!USER_ID){
$template_vars = array('{LANG_DIR}' => $lang_text_dir,
'{TITLE}' => $CONFIG['gallery_name'] . ' - ' . strip_tags(bb_decode($section)),
'{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
'{META}' => $meta,
'{GAL_NAME}' => $CONFIG['gallery_name'],
'{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
'{SYS_MENU}' => theme_main_menu('sys_menu'),
'{SUB_MENU}' => theme_main_menu('sub_menu'),
'{ADMIN_MENU}' => theme_admin_mode_menu(),
'{CUSTOM_HEADER}' => $custom_header,
'{LOGIN_FORM}' => loginForm() ,
);
} else {
$template_vars = array('{LANG_DIR}' => $lang_text_dir,
'{TITLE}' => $CONFIG['gallery_name'] . ' - ' . strip_tags(bb_decode($section)),
'{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
'{META}' => $meta,
'{GAL_NAME}' => $CONFIG['gallery_name'],
'{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
'{SYS_MENU}' => theme_main_menu('sys_menu'),
'{SUB_MENU}' => theme_main_menu('sub_menu'),
'{ADMIN_MENU}' => theme_admin_mode_menu(),
'{CUSTOM_HEADER}' => $custom_header,
'{LOGIN_FORM}' => loggedin() ,
);
}
echo template_eval($template_header, $template_vars);
}
?>
It works the way I wanted it to, except for the {USER_NAME} tag that I must have got wrong, as it won't display the actual username.