Update functions.inc.php

This commit is contained in:
arionum
2020-09-17 21:13:17 +03:00
committed by GitHub
parent 79a5fd4e28
commit 0d2bd3b419

View File

@@ -250,6 +250,11 @@ function ec_verify($data, $signature, $key)
}
return false;
}
// verify the validity of an url
function isValidURL($url)
{
return preg_match('|^(ht)?(f)?tp(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
}
// POST data to an URL (usualy peer). The data is an array, json encoded with is sent as $_POST['data']
function peer_post($url, $data = [], $timeout = 60, $debug = false)
@@ -258,6 +263,9 @@ function peer_post($url, $data = [], $timeout = 60, $debug = false)
if ($debug) {
echo "\nPeer post: $url\n";
}
if (!isValidURL($url)) {
return false;
}
$postdata = http_build_query(
[
'data' => json_encode($data),