diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index a635160a22d..3ef82f9f3b6 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1892,6 +1892,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); } @@ -1903,9 +1905,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 64e23642b60..fa4d9154dc8 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 f58b2200daf..b240c376f9e 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -289,7 +289,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'); @@ -365,6 +365,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++; @@ -378,6 +379,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)) { @@ -1600,6 +1602,10 @@ if ($action == 'exportsite') readfile($fileofzip); exit; } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } } // Import site @@ -2949,6 +2955,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"; @@ -2963,6 +2970,25 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $out.="\n
\n"; $out.="\n"; $out.=dolWebsiteReplacementOfLinks($object, $objectpage->htmlheader, 1); + + $out.="\n"; + // TODO Keep only the or the