Skip to content
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

Improved flush() function, removed workarround for delete() and improved internationalisation #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config.ini.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
DEBUG_MODE = ON

[SERVER]
SERVER = 127.0.0.1
SERVER = localhost
PORT = 11211

[AUTH]
PASSWORD = 81b637d8fcd2c6da6359e6963113a1170de795e4b725b84d1e0b4cfd9ec58ce9

[MISC]
PHP_TIMEZONE = Europe/London
PHP_TIMEZONE = UTC



Expand Down
16 changes: 3 additions & 13 deletions delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,9 @@

$config = parse_ini_file('config.ini.php', true);

/*
* Because of an API change on Memcache's side, the PHP module's 'delete'
* doesn't work (it hasn't been updated). I've used raw sockets instead.
*
* See http://pecl.php.net/bugs/bug.php?id=16927 for bug report.
*/

$fs = fsockopen($config['SERVER']['SERVER'], $config['SERVER']['PORT']);

fwrite($fs, 'delete ' . $_GET['delete_item'] . "\r\n");

fclose($fs);

$MEMCACHE = new Memcache();
$MEMCACHE->connect($config['SERVER']['SERVER'], $config['SERVER']['PORT']);
$MEMCACHE->delete($_GET['delete_item']);
}

header("Location: index.php");
Expand Down
8 changes: 6 additions & 2 deletions scripts/reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ function setRefreshInterval(){
interval = setInterval('pageReload()', 1000 * document.getElementById('refresh_rate').value);
}

function pageReload(){
function pageReload(flush){

$("img#loading_gif").removeClass("hidden");
$("div#content").load("viewer.php", colourExpired);
if (flush)
$("div#content").load("viewer.php?flush=1", colourExpired);
else
$("div#content").load("viewer.php", colourExpired);

setTimeout(function(){$("img#loading_gif").addClass("hidden")}, 100);

}
Expand Down
1 change: 1 addition & 0 deletions template/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ <h1>MemcacheViewer</h1>
<input type="button" onclick="location.href='logout.php'" value="Logout" />
<div id="settings">
<label for="refresh_rate">Refresh Rate (secs)</label><input type="text" onchange="setRefreshInterval()" value="1" id="refresh_rate" name="refresh_rate" />
<a href="javascript:pageReload(1)">Flush entries</a>
</div>
</div>

Expand Down
8 changes: 7 additions & 1 deletion viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
or die('Memcache PHP module doesn\'t appear to be installed. It is needed.');

$MEMCACHE = new Memcache();
$MEMCACHE->pconnect(SERVER, PORT);
$MEMCACHE->connect(SERVER, PORT);

//set timezone
date_default_timezone_set(isset($config['MISC']['PHP_TIMEZONE'])
Expand Down Expand Up @@ -60,6 +60,12 @@

}

if (isset($_GET['flush']) && $_GET['flush'] == 1) {
// $MEMCACHE->flush() does not work in the windows memcached-driver implementation I found ...
foreach(array_keys($items) as $item_key) {
$MEMCACHE->delete($item_key);
}
}

/*
* Time to display some output.
Expand Down