curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $return = curl_exec($ch); curl_close($ch); if (!$return || strlen($return) < 1) { die('Couldn\'t get ip addresses from GitHub!'); } $github_addresses = json_decode($return); if (!$github_address->hooks) { die('GitHub api request failed!'); } // Loop through the addresses and make sure the request is from inside one of the ranges $found_match = false; foreach ($github_address->hooks as $hook) { list($net_addr, $net_mask) = explode('/', $hook); if (ip_in_network($_SERVER['REMOTE_ADDR'], $net_addr, $net_mask)) { $found_match = true; break; } } if (!$found) { die('Not from GitHub!'); } // Check there is a payload if (!isset($_POST['payload'])) { die('No Payload!'); } $payload = $_POST['payload']; $commit = json_decode($payload); $repository = $commit->repository; // Check we have a config for this repo
/** * bool current_ip_in_network(void) * Checks if the current user's ip is in the network * @uses ip_in_network */ function current_ip_in_network() { return ip_in_network(current_user_ip()); }
if ($qname_parts[1]) { $qname_ip = str_replace('-', '.', $qname_parts[1]); } foreach ($suffix_ipv4 as $prefix => $suffix) { if ($suffix['suffix'] == $qname_parts[2]) { switch ($qtype) { case 'SOA': if (ip_in_network($qname_ip, $prefix) || $qname == $suffix['suffix']) { $result = array('result' => array(array('qtype' => 'SOA', 'qname' => $qname, 'content' => implode(" ", $soa), 'ttl' => $soa[6]))); } break; case 'NS': break; default: // Convert to IP and confirm it's in this prefix if (ip_in_network($qname_ip, $prefix)) { $result = array('result' => array(array('qtype' => 'A', 'qname' => $qname, 'content' => $qname_ip, 'ttl' => $soa[6]))); } break; } } } } elseif (in_array_recursive($qname_parts[2], $suffix_ipv6)) { // Get IP from $qname_parts if possible if ($qname_parts[1]) { $qname_ip = str_replace('-', ':', $qname_parts[1]); } foreach ($suffix_ipv6 as $prefix => $suffix) { if ($suffix['suffix'] == $qname_parts[2]) { switch ($qtype) { case 'SOA':