2
0
forked from Wavyzz/dolibarr

Merge remote-tracking branch 'upstream/develop' into Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword

This commit is contained in:
Frédéric FRANCE
2020-05-23 18:34:58 +02:00
26 changed files with 1687 additions and 1479 deletions

View File

@@ -448,15 +448,15 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len
{
$max = strlen($lowercase) - 1;
for ($x = 0; $x < $nbofchar; $x++) {
$randomCode .= $lowercase{random_int(0, $max)};
$randomCode .= $lowercase[random_int(0, $max)];
}
$max = strlen($uppercase) - 1;
for ($x = 0; $x < $nbofchar; $x++) {
$randomCode .= $uppercase{random_int(0, $max)};
$randomCode .= $uppercase[random_int(0, $max)];
}
$max = strlen($numbers) - 1;
for ($x = 0; $x < $nbofcharlast; $x++) {
$randomCode .= $numbers{random_int(0, $max)};
$randomCode .= $numbers[random_int(0, $max)];
}
$generated_password = str_shuffle($randomCode);
@@ -464,15 +464,15 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len
{
$max = strlen($lowercase) - 1;
for ($x = 0; $x < $nbofchar; $x++) {
$randomCode .= $lowercase{mt_rand(0, $max)};
$randomCode .= $lowercase[mt_rand(0, $max)];
}
$max = strlen($uppercase) - 1;
for ($x = 0; $x < $nbofchar; $x++) {
$randomCode .= $uppercase{mt_rand(0, $max)};
$randomCode .= $uppercase[mt_rand(0, $max)];
}
$max = strlen($numbers) - 1;
for ($x = 0; $x < $nbofcharlast; $x++) {
$randomCode .= $numbers{mt_rand(0, $max)};
$randomCode .= $numbers[mt_rand(0, $max)];
}
$generated_password = str_shuffle($randomCode);
@@ -495,9 +495,9 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len
$max = strlen($numbers) - 1;
if (function_exists('random_int')) // Cryptographic random
{
$generated_password = str_replace($replaceambiguouschars, $numbers{random_int(0, $max)}, $generated_password);
$generated_password = str_replace($replaceambiguouschars, $numbers[random_int(0, $max)], $generated_password);
} else {
$generated_password = str_replace($replaceambiguouschars, $numbers{mt_rand(0, $max)}, $generated_password);
$generated_password = str_replace($replaceambiguouschars, $numbers[mt_rand(0, $max)], $generated_password);
}
}

View File

@@ -228,11 +228,11 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage)
/**
* Save content of the index.php and wrapper.php page
* Save content of the index.php and/or wrapper.php page
*
* @param string $pathofwebsite Path of website root
* @param string $fileindex Full path of file index.php
* @param string $filetpl File tpl to index.php page redirect to
* @param string $filetpl File tpl the index.php page redirect to
* @param string $filewrapper Full path of file wrapper.php
* @return boolean True if OK
*/
@@ -245,29 +245,39 @@ function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper)
dol_mkdir($pathofwebsite);
dol_delete_file($fileindex);
$indexcontent = '<?php'."\n";
$indexcontent .= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
$indexcontent .= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
$indexcontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
$indexcontent .= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n";
$indexcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
$indexcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
$indexcontent .= ' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
$indexcontent .= "}\n";
$indexcontent .= "include_once './".basename($filetpl)."'\n";
$indexcontent .= '// END PHP ?>'."\n";
$result1 = file_put_contents($fileindex, $indexcontent);
if (!empty($conf->global->MAIN_UMASK)) {
@chmod($fileindex, octdec($conf->global->MAIN_UMASK));
if ($fileindex) {
dol_delete_file($fileindex);
$indexcontent = '<?php'."\n";
$indexcontent .= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
$indexcontent .= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
$indexcontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
$indexcontent .= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n";
$indexcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
$indexcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
$indexcontent .= ' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
$indexcontent .= "}\n";
$indexcontent .= "include_once './".basename($filetpl)."'\n";
$indexcontent .= '// END PHP ?>'."\n";
$result1 = file_put_contents($fileindex, $indexcontent);
if (!empty($conf->global->MAIN_UMASK)) {
@chmod($fileindex, octdec($conf->global->MAIN_UMASK));
}
}
else {
$result1 = true;
}
dol_delete_file($filewrapper);
$wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.php');
if ($filewrapper) {
dol_delete_file($filewrapper);
$wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.php');
$result2 = file_put_contents($filewrapper, $wrappercontent);
if (!empty($conf->global->MAIN_UMASK)) {
@chmod($filewrapper, octdec($conf->global->MAIN_UMASK));
$result2 = file_put_contents($filewrapper, $wrappercontent);
if (!empty($conf->global->MAIN_UMASK)) {
@chmod($filewrapper, octdec($conf->global->MAIN_UMASK));
}
} else {
$result2 = true;
}
return ($result1 && $result2);

View File

@@ -330,9 +330,10 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
* @param string $outputfile Output file
* @param string $filter (optional) Filter
* @param string $url Url (If empty, forge URL for agenda RSS export)
* @param string $langcode Language code to show in header
* @return int < 0 if ko, Nb of events in file if ok
*/
function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '', $url = '')
function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '', $url = '', $langcode = '')
{
global $user, $conf, $langs;
global $dolibarr_main_url_root;
@@ -358,7 +359,9 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt
fwrite($fichier, '<rss version="2.0">');
fwrite($fichier, "\n");
fwrite($fichier, "<channel>\n<title>".$title."</title>\n");
fwrite($fichier, "<channel>\n");
fwrite($fichier, "<title>".$title."</title>\n");
if ($langcode) fwrite($fichier, "<language>".$langcode."</language>\n");
/*
fwrite($fichier, "<description><![CDATA[".$desc.".]]></description>"."\n".