Merge branch 'develop' of github.com:Dolibarr/dolibarr into develop_atm

This commit is contained in:
Marc de Lima Lucio 2018-02-19 17:33:20 +01:00
commit 44b0d1ca0f
25 changed files with 601 additions and 477 deletions

View File

@ -34,17 +34,4 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+$conffiletoshow = "/etc/dolibarr/conf.php"; +$conffiletoshow = "/etc/dolibarr/conf.php";
// Load conf file if it is already defined
--- a/htdocs/support/inc.php
+++ b/htdocs/support/inc.php
@@ -69,8 +69,8 @@ $conffiletoshowshort = "conf.php";
$conffile = "../conf/conf.php";
$conffiletoshow = "htdocs/conf/conf.php";
// For debian/redhat like systems
-//$conffile = "/etc/dolibarr/conf.php";
-//$conffiletoshow = "/etc/dolibarr/conf.php";
+$conffile = "/etc/dolibarr/conf.php";
+$conffiletoshow = "/etc/dolibarr/conf.php";
// Load conf file if it is already defined // Load conf file if it is already defined

View File

@ -10,12 +10,23 @@ export DH_OPTIONS=-v
%: %:
dh $@ dh $@
# Replace standard debian package actions with a new one
########################################################
override_dh_auto_clean: override_dh_auto_clean:
# Do nothing. Added to disable launchpad to use bugged dh_auto_clean search for ant # Do nothing. Added to disable launchpad to use bugged dh_auto_clean search for ant
override_dh_auto_build: override_dh_auto_build:
# Do nothing. Added to disable launchpad to use bugged dh_auto_build search for ant # Do nothing. Added to disable launchpad to use bugged dh_auto_build search for ant
#override_dh_compress:
# dh_compress --no-act -X.png
# We disable this for png file because it modify content of original file so make
# the dolibarr signature not valid.
override_dh_strip_nondeterminism:
dh_strip_nondeterminism -X.png
override_dh_install: override_dh_install:
dh_install dh_install
# Delete files # Delete files

View File

@ -558,7 +558,7 @@ if ($nboftargetok) {
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/geoip/sample*.*`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/geoip/sample*.*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/ckeditor/adapters`; # Keep this removal in case we embed libraries $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/ckeditor/adapters`; # Keep this removal in case we embed libraries
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/ckeditor/samples`; # Keep this removal in case we embed libraries $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/ckeditor/samples`; # Keep this removal in case we embed libraries
#$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/_source`; # _source must be kept into tarball $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/_source`; # _source must be kept into tarball for official debian, not for the rest
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/select2/release.sh`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/select2/release.sh`;
@ -767,8 +767,8 @@ if ($nboftargetok) {
$cmd="cp -pr '$BUILDROOT/$PROJECT' '$BUILDROOT/$FILENAMETGZ2'"; $cmd="cp -pr '$BUILDROOT/$PROJECT' '$BUILDROOT/$FILENAMETGZ2'";
$ret=`$cmd`; $ret=`$cmd`;
# Removed files we don't need # Removed files we don't need (already removed before)
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/htdocs/includes/ckeditor/_source`; #$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/htdocs/includes/ckeditor/_source`;
print "Set permissions on files/dir\n"; print "Set permissions on files/dir\n";
$ret=`chmod -R 755 $BUILDROOT/$FILENAMETGZ2`; $ret=`chmod -R 755 $BUILDROOT/$FILENAMETGZ2`;
@ -915,8 +915,8 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/mike42/escpos-php/LICENSE.md`; $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/mike42/escpos-php/LICENSE.md`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/mobiledetect/mobiledetectlib/LICENSE.txt`; $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/mobiledetect/mobiledetectlib/LICENSE.txt`;
# Removed files we don't need # Removed files we don't need (already removed)
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/_source`; #$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/_source`;
# Rename upstream changelog to match debian rules # Rename upstream changelog to match debian rules
$ret=`mv $BUILDROOT/$PROJECT.tmp/ChangeLog $BUILDROOT/$PROJECT.tmp/changelog`; $ret=`mv $BUILDROOT/$PROJECT.tmp/ChangeLog $BUILDROOT/$PROJECT.tmp/changelog`;
@ -978,7 +978,7 @@ if ($nboftargetok) {
$ret=`chmod 755 $BUILDROOT/$PROJECT.tmp/debian/rules`; $ret=`chmod 755 $BUILDROOT/$PROJECT.tmp/debian/rules`;
$ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/translation/autotranslator.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/translation/autotranslator.class.php`;
$ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/actions_mymodule.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/actions_mymodule.class.php`;
$ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/api_myobject.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/api_mymodule.class.php`;
$ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/myobject.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/myobject.class.php`;
$ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/core/modules/modMyModule.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/core/modules/modMyModule.class.php`;
$ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/mymoduleindex.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/mymoduleindex.php`;

View File

@ -15,21 +15,7 @@ diff -up htdocs/filefunc.inc.php.patch htdocs/filefunc.inc.php
diff -up htdocs/install/inc.php.patch htdocs/install/inc.php diff -up htdocs/install/inc.php.patch htdocs/install/inc.php
--- htdocs/install/inc.php.patch 2011-09-03 02:33:26.450952000 +0200 --- htdocs/install/inc.php.patch 2011-09-03 02:33:26.450952000 +0200
+++ htdocs/install/inc.php 2011-09-03 02:33:36.286952001 +0200 +++ htdocs/install/inc.php 2011-09-03 02:33:36.286952001 +0200
@@ -71,8 +71,8 @@ @@ -74,8 +74,8 @@
$conffile = "../conf/conf.php";
$conffiletoshow = "htdocs/conf/conf.php";
// For debian/redhat like systems
-//$conffile = "/etc/dolibarr/conf.php";
-//$conffiletoshow = "/etc/dolibarr/conf.php";
+$conffile = "/etc/dolibarr/conf.php";
+$conffiletoshow = "/etc/dolibarr/conf.php";
// Load conf file if it is already defined
diff -up htdocs/support/inc.php.patch htdocs/support/inc.php
--- htdocs/support/inc.php.patch 2011-09-03 02:34:39.606952000 +0200
+++ htdocs/support/inc.php 2011-09-03 02:33:59.814952000 +0200
@@ -69,8 +69,8 @@
$conffile = "../conf/conf.php"; $conffile = "../conf/conf.php";
$conffiletoshow = "htdocs/conf/conf.php"; $conffiletoshow = "htdocs/conf/conf.php";
// For debian/redhat like systems // For debian/redhat like systems

View File

@ -25,7 +25,7 @@ BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
Group: Applications/Productivity Group: Applications/Productivity
Requires: httpd, php >= 5.3.0, php-cli, php-gd, php-ldap, php-imap, php-mysql, php-adodb, php-nusoap, dejavu-sans-fonts Requires: httpd, php >= 5.3.0, php-cli, php-gd, php-ldap, php-imap, php-mysqli, php-adodb, php-nusoap, dejavu-sans-fonts
Requires: mysql-server, mysql Requires: mysql-server, mysql
#BuildRequires: desktop-file-utils #BuildRequires: desktop-file-utils

View File

@ -46,7 +46,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version}
Group: Applications/Productivity Group: Applications/Productivity
Requires: httpd, php >= 5.3.0, php-cli, php-gd, php-ldap, php-imap, php-mysql, php-adodb, php-nusoap, dejavu-sans-fonts Requires: httpd, php >= 5.3.0, php-cli, php-gd, php-ldap, php-imap, php-mysqli, php-adodb, php-nusoap, dejavu-sans-fonts, php-mbstring, php-xml
Requires: mysql-server, mysql Requires: mysql-server, mysql
BuildRequires: desktop-file-utils BuildRequires: desktop-file-utils
%else %else
@ -63,9 +63,9 @@ Requires: mysql-community-server, mysql-community-server-client
BuildRequires: update-desktop-files fdupes BuildRequires: update-desktop-files fdupes
%else %else
Group: Applications/Productivity Group: Applications/Productivity
Requires: httpd, php >= 5.3.0, php-cli, php-gd, php-ldap, php-imap Requires: httpd, php >= 5.3.0, php-cli, php-gd, php-ldap, php-imap, php-mbstring, php-xml
Requires: mysql-server, mysql Requires: mysql-server, mysql
Requires: php-mysql >= 4.1.0 Requires: php-mysqli >= 4.1.0
%endif %endif
%endif %endif
%endif %endif
@ -441,8 +441,8 @@ if [ "x$os" = "xfedora-redhat" -a -s /sbin/restorecon ]; then
%else %else
echo Add SE Linux permissions for dolibarr echo Add SE Linux permissions for dolibarr
# semanage add records into /etc/selinux/targeted/contexts/files/file_contexts.local # semanage add records into /etc/selinux/targeted/contexts/files/file_contexts.local
semanage fcontext -a -t httpd_sys_script_rw_t "/etc/dolibarr(/.*?)" semanage fcontext -a -t httpd_sys_rw_content_t "/etc/dolibarr(/.*)?"
semanage fcontext -a -t httpd_sys_script_rw_t "/var/lib/dolibarr(/.*?)" semanage fcontext -a -t httpd_sys_rw_content_t "/var/lib/dolibarr(/.*)?"
restorecon -R -v /etc/dolibarr restorecon -R -v /etc/dolibarr
restorecon -R -v /var/lib/dolibarr restorecon -R -v /var/lib/dolibarr
%endif %endif

View File

@ -15,8 +15,14 @@ Alias /dolibarr /usr/share/dolibarr/htdocs
# Directory for web pages # Directory for web pages
<DirectoryMatch /usr/share/dolibarr> <DirectoryMatch /usr/share/dolibarr>
Order deny,allow <IfVersion >= 2.3>
Allow from all Require all granted
</IfVersion>
<IfVersion < 2.3>
Order deny,allow
Allow from all
</IfVersion>
DirectoryIndex index.php DirectoryIndex index.php
Options +FollowSymLinks +Indexes Options +FollowSymLinks +Indexes
@ -60,27 +66,51 @@ Alias /dolibarr /usr/share/dolibarr/htdocs
# Directory for public pages # Directory for public pages
<DirectoryMatch /usr/share/dolibarr/public> <DirectoryMatch /usr/share/dolibarr/public>
AllowOverride All <IfVersion >= 2.3>
Require all granted
</IfVersion>
<IfVersion < 2.3>
Order deny,allow Order deny,allow
Allow from all Allow from all
</IfVersion>
AllowOverride All
</DirectoryMatch> </DirectoryMatch>
# Config files # Config files
<DirectoryMatch /etc/dolibarr> <DirectoryMatch /etc/dolibarr>
AllowOverride All <IfVersion >= 2.3>
Require all granted
</IfVersion>
<IfVersion < 2.3>
Order deny,allow Order deny,allow
Allow from all Allow from all
</IfVersion>
AllowOverride All
</DirectoryMatch> </DirectoryMatch>
# Directory for data files # Directory for data files
<DirectoryMatch /usr/share/dolibarr/documents> <DirectoryMatch /usr/share/dolibarr/documents>
AllowOverride All <IfVersion >= 2.3>
Require all granted
</IfVersion>
<IfVersion < 2.3>
Order deny,allow Order deny,allow
Allow from all Allow from all
</IfVersion>
AllowOverride All
</DirectoryMatch> </DirectoryMatch>
<DirectoryMatch /var/lib/dolibarr/documents> <DirectoryMatch /var/lib/dolibarr/documents>
AllowOverride All <IfVersion >= 2.3>
Order deny,allow Require all granted
</IfVersion>
<IfVersion < 2.3>
Order allow,deny
Allow from all Allow from all
</IfVersion>
AllowOverride All
</DirectoryMatch> </DirectoryMatch>

View File

@ -698,10 +698,19 @@ else
print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
} }
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && ! in_array($action, array('testconnect', 'test', 'testhtml'))) if (! in_array($action, array('testconnect', 'test', 'testhtml')))
{ {
$text = $langs->trans("WarningPHPMail"); $text = '';
print info_admin($text); if ($conf->global->MAIN_MAIL_SENDMODE == 'mail')
{
$text.= $langs->trans("WarningPHPMail");
}
//$conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS='1.2.3.4';
if (! empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS))
{
$text.= ($text?'<br>':'').$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
}
if ($text) print info_admin($text);
} }
// Run the test to connect // Run the test to connect

