Source code for file /joomla/utilities/utility.php
Documentation is available at utility.php
* @version $Id: utility.php 6287 2007-01-16 00:31:17Z Jinx $
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant to the
* GNU General Public License, and as distributed it includes or is derivative
* of works licensed under the GNU General Public License or other free or open
* source software licenses. See COPYRIGHT.php for copyright notices and
* JUtility is a utility functions class
* @package Joomla.Framework
* Mail function (uses phpMailer)
* @param string $from From e-mail address
* @param string $fromname From name
* @param mixed $recipient Recipient e-mail address(es)
* @param string $subject E-mail subject
* @param string $body Message body
* @param boolean $mode false = plain text, true = HTML
* @param mixed $cc CC e-mail address(es)
* @param mixed $bcc BCC e-mail address(es)
* @param mixed $attachment Attachment file name(s)
* @param mixed $replyto Reply to email address(es)
* @param mixed $replytoname Reply to name(s)
* @return boolean True on success
function sendMail($from, $fromname, $recipient, $subject, $body, $mode=
0, $cc=
null, $bcc=
null, $attachment=
null, $replyto=
null, $replytoname=
null )
$mail->setSender(array($from, $fromname));
$mail->setSubject($subject);
// Are we sending the email as HTML?
$mail->addRecipient($recipient);
$mail->addAttachment($attachment);
// Take care of reply email addresses
$numReplyTo =
count($replyto);
for ( $i=
0; $i <
$numReplyTo; $i++
){
$mail->addReplyTo( array($replyto[$i], $replytoname[$i]) );
} elseif( isset
( $replyto ) ) {
$mail->addReplyTo( array( $replyto, $replytoname ) );
* Sends mail to administrator for approval of a user submission
* @param string $adminName Name of administrator
* @param string $adminEmail Email address of administrator
* @param string $email [NOT USED TODO: Deprecate?]
* @param string $type Type of item to approve
* @param string $title Title of item to approve
* @param string $author Author of item to approve
* @return boolean True on success
function sendAdminMail( $adminName, $adminEmail, $email, $type, $title, $author, $url =
null )
$subject =
JText::_( 'User Submitted' ) .
" '".
$type .
"'";
$message =
sprintf ( JText::_( 'MAIL_MSG_ADMIN' ), $adminName, $type, $title, $author, $url, $url, 'administrator', $type);
$message .=
JText::_( 'MAIL_MSG') .
"\n";
eval
("\$message = \"$message\";");
$mail->addRecipient($adminEmail);
$mail->setSubject($subject);
$mail->setBody($message);
* Provides a secure hash based on a seed
* @param string Seed string
return md5( $conf->getValue('config.secret') .
md5( $seed ) );
* Method to determine a hash for anti-spoofing variable names
* @return string Hashed var name
return $session->getToken($forceNew);
* Method to extract key/value pairs out of a string with xml style attributes
* @param string $string String containing xml style attributes
* @return array Key/Value pairs for the attributes
// Lets grab all the key/value pairs using a regular expression
$numPairs =
count($attr[1]);
for($i =
0; $i <
$numPairs; $i++
)
$retarray[$attr[1][$i]] =
$attr[2][$i];
* Method to determine if the host OS is Windows
* @return true if Windows OS