Просто добавление к этой теме ... Ниже приведена версия кода, опубликованного pahlevan, но для C # / XNA и немного подобрана:
/// <summary>
/// Intersects a line and a circle.
/// </summary>
/// <param name="location">the location of the circle</param>
/// <param name="radius">the radius of the circle</param>
/// <param name="lineFrom">the starting point of the line</param>
/// <param name="lineTo">the ending point of the line</param>
/// <returns>true if the line and circle intersect each other</returns>
public static bool IntersectLineCircle(Vector2 location, float radius, Vector2 lineFrom, Vector2 lineTo)
{
float ab2, acab, h2;
Vector2 ac = location - lineFrom;
Vector2 ab = lineTo - lineFrom;
Vector2.Dot(ref ab, ref ab, out ab2);
Vector2.Dot(ref ac, ref ab, out acab);
float t = acab / ab2;
if (t < 0)
t = 0;
else if (t > 1)
t = 1;
Vector2 h = ((ab * t) + lineFrom) - location;
Vector2.Dot(ref h, ref h, out h2);
return (h2 <= (radius * radius));
}
Для тех, у кого есть тот же вопрос, здесь мое решение:
В wp-includes/functions.php
:
add_filter('wpcf7_validate_file*', 'cf7_custom_file_validation', 10, 2);
add_filter('wpcf7_validate_file', 'cf7_custom_file_validation', 10, 2);
function cf7_custom_file_validation ($result, $tag) {
if ($tag->name === 'file-586') {
$contentType = mime_content_type($_FILES[$tag->name]['tmp_name']);
if ($contentType !== 'image/png' && $contentType !== 'image/jpeg' && $contentType !== 'application/pdf') {
$result->invalidate($tag, 'Ce type de fichier n\'est pas supporté');
}
}
return $result;
}
Wordpress использует фильтр upload_mimes
для управления тем, какие типы MIME разрешены на всем сайте. Вы можете настроить этот список, добавив следующее в wp-includes / functions.php:
function safe_mime_types($mime_types){
unset($mime_types['exe']); //remove .exe support
return $mime_types;
}
add_filter('upload_mimes', 'safe_mime_types', 1, 1);
Вы также можете добавить приемлемые типы MIME:
function safe_mime_types($mime_types){
$mime_types['svg'] = 'image/svg+xml'; //add .svg support
unset($mime_types['exe']);
return $mime_types;
}
add_filter('upload_mimes', 'safe_mime_types', 1, 1);
Я нашел для вас несколько полезных ответов на нашем форуме: PHP Загрузка файлов - только проверка изображения
Попробуйте этот ответ:
<?php
function isImage($img){
return (bool)getimagesize($img);
}
?>
Добавлено Джереми Харрис.
Вот руководство по getimagesize () http://php.net/manual/pl/function.getimagesize.php