diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 92b739b3190..ac7e97afab2 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1893,6 +1893,8 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz") try { + dol_syslog("dol_compress_file mode=".$mode." inputfile=".$inputfile." outputfile=".$outputfile); + $data = implode("", file(dol_osencode($inputfile))); if ($mode == 'gz') { $foundhandler=1; $compressdata = gzencode($data, 9); } elseif ($mode == 'bz') { $foundhandler=1; $compressdata = bzcompress($data, 9); } @@ -1904,9 +1906,25 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz") include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php'; $archive = new PclZip($outputfile); - $archive->add($inputfile, PCLZIP_OPT_REMOVE_PATH, dirname($inputfile)); - //$archive->add($inputfile); - return 1; + $result = $archive->add($inputfile, PCLZIP_OPT_REMOVE_PATH, dirname($inputfile)); + + if ($result === 0) + { + global $errormsg; + $errormsg=$archive->errorInfo(true); + dol_syslog("dol_compress_file failure - ".$errormsg, LOG_ERR); + if ($archive->errorCode() == PCLZIP_ERR_WRITE_OPEN_FAIL) + { + dol_syslog("dol_compress_file error PCLZIP_ERR_WRITE_OPEN_FAIL", LOG_ERR); + return -4; + } + return -3; + } + else + { + dol_syslog("dol_compress_file success - ".count($result)." files"); + return 1; + } } } diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index fffa25cf728..4218552c9aa 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -790,7 +790,7 @@ class Website extends CommonObject /** * Generate a zip with all data of web site. * - * @return string Path to file with zip + * @return string Path to file with zip or '' if error */ public function exportWebSite() { @@ -957,9 +957,18 @@ class Website extends CommonObject $filename = $conf->website->dir_temp.'/'.$website->ref.'/website_'.$website->ref.'-'.dol_print_date(dol_now(), 'dayhourlog').'.zip'; dol_delete_file($fileglob, 0); - dol_compress_file($filedir, $filename, 'zip'); + $result = dol_compress_file($filedir, $filename, 'zip'); - return $filename; + if ($result > 0) + { + return $filename; + } + else + { + global $errormsg; + $this->error = $errormsg; + return ''; + } } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 8ac8de1a5ca..75df4f2552c 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -338,7 +338,7 @@ if ($action == 'addsite') { $db->begin(); - if (GETPOST('virtualhost', 'alpha') && ! preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) + if (GETPOST('virtualhost', 'alpha') && ! preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) { $error++; setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors'); @@ -414,6 +414,7 @@ if ($action == 'addcontainer') { include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + //if (! preg_match('/^http/', $urltograb) && ! preg_match('/^file/', $urltograb)) if (! preg_match('/^http/', $urltograb)) { $error++; @@ -427,6 +428,7 @@ if ($action == 'addcontainer') // Clean url to grab, so url can be // http://www.example.com/ or http://www.example.com/dir1/ or http://www.example.com/dir1/aaa $urltograbwithoutdomainandparam = preg_replace('/^https?:\/\/[^\/]+\/?/i', '', $urltograb); + //$urltograbwithoutdomainandparam = preg_replace('/^file:\/\/[^\/]+\/?/i', '', $urltograb); $urltograbwithoutdomainandparam = preg_replace('/\?.*$/', '', $urltograbwithoutdomainandparam); if (empty($urltograbwithoutdomainandparam) && ! preg_match('/\/$/', $urltograb)) { @@ -1674,6 +1676,10 @@ if ($action == 'exportsite') readfile($fileofzip); exit; } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } } // Import site @@ -3142,6 +3148,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa // Ouput page under the Dolibarr top menu $objectpage->fetch($pageid); + $jscontent = @file_get_contents($filejs); $out = ''."\n"; @@ -3156,6 +3163,25 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $out.="\n\n"; $out.="\n"; $out.=dolWebsiteReplacementOfLinks($object, $objectpage->htmlheader, 1, 'htmlheader'); + + $out.="\n"; + // TODO Keep only the or the