Merge remote-tracking branch 'remotes/upstream/develop' into feature-rest-api-supplierinvoices-payments
This commit is contained in:
commit
6d55af2530
@ -458,16 +458,6 @@ variables_order = "GPCS"
|
||||
; with user data. This makes most sense when coupled with track_vars - in which
|
||||
; case you can access all of the GPC variables through the $HTTP_*_VARS[],
|
||||
; variables.
|
||||
;
|
||||
; You should do your best to write your scripts so that they do not require
|
||||
; register_globals to be on; Using form variables as globals can easily lead
|
||||
; to possible security problems, if the code is not very well thought of.
|
||||
register_globals = Off
|
||||
|
||||
; Whether or not to register the old-style input arrays, HTTP_GET_VARS
|
||||
; and friends. If you're not using them, it's recommended to turn them off,
|
||||
; for performance reasons.
|
||||
register_long_arrays = Off
|
||||
|
||||
; This directive tells PHP whether to declare the argv&argc variables (that
|
||||
; would contain the GET information). If you don't use these variables, you
|
||||
@ -477,8 +467,7 @@ register_argc_argv = Off
|
||||
; When enabled, the SERVER and ENV variables are created when they're first
|
||||
; used (Just In Time) instead of when the script starts. If these variables
|
||||
; are not used within a script, having this directive on will result in a
|
||||
; performance gain. The PHP directives register_globals, register_long_arrays,
|
||||
; and register_argc_argv must be disabled for this directive to have any affect.
|
||||
; performance gain.
|
||||
auto_globals_jit = On
|
||||
|
||||
; Maximum size of POST data that PHP will accept.
|
||||
@ -1101,14 +1090,6 @@ session.gc_maxlifetime = 1800
|
||||
; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
|
||||
; cd /path/to/sessions; find -cmin +24 | xargs rm
|
||||
|
||||
; PHP 4.2 and less have an undocumented feature/bug that allows you to
|
||||
; to initialize a session variable in the global scope, albeit register_globals
|
||||
; is disabled. PHP 4.3 and later will warn you, if this feature is used.
|
||||
; You can disable the feature and the warning separately. At this time,
|
||||
; the warning is only displayed, if bug_compat_42 is enabled.
|
||||
|
||||
session.bug_compat_42 = 0
|
||||
session.bug_compat_warn = 1
|
||||
|
||||
; Check HTTP Referer to invalidate externally stored URLs containing ids.
|
||||
; HTTP_REFERER has to contain this substring for the session to be
|
||||
|
||||
@ -29,16 +29,6 @@ Alias /dolibarr /usr/share/dolibarr/htdocs
|
||||
ErrorDocument 401 /public/error-401.php
|
||||
ErrorDocument 404 /public/error-404.php
|
||||
|
||||
<IfModule mod_php4.c>
|
||||
php_flag magic_quotes_gpc Off
|
||||
php_flag register_globals Off
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_php5.c>
|
||||
php_flag magic_quotes_gpc Off
|
||||
php_flag register_globals Off
|
||||
</IfModule>
|
||||
|
||||
|
||||
# OPTIMIZE: To use gzip compressed files (for Dolibarr already compressed files).
|
||||
# Note that constant MAIN_OPTIMIZE_SPEED must have a value with bit 0 set.
|
||||
|
||||
@ -658,20 +658,6 @@ html_errors = Off
|
||||
; Example:
|
||||
;arg_separator.input = ";&"
|
||||
|
||||
; This directive determines which super global arrays are registered when PHP
|
||||
; starts up. If the register_globals directive is enabled, it also determines
|
||||
; what order variables are populated into the global space. G,P,C,E & S are
|
||||
; abbreviations for the following respective super globals: GET, POST, COOKIE,
|
||||
; ENV and SERVER. There is a performance penalty paid for the registration of
|
||||
; these arrays and because ENV is not as commonly used as the others, ENV is
|
||||
; is not recommended on productions servers. You can still get access to
|
||||
; the environment variables through getenv() should you need to.
|
||||
; Default Value: "EGPCS"
|
||||
; Development Value: "GPCS"
|
||||
; Production Value: "GPCS";
|
||||
; http://php.net/variables-order
|
||||
variables_order = "GPCS"
|
||||
|
||||
; This directive determines which super global data (G,P,C,E & S) should
|
||||
; be registered into the super global array REQUEST. If so, it also determines
|
||||
; the order in which that data is registered. The values for this directive are
|
||||
@ -685,15 +671,6 @@ variables_order = "GPCS"
|
||||
; http://php.net/request-order
|
||||
request_order = "GP"
|
||||
|
||||
; Whether or not to register the EGPCS variables as global variables. You may
|
||||
; want to turn this off if you don't want to clutter your scripts' global scope
|
||||
; with user data.
|
||||
; You should do your best to write your scripts so that they do not require
|
||||
; register_globals to be on; Using form variables as globals can easily lead
|
||||
; to possible security problems, if the code is not very well thought of.
|
||||
; http://php.net/register-globals
|
||||
register_globals = Off
|
||||
|
||||
; Determines whether the deprecated long $HTTP_*_VARS type predefined variables
|
||||
; are registered by PHP or not. As they are deprecated, we obviously don't
|
||||
; recommend you use them. They are on by default for compatibility reasons but
|
||||
@ -722,8 +699,7 @@ register_argc_argv = Off
|
||||
; When enabled, the SERVER and ENV variables are created when they're first
|
||||
; used (Just In Time) instead of when the script starts. If these variables
|
||||
; are not used within a script, having this directive on will result in a
|
||||
; performance gain. The PHP directives register_globals, register_long_arrays,
|
||||
; and register_argc_argv must be disabled for this directive to have any affect.
|
||||
; performance gain.
|
||||
; http://php.net/auto-globals-jit
|
||||
auto_globals_jit = On
|
||||
|
||||
@ -1516,22 +1492,6 @@ session.gc_maxlifetime = 1440
|
||||
; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
|
||||
; find /path/to/sessions -cmin +24 | xargs rm
|
||||
|
||||
; PHP 4.2 and less have an undocumented feature/bug that allows you to
|
||||
; to initialize a session variable in the global scope, even when register_globals
|
||||
; is disabled. PHP 4.3 and later will warn you, if this feature is used.
|
||||
; You can disable the feature and the warning separately. At this time,
|
||||
; the warning is only displayed, if bug_compat_42 is enabled. This feature
|
||||
; introduces some serious security problems if not handled correctly. It's
|
||||
; recommended that you do not use this feature on production servers. But you
|
||||
; should enable this on development servers and enable the warning as well. If you
|
||||
; do not enable the feature on development servers, you won't be warned when it's
|
||||
; used and debugging errors caused by this can be difficult to track down.
|
||||
; Default Value: On
|
||||
; Development Value: On
|
||||
; Production Value: Off
|
||||
; http://php.net/session.bug-compat-42
|
||||
session.bug_compat_42 = Off
|
||||
|
||||
; This setting controls whether or not you are warned by PHP when initializing a
|
||||
; session value into the global space. session.bug_compat_42 must be enabled before
|
||||
; these warnings can be issued by PHP. See the directive above for more information.
|
||||
|
||||
3886
htdocs/core/class/lessc.class.php
Normal file
3886
htdocs/core/class/lessc.class.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -1889,24 +1889,87 @@ function dol_convert_file($fileinput, $ext = 'png', $fileoutput = '', $page = ''
|
||||
*/
|
||||
function dol_compress_file($inputfile, $outputfile, $mode = "gz")
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$foundhandler=0;
|
||||
|
||||
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); }
|
||||
elseif ($mode == 'zip')
|
||||
{
|
||||
if (class_exists('ZipArchive') && ! empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_COMPRESS))
|
||||
{
|
||||
$foundhandler=1;
|
||||
|
||||
$rootPath = realpath($inputfile);
|
||||
|
||||
dol_syslog("Class ZipArchive is set so we zip using ZipArchive to zip into ".$outputfile.' rootPath='.$rootPath);
|
||||
$zip = new ZipArchive;
|
||||
|
||||
if ($zip->open($outputfile, ZipArchive::CREATE)!==TRUE) {
|
||||
$errormsg="Failed to open file ".$outputfile."\n";
|
||||
dol_syslog("dol_compress_file failure - ".$errormsg, LOG_ERR);
|
||||
return -6;
|
||||
}
|
||||
|
||||
// Create recursive directory iterator
|
||||
/** @var SplFileInfo[] $files */
|
||||
$files = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($rootPath),
|
||||
RecursiveIteratorIterator::LEAVES_ONLY
|
||||
);
|
||||
|
||||
foreach ($files as $name => $file)
|
||||
{
|
||||
// Skip directories (they would be added automatically)
|
||||
if (!$file->isDir())
|
||||
{
|
||||
// Get real and relative path for current file
|
||||
$filePath = $file->getRealPath();
|
||||
$relativePath = substr($filePath, strlen($rootPath) + 1);
|
||||
|
||||
// Add current file to archive
|
||||
$zip->addFile($filePath, $relativePath);
|
||||
}
|
||||
}
|
||||
|
||||
// Zip archive will be created only after closing object
|
||||
$zip->close();
|
||||
|
||||
dol_syslog("dol_compress_file success - ".count($zip->numFiles)." files");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (defined('ODTPHP_PATHTOPCLZIP'))
|
||||
{
|
||||
$foundhandler=1;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1942,9 +2005,9 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz")
|
||||
*/
|
||||
function dol_uncompress($inputfile, $outputdir)
|
||||
{
|
||||
global $langs;
|
||||
global $conf, $langs;
|
||||
|
||||
if (defined('ODTPHP_PATHTOPCLZIP'))
|
||||
if (defined('ODTPHP_PATHTOPCLZIP') && empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_UNCOMPRESS))
|
||||
{
|
||||
dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir);
|
||||
include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
|
||||
/**
|
||||
* Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content.
|
||||
* Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content. It replaces also dynamic content with '...php...'
|
||||
* Used to ouput the page on the Preview from backoffice.
|
||||
*
|
||||
* @param Website $website Web site object
|
||||
@ -61,7 +61,7 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c
|
||||
$content = preg_replace('/href="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
|
||||
|
||||
//$replacewith='<span class="phptag">...php...</span>';
|
||||
$replacewith='<span class="phptag">...php...</span>';
|
||||
$replacewith='...phpx...';
|
||||
if ($removephppart) $replacewith='';
|
||||
//$content = preg_replace('/<\?php((?!\?toremove>).)*\?toremove>\n*/ims', $replacewith, $content);
|
||||
/*if ($content === null) {
|
||||
@ -93,6 +93,9 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c
|
||||
$content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
|
||||
$content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
|
||||
|
||||
// Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: ...href="/viewimage.php?modulepart="
|
||||
$content=preg_replace('/(url\(")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
|
||||
|
||||
dol_syslog('dolWebsiteReplacementOfLinks end', LOG_DEBUG);
|
||||
|
||||
return $content;
|
||||
@ -124,14 +127,15 @@ function dolStripPhpCode($str, $replacewith = '')
|
||||
$newstr .= $part;
|
||||
continue;
|
||||
}
|
||||
//split on closing tag
|
||||
// The second part is the php code. We split on closing tag
|
||||
$partlings = explode('?>', $part);
|
||||
if (!empty($partlings))
|
||||
{
|
||||
$phppart = $partlings[0];
|
||||
//remove content before closing tag
|
||||
if (count($partlings) > 1) $partlings[0] = '';
|
||||
if (count($partlings) > 1) $partlings[0] = ''; // Todo why a count > 1 and not >= 1 ?
|
||||
//append to out string
|
||||
$newstr .= $replacewith.implode('', $partlings);
|
||||
$newstr .= '<span class="phptag">'.$replacewith.'<!-- '.$phppart.' --></span>'.implode('', $partlings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -185,7 +189,7 @@ function dolKeepOnlyPhpCode($str)
|
||||
* @param string $contenttype Content type
|
||||
* @param int $containerid Contenair id
|
||||
* @return void
|
||||
* @see dolWebsiteReplacementOfLinks() for function used to replace content in the backoffice context when USEDOLIBARREDITOR is not on
|
||||
* @see dolWebsiteReplacementOfLinks() for function used to replace content in the backoffice context.
|
||||
*/
|
||||
function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '')
|
||||
{
|
||||
@ -228,6 +232,7 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '')
|
||||
// Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: href="/viewimage.php?modulepart=" => href="/dolibarr/viewimage.php?modulepart="
|
||||
$content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
|
||||
$content=preg_replace('/(src=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
|
||||
$content=preg_replace('/(url\(")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
|
||||
|
||||
// Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/
|
||||
$content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
|
||||
|
||||
@ -214,13 +214,7 @@ function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -241,13 +235,7 @@ function dolSaveCssFile($filecss, $csscontent)
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filecss, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages('Failed to write file '.$filecss, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -268,13 +256,7 @@ function dolSaveJsFile($filejs, $jscontent)
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filejs, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages('Failed to write file '.$filejs, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -295,13 +277,7 @@ function dolSaveRobotFile($filerobot, $robotcontent)
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages('Failed to write file '.$filerobot, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -322,13 +298,7 @@ function dolSaveHtaccessFile($filehtaccess, $htaccess)
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -349,13 +319,7 @@ function dolSaveManifestJson($file, $content)
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages('Failed to write file '.$file, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ class Interventions extends DolibarrApi
|
||||
|
||||
$result = $this->fichinter->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Intervention report not found');
|
||||
throw new RestException(404, 'Intervention not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('fichinter', $this->fichinter->id)) {
|
||||
@ -174,10 +174,10 @@ class Interventions extends DolibarrApi
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new RestException(503, 'Error when retrieve fichinter list : '.$db->lasterror());
|
||||
throw new RestException(503, 'Error when retrieve intervention list : '.$db->lasterror());
|
||||
}
|
||||
if( ! count($obj_ret)) {
|
||||
throw new RestException(404, 'No finchinter found');
|
||||
throw new RestException(404, 'No intervention found');
|
||||
}
|
||||
return $obj_ret;
|
||||
}
|
||||
@ -200,7 +200,7 @@ class Interventions extends DolibarrApi
|
||||
}
|
||||
|
||||
if ($this->fichinter->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, "Error creating fichinter", array_merge(array($this->fichinter->error), $this->fichinter->errors));
|
||||
throw new RestException(500, "Error creating intervention", array_merge(array($this->fichinter->error), $this->fichinter->errors));
|
||||
}
|
||||
|
||||
return $this->fichinter->id;
|
||||
@ -301,7 +301,7 @@ class Interventions extends DolibarrApi
|
||||
throw new RestException(404, 'Intervention not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('commande', $this->fichinter->id)) {
|
||||
if( ! DolibarrApi::_checkAccessToResource('fichinter', $this->fichinter->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@ -624,7 +624,7 @@ if (! defined('NOLOGIN'))
|
||||
session_destroy();
|
||||
session_name($sessionname);
|
||||
session_set_cookie_params(0, '/', null, false, true); // Add tag httponly on session cookie
|
||||
session_start(); // Fixing the bug of register_globals here is useless since session is empty
|
||||
session_start();
|
||||
|
||||
if ($resultFetchUser == 0)
|
||||
{
|
||||
@ -681,7 +681,7 @@ if (! defined('NOLOGIN'))
|
||||
session_destroy();
|
||||
session_name($sessionname);
|
||||
session_set_cookie_params(0, '/', null, false, true); // Add tag httponly on session cookie
|
||||
session_start(); // Fixing the bug of register_globals here is useless since session is empty
|
||||
session_start();
|
||||
|
||||
if ($resultFetchUser == 0)
|
||||
{
|
||||
@ -1441,6 +1441,9 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr
|
||||
print 'var ckeditorFilebrowserImageBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Type=Image&Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n";
|
||||
print '</script>'."\n";
|
||||
print '<script src="'.$pathckeditor.$jsckeditor.($ext?'?'.$ext:'').'"></script>'."\n";
|
||||
print '<script>';
|
||||
print 'CKEDITOR.disableAutoInline = true;'."\n";
|
||||
print '</script>'."\n";
|
||||
}
|
||||
|
||||
// Browser notifications
|
||||
|
||||
@ -245,3 +245,4 @@ $hookmanager=new HookManager($db);
|
||||
|
||||
|
||||
if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR', 'NPR');
|
||||
//if (! defined('PCLZIP_TEMPORARY_DIR')) define('PCLZIP_TEMPORARY_DIR', $conf->user->dir_temp);
|
||||
|
||||
@ -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 '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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))
|
||||
{
|
||||
@ -770,7 +772,10 @@ if ($action == 'addcontainer')
|
||||
|
||||
// Save page alias
|
||||
$result=dolSavePageAlias($filealias, $object, $objectpage);
|
||||
if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors');
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages('Failed to write file '.$filealias, null, 'errors');
|
||||
}
|
||||
|
||||
// Save page of content
|
||||
$result=dolSavePageContent($filetpl, $object, $objectpage);
|
||||
@ -988,7 +993,11 @@ if ($action == 'updatecss')
|
||||
|
||||
// Now generate the master.inc.php page
|
||||
$result = dolSaveMasterFile($filemaster);
|
||||
if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filemaster, null, 'errors');
|
||||
}
|
||||
|
||||
|
||||
// Html header file
|
||||
@ -1012,7 +1021,12 @@ if ($action == 'updatecss')
|
||||
|
||||
$htmlheadercontent = trim($htmlheadercontent)."\n";
|
||||
|
||||
dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent);
|
||||
$result = dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
|
||||
}
|
||||
|
||||
|
||||
// Css file
|
||||
@ -1024,23 +1038,21 @@ if ($action == 'updatecss')
|
||||
$csscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
|
||||
$csscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
|
||||
$csscontent.= "ob_start();\n";
|
||||
$csscontent.= "if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n";
|
||||
$csscontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n";
|
||||
$csscontent.= "header('Content-type: text/css');\n";
|
||||
$csscontent.= "}\n";
|
||||
$csscontent.= "// END PHP ?>\n";
|
||||
|
||||
$csscontent.= GETPOST('WEBSITE_CSS_INLINE', 'none');
|
||||
$csscontent.= trim(GETPOST('WEBSITE_CSS_INLINE', 'none'))."\n";
|
||||
|
||||
$csscontent.= "\n".'<?php // BEGIN PHP'."\n";
|
||||
$csscontent.= '<?php // BEGIN PHP'."\n";
|
||||
$csscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'."\n";
|
||||
$csscontent.= "// END PHP ?>"."\n";
|
||||
|
||||
dol_syslog("Save css content into ".$filecss);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filecss, $csscontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filecss, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$result = dolSaveCssFile($filecss, $csscontent);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
@ -1061,19 +1073,13 @@ if ($action == 'updatecss')
|
||||
$jscontent.= "header('Content-type: application/javascript');\n";
|
||||
$jscontent.= "// END PHP ?>\n";
|
||||
|
||||
$jscontent.= GETPOST('WEBSITE_JS_INLINE', 'none');
|
||||
$jscontent.= trim(GETPOST('WEBSITE_JS_INLINE', 'none'))."\n";
|
||||
|
||||
$jscontent.= "\n".'<?php // BEGIN PHP'."\n";
|
||||
$jscontent.= '<?php // BEGIN PHP'."\n";
|
||||
$jscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'."\n";
|
||||
$jscontent.= "// END PHP ?>"."\n";
|
||||
|
||||
dol_syslog("Save js content into ".$filejs);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filejs, $jscontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filejs, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$result = dolSaveJsFile($filejs, $jscontent);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
@ -1094,19 +1100,13 @@ if ($action == 'updatecss')
|
||||
$robotcontent.= "header('Content-type: text/css');\n";
|
||||
$robotcontent.= "// END PHP ?>\n";*/
|
||||
|
||||
$robotcontent.= GETPOST('WEBSITE_ROBOT', 'none');
|
||||
$robotcontent.= trim(GETPOST('WEBSITE_ROBOT', 'none'))."\n";
|
||||
|
||||
/*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n";
|
||||
$robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "robot");'."\n";
|
||||
$robotcontent.= "// END PHP ?>"."\n";*/
|
||||
|
||||
dol_syslog("Save file robot into ".$filerobot);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filerobot, $robotcontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$result = dolSaveRobotFile($filerobot, $robotcontent);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
@ -1116,20 +1116,15 @@ if ($action == 'updatecss')
|
||||
|
||||
// Htaccess file
|
||||
$htaccesscontent ='';
|
||||
$htaccesscontent.= GETPOST('WEBSITE_HTACCESS', 'none');
|
||||
$htaccesscontent.= trim(GETPOST('WEBSITE_HTACCESS', 'none'))."\n";
|
||||
|
||||
dol_syslog("Save file htaccess into ".$filehtaccess);
|
||||
$result = dolSaveHtaccessFile($filehtaccess, $htaccesscontent);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
|
||||
}
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filehtaccess, $htaccesscontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
|
||||
}
|
||||
|
||||
// manifest.json file
|
||||
$manifestjsoncontent ='';
|
||||
@ -1144,24 +1139,18 @@ if ($action == 'updatecss')
|
||||
$manifestjsoncontent.= "header('Content-type: application/manifest+json');\n";
|
||||
$manifestjsoncontent.= "// END PHP ?>\n";
|
||||
|
||||
$manifestjsoncontent.= GETPOST('WEBSITE_MANIFEST_JSON', 'none');
|
||||
$manifestjsoncontent.= trim(GETPOST('WEBSITE_MANIFEST_JSON', 'none'))."\n";
|
||||
|
||||
$manifestjsoncontent.= "\n".'<?php // BEGIN PHP'."\n";
|
||||
$manifestjsoncontent.= '<?php // BEGIN PHP'."\n";
|
||||
$manifestjsoncontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n";
|
||||
$manifestjsoncontent.= "// END PHP ?>"."\n";
|
||||
|
||||
dol_syslog("Save file manifest.json.php into ".$manifestjsoncontent);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filemanifestjson, $manifestjsoncontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filemanifestjson, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if ($result === false)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filemanifestjson, null, 'errors');
|
||||
}
|
||||
$result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filemanifestjson, null, 'errors');
|
||||
}
|
||||
|
||||
|
||||
// Message if no error
|
||||
@ -1674,6 +1663,11 @@ if ($action == 'exportsite')
|
||||
readfile($fileofzip);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Import site
|
||||
@ -2205,7 +2199,53 @@ if (! GETPOST('hide_websitemenu'))
|
||||
print '<!-- button EditInLine and ShowSubcontainers -->'."\n";
|
||||
print '<div class="websiteselectionsection inline-block">';
|
||||
print '<div class="inline-block">';
|
||||
|
||||
print '<span id="switchckeditorinline">';
|
||||
print '<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var isEditingEnabled = '.($conf->global->WEBSITE_EDITINLINE?'true':'false').';
|
||||
if (isEditingEnabled)
|
||||
{
|
||||
switchEditorOnline(true);
|
||||
}
|
||||
|
||||
$( "#switchckeditorinline" ).click(function() {
|
||||
switchEditorOnline();
|
||||
});
|
||||
|
||||
function switchEditorOnline(forceenable)
|
||||
{
|
||||
if (! isEditingEnabled || forceenable)
|
||||
{
|
||||
console.log("Enable inline edit");
|
||||
jQuery(\'section[contenteditable="true"]\').each(function(idx){
|
||||
var idtouse = $(this).attr(\'id\');
|
||||
console.log("Enable inline edit for "+idtouse);
|
||||
CKEDITOR.inline(idtouse, {
|
||||
// Allow some non-standard markup that we used in the introduction.
|
||||
extraAllowedContent: \'span(*);cite(*);q(*);dl(*);dt(*);dd(*);ul(*);li(*);header(*);button(*);h1(*);h2(*);\',
|
||||
removePlugins: \'stylescombo\',
|
||||
// Show toolbar on startup (optional).
|
||||
// startupFocus: true
|
||||
});
|
||||
})
|
||||
|
||||
isEditingEnabled = true;
|
||||
}
|
||||
else {
|
||||
console.log("Disable inline edit");
|
||||
for(name in CKEDITOR.instances)
|
||||
{
|
||||
CKEDITOR.instances[name].destroy(true);
|
||||
}
|
||||
isEditingEnabled = false;
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>';
|
||||
print $langs->trans("EditInLine");
|
||||
print '</span>';
|
||||
|
||||
if ($websitepage->grabbed_from)
|
||||
{
|
||||
//print '<input type="submit" class="button nobordertransp" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("OnlyEditionOfSourceForGrabbedContent")).'" value="'.dol_escape_htmltag($langs->trans("EditWithEditor")).'" name="editcontent">';
|
||||
@ -2223,6 +2263,7 @@ if (! GETPOST('hide_websitemenu'))
|
||||
print '<a class="button nobordertransp nohoverborder"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=unseteditinline">'.img_picto($langs->trans("EditInLineOn"), 'switch_on', '', false, 0, 0, '', 'nomarginleft').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
print '<div class="inline-block">';
|
||||
print $langs->trans("ShowSubcontainers");
|
||||
@ -2924,7 +2965,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
|
||||
if ($action != 'createcontainer')
|
||||
{
|
||||
print '<tr><td>';
|
||||
print $langs->trans('LastModificationAuthor');
|
||||
print $langs->trans('UserModif');
|
||||
print '</td><td>';
|
||||
if ($pageusermodifid > 0)
|
||||
{
|
||||
@ -3057,9 +3098,10 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm')
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="replacesiteconfirm">';
|
||||
print '<input type="hidden" name="website" value="'.$website->ref.'">';
|
||||
|
||||
|
||||
print '<!-- Edit Media -->'."\n";
|
||||
print '<!-- Replace string -->'."\n";
|
||||
print '<div class="fiche"><br>';
|
||||
|
||||
print load_fiche_titre($langs->trans("ReplaceWebsiteContent"));
|
||||
@ -3141,6 +3183,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa
|
||||
|
||||
// Ouput page under the Dolibarr top menu
|
||||
$objectpage->fetch($pageid);
|
||||
|
||||
$jscontent = @file_get_contents($filejs);
|
||||
|
||||
$out = '<!-- Page content '.$filetpl.' : Div with (Htmlheader/Style of page from database + CSS Of website from file + Page content from database or by include if WEBSITE_SUBCONTAINERSINLINE is on) -->'."\n";
|
||||
@ -3155,6 +3198,25 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa
|
||||
$out.="\n<html><head>\n";
|
||||
$out.="<!-- htmlheader/style of page from database -->\n";
|
||||
$out.=dolWebsiteReplacementOfLinks($object, $objectpage->htmlheader, 1, 'htmlheader');
|
||||
|
||||
$out.="<!-- htmlheader/style of website from files -->\n";
|
||||
// TODO Keep only the <link> or the <script> tags
|
||||
/*
|
||||
$htmlheadercontent = @file_get_contents($filehtmlheader);
|
||||
$dom = new DOMDocument;
|
||||
@$dom->loadHTML($htmlheadercontent);
|
||||
$styles = $dom->getElementsByTagName('link');
|
||||
$scripts = $dom->getElementsByTagName('script');
|
||||
foreach($styles as $stylescursor)
|
||||
{
|
||||
$out.=$stylescursor;
|
||||
}
|
||||
foreach($scripts as $scriptscursor)
|
||||
{
|
||||
$out.=$scriptscursor;
|
||||
}
|
||||
*/
|
||||
|
||||
$out.="</head>\n";
|
||||
$out.="\n<body>";
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user