• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cypht-org / cypht / 26230827274

21 May 2026 02:01PM UTC coverage: 72.803% (-5.4%) from 78.201%
26230827274

push

travis-ci

web-flow
Merge pull request #1972 from IrAlfred/remove-duplicate-testdox-flag-in-coverage-report

fix(workflow): remove duplicate --testdox flag causing coverage job exit code 1

4797 of 6589 relevant lines covered (72.8%)

7.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.61
/modules/core/handler_modules.php
1
<?php
2

3
/**
4
 * Core modules
5
 * @package modules
6
 * @subpackage core
7
 */
8

9
/**
10
 * Check the folder list icon setting
11
 * @subpackage core/handler
12
 */
13
class Hm_Handler_check_folder_icon_setting extends Hm_Handler_Module {
14
    /***
15
     * set a flag to use folder list icons or not
16
     */
17
    public function process() {
1✔
18
        $this->out('hide_folder_icons', $this->user_config->get('no_folder_icons_setting', DEFAULT_NO_FOLDER_ICONS));
1✔
19
    }
20
}
21

22
/**
23
 * Process a password update
24
 * @subpackage core/handler
25
 */
26
class Hm_Handler_process_pw_update extends Hm_Handler_Module {
27
    /***
28
     * update a password in the session for a server
29
     */
30
    public function process() {
1✔
31
        list($success, $form ) = $this->process_form(array('server_pw_id', 'password'));
1✔
32
        $missing = $this->get('missing_pw_servers', array());
1✔
33
        if (!$success) {
1✔
34
            return;
1✔
35
        }
36
        if (!array_key_exists($form['server_pw_id'], $missing)) {
1✔
37
            return;
1✔
38
        }
39
        $server = $missing[$form['server_pw_id']];
1✔
40
        switch ($server['type']) {
1✔
41
            case 'SMTP':
1✔
42
                $current = Hm_SMTP_List::dump($server['id']);
1✔
43
                $current['pass'] = $form['password'];
1✔
44
                unset($current['nopass']);
1✔
45
                Hm_SMTP_List::edit($server['id'], $current);
1✔
46
                $smtp = Hm_SMTP_List::connect($server['id'], false);
1✔
47
                if ($smtp->state == 'authed') {
1✔
48
                    Hm_Msgs::add('Password Updated');
1✔
49
                    $this->out('connect_status', true);
1✔
50
                }
51
                else {
52
                    unset($current['pass']);
1✔
53
                    Hm_SMTP_List::edit($server['id'], $current);
1✔
54
                    Hm_Msgs::add('Unable to authenticate to the SMTP server', 'warning');
1✔
55
                    $this->out('connect_status', false);
1✔
56
                }
57
                break;
1✔
58
            case 'IMAP':
1✔
59
                $current = Hm_IMAP_List::dump($server['id']);
1✔
60
                $current['pass'] = $form['password'];
1✔
61
                unset($current['nopass']);
1✔
62
                Hm_IMAP_List::edit($server['id'], $current);
1✔
63
                $mailbox = Hm_IMAP_List::connect($server['id'], false);
1✔
64
                if ($mailbox && $mailbox->authed()) {
1✔
65
                    Hm_Msgs::add('Password Updated');
1✔
66
                    $this->out('connect_status', true);
1✔
67
                }
68
                else {
69
                    unset($current['pass']);
1✔
70
                    Hm_IMAP_List::edit($server['id'], $current);
1✔
71
                    Hm_Msgs::add('Unable to authenticate to the IMAP server', 'warning');
1✔
72
                    $this->out('connect_status', false);
1✔
73
                }
74
                break;
1✔
75
        }
76
    }
77
}
78

79
/**
80
 * Check for missing passwords to populate a home page dialog
81
 * @subpackage core/handler
82
 */
83
class Hm_Handler_check_missing_passwords extends Hm_Handler_Module {
84
    /***
85
     * pass a list of servers with missing passwords to the output modules
86
     */
87
    public function process() {
1✔
88
        if (!$this->user_config->get('no_password_save_setting', DEFAULT_NO_PASSWORD_SAVE)) {
1✔
89
            return;
1✔
90
        }
91
        $missing = array();
1✔
92
        if ($this->module_is_supported('imap')) {
1✔
93
            foreach (Hm_IMAP_List::dump() as $index => $vals) {
1✔
94
                if (array_key_exists('nopass', $vals)) {
1✔
95
                    $vals['type'] = 'IMAP';
1✔
96
                    $key = 'imap_'.$index;
1✔
97
                    $missing[$key] = $vals;
1✔
98
                }
99
            }
100
        }
101
        if ($this->module_is_supported('smtp')) {
1✔
102
            foreach (Hm_SMTP_List::dump() as $index => $vals) {
1✔
103
                if (array_key_exists('nopass', $vals)) {
1✔
104
                    $vals['type'] = 'SMTP';
1✔
105
                    $key = 'smtp_'.$index;
1✔
106
                    $missing[$key] = $vals;
1✔
107
                }
108
            }
109
        }
110
        if (count($missing) > 0) {
1✔
111
            $this->out('missing_pw_servers', $missing);
1✔
112
        }
113
    }
114
}
115

116
/**
117
 * Close the session before it's automatically closed at the end of page processing
118
 * @subpackage core/handler
119
 */
120
class Hm_Handler_close_session_early extends Hm_Handler_Module {
121
    /***
122
     * Uses the close_early method of the session this->session object
123
     */
124
    public function process() {
1✔
125
        $this->session->close_early();
1✔
126
    }
127
}
128

129
/**
130
 * Build a list of HTTP headers to output to the browser
131
 * @subpackage core/handler
132
 */
133
class Hm_Handler_http_headers extends Hm_Handler_Module {
134
    /***
135
     * These are pretty restrictive, but the idea is to have a secure starting point
136
     */
137
    public function process() {
2✔
138
        $headers = array();
2✔
139
        if ($this->get('language',DEFAULT_SETTING_LANGUAGE)) {
2✔
140
            $headers['Content-Language'] = mb_substr($this->get('language',DEFAULT_SETTING_LANGUAGE), 0, 2);
2✔
141
        }
142
        if ($this->request->tls) {
2✔
143
            $headers['Strict-Transport-Security'] = 'max-age=31536000';
2✔
144
        }
145
        $img_src = "'self'";
2✔
146
        if ($this->config->get('allow_external_image_sources', false)) {
2✔
147
            $img_src = '*';
1✔
148
        }
149
        $headers['X-Frame-Options'] = 'SAMEORIGIN';
2✔
150
        $headers['X-XSS-Protection'] = '1; mode=block';
2✔
151
        $headers['X-Content-Type-Options'] = 'nosniff';
2✔
152
        $headers['Expires'] = gmdate('D, d M Y H:i:s \G\M\T', strtotime('-1 year'));
2✔
153
        $headers['Content-Security-Policy'] = "default-src 'none'; script-src 'self' 'unsafe-inline'; " .
2✔
154
            "connect-src 'self'; font-src 'self' https://fonts.gstatic.com; img-src " . $img_src . " data:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com;";
2✔
155
        if ($this->request->type == 'AJAX') {
2✔
156
            $headers['Content-Type'] = 'application/json';
2✔
157
        }
158
        $this->out('http_headers', $headers, false);
2✔
159
        if (array_key_exists('hm_reload_folders', $this->request->cookie)) {
2✔
160
            $this->session->set('hm_reload_folders', $this->session->get('hm_reload_folders', 0) + 1);
×
161
        }
162
        if ($this->session->get('hm_reload_folders', false) > 2) {
2✔
163
            $this->session->delete_cookie($this->request, 'hm_reload_folders');
×
164
            $this->session->del('hm_reload_folders');
×
165
        }
166
    }
167
}
168

