Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 12-19-2012, 07:15 PM
vsforums vsforums is offline
 
Join Date: Aug 2006
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to use php sleep function in vb

Hi,

I want to use sleep function in the installation code of the plugin, however i cannot display any message before the function. Everything is being displayed at the end of the installation process.
Example:
echo test;
flush();
ob_flush();
vbflush();
sleep(2);
echo test;
die();

It returns testtest after two minutes and i want to display test and after two minutes another test message.

I tried to use all kind of flush functions, but none of the above worked.

Any idea how I can do that?
Reply With Quote
  #2  
Old 12-19-2012, 08:49 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I believe the issue is that if you have "GZIP HTML Output" set to yes (under "Cookies and HTTP Header Options" in the admincp options), then ob_start() is called before there's any output (which is of course the only way it can be gzip'd before it's sent). It's the same for all the control panel pages, I think. So I think maybe what you could do is something like: (Edit: I removed the code because the code above already calls ob_flush(), and in any case the right thing to do is call vbflush as Paul posted below.)

But I wonder what happens if the web server is set to gzip output? If so, maybe you'll have the same problem even after doing this.

Edit: But I just noticed that you were calling ob_flush(), so if buffering were the problem it seems like that should have done it. So maybe the issue *is* that your web server is buffering. I did a little more research and it looks like if mod_gzip or mod_deflate is configured to compress that type of output, then it will be buffered. (I'm not sure what content-type is sent if you don't explicitly set a header).
Reply With Quote
  #3  
Old 12-19-2012, 09:33 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I use a similar setup with vbulletin gzip off but server gzip on without problem.
Reply With Quote
  #4  
Old 12-19-2012, 10:05 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's good to know. But I wonder what happens in that case? Does the server somehow decide not to gzip it? Or maybe it does it in parts? I guess I'll have to experiment when I get a chance.
Reply With Quote
  #5  
Old 12-19-2012, 10:39 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think its a case of when the gzip is executed as opposed to server files with that level of call. Here's some info http://www.gzip.org/README.mvs
Reply With Quote
  #6  
Old 12-19-2012, 11:00 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I just noticed that the first post does show a call to ob_flush(), so I guess my response about output buffering doesn't make sense.
Reply With Quote
  #7  
Old 12-19-2012, 11:04 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try using the vbflush() function

PHP Code:
echo 'My Message'
vbflush(); 
sleep(5); 
Reply With Quote
2 благодарности(ей) от:
kh99, wfouly
  #8  
Old 01-09-2013, 01:28 PM
vsforums vsforums is offline
 
Join Date: Aug 2006
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi Guys,

I tried to call vbflush(); and that didn't solve my problem. GZIP HTML Output in admin panel is set to no.
What i have now is:

echo $message . "<br />\r\n";
vbflush();
sleep(2);

Any other ideas?
Reply With Quote
  #9  
Old 01-10-2013, 04:18 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you try just making a non-vb php script and see if that works? My understanding is that the web server and even the browser could be buffering output so that what you're trying to do won't work.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:12 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04105 seconds
  • Memory Usage 2,239KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (2)post_thanks_box_bit
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete