Changeset 3310564
- Timestamp:
- 06/12/2025 02:18:01 PM (10 months ago)
- Location:
- dynamic-front-end-heartbeat-control
- Files:
-
- 2 edited
-
tags/1.2.98/visitor/cookie-helper.php (modified) (3 diffs)
-
trunk/visitor/cookie-helper.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dynamic-front-end-heartbeat-control/tags/1.2.98/visitor/cookie-helper.php
r3310561 r3310564 18 18 } 19 19 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'); 26 26 27 27 $visitor_id = empty($_COOKIE[$name]) … … 45 45 if (extension_loaded('redis') && class_exists('Redis')) { 46 46 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()) { 54 57 $redis->incr('dfehc_total_visitors'); 55 58 $redis->close(); 56 59 $fallback = false; 57 60 } 58 } catch ( Exception $e) {61 } catch (RedisException $e) { 59 62 } 60 63 } … … 65 68 $connected = @$memcached->addServer( 66 69 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(): 1121170 function_exists('dfehc_get_memcached_port') ? dfehc_get_memcached_port() : 11211 68 71 ); 69 72 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 } 71 77 $memcached->quit(); 72 78 $fallback = false; -
dynamic-front-end-heartbeat-control/trunk/visitor/cookie-helper.php
r3310561 r3310564 18 18 } 19 19 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'); 26 26 27 27 $visitor_id = empty($_COOKIE[$name]) … … 45 45 if (extension_loaded('redis') && class_exists('Redis')) { 46 46 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()) { 54 57 $redis->incr('dfehc_total_visitors'); 55 58 $redis->close(); 56 59 $fallback = false; 57 60 } 58 } catch ( Exception $e) {61 } catch (RedisException $e) { 59 62 } 60 63 } … … 65 68 $connected = @$memcached->addServer( 66 69 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(): 1121170 function_exists('dfehc_get_memcached_port') ? dfehc_get_memcached_port() : 11211 68 71 ); 69 72 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 } 71 77 $memcached->quit(); 72 78 $fallback = false;
Note: See TracChangeset
for help on using the changeset viewer.