Jump to content

[SOLVED] I cant count... no.. really..


squiggerz

Recommended Posts

I have been fighting with this for hours..

Below is an excerpt of what I'm working with. I have a list of domains in a text file, I upload the text file through  a form to my script. All of this is fine and dandy. I have a checkbox set to ask user if they want to stall for 10 minutes after 400 domains are ran through this script before executing 400 more. I can get the script to count the total amount of domains in the file, I just cant wrap my head around what I'm supposed to do if the counted number of domains reaches 400.

 

if ($sleep)
			{
				$counted = count($doms);
					while ($counted < 400)
						{

	                                          execute the script on the domain name;

						} pseudocode from here on:
                                                 when $counted == 400 
                                                        { 
                                                              sleep(600)
                                                        }
                                                  then continue till $counted == 800 ... 
			} 

 

Anybody have any idea how this can be accomplished?

Link to comment
https://forums.phpfreaks.com/topic/54720-solved-i-cant-count-no-really/
Share on other sites

Thank you so much! I had to rearrange it a bit for it to work with what I had, but it did work, now I can sleep! Thanks again!

 

if($sleep)
{
  $i = 0;
  foreach($doms as $key => $value)
						{

							$domain = trim($value);
							require 'single.php';
							$i++;

							if($i == '400')
									  {
									    echo "400 domains - resting 10 minutes";
									    sleep(600);
									    $i = '0';
				 					  }	
						}

		}

 

I think you'll find that for it to work correctly you'll need the if($i == 400) part before you output single.php. Otherwise I think it will echo 401 records at a time.

<?php
if($sleep)
{
  $i = 0;
  foreach($doms as $key => $value)
						{
							if($i == '400')
									  {
									    echo "400 domains - resting 10 minutes";
									    sleep(600);
									    $i = '0';
				 					  }														
							$domain = trim($value);
							require 'single.php';
							$i++;
						}

		}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.