View File

@ -49,7 +49,7 @@ $version='0.0';
if ($action == 'getlastversion') if ($action == 'getlastversion')
{ {
$result = getURLContent('http://sourceforge.net/projects/dolibarr/rss'); $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss');
//var_dump($result['content']); //var_dump($result['content']);
$sfurl = simplexml_load_string($result['content']); $sfurl = simplexml_load_string($result['content']);
} }

View File

@ -3235,7 +3235,6 @@ class Facture extends CommonInvoice
$sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'; $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code';
$sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; $sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t';
$sql.= ' WHERE pf.'.$field.' = '.$this->id; $sql.= ' WHERE pf.'.$field.' = '.$this->id;
//$sql.= ' WHERE pf.'.$field.' = 1';
$sql.= ' AND pf.'.$field2.' = p.rowid'; $sql.= ' AND pf.'.$field2.' = p.rowid';
$sql.= ' AND p.fk_paiement = t.id'; $sql.= ' AND p.fk_paiement = t.id';
$sql.= ' AND p.entity IN (' . getEntity($sharedentity).')'; $sql.= ' AND p.entity IN (' . getEntity($sharedentity).')';

View File

@ -283,7 +283,7 @@ class Contrat extends CommonObject
if ($result < 0) if ($result < 0)
{ {
$error++; $error++;
$this->errors = $contratline->error; $this->error = $contratline->error;
$this->errors = $contratline->errors; $this->errors = $contratline->errors;
break; break;
} }
@ -338,7 +338,7 @@ class Contrat extends CommonObject
if ($result < 0) if ($result < 0)
{ {
$error++; $error++;
$this->errors = $contratline->error; $this->error = $contratline->error;
$this->errors = $contratline->errors; $this->errors = $contratline->errors;
break; break;
} }

View File

@ -716,13 +716,13 @@ class FormFile
if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper
// Show file name with link to download // Show file name with link to download
$out.= '<td class="tdoverflowmax300">'; $out.= '<td class="minwidth200">';
$out.= '<a class="documentdownload paddingright" href="'.$documenturl.'?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).($param?'&'.$param:'').'"'; $out.= '<a class="documentdownload paddingright" href="'.$documenturl.'?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).($param?'&'.$param:'').'"';
$mime=dol_mimetype($relativepath,'',0); $mime=dol_mimetype($relativepath,'',0);
if (preg_match('/text/',$mime)) $out.= ' target="_blank"'; if (preg_match('/text/',$mime)) $out.= ' target="_blank"';
$out.= ' target="_blank">'; $out.= ' target="_blank">';
$out.= img_mime($file["name"],$langs->trans("File").': '.$file["name"]); $out.= img_mime($file["name"],$langs->trans("File").': '.$file["name"]);
$out.= $file["name"]; $out.= dol_trunc($file["name"], 150);
$out.= '</a>'."\n"; $out.= '</a>'."\n";
$out.= $this->showPreview($file,$modulepart,$relativepath,0,$param); $out.= $this->showPreview($file,$modulepart,$relativepath,0,$param);
$out.= '</td>'; $out.= '</td>';
@ -1089,7 +1089,7 @@ class FormFile
print '<tr id="row-'.($filearray[$key]['rowid']>0?$filearray[$key]['rowid']:'-AFTER'.$lastrowid.'POS'.($i+1)).'">'; print '<tr id="row-'.($filearray[$key]['rowid']>0?$filearray[$key]['rowid']:'-AFTER'.$lastrowid.'POS'.($i+1)).'">';
// File name // File name
print '<td class="tdoverflowmax300">'; print '<td class="minwith200">';
// Show file name with link to download // Show file name with link to download
//print "XX".$file['name']; //$file['name'] must be utf8 //print "XX".$file['name']; //$file['name'] must be utf8
@ -1112,7 +1112,7 @@ class FormFile
} }
else else
{ {
print $file['name']; print dol_trunc($file['name'], 200);
print '</a>'; print '</a>';
} }
// Preview link // Preview link

View File

@ -2780,28 +2780,42 @@ function dol_readcachefile($directory, $filename)
*/ */
function getFilesUpdated(&$file_list, SimpleXMLElement $dir, $path = '', $pathref = '', &$checksumconcat = array()) function getFilesUpdated(&$file_list, SimpleXMLElement $dir, $path = '', $pathref = '', &$checksumconcat = array())
{ {
global $conffile;
$exclude = 'install'; $exclude = 'install';
foreach ($dir->md5file as $file) // $file is a simpleXMLElement foreach ($dir->md5file as $file) // $file is a simpleXMLElement
{ {
$filename = $path.$file['name']; $filename = $path.$file['name'];
$file_list['insignature'][] = $filename; $file_list['insignature'][] = $filename;
$expectedmd5 = (string) $file;
//if (preg_match('#'.$exclude.'#', $filename)) continue; //if (preg_match('#'.$exclude.'#', $filename)) continue;
if (!file_exists($pathref.'/'.$filename)) if (!file_exists($pathref.'/'.$filename))
{ {
$file_list['missing'][] = array('filename'=>$filename, 'expectedmd5'=>(string) $file); $file_list['missing'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5);
} }
else else
{ {
$md5_local = md5_file($pathref.'/'.$filename); $md5_local = md5_file($pathref.'/'.$filename);
if ($md5_local != (string) $file) $file_list['updated'][] = array('filename'=>$filename, 'expectedmd5'=>(string) $file, 'md5'=>(string) $md5_local);
$checksumconcat[] = $md5_local; if ($conffile == '/etc/dolibarr/conf.php' && $filename == '/filefunc.inc.php') // For install with deb or rpm, we ignore test on filefunc.inc.php that was modified by package
{
$checksumconcat[] = $expectedmd5;
}
else
{
if ($md5_local != $expectedmd5) $file_list['updated'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5, 'md5'=>(string) $md5_local);
$checksumconcat[] = $md5_local;
}
} }
} }
foreach ($dir->dir as $subdir) getFilesUpdated($file_list, $subdir, $path.$subdir['name'].'/', $pathref, $checksumconcat); foreach ($dir->dir as $subdir) // $subdir['name'] is '' or '/accountancy/admin' for example
{
getFilesUpdated($file_list, $subdir, $path.$subdir['name'].'/', $pathref, $checksumconcat);
}
return $file_list; return $file_list;
} }

View File

