Add warning on non https website to axplain why features is broken

This commit is contained in:
Laurent Destailleur
2020-12-18 15:08:00 +01:00
parent 832db82fce
commit 0eaf924d3b
5 changed files with 35 additions and 4 deletions

View File

@@ -187,10 +187,18 @@ print '<td class="center">&nbsp;</td>'."\n";
print '<td class="right">'."\n";
if (empty($conf->global->AGENDA_REMINDER_BROWSER)) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER&amp;token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
if (! getIsHTTPS()) {
$langs->load("errors");
print img_warning($langs->trans("WarningAvailableOnlyForHTTPSServers"), '', 'valignmiddle size15x').' ';
}
print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER&amp;token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
print '</td></tr>'."\n";
} else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER&amp;token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
if (! getIsHTTPS()) {
$langs->load("errors");
print img_warning($langs->trans("WarningAvailableOnlyForHTTPSServers"), '', 'valignmiddle size15x').' ';
}
print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER&amp;token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
print '</td></tr>'."\n";
print '<tr class="oddeven">'."\n";

View File

@@ -2897,6 +2897,26 @@ function getUserRemoteIP()
return $ip;
}
/**
* Return if we are using a HTTPS connexion
* Check HTTPS (no way to be modified by user but may be empty or wrong if user is using a proxy)
* Take HTTP_X_FORWARDED_PROTO (defined when using proxy)
* Then HTTP_X_FORWARDED_SSL
*
* @return boolean True if user is using HTTPS
*/
function getIsHTTPS()
{
$isSecure = false;
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
$isSecure = true;
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
$isSecure = true;
}
return $isSecure;
}
/**
* Return a country code from IP. Empty string if not found.
*

View File

@@ -283,3 +283,4 @@ WarningSomeBankTransactionByChequeWereRemovedAfter=Some bank transaction were re
WarningFailedToAddFileIntoDatabaseIndex=Warning, failed to add file entry into ECM database index table
WarningTheHiddenOptionIsOn=Warning, the hidden option <b>%s</b> is on.
WarningCreateSubAccounts=Warning, you can't create directly a sub account, you must create a third party or an user and assign them an accounting code to find them in this list
WarningAvailableOnlyForHTTPSServers=Available only if using HTTPS secured connection.

View File

@@ -769,7 +769,8 @@ span.fa.fa-plus-circle.paddingleft {
padding-bottom: 2px;
}
.fa-toggle-on, .fa-toggle-off { font-size: 2em; }
.size15x { font-size: 1.5em; }
.fa-toggle-on, .fa-toggle-off, .size2x { font-size: 2em; }
.websiteselectionsection .fa-toggle-on, .websiteselectionsection .fa-toggle-off,
.asetresetmodule .fa-toggle-on, .asetresetmodule .fa-toggle-off,
.tdwebsitesearchresult .fa-toggle-on, .tdwebsitesearchresult .fa-toggle-off

View File

@@ -840,7 +840,8 @@ body[class*="colorblind-"] .text-success{
color: rgb(<?php echo $colortexttitle; ?>) !important;
}
.fa-toggle-on, .fa-toggle-off { font-size: 2em; }
.size15x { font-size: 1.5em; }
.fa-toggle-on, .fa-toggle-off, .size2x { font-size: 2em; }
.websiteselectionsection .fa-toggle-on, .websiteselectionsection .fa-toggle-off,
.asetresetmodule .fa-toggle-on, .asetresetmodule .fa-toggle-off {
font-size: 1.5em; vertical-align: text-bottom;