Plugin Directory

Changeset 3310564


Ignore:
Timestamp:
06/12/2025 02:18:01 PM (10 months ago)
Author:
loghin
Message:

1.2.98

Location:
dynamic-front-end-heartbeat-control
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • dynamic-front-end-heartbeat-control/tags/1.2.98/visitor/cookie-helper.php

    r3310561 r3310564  
    1818    }
    1919
    20     $name       = 'dfehc_user';
    21     $lifetime   = 400;
    22     $path       = apply_filters('dfehc_cookie_path', '/');
    23     $secure     = is_ssl();
    24     $httponly   = true;
    25     $same_site  = apply_filters('dfehc_cookie_samesite', 'Strict');
     20    $name      = 'dfehc_user';
     21    $lifetime  = 400;
     22    $path      = apply_filters('dfehc_cookie_path', '/');
     23    $secure    = is_ssl();
     24    $httponly  = true;
     25    $same_site = apply_filters('dfehc_cookie_samesite', 'Strict');
    2626
    2727    $visitor_id = empty($_COOKIE[$name])
     
    4545    if (extension_loaded('redis') && class_exists('Redis')) {
    4646        try {
    47             $redis      = new Redis();
    48             $socket     = get_option('dfehc_redis_socket', '');
    49             $connected  = $socket ? @$redis->connect($socket) : @$redis->connect(
    50                 function_exists('dfehc_get_redis_server') ? dfehc_get_redis_server() : '127.0.0.1',
    51                 function_exists('dfehc_get_redis_port') ? dfehc_get_redis_port() : 6379
    52             );
    53             if ($connected) {
     47            $redis     = new Redis();
     48            $socket    = get_option('dfehc_redis_socket', '');
     49            $connected = $socket
     50                ? @$redis->connect($socket)
     51                : @$redis->connect(
     52                    function_exists('dfehc_get_redis_server') ? dfehc_get_redis_server() : '127.0.0.1',
     53                    function_exists('dfehc_get_redis_port')   ? dfehc_get_redis_port()   : 6379,
     54                    1
     55                );
     56            if ($connected && $redis->ping()) {
    5457                $redis->incr('dfehc_total_visitors');
    5558                $redis->close();
    5659                $fallback = false;
    5760            }
    58         } catch (Exception $e) {
     61        } catch (RedisException $e) {
    5962        }
    6063    }
     
    6568            $connected = @$memcached->addServer(
    6669                function_exists('dfehc_get_memcached_server') ? dfehc_get_memcached_server() : '127.0.0.1',
    67                 function_exists('dfehc_get_memcached_port') ? dfehc_get_memcached_port() : 11211
     70                function_exists('dfehc_get_memcached_port')   ? dfehc_get_memcached_port()  : 11211
    6871            );
    6972            if ($connected) {
    70                 $memcached->increment('dfehc_total_visitors', 1, 1);
     73                $result = $memcached->increment('dfehc_total_visitors', 1);
     74                if ($result === false && $memcached->getResultCode() === Memcached::RES_NOTFOUND) {
     75                    $memcached->set('dfehc_total_visitors', 1);
     76                }
    7177                $memcached->quit();
    7278                $fallback = false;
  • dynamic-front-end-heartbeat-control/trunk/visitor/cookie-helper.php

    r3310561 r3310564  
    1818    }
    1919
    20     $name       = 'dfehc_user';
    21     $lifetime   = 400;
    22     $path       = apply_filters('dfehc_cookie_path', '/');
    23     $secure     = is_ssl();
    24     $httponly   = true;
    25     $same_site  = apply_filters('dfehc_cookie_samesite', 'Strict');
     20    $name      = 'dfehc_user';
     21    $lifetime  = 400;
     22    $path      = apply_filters('dfehc_cookie_path', '/');
     23    $secure    = is_ssl();
     24    $httponly  = true;
     25    $same_site = apply_filters('dfehc_cookie_samesite', 'Strict');
    2626
    2727    $visitor_id = empty($_COOKIE[$name])
     
    4545    if (extension_loaded('redis') && class_exists('Redis')) {
    4646        try {
    47             $redis      = new Redis();
    48             $socket     = get_option('dfehc_redis_socket', '');
    49             $connected  = $socket ? @$redis->connect($socket) : @$redis->connect(
    50                 function_exists('dfehc_get_redis_server') ? dfehc_get_redis_server() : '127.0.0.1',
    51                 function_exists('dfehc_get_redis_port') ? dfehc_get_redis_port() : 6379
    52             );
    53             if ($connected) {
     47            $redis     = new Redis();
     48            $socket    = get_option('dfehc_redis_socket', '');
     49            $connected = $socket
     50                ? @$redis->connect($socket)
     51                : @$redis->connect(
     52                    function_exists('dfehc_get_redis_server') ? dfehc_get_redis_server() : '127.0.0.1',
     53                    function_exists('dfehc_get_redis_port')   ? dfehc_get_redis_port()   : 6379,
     54                    1
     55                );
     56            if ($connected && $redis->ping()) {
    5457                $redis->incr('dfehc_total_visitors');
    5558                $redis->close();
    5659                $fallback = false;
    5760            }
    58         } catch (Exception $e) {
     61        } catch (RedisException $e) {
    5962        }
    6063    }
     
    6568            $connected = @$memcached->addServer(
    6669                function_exists('dfehc_get_memcached_server') ? dfehc_get_memcached_server() : '127.0.0.1',
    67                 function_exists('dfehc_get_memcached_port') ? dfehc_get_memcached_port() : 11211
     70                function_exists('dfehc_get_memcached_port')   ? dfehc_get_memcached_port()  : 11211
    6871            );
    6972            if ($connected) {
    70                 $memcached->increment('dfehc_total_visitors', 1, 1);
     73                $result = $memcached->increment('dfehc_total_visitors', 1);
     74                if ($result === false && $memcached->getResultCode() === Memcached::RES_NOTFOUND) {
     75                    $memcached->set('dfehc_total_visitors', 1);
     76                }
    7177                $memcached->quit();
    7278                $fallback = false;
Note: See TracChangeset for help on using the changeset viewer.