nette / latte

☕ Latte: the safest & truly intuitive templates for PHP. Engine for those who want the most secure PHP sites.
https://latte.nette.org
Other
1.09k stars 106 forks source link

ipv4/ipv6 address filters #364

Open Izolant opened 1 month ago

Izolant commented 1 month ago

Hello,

Is there a plan to add support for IP address filtering?

Something like: https://fiddle.nette.org/latte/#4e3b1086c4

https://github.com/mlocati/ip-lib https://docs.ansible.com/ansible/3/user_guide/playbooks_filters_ipaddr.html

deba12 commented 1 month ago

You can make your own filter with such functionality. I have made such simple filter for binary ip addresses.

    /**
     * @param string|null $ip
     * @return string
     * @noinspection PhpUnused
     */
    public static function inet_ntop(?string $ip): string {
        if(empty($ip)){
            return '';
        }

        return inet_ntop($ip);
    }

with s1lentium/iptools:dev-master you can fulfill all of the desired functionality.