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