169
/**
170
 * Process input from the the mailto handler setting in the general settings section.
171
 * @subpackage core/handler
172
 */
173
class Hm_Handler_process_mailto_handler_setting extends Hm_Handler_Module {
174
    /**
175
     * Can be one true or false
176
     */
177
    public function process() {
1✔
178
        function mailto_handler_callback($val) {
179
            return $val;
1✔
180
        }
181
        process_site_setting('mailto_handler', $this, 'mailto_handler_callback', false, true);
1✔
182
    }
183
}
184

185
/**
186
 * Process input from the the list style setting in the general settings section.
187
 * @subpackage core/handler
188
 */
189
class Hm_Handler_process_list_style_setting extends Hm_Handler_Module {
190
    /**
191
     * Can be one of two values, 'email_style' or 'list_style'. The default is 'email_style'.
192
     */
193
    public function process() {
2✔
194
        function list_style_callback($val) {
195
            if (in_array($val, array('email_style', 'news_style'))) {
2✔
196
                return $val;
1✔
197
            }
198
            return DEFAULT_LIST_STYLE;
1✔
199
        }
200
        process_site_setting('list_style', $this, 'list_style_callback', DEFAULT_LIST_STYLE);
2✔
201
    }
202
}
203

204
/**
205
 * Process input from the the start page setting in the general settings section.
206
 * @subpackage core/handler
207
 */
208
class Hm_Handler_process_start_page_setting extends Hm_Handler_Module {
209
    /**
210
     * Can be one of the values in start_page_opts()
211
     */
212
    public function process() {
2✔
213
        function start_page_callback($val) {
214
            if (in_array($val, start_page_opts(), true)) {
2✔
215
                return $val;
1✔
216
            }
217
            return false;
1✔
218
        }
219
        process_site_setting('start_page', $this, 'start_page_callback',DEFAULT_START_PAGE);
2✔
220
    }
221
}
222

223
/**
224
 * Check the default sort order
225
 * @subpackage core/handler
226
 */
227
class Hm_Handler_default_sort_order_setting extends Hm_Handler_Module {
228
    /***
229
     * retrieve default sort order of messages
230
     */
231
    public function process() {
×
232
        $this->out('default_sort_order', $this->user_config->get('default_sort_order_setting', 'arrival'));
×
233
        $this->out('list_sort', $this->request->get['sort'] ?? null);
×
234
    }
235
}
236

237
/**
238
 * Process input from the the default sort order setting in the general settings section.
239
 * @subpackage core/handler
240
 */
241
class Hm_Handler_process_default_sort_order_setting extends Hm_Handler_Module {
242
    /**
243
     * Can be one of the values in start_page_opts()
244
     */
245
    public function process() {
×
246
        function default_sort_order_callback($val) {
247
            if (in_array($val, array_keys(default_sort_order_opts()), true)) {
×
248
                return $val;
×
249
            }
250
            return false;
×
251
        }
252
        process_site_setting('default_sort_order', $this, 'default_sort_order_callback');
×
253
    }
254
}
255

256
/**
257
 * Process "hide folder list icons" setting
258
 * @subpackage core/handler
259
 */
260
class Hm_Handler_process_hide_folder_icons extends Hm_Handler_Module {
261
    /**
262
     * valid values are true or false
263
     */
264
    public function process() {
1✔
265
        function hide_folder_icons_callback($val) {
266
            return $val;
1✔
267
        }
268
        process_site_setting('no_folder_icons', $this, 'hide_folder_icons_callback', DEFAULT_NO_FOLDER_ICONS, true);
1✔
269
    }
270
}
271

272
/**
273
 * Process "show icons in message lists" setting for the message list page in the settings page
274
 * @subpackage core/handler
275
 */
276
class Hm_Handler_process_show_list_icons extends Hm_Handler_Module {
277
    /**
278
     * valid values are true or false
279
     */
280
    public function process() {
1✔
281
        function show_list_icons_callback($val) {
282
            return $val;
1✔
283
        }
284
        process_site_setting('show_list_icons', $this, 'show_list_icons_callback', DEFAULT_SHOW_LIST_ICONS, true);
1✔
285
    }
286
}
287

288
/**
289
 * Process input from the max per source setting for the Unread page in the settings page
290
 * @subpackage core/handler
291
 */
292
class Hm_Handler_process_unread_source_max_setting extends Hm_Handler_Module {
293
    /**
294
     * Allowed values are greater than zero and less than MAX_PER_SOURCE
295
     */
296
    public function process() {
1✔
297
        process_site_setting('unread_per_source', $this, 'max_source_setting_callback', DEFAULT_UNREAD_PER_SOURCE);
1✔
298
    }
299
}
300

301
/**
302
 * Process input from the max per source setting for the All E-mail page in the settings page
303
 * @subpackage core/handler
304
 */
305
class Hm_Handler_process_all_email_source_max_setting extends Hm_Handler_Module {
306
    /**
307
     * Allowed values are greater than zero and less than MAX_PER_SOURCE
308
     */
309
    public function process() {
1✔
310
        process_site_setting('all_email_per_source', $this, 'max_source_setting_callback', DEFAULT_ALL_EMAIL_PER_SOURCE);
1✔
311
    }
312
}
313

314
/**
315
 * Process input from the no pasword between logins setting
316
 * @subpackage core/handler
317
 */
318
class Hm_Handler_process_no_password_setting extends Hm_Handler_Module {
319
    /**
320
     * Allowed vals are bool true/false
321
     */
322
    public function process() {
1✔
323
        function no_password_callback($val) {
324
            return $val;
1✔
325
        }
326
        process_site_setting('no_password_save', $this, 'no_password_callback', false, true);
1✔
327
    }
328
}
329

