|
@@ -0,0 +1,51 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+
|
|
|
+require_once('CallbackForm.php');
|
|
|
+
|
|
|
+class CallbackFormEmailFail extends CallbackForm
|
|
|
+{
|
|
|
+ public $email;
|
|
|
+ public $uploadFile;
|
|
|
+
|
|
|
+ public function __construct(string $name, string $phone, string $email, array $uploadFile)
|
|
|
+ {
|
|
|
+ parent:: __construct($name, $phone);
|
|
|
+ $this->email = $email;
|
|
|
+ $this->uploadFile = $uploadFile;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function validate(): bool
|
|
|
+ {
|
|
|
+ if ($this->email && !filter_var($this->email, FILTER_VALIDATE_EMAIL)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (!empty($this->uploadFile['name']) &&
|
|
|
+ (mime_content_type($this->uploadFile['type']) !== 'application/pdf' || $this->uploadFile['size'] > 5242880)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return parent::validate();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function loadingFile(): bool
|
|
|
+ {
|
|
|
+ $loadDirectory = dirname(__DIR__, 1) . '/files/';
|
|
|
+ if (!file_exists($loadDirectory)) {
|
|
|
+ mkdir($loadDirectory);
|
|
|
+ }
|
|
|
+ if (!move_uploaded_file($this->uploadFile['tmp_name'], $loadDirectory . $this->uploadFile['name'])) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function send()
|
|
|
+ {
|
|
|
+ parent::send();
|
|
|
+ echo '<br>';
|
|
|
+ echo 'Email: ' . $this->email;
|
|
|
+ echo '<br>';
|
|
|
+ echo 'Файл ' . $this->uploadFile['name'] . 'успешно загружен';
|
|
|
+ }
|
|
|
+}
|