|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 13 Mar 2005 09:38:30 -0000 Issue 3335
php-general-digest-help
lists.php.net
Date: Sun Mar 13 2005 - 03:38:30 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 13 Mar 2005 09:38:30 -0000 Issue 3335
Topics (messages 210595 through 210606):
mail()
210595 by: Sebastian
210603 by: Guillermo Rauch
Eliminating CLI overhead
210596 by: Skippy
Re: warning & question about mysql sessions & concurrency
210597 by: Josh Whiting
Re: Building PHP5 on Windows - VS.net?
210598 by: cshmoove.bellsouth.net
Re: Question about "shortening" a string
210599 by: Jochem Maas
Re: SimpleXML add a node
210600 by: Jochem Maas
210602 by: Jochem Maas
210606 by: Claudio
Re: bulk emailer
210601 by: Manuel Lemos
210605 by: Leif Gregory
Mailing List
210604 by: stg
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Hi,
it appears mail() stopped working on my server. i recall it worked
previously. since i haven't used mail() in a while i dont recall when it
stopped working. running php 4.3.10
php.ini is default path for send mail which is the correct path for the
server.. anything else i should be looking for?
attached mail follows:
Hello Sebastian,
It'd very useful for those who want to help you out, a good
explanation of your error.
For example, you're not quoting some error or some error logs that you
found related to this behavior.
For instance, if you refer to:
http://uk.php.net/mail
You'll see there's a note explaining that in order to use mail(), PHP
must have access to the sendmail binary _during installation_. May be,
during some upgrade, this did not work (it has happened to me several
times)
In the other hand, if the mail() seems to work, but the mail is not
getting delivered successfully, there're some other things to check.
Best,
Guillermo Rauch.
attached mail follows:
I intend to run a lot of PHP scripts, all the time, on a Linux machine.
The scripts were designed for CLI environment, since they will handle
the entire management of the machine, being started by init and then
effectively and completely taking over.
I'm wondering whether starting up the PHP interpreter for every script
hurts performance, if there's anything I can do about it, and if possible,
would the potential gain be noticeable? We're talking a machine in the
range of 1 GHz CPU speed, with IDE disk drives. I've already considered
all kinds of Linux-specific "tricks", I'm interested in the pure PHP
aspect of the issue.
--
Skippy - Romanian Web Developers - http://ROWD.ORG
attached mail follows:
On Fri, Mar 11, 2005 at 09:57:46AM -0800, Richard Lynch wrote:
> > well the trouble is not in the writing at the end of the request, which
> > would likely only be a single query and therefore not need a transaction
> > in itself. the trouble is the lack of locking out other requests from
> > reading the data when you're using it during the main body of
> > the request.
[...]
> Short Version: Either your frames/tabs are gonna be so clunky as to be
> useless, or you need to lock them into only one, or you need business
> logic, not session-logic. Solving the race condition at session layer
> will only make your application un-responsive.
>
> This may go a long way to explaining why you're not finding any readily
> available solutions out there at the session layer.
You raise good points. However, my goal is simply to have a
transparent, database-driven replacement for PHP's native session
handler. I don't want to change my application logic because I'm
switching session handlers - my application shouldn't care! And so,
transparently reproducing PHP's session layer functionality is going to
mean locking concurrent requests out, because that is what PHP's session
handler already does (for good reason IMHO).
you're argument about slow frames is valid, but is ALSO applicable to
PHP's native session handler, e.g. i'm not introducing a new problem.
the trouble can be mostly avoided in either case by not starting session
in frames that don't need it (most of them), and doing any session stuff
right away and calling session_write_close() ASAP to free up the lock so
other frames can run.
you're right that i could change my application logic to deal safely
with concurrent requests from the same session, but PHP already nicely
defeats the issue so you don't have to worry about it, and at a more or
less negligable performance loss if you design the scripts to reduce
session open/locked time to the bare minimum...
i would speculate that the reason i haven't found a readily available
solution is because most folks either (1) don't understand the problem,
or (2) don't think such a race condition is likely enough to warrant a
fix, or (3) are using a different backend (oracle, etc.) that makes the
problem easy to solve. the PHP team, however, clearly thought it was
important enough as is evident by their session handler design.
...have i convinced you yet of the worthiness of this endeavor? :)
/jw
attached mail follows:
Jim,
i had only minor issues, but it builds fine otherwise.
"Jim Plush" <jiminoc
gmail.com> wrote in message
news:20050312174434.26058.qmail
lists.php.net...
> Has anyone successfully built php5 using visual studio.net ? or is VC6
> still only supported?
>
> thanks,
> Jim
attached mail follows:
Ashley M. Kirchner wrote:
> Mário Gamito wrote:
...
>> >> Does anyone knows how to do this ?
>> >
>> > <?php
>> > $parts = explode(' ', $fullName);
>> > $shortenedName = $parts[0].' '.$parts[count($parts)-1];
>> > ?>
>> >
>>
> This might solve one problem. What about people who have names like
> 'Pablo Ricardo del Rey' where you can't simply pick first and last
> because their last name really is 'del Rey'. Or 'von Braun', or ...you
> get the idea.
>
I thought so too... I thought maybe you could just provide 3 name text boxes:
<input name="firstname" /><input name="middlenames" /><input name="lastname" />
and store the names seperately, then you could display the short or long
version at will... additionally using substr() and the explode() technique
described above you can also generate their initials to create an even shorter
version of the name.
attached mail follows:
Richard Lynch wrote:
>>>php.net/dom
>>
>>??
>>
>>Like this?
>>
>>---
>>
>>try {
>>
>>$dom = new DOMDocument();
>>
>>$config =
>>$dom->appendChild($dom->importNode(dom_import_simplexml($this->configXML),true));
>>
>>$config->appendChild( $dom->createElement(($mode? 'softactive':'active'))
>>);
>>
>>$this->configXML = simplexml_import_dom($config);
>>
>>} catch(Exception $e) {}
>
>
> I dunno about that whole try/catch thing, but if you're not going to USE
> it to catch the errors, then you might as well be old school and check the
the try/catch block only catch exceptions, you still have to handle the std
errors as normally would - for the old school its business as usual, only this
simester there are a couple of new kids in the class :-).
I'm pretty sure there was alot of discussion about whether to throw exceptions
or trigger errors in the new php5 extensions. I can't actually think of any place
in php5 or the extensions I use where the engine throws an Exceptions...
at any rate all my Exceptions are userland generated. like for instance when
any object is not of the right class I might throw an Exception.
Exceptions are really cool, but they are not are a replacement for var &
error checking.
behold the 'instanceof' keyword. it is good :-)
(free tip: javascript has a 'instanceof' keyword that is
indentical to the php keyword in usage, AFAICT).
the rest (xml) is all french to me :-/
>
attached mail follows:
Jochem Maas wrote:
> Richard Lynch wrote:
>
>>>> php.net/dom
>>>
>>>
>>> ??
>>>
>>> Like this?
>>>
>>> ---
>>>
>>> try {
>>>
>>> $dom = new DOMDocument();
>>>
>>> $config =
>>> $dom->appendChild($dom->importNode(dom_import_simplexml($this->configXML),true));
>>>
>>>
>>> $config->appendChild( $dom->createElement(($mode?
>>> 'softactive':'active'))
>>> );
>>>
>>> $this->configXML = simplexml_import_dom($config);
>>>
>>> } catch(Exception $e) {}
>>
>>
>>
>> I dunno about that whole try/catch thing, but if you're not going to USE
>> it to catch the errors, then you might as well be old school and check
>> the
>
>
> the try/catch block only catch exceptions, you still have to handle the std
> errors as normally would - for the old school its business as usual,
> only this
> simester there are a couple of new kids in the class :-).
>
> I'm pretty sure there was alot of discussion about whether to throw
> exceptions
> or trigger errors in the new php5 extensions. I can't actually think of
> any place
> in php5 or the extensions I use where the engine throws an Exceptions...
I happened upon atleast one place where you can have the engine throw Exceptions
iso triggering errors
this:
$db->setAttribute( PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION );
I found here;
http://wiki.cc/php/PDO_Basics
...
attached mail follows:
richard
> I dunno about that whole try/catch thing, but if you're not going to USE
> it to catch the errors, then you might as well be old school and check the
> return values of all these functions.
that sounds good, but , so far I know, if the API says that a function _can_
throw an exception, I _must_ catch it. In this case 'importNode',
'appendChild', and 'createElement'. If I'm wrong please correct me.
> Since it "works" once and not the second time, I'd be looking to see if
> the XML produced on the first go-around is actually VALID, since, if it's
> not, that would cause this problem, I think.
The first time 'dom_import_simplexml' returns a DOMElement, the second a
DOMDocument. I don't know why.
The string version of the first SimpleXML is: (that produces a DOMElement)
<?xml version="1.0"?><config/>
The string version of the second SimpleXML is: (that produce a DOMDocument)
<?xml version="1.0"?><config><active/><config/>
jason
I'm alredy using the 'dom_import_simplexml' function (line 5, code anexed)
jochem
'instanceof' used now, thanks for reminding. Also if in this case it wasn't
the prpblem.
last of all, a probalbly readable version of the code:
---
// check if there is a valid simplexml document
if (!($this->configXML instanceof SimpleXMLElement))
$this->createConfigXML();
$dom = new DOMDocument('1.0');
// create a DOMElement from SimpleXML
$domElem = dom_import_simplexml($this->configXML);
if ( $domElem === false ) return false;
echo "\n\r".'1:';var_dump($domElem);echo "<BR>\n\r";
try {
// import DOMElement(simplexml) to empty DOMDocument
$domNode = $dom->importNode($domElem,true);
if ( $domNode === false ) return false;
// append the imported node to the DOMDocument
$domNode = $dom->appendChild($domNode);
// create new DOMElement
$domElem = $dom->createElement(($mode? 'softactive':'active'));
// add new Element to DOMElement(simplexml)
$domNode->appendChild( $domElem );
} catch(Exception $e) {
echo 'EXCEPTION: '.$e->getMessage().'<BR/>';
return false;
}
// redefine old simplexml
$simplexml = simplexml_import_dom($dom);
if ($simplexml === false) return false;
$this->configXML = $simplexml;
echo '2:';echo $this->configXML->asXML();echo "<BR>\n\r";
}
return true;
attached mail follows:
Hello,
on 03/11/2005 05:48 PM Redmond Militante said the following:
> i need some advice on making a bulk emailer script more robust.
>
> what i'm currently doing:
> -using mysql_fetcharray() to loop through an array of query results
> -for each iteration of the loop, get an email address from the current row in the result set, and use it with the mail() function to send out an individual email to that email address, then echo out a confirmation in HTML so that the user will know that an email has been sent
> -this is repeated for each email address found in the result set
> problem with this is: with large result sets (some of my result sets come up with a few thousand email addresses), users have to wait a long time for the confirmation messages to print out to their browser, sometimes it seems that not all the messages go through
>
> what i've tried:
> -using mysql_fetcharray() to loop through an array of query results
> -for each iteration of the loop, get an email address from the current row in the result set, and append it to a long strong called $bcc
> -then i plug the value of $bcc into the mail() command, which is
issued only once at the end of the loop
This is a bad idea because many mail systems like hotmail will classify
as junk messages that do not come with the actual recipient address in a
visible header: To: or Cc: .
> -this method seems to work better, does not take as long, HTML confirmation messages get printed faster since mail() function is only called once at the end of the loop, only one email is sent (with a long BCC field), so it doesn't bog the server down so much
> problem with this method is: with large result sets (some of my result sets come up with a few thousand email addresses), the BCC field is so large that it is too large for the mail server to send out
>
> has anyone done a bulk emailer script to send out mass emails? if you have any advice re: methodology, i'd like to hear it.
It depends on what type of MTA.
There is no way to do bulk mailing properly and and avoid long waits.
You need to send separate messages to each recipient due to the problem
mentioned above.
For starters, just stay away from SMTP based solutions if you can. It
works but it takes much longer to queue messages that some alternatives
because you need to deal with TCP overhead, which is silly when your MTA
is in the same machine.
The best alternative is to inject the messages in the local mailer queue
and tell it to no start delivering the messages immediately.
If you can use sendmail (or exim ) there are some switches for the
sendmail command for that purpose. Using qmail or postfix does not
require any switches.
In any case, you may want to try this MIME message composing and sending
class. It provides several means to optimize bulk deliveries,
personalized or not. You can pick a sub-class to optimize deliveries for
the MTA that you use. There are sub-classes for mail, sendmail (or exim
or postfix), qmail, SMTP or Windows pickup folder are supported.
Regardless of which you use, always call SetBulkMail() function before
start looping deliveries to your users.
If you are not personalizing message, you can tell the class to cache
message bodies between deliveries to avoid message regeneration overhead.
If you want to personalize messages, you can even use Smarty as template
engine to speedup personalized message generation.
There are several examples to demonstrate this:
http://www.phpclasses.org/mimemessage
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
attached mail follows:
Hello Richard,
Friday, March 11, 2005, 3:34:01 PM, you wrote:
RL> The mail() function is designed for quickie one-off emails, not
RL> sending out thousands. Hell, it can't even handle dozens, not
RL> reliably, at least not on some hardware/connections.
I've used it to send a little over 3,000.
On one of my TheBat lists, we had a user subscribe with one of those
confounded challenge/response e-mail addresses and the challenge
didn't show what the e-mail address was that the challenge was for, so
I wrote a script to send an e-mail to each subscriber and in the
subject and message body I echo'd out the e-mail address being
e-mailed to.
Within an hour I had the challenge showing the e-mail address in the
subject line and we summarily unsubscribed them.
Granted this was on a Windows system which was using Mercury and not
SendMail though.
Cheers,
Leif Gregory
--
TB Lists Moderator (and fellow registered end-user)
PCWize Editor / ICQ 216395 / PGP Key ID 0x7CD4926F
Web Site <http://www.PCWize.com>
attached mail follows:
Hi
I have two pages
------------
1)
A form with a rich text box and a submit button.
2)
A page which receives the value from the rich text box and emails out to
addresses in a column in a table
------------
For the rich text box its default value is a message saying: "Click the link
below to download the latest newsletter" and a link which get the file path
from a table in the db. Users can then add a message above the link to the
newsletter. Now this all works fine except for the link, (and any other
links I make using the rich text box), firstly when the form is posted a \
is placed before the ", ie <a href\"url.com.au\">Link</a> which renders the
link useless.
Someone suggested stripslashes, which I put on the second page where it
receives the variable; $_POST['msg'], this did remove the slashes however I
then had a problem with spaces in the file path for the newsletter, ie;
url.com/testfile.pdf would be sent instead of url.com/test file.pdf which it
should be.
Then someone suggested urlencode however that encoded the entire message, so
they got Click%20the%20link%20below..
If anyone could help I would be most grateful, I want to be able to send
these default links from the rich text box as well as allow users to add
links in the rich text box.
Cheers,
Simon
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]