330
/**
331
 * Process input from the disable delete prompts setting
332
 * @subpackage core/handler
333
 */
334
class Hm_Handler_process_delete_prompt_setting extends Hm_Handler_Module {
335
    /**
336
     * Allowed vals are bool true/false
337
     */
338
    public function process() {
1✔
339
        function delete_disabled_callback($val) {
340
            return $val;
1✔
341
        }
342
        process_site_setting('disable_delete_prompt', $this, 'delete_disabled_callback', DEFAULT_DISABLE_DELETE_PROMPT, true);
1✔
343
    }
344
}
345

346
/**
347
 * AJAX handler: directly save search_all_folders as integer (0=off, 1=button, 2=always-on).
348
 * Cannot use process_site_setting (requires save_settings key not present in AJAX calls).
349
 * @subpackage core/handler
350
 */
351
class Hm_Handler_ajax_save_search_all_folders extends Hm_Handler_Module {
352
    public function process() {
×
353
        $val = isset($this->request->post['search_all_folders']) ? (int)$this->request->post['search_all_folders'] : -1;
×
354
        if (in_array($val, [0, 1, 2], true)) {
×
355
            $this->user_config->set('search_all_folders_setting', $val);
×
356
            $this->out('search_all_folders_saved', true);
×
357
        }
358
    }
359
}
360

361
/**
362
 * Expose the search_all_folders setting to output modules (message_list page)
363
 * @subpackage core/handler
364
 */
365
class Hm_Handler_load_search_all_folders_setting extends Hm_Handler_Module {
366
    public function process() {
×
367
        // Only expose as "enabled" when setting=1 (button mode). Setting=2 is always-on and needs no button.
368
        $this->out('search_all_folders_enabled', (int)$this->user_config->get('search_all_folders_setting', 0) === 1);
×
369
    }
370
}
371

372
/**
373
 * Process input from the search all folders in combined views setting
374
 * @subpackage core/handler
375
 */
376
class Hm_Handler_process_search_all_folders_setting extends Hm_Handler_Module {
377
    public function process() {
×
378
        function search_all_folders_callback($val) {
379
            return $val;
×
380
        }
381
        process_site_setting('search_all_folders', $this, 'search_all_folders_callback', DEFAULT_SEARCH_ALL_FOLDERS, true);
×
382
    }
383
}
384

385
/**
386
 * Process input from the disable delete attachment setting
387
 * @subpackage core/handler
388
 */
389
class Hm_Handler_process_delete_attachment_setting extends Hm_Handler_Module {
390
    /**
391
     * Allowed vals are bool true/false
392
     */
393
    public function process() {
×
394
        function delete_attachment_callback($val) {
395
            return $val;
×
396
        }
397
        process_site_setting('allow_delete_attachment', $this, 'delete_attachment_callback', true, true);
×
398
    }
399
}
400

401
/**
402
 * Process input from the max per source setting for the Everything page in the settings page
403
 * @subpackage core/handler
404
 */
405
class Hm_Handler_process_all_source_max_setting extends Hm_Handler_Module {
406
    /**
407
     * Allowed values are greater than zero and less than MAX_PER_SOURCE
408
     */
409
    public function process() {
1✔
410
        process_site_setting('all_per_source', $this, 'max_source_setting_callback', DEFAULT_ALL_PER_SOURCE);
1✔
411
    }
412
}
413

414
/**
415
 * Process input from the max per source setting for the Flagged page in the settings page
416
 * @subpackage core/handler
417
 */
418
class Hm_Handler_process_flagged_source_max_setting extends Hm_Handler_Module {
419
    /**
420
     * Allowed values are greater than zero and less than MAX_PER_SOURCE
421
     */
422
    public function process() {
1✔
423
        process_site_setting('flagged_per_source', $this,'max_source_setting_callback', DEFAULT_PER_SOURCE);
1✔
424
    }
425
}
426

427
/**
428
 * Process "since" setting for the Flagged page in the settings page
429
 * @subpackage core/handler
430
 */
431
class Hm_Handler_process_flagged_since_setting extends Hm_Handler_Module {
432
    /**
433
     * valid values are defined in the process_since_argument function
434
     */
435
    public function process() {
1✔
436
        process_site_setting('flagged_since', $this, 'since_setting_callback', DEFAULT_FLAGGED_SINCE);
1✔
437
    }
438
}
439

440
/**
441
 * Process input from the max per source setting for the Snoozed page in the settings page
442
 * @subpackage core/handler
443
 */
444
class Hm_Handler_process_snoozed_source_max_setting extends Hm_Handler_Module {
445
    /**
446
     * Allowed values are greater than zero and less than MAX_PER_SOURCE
447
     */
448
    public function process() {
×
449
        process_site_setting('snoozed_per_source', $this, 'max_source_setting_callback', DEFAULT_SNOOZED_PER_SOURCE);
×
450
    }
451
}
452

453
/**
454
 * Process "since" setting for the Snoozed page in the settings page
455
 * @subpackage core/handler
456
 */
457
class Hm_Handler_process_snoozed_since_setting extends Hm_Handler_Module {
458
    /**
459
     * valid values are defined in the process_since_argument function
460
     */
461
    public function process() {
×
462
        process_site_setting('snoozed_since', $this, 'since_setting_callback', DEFAULT_SNOOZED_SINCE);
×
463
    }
464
}
465

466
/**
467
 * Process the enable/disable snooze setting
468
 * @subpackage core/handler
469
 */
470
class Hm_Handler_process_enable_snooze_setting extends Hm_Handler_Module {
471
    /**
472
     * Process the enable/disable snooze setting
473
     */
474
    public function process() {
×
475
        function enable_snooze_setting_callback($val) { return $val; }
×
476
        process_site_setting('enable_snooze', $this, 'enable_snooze_setting_callback', DEFAULT_ENABLE_SNOOZE, true);
×
477
    }
478
}
479

480
/**
481
 * Process "since" setting for the Everything page in the settings page
482
 * @subpackage core/handler
483
 */
484
class Hm_Handler_process_all_since_setting extends Hm_Handler_Module {
485
    /**
486
     * valid values are defined in the process_since_argument function
487
     */
488
    public function process() {
1✔
489
        process_site_setting('all_since', $this, 'since_setting_callback', DEFAULT_ALL_SINCE);
1✔
490
    }
491
}
492

493
/**
494
 * Process "since" setting for the All E-mail page in the settings page
495
 * @subpackage core/handler
496
 */
497
class Hm_Handler_process_all_email_since_setting extends Hm_Handler_Module {
498
    /**
499
     * valid values are defined in the process_since_argument function
500
     */
501
    public function process() {
1✔
502
        process_site_setting('all_email_since', $this, 'since_setting_callback', DEFAULT_ALL_EMAIL_SINCE);
1✔
503
    }
504
}
505

