Forum Moderators: open
<?php
$hrs = date('G');// Current Hrs - 24hr clock
if (($hrs < 12) ¦¦ ($hrs >= 15)) {
print <<<END
<html>
<head><title>Chatroom</title></head>
<body>
<h1>Chatroom - Offline</h1>
<p>The chatroom can only be accessed between midday and 3pm.</p>
<p>Please come back later.</p>
</body>
</html>
END;
exit;
}
?>
That should work. If it is 'out of hours' then the rest of your page will not be rendered (exit;) and you just get a simple page returned. You might be able to do header() redirect to another page instead if you wish - not sure which is best in terms of search engines, if that is of concern...?
(I'll get out of your computer now... bit dusty in there anyway! ;)
I tryed that in my code and i cant seem to get it working..
here it is.. Could you please have a look and see where you think i should put that code? please..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><!-- InstanceBegin template="/Templates/mainnigel.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="doctitle" -->
<title>Craic at the Village Chatroom</title>
<!-- InstanceEndEditable --><link href="css/mainnigel.css" rel="stylesheet" type="text/css">
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<style type="text/css">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
.style1 {color: #139433}
-->
</style></head>
<body>
<table width="737" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#139433">
<tr>
<td align="center" ><span class="style1"><!-- InstanceBeginEditable name="EditRegion4flashbanner" -->
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','700','height','160','title','banner','src','images/banner_restofsite','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','images/banner_restofsite' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="700" height="160" title="banner">
<param name="movie" value="images/banner_restofsite.swf">
<param name="quality" value="high">
<embed src="images/banner_restofsite.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="700" height="160"></embed>
</object></noscript>
<!-- InstanceEndEditable --></span></td>
</tr>
<tr>
<td bgcolor="#000000" align="center"> <div class="nav">
<ul>
<li><a href=""></a></li>
<li><a href="index.htm">Home </a></li>
<li><a href="readingepisodes.htm">Get Started </a></li>
<li><a href="back_episodes.htm">Back Episodes </a></li>
<li><a href="characterbiogs.htm">Character Biographies </a></li>
<li><a href="chattest.html"> Chat Room </a></li>
<li><a href="aboutus.htm"> About Us </a></li>
</ul></div></td>
</tr>
</table>
<!-- InstanceBeginEditable name="bodyarea" -->
<table width="737" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#139433">
<tr>
<td align="center" valign="middle"><p><iframe src="http://www.craicatthevillage.com/mychat/chat/" name="chat_iframe" width="728" marginwidth="0" height="450" marginheight="0" align="middle" scrolling="auto" frameborder="0"><a href="http://www.craicatthevillage.com/mychat/chat/">chat</a></iframe>
</p></td>
</tr>
</table> </table>
<table width="737" height="94" border="0" align="center" cellpadding="0" cellspacing="0" background="images/background2.jpg">
<tr></tr>
<tr height="5"></tr>
<tr>
</tr>
</table>
<table width="728" border="0" align="center" cellpadding="0" cellspacing="0">
</table>
<!-- InstanceEndEditable -->
</body>
<!-- InstanceEnd --></html>
I tryed that in my code and i cant seem to get it working..here it is.. Could you please have a look and see where you think i should put that code? please..
That code should go at the very start of your document, before the DOCTYPE...
<?php
// PHP CODE HERE....
?>
<!DOCTYPE HTML PUBLIC...... etc.
Your page will also need to end in ".php" (for the PHP to get parsed by the server), which I had assumed it was since you have a PHP chatroom?
You have to be a little careful that the 'print <<<END' block is exactly as shown, with (the closing) 'END;' on its own with no space before or after.
Do you get any errors reported?