vlc.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. /* $Id: vlc.php 3082 2007-06-09 13:51:43Z danez $ */
  3. /*******************************************************************************
  4. LICENSE
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License (GPL)
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. To read the license please visit http://www.gnu.org/copyleft/gpl.html
  14. *******************************************************************************/
  15. // prevent direct invocation
  16. if ((!isset($cfg['user'])) || (isset($_REQUEST['cfg']))) {
  17. @ob_end_clean();
  18. @header("location: ../../index.php");
  19. exit();
  20. }
  21. /******************************************************************************/
  22. // vlc class
  23. require_once('inc/classes/Vlc.php');
  24. // common functions
  25. require_once('inc/functions/functions.common.php');
  26. // dir functions
  27. require_once('inc/functions/functions.dir.php');
  28. // is enabled ?
  29. if ($cfg["enable_vlc"] != 1) {
  30. AuditAction($cfg["constants"]["error"], "ILLEGAL ACCESS: ".$cfg["user"]." tried to use vlc");
  31. @error("vlc is disabled. Action has been logged.", "", "");
  32. }
  33. // check the needed bins
  34. // vlc
  35. if (@file_exists($cfg['bin_vlc']) !== true) {
  36. @error("Required binary could not be found", "", "",
  37. (
  38. ($cfg['isAdmin'])
  39. ? array(
  40. 'vlc is required for vlc-streaming',
  41. 'Specified vlc-binary does not exist: '.$cfg['bin_vlc'],
  42. 'Check Settings on Admin-Server-Settings Page')
  43. : array('Please contact an Admin')
  44. )
  45. );
  46. }
  47. // init template-instance
  48. tmplInitializeInstance($cfg["theme"], "page.vlc.tmpl");
  49. // pageop
  50. //
  51. // * default
  52. // * start
  53. // * stop
  54. //
  55. $pageop = tfb_getRequestVar('pageop');
  56. $tmpl->setvar('pageop', (empty($pageop)) ? "default" : $pageop);
  57. // op-switch
  58. switch ($pageop) {
  59. default:
  60. case "default":
  61. // fill lists
  62. // vidc
  63. $vidcList = Vlc::getList('vidc');
  64. $list_vidc = array();
  65. foreach ($vidcList as $vidcT)
  66. array_push($list_vidc, array('name' => $vidcT));
  67. $tmpl->setloop('list_vidc', $list_vidc);
  68. // vbit
  69. $vbitList = Vlc::getList('vbit');
  70. $list_vbit = array();
  71. foreach ($vbitList as $vbitT)
  72. array_push($list_vbit, array('name' => $vbitT));
  73. $tmpl->setloop('list_vbit', $list_vbit);
  74. // audc
  75. $audcList = Vlc::getList('audc');
  76. $list_audc = array();
  77. foreach ($audcList as $audcT)
  78. array_push($list_audc, array('name' => $audcT));
  79. $tmpl->setloop('list_audc', $list_audc);
  80. // abit
  81. $abitList = Vlc::getList('abit');
  82. $list_abit = array();
  83. foreach ($abitList as $abitT)
  84. array_push($list_abit, array('name' => $abitT));
  85. $tmpl->setloop('list_abit', $list_abit);
  86. // requested file
  87. $dirName = urldecode($_REQUEST['dir']);
  88. $fileName = urldecode(stripslashes($_REQUEST['file']));
  89. $targetFile = $dirName.$fileName;
  90. // only valid dirs + entries with permission
  91. if (!((tfb_isValidPath($targetFile)) &&
  92. (isValidEntry(basename($targetFile))) &&
  93. (hasPermission($targetFile, $cfg["user"], 'r')))) {
  94. AuditAction($cfg["constants"]["error"], "ILLEGAL VLC-ACCESS: ".$cfg["user"]." tried to view ".$fileName." in ".$dirName);
  95. @error("Illegal access. Action has been logged.", "", "");
  96. }
  97. // set vars
  98. $tmpl->setvar('file', $fileName);
  99. $tmpl->setvar('target', urlencode(addslashes($targetFile)));
  100. // host vars
  101. $tmpl->setvar('addr', Vlc::getAddr());
  102. $tmpl->setvar('port', Vlc::getPort());
  103. // already streaming
  104. if (Vlc::isStreamRunning(Vlc::getPort()) === true) {
  105. $tmpl->setvar('is_streaming', 1);
  106. $streams = Vlc::getRunning(Vlc::getPort());
  107. $currentStream = (empty($streams))
  108. ? ""
  109. : array_pop($streams);
  110. $tmpl->setvar('current_stream', $currentStream);
  111. } else {
  112. $tmpl->setvar('is_streaming', 0);
  113. }
  114. break;
  115. case "start":
  116. // get vars
  117. $fileName = urldecode(stripslashes($_REQUEST['file']));
  118. $targetFile = urldecode(stripslashes($_POST['target']));
  119. $target_vidc = $_POST['vidc'];
  120. $target_vbit = $_POST['vbit'];
  121. $target_audc = $_POST['audc'];
  122. $target_abit = $_POST['abit'];
  123. // only valid dirs + entries with permission
  124. if (!((tfb_isValidPath($targetFile)) &&
  125. (isValidEntry(basename($targetFile))) &&
  126. (hasPermission($targetFile, $cfg["user"], 'r')))) {
  127. AuditAction($cfg["constants"]["error"], "ILLEGAL VLC-ACCESS: ".$cfg["user"]." tried to view ".$fileName." in ".$dirName);
  128. @error("Illegal access. Action has been logged.", "", "");
  129. }
  130. // set template vars
  131. $tmpl->setvar('file', $fileName);
  132. $tmpl->setvar('vidc', $target_vidc);
  133. $tmpl->setvar('vbit', $target_vbit);
  134. $tmpl->setvar('audc', $target_audc);
  135. $tmpl->setvar('abit', $target_abit);
  136. $tmpl->setvar('addr', Vlc::getAddr());
  137. $tmpl->setvar('port', Vlc::getPort());
  138. // start vlc
  139. Vlc::start($cfg["path"].$targetFile, $target_vidc, $target_vbit, $target_audc, $target_abit);
  140. break;
  141. case "stop":
  142. // stop vlc
  143. Vlc::stop();
  144. break;
  145. }
  146. // title-bar
  147. tmplSetTitleBar($cfg["pagetitle"]." - "."vlc", false);
  148. // iid
  149. tmplSetIidVars();
  150. // parse template
  151. $tmpl->pparse();
  152. ?>