506
/**
507
 * Process "since" setting for the Unread page in the settings page
508
 * @subpackage core/handler
509
 */
510
class Hm_Handler_process_unread_since_setting extends Hm_Handler_Module {
511
    /**
512
     * valid values are defined in the process_since_argument function
513
     */
514
    public function process() {
1✔
515
        process_site_setting('unread_since', $this, 'since_setting_callback', $this->user_config->get('default_setting_unread_since'));
1✔
516
    }
517
}
518

519
/**
520
 * Process language setting from the general section of the settings page
521
 * @subpackage core/handler
522
 */
523
class Hm_Handler_process_language_setting extends Hm_Handler_Module {
524
    /**
525
     * compared against the list in modules/core/functions.php:interface_langs()
526
     */
527
    public function process() {
2✔
528
        function language_setting_callback($val) {
529
            if (array_key_exists($val, interface_langs())) {
2✔
530
                return $val;
1✔
531
            }
532
            return DEFAULT_SETTING_LANGUAGE;
1✔
533
        }
534
        process_site_setting('language', $this, 'language_setting_callback',DEFAULT_SETTING_LANGUAGE);
2✔
535
    }
536
}
537

538
/**
539
 * Process the timezone setting from the general section of the settings page
540
 * @subpackage core/handler
541
 */
542
class Hm_Handler_process_timezone_setting extends Hm_Handler_Module {
543
    public function process() {
2✔
544
        function timezone_setting_callback($val) {
545
            if (in_array($val, timezone_identifiers_list(), true)) {
2✔
546
                return $val;
1✔
547
            }
548
            return false;
1✔
549
        }
550
        process_site_setting('timezone', $this, 'timezone_setting_callback');
2✔
551
    }
552
}
553

554
/**
555
 * Save user settings permanently
556
 * @subpackage core/handler
557
 */
558
class Hm_Handler_process_save_form extends Hm_Handler_Module {
559
    /**
560
     * save any changes since login to permanent storage
561
     */
562
    public function process() {
1✔
563
        list($success, $form) = $this->process_form(array('password'));
1✔
564
        if (!$success) {
1✔
565
            return;
1✔
566
        }
567
        $save = false;
1✔
568
        $logout = false;
1✔
569
        if (array_key_exists('save_settings_permanently', $this->request->post)) {
1✔
570
            $save = true;
1✔
571
        }
572
        elseif (array_key_exists('save_settings_permanently_then_logout', $this->request->post)) {
1✔
573
            $save = true;
1✔
574
            $logout = true;
1✔
575
        }
576
        if ($save) {
1✔
577
            save_user_settings($this, $form, $logout);
1✔
578
        }
579
    }
580
}
581

582
/**
583
 * Save settings from the settings page to the session
584
 * @subpackage core/handler
585
 */
586
class Hm_Handler_save_user_settings extends Hm_Handler_Module {
587
    /**
588
     * save new site settings to the session
589
     */
590
    public function process() {
1✔
591
        list($success, $form) = $this->process_form(array('save_settings'));
1✔
592
        if (!$success) {
1✔
593
            return;
1✔
594
        }
595
        if ($new_settings = $this->get('new_user_settings', array())) {
1✔
596
            foreach ($new_settings as $name => $value) {
1✔
597
                $this->user_config->set($name, $value);
1✔
598
            }
599
            Hm_Msgs::add('Settings updated');
1✔
600
            $this->session->record_unsaved('Site settings updated');
1✔
601
            $this->out('reload_folders', true, false);
1✔
602
        }
603
    }
604
}
605

606
/**
607
 * Do reset factory from the settings page to the session
608
 * @subpackage core/handler
609
 */
610
class Hm_Handler_reset_factory extends Hm_Handler_Module {
611
    /**
612
     * reset user config to the default
613
     */
614
    public function process() {
×
615
        list($success, $form) = $this->process_form(array('reset_factory'));
×
616
        if (!$success) {
×
617
            return;
×
618
        }
619
        $this->user_config->reset_factory();
×
620
        Hm_Msgs::add('Settings restored to default');
×
621
        $this->session->record_unsaved('Site settings restored to default');
×
622
        $this->out('reload_folders', true, false);
×
623
    }
624
}
625

626
/**
627
 * Setup a default title
628
 * @subpackage core/handler
629
 */
630
class Hm_Handler_title extends Hm_Handler_Module {
631
    /**
632
     * output a default title based on the page URL argument
633
     */
634
    public function process() {
1✔
635
        $this->out('title', ucfirst($this->page));
1✔
636
    }
637
}
638

639
/**
640
 * Setup the current language
641
 * @subpackage core/handler
642
 */
643
class Hm_Handler_language extends Hm_Handler_Module {
644
    /**
645
     * output the user configured language or English if not set
646
     */
647
    public function process() {
1✔
648
        $this->out('language', $this->user_config->get('language_setting', DEFAULT_SETTING_LANGUAGE));
1✔
649
    }
650
}
651

652
/**
653
 * Setup the date
654
 * @subpackage core/handler
655
 */
656
class Hm_Handler_date extends Hm_Handler_Module {
657
    /**
658
     * output a simple date string
659
     */
660
    public function process() {
3✔
661
        $this->out('date', date('G:i:s'));
3✔
662
    }
663
}
664

665
/**
666
 * Check for the "stay logged in" option
667
 */
668
class Hm_Handler_stay_logged_in extends Hm_Handler_Module {
669
    /**
670
     * If "stay logged in" is checked, set the session lifetime
671
     */
672
    public function process() {
1✔
673
        if ($this->config->get('allow_long_session')) {
1✔
674
            $this->out('allow_long_session', true);
1✔
675
        }
676
        $lifetime = intval($this->config->get('long_session_lifetime', 30));
1✔
677
        list($success, $form) = $this->process_form(array('stay_logged_in'));
1✔
678
        if ($success && $form['stay_logged_in']) {
1✔
679
            $lifetime_timestamp = time()+60*60*24*$lifetime;
1✔
680
            $this->session->lifetime = $lifetime_timestamp;
1✔
681
            // Store in session so it persists across page loads
682
            $this->session->set('long_session_lifetime', $lifetime_timestamp);
1✔
683
            $this->session->set('long_session_enabled', true);
1✔
684
        }
685
    }
686
}
687

688
/**
689
 * Process a potential login attempt
690
 * @subpackage core/handler
691
 */
