我正在使用 Joomla Easy Flash Uploader,上传完成后,会有一封自动电子邮件发送给管理员(或我选择的人)。它旨在在电子邮件中显示登录用户的姓名,但它只是继续显示“Guest”,即使该表单仅由登录用户访问。我迫切需要这个来正确提取用户名。消息的内容如下:(文件名和位置已被删除以保护我的网站。
一位客人 (Guest) 已于 2013 年 3 月 12 日星期二 14:56:07 -0500 成功将 FILE NAME 上传到 LOCATION。
- 查看代码:
//邮件通知 if ($_POST['notify'] != false && JMailHelper::isEmailAddress($_POST['recipient'])) { //获取邮件对象 $mailer =& JFactory::getMailer();
//set up the sender
$config =& JFactory::getConfig();
$sender = array(
$config->getValue( 'config.mailfrom' ),
$config->getValue( 'config.fromname' )
);
$mailer->setSender($sender);
//set up recipient
$mailer->addRecipient($_POST['recipient']);
//get user info
$user_info = array();
$user =& JFactory::getUser();
if ($user->guest == true)
{
$user_info['name'] = 'A guest';
$user_info['username'] = 'Guest';
}
else
{
$user_info['name'] = $user->name;
$user_info['username'] = $user->username;
}
//set up message
$body = $user_info['name']." (".$user_info['username'].") has successfully uploaded ".$fileName;
$body.= "(".sizeToText($fileSize).") to ".JPATH_SITE.DS.$cleanedSubPath;
$body.= " at ".date("r", time()).".\n";
$mailer->setSubject('New File Uploaded - PC Scribe');
$mailer->setBody($body);
//send email
$send =& $mailer->Send();
if ($send !== true)
{
//error: DO NOTHING!!!
/****DEBUGGING****/
//$replaceText.= ' * Email error *';
/**** CODE ****/
}
else
{
//success: DO NOTHING!!!
/****DEBUGGING****/
//$replaceText.= ' (Email sent)';
/**** CODE ****/
}
}