/**
* Logs an Attack.
*
* @access private
* @param string email address
* @return boolean true on success
*/
function _actionNotify( $email )
{
global $mainframe;
$mailer =& $mainframe->getMailer();
$mailer->setSender($email);
Chapter 11
[ 337 ]
$mailer->setRecipient($email);
$mailer->setSubject(JText::_('Excessive Attacks Detected'));
$mailer->setBody(JText::_"A user has exceeded the number of
allowed attacks. Please consult your
error log for more details."));
$mailer->Send();
}
This example is relatively simple. We could develop the method further by adding
a more comprehensive subject line and body. If logging is enabled we could also
include a copy of the log as an attachment (we would have to be careful if the log file
was very large).
Summary
Although we may perhaps never receive an error message from our extensions,
the JError class gives us all of the necessary tools to ensure that any errors that are
encountered can be cleanly dealt with. Using the PHP die() and exit() functions
can potentially 'break' the current users session; we should always exit cleanly.
Pages:
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468