692
class Hm_Handler_login extends Hm_Handler_Module {
693
    /**
694
     * Perform a new login if the form was submitted, otherwise check for and continue a session if it exists
695
     */
696
    public $validate_request = true;
697
    public function process() {
1✔
698
        $this->out('fancy_login_allowed', $this->config->get('fancy_login', false));
1✔
699
        $this->out('is_mobile', $this->request->mobile);
1✔
700
        if ($this->get('create_username', false)) {
1✔
701
            return;
1✔
702
        }
703
        list($success, $form) = $this->process_form(array('username', 'password'));
1✔
704
        if ($success) {
1✔
705
            $this->session->check($this->request, rtrim($form['username']), $form['password']);
1✔
706
            if (!$this->session->is_active()) {
1✔
707
                Hm_Msgs::add("Invalid username or password", "warning");
×
708
            }
709
            $this->session->set('username', rtrim($form['username']));
1✔
710
            if ($this->config->get('redirect_after_login')) {
1✔
711
                $this->out('redirect_url', $this->config->get('redirect_after_login'));
1✔
712
            }
713
        }
714
        else {
715
            $this->session->check($this->request);
1✔
716
        }
717
        if ($this->session->is_active()) {
1✔
718
            $this->out('changed_settings', $this->session->get('changed_settings', array()), false);
1✔
719
            $this->out('username', $this->session->get('username'));
1✔
720
            $this->out('is_logged', true);
1✔
721
        }
722
        if ($this->validate_request) {
1✔
723
            Hm_Request_Key::load($this->session, $this->request, $this->session->loaded);
1✔
724
            $this->validate_method($this->session, $this->request);
1✔
725
            $this->process_key();
1✔
726
            if (!$this->config->get('disable_origin_check', false)) {
1✔
727
                $this->validate_origin($this->session, $this->request, $this->config);
1✔
728
            }
729
        }
730
    }
731
}
732

733
/**
734
 * Setup default page data
735
 * @subpackage core/handler
736
 */
737
class Hm_Handler_default_page_data extends Hm_Handler_Module {
738
    public function process() {
1✔
739
        $this->out('data_sources', array(), false);
1✔
740
        $this->out('encrypt_ajax_requests', $this->config->get('encrypt_ajax_requests', false));
1✔
741
        $this->out('encrypt_local_storage', $this->config->get('encrypt_local_storage', false));
1✔
742
        $this->out('default_timezone', $this->user_config->get('default_setting_timezone', 'UTC'));
1✔
743
        $this->out('enabled_modules', $this->config->get_modules());
1✔
744
        $this->out('page_param_name', $this->config->get('page_param_name'));
1✔
745
        if (!crypt_state($this->config)) {
1✔
746
            $this->out('single_server_mode', true);
1✔
747
        }
748
    }
749
}
750

751
/**
752
 * Load user data
753
 * @subpackage core/handler
754
 */
755
class Hm_Handler_load_user_data extends Hm_Handler_Module {
756
    /**
757
     * Load data from persistant storage on login, or from the session if already logged in
758
     */
759
    public function process() {
1✔
760
        list($success, $form) = $this->process_form(array('username', 'password'));
1✔
761
        if ($this->session->is_active()) {
1✔
762
            if ($success) {
1✔
763
                $this->user_config->load(rtrim($form['username']), $form['password']);
1✔
764
            }
765
            else {
766
                $user_data = $this->session->get('user_data', array());
1✔
767
                if (!empty($user_data)) {
1✔
768
                    $this->user_config->reload($user_data, $this->session->get('username'));
1✔
769
                }
770
                $pages = $this->user_config->get('saved_pages', array());
1✔
771
                if (!empty($pages)) {
1✔
772
                    $this->session->set('saved_pages', $pages);
1✔
773
                }
774
            }
775
            $this->out('disable_delete_prompt', $this->user_config->get('disable_delete_prompt_setting', DEFAULT_DISABLE_DELETE_PROMPT));
1✔
776
        }
777
        if ($this->session->loaded) {
1✔
778
            $start_page = $this->user_config->get('start_page_setting');
1✔
779
            if ($start_page && $start_page != 'none' && in_array($start_page, start_page_opts(), true)) {
1✔
780
                $this->out('redirect_url', '?'.$start_page);
1✔
781
            }
782
        }
783
        $this->out('mailto_handler', $this->user_config->get('mailto_handler_setting', false));
1✔
784
        $this->out('warn_for_unsaved_changes', $this->user_config->get('warn_for_unsaved_changes_setting', false));
1✔
785
        $this->out('no_password_save', $this->user_config->get('no_password_save_setting', DEFAULT_NO_PASSWORD_SAVE));
1✔
786
        $this->out('user_settings', $this->user_config->dump(), false);
1✔
787
        if (!mb_strstr($this->request->server['REQUEST_URI'], 'page=') && $this->page == 'home') {
1✔
788
            $start_page = $this->user_config->get('start_page_setting', false);
×
789
            if ($start_page && $start_page != 'none' && in_array($start_page, start_page_opts(), true)) {
×
790
                $this->out('redirect_url', '?'.$start_page);
×
791
            }
792
        }
793
    }
794
}
795

796
/**
797
 * Save user data to the session
798
 * @subpackage core/handler
799
 */
800
class Hm_Handler_save_user_data extends Hm_Handler_Module {
801
    /**
802
     * @todo rename to make it obvious this is session only
803
     */
804
    public function process() {
1✔
805
        $user_data = $this->user_config->dump();
1✔
806
        if (!empty($user_data)) {
1✔
807
            $this->session->set('user_data', $user_data);
1✔
808
        }
809
    }
810
}
811

812
/**
813
 * Process a logout
814
 * @subpackage core/handler
815
 */
816
class Hm_Handler_logout extends Hm_Handler_Module {
817
    /**
818
     * Clean up everything on logout
819
     */
820
    public function process() {
1✔
821
        if ($this->request->get['prompt'] ?? false) {
1✔
822
            $backQuery = isset($this->request->get['back_query']) ? unserialize(base64_decode($this->request->get['back_query'])): [];
×
823

824
            $this->out('cancel_logout_url', '?' . http_build_query($backQuery));
×
825
            
826
            return;
×
827
        }
828

829
        if (array_key_exists('logout', $this->request->post) && !$this->session->loaded) {
1✔
830
            $this->session->destroy($this->request);
1✔
831
            Hm_Msgs::add('Session destroyed on logout', 'info');
1✔
832
            $this->out('redirect_url', '?home');
1✔
833
        }
834
        elseif (array_key_exists('save_and_logout', $this->request->post)) {
1✔
835
            list($success, $form) = $this->process_form(array('password'));
1✔
836
            if ($success) {
1✔
837
                $user = $this->session->get('username', false);
1✔
838
                $path = $this->config->get('user_settings_dir', false);
1✔
839
                $pages = $this->session->get('saved_pages', array());
1✔
840
                if (!empty($pages)) {
1✔
841
                    $this->user_config->set('saved_pages', $pages);
1✔
842
                }
843
                if ($this->session->auth($user, $form['password'])) {
1✔
844
                    $pass = $form['password'];
1✔
845
                }
846
                else {
847
                    Hm_Msgs::add('Incorrect password, could not save settings to the server', 'warning');
1✔
848
                    $pass = false;
1✔
849
                }
850
                if ($user && $path && $pass) {
1✔
851
                    try {
852
                        $this->user_config->save($user, $pass);
1✔
853
                        $this->session->destroy($this->request);
1✔
854
                        Hm_Msgs::add('Saved user data on logout, Session destroyed on logout', 'info');
1✔
855
                        $this->out('redirect_url', '?home');
1✔
856
                    } catch (Exception $e) {
×
857
                        Hm_Msgs::add('Could not save settings: ' . $e->getMessage(), 'warning');
1✔
858
                    }
859
                }
860
            }
861
            else {
862
                Hm_Msgs::add('Your password is required to save your settings to the server', 'warning');
1✔
863
            }
864
        }
865
    }
866
}
867

