expmail/helpers.php

25 lines
863 B
PHP
Raw Normal View History

2020-09-03 06:31:10 +00:00
<?php
function getFilename($url){
$content = get_headers($url,1);
$content = array_change_key_case($content, CASE_LOWER);
if ($content['content-disposition']) {
$tmp_name = explode('=', $content['content-disposition']);
if ($tmp_name[1]) $realfilename = trim($tmp_name[1],'";\'');
} else {
$stripped_url = preg_replace('/\\?.*/', '', $url);
2020-09-04 08:22:36 +00:00
$stripped_url = preg_replace('/\\/$/', '', $stripped_url);
2020-09-03 06:31:10 +00:00
$realfilename = basename($stripped_url);
}
2020-09-03 08:11:28 +00:00
return $realfilename;
2020-09-03 06:31:10 +00:00
}
function checkURL($url) {
$url = filter_var($url, FILTER_SANITIZE_URL);
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE || !in_array(strtolower(parse_url($url, PHP_URL_SCHEME)), ['http','https'], true)) return false;
$file_headers = @get_headers($url);
if ($httpStatus<400) return true;
return false;
}