2 if(filter_has_var(INPUT_GET
, 'submit'))
4 $infohash = filter_input(INPUT_GET
, 'infohash');
5 $name = filter_input(INPUT_GET
, 'tname');
6 $trackers = filter_input(INPUT_GET
, 'trackers');
7 $webseeds = filter_input(INPUT_GET
, 'webseeds');
9 if(strlen($infohash) == 0)
13 else if(strlen($infohash) == 40 && ctype_xdigit($infohash))
15 $magnetlink = "magnet:?xt=urn:btih:" . $infohash;
19 $magnetlink = $magnetlink . "&dn=" . $name;
23 $trackers = str_replace("\r","&tr=",$trackers);
24 $trackers = str_replace(" ","&tr=",$trackers);
25 $magnetlink = $magnetlink . "&tr=" . $trackers;
29 $magnetlink = $magnetlink . "&ws=" . $webseeds;
36 //$magnetlink = "magnet:?xt=urn:btih:" .$infohash . "&dn=" . $name . "&tr=" . $trackers;
43 <meta charset
="utf-8" />
44 <meta name
="viewport" content
="width=device-width, initial-scale=1">
46 <link rel
="icon" type
="image/png" sizes
="32x32" href
="magnet.png">
48 <link rel
="stylesheet" type
="text/css" href
="https://www.w3schools.com/w3css/4/w3.css">
49 <link rel
="stylesheet" type
="text/css" href
="https://www.w3schools.com/lib/w3-theme-red.css">
50 <link rel
="stylesheet" type
="text/css" href
="style.css">
53 <section
class="w3-panel">
54 <div
class="w3-card-4">
55 <div
class="w3-container w3-theme">
58 <form
class="w3-container" name
="magnet" method
="get" action
="#">
60 <label
>Infohash
</label
>
61 <input
class="w3-input" type
="text" name
="infohash" placeholder
="Hash of the Torrent Ex: DA39A3EE5E6B4B0D3255BFEF95601890AFD80709" />
65 <input
class="w3-input" type
="text" name
="tname" placeholder
="Name of the Torrent Ex:Linux 5.7" />
68 <label
>Trackers
</label
>
69 <textarea
class="w3-input" name
="trackers" placeholder
="One tracker per line Ex: udp://tracker.opentrackr.org:1337/announce"></textarea
>
72 <label
>Webseeds
</label
>
73 <input
class="w3-input" type
="text" name
="webseeds" placeholder
="Web Seeds Ex: http://example.com/linux.iso" />
76 <input
class="w3-button w3-theme-l3" type
="submit" name
="submit" value
="Create"/>
77 <input
class="w3-button w3-theme-l3" type
="reset" name
="reset" value
="Reset">
83 if(isset($error_code))
88 <div
class="w3-panel w3-pale-red w3-leftbar w3-border-red">
89 <p
>Error
: Infohash cannot be
empty.</p
>
93 else if($error_code == 2)
96 <div
class="w3-panel w3-pale-red w3-leftbar w3-border-red">
97 <p
>Error
: Invalid Infohash
.</p
>
102 else if(isset($magnetlink))
105 <div id
="magnet" class="w3-panel w3-pale-green w3-leftbar w3-border-green">
106 <p
><a href
= "<?php echo $magnetlink; ?>"><?php
echo $magnetlink; ?
></a
></p
>
113 <div
class="w3-panel w3-pale-blue w3-leftbar w3-border-blue">
114 <p
>Enter Some Torrent Info Hash
</p
>
120 <footer
class="w3-panel">
121 <a href
="https://www.w3schools.com/w3css/" target
="_blank" >W3
.css
</a
>
122 <a href
="https://github.com/cvmanjoo/magnet/" target
="_blank" >Github
</a
>