// Display memcached server status : #PSFV-631
This commit is contained in:
@@ -89,6 +89,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
<input type="submit" value="{l s=' Add Server '}" name="submitAddServer" class="button" />
|
<input type="submit" value="{l s=' Add Server '}" name="submitAddServer" class="button" />
|
||||||
|
<input type="button" value="{l s=' Test Server '}" id="testMemcachedServer" class="button" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -145,12 +146,47 @@
|
|||||||
$('#caching_system').change(function() {
|
$('#caching_system').change(function() {
|
||||||
showMemcached();
|
showMemcached();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#addMemcachedServer').click(function() {
|
$('#addMemcachedServer').click(function() {
|
||||||
$('#formMemcachedServer').show();
|
$('#formMemcachedServer').show();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#testMemcachedServer').click(function() {
|
||||||
|
var host = $('input:text[name=memcachedIp]').val();
|
||||||
|
var port = $('input:text[name=memcachedPort]').val();
|
||||||
|
if (host && port)
|
||||||
|
{
|
||||||
|
$.ajax({
|
||||||
|
url: 'index.php',
|
||||||
|
data:
|
||||||
|
{
|
||||||
|
controller: 'adminperformance',
|
||||||
|
token: '{$token}',
|
||||||
|
action: 'test_server',
|
||||||
|
sHost: host,
|
||||||
|
sPort: port,
|
||||||
|
ajax: true
|
||||||
|
},
|
||||||
|
context: document.body,
|
||||||
|
dataType: 'json',
|
||||||
|
context: this,
|
||||||
|
async: false,
|
||||||
|
success: function(data)
|
||||||
|
{
|
||||||
|
if (data)
|
||||||
|
{
|
||||||
|
var color = data != 0 ? 'green' : 'red';
|
||||||
|
$('#formMemcachedServerStatus').show();
|
||||||
|
$('input:text[name=memcachedIp]').css('background', color);
|
||||||
|
$('input:text[name=memcachedPort]').css('background', color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
$('input[name="smarty_force_compile"], input[name="smarty_cache"], input[name="smarty_console"]').change(function(){
|
$('input[name="smarty_force_compile"], input[name="smarty_cache"], input[name="smarty_console"]').change(function(){
|
||||||
$('#smarty_up').val(1);
|
$('#smarty_up').val(1);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -503,13 +503,13 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
public function initContent()
|
public function initContent()
|
||||||
{
|
{
|
||||||
if (!extension_loaded('memcache'))
|
if (!extension_loaded('memcache'))
|
||||||
$this->warnings[] = $this->l('To use Memcached, you must install the Memcache PECL extension on your server.').'
|
$this->warnings[] = $this->l('To use Memcached, you must install the Memcache PECL extension on your server.').'
|
||||||
<a href="http://www.php.net/manual/en/memcache.installation.php">http://www.php.net/manual/en/memcache.installation.php</a>';
|
<a href="http://www.php.net/manual/en/memcache.installation.php">http://www.php.net/manual/en/memcache.installation.php</a>';
|
||||||
if (!extension_loaded('apc'))
|
if (!extension_loaded('apc'))
|
||||||
$this->warnings[] = $this->l('To use APC, you must install the APC PECL extension on your server.').'
|
$this->warnings[] = $this->l('To use APC, you must install the APC PECL extension on your server.').'
|
||||||
<a href="http://fr.php.net/manual/fr/apc.installation.php">http://fr.php.net/manual/fr/apc.installation.php</a>';
|
<a href="http://fr.php.net/manual/fr/apc.installation.php">http://fr.php.net/manual/fr/apc.installation.php</a>';
|
||||||
if (!extension_loaded('xcache'))
|
if (!extension_loaded('xcache'))
|
||||||
$this->warnings[] = $this->l('To use Xcache, you must install the Xcache extension on your server.').'
|
$this->warnings[] = $this->l('To use Xcache, you must install the Xcache extension on your server.').'
|
||||||
<a href="http://xcache.lighttpd.net">http://xcache.lighttpd.net</a>';
|
<a href="http://xcache.lighttpd.net">http://xcache.lighttpd.net</a>';
|
||||||
|
|
||||||
if (!is_writable(_PS_CACHEFS_DIRECTORY_))
|
if (!is_writable(_PS_CACHEFS_DIRECTORY_))
|
||||||
@@ -759,6 +759,30 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
else
|
else
|
||||||
return parent::postProcess();
|
return parent::postProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ajaxProcess()
|
||||||
|
{
|
||||||
|
if (Tools::isSubmit('action') && Tools::getValue('action') == 'test_server')
|
||||||
|
{
|
||||||
|
$host = pSQL(Tools::getValue('sHost', ''));
|
||||||
|
$port = (int)Tools::getValue('sPort', 0);
|
||||||
|
|
||||||
|
if ($host != '' && $port != 0)
|
||||||
|
{
|
||||||
|
$res = 0;
|
||||||
|
|
||||||
|
if (function_exists('memcache_get_server_status') &&
|
||||||
|
function_exists('memcache_connect') &&
|
||||||
|
@fsockopen($host, $port))
|
||||||
|
{
|
||||||
|
$memcache = @memcache_connect($host, $port);
|
||||||
|
$res = @memcache_get_server_status($memcache, $host, $port);
|
||||||
|
}
|
||||||
|
die(Tools::jsonEncode(array($res)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user