forked from sineld/memcache
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemcache_ui.php
More file actions
82 lines (73 loc) · 1.87 KB
/
Copy pathmemcache_ui.php
File metadata and controls
82 lines (73 loc) · 1.87 KB
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
/**
* Memcache User Interface. Main file.
*
* @author Frederic G. MARAND <[email protected]>
*
* @copyright (c) 2011 Frederic G. MARAND
*
* Requirements:
* - PHP >= 5.3
*
* Recommended:
* - intl extension
* - on Ubuntu 11.04, this implies removing libidn, libsimplepie, and
* dokuwiki, among others
* - tidy extension
*/
namespace Memcache_UI {
/**
* Wrapper around php tidy class.
*
* @param string $html
*
* @return void
*/
function applyTidy (&$html) {
$config = array(
'indent' => TRUE,
'output-xhtml' => TRUE,
'sort-attributes' => 'alpha',
'wrap' => 200,
);
$tidy = new \tidy();
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();
$html = (string) $tidy;
}
function main() {
try {
ob_start();
//echo '<pre>';
// Set-up autoloader: it cannot autoload itself.
$package = 'Memcache_UI';
require "$package/Core/Autoloader.inc";
$classLoader = new \SplClassLoader($package, dirname(__FILE__));
$classLoader->setFileExtension('.inc');
$classLoader->register();
// Set up the context
$context = new Core\Context();
$context->setMessage("Dirname: [". $context->getBase() . "]", LOG_DEBUG);
$context->setMessage("Path: [". $context->getPath() . "]", LOG_DEBUG);
// Obtain the routing information
$router = new Core\Router($context);
$item = $router->getRoute();
$page = new $item['page class']($context, $item);
$page->emitHeaders();
echo $page;
$html = ob_get_clean();
// Filter it on output
if ($context->getTidy()) {
applyTidy($html);
}
echo $html;
}
catch (Exception $e) {
echo '<pre>';
echo $e->getMessage() . PHP_EOL;
echo $e->getTraceAsString();
echo "</pre>";
}
}
main();
}