@ -2205,19 +2205,19 @@ function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$sep
if (dol_strlen($phone) == 10) { if (dol_strlen($phone) == 10) {
$newphone=substr($newphone,0,2).$separ.substr($newphone,2,2).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2); $newphone=substr($newphone,0,2).$separ.substr($newphone,2,2).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2);
} }
elseif (dol_strlen($newphone) == 7) elseif (dol_strlen($phone) == 7)
{ {
$newphone=substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2); $newphone=substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2);
} }
elseif (dol_strlen($newphone) == 9) elseif (dol_strlen($phone) == 9)
{ {
$newphone=substr($newphone,0,2).$separ.substr($newphone,2,3).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2); $newphone=substr($newphone,0,2).$separ.substr($newphone,2,3).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2);
} }
elseif (dol_strlen($newphone) == 11) elseif (dol_strlen($phone) == 11)
{ {
$newphone=substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); $newphone=substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2);
} }
elseif (dol_strlen($newphone) == 12) elseif (dol_strlen($phone) == 12)
{ {
$newphone=substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); $newphone=substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2);
} }
@ -2230,252 +2230,252 @@ function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$sep
} }
} }
elseif (strtoupper($countrycode) == "PT" ) elseif (strtoupper($countrycode) == "PT" )
{//Portugal {//Portugal
if (dol_strlen($object) == 13) if (dol_strlen($phone) == 13)
{//ex: +351_ABC_DEF_GHI {//ex: +351_ABC_DEF_GHI
$newphone= substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3); $newphone= substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3);
} }
} }
elseif (strtoupper($countrycode) == "SR" ) elseif (strtoupper($countrycode) == "SR" )
{//Suriname {//Suriname
if (dol_strlen($object) == 10) if (dol_strlen($phone) == 10)
{//ex: +597_ABC_DEF {//ex: +597_ABC_DEF
$newphone= substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3); $newphone= substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3);
} }
elseif (dol_strlen($object) == 11) elseif (dol_strlen($phone) == 11)
{//ex: +597_ABC_DEFG {//ex: +597_ABC_DEFG
$newphone= substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,4); $newphone= substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,4);
} }
} }
elseif (strtoupper($countrycode) == "DE" ) elseif (strtoupper($countrycode) == "DE" )
{//Allemagne {//Allemagne
if (dol_strlen($object) == 14) if (dol_strlen($phone) == 14)
{//ex: +49_ABCD_EFGH_IJK {//ex: +49_ABCD_EFGH_IJK
$newphone= substr($newphone,0,3).$separ.substr($newphone,3,4).$separ.substr($newphone,7,4).$separ.substr($newphone,11,3); $newphone= substr($newphone,0,3).$separ.substr($newphone,3,4).$separ.substr($newphone,7,4).$separ.substr($newphone,11,3);
} }
elseif (dol_strlen($object) == 13) elseif (dol_strlen($phone) == 13)
{//ex: +49_ABC_DEFG_HIJ {//ex: +49_ABC_DEFG_HIJ
$newphone= substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,4).$separ.substr($newphone,10,3); $newphone= substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,4).$separ.substr($newphone,10,3);
} }
} }
elseif (strtoupper($countrycode) == "ES") elseif (strtoupper($countrycode) == "ES")
{//Espagne {//Espagne
if (dol_strlen($object) == 12) if (dol_strlen($phone) == 12)
{//ex: +34_ABC_DEF_GHI {//ex: +34_ABC_DEF_GHI
$newphone= substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3); $newphone= substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3);
} }
} }
elseif (strtoupper($countrycode) == "BF") elseif (strtoupper($countrycode) == "BF")
{// Burkina Faso {// Burkina Faso
if (dol_strlen($newphone) == 12) if (dol_strlen($phone) == 12)
{//ex : +22 A BC_DE_FG_HI {//ex : +22 A BC_DE_FG_HI
$newphone= substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); $newphone= substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2);
} }
} }
elseif (strtoupper($countrycode) == "RO") elseif (strtoupper($countrycode) == "RO")
{// Roumanie {// Roumanie
if (dol_strlen($newphone) == 12) if (dol_strlen($phone) == 12)
{//ex : +40 AB_CDE_FG_HI {//ex : +40 AB_CDE_FG_HI
$newphone= substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); $newphone= substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2);
} }
} }
elseif (strtoupper($countrycode) == "TR") elseif (strtoupper($countrycode) == "TR")
{//Turquie {//Turquie
if (dol_strlen($object) == 13) if (dol_strlen($phone) == 13)
{//ex : +90 ABC_DEF_GHIJ {//ex : +90 ABC_DEF_GHIJ
$newphone= substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,4); $newphone= substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,4);
} }
} }
elseif (strtoupper($countrycode) == "US") elseif (strtoupper($countrycode) == "US")
{//Etat-Unis {//Etat-Unis
if (dol_strlen($newphone) == 12) if (dol_strlen($phone) == 12)
{//ex: +1 ABC_DEF_GHIJ {//ex: +1 ABC_DEF_GHIJ
$newphone= substr($newphone,0,2).$separ.substr($newphone,2,3).$separ.substr($newphone,5,3).$separ.substr($newphone,8,4); $newphone= substr($newphone,0,2).$separ.substr($newphone,2,3).$separ.substr($newphone,5,3).$separ.substr($newphone,8,4);
} }
} }
elseif (strtoupper($countrycode) == "MX") elseif (strtoupper($countrycode) == "MX")
{//Mexique {//Mexique
if (dol_strlen($newphone) == 12) if (dol_strlen($phone) == 12)
{//ex: +52 ABCD_EFG_HI {//ex: +52 ABCD_EFG_HI
$newphone = substr($newphone,0,3).$separ.substr($newphone,3,4).$separ.substr($newphone,7,3).$separ.substr($newphone,10,2); $newphone = substr($newphone,0,3).$separ.substr($newphone,3,4).$separ.substr($newphone,7,3).$separ.substr($newphone,10,2);
} }
elseif (dol_strlen($newphone) == 11) elseif (dol_strlen($phone) == 11)
{//ex: +52 AB_CD_EF_GH {//ex: +52 AB_CD_EF_GH
$newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); $newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2);
} }
elseif (dol_strlen($newphone) == 13) elseif (dol_strlen($phone) == 13)
{//ex: +52 ABC_DEF_GHIJ {//ex: +52 ABC_DEF_GHIJ
$newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,4); $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,4);
} }
} }
elseif (strtoupper($countrycode) == "ML") elseif (strtoupper($countrycode) == "ML")
{//Mali {//Mali
if(dol_strlen($newphone) == 12) if(dol_strlen($phone) == 12)
{//ex: +223 AB_CD_EF_GH {//ex: +223 AB_CD_EF_GH
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2);
} }
} }
elseif (strtoupper($countrycode) == "TH") elseif (strtoupper($countrycode) == "TH")
{//Thaïlande {//Thaïlande
if(dol_strlen($newphone) == 11) if(dol_strlen($phone) == 11)
{//ex: +66_ABC_DE_FGH {//ex: +66_ABC_DE_FGH
$newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,2).$separ.substr($newphone,8,3); $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,2).$separ.substr($newphone,8,3);
} }
elseif(dol_strlen($newphone) == 12) elseif(dol_strlen($phone) == 12)
{//ex: +66_A_BCD_EF_GHI {//ex: +66_A_BCD_EF_GHI
$newphone = substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,3); $newphone = substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,3);
} }
} }
elseif (strtoupper($countrycode) == "MU") elseif (strtoupper($countrycode) == "MU")
{//Maurice {//Maurice
if(dol_strlen($newphone) == 11) if(dol_strlen($phone) == 11)
{//ex: +230_ABC_DE_FG {//ex: +230_ABC_DE_FG
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2);
} }
elseif(dol_strlen($newphone) == 12) elseif(dol_strlen($phone) == 12)
{//ex: +230_ABCD_EF_GH {//ex: +230_ABCD_EF_GH
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,4).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,4).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2);
} }
} }
elseif (strtoupper($countrycode) == "ZA") elseif (strtoupper($countrycode) == "ZA")
{//Afrique du sud {//Afrique du sud
if(dol_strlen($newphone) == 12) if(dol_strlen($phone) == 12)
{//ex: +27_AB_CDE_FG_HI {//ex: +27_AB_CDE_FG_HI
$newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); $newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2);
} }
} }
elseif (strtoupper($countrycode) == "SY") elseif (strtoupper($countrycode) == "SY")
{//Syrie {//Syrie
if(dol_strlen($newphone) == 12) if(dol_strlen($phone) == 12)
{//ex: +963_AB_CD_EF_GH {//ex: +963_AB_CD_EF_GH
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2);
} }
elseif(dol_strlen($newphone) == 13) elseif(dol_strlen($phone) == 13)
{//ex: +963_AB_CD_EF_GHI {//ex: +963_AB_CD_EF_GHI
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,3); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,3);
} }
} }
elseif (strtoupper($countrycode) == "AE") elseif (strtoupper($countrycode) == "AE")
{//Emirats Arabes Unis {//Emirats Arabes Unis
if(dol_strlen($newphone) == 12) if(dol_strlen($phone) == 12)
{//ex: +971_ABC_DEF_GH {//ex: +971_ABC_DEF_GH
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,2); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,2);
} }
elseif(dol_strlen($newphone) == 13) elseif(dol_strlen($phone) == 13)
{//ex: +971_ABC_DEF_GHI {//ex: +971_ABC_DEF_GHI
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3);
} }
elseif(dol_strlen($newphone) == 14) elseif(dol_strlen($phone) == 14)
{//ex: +971_ABC_DEF_GHIK {//ex: +971_ABC_DEF_GHIK
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,4); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,4);
} }
} }
elseif (strtoupper($countrycode) == "DZ") elseif (strtoupper($countrycode) == "DZ")
{//Algérie {//Algérie
if(dol_strlen($newphone) == 13) if(dol_strlen($phone) == 13)
{//ex: +213_ABC_DEF_GHI {//ex: +213_ABC_DEF_GHI
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3);
} }
} }
elseif (strtoupper($countrycode) == "BE") elseif (strtoupper($countrycode) == "BE")
{//Belgique {//Belgique
if(dol_strlen($newphone) == 11) if(dol_strlen($phone) == 11)
{//ex: +32_ABC_DE_FGH {//ex: +32_ABC_DE_FGH
$newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,2).$separ.substr($newphone,8,3); $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,2).$separ.substr($newphone,8,3);
} }
elseif(dol_strlen($newphone) == 12) elseif(dol_strlen($phone) == 12)
{//ex: +32_ABC_DEF_GHI {//ex: +32_ABC_DEF_GHI
$newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3); $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3);
} }
} }
elseif (strtoupper($countrycode) == "PF") elseif (strtoupper($countrycode) == "PF")
{//Polynésie française {//Polynésie française
if(dol_strlen($newphone) == 12) if(dol_strlen($phone) == 12)
{//ex: +689_AB_CD_EF_GH {//ex: +689_AB_CD_EF_GH
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2);
} }
} }
elseif (strtoupper($countrycode) == "CO") elseif (strtoupper($countrycode) == "CO")
{//Colombie {//Colombie
if(dol_strlen($newphone) == 13) if(dol_strlen($phone) == 13)
{//ex: +57_ABC_DEF_GH_IJ {//ex: +57_ABC_DEF_GH_IJ
$newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2); $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2);
} }
} }
elseif (strtoupper($countrycode) == "JO") elseif (strtoupper($countrycode) == "JO")
{//Jordanie {//Jordanie
if(dol_strlen($newphone) == 12) if(dol_strlen($phone) == 12)
{//ex: +962_A_BCD_EF_GH {//ex: +962_A_BCD_EF_GH
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,1).$separ.substr($newphone,5,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,1).$separ.substr($newphone,5,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2);
} }
} }
elseif (strtoupper($countrycode) == "MG") elseif (strtoupper($countrycode) == "MG")
{//Madagascar {//Madagascar
if(dol_strlen($newphone) == 13) if(dol_strlen($phone) == 13)
{//ex: +261_AB_CD_EF_GHI {//ex: +261_AB_CD_EF_GHI
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,3); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,3);
} }
} }
elseif (strtoupper($countrycode) == "GB") elseif (strtoupper($countrycode) == "GB")
{//Royaume uni {//Royaume uni
if(dol_strlen($newphone) == 13) if(dol_strlen($phone) == 13)
{//ex: +44_ABCD_EFG_HIJ {//ex: +44_ABCD_EFG_HIJ
$newphone = substr($newphone,0,3).$separ.substr($newphone,3,4).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3); $newphone = substr($newphone,0,3).$separ.substr($newphone,3,4).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3);
} }
} }
elseif (strtoupper($countrycode) == "CH") elseif (strtoupper($countrycode) == "CH")
{//Suisse {//Suisse
if(dol_strlen($newphone) == 12) if(dol_strlen($phone) == 12)
{//ex: +41_AB_CDE_FG_HI {//ex: +41_AB_CDE_FG_HI
$newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); $newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2);
} }
elseif(dol_strlen($newphone) == 15) elseif(dol_strlen($phone) == 15)
{// +41_AB_CDE_FGH_IJKL {// +41_AB_CDE_FGH_IJKL
$newphone =$newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,3).$separ.substr($newphone,11,4); $newphone =$newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,3).$separ.substr($newphone,11,4);
} }
} }
elseif (strtoupper($countrycode) == "TN") elseif (strtoupper($countrycode) == "TN")
{//Tunisie {//Tunisie
if(dol_strlen($newphone) == 12) if(dol_strlen($phone) == 12)
{//ex: +216_AB_CDE_FGH {//ex: +216_AB_CDE_FGH
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3);
} }
} }
elseif (strtoupper($countrycode) == "GF") elseif (strtoupper($countrycode) == "GF")
{//Guyane francaise {//Guyane francaise
if(dol_strlen($newphone) == 13) if(dol_strlen($phone) == 13)
{//ex: +594_ABC_DE_FG_HI (ABC=594 de nouveau) {//ex: +594_ABC_DE_FG_HI (ABC=594 de nouveau)
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2);
} }
} }
elseif (strtoupper($countrycode) == "GP") elseif (strtoupper($countrycode) == "GP")
{//Guadeloupe {//Guadeloupe
if(dol_strlen($newphone) == 13) if(dol_strlen($phone) == 13)
{//ex: +590_ABC_DE_FG_HI (ABC=590 de nouveau) {//ex: +590_ABC_DE_FG_HI (ABC=590 de nouveau)
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2);
} }
} }
elseif (strtoupper($countrycode) == "MQ") elseif (strtoupper($countrycode) == "MQ")
{//Martinique {//Martinique
if(dol_strlen($newphone) == 13) if(dol_strlen($phone) == 13)
{//ex: +596_ABC_DE_FG_HI (ABC=596 de nouveau) {//ex: +596_ABC_DE_FG_HI (ABC=596 de nouveau)
$newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2); $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2);
} }
} }
elseif (strtoupper($countrycode) == "IT") elseif (strtoupper($countrycode) == "IT")
{//Italie {//Italie
if(dol_strlen($newphone) == 12) if(dol_strlen($phone) == 12)
{//ex: +39_ABC_DEF_GHI {//ex: +39_ABC_DEF_GHI
$newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3); $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3);
} }
elseif(dol_strlen($newphone) == 13) elseif(dol_strlen($phone) == 13)
{//ex: +39_ABC_DEF_GH_IJ {//ex: +39_ABC_DEF_GH_IJ
$newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2); $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2);
} }
} }
elseif(strtoupper($countrycode) == "AU") elseif(strtoupper($countrycode) == "AU")
{//Australie {//Australie
if(dol_strlen($newphone) == 12) if(dol_strlen($phone) == 12)
{//ex: +61_A_BCDE_FGHI {//ex: +61_A_BCDE_FGHI
$newphone = substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,4).$separ.substr($newphone,8,4); $newphone = substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,4).$separ.substr($newphone,8,4);
} }

