文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>PHP做的服务器端的PUSH

PHP做的服务器端的PUSH

时间:2007-02-17  来源:PHP爱好者

PHP做的PUSH
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
/*------------------------------------------------------------------------------------
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
Server push PHP3 script
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
-------------------------------
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
A very short routine to perform simple server push animation,
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
with browser detection snippset. Server push work's only with
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
Netscape 4.0 or higher.
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
Author: Fabian Dennler, [email protected]
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
Date:01.05.2000
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF

ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
Insert the server push script like an image in your html file.
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
i.e. <IMG SRC="campush.php3">
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
------------------------------------------------------------------------------------*/
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
// filelocation of the webcam image
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$filename= "cam.jpg";
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
// how many time between push
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
// for unbuffered output set to 1.
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$pause = "10";
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
// how many time to pass to passthru fun
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
// ction , don't set this to high for serve
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
// r usage
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$PASSES = 20;
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF

ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
/*------------------------------------------------------------------------------------
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
for ($j=0;$j<=$PASSES;$j++) {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$img[count($img)] = $filename;
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
/*------------------------------------------------------------------------------------
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
/*------------------------------------------------------------------------------------*/
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
/* Plot the Currrent Data Block of the image */
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
/*------------------------------------------------------------------------------------*/
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
function plot_cam() {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
global $filename,$img,$pause;
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$k = 0;
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
Header("Content-type: multipart/x-mixed-replace;boundary=ThisRandomString");
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
while ($img[$k]==$filename) {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
print("n--ThisRandomStringnn");
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
Header("Content-type: text/plain");
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$cam = fopen($filename,"r");
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
fpassthru($cam);
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
fclose($cam);
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if ($pause) { sleep($pause);} // time between reload, usefull for server usage
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$k++;
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if ($k==count($img)) {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
echo("n--ThisRandomString--n");
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
/**************************************************************************************/
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
Broser Detection is provided by Leon Atkinson <[email protected]>
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
/*------------------------------------------------------------------------------------*/
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
/* Get the name the browser calls itself and what version */
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$Browser_Name = strtok($HTTP_USER_AGENT, "/");
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$Browser_Version = strtok(" ");
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
/* MSIE lies about its name */
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if(ereg("MSIE", $HTTP_USER_AGENT)) {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$Browser_Name = "MSIE";
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$Browser_Version = strtok("MSIE");
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$Browser_Version = strtok(" ");
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$Browser_Version = strtok(";");
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
/* Opera isn't completely honest, either ... */
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
/* Modificaton by Chris Mospaw <[email protected]> */
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if(ereg("Opera", $HTTP_USER_AGENT)) {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$Browser_Name = "Opera";
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$Browser_Version = strtok("Opera");
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$Browser_Version = strtok("/");
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$Browser_Version = strtok(";");
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
/* try to figure out what platform, windows or mac */
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$Browser_Platform = "unknown";
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if(ereg("Windows",$HTTP_USER_AGENT)
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
|| ereg("WinNT",$HTTP_USER_AGENT)
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
|| ereg("Win95",$HTTP_USER_AGENT)) {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$Browser_Platform = "Windows";
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if(ereg("Mac", $HTTP_USER_AGENT)) {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$Browser_Platform = "Macintosh";
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if(ereg("X11", $HTTP_USER_AGENT)) {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
$Browser_Platform = "Unix";
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if(($Browser_Platform == "Windows")){
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if($Browser_Name == "Mozilla") {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if($Browser_Version >= 3.0) {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
// SERVER PUSH WORK'S ONLY HERE :)
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if($Browser_Version >= 4.0) { plot_cam(); }
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
elseif($Browser_Platform == "Macintosh") {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if($Browser_Name == "Mozilla") {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if($Browser_Version >= 3.0) {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
// SERVER PUSH WORK'S ONLY HERE :)
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if($Browser_Version >= 4.0) {plot_cam();}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
elseif($Browser_Platform == "Unix") {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if($Browser_Name == "Mozilla") {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if($Browser_Version >= 3.0) {
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
// SERVER PUSH WORK'S ONLY HERE :)
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
if($Browser_Version >= 4.0) { plot_cam();}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
}
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
exit;
ww w.china it power.coBo7L0FJSv7AfHKq36i2ZbCxzF
?>
php爱好者站 http://www.phpfans.net PHP|MySQL|javascript|ajax|html.
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载