Server IP : 185.86.78.101 / Your IP : 216.73.216.108 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/wwwroot/mifepriston.org/models/ |
Upload File : |
<?php namespace app\models; use Yii; use yii\base\Model; /** * ContactForm is the model behind the contact form. */ class ContactForm extends Model { public $name; public $email; public $body; public $g_recaptcha_response; public $g_recaptcha_action; /** * @return array the validation rules. */ public function rules() { return [ // name, email and body are required [['name', 'email', 'body'], 'required'], // email has to be a valid email address ['email', 'email'], [['g_recaptcha_action', 'g_recaptcha_response'], 'safe'], ]; } /** * Sends an email to the specified email address using the information collected by this model. * @param string $email the target email address * @return bool whether the model passes validation */ public function contact($email) { // if ($this->validate() && $this->_validate_recaptcha()) { if ($this->validate()) { Yii::$app->mailer->compose() ->setTo($email) ->setFrom([Yii::$app->params['senderEmail'] => Yii::$app->params['senderName']]) ->setReplyTo([$this->email => $this->name]) ->setSubject('Запитання з сайту ' . $_SERVER['SERVER_NAME']) ->setTextBody($this->body) ->send(); return true; } return false; } /** * Google Recaptcha validation */ private function _validate_recaptcha() { $success = false; if ($this->g_recaptcha_response) { $secret = '6LdsBusUAAAAAPp6JFRLP01xH7W6ZuwSc4YZH4Wh'; $response = file_get_contents( "https://www.google.com/recaptcha/api/siteverify?secret=" . $secret . "&response=" . $this->g_recaptcha_response . "&remoteip=" . $_SERVER['REMOTE_ADDR'] ); $response = json_decode($response); Yii::info($response); if ($response->success === true && $response->score > 0.5) $success = true; } if (! $success) { Yii::warning('Unsuccesfull Google Recaptcha validation'); } return $success; } }