]> 472bisson.ca Git - magnet.git/commitdiff
A Complete Refresh
authorManjunath CV <cvmanjoo@gmail.com>
Thu, 23 Apr 2020 19:25:36 +0000 (00:55 +0530)
committerManjunath CV <cvmanjoo@gmail.com>
Thu, 23 Apr 2020 19:25:36 +0000 (00:55 +0530)
README.md
index.php
infohash.txt [deleted file]
magnet.html [new file with mode: 0644]
magnet.png [new file with mode: 0644]
style.css [new file with mode: 0644]

index a96e7a10227f74be76e3e5d47b20c22fd8b9cc1f..98ec99dc3f8ab750c4db2b0fab174eab0fc60ed6 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,5 +1,14 @@
-torrage
-=======
+# Hash to Magnet
 
 
-PHP script to generate .torrent file from info_hash
-That is pulling .torrents file from http://torrage.com
+Web tool to generate magnet URI from Torrent Hash.
+
+# Parameters
+
+* Magnet Hash (Required)
+* Name of Torrent (Optional)
+* Trackers (Optional)
+* Webseeds (Optional)
+
+# Resources
+1. Bittorrent Protocol http://bittorrent.org/beps/bep_0053.html
+2. CSS Design - https://www.w3schools.com/w3css/
index bda47446b534b861d9dc2a9f2f7ce5443b4ec225..6f9e74078f779d2e56b8a8c004436812a3c7c605 100644 (file)
--- a/index.php
+++ b/index.php
@@ -4,20 +4,35 @@ if(filter_has_var(INPUT_GET, 'submit'))
     $infohash = filter_input(INPUT_GET, 'infohash');\r
     $name = filter_input(INPUT_GET, 'tname');\r
     $trackers = filter_input(INPUT_GET, 'trackers');\r
     $infohash = filter_input(INPUT_GET, 'infohash');\r
     $name = filter_input(INPUT_GET, 'tname');\r
     $trackers = filter_input(INPUT_GET, 'trackers');\r
-\r
-    if(strlen($infohash) == 40 && ctype_xdigit($infohash))\r
-    {\r
-        $magnetlink = "magnet:?xt=urn:btih:" . $infohash;\r
-\r
-        if($name != "")\r
-        {\r
-            $magnetlink = $magnetlink . "&dn=" . $name;\r
-        }\r
-        if($trackers != "")\r
+    $webseeds = filter_input(INPUT_GET, 'webseeds');\r
+       \r
+       if(strlen($infohash) == 0)\r
+       {\r
+               $error_code = 1;\r
+       }\r
+        else if(strlen($infohash) == 40 && ctype_xdigit($infohash))\r
         {\r
         {\r
-            $magnetlink = $magnetlink . "&tr=" . $trackers;\r
+            $magnetlink = "magnet:?xt=urn:btih:" . $infohash;\r
+\r
+            if($name != "")\r
+            {\r
+                $magnetlink = $magnetlink . "&dn=" . $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
         }\r
-    }\r
+       else\r
+       {\r
+               $error_code = 2;\r
+       }\r
     //$magnetlink = "magnet:?xt=urn:btih:" .$infohash . "&dn=" . $name . "&tr=" . $trackers;\r
 }\r
 ?>\r
     //$magnetlink = "magnet:?xt=urn:btih:" .$infohash . "&dn=" . $name . "&tr=" . $trackers;\r
 }\r
 ?>\r
@@ -27,47 +42,84 @@ if(filter_has_var(INPUT_GET, 'submit'))
         <title>Magnet</title>\r
         <meta charset="utf-8" />\r
         <meta name="viewport" content="width=device-width, initial-scale=1">\r
         <title>Magnet</title>\r
         <meta charset="utf-8" />\r
         <meta name="viewport" content="width=device-width, initial-scale=1">\r
+\r
+        <link rel="icon" type="image/png" sizes="32x32" href="magnet.png">\r
+\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/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
     </head>\r
     <body>\r
-      <div class="w3-card-4">\r
-        <div class="w3-container w3-green">\r
-          <h2>Magnet Info</h2>\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"  placeholder="Hash of the Torrent Ex: DA39A3EE5E6B4B0D3255BFEF95601890AFD80709" />\r
+              </p>\r
+              <p>\r
+                <label>Name</label>\r
+                <input class="w3-input" type="text" name="tname" 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"></textarea>\r
+              </p>\r
+              <p>\r
+                <label>Webseeds</label>\r
+                <input class="w3-input" type="text" name="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
         </div>\r
-        <form class="w3-container" name="form1" method="get" action="#">\r
-          <p>\r
-            <label>Infohash</label>\r
-            <input class="w3-input" type="text" name="infohash" placeholder="Hash of the Torrent" />\r
-          </p>\r
-          <p>\r
-            <label>Name</label>\r
-            <input class="w3-input" type="text" name="tname" placeholder="Name of the Torrent" />\r
-          </p>\r
-          <p>\r
-            <label>Trackers</label>\r
-            <input class="w3-input" type="text" name="trackers" placeholder="Trackers" />\r
-          </p>\r
-          <p>\r
-            <input class="w3-button w3-green" type="submit" name="submit" value="Create"/>\r
-            <input class="w3-button w3-green" type="reset" name="reset" value="Reset">\r
-          </p>\r
-        </form>\r
-    </div>\r
-    <?php if(isset($magnetlink))\r
-    {\r
+       \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
       ?>\r
-      <div class="w3-panel w3-pale-green w3-leftbar w3-border-green">\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
           <p><a href = "<?php echo $magnetlink; ?>"><?php echo $magnetlink; ?></a></p>\r
-      </div>\r
+        </div>\r
       <?php\r
       <?php\r
-    }\r
-    else {\r
+      }\r
+      else\r
+      {\r
       ?>\r
       ?>\r
-      <div class="w3-panel w3-pale-green w3-leftbar w3-border-green">\r
+        <div class="w3-panel w3-pale-blue w3-leftbar w3-border-blue">\r
           <p>Enter Some Torrent Info Hash</p>\r
           <p>Enter Some Torrent Info Hash</p>\r
-      </div>\r
+        </div>\r
       <?php\r
       <?php\r
-    }\r
+      }\r
     ?>\r
     ?>\r
