0

Magnet link:

magnet:?xt=urn:btih:8fe65e43464debe1bc0961e4656ea780368d4fba&dn=A+Goofy+Movie+%281995%29+720p+HDTVRip+x264+Eng+Subs+%5BDual+Audio%5D+%5BHindi+DD+2.0+-+English+DD+2.0%5D+Exclusive+By+-%3D%21Dr.STAR%21%3D-&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Fglotorrents.pw%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fzer0day.to%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce

My question is how to check this link is valid or in valid in PHP

Sorry but i am new in coding and i dont have much knowledge of coding

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

1 Answers1

2

For PHP it can be done like so:

$str = 'magnet:?xt=urn:btih:74651f66e937698dc5ac1e0e252f44795070a7b5&dn=archlinux-2017.03.01-dual.iso&tr=udp://tracker.archlinux.org:6969&tr=http://tracker.archlinux.org:6969/announce';

if(preg_match('/magnet:\?xt=urn:[a-z0-9]+:[a-z0-9]{32,40}/', $str)){
  echo 'valid';
}

But this only checks if the format is in order, you don't know if the magnet link will work unless you try it out.

Xorifelse
  • 7,878
  • 1
  • 27
  • 38