Protect dynamic php content with installmodules.lock
This commit is contained in:
parent
261320e551
commit
c97c185368
@ -722,11 +722,31 @@ function checkPHPCode($phpfullcodestringold, $phpfullcodestring)
|
|||||||
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", '$...('), null, 'errors');
|
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", '$...('), null, 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error && empty($user->rights->website->writephp)) {
|
|
||||||
if ($phpfullcodestringold != $phpfullcodestring) {
|
if ($phpfullcodestringold != $phpfullcodestring) {
|
||||||
|
if (!$error && empty($user->rights->website->writephp)) {
|
||||||
$error++;
|
$error++;
|
||||||
setEventMessages($langs->trans("NotAllowedToAddDynamicContent"), null, 'errors');
|
setEventMessages($langs->trans("NotAllowedToAddDynamicContent"), null, 'errors');
|
||||||
}
|
}
|
||||||
|
if (!$error) {
|
||||||
|
$dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT);
|
||||||
|
$allowimportsite = true;
|
||||||
|
if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) {
|
||||||
|
$allowimportsite = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$allowimportsite) {
|
||||||
|
$error++;
|
||||||
|
// Blocked by installmodules.lock
|
||||||
|
if (getDolGlobalString('MAIN_MESSAGE_INSTALL_MODULES_DISABLED_CONTACT_US')) {
|
||||||
|
// Show clean corporate message
|
||||||
|
$message = $langs->trans('InstallModuleFromWebHasBeenDisabledContactUs');
|
||||||
|
} else {
|
||||||
|
// Show technical generic message
|
||||||
|
$message = $langs->trans("InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.'/installmodules.lock');
|
||||||
|
}
|
||||||
|
setEventMessages($message, null, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $error;
|
return $error;
|
||||||
|
|||||||
@ -1932,7 +1932,7 @@ BackupDumpWizard=Wizard to build the database dump file
|
|||||||
BackupZipWizard=Wizard to build the archive of documents directory
|
BackupZipWizard=Wizard to build the archive of documents directory
|
||||||
SomethingMakeInstallFromWebNotPossible=Installation of external module is not possible from the web interface for the following reason:
|
SomethingMakeInstallFromWebNotPossible=Installation of external module is not possible from the web interface for the following reason:
|
||||||
SomethingMakeInstallFromWebNotPossible2=For this reason, process to upgrade described here is a manual process only a privileged user may perform.
|
SomethingMakeInstallFromWebNotPossible2=For this reason, process to upgrade described here is a manual process only a privileged user may perform.
|
||||||
InstallModuleFromWebHasBeenDisabledContactUs=Install or development of external modules from the application is currently locked for security purpose. Please contact us if you need to enable this feature.
|
InstallModuleFromWebHasBeenDisabledContactUs=Install or development of external modules or dynamic websites, from the application, is currently locked for security purpose. Please contact us if you need to enable this feature.
|
||||||
InstallModuleFromWebHasBeenDisabledByFile=Install of external module from application has been disabled by your administrator. You must ask him to remove the file <strong>%s</strong> to allow this feature.
|
InstallModuleFromWebHasBeenDisabledByFile=Install of external module from application has been disabled by your administrator. You must ask him to remove the file <strong>%s</strong> to allow this feature.
|
||||||
ConfFileMustContainCustom=Installing or building an external module from application need to save the module files into directory <strong>%s</strong>. To have this directory processed by Dolibarr, you must setup your <strong>conf/conf.php</strong> to add the 2 directive lines:<br><strong>$dolibarr_main_url_root_alt='/custom';</strong><br><strong>$dolibarr_main_document_root_alt='%s/custom';</strong>
|
ConfFileMustContainCustom=Installing or building an external module from application need to save the module files into directory <strong>%s</strong>. To have this directory processed by Dolibarr, you must setup your <strong>conf/conf.php</strong> to add the 2 directive lines:<br><strong>$dolibarr_main_url_root_alt='/custom';</strong><br><strong>$dolibarr_main_document_root_alt='%s/custom';</strong>
|
||||||
HighlightLinesOnMouseHover=Highlight table lines when mouse move passes over
|
HighlightLinesOnMouseHover=Highlight table lines when mouse move passes over
|
||||||
|
|||||||
@ -572,7 +572,23 @@ if ($massaction == 'delcategory' && GETPOST('confirmmassaction', 'alpha') && $us
|
|||||||
if ($massaction == 'replace' && GETPOST('confirmmassaction', 'alpha') && $usercanedit) {
|
if ($massaction == 'replace' && GETPOST('confirmmassaction', 'alpha') && $usercanedit) {
|
||||||
$replacestring = GETPOST('replacestring', 'none');
|
$replacestring = GETPOST('replacestring', 'none');
|
||||||
|
|
||||||
if (empty($user->rights->website->writephp)) {
|
$dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT);
|
||||||
|
$allowimportsite = true;
|
||||||
|
if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) {
|
||||||
|
$allowimportsite = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$allowimportsite) {
|
||||||
|
// Blocked by installmodules.lock
|
||||||
|
if (getDolGlobalString('MAIN_MESSAGE_INSTALL_MODULES_DISABLED_CONTACT_US')) {
|
||||||
|
// Show clean corporate message
|
||||||
|
$message = $langs->trans('InstallModuleFromWebHasBeenDisabledContactUs');
|
||||||
|
} else {
|
||||||
|
// Show technical generic message
|
||||||
|
$message = $langs->trans("InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.'/installmodules.lock');
|
||||||
|
}
|
||||||
|
setEventMessages($message, null, 'errors');
|
||||||
|
} elseif (empty($user->rights->website->writephp)) {
|
||||||
setEventMessages("NotAllowedToAddDynamicContent", null, 'errors');
|
setEventMessages("NotAllowedToAddDynamicContent", null, 'errors');
|
||||||
} elseif (!$replacestring) {
|
} elseif (!$replacestring) {
|
||||||
setEventMessages("ErrorReplaceStringEmpty", null, 'errors');
|
setEventMessages("ErrorReplaceStringEmpty", null, 'errors');
|
||||||
@ -2377,6 +2393,13 @@ if ($action == 'regeneratesite' && $usercanedit) {
|
|||||||
|
|
||||||
// Import site
|
// Import site
|
||||||
if ($action == 'importsiteconfirm' && $usercanedit) {
|
if ($action == 'importsiteconfirm' && $usercanedit) {
|
||||||
|
$dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT);
|
||||||
|
$allowimportsite = true;
|
||||||
|
if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) {
|
||||||
|
$allowimportsite = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($allowimportsite) {
|
||||||
if (empty($_FILES) && !GETPOSTISSET('templateuserfile')) {
|
if (empty($_FILES) && !GETPOSTISSET('templateuserfile')) {
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors');
|
||||||
$action = 'importsite';
|
$action = 'importsite';
|
||||||
@ -2448,6 +2471,16 @@ if ($action == 'importsiteconfirm' && $usercanedit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (getDolGlobalString('MAIN_MESSAGE_INSTALL_MODULES_DISABLED_CONTACT_US')) {
|
||||||
|
// Show clean corporate message
|
||||||
|
$message = $langs->trans('InstallModuleFromWebHasBeenDisabledContactUs');
|
||||||
|
} else {
|
||||||
|
// Show technical generic message
|
||||||
|
$message = $langs->trans("InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.'/installmodules.lock');
|
||||||
|
}
|
||||||
|
setEventMessages($message, null, 'errors');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$domainname = '0.0.0.0:8080';
|
$domainname = '0.0.0.0:8080';
|
||||||
@ -3847,6 +3880,14 @@ if ($action == 'importsite') {
|
|||||||
|
|
||||||
print '<span class="opacitymedium">'.$langs->trans("ZipOfWebsitePackageToImport").'</span><br><br>';
|
print '<span class="opacitymedium">'.$langs->trans("ZipOfWebsitePackageToImport").'</span><br><br>';
|
||||||
|
|
||||||
|
|
||||||
|
$dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT);
|
||||||
|
$allowimportsite = true;
|
||||||
|
if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) {
|
||||||
|
$allowimportsite = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($allowimportsite) {
|
||||||
$maxfilesizearray = getMaxFileSizeArray();
|
$maxfilesizearray = getMaxFileSizeArray();
|
||||||
$maxmin = $maxfilesizearray['maxmin'];
|
$maxmin = $maxfilesizearray['maxmin'];
|
||||||
if ($maxmin > 0) {
|
if ($maxmin > 0) {
|
||||||
@ -3855,8 +3896,17 @@ if ($action == 'importsite') {
|
|||||||
print '<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">';
|
print '<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">';
|
||||||
print '<input type="submit" class="button small" name="buttonsubmitimportfile" value="'.dol_escape_htmltag($langs->trans("Upload")).'">';
|
print '<input type="submit" class="button small" name="buttonsubmitimportfile" value="'.dol_escape_htmltag($langs->trans("Upload")).'">';
|
||||||
print '<input type="submit" class="button button-cancel small" name="preview" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
|
print '<input type="submit" class="button button-cancel small" name="preview" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
|
||||||
|
|
||||||
print '<br><br><br>';
|
print '<br><br><br>';
|
||||||
|
} else {
|
||||||
|
if (getDolGlobalString('MAIN_MESSAGE_INSTALL_MODULES_DISABLED_CONTACT_US')) {
|
||||||
|
// Show clean corporate message
|
||||||
|
$message = $langs->trans('InstallModuleFromWebHasBeenDisabledContactUs');
|
||||||
|
} else {
|
||||||
|
// Show technical generic message
|
||||||
|
$message = $langs->trans("InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.'/installmodules.lock');
|
||||||
|
}
|
||||||
|
print info_admin($message).'<br><br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
print '<span class="opacitymedium">'.$langs->trans("ZipOfWebsitePackageToLoad").'</span><br><br>';
|
print '<span class="opacitymedium">'.$langs->trans("ZipOfWebsitePackageToLoad").'</span><br><br>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user