summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Peterson2013-02-21 20:52:49 (GMT)
committer Eric Peterson2013-02-21 20:52:49 (GMT)
commitef44b3a7d71ccdeb84a8c2ec91aee3bd4eb1f706 (patch)
treeec2da858a3b1a0c8c6655a1faaac9a73d18f7081
parent93561196a8840d412f10cc4cfd5b786de7191fd9 (diff)
Initial commit of the module; based entirely on the APC Status module.7.x-1.0
-rw-r--r--README.txt28
-rw-r--r--memcache_status.admin.inc37
-rw-r--r--memcache_status.info4
-rw-r--r--memcache_status.install24
-rw-r--r--memcache_status.module35
5 files changed, 128 insertions, 0 deletions
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..527dfc9
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,28 @@
+Memcache Status
+==========
+
+Requirements:
+ - Libraries API - http://drupal.org/project/libraries
+ - memcache.php - This third-party file is required for APC Status. It may
+ already be present on your computer (e.g. in /usr/share/doc/php-apc) or may
+ be extracted from the Memcache source (http://pecl.php.net/package/memcache).
+
+Installation:
+ - Create a directory named "memcache" somewhere Libraries API can find it,
+ e.g. sites/all/libraries/memcache.
+ - Rename memcache.php to memcache.php.inc and place it in the memcache
+ directory.
+
+ For example:
+ $ mkdir -p sites/all/libraries/memcache
+ $ cd sites/all/libraries/memcache
+ $ curl http://svn.php.net/viewvc/pecl/memcache/trunk/memcache.php?view=co \
+ > memcache.php.inc
+
+ - You will also want to remove the $MEMCACHE_SERVERS variable in your
+ memcache.php.inc file. This module will pull this information from your
+ configuration settings.
+
+Usage:
+ - Log in to your Drupal site as an administrator and visit
+ admin/reports/status/memcache.
diff --git a/memcache_status.admin.inc b/memcache_status.admin.inc
new file mode 100644
index 0000000..f53f9c6
--- /dev/null
+++ b/memcache_status.admin.inc
@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * @file
+ * Memcache Status menu callbacks.
+ */
+
+
+/**
+ * Menu callback; display the memcache status page.
+ */
+function memcache_status_memcache() {
+ // apc.php is broken without clean URLs.
+ if (!variable_get('clean_url', '0')) {
+ return t('<a href="@clean-url">Clean URLs</a> are required to access the memcache status page.', array('@clean-url' => url('admin/settings/clean-urls')));
+ }
+
+ // Locate apc.php.inc.
+ $memcache = libraries_get_path('memcache') . '/memcache.php.inc';
+ if (!is_file($memcache)) {
+ $output = t('<code>memcache.php.inc</code> not found. Please download and extract <a href="@memcache-url">memcache</a>, rename <code>memcache.php</code> to <code>memcache.php.inc</code> and place the file in a directory named <code>memcache</code> that <a href="@libraries-api-url">Libraries API</a> can find (i.e., in <code>sites/all/libraries/memcache</code>).', array('@memcache-url' => "http://pecl.php.net/package/memcache", '@libraries-api-url' => "http://drupal.org/project/libraries"));
+ return $output;
+ }
+
+ // Hacks to get the memcache.php file working.
+ global $MEMCACHE_SERVERS, $PHP_SELF;
+ $_SERVER['PHP_SELF'] = url('admin/reports/status/memcache');
+ $PHP_SELF = $_SERVERS['PHP_SELF'];
+ $_SERVER['PHP_AUTH_USER'] = 'memcache';
+ $_SERVER['PHP_AUTH_PW'] = 'password';
+ $MEMCACHE_SERVERS = array_keys(variable_get('memcache_servers', array()));
+
+ // We cannot use module_load_include as otherwise the above variables
+ // will not be in the global scope in the included PHP file.
+ require_once $memcache;
+ exit();
+}
diff --git a/memcache_status.info b/memcache_status.info
index fd6d1c2..bda5983 100644
--- a/memcache_status.info
+++ b/memcache_status.info
@@ -1 +1,5 @@
name = Memcache Status
+description = Adds Memcache status to the administrative reports.
+core = 7.x
+dependencies[] = libraries
+configure = admin/reports/status/memcache
diff --git a/memcache_status.install b/memcache_status.install
new file mode 100644
index 0000000..b5b4706
--- /dev/null
+++ b/memcache_status.install
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * @file
+ * Memcache Status install-time module hooks.
+ */
+
+
+/**
+ * Implements hook_requirements().
+ */
+function memcache_status_requirements($phase) {
+ $requirements = array();
+ $t = get_t();
+
+ if ($phase == 'runtime') {
+ $requirements['memcache_status'] = array(
+ 'title' => $t('Memcache status'),
+ 'value' => l(function_exists('memcache_debug') ? 'Enabled' : 'Disabled', 'admin/reports/status/memcache'),
+ );
+ }
+
+ return $requirements;
+}
diff --git a/memcache_status.module b/memcache_status.module
new file mode 100644
index 0000000..672249d
--- /dev/null
+++ b/memcache_status.module
@@ -0,0 +1,35 @@
+<?php
+
+/**
+ * @file
+ * Memcache Status module hooks.
+ */
+
+
+/**
+ * Implements hook_menu().
+ */
+function memcache_status_menu() {
+ $items['admin/reports/status/memcache'] = array(
+ 'title' => 'Memcache',
+ 'page callback' => 'memcache_status_memcache',
+ 'access arguments' => array('access memcache status'),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'memcache_status.admin.inc',
+ );
+ return $items;
+}
+
+
+/**
+ * Implements hook_permission().
+ */
+function memcache_status_permission() {
+ return array(
+ 'access memcache status' => array(
+ 'title' => t('Access Memcache status'),
+ 'description' => t('View cache reports and flush memcache servers.'),
+ 'restrict access' => TRUE,
+ ),
+ );
+}