| Server IP : 104.21.17.213 / Your IP : 216.73.217.141 Web Server : Apache System : Linux hosting01.arsenalhost.com 4.18.0-425.13.1.lve.el8.x86_64 #1 SMP Mon Feb 27 15:23:24 EST 2023 x86_64 User : corbizre ( 1013) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/corbizre/gotofindhomes.com3/components/Contact/Controllers/ |
Upload File : |
<?php
/**
* Documentation
* @author
* @category
* @package
* @subpackage
* @copyright Copyright (c) 2005-2011 ITCrimea Ukraine Inc. (http://www.itcrimea.com)
* @license
*/
class Contact_IndexController extends System_Controller_Base
{
/**
* Documentation
*/
public function indexAction() {
$row = array();
$row['Email'] = $row['Name'] = $row['Message'] = '';
$arrErrors = array();
$isAjax = $this->_request->isXmlHttpRequest();
if (System_User::getRoleID() != System_User::getGuestRoleID()) {
$objUser = System_User::getUser();
$row['Name'] = trim($objUser->FirstName . ' ' . $objUser->LastName);
$row['Email'] = $objUser->Email;
}
if ($this->getRequest()->isPost()) {
$row['Email'] = $this->getRequest()->getParam('Email');
$row['Name'] = $this->getRequest()->getParam('Name');
$row['Message'] = $this->getRequest()->getParam('Message');
$row['FromPage'] = $this->getRequest()->getParam('FromPage','http://'.$_SERVER["SERVER_NAME"].'/contact-us');
$validator = new Zend_Validate_EmailAddress();
if (empty($row['Email'])) {
if ($isAjax) {
$arrErrors[] = 'Please enter your email';
} else {
$this->addErrorMessage('Please enter your email');
}
} elseif (!$validator->isValid($row['Email'])) {
if ($isAjax) {
$arrErrors[] = 'Email "' . $row['Email'] . '" is not valid';
} else {
$this->addErrorMessage('Email "' . $row['Email'] . '" is not valid');
}
}
if (empty($row['Name'])) {
if ($isAjax) {
$arrErrors[] = 'Please enter your name';
} else {
$this->addErrorMessage('Please enter your name');
}
}
if (empty($row['Message'])) {
if ($isAjax) {
$arrErrors[] = 'Please enter message';
} else {
$this->addErrorMessage('Please enter message');
}
}
if (!$this->isErrorMessages() && !count($arrErrors)) {
$this->view->row = $row;
$tblMailTemplate = new LiteMail_Template_Table();
//Send notification to administrator
$select = $tblMailTemplate->select()->where('Name = ?', 'ContactUs');
$mailTemplate = $tblMailTemplate->fetchRow($select);
if(is_object($mailTemplate)){
$email = System_Company::getEmail();
$body = str_replace('{$Message}', $row['Message'], $mailTemplate->Body);
$body = str_replace('{$Name}', $row['Name'], $body);
$body = str_replace('{$Email}', $row['Email'], $body);
$body = str_replace('{$FromPage}', $row['FromPage'], $body);
$objMail = new Zend_Mail();
$objMail->setFrom($email, System_Company::getName());
$objMail->setBodyHtml($body);
$objMail->setSubject($mailTemplate->Subject);
$objMail->addTo($email);
if(!LiteMail_Transport::sendMail($objMail)){
LogSystem::addLog('Contact','index','index', $mailTemplate->ID , LogSystem::SEVERITY_ALERT, 'Sendmail Transport Error: process sending email does not completed', $body);
}
if (!$isAjax) {
$this->addOkMessage('Your message has been successfully sent. You can expect answer within 1-3 days.');
$this->render('index-success');
}
}
}
}
$this->view->row = $row;
if ($isAjax) {
$this->view->Errors = $arrErrors;
$this->render('index-ajax');
}
}
}