This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Reworking of WebInterface

Tags: None
(comma "," separated)
User avatar
bassmadrigal
Registered Member
Posts
113
Karma
0

Reworking of WebInterface

Thu Nov 30, 2006 2:12 pm
I was very pleased when I found that webinterface had a default and a mobile option. But when I tried the mobile option it seemed like it was geared more towards higher resolution browsers. So tonight I completely went through the code and reworked it for lower resolution browsers (ie cell phones > 200px). I ended up removing all the pictures because I couldn't get them to display properly. I may eventually redo this in wml so even older phones that don't support html can use it.

Unfortunately I don't know how to create patches, but it would be easy enough just to replace the files with mine (or someone can generate a patch for me :D )

So here goes (since I can't upload attachments I will just copy and paste.)

login.html

Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
  <title>KTorrent  WebInterface - Login</title>
  <meta http-equiv="Cache-Control" content="no-cache"/>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<FORM action="interface.php" method="POST">
 <p>
   Username<br /><INPUT type="text" name="username"><br />
   Password<br /><INPUT type="password" name="password"><br />
   <INPUT type="submit" name="Login">
 </p> 
</FORM>

</body>
</html>



interface.php

Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>KTorrent WebInterface</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Cache-Control" content="no-cache"/>
</head>
<body>
   <p>     
      KTorrent Transfers <a href="interface.php" >refresh</a><br />
     <a href="interface.php?startall=startall" >Start All</a><br />
   <a href="interface.php?stopall=stopall" >Stop All</a><br />
        <br />
   <a href="settings.php" >Settings</a><br />
   &nbsp   
   

   </p>
<hr>
       <?php
      $stats=downloadStatus();
      $a = 0;
      foreach ($stats as $torrent) {
         echo "<p>";
         $perc = round(100.0 - ($torrent[bytes_left_to_download] / $torrent[total_bytes_to_download]) * 100.0, 2);
         echo "<a href=\"torrent.php?id=$a\" >$torrent[torrent_name]</a><br />";
            switch ($torrent[status]) {
                  case 0:
                        echo "Not Started<br />";
                     break;
                  case 1:
                       echo "Seeding Complete<br />";
                        break;
                  case 2:
                     echo "Download Complete<br />";
                     break;
                  case 3:
                     echo "Seeding<br />";
                     break;
                  case 4:
                     echo "Downloading<br />";
                     break;
                  case 5:
                     echo "Stalled<br />";
                     break;
                  case 6:
                     echo "Stopped<br />";
                     break;
                  case 7:
                     echo "Allocating Diskspace<br />";
                     break;
                  case 8:
                     echo "Error<br />";
                     break;
                  case 9:
                     echo "Queued<br />";
                     break;
                  case 10:
                     echo "Checking Data<br />";
                     break;
                  default:
                     echo "Not supported Status<br />";
            }
            echo "$perc%<br />";
            $a=$a+1;   
      echo "</p>";
      }
         ?>
<hr>   
    <p>
       <?php
      $globalinfo=globalInfo();
      echo "Speed<br />";
      $downspeed=$globalinfo[download_speed]/1024;
      echo "Down: $downspeed kb/s<br />";
      $upspeed=$globalinfo[upload_speed]/1024;
      echo "Up: $upspeed kb/s<br />";
   ?>
    </p>
</body>
</html>



settings.php

Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>KTorrent WebInterface</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Cache-Control" content="no-cache"/>
</head>
<body>
      <strong>ktorrent-><a href="interface.php">transfers</a></strong>->settings
      <a href="settings.php" >refresh</a></td>
<?php
            $globalinfo=globalInfo();
      echo "<FORM method=\"GET\">";
      echo "<p>";
         echo "Upload Speed (0 is no limit): <br />";
         echo "<INPUT type=\"text\" name=\"maximum_upload_rate\" value=\"$globalinfo[max_upload_speed]\"><br />";

         echo "Download Speed (0 is no limit): <br />";
         echo "<INPUT type=\"text\" name=\"maximum_download_rate\" value=\"$globalinfo[max_download_speed]\"><br />";

         echo "Maximum downloads (0 is no limit): <br />";
         echo "<INPUT type=\"text\" name=\"maximum_downloads\" value=\"$globalinfo[max_downloads]\"><br />";

         echo "Maximum seeds (0 is no limit): <br />";
         echo "<INPUT type=\"text\" name=\"max_seeds\" value=\"$globalinfo[max_seeds]\"><br />";
   
      echo "<INPUT type=\"submit\"><br />";
      echo "</p>";
      echo "</FORM>";
?>

</body>
</html>



torrent.php

Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>KTorrent WebInterface</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Cache-Control" content="no-cache"/>
</head>
<body>
   <p>
      <?php
         $stats=downloadStatus();
         $t=$stats[$_REQUEST[id]];
         echo "ktorrent-><a href=\"interface.php\">transfers</a><br /><br />$t[torrent_name] <br /><br /> <a href=\"torrent.php?id=$_REQUEST[id]\" >refresh</a>";
      ?>
   </p>
   <p>
      <?php
         echo "Status: <br />";
         switch ($t[status]) {
      case 0:
            echo "NOT_STARTED<br />";
         break;
      case 1:
           echo "SEEDING_COMPLETE<br />";
            break;
      case 2:
         echo "DOWNLOAD_COMPLETE<br />";
         break;
      case 3:
         echo "SEEDING<br />";
         break;
      case 4:
         echo "DOWNLOADING<br />";
         break;
      case 5:
         echo "STALLED<br />";
         break;
      case 6:
         echo "STOPPED<br />";
         break;
      case 7:
         echo "ALLOCATING_DISKSPACE<br />";
         break;
      case 8:
         echo "ERROR<br />";
         break;
      case 9:
         echo "QUEUED<br />";
         break;
      case 10:
         echo "CHECKING_DATA<br />";
         break;
      default:
         echo "Not supported Status<br />";
      }
   echo "<br />";
   echo "Down speed: <br />";
   echo "$t[download_rate]<br />";
   echo "<br />";
   echo "Up speed: <br />";
   echo "$t[upload_rate]<br />";
   echo "<br />";
   echo "Complete: <br />";
   $perc = round(100.0 - ($t[bytes_left_to_download] / $t[total_bytes_to_download]) * 100.0, 2);
   echo "$perc %<br />";
      ?>
   </p>
   <p>
      <?php
   echo "<a href=\"torrent.php?start=$_REQUEST[id]&id=$_REQUEST[id]\" title=\"START\">Start<br /></a>";
          echo "<a href=\"torrent.php?stop=$_REQUEST[id]&id=$_REQUEST[id]\" title=\"STOP\">Stop</a><br />";
   echo "<a href=\"interface.php?remove=$_REQUEST[id]\" title=\"REMOVE\">Remove<br /></a>";
      ?>
   </p>
</body>
</html>



I did add the doctype and charset declarations just for validation purposes. And I set a no cache so the pages are automatically downloaded again.

My thought is that if the original mobile should be kept, to add a new selection for mobile low-res (or something similar), so people can choose either one... and hopefully soon wml.

Any thoughts or pointers would be appreciated.

Jeremy

Just an fyi... if you want to try it, just replace your mobile files with these and you can get an idea of how simplistic and easy it would be on a phone.

EDIT: Oh and I removed the redirect.html as I had issues with it on my phone so now the login points directly to interface.php. (As per a suggestion on a previous topic)


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar