| 1 |
<?php
|
| 2 |
// $Id: memcache.module,v 1.13 2007/05/22 08:58:15 robertDouglass Exp $
|
| 3 |
|
| 4 |
function memcache_init() {
|
| 5 |
if (strstr($_SERVER['PHP_SELF'], 'update.php') || strstr($_GET['q'], 'autocomplete')) {
|
| 6 |
// update.php relies on standard error handler
|
| 7 |
}
|
| 8 |
else {
|
| 9 |
if (user_access('access memcache statistics')) {
|
| 10 |
drupal_add_js(drupal_get_path('module', 'memcache'). '/memcache.js');
|
| 11 |
register_shutdown_function('memcache_shutdown');
|
| 12 |
}
|
| 13 |
}
|
| 14 |
}
|
| 15 |
|
| 16 |
function memcache_perm() {
|
| 17 |
return array('access memcache statistics');
|
| 18 |
}
|
| 19 |
|
| 20 |
/**
|
| 21 |
* See memcache_init() which registers this function as a shutdown function.
|
| 22 |
* Displays memcache stats in the footer.
|
| 23 |
*/
|
| 24 |
function memcache_shutdown() {
|
| 25 |
global $user, $_memcache_statistics;
|
| 26 |
|
| 27 |
// Try not to break non html pages.
|
| 28 |
if (function_exists('drupal_get_headers')) {
|
| 29 |
$headers = drupal_get_headers();
|
| 30 |
if(strstr($headers, 'xml') || strstr($headers, 'javascript') || strstr($headers, 'plain')) {
|
| 31 |
return;
|
| 32 |
}
|
| 33 |
}
|
| 34 |
|
| 35 |
if (user_access('access memcache statistics')) {
|
| 36 |
$stats = array();
|
| 37 |
foreach ($_memcache_statistics as $stat => $val) {
|
| 38 |
$stats[] = "<strong>$stat:</strong> ". theme('item_list', $val);
|
| 39 |
}
|
| 40 |
if (!empty($stats)) {
|
| 41 |
$output = theme('item_list', $stats);
|
| 42 |
// this makes sure all of the HTML is within the <body> even though this <script> is outside it
|
| 43 |
print '<div id="memcache-devel"><h2>'. t('Memcache statistics'). '</h2>'. $output.'</div>';
|
| 44 |
}
|
| 45 |
}
|
| 46 |
}
|