public function actionSend()
 {
     /* @var $contacts LuxContactInfo */
     $name = Yii::app()->request->getParam('name', null);
     $email = Yii::app()->request->getParam('mail', null);
     $message = Yii::app()->request->getParam('message', null);
     $cap_id = Yii::app()->request->getParam('cap_id', null);
     $cap = Yii::app()->request->getParam('cap', null);
     $contacts = LuxContactInfo::model()->findAll();
     if (count($contacts) > 0) {
         $contact = $contacts[0];
     } else {
         $contact = new LuxContactInfo();
     }
     $success = false;
     if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
         $captcha = new DwCaptcha();
         if (strlen($message) < 7 || !$captcha->CheckCaptcha($cap, $cap_id)) {
             $success = false;
         }
         if (strlen($message) > 7 && $captcha->CheckCaptcha($cap, $cap_id)) {
             $subject = $contact->getLngObject(Yii::app()->language)->feedback_subject;
             $to = $contact->administrator_email;
             //send email
             $headers = array();
             $headers[] = "MIME-Version: 1.0";
             $headers[] = "Content-type: text/plain; charset=iso-8859-1";
             $headers[] = "From: " . $name . " <" . $email . ">";
             $headers[] = "Subject: {$subject}";
             $headers[] = "X-Mailer: PHP/" . phpversion();
             $success = mail($to, $subject, $message, implode("\r\n", $headers));
         }
     }
     if ($success) {
         $this->redirect(UrlHelper::GetActionUrl('pages', 'index') . '#contacts');
     } else {
         $this->redirect(UrlHelper::GetActionUrl('pages', 'index', array('error' => 1)) . '#contacts');
     }
 }
Ejemplo n.º 2
0
<?php

/* @var $capObj CaptchaObject */
/* @var $error bool */
?>

<form method="post" action="<?php 
echo UrlHelper::GetActionUrl('feedback', 'send');
?>
">
    <div class="feedback-data">
        <input type="text" name="name" placeholder="Name">
        <input type="text" name="mail" placeholder="Mail">

        <div class="captcha">
            <p><?php 
echo Translations::Translate('Enter symbols');
?>
 <br> <?php 
echo Translations::Translate('in the picture');
?>
</p>
            <?php 
$cap = new DwCaptcha();
$capObj = $cap->GetRandomCaptcha();
?>
            <input type="hidden" name="cap_id" value="<?php 
echo $capObj->GetId();
?>
">
            <img style="width: 90px; height: 40px" src="<?php