View File

@ -164,6 +164,47 @@ function dolWebsiteSaveContent($content)
*/ */
/**
* Make a redirect to another container
*
* @param string $containeralias Path to file to include (must be a page from website root. Example: 'mypage.php' means 'mywebsite/mypage.php')
* @return void
*/
function redirectToContainer($containeralias)
{
global $db, $website;
$newurl = '';
if (defined('USEDOLIBARRSERVER')) // When page called from Dolibarr server
{
// Check new container exists
$tmpwebsitepage=new WebsitePage($db);
$result = $tmpwebsitepage->fetch(0, $website->id, $containeralias);
unset($tmpwebsitepage);
if ($result > 0)
{
$newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containeralias, $_SERVER["REQUEST_URI"]);
}
}
else // When page called from virtual host server
{
$newurl = '/'.$containeralias;
}
if ($newurl)
{
header("Location: ".$newurl);
exit;
}
else
{
print "Error, page contains a reditect to the alias page '".$containeralias."' that does not exists in web site '".$website->ref."'";
exit;
}
}
/** /**
* Clean an HTML page to report only content, so we can include it into another page. * Clean an HTML page to report only content, so we can include it into another page.
* It outputs content of file sanitized from html and body part. * It outputs content of file sanitized from html and body part.
@ -222,9 +263,11 @@ function includeContainer($containeralias)
* @param string $tmp Content to parse * @param string $tmp Content to parse
* @param string $action Var $action * @param string $action Var $action
* @param string $modifylinks 0=Do not modify content, 1=Replace links with a link to viewimage * @param string $modifylinks 0=Do not modify content, 1=Replace links with a link to viewimage
* @param int $grabimages 0=Do not grab images, 1=Grab images
* @param string $grabimagesinto 'root' or 'subpage'
* @return void * @return void
*/ */
function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0) function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0, $grabimages=1, $grabimagesinto='subpage')
{ {
global $conf; global $conf;
@ -252,15 +295,18 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify
} }
$linkwithoutdomain = $regs[2][$key]; $linkwithoutdomain = $regs[2][$key];
$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; $dirforimages = '/'.$objectpage->pageurl;
if ($grabimagesinto == 'root') $dirforimages='';
// Define $filetosave and $filename
$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
if (preg_match('/^http/', $regs[2][$key])) if (preg_match('/^http/', $regs[2][$key]))
{ {
$urltograbbis = $regs[2][$key]; $urltograbbis = $regs[2][$key];
$linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
} }
$filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
// Clean the aa/bb/../cc into aa/cc // Clean the aa/bb/../cc into aa/cc
$filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave); $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave);
@ -272,30 +318,33 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify
if (empty($alreadygrabbed[$urltograbbis])) if (empty($alreadygrabbed[$urltograbbis]))
{ {
$tmpgeturl = getURLContent($urltograbbis); if ($grabimages)
if ($tmpgeturl['curl_error_no'])
{ {
$error++; $tmpgeturl = getURLContent($urltograbbis);
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); if ($tmpgeturl['curl_error_no'])
$action='create'; {
} $error++;
elseif ($tmpgeturl['http_code'] != '200') setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
{ $action='create';
$error++; }
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); elseif ($tmpgeturl['http_code'] != '200')
$action='create'; {
} $error++;
else setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
{ $action='create';
$alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. }
else
{
$alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed.
dol_mkdir(dirname($filetosave)); dol_mkdir(dirname($filetosave));
$fp = fopen($filetosave, "w"); $fp = fopen($filetosave, "w");
fputs($fp, $tmpgeturl['content']); fputs($fp, $tmpgeturl['content']);
fclose($fp); fclose($fp);
if (! empty($conf->global->MAIN_UMASK)) if (! empty($conf->global->MAIN_UMASK))
@chmod($filetosave, octdec($conf->global->MAIN_UMASK)); @chmod($filetosave, octdec($conf->global->MAIN_UMASK));
}
} }
} }
@ -344,30 +393,33 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify
if (empty($alreadygrabbed[$urltograbbis])) if (empty($alreadygrabbed[$urltograbbis]))
{ {
$tmpgeturl = getURLContent($urltograbbis); if ($grabimages)
if ($tmpgeturl['curl_error_no'])
{ {
$error++; $tmpgeturl = getURLContent($urltograbbis);
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); if ($tmpgeturl['curl_error_no'])
$action='create'; {
} $error++;
elseif ($tmpgeturl['http_code'] != '200') setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
{ $action='create';
$error++; }
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); elseif ($tmpgeturl['http_code'] != '200')
$action='create'; {
} $error++;
else setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
{ $action='create';
$alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. }
else
{
$alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed.
dol_mkdir(dirname($filetosave)); dol_mkdir(dirname($filetosave));
$fp = fopen($filetosave, "w"); $fp = fopen($filetosave, "w");
fputs($fp, $tmpgeturl['content']); fputs($fp, $tmpgeturl['content']);
fclose($fp); fclose($fp);
if (! empty($conf->global->MAIN_UMASK)) if (! empty($conf->global->MAIN_UMASK))
@chmod($filetosave, octdec($conf->global->MAIN_UMASK)); @chmod($filetosave, octdec($conf->global->MAIN_UMASK));
}
} }
} }

View File

