Skip to content

Suggestion : clear the trace folder #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cavo789 opened this issue Feb 23, 2017 · 0 comments
Open

Suggestion : clear the trace folder #1

cavo789 opened this issue Feb 23, 2017 · 0 comments

Comments

@cavo789
Copy link

cavo789 commented Feb 23, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant