Ändere die Datei controller.php im Ordner components\com_contact entsprechend den Änderungen im nachfolgendem Code und du bekommst automatisch auch die IP des Absenders mitgesendet ohne das dieser dies bemerkt.
(Code ist für die aktuelle 1.5.23 gültig und ab 21.02.2010)
Für die 1.5.14 müßte man die Änderungen an der entspechend Stelle ebenfalls wohl in der Datei controller.php im Ordner components\com_contact entsprechen "einbauen".
PHP-Code:
// Initialize some variables
$db = & JFactory::getDBO();
$SiteName = $mainframe->getCfg('sitename');
$default = JText::sprintf( 'MAILENQUIRY', $SiteName );
$contactId = JRequest::getInt( 'id', 0, 'post' );
$name = JRequest::getVar( 'name', '', 'post' );
$email = JRequest::getVar( 'email', '', 'post' );
$subject = JRequest::getVar( 'subject', $default, 'post' );
$body = JRequest::getVar( 'text', '', 'post' );
$bodykopie = JRequest::getVar( 'text', '', 'post' );
$emailCopy = JRequest::getInt( 'email_copy', 0, 'post' );
$vonipAdresse = "IP-Adresse: ".$_SERVER['REMOTE_ADDR']." Name: ";
// load the contact details
$model = &$this->getModel('contact');
// query options
$qOptions['id'] = $contactId;
$contact = $model->getContact( $qOptions );
if($contact->email_to == '' && $contact->user_id != 0)
{
$contact_user = JUser::getInstance($contact->user_id);
$contact->email_to = $contact_user->get('email');
}
/*
* If there is no valid email address or message body then we throw an
* error and return false.
*/
jimport('joomla.mail.helper');
if (!$email || !$body || (JMailHelper::isEmailAddress($email) == false))
{
$this->setError(JText::_('CONTACT_FORM_NC'));
$this->display();
return false;
}
// Contact plugins
JPluginHelper::importPlugin( 'contact' );
$dispatcher =& JDispatcher::getInstance();
// Input validation
if (!$this->_validateInputs( $contact, $email, $subject, $body ) ) {
JError::raiseWarning( 0, $this->getError() );
return false;
}
// Custom handlers
$post = JRequest::get( 'post' );
$results = $dispatcher->trigger( 'onValidateContact', array( &$contact, &$post ) );
foreach ($results as $result)
{
if (JError::isError( $result )) {
return false;
}
}
// Passed Validation: Process the contact plugins to integrate with other applications
$results = $dispatcher->trigger( 'onSubmitContact', array( &$contact, &$post ) );
$pparams = &$mainframe->getParams('com_contact');
if (!$pparams->get( 'custom_reply' ))
{
$MailFrom = $mainframe->getCfg('mailfrom');
$FromName = $mainframe->getCfg('fromname');
// Prepare email body
$prefix = JText::sprintf('ENQUIRY_TEXT', JURI::base());
$body = $prefix."\n".$vonipAdresse.$name.' <'.$email.'>'."\r\n\r\n".stripslashes($body);
$bodykopie = $prefix."\n".$name.' <'.$email.'>'."\r\n\r\n".stripslashes($bodykopie);
$mail = JFactory::getMailer();
$mail->addRecipient( $contact->email_to );
$mail->setSender( array( $email, $name ) );
$mail->setSubject( $FromName.': '.$subject );
$mail->setBody( $body );
$sent = $mail->Send();
/*
* If we are supposed to copy the admin, do so.
*/
// parameter check
$params = new JParameter( $contact->params );
$emailcopyCheck = $params->get( 'show_email_copy', 0 );
// check whether email copy function activated
if ( $emailCopy && $emailcopyCheck )
{
$copyText = JText::sprintf('Copy of:', $contact->name, $SiteName);
$copyText .= "\r\n\r\n".$bodykopie;
$copySubject = JText::_('Copy of:')." ".$subject;
$mail = JFactory::getMailer();
$mail->addRecipient( $email );
$mail->setSender( array( $MailFrom, $FromName ) );
$mail->setSubject( $copySubject );
$mail->setBody( $copyText );
$sent = $mail->Send();
}
}
$msg = JText::_( 'Thank you for your e-mail');
$link = JRoute::_('index.php?option=com_contact&view=contact&id='.$contact->slug.'&catid='.$contact->catslug, false);
$this->setRedirect($link, $msg);
}
/**
* Method to output a vCard
*
* @static
* @since 1.0
*/
Insbesondere die neu hinzugefügte Variable $vonipAdresse gibt diese Angabe weiter.
Und die neue Variable $bodykopie sorgt auch dafür das der Absender dies nicht bemerkt !
Dies ist aber ein Änderung des Joomla-Core und deshalb mußt du die Änderung nach jedem weiteren Update auf Funktion bzw. Überschreiben der Datei controller.php durch das Update prüfen.
Nachfolgend noch als Anhang die komplette geänderte controller.php bei der nur noch der Dateiname von controller.php.doc in controller.php geändert werden muß um sie zu benutzen:
controller.php.doc
Lesezeichen