Skip to content

Instantly share code, notes, and snippets.

@samdark
samdark / github-post-receive.php
Last active Oct 11, 2019
Simple GitHub post-receive PHP hook
View github-post-receive.php
<?php
function cidr_match($ip, $ranges)
{
$ranges = (array)$ranges;
foreach($ranges as $range) {
list($subnet, $mask) = explode('/', $range);
if((ip2long($ip) & ~((1 << (32 - $mask)) - 1)) == ip2long($subnet)) {
return true;
}
}
You can’t perform that action at this time.