]> 472bisson.ca Git - magnet.git/blobdiff - index.php
Small Changes
[magnet.git] / index.php
index 18644b2f4424f737a995017cc047fadd1ce920b8..238a241f0e9f3780bd90ed5482f1d195310e64f6 100644 (file)
--- a/index.php
+++ b/index.php
-<!DOCTYPE html>
-<html lang="en">
-    <head>
-        <title>Torrage</title>
-        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
-        <link href="style.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h1>Torrage</h1>
-        <form action="index.php" method="get">
-            <input type="text" name="infohash"/>
-            <input type="submit" value="Get .torrent"/>
-            <br />
-            <input type="radio" name="site" value="torrage" checked/>
-            <span>Torrage</span>
-            <input type="radio" name="site" value="torcache"/>
-            <span>Torcache</span>
-            <input type="radio" name="site" value="zoink"/>
-            <span>Zoink</span>
-        </form>                
-        <?php
-        /************************
-          http://torrage.com/torrent/640FE84C613C17F663551D218689A64E8AEBEABE.torrent
-          http://torcache.net/torrent/640FE84C613C17F663551D218689A64E8AEBEABE.torrent
-          http://zoink.it/torrent/640FE84C613C17F663551D218689A64E8AEBEABE.torrent
-        *************************/
-        if(filter_has_var(INPUT_GET, 'infohash') && filter_has_var(INPUT_GET, 'site'))
-        {
-            $infohash = filter_input(INPUT_GET, 'infohash');
-            $site = filter_input(INPUT_GET, 'site');
-            if(strlen($infohash) == 40 && ctype_xdigit($infohash))
-            {
-                $infohash = strtoupper($infohash);
-                //echo "Debug:$url = ".$url."<br />";
-                if($site == 'torrage')
-                {
-                    $url = "http://torrage.com/torrent/" . $infohash . ".torrent";
-                    header('Location: ' . $url);  //Internet 
-                }
-                else if($site == 'torcache')
-                {
-                    $url = "http://torcache.net/torrent/" . $infohash . ".torrent";
-                    header('Location: ' . $url);  //Internet 
-                }
-                else
-                {
-                    $url = "http://zoink.it/torrent/" . $infohash . ".torrent";
-                    header('Location: ' . $url);  //Internet 
-                }
-            }
-            else
-            {
-                echo "<span>Invalid INFO_HASH</span>";
-            }
-        }
-        ?>
-    </body>
-</html>                                                                                                           
\ No newline at end of file
+<?php\r
+\r
+$infohash = null;\r
+$tor_name = null;\r
+$trackers = null;\r
+$webseeds = null;\r
+\r
+$trackers = str_replace("&tr="," ",$trackers);\r
+\r
+if(filter_has_var(INPUT_GET, 'submit'))\r
+{\r
+       $infohash = filter_input(INPUT_GET, 'infohash');\r
+       $tor_name = filter_input(INPUT_GET, 'tname');\r
+       $trackers = filter_input(INPUT_GET, 'trackers');\r
+       $webseeds = filter_input(INPUT_GET, 'webseeds');\r
+\r
+       $infohash = strtoupper($infohash);\r
+\r
+       if(strlen($infohash) == 0)\r
+       {\r
+               $error_code = 1;\r
+       }\r
+       else if(strlen($infohash) == 40 && ctype_xdigit($infohash))\r
+       {\r
+               $magnetlink = "magnet:?xt=urn:btih:" . $infohash;\r
+\r
+               if($tor_name != "")\r
+               {\r
+                       $magnetlink = $magnetlink . "&dn=" . $tor_name;\r
+               }\r
+               if($trackers != "")\r
+               {\r
+                       $trackers = str_replace("\r","&tr=",$trackers);\r
+                       $trackers = str_replace(" ","&tr=",$trackers);\r
+                       $magnetlink = $magnetlink . "&tr=" . $trackers;\r
+               }\r
+               if ($webseeds != "")\r
+               {\r
+                       $magnetlink = $magnetlink . "&ws=" . $webseeds;\r
+               }\r
+       }\r
+       else\r
+       {\r
+               $error_code = 2;\r
+       }\r
+       //$magnetlink = "magnet:?xt=urn:btih:" .$infohash . "&dn=" . $tor_name . "&tr=" . $trackers;\r
+}\r
+?>\r
+<!DOCTYPE html>\r
+<html lang="en">\r
+       <head>\r
+               <title>Magnet</title>\r
+               <meta charset="utf-8" />\r
+               <meta name="viewport" content="width=device-width, initial-scale=1">\r
+               <link rel="icon" type="image/png" sizes="32x32" href="magnet.png">\r
+               <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/w3css/4/w3.css">\r
+               <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/lib/w3-theme-red.css">\r
+               <link rel="stylesheet" type="text/css" href="style.css">\r
+       </head>\r
+       <body>\r
+               <section class="w3-panel"> \r
+               <div class="w3-card-4">\r
+                       <div class="w3-container w3-theme">\r
+                               <h2>Magnet Info</h2>\r
+                       </div>\r
+                       <form class="w3-container" name="magnet" method="get" action="#">\r
+                               <p>\r
+                                       <label>Infohash</label>\r
+                                       <input class="w3-input" type="text" name="infohash" value='<?php echo $infohash ?>' placeholder="Hash of the Torrent Ex: DA39A3EE5E6B4B0D3255BFEF95601890AFD80709" />\r
+                               </p>\r
+                               <p>\r
+                                       <label>Name</label>\r
+                                       <input class="w3-input" type="text" name="tname" value='<?php echo $tor_name ?>' placeholder="Name of the Torrent Ex:Linux 5.7" />\r
+                               </p>\r
+                               <p>\r
+                                       <label>Trackers</label>\r
+                                       <textarea  class="w3-input" name="trackers" placeholder="One tracker per line Ex: udp://tracker.opentrackr.org:1337/announce"><?php echo $trackers ?></textarea>\r
+                               </p>\r
+                               <p>\r
+                                       <label>Webseeds</label>\r
+                                       <input class="w3-input" type="text" name="webseeds" value='<?php echo $webseeds ?>' placeholder="Web Seeds Ex: http://example.com/linux.iso" />\r
+                               </p>\r
+                               <p>\r
+                                       <input class="w3-button w3-theme-l3" type="submit" name="submit" value="Create"/>\r
+                                       <input class="w3-button w3-theme-l3" type="reset" name="reset" value="Reset">\r
+                               </p>\r
+                       </form>\r
+               </div> \r
+               <?php\r
+               if(isset($error_code))\r
+               {\r
+                       if($error_code == 1)\r
+                       {\r
+                       ?>\r
+                       <div class="w3-panel w3-pale-red w3-leftbar w3-border-red">\r
+                               <p>Error : Infohash cannot be empty.</p>\r
+                       </div>\r
+                       <?php\r
+                       }\r
+                       else if($error_code == 2)\r
+                       {\r
+                       ?>\r
+                       <div class="w3-panel w3-pale-red w3-leftbar w3-border-red">\r
+                               <p>Error : Invalid Infohash.</p>\r
+                       </div>\r
+                       <?php\r
+                       }\r
+               }\r
+               else if(isset($magnetlink))\r
+               {\r
+               ?>\r
+                       <div id="magnet" class="w3-panel w3-pale-green w3-leftbar w3-border-green">\r
+                               <p><a href = "<?php echo $magnetlink; ?>"><?php echo $magnetlink; ?></a></p>\r
+                       </div>\r
+               <?php\r
+               }\r
+               else\r
+               {\r
+               ?>\r
+                       <div class="w3-panel w3-pale-blue w3-leftbar w3-border-blue">\r
+                               <p>Enter Some Torrent Info Hash</p>\r
+                       </div>\r
+               <?php\r
+               }\r
+               ?>\r
+       </section>\r
+       <footer class="w3-panel">\r
+               <a href="https://www.w3schools.com/w3css/" target="_blank" >W3.css</a>\r
+               <a href="https://github.com/cvmanjoo/magnet/" target="_blank" >Github</a>\r
+       </footer>\r
+       </body>\r
+</html>
\ No newline at end of file