Advertisement
Guest User

Roku Remote

a guest
Sep 16th, 2010
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.26 KB | None | 0 0
  1. <form name="input" action="index2.php" method="get">
  2. Text: <input type="text" name="str" />
  3. <input type="hidden" name="cmd" value="text" />
  4. <input type="submit" value="Submit" />
  5. </form>
  6. <a href="index2.php?cmd=up">Up</a><br>
  7. <a href="index2.php?cmd=down">Down</a><br>
  8. <a href="index2.php?cmd=left">Left</a><br>
  9. <a href="index2.php?cmd=right">Right</a><br>
  10. <a href="index2.php?cmd=select">Select</a><br>
  11. <a href="index2.php?cmd=home">Home</a><br>
  12. <a href="index2.php?cmd=fwd">Forward</a><br>
  13. <a href="index2.php?cmd=back">Rewind</a><br>
  14. <a href="index2.php?cmd=pause">Play/Pause</a><br>
  15. <?php
  16. if (@!$_GET['str'] and @!$_GET['cmd']) {
  17.     exit();
  18. }
  19. include 'telnet.class.php';
  20.                 $telnet = new telnet;
  21.                 $telnet->set_host("192.168.1.146");
  22.                 $telnet->connect();
  23.                 usleep(300000);
  24. $cmd = $_GET['cmd'];
  25. if ($cmd == "text") {
  26.     $posa = array (
  27.         "<" => "-1,0",
  28.         ">" => "-1,1",
  29.         " " => "-1,4",
  30.         "a" => "0,0",
  31.         "b" => "0,1",
  32.         "c" => "0,2",
  33.         "d" => "0,3",
  34.         "e" => "0,4",
  35.         "f" => "0,5",
  36.         "g" => "1,0",
  37.         "h" => "1,1",
  38.         "i" => "1,2",
  39.         "j" => "1,3",
  40.         "k" => "1,4",
  41.         "l" => "1,5",
  42.         "m" => "2,0",
  43.         "n" => "2,1",
  44.         "o" => "2,2",
  45.         "p" => "2,3",
  46.         "q" => "2,4",
  47.         "r" => "2,5",
  48.         "s" => "3,0",
  49.         "t" => "3,1",
  50.         "u" => "3,2",
  51.         "v" => "3,3",
  52.         "w" => "3,4",
  53.         "x" => "3,5",
  54.         "y" => "4,0",
  55.         "z" => "4,1",
  56.         "1" => "4,2",
  57.         "2" => "4,3",
  58.         "3" => "4,4",
  59.         "4" => "4,5",
  60.         "5" => "5,0",
  61.         "6" => "5,1",
  62.         "7" => "5,2",
  63.         "8" => "5,3",
  64.         "9" => "5,4",
  65.         "0" => "5,5",
  66.         );
  67.         $str = $_GET['str'];
  68.         $strpos = strpos($str, "[");
  69.         $stra = str_split($str);
  70.         $oldpos = $posa['a'];
  71.         $oldpossa = explode(",", $oldpos);
  72.         foreach ($stra as $val) {
  73.             $pos = $posa[$val];
  74.             $possa = explode(",", $pos);
  75.             $pos1 = $possa['0']-$oldpossa['0'];
  76.             $pos2 = $possa['1']-$oldpossa['1'];
  77.             $telnet->set_prompt(">");
  78.             while ($pos1 != 0 or $pos2 != 0) {
  79.                 if ($pos1 < 0) {
  80.                     $telnet->write("press up");
  81.                     //echo "press up";
  82.                     $telnet->wait_prompt();
  83.                     echo "<br>";
  84.                     $pos1++;
  85.                 } elseif ($pos1 > 0) {
  86.                     $telnet->write("press down");
  87.                     //echo "press down";
  88.                     $telnet->wait_prompt();
  89.                     echo "<br>";
  90.                     $pos1--;
  91.                 }          
  92.                 if ($pos2 < 0) {
  93.                     $telnet->write("press left");
  94.                     //echo "press left";
  95.                     $telnet->wait_prompt();
  96.                     echo "<br>";
  97.                     $pos2++;
  98.                 } elseif ($pos2 > 0) {
  99.                     $telnet->write("press right");
  100.                     //echo "press right";
  101.                     $telnet->wait_prompt();
  102.                     echo "<br>";
  103.                     $pos2--;
  104.                 }
  105.             }
  106.             $oldpos = $posa[$val];
  107.             $oldpossa = explode(",", $oldpos);
  108.             $telnet->write("press select");
  109.             //  echo "press select";
  110.             echo "<br>";
  111.         }
  112.     } elseif ($cmd == "up") {
  113.         $telnet->write("press up");
  114.     } elseif ($cmd == "down") {
  115.         $telnet->write("press down");
  116.     } elseif ($cmd == "left") {
  117.         $telnet->write("press left");
  118.     }elseif ($cmd == "right") {
  119.         $telnet->write("press right");
  120.     } elseif ($cmd == "select") {
  121.         $telnet->write("press select");
  122.     } elseif ($cmd == "home") {
  123.         $telnet->write("press home");
  124.     }elseif ($cmd == "fwd") {
  125.         $telnet->write("press fwd");
  126.     } elseif ($cmd == "back") {
  127.         $telnet->write("press back");
  128.     } elseif ($cmd == "pause") {
  129.         $telnet->write("press pause");
  130.     }
  131.    
  132.    
  133. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement