/** * Contact Us page render * * @param $page * @return string * @throws Mandrill_Error * @throws \Exception */ private function renderContactUs($page) { $model = new ContactForm(); $mess = ''; if ($model->load(Yii::$app->request->post()) && $model->validate()) { $settings = new Settings(); /** @var string $sendTo - address which collects feedback from customers * @fixme change this emails */ try { $support = $settings->getConfigurationParamByKey('support_email'); } catch (\yii\base\Exception $e) { $support = null; } try { $support = $settings->getConfigurationParamByKey('admin_email'); } catch (\yii\base\Exception $e) { $admin = null; } if (!$support) { $sendTo = \Yii::$app->params['supportEmail']; } else { $sendTo = $support; } if (!$admin) { $replyTo = \Yii::$app->params['adminEmail']; } else { $replyTo = $admin; } $name = Yii::$app->request->post("ContactForm")['name']; $body = Yii::$app->request->post("ContactForm")['body']; $usermail = Yii::$app->request->post("ContactForm")['email']; $subject_internal = Yii::$app->request->post("ContactForm")['subject']; $subject = "New Feedback from {$name} ({$usermail})"; $mailer = new \common\helpers\Mandrill($sendTo, $subject, $local_tpl_name = null, $sender = null, ['from_name' => '[Auto-generated]', 'reply_to' => $replyTo, 'mandrill_template_name' => 'contactrazzd', 'vars' => ['header' => $subject_internal, 'body' => $body, 'usermail' => $usermail]]); $result = $mailer->sendWithMandrillTemplate(); $mess = (string) $result; if ($result) { Yii::$app->session->setFlash('success', 'Your message has been sent.'); } else { Yii::$app->session->setFlash('error', 'Is there something wrong. Contact Support.'); } $model = new ContactForm(); } return $this->render('contact_us', ['page' => $page, 'model' => $model]); }
/** * Действия по завершении загрузки видео * * @return string */ public function actionMerge() { $fileName = Yii::$app->request->post('filename', null); //$fileName = ""; // [!] Можно брать из сессии $response = []; $response['result'] = "Ok"; $dir = '/frontend/web/files/tmp'; $path = $_SERVER['DOCUMENT_ROOT'] . $dir; $img_ext = ".png"; $Settings = new Settings(); $enc_params = $options = ""; // Cкриншот $from_file = "{$path}/{$fileName}.webm"; $to_file = "{$path}/{$fileName}{$img_ext}"; $out_file = str_replace('.webm', '', $path . '/' . $fileName) . '.mp4'; $sound_file = str_replace('.webm', '', $path . '/' . $fileName) . '.wav'; if (file_exists($from_file)) { $Settings = new \frontend\models\Settings(); // Snapshot try { $useForSnapshot = $Settings->getConfigurationParamByKey("ffmpeg_use_for_snapshot"); if (!!$useForSnapshot) { echo shell_exec("ffmpeg -ss 00:00:01 -i {$from_file} -f image2 -vframes 1 {$to_file} -y"); } } catch (\yii\base\Exception $e) { } // Cведение видео и аудио try { $isMerge = $Settings->getConfigurationParamByKey("ffmpeg_use_for_merge_audiovideo"); $enc_params = $Settings->getConfigurationParamByKey("ffmpeg_encoding_params"); $options = $Settings->getConfigurationParamByKey("ffmpeg_encoding_options"); if (!!$isMerge) { echo shell_exec("ffmpeg -i {$sound_file} -i {$from_file} {$enc_params} {$out_file} {$options}"); } } catch (\yii\base\Exception $e) { } } $response['snapshot'] = $fileName . $img_ext; return json_encode($response); }
public function actionGetConfigAjax() { $key = Yii::$app->request->post('key', null); $keys = Yii::$app->request->post('keys', null); $response = []; $model = new Settings(); try { if (!is_null($key)) { $response[$key] = $model->getConfigurationParamByKey($key); } elseif (!is_null($keys)) { $arr = explode('|', $keys); foreach ($arr as $key) { $response[$key] = $model->getConfigurationParamByKey($key); } } } catch (Exception $e) { $response['error'] = $e->getMessage(); } return json_encode($response); }