Re: [PHP] Array question - Please help

2002-05-23 Thread 1LT John W. Holmes

Write your results to a file and create a mail from the file once a day and
send it to yourself with cron, or use a database to hold the results if one
is available.

Instead of making a mail message with your loop, write information back to
the file. Format your file like this:

url, pass, fail, last_fail_time



The create another PHP script that simply loads up the .txt file and formats
an email with it to give you the results, and call it with cron/at.

I wrote that kind of quickly, so adapt to your needs and it may have
errors...but hopefully you get the idea. You can take out the isset() parts
if you want to go through and format your file in the correct format (with
all four columns). if you leave them in there, it'll basically take the file
you have now and reformat it to the new one the first time it's ran. Also
it'll make it so you can just add in a url, w/o having to put zero, zero,
and None for the other columns. adapt to your needs.

---John Holmes...

- Original Message -
From: "Dan McCullough" <[EMAIL PROTECTED]>
To: "PHP General List" <[EMAIL PROTECTED]>
Sent: Thursday, May 23, 2002 1:03 PM
Subject: [PHP] Array question - Please help


> Here is the problem.  I have over 60 subdomains to check on a regular
basis.  I wrote a php script
> that gets a list from a text file and then checks whether it can open that
domain/subdomain.  That
> works great.  My problem is that everything is lumped together, so I have
to scan a list of 60
> names for the one that fails, I also get 1 email for each time the check
fails.
>
> How can I get a list broken up by failed and passed, and only get one
email with a list of the
> subdomains that failed.
>
> Here is the script as it stands now.
>
> 
> $url_file = "url.txt";
> $url_list = file($url_file);
>
>   for($x = 0; $x < count($url_list); $x++)
>   {
>   $url_list[$x] = eregi_replace("[\n\r]","",$url_list[$x]);
>   $fp = fsockopen ($url_list[$x], 80, $errno, $errstr, 30);
> if (!$fp) {
> echo "$url_list[$x] has an error.  $errstr ($errno)\n";
> //$subject = "A URL test has failed";
> //$message = "$url_list[$x] has an error.  $errstr ($errno)\r\n";
>
> /*mail("[EMAIL PROTECTED]", $subject, $message, "From:
[EMAIL PROTECTED]\r\n"
> ."Reply-To: [EMAIL PROTECTED]\r\n"
> ."X-Mailer: PHP/" . phpversion());*/
>
> } else {
> echo "$url_list[$x] is up.\n";
> }
>   }
> ?>
>
> =
> 
> "Theres no such thing as a problem unless the servers are on fire!"
>
>
> __
> Do You Yahoo!?
> LAUNCH - Your Yahoo! Music Experience
> http://launch.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Array question - Please help

2002-05-23 Thread Jason Wong

On Friday 24 May 2002 01:03, Dan McCullough wrote:
> Here is the problem.  I have over 60 subdomains to check on a regular
> basis.  I wrote a php script that gets a list from a text file and then
> checks whether it can open that domain/subdomain.  That works great.  My
> problem is that everything is lumped together, so I have to scan a list of
> 60 names for the one that fails, I also get 1 email for each time the check
> fails.
>
> How can I get a list broken up by failed and passed, and only get one email
> with a list of the subdomains that failed.

When you loop through add the status for the domain onto a results array. When 
the loop is finished, then send the mail with the contents of the results 
array.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
To be is to program.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Array question - Please help

2002-05-23 Thread Dan McCullough

Here is the problem.  I have over 60 subdomains to check on a regular basis.  I wrote 
a php script
that gets a list from a text file and then checks whether it can open that 
domain/subdomain.  That
works great.  My problem is that everything is lumped together, so I have to scan a 
list of 60
names for the one that fails, I also get 1 email for each time the check fails.

How can I get a list broken up by failed and passed, and only get one email with a 
list of the
subdomains that failed.

Here is the script as it stands now.

$url_list[$x] has an error.  $errstr ($errno)\n";
//$subject = "A URL test has failed";
//$message = "$url_list[$x] has an error.  $errstr 
($errno)\r\n";

/*mail("[EMAIL PROTECTED]", $subject, $message, "From: 
[EMAIL PROTECTED]\r\n"
."Reply-To: [EMAIL PROTECTED]\r\n"
."X-Mailer: PHP/" . phpversion());*/

} else {
echo "$url_list[$x] is up.\n";
}
  }
?>

=

"Theres no such thing as a problem unless the servers are on fire!"


__
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php