audiorecorder.inc.php 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Created on 27.09.2006
  5. * Include the lazlo file necessary to use the audiorecorder
  6. * @author Sebastian Wagner <seba.wagner@gmail.com>
  7. * @author Eric Marguin <e.marguin@elixir-interactive.com>
  8. * @author Arnaud Ligot <arnaud@cblue.be>
  9. * @package chamilo.learnpath
  10. */
  11. global $_configuration;
  12. $web_path = api_get_path(WEB_CODE_PATH);
  13. $getid3_path = api_get_path(LIBRARY_PATH);
  14. require_once $getid3_path.'getid3/getid3.php';
  15. function getFLVDuration($flv_path) {
  16. $getid3 = new getID3;
  17. $getid3->encoding = 'UTF-8';
  18. try {
  19. $getid3->Analyze($flv_path);
  20. return $getid3->info['playtime_seconds'];
  21. } catch (Exception $e) {
  22. return 0;
  23. }
  24. }
  25. $course_id = api_get_course_int_id();
  26. if ($audio_recorder_studentview == 'false') {
  27. $width = 295;
  28. $height= 90;
  29. $player = 'recorder2.swf';
  30. $server = (api_get_setting('service_visio', 'visio_use_rtmpt') == 'true' ? 'rtmpt://' : 'rtmp://').api_get_setting('service_visio', 'visio_host').':'.(api_get_setting('service_visio', 'visio_use_rtmpt') == 'true' ? '80' : api_get_setting('service_visio', 'visio_port')).'/recorder';
  31. $post_uri = urlencode($web_path.'conference/audiopost.php?course_code='.api_get_course_id().'&user_id='.api_get_user_id().'&checker='.md5(api_get_course_id().api_get_user_id().gmdate('Ymd').$_configuration['security_key']));
  32. $filename = 'lpi'.$audio_recorder_item_id.'-'.gmdate('YmdHis').api_get_user_id().'.flv'; // Using -z- as fields splitter.
  33. $path_to_lzx = $web_path.'conference/'.$player.'?server='.urlencode($server).'&postURI='.$post_uri.'&filename='.$filename;
  34. } else {
  35. $width = 295;
  36. $height = 24;
  37. $player = 'player2.swf';
  38. $cp = api_get_course_path();
  39. $docs = Database::get_course_table(TABLE_DOCUMENT);
  40. $select = "SELECT * FROM $docs " .
  41. " WHERE c_id = $course_id AND path like BINARY '/audio/lpi".intval($audio_recorder_item_id)."-%' AND filetype='file' " .
  42. " ORDER BY path DESC";
  43. $res = Database::query($select);
  44. if (Database::num_rows($res) > 0) {
  45. $row = Database::fetch_array($res);
  46. //$filepath = api_get_path(WEB_COURSE_PATH).$cp.'/document'.$row['path'];
  47. $duration = getFLVDuration(api_get_path(SYS_COURSE_PATH).$cp.'/document'.$row['path']);
  48. $filepath = api_get_path(WEB_CODE_PATH).'document/download.php?'.api_get_cidreq().'&doc_url='.$row['path'];
  49. $path_to_lzx = $web_path.'conference/'.$player.'?uri='.urlencode($filepath).'&autostart=true&duration='.$duration;
  50. }
  51. }
  52. if (!empty($path_to_lzx)) {
  53. $recorder_content = sprintf("<object type=\"application/x-shockwave-flash\" data=\"%s\" ".
  54. "width='$width' height='$height'>".
  55. "<param name=\"movie\" value=\"%s\">".
  56. "<param name=\"quality\" value=\"high\">".
  57. "<param name=\"scale\" value=\"noscale\">".
  58. "<param name=\"salign\" value=\"LT\">".
  59. "<param name=\"menu\" value=\"false\"></object>", $path_to_lzx, $path_to_lzx);
  60. if ($audio_recorder_studentview == 'false') {
  61. echo '<script type="text/javascript">
  62. function show_audiorecorder() {
  63. document.getElementById("audiorecorder_frame").innerHTML = "'.addslashes($recorder_content).'";
  64. document.getElementById("show_audiorecorder_div").style.display="none";
  65. }
  66. </script>';
  67. // Commented the audio for the version stable.
  68. //echo '<div id="show_audiorecorder_div"><a style="cursor:pointer" onclick="show_audiorecorder()">'.get_lang('ShowAudioRecorder').'</a></div>';
  69. //echo '<div id="audiorecorder_frame"></div>';
  70. } else {
  71. echo $recorder_content;
  72. }
  73. }