diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index 749f81f1197..b44b8fd835f 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -31,7 +31,6 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); - if (! isset($mode) || $mode != 'noajax') // For ajax call { $res=@include '../../main.inc.php'; diff --git a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php index ba3c2a20b96..9d72ddd4383 100644 --- a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php +++ b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php @@ -46,7 +46,8 @@ $(document).ready(function() { $('#filetree').fileTree({ root: '', // Ajax called if we click to expand a dir (not a file). Parameter 'dir' is provided as a POST parameter by fileTree code to this following URL. - script: '', + // We must use token=$_SESSION['token'] and not token=$_SESSION['newtoken'] here because ajaxdirtree has NOTOKENRENEWAL define so there is no rollup of token so we must compare with the one valid on main page + script: '', folderEvent: 'click', // 'dblclick' multiFolder: false }, // Called if we click on a file (not a dir) @@ -90,7 +91,7 @@ function loadandshowpreview(filedirname,section) { //alert('filedirname='+filedirname); //console.log(filedirname); - //console.log(section); + //console.log('loadandshowpreview for section='+section); $('#ecmfileview').empty(); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 0315f17b743..f4fd328c62b 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -363,6 +363,8 @@ if ((! empty($conf->global->MAIN_VERSION_LAST_UPGRADE) && ($conf->global->MAIN_V } } +//var_dump(GETPOST('token').' '.$_SESSION['token'].' - '.$_SESSION['newtoken'].' '.$_SERVER['SCRIPT_FILENAME']); + // Creation of a token against CSRF vulnerabilities if (! defined('NOTOKENRENEWAL')) { @@ -373,6 +375,9 @@ if (! defined('NOTOKENRENEWAL')) $token = dol_hash(uniqid(mt_rand(), true)); // Generates a hash of a random number $_SESSION['newtoken'] = $token; } + +//var_dump(GETPOST('token').' '.$_SESSION['token'].' - '.$_SESSION['newtoken'].' '.$_SERVER['SCRIPT_FILENAME']); + // Check token if ((! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && ! empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) || defined('CSRFCHECK_WITH_TOKEN')) // Check validity of token, only if option MAIN_SECURITY_CSRF_WITH_TOKEN enabled or if constant CSRFCHECK_WITH_TOKEN is set