Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form name="input" action="index2.php" method="get">
- Text: <input type="text" name="str" />
- <input type="hidden" name="cmd" value="text" />
- <input type="submit" value="Submit" />
- </form>
- <a href="index2.php?cmd=up">Up</a><br>
- <a href="index2.php?cmd=down">Down</a><br>
- <a href="index2.php?cmd=left">Left</a><br>
- <a href="index2.php?cmd=right">Right</a><br>
- <a href="index2.php?cmd=select">Select</a><br>
- <a href="index2.php?cmd=home">Home</a><br>
- <a href="index2.php?cmd=fwd">Forward</a><br>
- <a href="index2.php?cmd=back">Rewind</a><br>
- <a href="index2.php?cmd=pause">Play/Pause</a><br>
- <?php
- if (@!$_GET['str'] and @!$_GET['cmd']) {
- exit();
- }
- include 'telnet.class.php';
- $telnet = new telnet;
- $telnet->set_host("192.168.1.146");
- $telnet->connect();
- usleep(300000);
- $cmd = $_GET['cmd'];
- if ($cmd == "text") {
- $posa = array (
- "<" => "-1,0",
- ">" => "-1,1",
- " " => "-1,4",
- "a" => "0,0",
- "b" => "0,1",
- "c" => "0,2",
- "d" => "0,3",
- "e" => "0,4",
- "f" => "0,5",
- "g" => "1,0",
- "h" => "1,1",
- "i" => "1,2",
- "j" => "1,3",
- "k" => "1,4",
- "l" => "1,5",
- "m" => "2,0",
- "n" => "2,1",
- "o" => "2,2",
- "p" => "2,3",
- "q" => "2,4",
- "r" => "2,5",
- "s" => "3,0",
- "t" => "3,1",
- "u" => "3,2",
- "v" => "3,3",
- "w" => "3,4",
- "x" => "3,5",
- "y" => "4,0",
- "z" => "4,1",
- "1" => "4,2",
- "2" => "4,3",
- "3" => "4,4",
- "4" => "4,5",
- "5" => "5,0",
- "6" => "5,1",
- "7" => "5,2",
- "8" => "5,3",
- "9" => "5,4",
- "0" => "5,5",
- );
- $str = $_GET['str'];
- $strpos = strpos($str, "[");
- $stra = str_split($str);
- $oldpos = $posa['a'];
- $oldpossa = explode(",", $oldpos);
- foreach ($stra as $val) {
- $pos = $posa[$val];
- $possa = explode(",", $pos);
- $pos1 = $possa['0']-$oldpossa['0'];
- $pos2 = $possa['1']-$oldpossa['1'];
- $telnet->set_prompt(">");
- while ($pos1 != 0 or $pos2 != 0) {
- if ($pos1 < 0) {
- $telnet->write("press up");
- //echo "press up";
- $telnet->wait_prompt();
- echo "<br>";
- $pos1++;
- } elseif ($pos1 > 0) {
- $telnet->write("press down");
- //echo "press down";
- $telnet->wait_prompt();
- echo "<br>";
- $pos1--;
- }
- if ($pos2 < 0) {
- $telnet->write("press left");
- //echo "press left";
- $telnet->wait_prompt();
- echo "<br>";
- $pos2++;
- } elseif ($pos2 > 0) {
- $telnet->write("press right");
- //echo "press right";
- $telnet->wait_prompt();
- echo "<br>";
- $pos2--;
- }
- }
- $oldpos = $posa[$val];
- $oldpossa = explode(",", $oldpos);
- $telnet->write("press select");
- // echo "press select";
- echo "<br>";
- }
- } elseif ($cmd == "up") {
- $telnet->write("press up");
- } elseif ($cmd == "down") {
- $telnet->write("press down");
- } elseif ($cmd == "left") {
- $telnet->write("press left");
- }elseif ($cmd == "right") {
- $telnet->write("press right");
- } elseif ($cmd == "select") {
- $telnet->write("press select");
- } elseif ($cmd == "home") {
- $telnet->write("press home");
- }elseif ($cmd == "fwd") {
- $telnet->write("press fwd");
- } elseif ($cmd == "back") {
- $telnet->write("press back");
- } elseif ($cmd == "pause") {
- $telnet->write("press pause");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement