|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Comet example 1</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function chat(txt) {
document.getElementById("chat").innerHTML += txt;
}
</script>
</head>
<body>
<div id="chat"></div>
<?php
for($i=0; $i<10; $i++) {
echo '<script type="text/javascript">';
echo 'chat("<p>server is still alive at '.date('Y-m-d H:i:s').'</p>");';
echo '</script>';
// sende die Ausgabe zum Browser
flush();
// warte 0.2 Sekunden um den Server zu entlasten
usleep(1000000);
}
?>
<script type="text/javascript">
chat("<p>server is done</p>");
</script>
</body>
</html>
|
This post has been edited 1 times, last edit by "toxic" (Oct 27th 2011, 7:06pm)
This post has been edited 3 times, last edit by "toxic" (Oct 28th 2011, 1:10am)
|
|
Source code |
1 |
<FRAME SRC="oframe.php?id=<?php print $id?>" marginwidth="0" marginheight="0" name="Output"> |
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?php
for($i=0; $i<999999999999999999999999999999999999999999999; $i++) {
ob_flush();
print date("H:i");
print "<br><script>scrollWindow()</script>";
// sende die Ausgabe zum Browser
ob_flush();
flush();
// warte x Sekunden um den Server zu entlasten
usleep(500000);
}
?>
|
This post has been edited 1 times, last edit by "toxic" (Oct 28th 2011, 10:13pm)
|
|
PHP Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<script type="text/javascript"> function Chat() { this.timer = aktuelle uhrzeit; window.setInterval(this.checkInterval, 500); this.write = function(msg) { this.timer = aktuelle uhrzeit; document.getElementById('msg').innerHTML += '<p>' + msg + '</p>'; scrollWindow(); }; this.checkInterval = function() { if(this.timer älter als 30 sekunden) { window.location.refresh(); } }; } var chat = new Chat(); </script> <div id="msg"></div> <?php while(1) { print "<script>chat.write('hello world')</script>"; // sende die Ausgabe zum Browser ob_flush(); flush(); // warte x Sekunden um den Server zu entlasten usleep(500000); } |
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
for($i=0; $i<999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999; $i++) {
ob_flush();
if ($s == 1){
$s=0;
}else{
//setze den eintrag im chat
if($result = $db->query("SELECT * FROM $roomy ORDER by id DESC LIMIT 1")){
while ($data = $result->fetch_object() ){
$eintragung = $data->id;
if ($line_id < $eintragung){
if ($data->message != "")print $data->message."<br>";
//ob_flush();
flush();
//ob_end_flush()
print "<script type=\"text/javascript\">
scrollWindow()
</script>";
$line_id = $data->id;
}}
//setze private nachrichten im chat
if($result = $db->query("SELECT * FROM privat WHERE nick = '$nickname' ORDER by id DESC LIMIT 1")){
while ($data = $result->fetch_object() ){
$eintragung = $data->id;
if ($line_id < $eintragung){
if ($data->message != "")print $data->message."<br>";
//ob_flush();
flush();
//ob_end_flush()
print "<script type=\"text/javascript\">
scrollWindow()
</script>";
$line_id = $data->id;
}}
// sende die Ausgabe zum Browser
ob_flush();
flush();
// warte x Sekunden um den Server zu entlasten
usleep(500000);
}
}}
|
This post has been edited 11 times, last edit by "toxic" (Oct 30th 2011, 7:47pm)
This post has been edited 3 times, last edit by "toxic" (Oct 31st 2011, 11:39pm)