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

This commit is contained in:
Laurent Destailleur 2012-12-21 14:26:26 +01:00
commit a3f679183f
7 changed files with 116 additions and 73 deletions

View File

@ -23,9 +23,16 @@
*/ */
function CombinePaths( $sBasePath, $sFolder ) function CombinePaths( $sBasePath, $sFolder )
{ {
return RemoveFromEnd( $sBasePath, '/' ) . '/' . RemoveFromStart( $sFolder, '/' ); return RemoveFromEnd($sBasePath, '/') . '/' . RemoveFromStart($sFolder, '/');
} }
function GetResourceTypePath( $resourceType, $sCommand ) /**
* GetResourceTypePath
*
* @param string $resourceType Resource type
* @param string $sCommand Command
* @return string Config
*/
function GetResourceTypePath($resourceType, $sCommand)
{ {
global $Config ; global $Config ;
@ -35,93 +42,119 @@ function GetResourceTypePath( $resourceType, $sCommand )
return $Config['FileTypesPath'][$resourceType] ; return $Config['FileTypesPath'][$resourceType] ;
} }
function GetResourceTypeDirectory( $resourceType, $sCommand ) /**
* GetResourceTypeDirectory
*
* @param unknown_type $resourceType Resource type
* @param unknown_type $sCommand Command
* @return string
*/
function GetResourceTypeDirectory($resourceType, $sCommand)
{ {
global $Config ; global $Config ;
if ( $sCommand == "QuickUpload") if ( $sCommand == "QuickUpload")
{ {
if ( strlen( $Config['QuickUploadAbsolutePath'][$resourceType] ) > 0 ) if ( strlen($Config['QuickUploadAbsolutePath'][$resourceType]) > 0)
return $Config['QuickUploadAbsolutePath'][$resourceType] ; return $Config['QuickUploadAbsolutePath'][$resourceType] ;
// Map the "UserFiles" path to a local directory. // Map the "UserFiles" path to a local directory.
return Server_MapPath( $Config['QuickUploadPath'][$resourceType] ); return Server_MapPath($Config['QuickUploadPath'][$resourceType]);
} }
else else
{ {
if ( strlen( $Config['FileTypesAbsolutePath'][$resourceType] ) > 0 ) if ( strlen($Config['FileTypesAbsolutePath'][$resourceType]) > 0)
return $Config['FileTypesAbsolutePath'][$resourceType] ; return $Config['FileTypesAbsolutePath'][$resourceType] ;
// Map the "UserFiles" path to a local directory. // Map the "UserFiles" path to a local directory.
return Server_MapPath( $Config['FileTypesPath'][$resourceType] ); return Server_MapPath($Config['FileTypesPath'][$resourceType]);
} }
} }
function GetUrlFromPath( $resourceType, $folderPath, $sCommand ) function GetUrlFromPath($resourceType, $folderPath, $sCommand)
{ {
return CombinePaths( GetResourceTypePath( $resourceType, $sCommand ), $folderPath ); return CombinePaths(GetResourceTypePath($resourceType, $sCommand), $folderPath);
} }
function RemoveExtension( $fileName ) /**
* RemoveExtension
*
* @param string $fileName Filename
* @return string String without extension
*/
function RemoveExtension($fileName)
{ {
return substr( $fileName, 0, strrpos( $fileName, '.' ) ); return substr($fileName, 0, strrpos($fileName, '.'));
} }
/**
function ServerMapFolder( $resourceType, $folderPath, $sCommand ) * ServerMapFolder
*
* @param string $resourceType Resource type
* @param string $folderPath Folder
* @param string $sCommand Command
* @return void
*/
function ServerMapFolder($resourceType, $folderPath, $sCommand)
{ {
// Get the resource type directory. // Get the resource type directory.
$sResourceTypePath = GetResourceTypeDirectory( $resourceType, $sCommand ); $sResourceTypePath = GetResourceTypeDirectory($resourceType, $sCommand);
// Ensure that the directory exists. // Ensure that the directory exists.
$sErrorMsg = CreateServerFolder( $sResourceTypePath ); $sErrorMsg = CreateServerFolder($sResourceTypePath);
if ( $sErrorMsg != '' ) if ( $sErrorMsg != '' )
SendError( 1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})" ); SendError(1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})");
// Return the resource type directory combined with the required path. // Return the resource type directory combined with the required path.
return CombinePaths( $sResourceTypePath , $folderPath ); return CombinePaths($sResourceTypePath, $folderPath);
} }
function GetParentFolder( $folderPath ) function GetParentFolder( $folderPath )
{ {
$sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-" ; $sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-" ;
return preg_replace( $sPattern, '', $folderPath ); return preg_replace($sPattern, '', $folderPath);
} }
/**
function CreateServerFolder( $folderPath, $lastFolder = null ) * CreateServerFolder
*
* @param string $folderPath Folder
* @param string $lastFolder Folder
* @return string ''=success, error message otherwise
*/
function CreateServerFolder($folderPath, $lastFolder = null)
{ {
global $Config ; global $Config ;
$sParent = GetParentFolder( $folderPath ); $sParent = GetParentFolder($folderPath);
// Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms // Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms
while ( strpos($folderPath, '//') !== false ) while ( strpos($folderPath, '//') !== false )
{ {
$folderPath = str_replace( '//', '/', $folderPath ); $folderPath = str_replace('//', '/', $folderPath);
} }
// Check if the parent exists, or create it. // Check if the parent exists, or create it.
if ( !empty($sParent) && !file_exists( $sParent ) ) if ( !empty($sParent) && !file_exists($sParent))
{ {
//prevents agains infinite loop when we can't create root folder //prevents agains infinite loop when we can't create root folder
if ( !is_null( $lastFolder ) && $lastFolder === $sParent) { if ( !is_null($lastFolder) && $lastFolder === $sParent) {
return "Can't create $folderPath directory" ; return "Can't create $folderPath directory" ;
} }
$sErrorMsg = CreateServerFolder( $sParent, $folderPath ); $sErrorMsg = CreateServerFolder($sParent, $folderPath);
if ( $sErrorMsg != '' ) if ( $sErrorMsg != '' )
return $sErrorMsg ; return $sErrorMsg ;
} }
if ( !file_exists( $folderPath ) ) if ( !file_exists($folderPath))
{ {
// Turn off all error reporting. // Turn off all error reporting.
error_reporting( 0 ); error_reporting(0);
$php_errormsg = '' ; $php_errormsg = '' ;
// Enable error tracking to catch the error. // Enable error tracking to catch the error.
ini_set( 'track_errors', '1' ); ini_set('track_errors', '1');
if ( isset( $Config['ChmodOnFolderCreate'] ) && !$Config['ChmodOnFolderCreate'] ) if ( isset( $Config['ChmodOnFolderCreate'] ) && !$Config['ChmodOnFolderCreate'] )
{ {
mkdir( $folderPath ); mkdir($folderPath);
} }
else else
{ {
@ -132,15 +165,15 @@ function CreateServerFolder( $folderPath, $lastFolder = null )
} }
// To create the folder with 0777 permissions, we need to set umask to zero. // To create the folder with 0777 permissions, we need to set umask to zero.
$oldumask = umask(0); $oldumask = umask(0);
mkdir( $folderPath, $permissions ); mkdir($folderPath, $permissions);
umask( $oldumask ); umask($oldumask);
} }
$sErrorMsg = $php_errormsg ; $sErrorMsg = $php_errormsg ;
// Restore the configurations. // Restore the configurations.
ini_restore( 'track_errors' ); ini_restore('track_errors');
ini_restore( 'error_reporting' ); ini_restore('error_reporting');
return $sErrorMsg ; return $sErrorMsg ;
} }
@ -153,23 +186,23 @@ function GetRootPath()
if (!isset($_SERVER)) { if (!isset($_SERVER)) {
global $_SERVER; global $_SERVER;
} }
$sRealPath = realpath( './' ); $sRealPath = realpath('./');
// #2124 ensure that no slash is at the end // #2124 ensure that no slash is at the end
$sRealPath = rtrim($sRealPath,"\\/"); $sRealPath = rtrim($sRealPath,"\\/");
$sSelfPath = $_SERVER['PHP_SELF'] ; $sSelfPath = $_SERVER['PHP_SELF'] ;
$sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ); $sSelfPath = substr($sSelfPath, 0, strrpos($sSelfPath, '/'));
$sSelfPath = str_replace( '/', DIRECTORY_SEPARATOR, $sSelfPath ); $sSelfPath = str_replace('/', DIRECTORY_SEPARATOR, $sSelfPath);
$position = strpos( $sRealPath, $sSelfPath ); $position = strpos($sRealPath, $sSelfPath);
// This can check only that this script isn't run from a virtual dir // This can check only that this script isn't run from a virtual dir
// But it avoids the problems that arise if it isn't checked // But it avoids the problems that arise if it isn't checked
if ( $position === false || $position <> strlen( $sRealPath ) - strlen( $sSelfPath ) ) if ( $position === false || $position <> strlen($sRealPath) - strlen($sSelfPath) )
SendError( 1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".' ); SendError(1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".');
return substr( $sRealPath, 0, $position ); return substr($sRealPath, 0, $position);
} }
// Emulate the asp Server.mapPath function. // Emulate the asp Server.mapPath function.
@ -177,9 +210,9 @@ function GetRootPath()
function Server_MapPath( $path ) function Server_MapPath( $path )
{ {
// This function is available only for Apache // This function is available only for Apache
if ( function_exists( 'apache_lookup_uri' ) ) if (function_exists('apache_lookup_uri'))
{ {
$info = apache_lookup_uri( $path ); $info = apache_lookup_uri($path);
return $info->filename . $info->path_info ; return $info->filename . $info->path_info ;
} }
@ -188,41 +221,52 @@ function Server_MapPath( $path )
return GetRootPath() . $path ; return GetRootPath() . $path ;
} }
function IsAllowedExt( $sExtension, $resourceType ) function IsAllowedExt($sExtension, $resourceType)
{ {
global $Config ; global $Config ;
// Get the allowed and denied extensions arrays. // Get the allowed and denied extensions arrays.
$arAllowed = $Config['AllowedExtensions'][$resourceType] ; $arAllowed = $Config['AllowedExtensions'][$resourceType] ;
$arDenied = $Config['DeniedExtensions'][$resourceType] ; $arDenied = $Config['DeniedExtensions'][$resourceType] ;
if ( count($arAllowed) > 0 && !in_array( $sExtension, $arAllowed ) ) if ( count($arAllowed) > 0 && !in_array($sExtension, $arAllowed))
return false ; return false ;
if ( count($arDenied) > 0 && in_array( $sExtension, $arDenied ) ) if ( count($arDenied) > 0 && in_array($sExtension, $arDenied))
return false ; return false ;
return true ; return true ;
} }
function IsAllowedType( $resourceType ) function IsAllowedType($resourceType)
{ {
global $Config ; global $Config ;
if ( !in_array( $resourceType, $Config['ConfigAllowedTypes'] ) ) if ( !in_array($resourceType, $Config['ConfigAllowedTypes']))
return false ; return false ;
return true ; return true ;
} }
function IsAllowedCommand( $sCommand ) /**
* IsAllowedCommand
*
* @param string $sCommand Command
* @return boolean True or false
*/
function IsAllowedCommand($sCommand)
{ {
global $Config ; global $Config ;
if ( !in_array( $sCommand, $Config['ConfigAllowedCommands'] ) ) if ( !in_array($sCommand, $Config['ConfigAllowedCommands']))
return false ; return false ;
return true ; return true ;
} }
/**
* GetCurrentFolder
*
* @return string current folder
*/
function GetCurrentFolder() function GetCurrentFolder()
{ {
if (!isset($_GET)) { if (!isset($_GET)) {
@ -231,22 +275,22 @@ function GetCurrentFolder()
$sCurrentFolder = isset( $_GET['CurrentFolder'] ) ? $_GET['CurrentFolder'] : '/' ; $sCurrentFolder = isset( $_GET['CurrentFolder'] ) ? $_GET['CurrentFolder'] : '/' ;
// Check the current folder syntax (must begin and start with a slash). // Check the current folder syntax (must begin and start with a slash).
if ( !preg_match( '|/$|', $sCurrentFolder ) ) if (!preg_match('|/$|', $sCurrentFolder))
$sCurrentFolder .= '/' ; $sCurrentFolder .= '/' ;
if ( strpos( $sCurrentFolder, '/' ) !== 0 ) if (strpos($sCurrentFolder, '/') !== 0)
$sCurrentFolder = '/' . $sCurrentFolder ; $sCurrentFolder = '/' . $sCurrentFolder ;
// Ensure the folder path has no double-slashes // Ensure the folder path has no double-slashes
while ( strpos ($sCurrentFolder, '//') !== false ) { while ( strpos($sCurrentFolder, '//') !== false ) {
$sCurrentFolder = str_replace ('//', '/', $sCurrentFolder); $sCurrentFolder = str_replace('//', '/', $sCurrentFolder);
} }
// Check for invalid folder paths (..) // Check for invalid folder paths (..)
if ( strpos( $sCurrentFolder, '..' ) || strpos( $sCurrentFolder, "\\" )) if ( strpos($sCurrentFolder, '..') || strpos($sCurrentFolder, "\\"))
SendError( 102, '' ); SendError(102, '');
if ( preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $sCurrentFolder)) if ( preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $sCurrentFolder))
SendError( 102, '' ); SendError(102, '');
return $sCurrentFolder ; return $sCurrentFolder ;
} }
@ -254,10 +298,10 @@ function GetCurrentFolder()
// Do a cleanup of the folder name to avoid possible problems // Do a cleanup of the folder name to avoid possible problems
function SanitizeFolderName( $sNewFolderName ) function SanitizeFolderName( $sNewFolderName )
{ {
$sNewFolderName = stripslashes( $sNewFolderName ); $sNewFolderName = stripslashes($sNewFolderName);
// Remove . \ / | : ? * " < > // Remove . \ / | : ? * " < >
$sNewFolderName = preg_replace( '/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFolderName ); $sNewFolderName = preg_replace('/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFolderName);
return $sNewFolderName ; return $sNewFolderName ;
} }
@ -267,14 +311,14 @@ function SanitizeFileName( $sNewFileName )
{ {
global $Config ; global $Config ;
$sNewFileName = stripslashes( $sNewFileName ); $sNewFileName = stripslashes($sNewFileName);
// Replace dots in the name with underscores (only one dot can be there... security issue). // Replace dots in the name with underscores (only one dot can be there... security issue).
if ( $Config['ForceSingleExtension'] ) if ( $Config['ForceSingleExtension'] )
$sNewFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sNewFileName ); $sNewFileName = preg_replace('/\\.(?![^.]*$)/', '_', $sNewFileName);
// Remove \ / | : ? * " < > // Remove \ / | : ? * " < >
$sNewFileName = preg_replace( '/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName ); $sNewFileName = preg_replace('/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName);
return $sNewFileName ; return $sNewFileName ;
} }
@ -295,7 +339,7 @@ EOF;
} }
$rpl = array( '\\' => '\\\\', '"' => '\\"' ); $rpl = array( '\\' => '\\\\', '"' => '\\"' );
echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . strtr( $fileUrl, $rpl ) . '","' . strtr( $fileName, $rpl ) . '", "' . strtr( $customMsg, $rpl ) . '");' ; echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . strtr($fileUrl, $rpl) . '","' . strtr($fileName, $rpl) . '", "' . strtr($customMsg, $rpl) . '");' ;
echo '</script>' ; echo '</script>' ;
exit ; exit ;
} }
@ -310,8 +354,7 @@ function SendCKEditorResults ($callback, $sFileUrl, $customMsg = '')
$rpl = array( '\\' => '\\\\', '"' => '\\"' ); $rpl = array( '\\' => '\\\\', '"' => '\\"' );
echo 'window.parent.CKEDITOR.tools.callFunction("'. $callback. '","'. echo 'window.parent.CKEDITOR.tools.callFunction("'. $callback. '","'. strtr($sFileUrl, $rpl). '", "'. strtr($customMsg, $rpl). '");' ;
strtr($sFileUrl, $rpl). '", "'. strtr($customMsg, $rpl). '");' ;
echo '</script>'; echo '</script>';
} }

