]> 472bisson.ca Git - magnet.git/commitdiff
Fixes
authorManjunath CV <cvmanjoo@gmail.com>
Sun, 4 Aug 2024 16:06:55 +0000 (21:36 +0530)
committerManjunath CV <cvmanjoo@gmail.com>
Sun, 4 Aug 2024 16:06:55 +0000 (21:36 +0530)
README.md
index.php
style.css

index 98ec99dc3f8ab750c4db2b0fab174eab0fc60ed6..3083ea844696a6585789f9576c540eca9f0e51d3 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,14 +1,27 @@
 # Hash to Magnet
 
 # Hash to Magnet
 
-Web tool to generate magnet URI from Torrent Hash.
+Web tool to generate magnet URI from Torrent Hash. 
 
 
-# Parameters
+Link : https://cvmanjoo.in/magnet
+
+## Parameters
 
 * Magnet Hash (Required)
 * Name of Torrent (Optional)
 * Trackers (Optional)
 * Webseeds (Optional)
 
 
 * Magnet Hash (Required)
 * Name of Torrent (Optional)
 * Trackers (Optional)
 * Webseeds (Optional)
 
-# Resources
+## Example
+
+| First Header  | Second Header |
+| ------------- | ------------- |
+| Infohash      | 2AA4F5A7E209E54B32803D43670971C4C8CAAA05 |
+| Torrent Name  | Ubuntu 24.04 Desktop (x64)  |
+| Trackers      | https://torrent.ubuntu.com/announce |
+|               | https://ipv6.torrent.ubuntu.com/announce|
+| Webseeds      | https://releases.ubuntu.com/24.04/ubuntu-24.04-desktop-amd64.iso |
+
+## Resources
 1. Bittorrent Protocol http://bittorrent.org/beps/bep_0053.html
 1. Bittorrent Protocol http://bittorrent.org/beps/bep_0053.html
-2. CSS Design - https://www.w3schools.com/w3css/
+2. Magnet URI scheme https://en.wikipedia.org/wiki/Magnet_URI_scheme
+2. CSS Design - https://www.w3schools.com/w3css/
\ No newline at end of file
index 6f9e74078f779d2e56b8a8c004436812a3c7c605..7fb3a884af0488b5055cc5c51dc96b4fa4e2b4c6 100644 (file)
--- a/index.php
+++ b/index.php
 <?php\r
 <?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
 if(filter_has_var(INPUT_GET, 'submit'))\r
 {\r
-    $infohash = filter_input(INPUT_GET, 'infohash');\r
-    $name = filter_input(INPUT_GET, 'tname');\r
-    $trackers = filter_input(INPUT_GET, 'trackers');\r
-    $webseeds = filter_input(INPUT_GET, 'webseeds');\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
        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
+       else if(strlen($infohash) == 40 && ctype_xdigit($infohash))\r
+       {\r
+               $magnetlink = "magnet:?xt=urn:btih:" . $infohash;\r
 \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
+               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
        else\r
        {\r
                $error_code = 2;\r
        }\r
-    //$magnetlink = "magnet:?xt=urn:btih:" .$infohash . "&dn=" . $name . "&tr=" . $trackers;\r
+       //$magnetlink = "magnet:?xt=urn:btih:" .$infohash . "&dn=" . $tor_name . "&tr=" . $trackers;\r
 }\r
 ?>\r
 <!DOCTYPE html>\r
 <html lang="en">\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
+       <head>\r
+               <title>Magnet</title>\r
+               <meta charset="utf-8" />\r
+               <meta name="viewport" content="width=device-width, initial-scale=1">\r
 \r
 \r
-        <link rel="icon" type="image/png" sizes="32x32" href="magnet.png">\r
+               <link rel="icon" type="image/png" sizes="32x32" href="magnet.png">\r
 \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/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"  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
-       \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
+               <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
 </html>
\ No newline at end of file
index b500007a5d16855dbb7af5136c7e82064130ee1b..05200a23b7fc28ccf81a6c95c61a5621e31fe7c8 100644 (file)
--- a/style.css
+++ b/style.css
@@ -4,10 +4,12 @@
     Author     : Manjunath CV
 */
 
     Author     : Manjunath CV
 */
 
-@import url('https://fonts.googleapis.com/css2?family=Roboto&family=Roboto+Mono&display=swap');
+@import url('https://fonts.googleapis.com/css2?family=Fira+Sans&display=swap');
 
 
-body {
-    font-family: 'Roboto', sans-serif;
+body, h2 {
+    font-family: "Fira Sans", sans-serif;
+    font-weight: 400;
+    font-style: normal;
     
 }
 
     
 }
 
@@ -26,7 +28,6 @@ footer {
 }
 
 
 }
 
 
-
 /* Responsive layout - makes the two columns/boxes 
    stack on top of each other instead of next to 
    each other, on small screens */
 /* Responsive layout - makes the two columns/boxes 
    stack on top of each other instead of next to 
    each other, on small screens */
@@ -34,6 +35,4 @@ footer {
     section {
         width: 95%;
     }
     section {
         width: 95%;
     }
-
-
 }
 }