date('H'); gibt die Stunde mit führenden Nullen an, also 00 - 23
date('G'); gibt sie ohne an, also 0 - 23
Dann hast Du in deiner Abfrage Zeiträume nicht erfasst, wie 11 o. 21 Uhr
So würde ich es machen, obwohl ein ARRAY besser wäre, ab das geht auch:
$time = date('G');
if ($time >= 0 AND $time < 4) $gruss = 'Ab ins Bett!'; // 0-3
if ($time >= 4 AND $time < 7) $gruss = 'Schon wach?'; // 4-6
if ($time >= 7 AND $time < 11) $gruss = 'Guten Morgen'; // 7-10
if ($time >= 11 AND $time < 14) $gruss = 'Mahlzeit'; // 11-13
if ($time >= 14 AND $time < 18) $gruss = 'Guten Tag'; // 14-17
if ($time >= 18 AND $time < 22) $gruss = 'Guten Abend'; // 18-21
if ($time >= 22 AND $time < 24) $gruss = 'Gute Nacht'; // 22-23
Diesen Code musst Du in die ausführende PHP setzen und das vor der Templateausgabe ($tpl->set) in der Templateausgabe musst Du definieren, was er den übergeben soll. In diesem Fall die Variable $gruss.
$tpl->set ( 'GRUSS' , $gruss );
nun muss nur noch im Template (user/boxen_login.htm) selbst dass {GRUSS} an die gewollte Position!
So könnte es dann aussehen:
include/boxes/login.php
<?php
# Copyright by Manuel
# Support www.ilch.de
defined ('main') or die ( 'no direct access' );
$tpl = new tpl ( 'user/boxen_login.htm' );
if ( loggedin() ) {
if ( user_has_admin_right($menu,false) ) {
$tpl->set ( 'ADMIN', '<a class="box" href="admin.php?admin">'.$lang['adminarea'].'</a>' );
} else {
$tpl->set ( 'ADMIN', '' );
}
if ( $allgAr['Fpmf'] == 1 ) {
$erg = db_query("SELECT COUNT(id) FROM `prefix_pm` WHERE gelesen = 0 AND status < 1 AND eid = ".$_SESSION['authid']);
$check_pm = db_result($erg,0);
$nachrichten_link = '<a class="box" href="index.php?forum-privmsg">'.$lang['messages'].'</a> ('.$check_pm.')<br>';
} else {
$nachrichten_link = '';
}
// Begruessung
$time = date('G');
if ($time >= 0 AND $time < 4) $gruss = 'Ab ins Bett!';
if ($time >= 4 AND $time < 6) $gruss = 'Schon wach?';
if ($time >= 6 AND $time < 11) $gruss = 'Guten Morgen';
if ($time >= 11 AND $time < 13) $gruss = 'Mahlzeit';
if ($time >= 13 AND $time < 18) $gruss = 'Guten Tag';
if ($time >= 18 AND $time < 22) $gruss = 'Guten Abend';
if ($time >= 22 AND $time < 24) $gruss = 'Gute Nacht';
$tpl->set ( 'GRUSS' , $gruss );
$tpl->set ( 'SID' , session_id() );
$tpl->set ( 'NACHRICHTEN' , $nachrichten_link );
$tpl->set ( 'NAME', $_SESSION['authname'] );
$tpl->out (0);
} else {
if (empty($_POST['login_name'])) { $_POST['login_name'] = 'Nickname'; }
if (empty($_POST['login_pw'])) { $_POST['login_pw'] = 'ääääääää'; }
$regist = '';
if ( $allgAr['forum_regist'] == 1 ) {
$regist = ' <a href="index.php?user-regist">Regist</a>';
}
$tpl->set_ar_out ( array ( 'regist' => $regist, 'wdlink' => '?'.$allgAr['smodul'], 'PASS' => $_POST['login_pw'], 'NAME' => $_POST['login_name'] ) , 1 );
}
unset($tpl);
?>
include/templates/user/boxen_login.htm
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
{GRUSS} <b>{NAME}</b>
<br />
{NACHRICHTEN}
<br />
<a class="box" href="index.php?user-8"><img src="include/images/icons/profil.gif" style="margin-top:3px" border="0" alt="Profil"></a>
<br />
<a class="box" href="index.php?user-3"><img src="include/images/icons/logout.gif" style="margin-top:3px" border="0" alt="Logout"></a>
<br />
{ADMIN}
</td>
</tr>
</table>