Skip to content

Instantly share code, notes, and snippets.

@svrnm
svrnm / anonymize_ip.php
Last active March 27, 2018 22:10
Anonymize IPv4 and IPv6 addresses
<?php
function anonymize_ip($ip) {
if($ip = @inet_pton($ip)) {
return inet_ntop(substr($ip, 0, strlen($ip)/2) . str_repeat( chr(0), strlen($ip)/2 ));
}
return '0.0.0.0';
}
?>
@svrnm
svrnm / ClientCacheFilter.php
Last active August 29, 2015 13:55
This version of ClientCacheFilter.php uses laravel session instead of $_SESSION
<?php namespace Codesleeve\AssetPipeline\Filters;
use DateTime;
use Session;
use Assetic\Cache\CacheInterface;
class ClientCacheFilter implements CacheInterface
{
/**
* This is a decorator class which uses an underlying CacheInterface