View File

@ -19,7 +19,7 @@
/** /**
* File that defines the balance of paid holiday of users. * File that defines the balance of paid holiday of users.
* *
* \file define_holiday.php * \file htdocs/holiday/define_holiday.php
* \ingroup holiday * \ingroup holiday
* \brief File that defines the balance of paid holiday of users. * \brief File that defines the balance of paid holiday of users.
*/ */

View File

@ -18,7 +18,7 @@
*/ */
/** /**
* \file fiche.php * \file htdocs/holiday/fiche.php
* \ingroup holiday * \ingroup holiday
* \brief Form and file creation of paid holiday. * \brief Form and file creation of paid holiday.
*/ */

View File

@ -18,7 +18,7 @@
*/ */
/** /**
* \file index.php * \file htdocs/holiday/index.php
* \ingroup holiday * \ingroup holiday
* \brief List of holiday. * \brief List of holiday.
*/ */

View File

@ -17,7 +17,7 @@
*/ */
/** /**
* \file month_report.php * \file htdocs/holiday/month_report.php
* \ingroup holiday * \ingroup holiday
* \brief Monthly report of paid holiday. * \brief Monthly report of paid holiday.
*/ */
@ -113,7 +113,7 @@ if($num == '0') {
$holidaystatic->id=$holiday['rowid']; $holidaystatic->id=$holiday['rowid'];
$holidaystatic->ref=$holiday['rowid']; $holidaystatic->ref=$holiday['rowid'];
$start_date=$db->jdate($holiday['date_debut']); $start_date=$db->jdate($holiday['date_debut']);
$end_date=$db->jdate($holiday['date_fin']); $end_date=$db->jdate($holiday['date_fin']);
/*if(substr($holiday['date_debut'],5,2)==$month-1){ /*if(substr($holiday['date_debut'],5,2)==$month-1){

View File

@ -19,7 +19,7 @@
/** /**
* Displays the log of actions performed in the module. * Displays the log of actions performed in the module.
* *
* \file view_log.php * \file htdocs/holiday/view_log.php
* \ingroup holiday * \ingroup holiday
*/ */

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2012 Nicolas Péré <nicolas@amarok2.net> /* Copyright (C) 2012 Nicolas Péré <nicolas@amarok2.net>
* Copyright (C) 2012 Xavier Peyronnet <xavier.peyronnet@free.fr> * Copyright (C) 2012 Xavier Peyronnet <xavier.peyronnet@free.fr>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* Version 0.6 (2012-10-30) * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -652,7 +652,7 @@ div.ficheaddleft {
/* boutons : */ /* boutons : */
.button, .butAction {background: #999;border: solid 1px #666;} .button, .butAction {background: #999;border: solid 1px #666;}
.butActionRefused {background: #ccc;} .butActionRefused {background: #eaeaea; color:rgba(0,0,0,0.6)}
.butActionDelete {background: #b33c37;border:solid 1px #8d2f2b;} .butActionDelete {background: #b33c37;border:solid 1px #8d2f2b;}
.button, .butAction, .butActionRefused, .butActionDelete { .button, .butAction, .butActionRefused, .butActionDelete {
@ -688,7 +688,7 @@ border-left: solid 1px rgba(0,0,0,.3);
td.formdocbutton {padding-top:6px;} td.formdocbutton {padding-top:6px;}
.button:hover, .butAction:hover, .butActionRefused:hover, .butActionDelete:hover { .button:hover, .butAction:hover, .butActionDelete:hover {
background-image: linear-gradient(top, rgba(255,255,255,.3) 100%, rgba(0,0,0,.3) 0%); background-image: linear-gradient(top, rgba(255,255,255,.3) 100%, rgba(0,0,0,.3) 0%);
background-image: -o-linear-gradient(top, rgba(255,255,255,.3) 100%, rgba(0,0,0,.3) 0%); background-image: -o-linear-gradient(top, rgba(255,255,255,.3) 100%, rgba(0,0,0,.3) 0%);
background-image: -moz-linear-gradient(top, rgba(255,255,255,.3) 100%, rgba(0,0,0,.3) 0%); background-image: -moz-linear-gradient(top, rgba(255,255,255,.3) 100%, rgba(0,0,0,.3) 0%);