roku.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2012
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ); //hide notices and warnings
  22. //roku commands
  23. //press up
  24. //press down
  25. //press left
  26. //press right
  27. //press select
  28. //press home
  29. //press fwd
  30. //press back
  31. //press pause
  32. if (strlen($_SERVER['argv'][1]) > 0) {
  33. $cmd = $_SERVER['argv'][1];
  34. switch ($cmd) {
  35. case "1":
  36. $cmd = "home";
  37. break;
  38. case "2":
  39. $cmd = "up";
  40. break;
  41. case "3":
  42. $cmd = "home";
  43. break;
  44. case "4":
  45. $cmd = "left";
  46. break;
  47. case "5":
  48. $cmd = "select";
  49. break;
  50. case "6":
  51. $cmd = "right";
  52. break;
  53. case "7":
  54. $cmd = "back";
  55. break;
  56. case "8":
  57. $cmd = "down";
  58. break;
  59. case "9":
  60. $cmd = "fwd";
  61. break;
  62. case "0":
  63. $cmd = "pause"; //toggle play/pause
  64. break;
  65. case "#":
  66. $cmd = "pause"; //toggle play/pause
  67. break;
  68. default:
  69. $cmd = "pause"; //toggle play/pause
  70. }
  71. }
  72. if (strlen($cmd)==0) {
  73. if (strlen($_GET['cmd']) > 0) { $cmd = $_GET['cmd']; }
  74. }
  75. $host = $_SERVER['argv'][2];
  76. $port = $_SERVER['argv'][3];
  77. $cmd = "press ".$cmd;
  78. $fp = fsockopen($host, $port, $errno, $errdesc) or die("Connection to $host $errno $errdesc failed");
  79. fputs($fp, $cmd."\r\n");
  80. ?>