|
11 | 11 | require_once '../lib/db.php'; |
12 | 12 | require_once '../lib/log.php'; |
13 | 13 |
|
14 | | -if (empty($_POST['sendTo']) || empty($_POST['image']) || !PHPMailer::validateAddress($_POST['sendTo'])) { |
| 14 | +if (empty($_POST['sendTo']) || !PHPMailer::validateAddress($_POST['sendTo'])) { |
15 | 15 | $LogData = [ |
16 | 16 | 'success' => false, |
17 | 17 | 'error' => 'E-Mail address invalid', |
|
24 | 24 | die($LogString); |
25 | 25 | } |
26 | 26 |
|
| 27 | +if (isset($_POST['send-link']) && $_POST['send-link'] === 'yes') { |
| 28 | + if (!file_exists(MAIL_FILE)) { |
| 29 | + $addresses = []; |
| 30 | + } else { |
| 31 | + $addresses = json_decode(file_get_contents(MAIL_FILE)); |
| 32 | + } |
| 33 | + |
| 34 | + if (!in_array($_POST['sendTo'], $addresses)) { |
| 35 | + $addresses[] = $_POST['sendTo']; |
| 36 | + } |
| 37 | + |
| 38 | + file_put_contents(MAIL_FILE, json_encode($addresses)); |
| 39 | + |
| 40 | + die( |
| 41 | + json_encode([ |
| 42 | + 'success' => true, |
| 43 | + 'saved' => true, |
| 44 | + ]) |
| 45 | + ); |
| 46 | +} |
| 47 | + |
| 48 | +if (empty($_POST['image'])) { |
| 49 | + $LogData = [ |
| 50 | + 'success' => false, |
| 51 | + 'error' => 'Image not defined', |
| 52 | + 'php' => basename($_SERVER['PHP_SELF']), |
| 53 | + ]; |
| 54 | + $LogString = json_encode($LogData); |
| 55 | + if ($config['dev']['enabled']) { |
| 56 | + logError($LogData); |
| 57 | + } |
| 58 | + die($LogString); |
| 59 | +} |
| 60 | + |
27 | 61 | $postImage = basename($_POST['image']); |
28 | 62 | if (!isImageInDB($postImage)) { |
29 | 63 | $LogData = [ |
|
96 | 130 | die($LogString); |
97 | 131 | } |
98 | 132 |
|
99 | | -if (isset($_POST['send-link']) && $_POST['send-link'] === 'yes') { |
100 | | - if (!file_exists(MAIL_FILE)) { |
101 | | - $addresses = []; |
102 | | - } else { |
103 | | - $addresses = json_decode(file_get_contents(MAIL_FILE)); |
104 | | - } |
105 | | - |
106 | | - if (!in_array($_POST['sendTo'], $addresses)) { |
107 | | - $addresses[] = $_POST['sendTo']; |
108 | | - } |
109 | | - |
110 | | - file_put_contents(MAIL_FILE, json_encode($addresses)); |
111 | | - |
112 | | - die( |
113 | | - json_encode([ |
114 | | - 'success' => true, |
115 | | - 'saved' => true, |
116 | | - ]) |
117 | | - ); |
118 | | -} |
119 | | - |
120 | 133 | if ($mail->send()) { |
121 | 134 | die( |
122 | 135 | json_encode([ |
|
0 commit comments