audiorecorder.inc.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php //$id: $
  2. // This file is part of the Dokeos software - See license and credits in the documentation/ directory
  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. */
  10. global $_configuration;
  11. $web_path = api_get_path(WEB_CODE_PATH);
  12. $getid3_path = api_get_path(LIBRARY_PATH);
  13. require_once($getid3_path."getid3/getid3.php");
  14. function getFLVDuration($flv_path) {
  15. $getid3 = new getID3;
  16. $getid3->encoding = 'UTF-8';
  17. try {
  18. $getid3->Analyze($flv_path);
  19. return $getid3->info['playtime_seconds'];
  20. } catch (Exception $e) {
  21. return 0;
  22. }
  23. }
  24. if($audio_recorder_studentview=='false')
  25. {
  26. $width = 295;
  27. $height= 90;
  28. $player = 'recorder2.swf';
  29. $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';
  30. $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']));
  31. $filename = 'lpi'.$audio_recorder_item_id.'-'.gmdate('YmdHis').api_get_user_id().'.flv';//using -z- as fields splitter
  32. $path_to_lzx = $web_path.'conference/'.$player.'?server='.urlencode($server).'&postURI='.$post_uri.'&filename='.$filename;
  33. }
  34. else
  35. {
  36. $width = 295;
  37. $height = 24;
  38. $player = 'player2.swf';
  39. $cp = api_get_course_path();
  40. $docs = Database::get_course_table(TABLE_DOCUMENT);
  41. $select = "SELECT * FROM $docs " .
  42. " WHERE path like BINARY '/audio/lpi".Database::escape_string($audio_recorder_item_id)."-%' AND filetype='file' " .
  43. " ORDER BY path DESC";
  44. $res = Database::query($select);
  45. if(Database::num_rows($res)>0)
  46. {
  47. $row = Database::fetch_array($res);
  48. //$filepath = api_get_path(WEB_COURSE_PATH).$cp.'/document'.$row['path'];
  49. $duration = getFLVDuration(api_get_path(SYS_COURSE_PATH).$cp.'/document'.$row['path']);
  50. $filepath = api_get_path(WEB_CODE_PATH).'document/download.php?'.api_get_cidreq().'&doc_url='.$row['path'];
  51. $path_to_lzx = $web_path.'conference/'.$player.'?uri='.urlencode($filepath).'&autostart=true&duration='.$duration;
  52. }
  53. }
  54. if(!empty($path_to_lzx)){
  55. $recorder_content = sprintf("<object type=\"application/x-shockwave-flash\" data=\"%s\" ".
  56. "width='$width' height='$height'>".
  57. "<param name=\"movie\" value=\"%s\">".
  58. "<param name=\"quality\" value=\"high\">".
  59. "<param name=\"scale\" value=\"noscale\">".
  60. "<param name=\"salign\" value=\"LT\">".
  61. "<param name=\"menu\" value=\"false\"></object>",$path_to_lzx,$path_to_lzx);
  62. if($audio_recorder_studentview=='false')
  63. {
  64. echo '<script type="text/javascript">
  65. function show_audiorecorder()
  66. {
  67. document.getElementById("audiorecorder_frame").innerHTML = "'.addslashes($recorder_content).'";
  68. document.getElementById("show_audiorecorder_div").style.display="none";
  69. }
  70. </script>
  71. ';
  72. //Commented the audio for the version stable
  73. //echo '<div id="show_audiorecorder_div"><a style="cursor:pointer" onclick="show_audiorecorder()">'.get_lang('ShowAudioRecorder').'</a></div>';
  74. //echo '<div id="audiorecorder_frame"></div>';
  75. }
  76. else
  77. {
  78. echo $recorder_content;
  79. }
  80. }
  81. ?>