Hello,
I checked the archives a bit, but couldn't find a direct answer to my question, so maybe you can help. I wanted to parse the db for some e-mail addresses, and save these to a file. I did this on a secure php page, and was able to write to a file appropriately.
However, I had to screw around with permissions quite a bit to get this work.
I used the following:
$fh = fopen("url_email.txt", "w");
// url is general, as we have 20+ sites
// on our network
// do query
// blah....
fwrite($fh, $result);
Like I said, I was able to get this work, but some things I don't like about it. First, my file "url_email.txt" had to be present on the server. If it wasn't there, I would get a security error. So finally, I just created blank files on the server and changed my permissions to 777 (which I didn't want to do either) on the file, and was able to get it to work.
Unfortunately, this wasn't as dynamic or flexible as I had hoped. Like I mentioned above, we have about 20+ sites on our network, and creating 20+ files manually was a pain. Second, I wanted to break the files in blocks of 5000 e-mail accounts. Therefore, let's say my site was "Yahoo.com", and it had 11000 email accounts.
I wanted to be able to output:
"yahoo-email1.txt" - first 5000
"yahoo-email2.txt" - next 5000
"yahoo-email3.txt" - last 1000
... etc.
The reason these need to be in plain text is because we use a mass-mailing program that runs in Windows, and it takes lists of e-mail addresses. The reason I want to break up the files in groups of 5000, is because I don't want to run all of the e-mails in one batch, and take a risk of the machine crashing or the internet connection breaking off. One of our sites has 50000 members, and sending mass mail can take a couple of hours for this many. Too much of a chance for network failure.
Obviously, the number of accounts changes, so manually creating 'x' files is a pain in the ass.
I'm relatively new to PHP, and I know something like this can be done in Perl.
Can anyone help me?