public function ajaxProcess()
 {
     /* PrestaShop demo mode */
     if (_PS_MODE_DEMO_) {
         die(Tools::displayError('This functionality has been disabled.'));
     }
     /* PrestaShop demo mode*/
     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;
 }
Exemple #2
0
 /**
  * 用于获取一个服务器的在线/离线状态
  *
  * @param mixed $host
  * @param mixed $port
  */
 public function getServerStatus($host, $port = 11211)
 {
     $re = memcache_get_server_status($this->memcache, $host, $port);
     return $re;
 }
 public function displayAjaxTestServer()
 {
     /* PrestaShop demo mode */
     if (_PS_MODE_DEMO_) {
         die(Tools::displayError('This functionality has been disabled.'));
     }
     /* PrestaShop demo mode*/
     if (Tools::isSubmit('action') && Tools::getValue('action') == 'test_server') {
         $host = pSQL(Tools::getValue('sHost', ''));
         $port = (int) Tools::getValue('sPort', 0);
         $type = Tools::getValue('type', '');
         if ($host != '' && $port != 0) {
             $res = 0;
             if ($type == 'memcached') {
                 if (extension_loaded('memcached') && @fsockopen($host, $port)) {
                     $memcache = new Memcached();
                     $memcache->addServer($host, $port);
                     $res = in_array('255.255.255', $memcache->getVersion(), true) === false;
                 }
             } else {
                 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;
 }
 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;
 }
 function status()
 {
     return memcache_get_server_status($this->_memcached);
 }