-
Notifications
You must be signed in to change notification settings - Fork 452
/
debug.php
82 lines (65 loc) · 2.99 KB
/
debug.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
namespace Concrete\Controller\SinglePage\Dashboard\System\Environment;
use Concrete\Core\Page\Controller\DashboardPageController;
use Exception;
class Debug extends DashboardPageController
{
public function view()
{
$config = $this->app->make('config');
$this->set('debug_enabled', (bool) $config->get('concrete.debug.display_errors'));
$this->set('debug_detail', $config->get('concrete.debug.detail'));
$this->set('warnings_as_errors', (string) $config->get('concrete.debug.error_reporting') !== '');
}
public function update_debug()
{
if ($this->token->validate('update_debug')) {
if ($this->request->isPost()) {
$post = $this->request->request;
$config = $this->app->make('config');
$config->save('concrete.debug.display_errors', (bool) $post->get('debug_enabled'));
$config->save('concrete.debug.detail', $post->get('debug_detail'));
$config->save('concrete.debug.error_reporting', $post->get('warnings_as_errors') ? -1 : null);
$this->flash('success', t('Debug configuration saved.'));
$this->redirect($this->action(''));
}
} else {
$this->error->add($this->token->getErrorMessage());
}
}
public function debug_example()
{
$config = $this->app->make('config');
$config->set('concrete.log.errors', false);
$config->set('concrete.debug.display_errors', true);
$config->set('concrete.debug.detail', 'debug');
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'debug_example';
error_reporting($this->request->query->get('warnings_as_errors') ? -1 : DEFAULT_ERROR_REPORTING);
$this->will_throw_a_warning_because = $this->is_not_a_defined_property;
throw new ExampleException('Sample Debug Output!');
}
public function message_example()
{
$config = $this->app->make('config');
$config->set('concrete.log.errors', false);
$config->set('concrete.debug.display_errors', true);
$config->set('concrete.debug.detail', 'message');
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'debug_example';
error_reporting($this->request->query->get('warnings_as_errors') ? -1 : DEFAULT_ERROR_REPORTING);
$this->will_throw_a_warning_because = $this->is_not_a_defined_property;
throw new ExampleException('Sample Message Output!');
}
public function disabled_example()
{
$config = $this->app->make('config');
$config->set('concrete.log.errors', false);
$config->set('concrete.debug.display_errors', false);
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'debug_example';
error_reporting($this->request->query->get('warnings_as_errors') ? -1 : DEFAULT_ERROR_REPORTING);
$this->will_throw_a_warning_because = $this->is_not_a_defined_property;
throw new ExampleException('Sample Disabled Output!');
}
}
class ExampleException extends Exception
{
}