国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
如何在用戶中止了瀏覽器之后,讓php程序繼續(xù)運(yùn)行?
標(biāo)題: 忘了,問一下:如何在用戶中止了瀏覽器之后,讓php程序繼續(xù)運(yùn)行? [打印本頁(yè)]

作者: spiceboy     時(shí)間: 2006-4-6 17:36     標(biāo)題: 忘了,問一下:如何在用戶中止了瀏覽器之后,讓php程序繼續(xù)運(yùn)行?

有個(gè)參數(shù)什么的吧。
是什么參數(shù)???


作者: 北京野狼     時(shí)間: 2006-4-6 17:40


作者: spiceboy     時(shí)間: 2006-4-6 17:47

不用回了。
知道了。
ignore_user_abort
作者: 北京野狼     時(shí)間: 2006-4-6 17:58

你再好好想想。
作者: spiceboy     時(shí)間: 2006-4-6 18:00

就是它啊。還想啥?
算了,不跟你說話,你肯定又打算鉆我牛角尖。
可我需要的就是這個(gè)。
作者: 北京野狼     時(shí)間: 2006-4-6 18:04

應(yīng)該說您自己的牛角太大不用鉆。  你總是不考慮清楚就出來發(fā)表意見, 那就不要抱怨。這不是好態(tài)度。

你需要的不是這個(gè)。

[ 本帖最后由 北京野狼 于 2006-4-6 18:05 編輯 ]
作者: spiceboy     時(shí)間: 2006-4-6 18:12

好好。
我需要的不是這個(gè)。
不是這個(gè)。。。。。
我再去重新找。
作者: 北京野狼     時(shí)間: 2006-4-6 18:15

服務(wù)器如何知道用戶中止了瀏覽器 ?
作者: spiceboy     時(shí)間: 2006-4-6 18:19

別急啊
我不是正在找嗎
找到了再告訴你。
作者: 北京野狼     時(shí)間: 2006-4-6 18:26

找到之后,別忘了通知官方更新一下http協(xié)議
作者: spiceboy     時(shí)間: 2006-4-6 19:20

好的,沒問題。
作者: yzmxf     時(shí)間: 2006-4-6 19:24

呵呵

感覺沒有可能
作者: 韓三普     時(shí)間: 2006-4-6 23:59

這個(gè)功能要配置Apache實(shí)現(xiàn)。當(dāng)你關(guān)了瀏覽器,apache仍然會(huì)做為進(jìn)程工作,我曾經(jīng)用這個(gè)功能,抓過幾G的圖片
作者: spiceboy     時(shí)間: 2006-4-7 00:02

那樓上的你改http協(xié)議了沒?
作者: achieverain     時(shí)間: 2006-4-7 00:05

曾經(jīng)討論過這個(gè)問題。你找一下老帖子
作者: mike519     時(shí)間: 2006-4-7 00:32

北京野狼 有個(gè)性

spiceboy  還沒明白怎么回事啊
作者: 北京野狼     時(shí)間: 2006-4-7 09:45

其實(shí)與http協(xié)議和apache沒什么關(guān)系。 你想想qq, 等客戶端軟件, 斷網(wǎng)了服務(wù)器能立刻知道嗎?

只要客戶端發(fā)出請(qǐng)求,服務(wù)器都是執(zhí)行完了再說。
作者: wobushiwo     時(shí)間: 2006-4-7 11:17

當(dāng)一個(gè)請(qǐng)求完了,服務(wù)器和客戶端之間就不存在狀態(tài)了

比如 客戶端請(qǐng)求,服務(wù)端因?yàn)槭裁词马憫?yīng)太慢,這時(shí)突然關(guān)掉瀏覽器或點(diǎn)“停止”

或是服務(wù)器在給客戶端發(fā)送數(shù)據(jù)時(shí),執(zhí)行了上面的操作,服務(wù)器才能知道

總而言之,要捕抓到這一動(dòng)作,除非是兩者在通信時(shí)發(fā)生的事情

跟HTTP協(xié)議沒關(guān)系,這是socket層面的,它只是規(guī)范信息傳遞的格式
作者: wobushiwo     時(shí)間: 2006-4-7 11:19

好像有點(diǎn)跑題了。。。

