xdebug-trace-tree icon indicating copy to clipboard operation
xdebug-trace-tree copied to clipboard

Suggestion : clear the trace folder

Open cavo789 opened this issue 8 years ago • 0 comments

Hello

Small suggestion : next to the Load button, add a "clear folder" button so the user can empty the trace folder.

In a very quick (and probably dirty) addition, I suggest to add something like this at the top of your file

	$dir = ini_get('xdebug.trace_output_dir');
	if (!$dir) $dir = '/tmp/';
	if (isset($_GET['task'])) {

	if ($_GET['task']==='empty') 
	{
		$files = glob("$dir/*.xt");
		$return='';
		if (count($files)>0) {
			foreach ($files as $file) 
			{
				$return.=$file.'|';
				unlink($file);
			}
		}
		echo $return;
		die();
	} else {

		$btnEmpty="<button id='emptyfolder'>Empty trace folder</button>".
		"<script>\n".
		"   $('#emptyfolder').click(function (e) {\n".
		"      e.preventDefault();\n".
		"      $.ajax({\n".
		"      url: 'index.php?task=empty'\n".
		"      }).done(function() {\n".
		"         alert('Files in $dir have been removed');\n".
		"      });\n".
		"   });\n".
		"</script>\n";
	}

This will erase every .xt files (when ?task=empty is specified on the querystring).

Otherwise will initialize a $btnEmpty button.

In your html, next to the load button, just echo $btnEmpty.

Have a nice day.

cavo789 avatar Feb 23 '17 10:02 cavo789