-  </body>\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
 </html>
\ No newline at end of file
diff --git a/infohash.txt b/infohash.txt
deleted file mode 100644 (file)
index 36e2399..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-http://torrage.com/torrent/640FE84C613C17F663551D218689A64E8AEBEABE.torrent\r
-http://torcache.net/torrent/640FE84C613C17F663551D218689A64E8AEBEABE.torrent\r
-http://zoink.it/torrent/640FE84C613C17F663551D218689A64E8AEBEABE.torrent\r
-http://istoretor.com/t/640FE84C613C17F663551D218689A64E8AEBEABE\r
-\r
-ubuntu-13.10-desktop-i386.iso --> 597A92F6EEED29E6028B70B416C847E51BA76C38\r
-non exist --> 886D8CA336A8BBE7C1B19C8B5D23729496F7A48F\r
-xbmc-12.3.exe --> F948DD1E2A216B018FC3B5BA3FB4B1A63F61F06B\r
-\r
-http://mgnet.me/api.html\r
\r
-magnet:?xt=urn:btih:E07744C839318F95DADC57809F11465A2D26EE73&dn=Non+Stop+2014+1080p+Trailer&tr=udp://tracker.openbittorrent.com:80/announce&tr=udp://open.demonii.com:1337&ws=http://videos.hd-trailers.net/nonstop-tlr1_h1080p.mov\r
-\r
-magnet:?xt=urn:btih:<info-hash>&dn=<name>&tr=<tracker-url>&ws=<webseed>
\ No newline at end of file
diff --git a/magnet.html b/magnet.html
new file mode 100644 (file)
index 0000000..7623c72
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html lang="en">
+    <head>
+        <title>Magnet</title>
+        <meta charset="utf-8" />
+        <meta name="viewport" content="width=device-width, initial-scale=1">
+        <link rel="stylesheet" type="text/css" href="https://www.w3schools.com/w3css/4/w3.css">
+        <link rel="stylesheet" type="text/css" href="style.css">
+        <link rel="shortcut icon" type="image/x-icon" />
+    </head>
+    <body>
+        <div class="w3-card-4">
+            <div class="w3-container w3-green">
+                <h2>Magnet Info</h2>
+            </div>
+            <form class="w3-container" name="magnet" method="get" action="#">
+                <p>
+                    <label>Infohash</label>
+                    <input class="w3-input" type="text" name="infohash" placeholder="Hash of the Torrent Ex: DA39A3EE5E6B4B0D3255BFEF95601890AFD80709" />
+                </p>
+                <p>
+                    <label>Name</label>
+                    <input class="w3-input" type="text" name="tname" placeholder="Name of the Torrent Ex:Linux 5.7" />
+                </p>
+                <p>
+                    <label>Trackers</label>
+                    <textarea class="w3-input" name="trackers" placeholder="Trackers Ex: udp://tracker.opentrackr.org:1337/announce"></textarea>
+                </p>
+                <p>
+                    <label>Webseeds</label>
+                    <input class="w3-input" type="text" name="webseeds" placeholder="Web Seeds Ex: http://example.com/linux.iso" />
+                </p>
+                <p>
+                    <input class="w3-button w3-green" type="submit" name="submit" value="Create" />
+                    <input class="w3-button w3-green" type="reset" name="reset" value="Reset">
+                </p>
+            </form>
+        </div>
+        <script type="text/javascript">
+            magnet.onsubmit = async (e) => {
+                e.preventDefault();
+
+                $(document).ready 
+
+        </script>
+    </body>
+</html>
\ No newline at end of file
diff --git a/magnet.png b/magnet.png
new file mode 100644 (file)
index 0000000..97480df
Binary files /dev/null and b/magnet.png differ
diff --git a/style.css b/style.css
new file mode 100644 (file)
index 0000000..b500007
--- /dev/null
+++ b/style.css
@@ -0,0 +1,39 @@
+
+/* 
+    Created on : 10 Jun, 2018, 9:23:39 PM
+    Author     : Manjunath CV
+*/
+
+@import url('https://fonts.googleapis.com/css2?family=Roboto&family=Roboto+Mono&display=swap');
+
+body {
+    font-family: 'Roboto', sans-serif;
+    
+}
+
+#magnet {
+    font-family: 'Roboto Mono', monospace;
+}
+
+section {
+    margin: auto;
+    width: 850px;
+}
+
+footer {
+    width:100%;
+    text-align: center;
+}
+
+
+
+/* Responsive layout - makes the two columns/boxes 
+   stack on top of each other instead of next to 
+   each other, on small screens */
+@media (max-width: 850px) {
+    section {
+        width: 95%;
+    }
+
+
+}