]> 472bisson.ca Git - magnet.git/blob - index.php
6f9e74078f779d2e56b8a8c004436812a3c7c605
[magnet.git] / index.php
1 <?php
2 if(filter_has_var(INPUT_GET, 'submit'))
3 {
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');
8
9 if(strlen($infohash) == 0)
10 {
11 $error_code = 1;
12 }
13 else if(strlen($infohash) == 40 && ctype_xdigit($infohash))
14 {
15 $magnetlink = "magnet:?xt=urn:btih:" . $infohash;
16
17 if($name != "")
18 {
19 $magnetlink = $magnetlink . "&dn=" . $name;
20 }
21 if($trackers != "")
22 {
23 $trackers = str_replace("\r","&tr=",$trackers);
24 $trackers = str_replace(" ","&tr=",$trackers);
25 $magnetlink = $magnetlink . "&tr=" . $trackers;
26 }
27 if ($webseeds != "")
28 {
29 $magnetlink = $magnetlink . "&ws=" . $webseeds;
30 }
31 }
32 else
33 {
34 $error_code = 2;
35 }
36 //$magnetlink = "magnet:?xt=urn:btih:" .$infohash . "&dn=" . $name . "&tr=" . $trackers;
37 }
38 ?>
39 <!DOCTYPE html>
40 <html lang="en">
41 <head>
42 <title>Magnet</title>
43 <meta charset="utf-8" />
44 <meta name="viewport" content="width=device-width, initial-scale=1">
45
46 <link rel="icon" type="image/png" sizes="32x32" href="magnet.png">
47
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">
51 </head>
52 <body>
53 <section class="w3-panel">
54 <div class="w3-card-4">
55 <div class="w3-container w3-theme">
56 <h2>Magnet Info</h2>
57 </div>
58 <form class="w3-container" name="magnet" method="get" action="#">
59 <p>
60 <label>Infohash</label>
61 <input class="w3-input" type="text" name="infohash" placeholder="Hash of the Torrent Ex: DA39A3EE5E6B4B0D3255BFEF95601890AFD80709" />
62 </p>
63 <p>
64 <label>Name</label>
65 <input class="w3-input" type="text" name="tname" placeholder="Name of the Torrent Ex:Linux 5.7" />
66 </p>
67 <p>
68 <label>Trackers</label>
69 <textarea class="w3-input" name="trackers" placeholder="One tracker per line Ex: udp://tracker.opentrackr.org:1337/announce"></textarea>
70 </p>
71 <p>
72 <label>Webseeds</label>
73 <input class="w3-input" type="text" name="webseeds" placeholder="Web Seeds Ex: http://example.com/linux.iso" />
74 </p>
75 <p>
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">
78 </p>
79 </form>
80 </div>
81
82 <?php
83 if(isset($error_code))
84 {
85 if($error_code == 1)
86 {
87 ?>
88 <div class="w3-panel w3-pale-red w3-leftbar w3-border-red">
89 <p>Error : Infohash cannot be empty.</p>
90 </div>
91 <?php
92 }
93 else if($error_code == 2)
94 {
95 ?>
96 <div class="w3-panel w3-pale-red w3-leftbar w3-border-red">
97 <p>Error : Invalid Infohash.</p>
98 </div>
99 <?php
100 }
101 }
102 else if(isset($magnetlink))
103 {
104 ?>
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>
107 </div>
108 <?php
109 }
110 else
111 {
112 ?>
113 <div class="w3-panel w3-pale-blue w3-leftbar w3-border-blue">
114 <p>Enter Some Torrent Info Hash</p>
115 </div>
116 <?php
117 }
118 ?>
119 </section>
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>
123 </footer>
124 </body>
125 </html>