Skip to content

Commit

Permalink
Merge branch 'cypht-org:master' into docker-refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
jonocodes authored May 18, 2024
2 parents e052fdd + cea402c commit 178746b
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 65 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ Community chat room: [https://gitter.im/cypht-org/community](https://gitter.im/c

For developers, get via Composer: [https://packagist.org/packages/jason-munro/cypht](https://packagist.org/packages/jason-munro/cypht)

Auto-generated code documentation: [https://cypht.org/docs/code_docs/index.html](https://cypht.org/docs/code_docs/index.html)

Docker: [https://hub.docker.com/r/sailfrog/cypht-docker](https://hub.docker.com/r/sailfrog/cypht-docker)

LinkedIn group: [https://www.linkedin.com/groups/13804559/](https://www.linkedin.com/groups/13804559/)

Contact: [[email protected]](mailto:[email protected])
4 changes: 2 additions & 2 deletions lib/framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Hm_Functions {
* @param string $value
* @return boolean
*/
public static function setcookie($name, $value, $lifetime = 0, $path = '', $domain = '', $secure = false, $html_only = false) {
public static function setcookie($name, $value, $lifetime = 0, $path = '', $domain = '', $secure = false, $html_only = false, $same_site = 'Strict') {
$prefix = ($lifetime != 0 && $lifetime < time()) ? 'Deleting' : 'Setting';
Hm_Debug::add(sprintf('%s cookie: name: %s, lifetime: %s, path: %s, domain: %s, secure: %s, html_only %s',$prefix, $name, $lifetime, $path, $domain, $secure, $html_only));
if (version_compare(PHP_VERSION, '7.3', '>=')) {
Expand All @@ -78,7 +78,7 @@ public static function setcookie($name, $value, $lifetime = 0, $path = '', $doma
'domain' => $domain,
'secure' => $secure,
'httponly' => $html_only,
'samesite' => 'Strict'
'samesite' => $same_site
]
);
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/ini_set.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/* limit session cookie to HTTP only */
ini_set('session.cookie_httponly', 1);
if (version_compare(PHP_VERSION, 7.3, '>=')) {
ini_set('session.cookie_samesite', 'Strict');
ini_set('session.cookie_samesite', 'Lax');
}

/* HTTPS required for session cookie */
Expand Down
6 changes: 3 additions & 3 deletions lib/session_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public function plaintext($data) {
*/
protected function set_key($request) {
$this->enc_key = Hm_Crypt::unique_id();
$this->secure_cookie($request, 'hm_id', $this->enc_key);
$this->secure_cookie($request, 'hm_id', $this->enc_key, '', '', 'Lax');
}

/**
Expand Down Expand Up @@ -329,9 +329,9 @@ private function cookie_path($request) {
* @param string $domain cookie domain
* @return boolean
*/
public function secure_cookie($request, $name, $value, $path='', $domain='') {
public function secure_cookie($request, $name, $value, $path='', $domain='', $same_site = 'Strict') {
list($path, $domain, $html_only) = $this->prep_cookie_params($request, $name, $path, $domain);
return Hm_Functions::setcookie($name, $value, $this->lifetime, $path, $domain, $request->tls, $html_only);
return Hm_Functions::setcookie($name, $value, $this->lifetime, $path, $domain, $request->tls, $html_only, $same_site);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions modules/api_login/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function process() {
return;
}
list($secure, $path, $domain) = $this->session->set_session_params($this->request);
Hm_Functions::setcookie('hm_id', stripslashes($form['hm_id']), 0, $path, $domain, $secure, true);
Hm_Functions::setcookie('hm_session', stripslashes($form['hm_session']), 0, $path, $domain, $secure, true);
Hm_Functions::setcookie('hm_id', stripslashes($form['hm_id']), 0, $path, $domain, $secure, true, 'Lax');
Hm_Functions::setcookie('hm_session', stripslashes($form['hm_session']), 0, $path, $domain, $secure, true, 'Lax');
Hm_Dispatch::page_redirect('?page=home');
}
}
Expand Down
4 changes: 2 additions & 2 deletions modules/contacts/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function process() {

if (!empty($newContacts)) {
$newContacts = array_map(function ($email) {
return ['source' => 'local', 'email_address' => $email, 'display_name' => $email, 'group' => $this->trans('Collected Recipients')];
return ['source' => 'local', 'email_address' => $email, 'display_name' => $email, 'group' => 'Collected Recipients'];
}, $newContacts);
$contacts->add_contact($newContacts[0]);
$this->session->record_unsaved('Contact Added');
Expand All @@ -64,7 +64,7 @@ public function process() {
$contact_list = $contacts->getAll();
$existingEmails = array_column($contact_list, 'email_address');
if (!in_array($email, $existingEmails)) {
$contacts->add_contact(['source' => 'local', 'email_address' => $email, 'display_name' => $name, 'group' => $this->trans('Trusted Senders')]);
$contacts->add_contact(['source' => 'local', 'email_address' => $email, 'display_name' => $name, 'group' => 'Trusted Senders']);
$this->session->record_unsaved('Contact Added');
Hm_Msgs::add('Contact Added');
}
Expand Down
3 changes: 1 addition & 2 deletions modules/contacts/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
'contact_email' => FILTER_DEFAULT,
'contact_name' => FILTER_DEFAULT,
'contact_phone' => FILTER_DEFAULT,
'contact_id' => FILTER_VALIDATE_INT,
'contact_id' => FILTER_DEFAULT,
'contact_value' => FILTER_DEFAULT,
'edit_contact' => FILTER_DEFAULT,
'add_contact' => FILTER_DEFAULT,
Expand All @@ -70,7 +70,6 @@
'contact_name' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
'contact_phone' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
'contact_group' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
'contact_id' => FILTER_VALIDATE_INT,
'contact_value' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
'edit_contact' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
'add_contact' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
Expand Down
33 changes: 16 additions & 17 deletions modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,13 @@ protected function output() {
$logged_out_class = ' logged_out';
}
$res .= '<div class="d-none position-fixed top-0 end-0 mt-3 me-3 sys_messages'.$logged_out_class.'">';
if (!empty($msgs)) {
$res .= implode(',', array_map(function($v) {
if (preg_match("/ERR/", $v)) {
return sprintf('<div class="alert alert-danger alert-dismissible fade show" role="alert"><i class="bi bi-exclamation-triangle me-2"></i><span class="danger">%s</span>', $this->trans(substr((string) $v, 3)));
}
else {
return sprintf('<div class="alert alert-success alert-dismissible fade show" role="alert"><i class="bi bi-check-circle me-2"></i><span class="info">%s</span>', $this->trans($v));
}
}, $msgs));
foreach ($msgs as $msg) {
if (preg_match("/ERR/", $msg)) {
$res .= sprintf('<div class="alert alert-danger alert-dismissible fade show" role="alert"><i class="bi bi-exclamation-triangle me-2"></i><span class="danger">%s</span>', $this->trans(substr((string) $msg, 3)));
}
else {
$res .= sprintf('<div class="alert alert-success alert-dismissible fade show" role="alert"><i class="bi bi-check-circle me-2"></i><span class="info">%s</span>', $this->trans($msg));
}
$res .= '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>';
}
$res .= '</div>';
Expand Down Expand Up @@ -1775,18 +1773,19 @@ class Hm_Output_home_password_dialogs extends Hm_Output_Module {
protected function output() {
$missing = $this->get('missing_pw_servers', array());
if (count($missing) > 0) {
$res = '<div class="home_password_dialogs">';
$res .= '<div class="nux_title">Passwords</div>'.$this->trans('You have elected to not store passwords between logins.').
' '.$this->trans('Enter your passwords below to gain access to these services during this session.').'<br /><br />';
$res = '<div class="home_password_dialogs mt-3 col-lg-6 col-md-5 col-sm-12">';
$res .= '<div class="card"><div class="card-body">';
$res .= '<div class="card_title"><h4>Passwords</h4></div><p>'.$this->trans('You have elected to not store passwords between logins.').
' '.$this->trans('Enter your passwords below to gain access to these services during this session.').'</p>';

foreach ($missing as $vals) {
$id = $this->html_safe(sprintf('%s_%s', strtolower($vals['type']), $vals['id']));
$res .= '<div class="div_'.$id.'" >'.$this->html_safe($vals['type']).' '.$this->html_safe($vals['name']).
' '.$this->html_safe($vals['user']).' '.$this->html_safe($vals['server']).' <input placeholder="'.$this->trans('Password').
'" type="password" class="pw_input" id="update_pw_'.$id.'" /> <input type="button" class="pw_update" data-id="'.$id.
'" value="'.$this->trans('Update').'" /></div>';
$res .= '<div class="div_'.$id.' mt-3">'.$this->html_safe($vals['type']).' '.$this->html_safe($vals['name']).
' '.$this->html_safe($vals['user']).' '.$this->html_safe($vals['server']).' <div class="input-group mt-2"><input placeholder="'.$this->trans('Password').
'" type="password" class="form-control pw_input" id="update_pw_'.$id.'" /> <input type="button" class="pw_update btn btn-primary" data-id="'.$id.
'" value="'.$this->trans('Update').'" /></div></div>';
}
$res .= '</div>';
$res .= '</div></div></div>';
return $res;
}
}
Expand Down
16 changes: 0 additions & 16 deletions modules/core/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -772,22 +772,6 @@ div.unseen,
rgba(0, 0, 0, 0.3) 70%
);
}
.home_password_dialogs {
min-height: 400px;
max-width: 480px;
padding: 20px;
margin: 20px;
margin-right: 0px;
float: left;
border: solid 1px #eee;
}
.home_password_dialogs .pw_input {
width: 120px;
}
.nux_title {
font-size: 120%;
margin-bottom: 20px;
}
.total_unread_count,
.unread_count {
background-color: #ccc;
Expand Down
2 changes: 1 addition & 1 deletion modules/feeds/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
add_handler('servers', 'process_add_feed', true, 'feeds', 'load_feeds_from_config', 'after');
add_handler('servers', 'add_feeds_to_page_data', true, 'feeds', 'process_add_feed', 'after');
add_handler('servers', 'save_feeds', true, 'feeds', 'add_feeds_to_page_data', 'after');
add_output('servers', 'add_feed_dialog', true, 'feeds', 'server_content_start', 'after');
add_output('servers', 'add_feed_dialog', true, 'feeds', 'server_content_end', 'before');
add_output('servers', 'display_configured_feeds', true, 'feeds', 'add_feed_dialog', 'after');
add_output('servers', 'feed_ids', true, 'feeds', 'page_js', 'before');

Expand Down
4 changes: 2 additions & 2 deletions modules/imap/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function format_imap_folder_section($folders, $id, $output_mod, $with_input = fa
if (strlen($output_mod->html_safe($folder['basename']))>15) {
$results .= '<a ' . $attrs .
' title="'.$output_mod->html_safe($folder['basename']).
'">'.substr($output_mod->html_safe($folder['basename']),0,15).'...</a>';
'">'.mb_substr($output_mod->html_safe($folder['basename']),0,15).'...</a>';
}
else {
$results .= '<a ' . $attrs. '>'.$output_mod->html_safe($folder['basename']).'</a>';
Expand Down Expand Up @@ -1217,7 +1217,7 @@ function prep_folder_name($imap, $folder, $decode_folder=false, $parent=false) {
if ($parent) {
$folder = sprintf('%s%s%s', $parent, $ns['delim'], $folder);
}
if ($folder && $ns['prefix'] && substr($folder, 0, strlen($ns['prefix'])) !== $ns['prefix']) {
if ($folder && $ns['prefix'] && mb_substr($folder, 0, strlen($ns['prefix'])) !== $ns['prefix']) {
$folder = sprintf('%s%s', $ns['prefix'], $folder);
}
return $folder;
Expand Down
4 changes: 2 additions & 2 deletions modules/nux/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ protected function output() {
*/
class Hm_Output_nux_dev_news extends Hm_Output_Module {
protected function output() {
$res = '<div class="nux_dev_news mt-3 col-12"><div class="card"><div class="card-body"><div class="nux_title">'.$this->trans('Development Updates').'</div><table>';
$res = '<div class="nux_dev_news mt-3 col-12"><div class="card"><div class="card-body"><div class="card_title"><h4>'.$this->trans('Development Updates').'</h4></div><table>';
foreach ($this->get('nux_dev_news', array()) as $vals) {
$res .= sprintf('<tr><td><a href="https://github.com/cypht-org/cypht/commit/%s" target="_blank" rel="noopener">%s</a>'.
'</td><td class="msg_date">%s</td><td>%s</td><td>%s</td></tr>',
Expand All @@ -351,7 +351,7 @@ protected function output() {
*/
class Hm_Output_nux_help extends Hm_Output_Module {
protected function output() {
return '<div class="nux_help mt-3 col-lg-6 col-md-12 col-sm-12"><div class="card"><div class="card-body"><div class="nux_title">'.$this->trans('Help').'</div>'.
return '<div class="nux_help mt-3 col-lg-6 col-md-12 col-sm-12"><div class="card"><div class="card-body"><div class="card_title"><h4>'.$this->trans('Help').'</h4></div>'.
$this->trans('Cypht is a webmail program. You can use it to access your E-mail accounts from any service that offers IMAP, or SMTP access - which most do.').' '.
'</div></div></div>';
}
Expand Down
2 changes: 1 addition & 1 deletion modules/nux/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
output_source('nux');

/* servers page */
add_output('servers', 'quick_add_section', true, 'nux', 'server_config_stepper_accordion_end_part', 'after');
add_output('servers', 'quick_add_section', true, 'nux', 'server_content_start', 'after');
add_output('servers', 'quick_add_dialog', true, 'nux', 'quick_add_section', 'after');

add_handler('ajax_nux_service_select', 'login', false, 'core');
Expand Down
2 changes: 1 addition & 1 deletion modules/smtp/assets/markdown/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7224,7 +7224,7 @@ Editor.prototype.render = function(el) {
tabSize: '2',
indentWithTabs: true,
lineNumbers: false,
autofocus: true,
autofocus: false,
extraKeys: keyMaps
});

Expand Down
8 changes: 4 additions & 4 deletions modules/smtp/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ protected function output() {
if ($html == 1) {
$res .= '<script type="text/javascript" src="'.WEB_ROOT.'modules/smtp/assets/kindeditor/kindeditor-all-min.js"></script>'.
'<link href="'.WEB_ROOT.'modules/smtp/assets/kindeditor/themes/default/default.css" rel="stylesheet" />'.
'<script type="text/javascript">KindEditor.ready(function(K) { K.create("#compose_body", {items:'.
'<script type="text/javascript">KindEditor.ready(function(K) { window.kindEditor = K.create("#compose_body", {items:'.
"['formatblock', 'fontname', 'fontsize', 'forecolor', 'hilitecolor', 'bold',".
"'italic', 'underline', 'strikethrough', 'lineheight', 'table', 'hr', 'pagebreak', 'link', 'unlink',".
"'justifyleft', 'justifycenter', 'justifyright',".
Expand Down Expand Up @@ -1131,14 +1131,14 @@ protected function output() {
'</div>'.
'<div class="form-floating mb-3">'.
'<textarea id="compose_body" name="compose_body" class="compose_body form-control" placeholder="'.$this->trans('Message').'">'.$this->html_safe($body).'</textarea>'.
'<label for="compose_body">'.$this->trans('Message').'</label>'.
(!$html ? '<label for="compose_body">'.$this->trans('Message').'</label>': '').
'</div>'.
'<div class="form-check mb-3"><input value="1" name="compose_delivery_receipt" id="compose_delivery_receipt" type="checkbox" class="form-check-input" /><label for="compose_delivery_receipt" class="form-check-label">'.$this->trans('Request a delivery receipt').'</label></div>';
'<div class="form-check mb-3"><input value="0" name="compose_delivery_receipt" id="compose_delivery_receipt" type="checkbox" class="form-check-input" /><label for="compose_delivery_receipt" class="form-check-label">'.$this->trans('Request a delivery receipt').'</label></div>';
if ($html == 2) {
$res .= '<link href="'.WEB_ROOT.'modules/smtp/assets/markdown/editor.css" rel="stylesheet" />'.
'<script type="text/javascript" src="'.WEB_ROOT.'modules/smtp/assets/markdown/editor.js"></script>'.
'<script type="text/javascript" src="'.WEB_ROOT.'modules/smtp/assets/markdown/marked.js"></script>'.
'<script type="text/javascript">var editor = new Editor(); editor.render();</script>';
'<script type="text/javascript">window.mdEditor = new Editor(); mdEditor.render();</script>';
}
$res .= '<table class="uploaded_files">';

Expand Down
6 changes: 3 additions & 3 deletions modules/smtp/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
.smtp_server_setup .content_title { cursor: pointer; }
/* .compose_server, .compose_server option { width: 100%; padding: 5px; margin: 5px; } */
/* .compose_attach_button, .smtp_save, .smtp_reset { cursor: pointer; margin-left: 10px; float: right; margin-top: 10px; } */
.ke-container { margin-left: 5px !important; border-radius: 3px 3px 3px; margin-top: 5px !important; margin-bottom: 5px !important; padding-right: 0px !important; width: 100% !important; }
.ke-container { border-radius: var(--bs-border-radius); margin-top: 5px !important; margin-bottom: 5px !important; padding-right: 0px !important; width: 100% !important; }
.recipient_fields { display: none; }
.compose_attach_file { width: 0px; opacity: 0; }
.uploaded_files { width: 1%; margin-left: 5px; margin-top: 5px; margin-bottom: 5px; }
Expand All @@ -25,9 +25,9 @@
.draft_title { top: 10px; right: 10px; }
.draft_list a { font-size: 115%; padding-right: 10px; }
.draft_list img { float: right; opacity: .4; vertical-align: -3px; cursor: pointer; }
.CodeMirror { border: solid 1px #ddd; border-top: none; margin-left: 5px; border-radius: 0px 0px 3px 3px; width: 100%; }
.CodeMirror { border: solid 1px #ddd; border-top: none; border-bottom-left-radius: var(--bs-border-radius); border-bottom-right-radius: var(--bs-border-radius); width: 100%; }
.editor-toolbar * { border: none !important; }
.editor-toolbar { z-index: 0; margin-left: 5px; margin-top: 10px; border: solid 1px #ccc; width: 100%; border-radius: 3px 3px 0px 0px; }
.editor-toolbar { z-index: 0; margin-top: 10px; border: solid 1px #ccc; width: 100%; border-top-left-radius: var(--bs-border-radius); border-top-right-radius: var(--bs-border-radius); }
.editor-statusbar { border-top: none !important; }
.editor-toolbar:before, .editor-toolbar:after { background: none !important; }
.meter { height: 5px; position: relative; background: #ede8e6; overflow: hidden;}
Expand Down
8 changes: 8 additions & 0 deletions modules/smtp/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,14 @@ $(function () {
});

$('.smtp_send_placeholder').on("click", function (e) {
if (window.kindEditor) {
kindEditor.sync();
}

if (window.mdEditor) {
mdEditor.codemirror.save();
}

const body = $('.compose_body').val().trim();
const subject = $('.compose_subject').val().trim();

Expand Down
Loading

0 comments on commit 178746b

Please sign in to comment.