From e85921c82fe4c27b19efdb588cdcbda2ba716587 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 11:44:45 +0200 Subject: [PATCH 01/14] Start to introduce sftp --- htdocs/ftp/index.php | 209 +++++++++++++++++++++++++----------- htdocs/langs/en_US/ftp.lang | 2 + 2 files changed, 151 insertions(+), 60 deletions(-) diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 4da37cde779..19c4b50dc7d 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -38,12 +38,13 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'ftp',''); // Get parameters -$action = isset($_GET["action"])?$_GET["action"]:$_POST['action']; -$section=isset($_GET["section"])?$_GET["section"]:$_POST['section']; +$action=GETPOST('action'); +$section=GETPOST('section'); if (! $section) $section='/'; $numero_ftp = GETPOST("numero_ftp"); -if (! $numero_ftp) $numero_ftp=1; -$file=isset($_GET["file"])?$_GET["file"]:$_POST['file']; +/* if (! $numero_ftp) $numero_ftp=1; */ +$file=GETPOST("file"); +$confirm=GETPOST('confirm'); $upload_dir = $conf->ftp->dir_temp; $download_dir = $conf->ftp->dir_temp; @@ -71,18 +72,19 @@ $ftp_user=$conf->global->$s_ftp_user; $ftp_password=$conf->global->$s_ftp_password; $ftp_passive=$conf->global->$s_ftp_passive; +// For result on connection +$ok=0; $conn_id=null; // FTP connection ID +$mesg=''; -/******************************************************************* +/* * ACTIONS - * - * Put here all code to do according to value of "action" parameter - ********************************************************************/ + */ -// Envoie fichier -if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) +// Submit file +if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -127,7 +129,7 @@ if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) } // Action ajout d'un rep -if ($_POST["action"] == 'add' && $user->rights->ftp->setup) +if ($action == 'add' && $user->rights->ftp->setup) { $ecmdir->ref = $_POST["ref"]; $ecmdir->label = $_POST["label"]; @@ -148,7 +150,7 @@ if ($_POST["action"] == 'add' && $user->rights->ftp->setup) } // Remove file -if ($_REQUEST['action'] == 'confirm_deletefile' && $_REQUEST['confirm'] == 'yes') +if ($action == 'confirm_deletefile' && $_REQUEST['confirm'] == 'yes') { // set up a connection or die if (! $conn_id) @@ -246,7 +248,7 @@ if ($_POST["const"] && $_POST["delete"] && $_POST["delete"] == $langs->trans("De } // Remove directory -if ($_REQUEST['action'] == 'confirm_deletesection' && $_REQUEST['confirm'] == 'yes') +if ($action == 'confirm_deletesection' && $confirm == 'yes') { // set up a connection or die if (! $conn_id) @@ -286,7 +288,7 @@ if ($_REQUEST['action'] == 'confirm_deletesection' && $_REQUEST['confirm'] == 'y } // Download directory -if ($_REQUEST['action'] == 'download') +if ($action == 'download') { // set up a connection or die if (! $conn_id) @@ -339,8 +341,7 @@ if ($_REQUEST['action'] == 'download') } else { - //TODO: Translate - setEventMessage('Failed to get file '.$remotefile, 'errors'); + setEventMessages($langs->trans('FailedToGetFile',$remotefile), null, 'errors'); } } @@ -355,11 +356,9 @@ if ($_REQUEST['action'] == 'download') -/******************************************************************* - * PAGE - * - * Put here all code to do according to value of "action" parameter - ********************************************************************/ +/* + * View + */ llxHeader(); @@ -383,10 +382,7 @@ $formfile=new FormFile($db); $userstatic = new User($db); - -//*********************** // List -//*********************** print_fiche_titre($langs->trans("FTPArea")); print $langs->trans("FTPAreaDesc")."
"; @@ -397,18 +393,17 @@ if (! function_exists('ftp_connect')) } else { - if (! empty($ftp_server)) + if (! empty($ftp_server)) { - // Confirm remove file - if ($_GET['action'] == 'delete') + if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'§ion='.urlencode($_REQUEST["section"]).'&file='.urlencode($_GET["file"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile','','',1); } // Confirmation de la suppression d'une ligne categorie - if ($_GET['action'] == 'delete_section') + if ($action == 'delete_section') { print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'§ion='.urlencode($_REQUEST["section"]).'&file='.urlencode($_GET["file"]), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection','','',1); @@ -417,8 +412,9 @@ else print $langs->trans("Server").': '.$ftp_server.'
'; print $langs->trans("Port").': '.$ftp_port.' '.($ftp_passive?"(Passive)":"(Active)").'
'; print $langs->trans("User").': '.$ftp_user.'
'; - - print $langs->trans("Directory").': '; + print $langs->trans("FTPs (FTP over SSH)").': '.yn($conf->global->FTP_CONNECT_WITH_SSL).'
'; + print $langs->trans("SFTP (FTP as a subsytem of SSH)").': '.yn($conf->global->FTP_CONNECT_WITH_SFTP).'
'; + print $langs->trans("Directory").': '; $sectionarray=preg_split('|[\/]|',$section); // For / $newsection='/'; @@ -465,24 +461,43 @@ else print ''."\n"; // set up a connection or die - if (! $conn_id) + if (empty($conn_id)) { $resultarray=dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $section, $ftp_passive); + $conn_id=$resultarray['conn_id']; $ok=$resultarray['ok']; $mesg=$resultarray['mesg']; - } if ($ok) { //$type = ftp_systype($conn_id); - $newsectioniso=utf8_decode($section); - $buff = ftp_rawlist($conn_id, $newsectioniso); - $contents = ftp_nlist($conn_id, $newsectioniso); // Sometimes rawlist fails but never nlist - //var_dump($contents); - //var_dump($buff); + $newsection=$section; + $newsectioniso=utf8_decode($section); + //$newsection='/home'; + + // List content of directory ($newsection = '/', '/home', ...) + if (! empty($conf->global->FTP_CONNECT_WITH_SFTP)) + { + if ($newsection == '/') $newsection='/./'; # workaround for bug https://bugs.php.net/bug.php?id=64169 + //$dirHandle = opendir("ssh2.sftp://$conn_id".$newsection); + //var_dump($dirHandle); + $contents = scandir('ssh2.sftp://' . $conn_id . $newsection); + $buff=array(); + foreach($contents as $i => $key) + { + $buff[$i]="---------- - root root 1234 Aug 01 2000 ".$key; + } + } + else + { + $buff = ftp_rawlist($conn_id, $newsectioniso); + $contents = ftp_nlist($conn_id, $newsectioniso); // Sometimes rawlist fails but never nlist + //var_dump($contents); + //var_dump($buff); + } $nboflines=count($contents); $var=true; @@ -590,9 +605,16 @@ else } - print ""; + + if (! $ok) + { + print $mesg.'
'."\n"; + setEventMessages($mesg, null, 'errors'); + } + + // Actions /* if ($user->rights->ftp->write && ! empty($section)) @@ -611,20 +633,43 @@ else } else { - print $langs->trans("SetupOfFTPClientModuleNotComplete"); + $s_ftp_server='FTP_SERVER_1'; + if (empty($s_ftp_server)) + { + print $langs->trans("SetupOfFTPClientModuleNotComplete"); + } + else + { + print $langs->trans("ChooseAFTPEntryIntoMenu"); + } } } print '
'; // Close FTP connection -if ($conn_id) ftp_close($conn_id); - -// End of page -$db->close(); +if ($conn_id) +{ + if (! empty($conf->global->FTP_CONNECT_WITH_SFTP)) + { + + } + else if (! empty($conf->global->FTP_CONNECT_WITH_SSL)) + { + ftp_close($conn_id); + } + else + { + ftp_close($conn_id); + } +} + llxFooter(); +$db->close(); + + /** * Connect to FTP server @@ -642,46 +687,90 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect global $langs, $conf; $ok=1; - + $conn_id=null; + if (! is_numeric($ftp_port)) { - $mesg=$langs->trans("FailedToConnectToFTPServer",$ftp_server,$ftp_port); + $mesg=$langs->transnoentitiesnoconv("FailedToConnectToFTPServer",$ftp_server,$ftp_port); $ok=0; } if ($ok) { $connecttimeout=(empty($conf->global->FTP_CONNECT_TIMEOUT)?40:$conf->global->FTP_CONNECT_TIMEOUT); - if (! empty($conf->global->FTP_CONNECT_WITH_SSL)) $conn_id = ftp_ssl_connect($ftp_server, $ftp_port, $connecttimeout); - else $conn_id = ftp_connect($ftp_server, $ftp_port, $connecttimeout); - if ($conn_id) + if (! empty($conf->global->FTP_CONNECT_WITH_SFTP)) + { + dol_syslog('Try to connect with ssh2_ftp'); + $tmp_conn_id = ssh2_connect($ftp_server, $ftp_port); + } + else if (! empty($conf->global->FTP_CONNECT_WITH_SSL)) + { + dol_syslog('Try to connect with ftp_ssl_connect'); + $conn_id = ftp_ssl_connect($ftp_server, $ftp_port, $connecttimeout); + } + else + { + dol_syslog('Try to connect with ftp_connect'); + $conn_id = ftp_connect($ftp_server, $ftp_port, $connecttimeout); + } + if ($conn_id || $tmp_conn_id) { if ($ftp_user) { - if (ftp_login($conn_id, $ftp_user, $ftp_password)) + if (! empty($conf->global->FTP_CONNECT_WITH_SFTP)) { - // Turn on passive mode transfers (must be after a successful login - if ($ftp_passive) ftp_pasv($conn_id, true); - - // Change the dir - $newsectioniso=utf8_decode($section); - ftp_chdir($conn_id, $newsectioniso); - } + if (ssh2_auth_password($tmp_conn_id, $ftp_user, $ftp_password)) + { + // Turn on passive mode transfers (must be after a successful login + //if ($ftp_passive) ftp_pasv($conn_id, true); + + // Change the dir + $newsectioniso=utf8_decode($section); + //ftp_chdir($conn_id, $newsectioniso); + $conn_id = ssh2_sftp($tmp_conn_id); + if (! $conn_id) + { + $mesg=$langs->transnoentitiesnoconv("FailedToConnectToSFTPAfterSSHAuthentication"); + $ok=0; + $error++; + } + } + else + { + $mesg=$langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials"); + $ok=0; + $error++; + } + } else { - $mesg=$langs->trans("FailedToConnectToFTPServerWithCredentials"); - $ok=0; + if (ftp_login($conn_id, $ftp_user, $ftp_password)) + { + // Turn on passive mode transfers (must be after a successful login + if ($ftp_passive) ftp_pasv($conn_id, true); + + // Change the dir + $newsectioniso=utf8_decode($section); + ftp_chdir($conn_id, $newsectioniso); + } + else + { + $mesg=$langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials"); + $ok=0; + $error++; + } } } } else { - $mesg=$langs->trans("FailedToConnectToFTPServer",$ftp_server,$ftp_port); + dol_syslog('FailedToConnectToFTPServer '.$ftp_server.' '.$ftp_port, LOG_ERR); + $mesg=$langs->transnoentitiesnoconv("FailedToConnectToFTPServer",$ftp_server,$ftp_port); $ok=0; } } - $arrayresult=array('conn_id'=>$conn_id, 'ok'=>$ok, 'mesg'=>$mesg); + $arrayresult=array('conn_id'=>$conn_id, 'ok'=>$ok, 'mesg'=>$mesg, 'curdir'=>$section, 'curdiriso'=>$newsectioniso); return $arrayresult; } diff --git a/htdocs/langs/en_US/ftp.lang b/htdocs/langs/en_US/ftp.lang index 9984ce689ee..d6b9d2ca070 100644 --- a/htdocs/langs/en_US/ftp.lang +++ b/htdocs/langs/en_US/ftp.lang @@ -10,3 +10,5 @@ FailedToConnectToFTPServerWithCredentials=Failed to login to FTP server with def FTPFailedToRemoveFile=Failed to remove file %s. FTPFailedToRemoveDir=Failed to remove directory %s (Check permissions and that directory is empty). FTPPassiveMode=Passive mode +ChooseAFTPEntryIntoMenu=Choose a FTP entry into menu... +FailedToGetFile=Failed to get files %s \ No newline at end of file From f3c71a9a5a77532af868ad69b85b27742d9cb0d9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 12:09:42 +0200 Subject: [PATCH 02/14] Dolibarr must not contains autoload feature. The developer and user must decide which lib is used and it must not be a random feature that take a library "randomly" (first one found is same a randomly found). By default, library embedded of dolibarr must be used. If we want to use another one, an option to set the path of external libray must be available. --- .../core/modules/syslog/mod_syslog_sentry.php | 1 - htdocs/includes/autoload.php | 7 - htdocs/includes/composer/ClassLoader.php | 413 ------------------ htdocs/includes/composer/LICENSE | 21 - .../includes/composer/autoload_classmap.php | 24 - .../includes/composer/autoload_namespaces.php | 14 - htdocs/includes/composer/autoload_psr4.php | 9 - htdocs/includes/composer/autoload_real.php | 50 --- htdocs/includes/composer/installed.json | 400 ----------------- 9 files changed, 939 deletions(-) delete mode 100644 htdocs/includes/autoload.php delete mode 100644 htdocs/includes/composer/ClassLoader.php delete mode 100644 htdocs/includes/composer/LICENSE delete mode 100644 htdocs/includes/composer/autoload_classmap.php delete mode 100644 htdocs/includes/composer/autoload_namespaces.php delete mode 100644 htdocs/includes/composer/autoload_psr4.php delete mode 100644 htdocs/includes/composer/autoload_real.php delete mode 100644 htdocs/includes/composer/installed.json diff --git a/htdocs/core/modules/syslog/mod_syslog_sentry.php b/htdocs/core/modules/syslog/mod_syslog_sentry.php index 3625405aeaa..5edcca9e03e 100644 --- a/htdocs/core/modules/syslog/mod_syslog_sentry.php +++ b/htdocs/core/modules/syslog/mod_syslog_sentry.php @@ -17,7 +17,6 @@ * along with this program. If not, see . */ -require_once DOL_DOCUMENT_ROOT . '/includes/autoload.php'; require_once DOL_DOCUMENT_ROOT . '/core/modules/syslog/logHandler.php'; /** diff --git a/htdocs/includes/autoload.php b/htdocs/includes/autoload.php deleted file mode 100644 index be5223ff062..00000000000 --- a/htdocs/includes/autoload.php +++ /dev/null @@ -1,7 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Autoload; - -/** - * ClassLoader implements a PSR-0 class loader - * - * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md - * - * $loader = new \Composer\Autoload\ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * This class is loosely based on the Symfony UniversalClassLoader. - * - * @author Fabien Potencier - * @author Jordi Boggiano - */ -class ClassLoader -{ - // PSR-4 - private $prefixLengthsPsr4 = array(); - private $prefixDirsPsr4 = array(); - private $fallbackDirsPsr4 = array(); - - // PSR-0 - private $prefixesPsr0 = array(); - private $fallbackDirsPsr0 = array(); - - private $useIncludePath = false; - private $classMap = array(); - - private $classMapAuthoritative = false; - - public function getPrefixes() - { - if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); - } - - return array(); - } - - public function getPrefixesPsr4() - { - return $this->prefixDirsPsr4; - } - - public function getFallbackDirs() - { - return $this->fallbackDirsPsr0; - } - - public function getFallbackDirsPsr4() - { - return $this->fallbackDirsPsr4; - } - - public function getClassMap() - { - return $this->classMap; - } - - /** - * @param array $classMap Class to filename map - */ - public function addClassMap(array $classMap) - { - if ($this->classMap) { - $this->classMap = array_merge($this->classMap, $classMap); - } else { - $this->classMap = $classMap; - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, either - * appending or prepending to the ones previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - */ - public function add($prefix, $paths, $prepend = false) - { - if (!$prefix) { - if ($prepend) { - $this->fallbackDirsPsr0 = array_merge( - (array) $paths, - $this->fallbackDirsPsr0 - ); - } else { - $this->fallbackDirsPsr0 = array_merge( - $this->fallbackDirsPsr0, - (array) $paths - ); - } - - return; - } - - $first = $prefix[0]; - if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; - - return; - } - if ($prepend) { - $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, - $this->prefixesPsr0[$first][$prefix] - ); - } else { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $this->prefixesPsr0[$first][$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, either - * appending or prepending to the ones previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-0 base directories - * @param bool $prepend Whether to prepend the directories - * - * @throws \InvalidArgumentException - */ - public function addPsr4($prefix, $paths, $prepend = false) - { - if (!$prefix) { - // Register directories for the root namespace. - if ($prepend) { - $this->fallbackDirsPsr4 = array_merge( - (array) $paths, - $this->fallbackDirsPsr4 - ); - } else { - $this->fallbackDirsPsr4 = array_merge( - $this->fallbackDirsPsr4, - (array) $paths - ); - } - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { - // Register directories for a new namespace. - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } elseif ($prepend) { - // Prepend directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, - $this->prefixDirsPsr4[$prefix] - ); - } else { - // Append directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $this->prefixDirsPsr4[$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, - * replacing any others previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 base directories - */ - public function set($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr0 = (array) $paths; - } else { - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, - * replacing any others previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * - * @throws \InvalidArgumentException - */ - public function setPsr4($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr4 = (array) $paths; - } else { - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include path for class files. - * - * @param bool $useIncludePath - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return bool - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Turns off searching the prefix and fallback directories for classes - * that have not been registered with the class map. - * - * @param bool $classMapAuthoritative - */ - public function setClassMapAuthoritative($classMapAuthoritative) - { - $this->classMapAuthoritative = $classMapAuthoritative; - } - - /** - * Should class lookup fail if not found in the current class map? - * - * @return bool - */ - public function isClassMapAuthoritative() - { - return $this->classMapAuthoritative; - } - - /** - * Registers this instance as an autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - } - - /** - * Unregisters this instance as an autoloader. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return bool|null True if loaded, null otherwise - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - includeFile($file); - - return true; - } - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|false The path if found, false otherwise - */ - public function findFile($class) - { - // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 - if ('\\' == $class[0]) { - $class = substr($class, 1); - } - - // class map lookup - if (isset($this->classMap[$class])) { - return $this->classMap[$class]; - } - if ($this->classMapAuthoritative) { - return false; - } - - $file = $this->findFileWithExtension($class, '.php'); - - // Search for Hack files if we are running on HHVM - if ($file === null && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); - } - - if ($file === null) { - // Remember that this class does not exist. - return $this->classMap[$class] = false; - } - - return $file; - } - - private function findFileWithExtension($class, $ext) - { - // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; - - $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { - if (0 === strpos($class, $prefix)) { - foreach ($this->prefixDirsPsr4[$prefix] as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { - return $file; - } - } - } - } - } - - // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; - } - } - - // PSR-0 lookup - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); - } else { - // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; - } - - if (isset($this->prefixesPsr0[$first])) { - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - } - } - } - - // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - - // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; - } - } -} - -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - */ -function includeFile($file) -{ - include $file; -} diff --git a/htdocs/includes/composer/LICENSE b/htdocs/includes/composer/LICENSE deleted file mode 100644 index c8d57af8b27..00000000000 --- a/htdocs/includes/composer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - -Copyright (c) 2015 Nils Adermann, Jordi Boggiano - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - diff --git a/htdocs/includes/composer/autoload_classmap.php b/htdocs/includes/composer/autoload_classmap.php deleted file mode 100644 index 0d1abcbe041..00000000000 --- a/htdocs/includes/composer/autoload_classmap.php +++ /dev/null @@ -1,24 +0,0 @@ - $vendorDir . '/tecnick.com/tcpdf/include/barcodes/datamatrix.php', - 'Mobile_Detect' => $vendorDir . '/mobiledetect/mobiledetectlib/Mobile_Detect.php', - 'PDF417' => $vendorDir . '/tecnick.com/tcpdf/include/barcodes/pdf417.php', - 'QRcode' => $vendorDir . '/tecnick.com/tcpdf/include/barcodes/qrcode.php', - 'TCPDF' => $vendorDir . '/tecnick.com/tcpdf/tcpdf.php', - 'TCPDF2DBarcode' => $vendorDir . '/tecnick.com/tcpdf/tcpdf_barcodes_2d.php', - 'TCPDFBarcode' => $vendorDir . '/tecnick.com/tcpdf/tcpdf_barcodes_1d.php', - 'TCPDF_COLORS' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_colors.php', - 'TCPDF_FILTERS' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_filters.php', - 'TCPDF_FONTS' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_fonts.php', - 'TCPDF_FONT_DATA' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_font_data.php', - 'TCPDF_IMAGES' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_images.php', - 'TCPDF_IMPORT' => $vendorDir . '/tecnick.com/tcpdf/tcpdf_import.php', - 'TCPDF_PARSER' => $vendorDir . '/tecnick.com/tcpdf/tcpdf_parser.php', - 'TCPDF_STATIC' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_static.php', -); diff --git a/htdocs/includes/composer/autoload_namespaces.php b/htdocs/includes/composer/autoload_namespaces.php deleted file mode 100644 index 27e1e79f483..00000000000 --- a/htdocs/includes/composer/autoload_namespaces.php +++ /dev/null @@ -1,14 +0,0 @@ - array($vendorDir . '/raven/raven/lib'), - 'PHPExcel' => array($vendorDir . '/phpoffice/phpexcel/Classes'), - 'Luracast\\Restler' => array($vendorDir . '/restler/framework'), - 'Detection' => array($vendorDir . '/mobiledetect/mobiledetectlib/namespaced'), - 'ChromePhp' => array($vendorDir . '/ccampbell/chromephp'), -); diff --git a/htdocs/includes/composer/autoload_psr4.php b/htdocs/includes/composer/autoload_psr4.php deleted file mode 100644 index 80607ee9774..00000000000 --- a/htdocs/includes/composer/autoload_psr4.php +++ /dev/null @@ -1,9 +0,0 @@ - $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - - $loader->register(true); - - return $loader; - } -} - -function composerRequire8837e679482b97ebb428daf0298d9535($file) -{ - require $file; -} diff --git a/htdocs/includes/composer/installed.json b/htdocs/includes/composer/installed.json deleted file mode 100644 index 88bf8b37f43..00000000000 --- a/htdocs/includes/composer/installed.json +++ /dev/null @@ -1,400 +0,0 @@ -[ - { - "name": "ccampbell/chromephp", - "version": "4.1.0", - "version_normalized": "4.1.0.0", - "source": { - "type": "git", - "url": "https://github.com/ccampbell/chromephp.git", - "reference": "c3c297615d48ae5b2a86a82311152d1ed095fcef" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ccampbell/chromephp/zipball/c3c297615d48ae5b2a86a82311152d1ed095fcef", - "reference": "c3c297615d48ae5b2a86a82311152d1ed095fcef", - "shasum": "" - }, - "require": { - "php": ">=5.0.0" - }, - "time": "2013-06-26 03:44:33", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "ChromePhp": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Craig Campbell", - "email": "iamcraigcampbell@gmail.com", - "homepage": "http://craig.is", - "role": "Developer" - } - ], - "description": "Log variables to the Chrome console (via Chrome Logger Google Chrome extension).", - "homepage": "http://github.com/ccampbell/chromephp", - "keywords": [ - "log", - "logging" - ] - }, - { - "name": "ckeditor/ckeditor", - "version": "4.3.3", - "version_normalized": "4.3.3.0", - "source": { - "type": "git", - "url": "https://github.com/ckeditor/ckeditor-releases.git", - "reference": "0068dd540ce8bf1815abb7b5455c55354bc56334" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ckeditor/ckeditor-releases/zipball/0068dd540ce8bf1815abb7b5455c55354bc56334", - "reference": "0068dd540ce8bf1815abb7b5455c55354bc56334", - "shasum": "" - }, - "time": "2014-02-26 15:34:37", - "type": "library", - "installation-source": "dist", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+", - "LGPL-2.1+", - "MPL-1.1+" - ], - "authors": [ - { - "name": "CKSource - Frederico Knabben", - "homepage": "http://cksource.com" - } - ], - "description": "JavaScript WYSIWYG web text editor.", - "homepage": "http://ckeditor.com", - "keywords": [ - "CKEditor", - "editor", - "fckeditor", - "html", - "javascript", - "richtext", - "text", - "wysiwyg" - ] - }, - { - "name": "mobiledetect/mobiledetectlib", - "version": "2.8.3", - "version_normalized": "2.8.3.0", - "source": { - "type": "git", - "url": "https://github.com/serbanghita/Mobile-Detect.git", - "reference": "f5753e4b90daffe50c902e99df5ce3c58fca3fee" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/serbanghita/Mobile-Detect/zipball/f5753e4b90daffe50c902e99df5ce3c58fca3fee", - "reference": "f5753e4b90daffe50c902e99df5ce3c58fca3fee", - "shasum": "" - }, - "require": { - "php": ">=5.0.0" - }, - "require-dev": { - "phpunit/phpunit": "*" - }, - "time": "2014-07-10 20:00:25", - "type": "library", - "installation-source": "dist", - "autoload": { - "classmap": [ - "Mobile_Detect.php" - ], - "psr-0": { - "Detection": "namespaced/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Serban Ghita", - "email": "serbanghita@gmail.com", - "homepage": "http://ghita.org", - "role": "Developer" - } - ], - "description": "Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.", - "homepage": "https://github.com/serbanghita/Mobile-Detect", - "keywords": [ - "detect mobile devices", - "mobile", - "mobile detect", - "mobile detector", - "php mobile detect" - ] - }, - { - "name": "phpoffice/phpexcel", - "version": "1.8.0", - "version_normalized": "1.8.0.0", - "source": { - "type": "git", - "url": "https://github.com/PHPOffice/PHPExcel.git", - "reference": "e69a5e4d0ffa7fb6f171859e0a04346e580df30b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/e69a5e4d0ffa7fb6f171859e0a04346e580df30b", - "reference": "e69a5e4d0ffa7fb6f171859e0a04346e580df30b", - "shasum": "" - }, - "require": { - "ext-xml": "*", - "ext-xmlwriter": "*", - "php": ">=5.2.0" - }, - "time": "2014-03-02 15:22:49", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "PHPExcel": "Classes/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL" - ], - "authors": [ - { - "name": "Maarten Balliauw", - "homepage": "http://blog.maartenballiauw.be" - }, - { - "name": "Mark Baker" - }, - { - "name": "Franck Lefevre", - "homepage": "http://blog.rootslabs.net" - }, - { - "name": "Erik Tilt" - } - ], - "description": "PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", - "homepage": "http://phpexcel.codeplex.com", - "keywords": [ - "OpenXML", - "excel", - "php", - "spreadsheet", - "xls", - "xlsx" - ] - }, - { - "name": "restler/framework", - "version": "3.0.0", - "version_normalized": "3.0.0.0", - "target-dir": "Luracast/Restler", - "source": { - "type": "git", - "url": "https://github.com/Luracast/Restler-Framework.git", - "reference": "6ee10b3e5dbc6376916fed55ec2340a37cce436b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Luracast/Restler-Framework/zipball/6ee10b3e5dbc6376916fed55ec2340a37cce436b", - "reference": "6ee10b3e5dbc6376916fed55ec2340a37cce436b", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "replace": { - "luracast/restler": "3.*" - }, - "require-dev": { - "bshaffer/oauth2-server-php": "v1.0", - "luracast/explorer": "*", - "mustache/mustache": "dev-master", - "rodneyrehm/plist": "dev-master", - "symfony/yaml": "*", - "twig/twig": "v1.13.0", - "zendframework/zendamf": "dev-master" - }, - "suggest": { - "bshaffer/oauth2-server-php": "Restler can provide OAuth2 authentication using this library (see require-dev for details)", - "luracast/explorer": "Restler's very own api explorer (see require-dev for details)", - "mustache/mustache": "Restler can render HtmlView using mustache/handlebar templates (see require-dev for details)", - "rodneyrehm/plist": "Restler supports tho Apple plist xml format (see require-dev for details)", - "symfony/yaml": "Restler can produce content in yaml format as well (see require-dev for details)", - "twig/twig": "Restler can render HtmlView using twig templates (see require-dev for details)", - "zendframework/zendamf": "Support for the amf document format (see require-dev for details)" - }, - "time": "2015-08-04 07:52:49", - "type": "library", - "extra": { - "branch-alias": { - "master": "v3.0.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Luracast\\Restler": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-2.1" - ], - "authors": [ - { - "name": "Luracast", - "email": "arul@luracast.com" - }, - { - "name": "Nick nickl- Lombard", - "email": "github@jigsoft.co.za" - } - ], - "description": "Just the Restler Framework without the tests and examples", - "homepage": "http://luracast.com/products/restler/", - "keywords": [ - "api", - "framework", - "rest", - "server" - ] - }, - { - "name": "tecnick.com/tcpdf", - "version": "6.2.6", - "version_normalized": "6.2.6.0", - "source": { - "type": "git", - "url": "https://github.com/tecnickcom/TCPDF.git", - "reference": "a2e8f5b505a7a14a4ed960313c4baf699fd1f4bb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/a2e8f5b505a7a14a4ed960313c4baf699fd1f4bb", - "reference": "a2e8f5b505a7a14a4ed960313c4baf699fd1f4bb", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "time": "2015-01-28 18:51:40", - "type": "library", - "installation-source": "dist", - "autoload": { - "classmap": [ - "fonts", - "config", - "include", - "tcpdf.php", - "tcpdf_parser.php", - "tcpdf_import.php", - "tcpdf_barcodes_1d.php", - "tcpdf_barcodes_2d.php", - "include/tcpdf_colors.php", - "include/tcpdf_filters.php", - "include/tcpdf_font_data.php", - "include/tcpdf_fonts.php", - "include/tcpdf_images.php", - "include/tcpdf_static.php", - "include/barcodes/datamatrix.php", - "include/barcodes/pdf417.php", - "include/barcodes/qrcode.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPLv3" - ], - "authors": [ - { - "name": "Nicola Asuni", - "email": "info@tecnick.com", - "homepage": "http://nicolaasuni.tecnick.com" - } - ], - "description": "TCPDF is a PHP class for generating PDF documents and barcodes.", - "homepage": "http://www.tcpdf.org/", - "keywords": [ - "PDFD32000-2008", - "TCPDF", - "barcodes", - "datamatrix", - "pdf", - "pdf417", - "qrcode" - ] - }, - { - "name": "raven/raven", - "version": "0.12.1", - "version_normalized": "0.12.1.0", - "source": { - "type": "git", - "url": "https://github.com/getsentry/raven-php.git", - "reference": "b325984c792ff89f985b73da9a3ad8ed8b520bca" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/getsentry/raven-php/zipball/b325984c792ff89f985b73da9a3ad8ed8b520bca", - "reference": "b325984c792ff89f985b73da9a3ad8ed8b520bca", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "php": ">=5.2.4" - }, - "require-dev": { - "fabpot/php-cs-fixer": "^1.8.0", - "phpunit/phpunit": "^4.6.6" - }, - "time": "2015-08-25 22:38:46", - "bin": [ - "bin/raven" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.12.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Raven_": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD" - ], - "authors": [ - { - "name": "David Cramer", - "email": "dcramer@gmail.com" - } - ], - "description": "A PHP client for Sentry (http://getsentry.com)", - "homepage": "http://getsentry.com", - "keywords": [ - "log", - "logging" - ] - } -] From 28c62fb214c215262f9fcaeca1836948ab0df41f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 12:21:26 +0200 Subject: [PATCH 03/14] Introduce a function to return a warning by loggers. --- htdocs/admin/syslog.php | 6 ++++- htdocs/core/modules/syslog/logHandler.php | 14 ++++++++++-- .../modules/syslog/logHandlerInterface.php | 7 ++++++ .../modules/syslog/mod_syslog_chromephp.php | 22 +++++++++++++++---- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 7d713760382..44002dc4c74 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -225,7 +225,11 @@ foreach ($syslogModules as $moduleName) print ''; if ($module->getInfo()) { - print $form->textwithpicto('', $module->getInfo()); + print $form->textwithpicto('', $module->getInfo(), 1, 'help'); + } + if ($module->getWarning()) + { + print $form->textwithpicto('', $module->getWarning(), 1, 'warning'); } print ''; print "\n"; diff --git a/htdocs/core/modules/syslog/logHandler.php b/htdocs/core/modules/syslog/logHandler.php index 1701ca2bdce..fa013f4b083 100644 --- a/htdocs/core/modules/syslog/logHandler.php +++ b/htdocs/core/modules/syslog/logHandler.php @@ -28,13 +28,23 @@ class LogHandler /** * Content of the info tooltip. * - * @return false|string + * @return string */ public function getInfo() { - return false; + return ''; } + /** + * Return warning if something is wrong with logger + * + * @return string + */ + public function getWarning() + { + return ''; + } + /** * Version of the module ('x.y.z' or 'dolibarr' or 'experimental' or 'development') * diff --git a/htdocs/core/modules/syslog/logHandlerInterface.php b/htdocs/core/modules/syslog/logHandlerInterface.php index f0d78735155..6f59482a1c0 100644 --- a/htdocs/core/modules/syslog/logHandlerInterface.php +++ b/htdocs/core/modules/syslog/logHandlerInterface.php @@ -48,6 +48,13 @@ interface LogHandlerInterface */ public function getInfo(); + /** + * Return warning if something is wrong with logger + * + * @return string Warning message + */ + public function getWarning(); + /** * Return array of configuration data * diff --git a/htdocs/core/modules/syslog/mod_syslog_chromephp.php b/htdocs/core/modules/syslog/mod_syslog_chromephp.php index e47a0059828..adcaa9d7f00 100644 --- a/htdocs/core/modules/syslog/mod_syslog_chromephp.php +++ b/htdocs/core/modules/syslog/mod_syslog_chromephp.php @@ -32,19 +32,29 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface /** * Content of the info tooltip. * - * @return false|string + * @return string */ public function getInfo() + { + return ''; + } + + /** + * Return warning if something is wrong with logger + * + * @return string + */ + public function getWarning() { global $langs; return $this->isActive()?'':$langs->trans('ClassNotFoundIntoPathWarning','ChromePhp.class.php'); } - + /** * Is the module active ? * - * @return int + * @return int -1 if not active, 0 if active but lib/path not found, 1 if OK */ public function isActive() { @@ -65,6 +75,10 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface { return 1; } + else + { + return 0; + } } catch(Exception $e) { @@ -89,7 +103,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface 'constant' => 'SYSLOG_CHROMEPHP_INCLUDEPATH', 'default' => DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/', 'attr' => 'size="60"', - 'example' =>'/usr/share/php' + 'example' =>'/usr/share/php, '.DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/' ) ); } From 5ffab9720f24b7f453282554fcb33c55dfe09f08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 12:38:39 +0200 Subject: [PATCH 04/14] More complete connexion profile --- htdocs/user/class/user.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 475b9d7fd2b..fc4abd88079 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1888,6 +1888,8 @@ class User extends CommonObject $s=picto_from_langcode($langs->getDefaultLang()); $label.= '
'.$langs->trans("CurrentUserLanguage").': '.($s?$s.' ':'').$langs->getDefaultLang(); $label.= '
'.$langs->trans("Browser").': '.$conf->browser->name.($conf->browser->version?' '.$conf->browser->version:'').' ('.$_SERVER['HTTP_USER_AGENT'].')'; + $label.= '
'.$langs->trans("Layout").': '.$conf->browser->layout; + $label.= '
'.$langs->trans("Screen").': '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']; if (! empty($conf->browser->phone)) $label.= '
'.$langs->trans("Phone").': '.$conf->browser->phone; if (! empty($_SESSION["disablemodules"])) $label.= '
'.$langs->trans("DisabledModules").':
'.join(', ',explode(',',$_SESSION["disablemodules"])); } From a44ab5168cd8b291470e944d0056a091f373a019 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 12:43:25 +0200 Subject: [PATCH 05/14] Save memory. --- htdocs/core/class/html.form.class.php | 3 ++- htdocs/main.inc.php | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index bc831baeddf..fe4852d839b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -364,7 +364,8 @@ class Form } /** - * Show a text and picto with tooltip on text or picto + * Show a text and picto with tooltip on text or picto. + * Can be called by an instancied $form->textwithtooltip or by a static call Form::textwithtooltip * * @param string $text Text to show * @param string $htmltext HTML content of tooltip. Must be HTML/UTF8 encoded. diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index d4f27fb3145..ab1a16c9883 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1428,7 +1428,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $menumanager->showmenu('top'); // This contains a \n print "\n"; - $form=new Form($db); + //$form=new Form($db); // Define link to login card $appli='Dolibarr'; @@ -1496,11 +1496,11 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $text =''; $text.= img_picto(":".$langs->trans("PrintContentArea"), 'printer.png', 'class="printer"'); $text.=''; - $toprightmenu.=$form->textwithtooltip('',$langs->trans("PrintContentArea"),2,1,$text,'login_block_elem',2); + $toprightmenu.=Form::textwithtooltip('',$langs->trans("PrintContentArea"),2,1,$text,'login_block_elem',2); } // Logout link - $toprightmenu.=$form->textwithtooltip('',$logouthtmltext,2,1,$logouttext,'login_block_elem',2); + $toprightmenu.=Form::textwithtooltip('',$logouthtmltext,2,1,$logouttext,'login_block_elem',2); $toprightmenu.=''; @@ -1509,7 +1509,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a print "\n"; print ''; - unset($form); + //unset($form); } if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "\n"; From ff3968b07f965176e083f7312fe3b6b0ef1efd54 Mon Sep 17 00:00:00 2001 From: philippe grand Date: Mon, 7 Sep 2015 12:46:49 +0200 Subject: [PATCH 06/14] translations missing --- htdocs/core/modules/modFournisseur.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 0db347f0df2..4f82710d3f5 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Juanjo Menent - * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2013-2015 Philippe Grand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,17 +20,17 @@ */ /** - * \defgroup fournisseur Module suppliers - * \brief Module pour gerer des societes et contacts de type fournisseurs + * \defgroup fournisseur suppliers Module + * \brief Module to manage companies and contacts of supplier type * \file htdocs/core/modules/modFournisseur.class.php * \ingroup fournisseur - * \brief Fichier de description et activation du module Fournisseur + * \brief Description and activation file for module Fournisseur */ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; /** - * Classe de description et activation du module Fournisseur + * Description and activation class for module Fournisseur */ class modFournisseur extends DolibarrModules { @@ -67,7 +67,7 @@ class modFournisseur extends DolibarrModules "/fournisseur/facture/temp" ); - // Dependances + // Dependencies $this->depends = array("modSociete"); $this->requiredby = array(); $this->langfiles = array('bills', 'companies', 'suppliers', 'orders'); @@ -75,7 +75,7 @@ class modFournisseur extends DolibarrModules // Config pages $this->config_page_url = array("supplier_order.php"); - // Constantes + // Constants $this->const = array(); $r=0; From 1b3db2ca41a4f8a405cd9fb0aed443e6d0f003b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 13:20:44 +0200 Subject: [PATCH 07/14] NEW Add none/all selection into list of files for FTP browser module --- htdocs/ftp/index.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 19c4b50dc7d..5e4dd33faed 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -369,11 +369,22 @@ if ($conf->use_javascript_ajax) + '.$langs->trans("Owner").''."\n"; print ''.$langs->trans("Group").''."\n"; print ''.$langs->trans("Permissions").''."\n"; - print ''; + print ''; + if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").' '; print ''.img_picto($langs->trans("Refresh"),'refresh').' '; print ''."\n"; print ''."\n"; From 3333970eb43d32d3120fa518add13fa5396991cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 13:23:51 +0200 Subject: [PATCH 08/14] Prepare 3.9 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index c591359f424..08080b9388d 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -30,7 +30,7 @@ * \brief File that include conf.php file and commons lib like functions.lib.php */ -if (! defined('DOL_VERSION')) define('DOL_VERSION','3.8.0-beta'); +if (! defined('DOL_VERSION')) define('DOL_VERSION','3.9.0-beta'); if (! defined('EURO')) define('EURO',chr(128)); From 7f05e19e0d683f6eae0c15de33e661faf37500e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 13:24:52 +0200 Subject: [PATCH 09/14] Prepare 3.9 --- htdocs/install/check.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 0b9b08f3b68..c2abbc2a014 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -387,7 +387,8 @@ else array('from'=>'3.4.0', 'to'=>'3.5.0'), array('from'=>'3.5.0', 'to'=>'3.6.0'), array('from'=>'3.6.0', 'to'=>'3.7.0'), - array('from'=>'3.7.0', 'to'=>'3.8.0') + array('from'=>'3.7.0', 'to'=>'3.8.0'), + array('from'=>'3.8.0', 'to'=>'3.9.0') ); $count=0; From fe609275030d29d65c2a226a110fb26ff446a98d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 13:30:02 +0200 Subject: [PATCH 10/14] Fix button must appears if box selected --- htdocs/ftp/index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 5e4dd33faed..4a42c6978ba 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -145,7 +145,7 @@ if ($action == 'add' && $user->rights->ftp->setup) { //TODO: Translate setEventMessage('Error '.$langs->trans($ecmdir->error)); - $_GET["action"] = "create"; + $action = "create"; } } @@ -376,9 +376,11 @@ jQuery(document).ready(function() { $("#checkall").click(function() { $(".checkboxfordelete").prop('checked', true); + jQuery("#delconst").show(); }); $("#checknone").click(function() { $(".checkboxfordelete").prop('checked', false); + jQuery("#delconst").hide(); }); }); From 2de690259a61bb03cfc0eeb39cb2c9b952993f72 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 14:01:05 +0200 Subject: [PATCH 11/14] Add migration script for 3.9 --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5bc5f49b2e5..98c63e3c366 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ php: - 5.5 - 5.6 - 7.0 - + matrix: allow_failures: - php: 7.0 @@ -130,6 +130,7 @@ script: - php upgrade.php 3.7.0 3.8.0 ignoredbversion > upgrade370380.log # - cat upgrade370380.log - php upgrade2.php 3.7.0 3.8.0 ignoredbversion > upgrade370380-2.log + - php upgrade2.php 3.8.0 3.9.0 ignoredbversion > upgrade380390-2.log # - cat upgrade370380-2.log - cd ../.. - date From fc35c4e3f09bd07fecc9f59b27c7bce56bb2afe2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 14:01:59 +0200 Subject: [PATCH 12/14] Add migration script for 3.9 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 98c63e3c366..54d937625ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -130,6 +130,7 @@ script: - php upgrade.php 3.7.0 3.8.0 ignoredbversion > upgrade370380.log # - cat upgrade370380.log - php upgrade2.php 3.7.0 3.8.0 ignoredbversion > upgrade370380-2.log + - php upgrade.php 3.8.0 3.9.0 ignoredbversion > upgrade380390.log - php upgrade2.php 3.8.0 3.9.0 ignoredbversion > upgrade380390-2.log # - cat upgrade370380-2.log - cd ../.. From 53a9c93b90c0c7f1b6bc5c4e807c598a1d869613 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 15:16:43 +0200 Subject: [PATCH 13/14] Fix PHPCS --- htdocs/ftp/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 4a42c6978ba..9b0c2a36e0e 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -495,7 +495,7 @@ else // List content of directory ($newsection = '/', '/home', ...) if (! empty($conf->global->FTP_CONNECT_WITH_SFTP)) { - if ($newsection == '/') $newsection='/./'; # workaround for bug https://bugs.php.net/bug.php?id=64169 + if ($newsection == '/') $newsection='/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 //$dirHandle = opendir("ssh2.sftp://$conn_id".$newsection); //var_dump($dirHandle); $contents = scandir('ssh2.sftp://' . $conn_id . $newsection); From 0a6451d72c5d9447d7fe574542c30ed388c6a29f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 20:17:05 +0200 Subject: [PATCH 14/14] Fix memcached effect was lost because init was done each time. --- htdocs/core/class/translate.class.php | 3 +- htdocs/core/lib/memory.lib.php | 54 +++++++++++++++++++-------- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 100af13af5d..5d06586fb16 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -234,7 +234,8 @@ class Translate if ($usecachekey) { //dol_syslog('Translate::Load we will cache result into usecachekey '.$usecachekey); - + //global $aaa; $aaa+=1; + //print $aaa." ".$usecachekey."\n"; require_once DOL_DOCUMENT_ROOT .'/core/lib/memory.lib.php'; $tmparray=dol_getcache($usecachekey); if (is_array($tmparray) && count($tmparray)) diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index b68016c3a46..7df56b6283c 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -47,10 +47,16 @@ function dol_setcache($memoryid,$data) // Using a memcached server if (! empty($conf->memcached->enabled) && class_exists('Memcached')) { - $memoryid=session_name().'_'.$memoryid; - $m=new Memcached(); - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + global $m; + if (empty($m) || ! is_object($m)) + { + $m=new Memcached(); + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); + $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + if (! $result) return -1; + } + + $memoryid=session_name().'_'.$memoryid; //$m->setOption(Memcached::OPT_COMPRESSION, false); //print "Add memoryid=".$memoryid; $m->add($memoryid,$data); // This fails if key already exists @@ -66,10 +72,16 @@ function dol_setcache($memoryid,$data) } else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) { - $memoryid=session_name().'_'.$memoryid; - $m=new Memcache(); - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + global $m; + if (empty($m) || ! is_object($m)) + { + $m=new Memcache(); + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); + $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + if (! $result) return -1; + } + + $memoryid=session_name().'_'.$memoryid; //$m->setOption(Memcached::OPT_COMPRESSION, false); $result=$m->add($memoryid,$data); // This fails if key already exists if ($result) @@ -103,10 +115,16 @@ function dol_getcache($memoryid) // Using a memcached server if (! empty($conf->memcached->enabled) && class_exists('Memcached')) { + global $m; + if (empty($m) || ! is_object($m)) + { + $m=new Memcached(); + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); + $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + if (! $result) return -1; + } + $memoryid=session_name().'_'.$memoryid; - $m=new Memcached(); - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); //$m->setOption(Memcached::OPT_COMPRESSION, false); //print "Get memoryid=".$memoryid; $data=$m->get($memoryid); @@ -124,10 +142,16 @@ function dol_getcache($memoryid) } else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) { - $memoryid=session_name().'_'.$memoryid; - $m=new Memcache(); - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + global $m; + if (empty($m) || ! is_object($m)) + { + $m=new Memcache(); + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); + $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + if (! $result) return -1; + } + + $memoryid=session_name().'_'.$memoryid; //$m->setOption(Memcached::OPT_COMPRESSION, false); $data=$m->get($memoryid); //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n
";