Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-23-2006, 09:16 AM
pyro.699 pyro.699 is offline
 
Join Date: Sep 2005
Location: Fredericton, New Brunswic
Posts: 261
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default PHP: Timedelay between outputs!

Hello everyone,
I have spent the last few weeks trying to get this small script to work, and it seemes verry simple. But, as we all know with php, looks can be deciving...

When you go to install a fresh copy of vbulletin, and it is at step 3 (or greater) and is adding the tables, and inserting info into the MySQL Database. How the vBulletin has designed the script, to show the completion srcipt:
PHP Code:
echo "<li>$explain[$key]</li>\n"
Quote:
# Creating access table
# Creating adminhelp table
# Creating administrator table
# Creating adminlog table
# Creating adminutil table
...
Now, if by chance, the script runs into an error, it halts the script, and then it displays an error... what i want to know, is how did the make the text appear, as the scripts were being run? I have made a script, that makes alot of files, and i would like it to display the files that it has created. Now i know that i could just take the easy way out and go:
PHP Code:
$d dir("./directory/");
while (
false !== ($entry $d->read())) 
{
    if (
$entry == "." or $entry == "..")
    {}
    else
    {
        
//Stuff for if the files name is not . or ..
    
}

But, I would like to know the ones that it has just made... So, putting it in simple terms, i want something like "sleep{};" , but NOT sleep(); with Sleep, it adds up the ammont in to one large sum, i want some to appear, before that happens.

Ok, i hope i have supplied you with enough information. Thankyou to any help in advanced
-Cody Woolaver
Reply With Quote
  #2  
Old 02-23-2006, 09:25 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I really don't get what you are asking.

If you want to output lines before the page is finished, have a look into flush() and ob_flush(), or search the PHP documentation for Output Control Functions
Reply With Quote
  #3  
Old 02-24-2006, 12:45 AM
pyro.699 pyro.699 is offline
 
Join Date: Sep 2005
Location: Fredericton, New Brunswic
Posts: 261
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, when you think about it, its actchually quite simple...

I am creating mass ammounts of files, (in the thousands(please don't ask what they're for)), and i have a script set up to do it all in one simple process. I want it to only display text as the file is displayed:

-File#1 gets made
-At the moment, the only text on the screen should be "Creating File #1: 5jd9ndio.djb" ---
-File#2 gets made
-Now since another file has been made mroe text has been added, so it should all say:
Quote:
Creating File #1: 5jd9ndio.djb
Creating File #2: 7uq3yahv.djb
---
??What if??
-Ok, i make File #4 have an ileagle name (/ \ : * ? < > |)
-"5*d9|sj:/.djb"
-It should now say:
Quote:
Creating File #1: 5jd9ndio.djb
Creating File #2: 7uq3yahv.djb
Creating File #3: 9di8digk.djb
Warning: file_put_contents(./5*d9|sj:/.djb) [function.file-put-contents]: failed to open stream: Invalid argument in [file.php] on line [line#]

...


So, putting all file making aside, i would like this to happen (pretend the quote boxxes is 1 .php file)
Start of Page->
Quote:
Originally Posted by new.php
B
2 Seconds Latter->
Quote:
Originally Posted by new.php
Bo
2 Seconds Latter->
Quote:
Originally Posted by new.php
Bob
2 Seconds Latter->
Quote:
Originally Posted by new.php
Bob
2 Seconds Latter->
Quote:
Originally Posted by new.php
Bob D
2 Seconds Latter->
Quote:
Originally Posted by new.php
Bob Di
2 Seconds Latter->
Quote:
Originally Posted by new.php
Bob Die
2 Seconds Latter->
Quote:
Originally Posted by new.php
Bob Died
Now rember there is a time delay
Reply With Quote
  #4  
Old 02-24-2006, 12:52 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Checkout sleep()/usleep() and flush()
Reply With Quote
  #5  
Old 02-24-2006, 12:54 AM
pyro.699 pyro.699 is offline
 
Join Date: Sep 2005
Location: Fredericton, New Brunswic
Posts: 261
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I Did, it adds them up, ill give you part of my code...
PHP Code:
$number 0;
foreach (
$songs as $filename
{
        
$songname "$filename";
        
$filename "./ddrsongs/$filename.ddr";
        if(
file_exists($filename)) 
        
$variable file_get_contents($filename);
        
$variable "[$songname] - User Favorites:\n";
        
file_put_contents($filename$variable);
        
$number $number 1;
        
// Rename For output
        
$before = array('[heart]''[2]''[star]''[A]''[coma]''[q-mark]''[e]');
        
$after = array('&hearts;''<sup>2</sup>''★''&forall;'',''?''é');
        
$entry str_replace($before['...'], $after['...'], $songname);
        ...
        
$output "    <li>Creating File #$number$entry</li>\n";
        echo 
$output;
        

Hey, umm, i just got it ^^;
PHP Code:
        sleep(1);
        echo 
$output;
        
ob_flush();
        
flush(); 
thanks anyway ^^;
Reply With Quote
Reply


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:50 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04106 seconds
  • Memory Usage 2,223KB
  • 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
  • (4)bbcode_php
  • (11)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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_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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete