Code: Select all
<?php
defined( '_VALID_WT' ) or die( 'Direct Access to this location is not allowed.' );
$content='';
switch($task) {
case "sendmail":
$content.=sendmail( $option );
break;
default:
$content.=contactpage( $option, $Itemid );
break;
}
function contactpage( $option, $Itemid ) {
global $database, $mainframe, $cur_template, $lang, $Itemid;
$tfile = 'templates/'.$cur_template.'/components/com_contact.html';
$ffile = 'templates/'.$cur_template.'/components/com_contact.inc';
if (file_exists($tfile)) {
if ($tpl_main = temp_load($tfile)) {
$database->setQuery( "SELECT value FROM #__globals WHERE name='contact_txt' LIMIT 1" );
$txt = null;
$database->loadObject( $txt );
$contact['_CONTACT_FORM_TOP'] = $txt->value;
if (file_exists($ffile)) {
include $ffile;
}
temp_subs($tpl_main, "contact", $contact);
temp_done($tpl_main);
$ret .= temp_out($tpl_main);
}
} else {
$ret.='Can\'t find file '.$tfile;
}
return $ret;
}
function sendmail( $option ) {
global $database, $Itemid, $lang;
global $mainframe;
$ret = '';
$ypost = trim( mosGetParam( $_POST, 'ypost', '' ) );
$email = trim( mosGetParam( $_POST, 'email', '' ) );
$contact = trim( mosGetParam( $_POST, 'contact', '' ) );
$database->setQuery( "SELECT value FROM #__globals WHERE name='contact_recipient' LIMIT 1" );
$recipient = null;
$database->loadObject( $recipient );
$email_to=$recipient->value;
$database->setQuery( "SELECT value FROM #__globals WHERE name='contact_subject' LIMIT 1" );
$sub = null;
$database->loadObject( $sub );
$subject=$sub->value;
$mails=explode(";",$email_to);
$m= new Mail; // create the mail
$m->From( $mainframe->getCfg('sitename').'<'.$mails[0].'>' );
$m->To( $mails );
$m->Subject( $subject );
$m->Content_type( "text/html" );
$message = _CONTACT_POST.': '.$ypost.'<br/>';
$message .= _CONTACT_MAIL.': '.$email.'<br/>';
$message .= _CONTACT_INFO.': '.$contact.'<br/>';
// set the body
if ($lang==4) {
$m->Body( $message, "windows-1251" );
} else {
$m->Body( $message, "iso-8859-1" );
}
$m->Send(); // send the mail
$ret.='<script> alert("'._THANK_MESSAGE.'"); document.location.href=\''.sefRelToAbs("index.php?option=$option&Itemid=$Itemid&lang=$lang").'\';</script>';
return $ret;
}
function is_email($email){
$rBool=false;
if(preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $email)){
$rBool=true;
}
return $rBool;
}
?>