YaWK  24.1
Yet another WebKit
webmail-compose.php
Go to the documentation of this file.
1 <script src="../system/engines/jquery/dropzone/dropzone.js"></script>
2 <link href="../system/engines/jquery/dropzone/dropzone.css" rel="stylesheet">
3 <?php
4 
5 use YAWK\backend;
6 use YAWK\db;
7 use YAWK\editor;
9 use YAWK\language;
10 use YAWK\settings;
11 
12 /** @var $db db */
13 /** @var $lang language */
14 
15 // import editor class + load editor settings
16 require_once '../system/classes/editor.php';
17 $editorSettings = settings::getEditorSettings($db, 14);
18 $editorSettings['editorHeight'] = "360";
19 editor::loadJavascript($editorSettings);
20 editor::setEditorSettings($editorSettings);
21 
22 // include imap client classes
23 require_once "../system/engines/imapClient/AdapterForOutgoingMessage.php";
24 require_once "../system/engines/imapClient/Helper.php";
25 require_once "../system/engines/imapClient/ImapClient.php";
26 require_once "../system/engines/imapClient/ImapClientException.php";
27 require_once "../system/engines/imapClient/ImapConnect.php";
28 require_once "../system/engines/imapClient/IncomingMessage.php";
29 require_once "../system/engines/imapClient/IncomingMessageAttachment.php";
30 require_once "../system/engines/imapClient/OutgoingMessage.php";
31 require_once "../system/engines/imapClient/Section.php";
32 require_once "../system/engines/imapClient/SubtypeBody.php";
33 require_once "../system/engines/imapClient/TypeAttachments.php";
34 require_once "../system/engines/imapClient/TypeBody.php";
35 
36 // let php know we need these classes:
37 use SSilence\ImapClient\ImapClientException;
38 use SSilence\ImapClient\ImapClient as Imap;
39 use YAWK\webmail;
40 
41 // get all webmail setting values into an array
42 $webmailSettings = settings::getValueSettingsArray($db, "webmail_");
43 
44 // imap connection only made be made if webmail is set to active
45 // check if webmail is activated
46 if ($webmailSettings['webmail_active'] == true)
47 { // webmail enabled, get mailbox settings
48 
49  // mailbox server (imap.server.com)
50  $server = $webmailSettings['webmail_imap_server'];
51  // mailbox user ([email protected])
52  $username = $webmailSettings['webmail_imap_username'];
53  // mailbox password
54  $password = $webmailSettings['webmail_imap_password'];
55  // encryption type (ssl, tsl, null)
56  $encryption = "/" . $webmailSettings['webmail_imap_encrypt'];
57  // port (default: 993)
58  $port = ":" . $webmailSettings['webmail_imap_port'];
59  // start at email no
60  $imapStart = $webmailSettings['webmail_imap_start'];
61  // amount of emails to be retrieved
62  $imapAmount = $webmailSettings['webmail_imap_amount'];
63  // amount of emails to be retrieved
64  $imapMsgTypes = $webmailSettings['webmail_imap_msgtypes'];
65  // sortation asc | desc
66  $imapSortation = $webmailSettings['webmail_imap_sortation'];
67  // novalidate-cert
68  $novalidate = $webmailSettings['webmail_imap_novalidate'];
69 
70  // include webmail class
71  require_once "../system/classes/webmail.php";
72  // create new webmail object
73  $webmail = new webmail();
74  // set connection info var
75  $webmail->connectionInfo = "<i>$username</i>";
76  // options (novalidate-cert)
77  $options = array($novalidate);
78 
79  try // open connection to imap server
80  {
81  // create new imap handle
82  $imap = new Imap($server.$port.$encryption, $username, $password, $encryption, 0, 0, $options);
83  // connection successful, error = false
84  $error = false;
85  $errorMsg = '';
86 
87  // webmail page called with parameter - user requested a folder
88  if (isset($_GET['folder']) && (!empty($_GET['folder']) && (is_string($_GET['folder']))))
89  { // select requested folder
90  $imap->selectFolder($_GET['folder']);
91  // set current folder string
92  $imap->currentFolder = $_GET['folder'];
93  }
94  else // webmail page called w/o any parameters
95  { // select default folder
96  $imap->selectFolder('INBOX');
97  $imap->currentFolder = "INBOX";
98  }
99  }
100  // open imap connection failed...
101  catch (ImapClientException $error)
102  { // no errors in production...
103  $webmail->connectionInfo = $error->getMessage() . PHP_EOL;
104  // exit with error
105  $error = true;
106  $errorMsg = 'Oh no! Verbindung mit server: '.$server.' als user: '.$username.' nicht moeglich!';
107  }
108 }
109 else // webmail is not activated...
110 { // leave vars empty
111  $webmail = "";
112  $imap = "";
117  $error = "";
118  $errorMsg = "";
119 }
120 
121 // TEMPLATE WRAPPER - HEADER & breadcrumbs
122 echo "
123  <!-- Content Wrapper. Contains page content -->
124  <div class=\"content-wrapper\" id=\"content-FX\">
125  <!-- Content Header (Page header) -->
126  <section class=\"content-header\">";
127 /* draw Title on top */
128 echo backend::getTitle($lang['WEBMAIL'], $lang['WEBMAIL_SUBTEXT']);
129 echo"<ol class=\"breadcrumb\">
130  <li><a href=\"index.php\" title=\"$lang[DASHBOARD]\"><i class=\"fa fa-dashboard\"></i> $lang[DASHBOARD]</a></li>
131  <li class=\"active\"><a href=\"index.php?page=webmail\" title=\"$lang[WEBMAIL]\"> $lang[WEBMAIL]</a></li>
132  </ol>
133  </section>
134  <!-- Main content -->
135  <section class=\"content\">";
136 /* page content start here */
137 // check if there was a connection error
138 if (isset($error) && ($error == true))
139 { // output error message
140  echo $errorMsg;
141 }
142 // draw webmail only, of webmal is set to active...
143 if ($webmailSettings['webmail_active'] == true && ($error == false))
144 {
145  ?>
146  <div class="row">
147  <div class="col-md-3">
148  <!-- left col -->
149  <a href="index.php?page=webmail" class="btn btn-success btn-large" style="width: 100%;"><i class="fa fa-reply-all"></i>&nbsp;&nbsp; Back to inbox</a><br><br>
150  <div class="box box-default">
151  <div class="box-header with-border">
152  <h3 class="box-title">Folders</h3>
153 
154  <div class="box-tools">
155  <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
156  </button>
157  </div>
158  </div>
159  <div class="box-body no-padding animated fadeIn">
160  <ul class="nav nav-pills nav-stacked">
161  <?php
162  /** @var $imap \SSilence\ImapClient\ImapClient */
163  $webmail->drawFolders($imap, $imap->getFolders());
164  ?>
165  </ul>
166  </div>
167  <!-- /.box-body -->
168  </div>
169  </div> <!-- /. left col -->
170 
171  <div class="col-md-9 animated fadeIn">
172  <!-- <form enctype="multipart/form-data" class="dropzone" action="index.php?page=webmail-compose" method="POST"> -->
173  <form id="my-dropzone" class="dropzone" enctype="multipart/form-data">
174  <!-- right col -->
175  <div class="box box-secondary">
176  <div class="box-header with-border">
177  <h3 class="box-title">Compose New Message</h3>
178  <div class="pull-right">
179  <i id="addCCBtn" class="btn btn-default btn-sm">CC</i>&nbsp;&nbsp;
180  <i id="addBCCBtn" class="btn btn-default btn-sm">BCC</i>
181  </div>
182  </div>
183  <!-- /.box-header -->
184  <div class="box-body">
185  <div class="form-group">
186  <input class="form-control" name="to" placeholder="To:">
187  <input id="ccField" class="form-control hidden" name="ccField" placeholder="CC:">
188  <input id="bccField" class="form-control hidden" name="bccField" placeholder="BCC:">
189  </div>
190  <div class="form-group">
191  <input class="form-control" name="subject" placeholder="Subject:">
192  </div>
193  <div class="form-group">
194  <label for="summernote" class="hidden"></label>
195  <!-- summernote editor -->
196  <textarea id="summernote" name="body" class="form-control"></textarea>
197  </div>
198 
199  <!-- start dropzone -->
200  <div id="actions">
201  <!-- this is were the previews should be shown. -->
202  <div class="dropzone-previews"></div>
203  <!-- The fileinput-button span is used to style the file input field as button -->
204  <span id="addBtn" class="btn btn-success fileinput-button">
205  <i class="fa fa-plus"></i>
206  <span>Add files...</span>
207  </span>
208 
209  <div class="pull-right">
210  <a id="draftBtn" href="index.php?page=webmail-compose&draft=1" type="button" class="btn btn-default"><i class="fa fa-pencil"></i>&nbsp; Draft</a>
211  &nbsp;
212  <button id="submitBtn" type="submit" class="btn btn-success pull-right"><i id="submitIcon" class="fa fa-paper-plane-o"></i> &nbsp;&nbsp;Send Email</button>
213  <!-- <button type="submit" id="submitBtn" class="btn btn-success start"><i class="fa fa-paper-plane-o"></i>&nbsp; Send</button> -->
214  <input type="hidden" name="sendEmail" value="true">
215  </div>
216 
217  <p class="help-block">Max. <?php echo filemanager::getPostMaxSize(); ?></p>
218  </div>
219  <!-- /. bootstrap dropzone -->
220 
221  </div>
222  </div>
223  <!-- /.box-body -->
224  <br><br>
225  </form>
226  </div>
227  </div>
228  <?php
229  // close current imap connection
230  $imap->close();
231 }
232 else
233 { // webmail not enabled
234  echo "<h4>".$lang['WEBMAIL_NOT_ENABLED']."</h4>";
235 }
236 ?>
237 
238 <script type="text/javascript">
239  // DROPZONE
240  Dropzone.options.myDropzone = { // The camelized version of the ID of the form element
241  // ajax form action
242  url: "js/email-send.php",
243  // dropzone options
244  autoProcessQueue: false,
245  uploadMultiple: true,
246  parallelUploads: 100,
247  maxFilesize: 64, // MB
248  maxFiles: 100,
249  addRemoveLinks: true,
250  paramName: "files",
251  acceptedFiles: ".jpg, .jpeg, .png, .gif, .pdf, .doc, .xls, .wav, .mp3, .mp4, .mpg",
252  clickable: ".fileinput-button", // Define the element that should be used as click trigger to select files.
253 
254  // Language Strings
255  dictFileTooBig: "File is to big ({{filesize}}mb). Max allowed file size is {{maxFilesize}}mb",
256  dictInvalidFileType: "Invalid File Type",
257  dictCancelUpload: "Cancel",
258  dictRemoveFile: "Remove",
259  dictMaxFilesExceeded: "Only {{maxFiles}} files are allowed",
260  dictDefaultMessage: "Drop files here to upload",
261 
262  // The setting up of the dropzone
263  init: function() {
264  var myDropzone = this;
265  var dropzoneFormElement = $('#my-dropzone');
266 
267  $(".dz-message").hide();
268  // First change the button to actually tell Dropzone to process the queue.
269  this.element.querySelector("button[type=submit]").addEventListener("click", function(e) {
270  // Make sure that the form isn't actually being sent.
271  e.preventDefault();
272  e.stopPropagation();
273 
274  // process only, if there are any attachments
275  if (myDropzone.getQueuedFiles().length > 0) {
276  myDropzone.processQueue();
277  }
278  else
279  { // process w/o attachments
280  // add form action & methods, call submit event
281  $(dropzoneFormElement).attr('action', 'js/email-send.php');
282  $(dropzoneFormElement).attr('method', 'post');
283  $(dropzoneFormElement).submit();
284  }
285  });
286 
287  // Listen to the sendingmultiple event. In this case, it's the sendingmultiple event instead
288  // of the sending event because uploadMultiple is set to true.
289  this.on("sendingmultiple", function(file) {
290  // Gets triggered when the form is actually being sent.
291  // Indicate loading button
292  $("#submitIcon").removeClass().addClass("fa fa-spinner fa-spin");
293  $("#submitBtn").removeClass().addClass("btn btn-danger disabled pull-right");
294  $("#draftBtn").removeClass().addClass("btn btn-default disabled");
295  $("#addBtn").removeClass().addClass("btn btn-success disabled");
296  });
297 
298  this.on("successmultiple", function(files, response) {
299  // Gets triggered when files + form have successfully been sent.
300  // redirect to webmail start page
301  window.location.replace("index.php?page=webmail");
302  });
303  this.on("errormultiple", function(files, response) {
304  // Gets triggered when there was an error sending the files.
305  // Maybe show form again, and notify user of error
306  });
307  }
308  };
309 
310  // CC button handling (toggle fadeIn/out on demand)
311  $( "#addCCBtn" ).click(function() {
312  // alert( "Add CC Field Btn clicked!" );
313  var ccField = $('#ccField');
314  var ccFieldClass = $(ccField).attr('class');
315  if (ccFieldClass === 'form-control hidden')
316  {
317  $(ccField).removeClass().addClass('form-control animated fadeIn');
318  }
319  else if (ccFieldClass === 'form-control animated fadeIn')
320  {
321  $(ccField).removeClass().addClass('form-control animated fadeOut hidden');
322  }
323  else if (ccFieldClass === 'form-control animated fadeOut hidden')
324  {
325  $(ccField).removeClass().addClass('form-control animated fadeIn');
326  }
327  });
328 
329  // BCC button handling (toggle fadeIn/out on demand)
330  $( "#addBCCBtn" ).click(function() {
331  // alert( "Add BCC Field Btn clicked!" );
332  var bccField = $('#bccField');
333  var bccFieldClass = $(bccField).attr('class');
334  if (bccFieldClass === 'form-control hidden')
335  {
336  $(bccField).removeClass().addClass('form-control animated fadeIn');
337  }
338  else if (bccFieldClass === 'form-control animated fadeIn')
339  {
340  $(bccField).removeClass().addClass('form-control animated fadeOut hidden');
341  }
342  else if (bccFieldClass === 'form-control animated fadeOut hidden')
343  {
344  $(bccField).removeClass().addClass('form-control animated fadeIn');
345  }
346  });
347 
348 </script>
print $lang['FILEMAN_UPLOAD']
Backend class serves a few useful functions for the admin backend.
Definition: backend.php:27
Mysqli database class; returns db connection object.
Definition: db.php:16
Load editor settings, required javascript and html markup.
Definition: editor.php:12
Basic File Manager (Backend)
Definition: filemanager.php:17
The language class - support multilingual backend.
Definition: language.php:17
Settings class: get and set YaWK system settings.
Definition: settings.php:9
Integrated IMAP Webmail.
Definition: webmail.php:25
$server
Definition: email-send.php:133
function window
Definition: fuckAdBlock.js:8
FuckAdBlock prototype on
Definition: fuckAdBlock.js:227
function a
Definition: browser.js:14
type
Definition: menu-new.php:35
print $_GET['id']
Definition: page-edit.php:357
function e
Definition: plyr.js:1
function i(e, t)
Definition: plyr.js:1
function p(e)
Definition: plyr.js:1
<!-- backend language -->< h3 >< i class="fa fa-language"></i > & nbsp
$template name
$imapMsgTypes
$imapStart
$editorSettings
$imapAmount
$imapSortation
$webmailSettings