Fix upload of website templates must remain into templates dir.
This commit is contained in:
parent
3143175349
commit
064409803a
@ -1157,7 +1157,7 @@ class Website extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Open a zip with all data of web site and load it into database.
|
* Open a zip with all data of web site and load it into database.
|
||||||
*
|
*
|
||||||
* @param string $pathtofile Path of zip file
|
* @param string $pathtofile Full path of zip file
|
||||||
* @return int <0 if KO, Id of new website if OK
|
* @return int <0 if KO, Id of new website if OK
|
||||||
*/
|
*/
|
||||||
public function importWebSite($pathtofile)
|
public function importWebSite($pathtofile)
|
||||||
@ -1166,6 +1166,8 @@ class Website extends CommonObject
|
|||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
|
$pathtofile = dol_sanitizePathName($pathtofile);
|
||||||
|
|
||||||
$object = $this;
|
$object = $this;
|
||||||
if (empty($object->ref)) {
|
if (empty($object->ref)) {
|
||||||
$this->error = 'Function importWebSite called on object not loaded (object->ref is empty)';
|
$this->error = 'Function importWebSite called on object not loaded (object->ref is empty)';
|
||||||
|
|||||||
@ -2420,14 +2420,17 @@ if ($action == 'importsiteconfirm' && $usercanedit) {
|
|||||||
|
|
||||||
$fileofzip = '';
|
$fileofzip = '';
|
||||||
if (GETPOSTISSET('templateuserfile')) {
|
if (GETPOSTISSET('templateuserfile')) {
|
||||||
$fileofzip = DOL_DATA_ROOT.'/doctemplates/websites/'.GETPOST('templateuserfile', 'alpha');
|
// Case we selected one template
|
||||||
|
$fileofzip = DOL_DATA_ROOT.'/doctemplates/websites/'.GETPOST('templateuserfile', 'alpha'); // $fileofzip will be sanitized later into the importWebSite()
|
||||||
} elseif (!empty($_FILES)) {
|
} elseif (!empty($_FILES)) {
|
||||||
|
// Case we upload a new template
|
||||||
if (is_array($_FILES['userfile']['tmp_name'])) {
|
if (is_array($_FILES['userfile']['tmp_name'])) {
|
||||||
$userfiles = $_FILES['userfile']['tmp_name'];
|
$userfiles = $_FILES['userfile']['tmp_name'];
|
||||||
} else {
|
} else {
|
||||||
$userfiles = array($_FILES['userfile']['tmp_name']);
|
$userfiles = array($_FILES['userfile']['tmp_name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if $_FILES is ok
|
||||||
foreach ($userfiles as $key => $userfile) {
|
foreach ($userfiles as $key => $userfile) {
|
||||||
if (empty($_FILES['userfile']['tmp_name'][$key])) {
|
if (empty($_FILES['userfile']['tmp_name'][$key])) {
|
||||||
$error++;
|
$error++;
|
||||||
@ -2442,20 +2445,25 @@ if ($action == 'importsiteconfirm' && $usercanedit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$upload_dir = $conf->website->dir_temp;
|
//$upload_dir = $conf->website->dir_temp;
|
||||||
|
$upload_dir = DOL_DATA_ROOT.'/doctemplates/websites/';
|
||||||
$result = dol_add_file_process($upload_dir, 1, -1, 'userfile', '');
|
$result = dol_add_file_process($upload_dir, 1, -1, 'userfile', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get name of file (take last one if several name provided)
|
// Get name of file (take last one if several name provided)
|
||||||
|
/*
|
||||||
$fileofzip = $upload_dir.'/unknown';
|
$fileofzip = $upload_dir.'/unknown';
|
||||||
foreach ($_FILES as $key => $ifile) {
|
foreach ($_FILES as $key => $ifile) {
|
||||||
foreach ($ifile['name'] as $key2 => $ifile2) {
|
foreach ($ifile['name'] as $key2 => $ifile2) {
|
||||||
$fileofzip = $upload_dir.'/'.$ifile2;
|
$fileofzip = $upload_dir.'/'.$ifile2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
$action = 'importsite';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error && GETPOSTISSET('templateuserfile')) {
|
||||||
$result = $object->importWebSite($fileofzip);
|
$result = $object->importWebSite($fileofzip);
|
||||||
|
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user