868
/**
869
 * Setup the message list type based on URL arguments
870
 * @subpackage core/handler
871
 */
872
class Hm_Handler_message_list_type extends Hm_Handler_Module {
873
    /**
874
     * @todo clean this up somehow
875
     */
876
    public function process() {
1✔
877
        $uid = '';
1✔
878
        $list_parent = '';
1✔
879
        $list_page = 1;
1✔
880
        $list_meta = true;
1✔
881
        $list_path = '';
1✔
882
        $mailbox_list_title = array();
1✔
883
        $message_list_since = DEFAULT_SINCE;
1✔
884
        $per_source_limit = DEFAULT_PER_SOURCE;
1✔
885
        $no_list_headers = false;
1✔
886

887
        if (array_key_exists('list_path', $this->request->get)) {
1✔
888
            $path = $this->request->get['list_path'];
1✔
889
            list($list_path, $mailbox_list_title, $message_list_since, $per_source_limit) = get_message_list_settings($path, $this);
1✔
890
        }
891
        if (array_key_exists('list_parent', $this->request->get)) {
1✔
892
            $list_parent = $this->request->get['list_parent'];
1✔
893
        }
894
        if (array_key_exists('list_page', $this->request->get)) {
1✔
895
            $list_page = (int) $this->request->get['list_page'];
1✔
896
            if ($list_page < 1) {
1✔
897
                $list_page = 1;
1✔
898
            }
899
        }
900
        else {
901
            $list_page = 1;
1✔
902
        }
903
        if (array_key_exists('uid', $this->request->get) && preg_match("/^[0-9a-z]+$/i", $this->request->get['uid'])) {
1✔
904
            $uid = $this->request->get['uid'];
1✔
905
        }
906
        $list_style = $this->user_config->get('list_style_setting', DEFAULT_LIST_STYLE);
1✔
907
        if ($this->get('is_mobile', false)) {
1✔
908
            $list_style = 'news_style';
1✔
909
        }
910
        if ($list_style == 'news_style') {
1✔
911
            $no_list_headers = true;
1✔
912
            $this->out('news_list_style', true);
1✔
913
        }
914
        $this->out('uid', $uid);
1✔
915
        $this->out('list_path', $list_path, false);
1✔
916
        $this->out('list_meta', $list_meta, false);
1✔
917
        $this->out('list_parent', $list_parent, false);
1✔
918
        $this->out('list_page', $list_page, false);
1✔
919
        $this->out('mailbox_list_title', $mailbox_list_title, false);
1✔
920
        $this->out('message_list_since', $message_list_since, false);
1✔
921
        $this->out('per_source_limit', $per_source_limit, false);
1✔
922
        $this->out('no_message_list_headers', $no_list_headers);
1✔
923
        $this->out('msg_list_icons', $this->user_config->get('show_list_icons_setting', false));
1✔
924
        $this->out('message_list_fields', array(
1✔
925
            array('chkbox_col', false, false),
1✔
926
            array('source_col', 'source', 'Source'),
1✔
927
            array('from_col', 'from', 'From'),
1✔
928
            array('subject_col', 'subject', 'Subject'),
1✔
929
            array('date_col', 'msg_date', 'Date'),
1✔
930
            array('icon_col', false, false)), false);
1✔
931
    }
932
}
933

934
/**
935
 * Set a cookie to instruct the JS to reload the folder list
936
 * @subpackage core/handler
937
 */
938
class Hm_Handler_reload_folder_cookie extends Hm_Handler_Module {
939
    /**
940
     * This cookie will be deleted by JS
941
     */
942
    public function process() {
1✔
943
        if ($this->get('reload_folders', false)) {
1✔
944
            $this->session->secure_cookie($this->request, 'hm_reload_folders', '1');
1✔
945
            $this->session->set('hm_reload_folders', 1);
1✔
946
        }
947
    }
948
}
949

950
/**
951
 * @subpackage core/handler
952
 */
953
class Hm_Handler_reset_search extends Hm_Handler_Module {
954
    public function process() {
1✔
955
        $this->session->set('search_terms', '');
1✔
956
        $this->session->set('search_since', DEFAULT_SEARCH_SINCE);
1✔
957
        $this->session->set('search_fld', DEFAULT_SEARCH_FLD);
1✔
958
    }
959
}
960

961
/**
962
 * Process search terms from a URL
963
 * @subpackage core/handler
964
 */
965
class Hm_Handler_process_search_terms extends Hm_Handler_Module {
966
    /**
967
     * validate and set search tems in the session
968
     */
969
    public function process() {
1✔
970
        if (array_key_exists('search_terms', $this->request->get) && $this->request->get['search_terms']) {
1✔
971
            $this->out('run_search', 1, false);
1✔
972
            $this->session->set('search_terms', validate_search_terms($this->request->get['search_terms']));
1✔
973
        }
974
        if (array_key_exists('search_since', $this->request->get)) {
1✔
975
            $this->session->set('search_since', process_since_argument($this->request->get['search_since'], true));
1✔
976
        }
977
        if (array_key_exists('search_fld', $this->request->get)) {
1✔
978
            $this->session->set('search_fld', validate_search_fld($this->request->get['search_fld']));
1✔
979
        }
980
        $this->out('search_since', $this->session->get('search_since', DEFAULT_SEARCH_SINCE));
1✔
981
        $this->out('search_terms', $this->session->get('search_terms', ''));
1✔
982
        $this->out('search_fld', $this->session->get('search_fld', DEFAULT_SEARCH_FLD));
1✔
983
        if ($this->session->get('search_terms')) {
1✔
984
            $this->out('run_search', 1);
1✔
985
        }
986
    }
987
}
988

989
/**
990
 * Process input from the max per source setting for the Junk page in the settings page
991
 * @subpackage core/handler
992
 */