QUOTE:
如何在用戶中止了瀏覽器之后,讓php程序繼續(xù)運(yùn)行?
一個(gè)完整的請(qǐng)求過去,服務(wù)器就會(huì)跑完這個(gè)請(qǐng)求了啊。。。
作者: 網(wǎng)絡(luò)混混     時(shí)間: 2006-4-7 11:46

register_shutdown_function
作者: spiceboy     時(shí)間: 2006-4-7 13:13

carlos at fischerinformatica dot com dot br
31-Jan-2002 10:58
Very very useful!
I was building a chat and I wanted my script to detect when the browser was closed, so the user could be deleted from the online_users table.

<?
echo str_repeat(" ",300);
ignore_user_abort(true); //this way, the user can stop the output, but not the script.
while (true) {
         echo "test<br>\n";
         flush();
         sleep(2);
         if (connection_status()!=0){
                 include (‘dbconnect.inc‘);
                 $sql="delete from online_users where online_user=$user";
                 $sql_exec=pg_exec($vChatDB, $sql);
                 die(); //kills the script
         }
}
?>
作者: 北京野狼     時(shí)間: 2006-4-7 13:16



I was building a chat and I wanted my script to detect when the browser was closed
如果你也做聊天室,可以考慮。
作者: spiceboy     時(shí)間: 2006-4-7 13:28

<superspice AT yeah.net> wrote:

vi ignore.php

<?php
Set_Time_Limit(0);
ignore_user_abort(true);
echo "begin, please close or stop your browser in 10 seconds\n";
sleep(10);
touch("test.txt");
echo "end";
?>
I browsed ignore.php with my browser, 10 seconds later, test.txt was created.
Then I deleted "test.txt",  refreshed this page and closed it within 3 seconds.
After a few seconds, "test.txt" was created as before.

It showed me the case that the aborting of users‘ browsing had been ignored.
作者: spiceboy     時(shí)間: 2006-4-7 13:32

I wrote a simple function that can "spawn" another thread within the webserver by making async http request. The page that is being spawned can call ignore_user_abort() and do whatever it wants in the background...

<?php

   function http_spawn($page)
   {
       $basepath=ereg_replace(‘[^/]*$‘, ‘‘, $_SERVER[‘PHP_SELF‘]);
       $cbSock=fsockopen(‘localhost‘, $_SERVER[‘SERVER_PORT‘], $errno, $errstr, 5);
       if ($cbSock)
       {
           fwrite($cbSock, "GET {$basepath}{$page} HTTP/1.0\r\n"
               ."Host: {$_SERVER[‘HTTP_HOST‘]}\r\n\r\n");
       }
   }
?>

Example:
<?php

   if ($search_initialized)
       http_spawn("ftindex.php");
?>
作者: spiceboy     時(shí)間: 2006-4-7 13:41



<?php
ignore_user_abort(true);
// 1.1 處理用戶提交數(shù)據(jù)
$Adodb->StartTrans();
    .........................
    .........................
$Adodb->CompleteTrans();

/* 用戶可能在1.1執(zhí)行完成后,而2.1沒有執(zhí)行前的此處關(guān)閉瀏覽器或死機(jī)? */

// 1.2 處理另一部分?jǐn)?shù)據(jù)
$Adodb->StartTrans();
    .........................
    .........................
$Adodb->CompleteTrans();

// 1.3 校驗(yàn)整個(gè)數(shù)據(jù)的一致性和完整性,并寫錯(cuò)誤日志
   dosomething();
?>
當(dāng)一個(gè)頁(yè)面里放置了2個(gè)或2個(gè)以上的事務(wù)操作。需要這個(gè)頁(yè)面不被中斷。以保持?jǐn)?shù)據(jù)的一致性。
作者: 北京野狼     時(shí)間: 2006-4-7 13:54

你真好有趣啊, 還是再想想吧

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
炒股必看三十圖(箱體篇、量能篇)A
PHP 常用的header頭部定義
php php ignore_user_abort
使用瀏覽器緩存來加快站點(diǎn)的訪問速度
VBA入庫(kù)單改進(jìn)版(窗體錄入的完美例子)
用 PHP 獲得瀏覽器信息?
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服