@ -69,21 +69,9 @@ $conffiletoshow = "htdocs/conf/conf.php";
// Include configuration // Include configuration
// --- End of part replaced by Dolibarr packager makepack-dolibarr // --- End of part replaced by Dolibarr packager makepack-dolibarr
// Replace conf filename with "conf" parameter on url by GET
/* Disabled. This is a serious security hole
if (! empty($_GET['conf']))
{
$confname=basename($_GET['conf']);
setcookie('dolconf', $confname, 0, '/');
$conffile = 'conf/'.$confname.'.php';
} else {
$confname=basename(empty($_COOKIE['dolconf']) ? 'conf' : $_COOKIE['dolconf']);
$conffile = 'conf/'.$confname.'.php';
}
*/
// Include configuration // Include configuration
$result=@include_once $conffile; // Keep @ because with some error reporting this break the redirect $result=@include_once $conffile; // Keep @ because with some error reporting this break the redirect done when file not found
if (! $result && ! empty($_SERVER["GATEWAY_INTERFACE"])) // If install not done and we are in a web session if (! $result && ! empty($_SERVER["GATEWAY_INTERFACE"])) // If install not done and we are in a web session
{ {

View File

@ -342,7 +342,7 @@ ErrorCantUseRazIfNoYearInMask=Error, can't use option @ to reset counter each ye
ErrorCantUseRazInStartedYearIfNoYearMonthInMask=Error, can't use option @ if sequence {yy}{mm} or {yyyy}{mm} is not in mask. ErrorCantUseRazInStartedYearIfNoYearMonthInMask=Error, can't use option @ if sequence {yy}{mm} or {yyyy}{mm} is not in mask.
UMask=UMask parameter for new files on Unix/Linux/BSD/Mac file system. UMask=UMask parameter for new files on Unix/Linux/BSD/Mac file system.
UMaskExplanation=This parameter allow you to define permissions set by default on files created by Dolibarr on server (during upload for example).<br>It must be the octal value (for example, 0666 means read and write for everyone).<br>This parameter is useless on a Windows server. UMaskExplanation=This parameter allow you to define permissions set by default on files created by Dolibarr on server (during upload for example).<br>It must be the octal value (for example, 0666 means read and write for everyone).<br>This parameter is useless on a Windows server.
SeeWikiForAllTeam=Take a look at the wiki page for full list of all actors and their organisation SeeWikiForAllTeam=Take a look at the wiki page for full list of all actors and their organization
UseACacheDelay= Delay for caching export response in seconds (0 or empty for no cache) UseACacheDelay= Delay for caching export response in seconds (0 or empty for no cache)
DisableLinkToHelpCenter=Hide link "<b>Need help or support</b>" on login page DisableLinkToHelpCenter=Hide link "<b>Need help or support</b>" on login page
DisableLinkToHelp=Hide link to online help "<b>%s</b>" DisableLinkToHelp=Hide link to online help "<b>%s</b>"
@ -449,7 +449,8 @@ ModuleCompanyCodePanicum=Return an empty accounting code.
ModuleCompanyCodeDigitaria=Accounting code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code. ModuleCompanyCodeDigitaria=Accounting code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code.
Use3StepsApproval=By default, Purchase Orders need to be created and approved by 2 different users (one step/user to create and one step/user to approve. Note that if user has both permission to create and approve, one step/user will be enough). You can ask with this option to introduce a third step/user approval, if amount is higher than a dedicated value (so 3 steps will be necessary: 1=validation, 2=first approval and 3=second approval if amount is enough).<br>Set this to empty if one approval (2 steps) is enough, set it to a very low value (0.1) if a second approval (3 steps) is always required. Use3StepsApproval=By default, Purchase Orders need to be created and approved by 2 different users (one step/user to create and one step/user to approve. Note that if user has both permission to create and approve, one step/user will be enough). You can ask with this option to introduce a third step/user approval, if amount is higher than a dedicated value (so 3 steps will be necessary: 1=validation, 2=first approval and 3=second approval if amount is enough).<br>Set this to empty if one approval (2 steps) is enough, set it to a very low value (0.1) if a second approval (3 steps) is always required.
UseDoubleApproval=Use a 3 steps approval when amount (without tax) is higher than... UseDoubleApproval=Use a 3 steps approval when amount (without tax) is higher than...
WarningPHPMail=WARNING: Some email providers (like Yahoo) does not allow you to send an email from another server than the Yahoo server if the email address used as a sender is your Yahoo email (like myemail@yahoo.com, myemail@yahoo.fr, ...). Your current setup use the server of the application to send email, so some recipients (the one compatible with the restrictive DMARC protocol), will ask Yahoo if they can accept your email and Yahoo will respond "no" because the server is not a server owned by Yahoo, so few of your sent Emails may not be accepted.<br>If your Email provider (like Yahoo) has this restriction, you must change Email setup to choose the other method "SMTP server" and enter the SMTP server and credentials provided by your Email provider (ask your EMail provider to get SMTP credentials for your account). WarningPHPMail=WARNING: It is often better to setup outgoing emails to use the email server of your provider instead of the default setup. Some email providers (like Yahoo) does not allow you to send an email from another server than their own server. Your current setup use the server of the application to send email and not the server of your email provider, so some recipients (the one compatible with the restrictive DMARC protocol), will ask your email provider if they can accept your email and some email providers (like Yahoo) may respond "no" because the server is not a server of them, so few of your sent Emails may not be accepted (be car also to your email provider sending quota).<br>If your Email provider (like Yahoo) has this restriction, you must change Email setup to choose the other method "SMTP server" and enter the SMTP server and credentials provided by your Email provider (ask your EMail provider to get SMTP credentials for your account).
WarningPHPMail2=If your email SMTP provider need to restrict email client to some IP addresses (very rare), this is the IP address of your ERP CRM application: <strong>%s</strong>.
ClickToShowDescription=Click to show description ClickToShowDescription=Click to show description
DependsOn=This module need the module(s) DependsOn=This module need the module(s)
RequiredBy=This module is required by module(s) RequiredBy=This module is required by module(s)
@ -911,8 +912,8 @@ TypeOfRevenueStamp=Type of revenue stamp
VATManagement=VAT Management VATManagement=VAT Management
VATIsUsedDesc=By default when creating prospects, invoices, orders etc the VAT rate follows the active standard rule:<br>If the seller is not subjected to VAT, then VAT defaults to 0. End of rule.<br>If the (selling country= buying country), then the VAT by default equals the VAT of the product in the selling country. End of rule. <br>If seller and buyer are both in the European Community and goods are transport products (car, ship, plane), the default VAT is 0 ( The VAT should be paid by the buyer to the customoffice of his country and not to the seller). End of rule.<br>If seller and buyer are both in the European Community and the buyer is not a company, then the VAT by defaults to the VAT of the product sold. End of rule.<br>If seller and buyer are both in the European Community and the buyer is a company, then the VAT is 0 by default . End of rule.<br>In any othe case the proposed default is VAT=0. End of rule. VATIsUsedDesc=By default when creating prospects, invoices, orders etc the VAT rate follows the active standard rule:<br>If the seller is not subjected to VAT, then VAT defaults to 0. End of rule.<br>If the (selling country= buying country), then the VAT by default equals the VAT of the product in the selling country. End of rule. <br>If seller and buyer are both in the European Community and goods are transport products (car, ship, plane), the default VAT is 0 ( The VAT should be paid by the buyer to the customoffice of his country and not to the seller). End of rule.<br>If seller and buyer are both in the European Community and the buyer is not a company, then the VAT by defaults to the VAT of the product sold. End of rule.<br>If seller and buyer are both in the European Community and the buyer is a company, then the VAT is 0 by default . End of rule.<br>In any othe case the proposed default is VAT=0. End of rule.
VATIsNotUsedDesc=By default the proposed VAT is 0 which can be used for cases like associations, individuals ou small companies. VATIsNotUsedDesc=By default the proposed VAT is 0 which can be used for cases like associations, individuals ou small companies.
VATIsUsedExampleFR=In France, it means companies or organisations having a real fiscal system (Simplified real or normal real). A system in which VAT is declared. VATIsUsedExampleFR=In France, it means companies or organizations having a real fiscal system (Simplified real or normal real). A system in which VAT is declared.
VATIsNotUsedExampleFR=In France, it means associations that are non VAT declared or companies, organisations or liberal professions that have chosen the micro enterprise fiscal system (VAT in franchise) and paid a franchise VAT without any VAT declaration. This choice will display the reference "Non applicable VAT - art-293B of CGI" on invoices. VATIsNotUsedExampleFR=In France, it means associations that are non VAT declared or companies, organizations or liberal professions that have chosen the micro enterprise fiscal system (VAT in franchise) and paid a franchise VAT without any VAT declaration. This choice will display the reference "Non applicable VAT - art-293B of CGI" on invoices.
##### Local Taxes ##### ##### Local Taxes #####
LTRate=Rate LTRate=Rate
LocalTax1IsNotUsed=Do not use second tax LocalTax1IsNotUsed=Do not use second tax
@ -977,7 +978,7 @@ Host=Server
DriverType=Driver type DriverType=Driver type
SummarySystem=System information summary SummarySystem=System information summary
SummaryConst=List of all Dolibarr setup parameters SummaryConst=List of all Dolibarr setup parameters
MenuCompanySetup=Company/Organisation MenuCompanySetup=Company/Organization
DefaultMenuManager= Standard menu manager DefaultMenuManager= Standard menu manager
DefaultMenuSmartphoneManager=Smartphone menu manager DefaultMenuSmartphoneManager=Smartphone menu manager
Skin=Skin theme Skin=Skin theme
@ -993,8 +994,8 @@ PermanentLeftSearchForm=Permanent search form on left menu
DefaultLanguage=Default language to use (language code) DefaultLanguage=Default language to use (language code)
EnableMultilangInterface=Enable multilingual interface EnableMultilangInterface=Enable multilingual interface
EnableShowLogo=Show logo on left menu EnableShowLogo=Show logo on left menu
CompanyInfo=Company/organisation information CompanyInfo=Company/organization information
CompanyIds=Company/organisation identities CompanyIds=Company/organization identities
CompanyName=Name CompanyName=Name
CompanyAddress=Address CompanyAddress=Address
CompanyZip=Zip CompanyZip=Zip
@ -1550,7 +1551,7 @@ SupposedToBeInvoiceDate=Invoice date used
Buy=Buy Buy=Buy
Sell=Sell Sell=Sell
InvoiceDateUsed=Invoice date used InvoiceDateUsed=Invoice date used
YourCompanyDoesNotUseVAT=Your company has been defined to not use VAT (Home - Setup - Company/Organisation), so there is no VAT options to setup. YourCompanyDoesNotUseVAT=Your company has been defined to not use VAT (Home - Setup - Company/Organization), so there is no VAT options to setup.
AccountancyCode=Accounting Code AccountancyCode=Accounting Code
AccountancyCodeSell=Sale account. code AccountancyCodeSell=Sale account. code
AccountancyCodeBuy=Purchase account. code AccountancyCodeBuy=Purchase account. code

View File

@ -127,7 +127,7 @@ ErrorFailedToAddToMailmanList=Failed to add record %s to Mailman list %s or SPIP
ErrorFailedToRemoveToMailmanList=Failed to remove record %s to Mailman list %s or SPIP base ErrorFailedToRemoveToMailmanList=Failed to remove record %s to Mailman list %s or SPIP base
ErrorNewValueCantMatchOldValue=New value can't be equal to old one ErrorNewValueCantMatchOldValue=New value can't be equal to old one
ErrorFailedToValidatePasswordReset=Failed to reinit password. May be the reinit was already done (this link can be used only one time). If not, try to restart the reinit process. ErrorFailedToValidatePasswordReset=Failed to reinit password. May be the reinit was already done (this link can be used only one time). If not, try to restart the reinit process.
ErrorToConnectToMysqlCheckInstance=Connect to database fails. Check Mysql server is running (in most cases, you can launch it from command line with 'sudo /etc/init.d/mysql start'). ErrorToConnectToMysqlCheckInstance=Connect to database fails. Check database server is running (for example, with mysql/mariadb, you can launch it from command line with 'sudo service mysql start').
ErrorFailedToAddContact=Failed to add contact ErrorFailedToAddContact=Failed to add contact
ErrorDateMustBeBeforeToday=The date cannot be greater than today ErrorDateMustBeBeforeToday=The date cannot be greater than today
ErrorPaymentModeDefinedToWithoutSetup=A payment mode was set to type %s but setup of module Invoice was not completed to define information to show for this payment mode. ErrorPaymentModeDefinedToWithoutSetup=A payment mode was set to type %s but setup of module Invoice was not completed to define information to show for this payment mode.

View File

@ -44,7 +44,7 @@ ErrorConstantNotDefined=Parameter %s not defined
ErrorUnknown=Unknown error ErrorUnknown=Unknown error
ErrorSQL=SQL Error ErrorSQL=SQL Error
ErrorLogoFileNotFound=Logo file '%s' was not found ErrorLogoFileNotFound=Logo file '%s' was not found
ErrorGoToGlobalSetup=Go to 'Company/Organisation' setup to fix this ErrorGoToGlobalSetup=Go to 'Company/Organization' setup to fix this
ErrorGoToModuleSetup=Go to Module setup to fix this ErrorGoToModuleSetup=Go to Module setup to fix this
ErrorFailedToSendMail=Failed to send mail (sender=%s, receiver=%s) ErrorFailedToSendMail=Failed to send mail (sender=%s, receiver=%s)
ErrorFileNotUploaded=File was not uploaded. Check that size does not exceed maximum allowed, that free space is available on disk and that there is not already a file with same name in this directory. ErrorFileNotUploaded=File was not uploaded. Check that size does not exceed maximum allowed, that free space is available on disk and that there is not already a file with same name in this directory.
@ -421,7 +421,7 @@ ActionRunningShort=In progress
ActionDoneShort=Finished ActionDoneShort=Finished
ActionUncomplete=Uncomplete ActionUncomplete=Uncomplete
LatestLinkedEvents=Latest %s linked events LatestLinkedEvents=Latest %s linked events
CompanyFoundation=Company/Organisation CompanyFoundation=Company/Organization
ContactsForCompany=Contacts for this third party ContactsForCompany=Contacts for this third party
ContactsAddressesForCompany=Contacts/addresses for this third party ContactsAddressesForCompany=Contacts/addresses for this third party
AddressesForCompany=Addresses for this third party AddressesForCompany=Addresses for this third party

View File

@ -12,7 +12,7 @@ ShowTrip=Show expense report
NewTrip=New expense report NewTrip=New expense report
LastExpenseReports=Latest %s expense reports LastExpenseReports=Latest %s expense reports
AllExpenseReports=All expense reports AllExpenseReports=All expense reports
CompanyVisited=Company/organisation visited CompanyVisited=Company/organization visited
FeesKilometersOrAmout=Amount or kilometers FeesKilometersOrAmout=Amount or kilometers
DeleteTrip=Delete expense report DeleteTrip=Delete expense report
ConfirmDeleteTrip=Are you sure you want to delete this expense report? ConfirmDeleteTrip=Are you sure you want to delete this expense report?

View File

@ -69,8 +69,8 @@ InternalUser=Internal user
ExportDataset_user_1=Dolibarr's users and properties ExportDataset_user_1=Dolibarr's users and properties
DomainUser=Domain user %s DomainUser=Domain user %s
Reactivate=Reactivate Reactivate=Reactivate
CreateInternalUserDesc=This form allows you to create an user internal to your company/organisation. To create an external user (customer, supplier, ...), use the button 'Create Dolibarr user' from third party's contact card. CreateInternalUserDesc=This form allows you to create an user internal to your company/organization. To create an external user (customer, supplier, ...), use the button 'Create Dolibarr user' from third party's contact card.
InternalExternalDesc=An <b>internal</b> user is a user that is part of your company/organisation.<br>An <b>external</b> user is a customer, supplier or other.<br><br>In both cases, permissions defines rights on Dolibarr, also external user can have a different menu manager than internal user (See Home - Setup - Display) InternalExternalDesc=An <b>internal</b> user is a user that is part of your company/organization.<br>An <b>external</b> user is a customer, supplier or other.<br><br>In both cases, permissions defines rights on Dolibarr, also external user can have a different menu manager than internal user (See Home - Setup - Display)
PermissionInheritedFromAGroup=Permission granted because inherited from one of a user's group. PermissionInheritedFromAGroup=Permission granted because inherited from one of a user's group.
Inherited=Inherited Inherited=Inherited
UserWillBeInternalUser=Created user will be an internal user (because not linked to a particular third party) UserWillBeInternalUser=Created user will be an internal user (because not linked to a particular third party)

View File

@ -41,7 +41,7 @@ VirtualHostUrlNotDefined=URL of the virtual host served by external web server n
NoPageYet=No pages yet NoPageYet=No pages yet
SyntaxHelp=Help on specific syntax tips SyntaxHelp=Help on specific syntax tips
YouCanEditHtmlSourceckeditor=You can edit HTML source code using the "Source" button in editor. YouCanEditHtmlSourceckeditor=You can edit HTML source code using the "Source" button in editor.
YouCanEditHtmlSource=<br><span class="fa fa-bug"></span> You can include PHP code into this source using tags <strong>&lt;?php ?&gt;</strong>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.<br><br><span class="fa fa-bug"></span> You can also include content of another Page/Container with the following syntax:<br><strong>&lt;?php includeContainer('alias_of_container_to_include'); ?&gt;</strong><br><br><span class="fa fa-download"></span> To include a <strong>link to download</strong> a file stored into the <strong>documents</strong> directory, use the <strong>document.php</strong> wrapper:<br>Example, for a file into documents/ecm (need to be logged), syntax is:<br><strong>&lt;a href="/document.php?modulepart=ecm&file=[relative_dir/]filename.ext"&gt;</strong><br>For a file into documents/medias (open directory for public access), syntax is:<br><strong>&lt;a href="/document.php?modulepart=medias&file=[relative_dir/]filename.ext"&gt;</strong><br>For a file shared with a share link (open access using the sharing hash key of file), syntax is:<br><strong>&lt;a href="/document.php?hashp=publicsharekeyoffile"&gt;</strong><br><br><span class="fa fa-picture-o"></span> To include an <strong>image</strong> stored into the <strong>documents</strong> directory, use the <strong>viewimage.php</strong> wrapper:<br>Example, for an image into documents/medias (open access), syntax is:<br><strong>&lt;a href="/viewimage.php?modulepart=medias&amp;file=[relative_dir/]filename.ext"&gt;</strong><br> YouCanEditHtmlSource=<br><span class="fa fa-bug"></span> You can include PHP code into this source using tags <strong>&lt;?php ?&gt;</strong>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.<br><br><span class="fa fa-bug"></span> You can also include content of another Page/Container with the following syntax:<br><strong>&lt;?php includeContainer('alias_of_container_to_include'); ?&gt;</strong><br><br><span class="fa fa-bug"></span> You can make a redirect to another Page/Container with the following syntax:<br><strong>&lt;?php redirectToContainer('alias_of_container_to_redirect_to'); ?&gt;</strong><br><br><span class="fa fa-download"></span> To include a <strong>link to download</strong> a file stored into the <strong>documents</strong> directory, use the <strong>document.php</strong> wrapper:<br>Example, for a file into documents/ecm (need to be logged), syntax is:<br><strong>&lt;a href="/document.php?modulepart=ecm&file=[relative_dir/]filename.ext"&gt;</strong><br>For a file into documents/medias (open directory for public access), syntax is:<br><strong>&lt;a href="/document.php?modulepart=medias&file=[relative_dir/]filename.ext"&gt;</strong><br>For a file shared with a share link (open access using the sharing hash key of file), syntax is:<br><strong>&lt;a href="/document.php?hashp=publicsharekeyoffile"&gt;</strong><br><br><span class="fa fa-picture-o"></span> To include an <strong>image</strong> stored into the <strong>documents</strong> directory, use the <strong>viewimage.php</strong> wrapper:<br>Example, for an image into documents/medias (open access), syntax is:<br><strong>&lt;a href="/viewimage.php?modulepart=medias&amp;file=[relative_dir/]filename.ext"&gt;</strong><br>
ClonePage=Clone page/container ClonePage=Clone page/container
CloneSite=Clone site CloneSite=Clone site
SiteAdded=Web site added SiteAdded=Web site added
@ -68,4 +68,9 @@ WEBSITE_USE_WEBSITE_ACCOUNTS=Enable the web site account table
WEBSITE_USE_WEBSITE_ACCOUNTSTooltip=Enable the table to store web site accounts (login/pass) for each website / thirdparty WEBSITE_USE_WEBSITE_ACCOUNTSTooltip=Enable the table to store web site accounts (login/pass) for each website / thirdparty
YouMustDefineTheHomePage=You must first define the default Home page YouMustDefineTheHomePage=You must first define the default Home page
OnlyEditionOfSourceForGrabbedContentFuture=Note: only edition of HTML source will be possible when a page content is intiliazed by grabbing it from an external page (WYSIWYG editor will not be available) OnlyEditionOfSourceForGrabbedContentFuture=Note: only edition of HTML source will be possible when a page content is intiliazed by grabbing it from an external page (WYSIWYG editor will not be available)
OnlyEditionOfSourceForGrabbedContent=Only edition of HTML source is possible when content was grabber from an external site OnlyEditionOfSourceForGrabbedContent=Only edition of HTML source is possible when content was grabbed from an external site
GrabImagesInto=Grab also images found into css and page.
ImagesShouldBeSavedInto=Images should be saved into directory
WebsiteRootOfImages=Root directory for website images
SubdirOfPage=Sub-directory dedicated to page
AliasPageAlreadyExists=Alias page <strong>%s</strong> already exists

View File

@ -58,8 +58,11 @@ $conffiletoshowshort = "conf.php";
$conffile = "../conf/conf.php"; $conffile = "../conf/conf.php";
$conffiletoshow = "htdocs/conf/conf.php"; $conffiletoshow = "htdocs/conf/conf.php";
// For debian/redhat like systems // For debian/redhat like systems
//$conffile = "/etc/dolibarr/conf.php"; if (! file_exists($conffile))
//$conffiletoshow = "/etc/dolibarr/conf.php"; {
$conffile = "/etc/dolibarr/conf.php";
$conffiletoshow = "/etc/dolibarr/conf.php";
}
// Load conf file if it is already defined // Load conf file if it is already defined
@ -208,7 +211,7 @@ function pHeader($soutitre,$next,$action='none')
// On force contenu dans format sortie // On force contenu dans format sortie
header("Content-type: text/html; charset=".$conf->file->character_set_client); header("Content-type: text/html; charset=".$conf->file->character_set_client);
header("X-Content-Type-Options: nosniff"); header("X-Content-Type-Options: nosniff");
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n"; print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
print '<html manifest="'.DOL_URL_ROOT.'/cache.manifest">'."\n"; print '<html manifest="'.DOL_URL_ROOT.'/cache.manifest">'."\n";
print '<head>'."\n"; print '<head>'."\n";

View File

@ -113,13 +113,16 @@ class WebsitePage extends CommonObject
*/ */
public function create(User $user, $notrigger = false) public function create(User $user, $notrigger = false)
{ {
$this->description = dol_trunc($this->description, 255, 'right', 'utf-8', 1);
$this->keywords = dol_trunc($this->keywords, 255, 'right', 'utf-8', 1);
return $this->createCommon($user, $notrigger); return $this->createCommon($user, $notrigger);
} }
/** /**
* Load object in memory from the database * Load object in memory from the database
* *
* @param int $id Id object. If this is 0, the default page of website_id will be used, if not defined, the first one found. * @param int $id Id object. If this is 0, the value into $page will be used. If not found of $page not defined, the default page of website_id will be used or the first page found if not set.
* @param string $website_id Web site id (page name must also be filled if this parameter is used) * @param string $website_id Web site id (page name must also be filled if this parameter is used)
* @param string $page Page name (website id must also be filled if this parameter is used) * @param string $page Page name (website id must also be filled if this parameter is used)
* *

View File

@ -210,6 +210,7 @@ if ($action == 'addsite')
if (! $error && ! preg_match('/^[a-z0-9_\-\.]+$/i', GETPOST('WEBSITE_REF','alpha'))) if (! $error && ! preg_match('/^[a-z0-9_\-\.]+$/i', GETPOST('WEBSITE_REF','alpha')))
{ {
$error++; $error++;
$langs->load("errors");
setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("Ref")), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("Ref")), null, 'errors');
} }
@ -261,6 +262,9 @@ if ($action == 'addcontainer')
if (GETPOST('fetchexternalurl','alpha')) if (GETPOST('fetchexternalurl','alpha'))
{ {
$urltograb=GETPOST('externalurl','alpha'); $urltograb=GETPOST('externalurl','alpha');
$grabimages=GETPOST('grabimages','alpha');
$grabimagesinto=GETPOST('grabimagesinto','alpha');
//var_dump($grabimages);exit;
} }
if ($urltograb) if ($urltograb)
@ -275,234 +279,255 @@ if ($action == 'addcontainer')
{ {
$urltograb.='/'; $urltograb.='/';
} }
$pageurl = dol_sanitizeFileName(preg_replace('/[\/\.]/','-', preg_replace('/\/+$/', '', $urltograbwithoutdomainandparam)));
$urltograbdirwithoutslash = dirname($urltograb.'.'); $urltograbdirwithoutslash = dirname($urltograb.'.');
$urltograbdirrootwithoutslash = getRootURLFromURL($urltograbdirwithoutslash); $urltograbdirrootwithoutslash = getRootURLFromURL($urltograbdirwithoutslash);
// Exemple, now $urltograbdirwithoutslash is https://www.dolimed.com/screenshots // Exemple, now $urltograbdirwithoutslash is https://www.dolimed.com/screenshots
// and $urltograbdirrootwithoutslash is https://www.dolimed.com // and $urltograbdirrootwithoutslash is https://www.dolimed.com
$tmp = getURLContent($urltograb); // Check pageurl is not already used
if ($tmp['curl_error_no']) $tmpwebsitepage = new WebsitePage($db);
$result = $tmpwebsitepage->fetch(0, $object->id, $pageurl);
if ($result > 0)
{ {
setEventMessages($langs->trans("AliasPageAlreadyExists", $pageurl), null, 'errors');
$error++; $error++;
setEventMessages('Error getting '.$urltograb.': '.$tmp['curl_error_msg'], null, 'errors');
$action='createcontainer'; $action='createcontainer';
} }
elseif ($tmp['http_code'] != '200')
if (! $error)
{ {
$error++; $tmp = getURLContent($urltograb);
setEventMessages('Error getting '.$urltograb.': '.$tmp['http_code'], null, 'errors'); if ($tmp['curl_error_no'])
$action='createcontainer';
}
else
{
// Remove comments
$tmp['content'] = removeHtmlComment($tmp['content']);
preg_match('/<head>(.*)<\/head>/is', $tmp['content'], $reg);
$head = $reg[1];
$objectpage->type_container = 'page';
$objectpage->pageurl = dol_sanitizeFileName(preg_replace('/[\/\.]/','-', preg_replace('/\/+$/', '', $urltograbwithoutdomainandparam)));
if (empty($objectpage->pageurl))
{
$tmpdomain = getDomainFromURL($urltograb);
$objectpage->pageurl=$tmpdomain.'-home';
}
if (preg_match('/<title>(.*)<\/title>/ims', $head, $regtmp))
{ {
$objectpage->title = $regtmp[1]; $error++;
setEventMessages('Error getting '.$urltograb.': '.$tmp['curl_error_msg'], null, 'errors');
$action='createcontainer';
} }
if (preg_match('/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) elseif ($tmp['http_code'] != '200')
{ {
$objectpage->description = $regtmp[1]; $error++;
setEventMessages('Error getting '.$urltograb.': '.$tmp['http_code'], null, 'errors');
$action='createcontainer';
} }
if (preg_match('/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp)) else
{ {
$objectpage->keywords = $regtmp[1]; // Remove comments
$tmp['content'] = removeHtmlComment($tmp['content']);
preg_match('/<head>(.*)<\/head>/is', $tmp['content'], $reg);
$head = $reg[1];
$objectpage->type_container = 'page';
$objectpage->pageurl = $pageurl;
if (empty($objectpage->pageurl))
{
$tmpdomain = getDomainFromURL($urltograb);
$objectpage->pageurl=$tmpdomain.'-home';
}
if (preg_match('/<title>(.*)<\/title>/ims', $head, $regtmp))
{
$objectpage->title = $regtmp[1];
}
if (preg_match('/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp))
{
if (empty($objectpage->title)) $objectpage->title = $regtmp[1]; // If title not found into <title>, we get it from <meta title>
}
if (preg_match('/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp))
{
$objectpage->description = $regtmp[1];
}
if (preg_match('/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp))
{
$objectpage->keywords = $regtmp[1];
}
if (preg_match('/<html\s+lang="([^"]+)"/ims', $tmp['content'], $regtmp))
{
$tmplang=explode('-', $regtmp[1]);
$objectpage->lang = $tmplang[0].($tmplang[1] ? '_'.strtoupper($tmplang[1]) : '');
}
$tmp['content'] = preg_replace('/\s*<meta name="generator"[^"]+content="([^"]+)"\s*\/?>/ims', '', $tmp['content']);
$objectpage->content = $tmp['content'];
$objectpage->content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $objectpage->content);
$objectpage->content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $objectpage->content);
$absoluteurlinaction=$urltograbdirwithoutslash;
// TODO Replace 'action="$urltograbdirwithoutslash' into action="/"
// TODO Replace 'action="$urltograbdirwithoutslash..."' into action="..."
// TODO Replace 'a href="$urltograbdirwithoutslash' into a href="/"
// TODO Replace 'a href="$urltograbdirwithoutslash..."' into a href="..."
// Now loop to fetch all css files. Include them inline into header of page
$objectpage->htmlheader = $tmp['content'];
$objectpage->htmlheader = preg_replace('/^.*<head(\s[^>]*)*>/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<\/head(\s[^>]*)*>.*$/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<base(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<meta http-equiv="content-type"([^>]*)*>\n*/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<meta name="robots"([^>]*)*>\n*/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<meta name="title"([^>]*)*>\n*/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<meta name="description"([^>]*)*>\n*/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<meta name="keywords"([^>]*)*>\n*/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<meta name="generator"([^>]*)*>\n*/ims', '', $objectpage->htmlheader);
//$objectpage->htmlheader = preg_replace('/<meta name="verify-v1[^>]*>\n*/ims', '', $objectpage->htmlheader);
//$objectpage->htmlheader = preg_replace('/<meta name="msvalidate.01[^>]*>\n*/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<title>[^<]*<\/title>\n*/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<link[^>]*rel="shortcut[^>]*>\n/ims', '', $objectpage->htmlheader);
// Now loop to fetch JS
$tmp = $objectpage->htmlheader;
preg_match_all('/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs);
foreach ($regs[0] as $key => $val)
{
dol_syslog("We will grab the resource found into script tag ".$regs[2][$key]);
$linkwithoutdomain = $regs[2][$key];
if (preg_match('/^\//', $regs[2][$key]))
{
$urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot
}
else
{
$urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file
}
//$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
if (preg_match('/^http/', $regs[2][$key]))
{
$urltograbbis = $regs[2][$key];
$linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
//$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
}
//print $domaintograb.' - '.$domaintograbbis.' - '.$urltograbdirwithoutslash.' - ';
//print $linkwithoutdomain.' - '.$urltograbbis."<br>\n";
// Test if this is an external URL of grabbed web site. If yes, we do not load resource
$domaintograb = getDomainFromURL($urltograbdirwithoutslash);
$domaintograbbis = getDomainFromURL($urltograbbis);
if ($domaintograb != $domaintograbbis) continue;
/*
$tmpgeturl = getURLContent($urltograbbis);
if ($tmpgeturl['curl_error_no'])
{
$error++;
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
$action='createcontainer';
}
elseif ($tmpgeturl['http_code'] != '200')
{
$error++;
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
$action='createcontainer';
}
else
{
dol_mkdir(dirname($filetosave));
$fp = fopen($filetosave, "w");
fputs($fp, $tmpgeturl['content']);
fclose($fp);
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
}
*/
//$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
$tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '', $tmp);
}
$objectpage->htmlheader = trim($tmp)."\n";
// Now loop to fetch CSS
$pagecsscontent = "\n".'<style>'."\n";
preg_match_all('/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs);
foreach ($regs[0] as $key => $val)
{
dol_syslog("We will grab the resource found into link tag ".$regs[2][$key]);
$linkwithoutdomain = $regs[2][$key];
if (preg_match('/^\//', $regs[2][$key]))
{
$urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot
}
else
{
$urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file
}
//$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
if (preg_match('/^http/', $regs[2][$key]))
{
$urltograbbis = $regs[2][$key];
$linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
//$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
}
//print $domaintograb.' - '.$domaintograbbis.' - '.$urltograbdirwithoutslash.' - ';
//print $linkwithoutdomain.' - '.$urltograbbis."<br>\n";
// Test if this is an external URL of grabbed web site. If yes, we do not load resource
$domaintograb = getDomainFromURL($urltograbdirwithoutslash);
$domaintograbbis = getDomainFromURL($urltograbbis);
if ($domaintograb != $domaintograbbis) continue;
$tmpgeturl = getURLContent($urltograbbis);
if ($tmpgeturl['curl_error_no'])
{
$error++;
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
$action='createcontainer';
}
elseif ($tmpgeturl['http_code'] != '200')
{
$error++;
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
$action='createcontainer';
}
else
{
//dol_mkdir(dirname($filetosave));
//$fp = fopen($filetosave, "w");
//fputs($fp, $tmpgeturl['content']);
//fclose($fp);
//if (! empty($conf->global->MAIN_UMASK))
// @chmod($file, octdec($conf->global->MAIN_UMASK));
// $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
$pagecsscontent.='/* Content of file '.$urltograbbis.' */'."\n";
getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl['content'], $action, 1, $grabimages, $grabimagesinto);
$pagecsscontent.=$tmpgeturl['content']."\n";
$objectpage->htmlheader = preg_replace('/'.preg_quote($regs[0][$key],'/').'\n*/ims', '', $objectpage->htmlheader);
}
}
$pagecsscontent.='</style>';
//var_dump($pagecsscontent);
//print dol_escape_htmltag($tmp);exit;
$objectpage->htmlheader .= trim($pagecsscontent)."\n";
// Now loop to fetch all images into page
$tmp = $objectpage->content;
getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto);
//print dol_escape_htmltag($tmp);exit;
$objectpage->content = $tmp;
$objectpage->grabbed_from = $urltograb;
} }
if (preg_match('/<html\s+lang="([^"]+)"/ims', $tmp['content'], $regtmp))
{
$tmplang=explode('-', $regtmp[1]);
$objectpage->lang = $tmplang[0].($tmplang[1] ? '_'.strtoupper($tmplang[1]) : '');
}
$objectpage->content = $tmp['content'];
$objectpage->content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $objectpage->content);
$objectpage->content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $objectpage->content);
$absoluteurlinaction=$urltograbdirwithoutslash;
// TODO Replace 'action="$urltograbdirwithoutslash' into action="/"
// TODO Replace 'action="$urltograbdirwithoutslash..."' into action="..."
// TODO Replace 'a href="$urltograbdirwithoutslash' into a href="/"
// TODO Replace 'a href="$urltograbdirwithoutslash..."' into a href="..."
// Now loop to fetch all css files. Include them inline into header of page
$objectpage->htmlheader = $tmp['content'];
$objectpage->htmlheader = preg_replace('/^.*<head(\s[^>]*)*>/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<\/head(\s[^>]*)*>.*$/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<base(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<meta name="robot(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<meta name="keywords(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<meta name="title(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<meta name="description(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<meta name="generator(\s[^>]*)*>\n*/ims', '', $objectpage->htmlheader);
//$objectpage->htmlheader = preg_replace('/<meta name="verify-v1[^>]*>\n*/ims', '', $objectpage->htmlheader);
//$objectpage->htmlheader = preg_replace('/<meta name="msvalidate.01[^>]*>\n*/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<title>[^<]*<\/title>\n*/ims', '', $objectpage->htmlheader);
$objectpage->htmlheader = preg_replace('/<link[^>]*rel="shortcut[^>]*>\n/ims', '', $objectpage->htmlheader);
// Now loop to fetch JS
$tmp = $objectpage->htmlheader;
preg_match_all('/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs);
foreach ($regs[0] as $key => $val)
{
dol_syslog("We will grab the resource found into script tag ".$regs[2][$key]);
$linkwithoutdomain = $regs[2][$key];
if (preg_match('/^\//', $regs[2][$key]))
{
$urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot
}
else
{
$urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file
}
//$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
if (preg_match('/^http/', $regs[2][$key]))
{
$urltograbbis = $regs[2][$key];
$linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
//$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
}
//print $domaintograb.' - '.$domaintograbbis.' - '.$urltograbdirwithoutslash.' - ';
//print $linkwithoutdomain.' - '.$urltograbbis."<br>\n";
// Test if this is an external URL of grabbed web site. If yes, we do not load resource
$domaintograb = getDomainFromURL($urltograbdirwithoutslash);
$domaintograbbis = getDomainFromURL($urltograbbis);
if ($domaintograb != $domaintograbbis) continue;
/*
$tmpgeturl = getURLContent($urltograbbis);
if ($tmpgeturl['curl_error_no'])
{
$error++;
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
$action='createcontainer';
}
elseif ($tmpgeturl['http_code'] != '200')
{
$error++;
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
$action='createcontainer';
}
else
{
dol_mkdir(dirname($filetosave));
$fp = fopen($filetosave, "w");
fputs($fp, $tmpgeturl['content']);
fclose($fp);
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
}
*/
//$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
$tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '', $tmp);
}
$objectpage->htmlheader = trim($tmp);
// Now loop to fetch CSS
$pagecsscontent = "\n".'<style>'."\n";
preg_match_all('/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs);
foreach ($regs[0] as $key => $val)
{
dol_syslog("We will grab the resource found into link tag ".$regs[2][$key]);
$linkwithoutdomain = $regs[2][$key];
if (preg_match('/^\//', $regs[2][$key]))
{
$urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot
}
else
{
$urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file
}
//$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
if (preg_match('/^http/', $regs[2][$key]))
{
$urltograbbis = $regs[2][$key];
$linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
//$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
}
//print $domaintograb.' - '.$domaintograbbis.' - '.$urltograbdirwithoutslash.' - ';
//print $linkwithoutdomain.' - '.$urltograbbis."<br>\n";
// Test if this is an external URL of grabbed web site. If yes, we do not load resource
$domaintograb = getDomainFromURL($urltograbdirwithoutslash);
$domaintograbbis = getDomainFromURL($urltograbbis);
if ($domaintograb != $domaintograbbis) continue;
$tmpgeturl = getURLContent($urltograbbis);
if ($tmpgeturl['curl_error_no'])
{
$error++;
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
$action='createcontainer';
}
elseif ($tmpgeturl['http_code'] != '200')
{
$error++;
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
$action='createcontainer';
}
else
{
//dol_mkdir(dirname($filetosave));
//$fp = fopen($filetosave, "w");
//fputs($fp, $tmpgeturl['content']);
//fclose($fp);
//if (! empty($conf->global->MAIN_UMASK))
// @chmod($file, octdec($conf->global->MAIN_UMASK));
// $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
$pagecsscontent.='/* Content of file '.$urltograbbis.' */'."\n";
getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl['content'], $action, 1);
$pagecsscontent.=$tmpgeturl['content']."\n";
$objectpage->htmlheader = preg_replace('/'.preg_quote($regs[0][$key],'/').'\n*/ims', '', $objectpage->htmlheader);
}
}
$pagecsscontent.='</style>'."\n";
//var_dump($pagecsscontent);
//print dol_escape_htmltag($tmp);exit;
$objectpage->htmlheader .= $pagecsscontent;
// Now loop to fetch all images
$tmp = $objectpage->content;
getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1);
//print dol_escape_htmltag($tmp);exit;
$objectpage->content = $tmp;
$objectpage->grabbed_from = $urltograb;
} }
} }
else else
@ -526,18 +551,21 @@ if ($action == 'addcontainer')
{ {
if (empty($objectpage->pageurl)) if (empty($objectpage->pageurl))
{ {
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors');
$error++; $error++;
$action='createcontainer'; $action='createcontainer';
} }
else if (! preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) else if (! preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl))
{ {
$langs->load("errors");
setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors');
$error++; $error++;
$action='createcontainer'; $action='createcontainer';
} }
if (empty($objectpage->title)) if (empty($objectpage->title))
{ {
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_TITLE")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_TITLE")), null, 'errors');
$error++; $error++;
$action='createcontainer'; $action='createcontainer';
@ -898,14 +926,16 @@ if ($action == 'setashome')
if ($action == 'updatemeta') if ($action == 'updatemeta')
{ {
$db->begin(); $db->begin();
$object->fetch(0, $website); $object->fetch(0, $website);
$objectpage->fk_website = $object->id; $objectpage->fk_website = $object->id;
// Check parameters // Check parameters
if (! preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) if (! preg_match('/^[a-z0-9\-\_]+$/i', GETPOST('WEBSITE_PAGENAME', 'alpha')))
{ {
$error++; $error++;
$langs->load("errors");
setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors');
$action='editmeta'; $action='editmeta';
} }
@ -914,7 +944,7 @@ if ($action == 'updatemeta')
if ($res <= 0) if ($res <= 0)
{ {
$error++; $error++;
dol_print_error($db, 'Page not found'); setEventMessages('Page not found '.$objectpage->error, $objectpage->errors, 'errors');
} }
if (! $error) if (! $error)
@ -927,7 +957,7 @@ if ($action == 'updatemeta')
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); $objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha');
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha'); $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha');
$objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09'); $objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09');
$objectpage->htmlheader = GETPOST('htmlheader', 'none'); $objectpage->htmlheader = trim(GETPOST('htmlheader', 'none'));
$res = $objectpage->update($user); $res = $objectpage->update($user);
if (! $res > 0) if (! $res > 0)
@ -935,67 +965,70 @@ if ($action == 'updatemeta')
$error++; $error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors'); setEventMessages($objectpage->error, $objectpage->errors, 'errors');
} }
}
if (! $error) if (! $error)
{
$db->commit();
}
else
{
$db->rollback();
}
if (! $error)
{
$filemaster=$pathofwebsite.'/master.inc.php';
$fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php';
$filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php';
dol_mkdir($pathofwebsite);
// Now generate the master.inc.php page
dol_syslog("We regenerate the master file (because we update meta)");
dol_delete_file($filemaster);
$mastercontent = '<?php'."\n";
$mastercontent.= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n";
$mastercontent.= "if (! defined('USEDOLIBARRSERVER')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
//$mastercontent.= "include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';"."\n";
//$mastercontent.= '$website = new WebSite($db)'."\n";
$mastercontent.= '?>'."\n";
$result = file_put_contents($filemaster, $mastercontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');
// Now generate the alias.php page
if (! empty($fileoldalias))
{ {
$db->commit(); dol_syslog("We regenerate alias page new name=".$filealias.", old name=".$fileoldalias);
dol_delete_file($fileoldalias);
}
$filemaster=$pathofwebsite.'/master.inc.php'; // Save page alias
$fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; $result=dolSavePageAlias($filealias, $object, $objectpage);
$filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php'; if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors');
dol_mkdir($pathofwebsite); // Save page of content
$result=dolSavePageContent($filetpl, $object, $objectpage);
if ($result)
// Now generate the master.inc.php page {
dol_syslog("We regenerate the master file (because we update meta)"); setEventMessages($langs->trans("Saved"), null, 'mesgs');
dol_delete_file($filemaster); //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
//exit;
$mastercontent = '<?php'."\n";
$mastercontent.= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n";
$mastercontent.= "if (! defined('USEDOLIBARRSERVER')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
//$mastercontent.= "include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';"."\n";
//$mastercontent.= '$website = new WebSite($db)'."\n";
$mastercontent.= '?>'."\n";
$result = file_put_contents($filemaster, $mastercontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');
// Now generate the alias.php page
if (! empty($fileoldalias))
{
dol_syslog("We regenerate alias page new name=".$filealias.", old name=".$fileoldalias);
dol_delete_file($fileoldalias);
}
// Save page alias
$result=dolSavePageAlias($filealias, $object, $objectpage);
if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors');
// Save page of content
$result=dolSavePageContent($filetpl, $object, $objectpage);
if ($result)
{
setEventMessages($langs->trans("Saved"), null, 'mesgs');
//header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
//exit;
}
else
{
setEventMessages('Failed to write file '.$filetpl, null, 'errors');
//header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
//exit;
}
$action='preview';
} }
else else
{ {
$db->rollback(); setEventMessages('Failed to write file '.$filetpl, null, 'errors');
//header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
//exit;
} }
$action='preview';
} }
} }
@ -1895,27 +1928,30 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '<!-- Edit or create page/container -->'."\n"; print '<!-- Edit or create page/container -->'."\n";
//print '<div class="fichecenter">'; //print '<div class="fichecenter">';
if ($conf->global->MAIN_FEATURES_LEVEL >= 1) if ($action == 'createcontainer')
{ {
if ($action == 'createcontainer') print '<br>';
{
print '<br>';
print ' * '.$langs->trans("CreateByFetchingExternalPage").'<br><hr>'; print ' * '.$langs->trans("CreateByFetchingExternalPage").'<br><hr>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans("URL"); print $langs->trans("URL");
print '</td><td>'; print '</td><td>';
print '<input class="flat minwidth300" type="text" name="externalurl" value="'.dol_escape_htmltag(GETPOST('externalurl','alpha')).'" placeholder="https://externalsite/pagetofetch"> '; print '<input class="flat minwidth300" type="text" name="externalurl" value="'.dol_escape_htmltag(GETPOST('externalurl','alpha')).'" placeholder="https://externalsite/pagetofetch"> ';
print '<input class="button" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans("FetchAndCreate")).'">'; print '<input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> '.$langs->trans("GrabImagesInto");
print '<br><br>'.info_admin($langs->trans("OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0, '1'); print ' ';
print '</td></tr>'; print $langs->trans("ImagesShouldBeSavedInto").' ';
print '</table>'; $arraygrabimagesinto=array('root'=>$langs->trans("WebsiteRootOfImages"), 'subpage'=>$langs->trans("SubdirOfPage"));
print $form->selectarray('grabimagesinto', $arraygrabimagesinto, GETPOSTISSET('grabimagesinto')?GETPOST('grabimagesinto'):'root');
print '<br>';
print '<input class="button" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans("FetchAndCreate")).'">';
print '<br>'.info_admin($langs->trans("OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0, '1');
print '</td></tr>';
print '</table>';
print '<br>'; print '<br>';
print ' * '.$langs->trans("OrEnterPageInfoManually").'<br><hr>'; print ' * '.$langs->trans("OrEnterPageInfoManually").'<br><hr>';
}
} }
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';