993
class Hm_Handler_process_junk_source_max_setting extends Hm_Handler_Module {
994
    /**
995
     * Allowed values are greater than zero and less than MAX_PER_SOURCE
996
     */
997
    public function process() {
×
998
        process_site_setting('junk_per_source', $this, 'max_source_setting_callback', DEFAULT_JUNK_PER_SOURCE);
×
999
    }
1000
}
1001

1002
/**
1003
 * Process "since" setting for the junk page in the settings page
1004
 * @subpackage core/handler
1005
 */
1006
class Hm_Handler_process_junk_since_setting extends Hm_Handler_Module {
1007
    /**
1008
     * valid values are defined in the process_since_argument function
1009
     */
1010
    public function process() {
×
1011
        process_site_setting('junk_since', $this, 'since_setting_callback', DEFAULT_JUNK_SINCE);
×
1012
    }
1013
}
1014

1015
/**
1016
 * Process input from the max per source setting for the Trash page in the settings page
1017
 * @subpackage core/handler
1018
 */
1019
class Hm_Handler_process_trash_source_max_setting extends Hm_Handler_Module {
1020
    /**
1021
     * Allowed values are greater than zero and less than MAX_PER_SOURCE
1022
     */
1023
    public function process() {
×
1024
        process_site_setting('trash_per_source', $this, 'max_source_setting_callback', DEFAULT_TRASH_PER_SOURCE);
×
1025
    }
1026
}
1027

1028
/**
1029
 * Process "since" setting for the trash page in the settings page
1030
 * @subpackage core/handler
1031
 */
1032
class Hm_Handler_process_trash_since_setting extends Hm_Handler_Module {
1033
    /**
1034
     * valid values are defined in the process_since_argument function
1035
     */
1036
    public function process() {
×
1037
        process_site_setting('trash_since', $this, 'since_setting_callback');
×
1038
    }
1039
}
1040

1041
/**
1042
 * Process input from the max per source setting for the Draft page in the settings page
1043
 * @subpackage core/handler
1044
 */
1045
class Hm_Handler_process_drafts_source_max_setting extends Hm_Handler_Module {
1046
    /**
1047
     * Allowed values are greater than zero and less than MAX_PER_SOURCE
1048
     */
1049
    public function process() {
×
1050
        process_site_setting('drafts_per_source', $this, 'max_source_setting_callback', DEFAULT_DRAFT_PER_SOURCE);
×
1051
    }
1052
}
1053

1054
/**
1055
 * Process "since" setting for the Drafts page in the settings page
1056
 * @subpackage core/handler
1057
 */
1058
class Hm_Handler_process_drafts_since_setting extends Hm_Handler_Module {
1059
    /**
1060
     * valid values are defined in the process_since_argument function
1061
     */
1062
    public function process() {
×
1063
        process_site_setting('drafts_since', $this, 'since_setting_callback', DEFAULT_DRAFT_SINCE);
×
1064
    }
1065
}
1066

1067
/**
1068
 * Process warn for unsaved changes in the settings page
1069
 * @subpackage core/handler
1070
 */
1071
class Hm_Handler_process_warn_for_unsaved_changes_setting extends Hm_Handler_Module {
1072
    /**
1073
     * valid values are true and false
1074
     */
1075
    public function process() {
×
1076
        function warn_for_unsaved_changes_callback($val) {
1077
            return $val;
×
1078
        }
1079
        process_site_setting('warn_for_unsaved_changes', $this, 'warn_for_unsaved_changes_callback', false, true);
×
1080
    }
1081
}
1082

1083
/**
1084
 * @subpackage core/handler
1085
 */
1086
class Hm_Handler_quick_servers_setup extends Hm_Handler_Module {
1087
    public $smtp_server_id = null;
1088
    public $imap_server_id = null;
1089
    public $jmap_server_id = null;
1090

1091
    public function process() {
×
1092
        list($success, $form) = $this->process_form(array(
×
1093
            'srv_setup_stepper_profile_name',
×
1094
            'srv_setup_stepper_email',
×
1095
            'srv_setup_stepper_password',
×
1096
            'srv_setup_stepper_provider',
×
1097
            'srv_setup_stepper_is_sender',
×
1098
            'srv_setup_stepper_is_receiver',
×
1099
            'srv_setup_stepper_smtp_address',
×
1100
            'srv_setup_stepper_smtp_port',
×
1101
            'srv_setup_stepper_smtp_tls',
×
1102
            'srv_setup_stepper_imap_address',
×
1103
            'srv_setup_stepper_imap_port',
×
1104
            'srv_setup_stepper_imap_tls',
×
1105
            'srv_setup_stepper_enable_sieve',
×
1106
            'srv_setup_stepper_create_profile',
×
1107
            'srv_setup_stepper_profile_is_default',
×
1108
            'srv_setup_stepper_profile_signature',
×
1109
            'srv_setup_stepper_profile_reply_to',
×
1110
            'srv_setup_stepper_imap_sieve_host',
×
1111
            'srv_setup_stepper_imap_sieve_mode_tls',
×
1112
            'srv_setup_stepper_only_jmap',
×
1113
            'srv_setup_stepper_imap_hide_from_c_page',
×
1114
            'srv_setup_stepper_jmap_address',
×
1115
            'srv_setup_stepper_imap_server_id',
×
1116
            'srv_setup_stepper_smtp_server_id',
×
1117
        ));
×
1118
        if ($success) {
×
1119
            // Destructure form array into variables
1120
            [
×
1121
                'srv_setup_stepper_profile_name' => $profileName,
×
1122
                'srv_setup_stepper_email' => $email,
×
1123
                'srv_setup_stepper_password' => $password,
×
1124
                'srv_setup_stepper_provider' => $provider,
×
1125
                'srv_setup_stepper_is_sender' => $isSender,
×
1126
                'srv_setup_stepper_is_receiver' => $isReceiver,
×
1127
                'srv_setup_stepper_smtp_address' => $smtpAddress,
×
1128
                'srv_setup_stepper_smtp_port' => $smtpPort,
×
1129
                'srv_setup_stepper_smtp_tls' => $smtpTls,
×
1130
                'srv_setup_stepper_imap_address' => $imapAddress,
×
1131
                'srv_setup_stepper_imap_port' => $imapPort,
×
1132
                'srv_setup_stepper_imap_tls' => $imapTls,
×
1133
                'srv_setup_stepper_enable_sieve' => $enableSieve,
×
1134
                'srv_setup_stepper_create_profile' => $createProfile,
×
1135
                'srv_setup_stepper_profile_is_default' => $profileIsDefault,
×
1136
                'srv_setup_stepper_profile_signature' => $profileSignature,
×
1137
                'srv_setup_stepper_profile_reply_to' => $profileReplyTo,
×
1138
                'srv_setup_stepper_imap_sieve_host' => $imapSieveHost,
×
1139
                'srv_setup_stepper_imap_sieve_mode_tls' => $imapSieveTls,
×
1140
                'srv_setup_stepper_only_jmap' => $onlyJmap,
×
1141
                'srv_setup_stepper_imap_hide_from_c_page' => $hideFromCombinedView,
×
1142
                'srv_setup_stepper_jmap_address' => $jmapAddress,
×
1143
                'srv_setup_stepper_imap_server_id' => $imapServerId,
×
1144
                'srv_setup_stepper_smtp_server_id' => $smtpServerId
×
1145
            ] = $form;
×
1146
            $compose_type = $this->user_config->get('smtp_compose_type_setting', DEFAULT_SMTP_COMPOSE_TYPE);
×
1147
            if ($compose_type == 1) {
×
1148
                $profileSignature = purify_html_sig($profileSignature);
×
1149
            }
1150

1151
            /*
1152
            *  Connect to SMTP server if user wants to send emails
1153
            */
1154
            if($isSender){
×
1155
                if (!$this->module_is_supported('smtp')) {
×
1156
                    Hm_Msgs::add("SMTP module is not enabled",'danger');
×
1157
                    return;
×
1158
                }
1159
                $this->smtp_server_id = connect_to_smtp_server($smtpAddress, $profileName, $smtpPort, $email, $password, $smtpTls, 'smtp', $smtpServerId);
×
1160
                if(!isset($this->smtp_server_id)){
×
1161
                    Hm_Msgs::add("Could not save server", 'danger');
×
1162
                    return;
×
1163
                }
1164
            }
1165

1166
            /*
1167
            * When JMAP selected only configure JMAP
1168
            */
1169
            if(isset($onlyJmap) && $onlyJmap) {
×
1170
                if (!$this->module_is_supported('jmap')) {
×
1171
                    Hm_Msgs::add("JMAP module is not enabled", "danger");
×
1172
                    return;
×
1173
                }
1174

1175
                $this->jmap_server_id = connect_to_imap_server(
×
1176
                    $jmapAddress,
×
1177
                    $profileName,
×
1178
                    $imapPort,
×
1179
                    $email,
×
1180
                    $password,
×
1181
                    $imapTls,
×
1182
                    null,
×
1183
                    false,
×
1184
                    'jmap',
×
1185
                    $this,
×
1186
                    $hideFromCombinedView,
×
1187
                    $imapServerId,
×
1188
                    $imapSieveTls
×
1189
                );
×
1190

1191
                if(!isset($this->jmap_server_id)) {
×
1192
                    Hm_Msgs::add("Could not save JMAP server", "warning");
×
1193
                    return;
×
1194
                };
1195

1196
                Hm_Msgs::add("JMAP Server saved");
×
1197
                $this->out('just_saved_credentials', true);
×
1198
                return;
×
1199
            } else {
1200

1201
                /*
1202
                 *  Connect to IMAP server if user wants to receive emails
1203
                 */
1204
                if($isReceiver){
×
1205
                    if (!$this->module_is_supported('imap')) {
×
1206
                        Hm_Msgs::add("IMAP module is not enabled", "danger");
×
1207
                        return;
×
1208
                    }
1209

1210
                    $this->imap_server_id = connect_to_imap_server(
×
1211
                        $imapAddress,
×
1212
                        $profileName,
×
1213
                        $imapPort,
×
1214
                        $email,
×
1215
                        $password,
×
1216
                        $imapTls,
×
1217
                        $imapSieveHost,
×
1218
                        $enableSieve,
×
1219
                        'imap',
×
1220
                        $this,
×
1221
                        $hideFromCombinedView,
×
1222
                        $imapServerId,
×
1223
                        $imapSieveTls
×
1224
                    );
×
1225

1226
                    if(!isset($this->imap_server_id)) {
×
1227
                        if($isSender && isset($this->smtp_server_id)){
×
1228
                            delete_smtp_server($this->smtp_server_id, $this);
×
1229
                        }
1230
                        Hm_Msgs::add("Could not save IMAP server", "warning");
×
1231
                        return;
×
1232
                    };
1233
                }
1234

1235
                if ($this->module_is_supported('imap_folders')) {
×
1236
                    $this->out('imap_server_id', $this->imap_server_id);
×
1237
                    $this->out('imap_service_name', $provider);
×
1238
                }
1239
                $this->out('just_saved_credentials', true);
×
1240
                if (isPageConfigured('save')) {
×
1241
                    Hm_Msgs::add("Server saved. To preserve these settings after logout, please go to <a class='alert-link' href='".$this->build_page_url('save')."'>Save Settings</a>.");
×
1242
                } else {
1243
                    Hm_Msgs::add("Server saved.");
×
1244
                }
1245
            }
1246

1247
            if ($createProfile && $this->smtp_server_id && ($this->imap_server_id || $this->jmap_server_id)) {
×
1248
                if (!$this->module_is_supported('profiles')) {
×
1249
                    Hm_Msgs::add("Profiles module is not enabled", "danger");
×
1250
                    return;
×
1251
                }
1252

1253
                add_profile($profileName, $profileSignature, $profileReplyTo, $profileIsDefault, $email, $imapAddress, $email, $this->smtp_server_id, $this->imap_server_id ?? $this->jmap_server_id, $this);
×
1254
            }
1255
        }
1256
    }
1257
}
1258

1259
class Hm_Handler_privacy_settings extends Hm_Handler_Module {
1260
    
1261
    public function process() {
×
1262
        $settings = Hm_Output_privacy_settings::$settings;
×
1263
        foreach ($settings as $key => $setting) {
×
1264
            process_site_setting($key, $this, 'privacy_setting_callback');
×
1265
        }
1266
    }
1267
}
1268

1269
class Hm_Handler_version_upgrade_checker extends Hm_Handler_Module {
1270

1271
    public function process()
×
1272
    {
1273
        if ($this->session->get('latest_version')) {
×
1274
            $latestVersion = $this->session->get('latest_version');
×
1275
        } else {
1276
            $api = new Hm_API_Curl();
×
1277
            $data = $api->command('https://api.github.com/repos/cypht-org/cypht/releases');
×
1278

1279
            if ($api->last_status == 200) {
×
1280
                $latestRelease = reset($data);
×
1281
                $latestVersion = substr($latestRelease['tag_name'], 1);
×
1282

1283
                $this->session->set('latest_version', $latestVersion);
×
1284
            }
1285
        }
1286

1287
        if (version_compare(CYPHT_VERSION, $latestVersion, '<')) {
×
1288
            $needUpgrade = true;
×
1289
        } else {
1290
            $needUpgrade = false;
×
1291
        }
1292
        $this->out('need_upgrade', $needUpgrade);
×
1293
        $this->out('latest_version', $latestVersion);
×
1294
    }
1295
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc