online_master.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <?php // $Id: online_master.php 9246 2006-09-25 13:24:53Z bmol $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Olivier Brouckaert
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * Displays the master's picture and/or the video or audio file
  22. *
  23. * @author Olivier Brouckaert
  24. * @package dokeos.online
  25. ==============================================================================
  26. */
  27. define('FRAME','master');
  28. $langFile='chat';
  29. include('../inc/global.inc.php');
  30. $this_section=SECTION_COURSES;
  31. $init=intval($_GET['init']);
  32. $tbl_user = Database::get_main_table(MAIN_USER_TABLE);
  33. $tbl_course_user = Database::get_main_table(MAIN_COURSE_USER_TABLE);
  34. $tbl_online_link=Database::get_course_table(ONLINE_LINK_TABLE);
  35. $query="SELECT t1.user_id,username,picture_uri,t2.status FROM $tbl_user t1,$tbl_course_user t2 WHERE t1.user_id=t2.user_id AND course_code='$_cid' AND (t1.user_id='$_uid' OR t2.status='1')";
  36. $result=api_sql_query($query,__FILE__,__LINE__);
  37. while($row=mysql_fetch_array($result))
  38. {
  39. if($row['user_id'] == $_uid)
  40. {
  41. $pseudoUser=$row['username'];
  42. }
  43. if($row['status'] == 1)
  44. {
  45. $picture_uri=$row['picture_uri'];
  46. }
  47. }
  48. $isAllowed=(empty($pseudoUser) || !$_cid)?false:true;
  49. $isMaster=$is_courseAdmin?true:false;
  50. if(!$isAllowed)
  51. {
  52. exit();
  53. }
  54. $pictureURL=api_get_path(WEB_CODE_PATH).'upload/users/';
  55. $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
  56. $onlinePath=$documentPath.'online_files/';
  57. if(!is_dir($onlinePath))
  58. {
  59. if(is_file($onlinePath))
  60. {
  61. @unlink($onlinePath);
  62. }
  63. @mkdir($onlinePath,0777);
  64. @chmod($onlinePath,0777);
  65. }
  66. if($isMaster && $init)
  67. {
  68. $fp=fopen($onlinePath.'htmlarea.html','w');
  69. fputs($fp,get_lang('TextEditorDefault'));
  70. fclose($fp);
  71. if(!file_exists($onlinePath.'streaming.txt'))
  72. {
  73. $fp=fopen($onlinePath.'streaming.txt','w');
  74. fputs($fp,"http://www.dokeos.com/pub/01_discovery_high.mov\nmov");
  75. fclose($fp);
  76. }
  77. }
  78. if(!$isMaster)
  79. {
  80. if(!list($stream_url,$stream_type)=@file($onlinePath.'streaming.txt'))
  81. {
  82. $stream_url='';
  83. $stream_type='mp3';
  84. }
  85. else
  86. {
  87. $stream_url=rtrim($stream_url);
  88. $stream_type=rtrim($stream_type);
  89. }
  90. $query="SELECT id,name,url FROM $tbl_online_link ORDER BY name";
  91. $result=api_sql_query($query,__FILE__,__LINE__);
  92. $Links=api_store_result($result);
  93. }
  94. include('header_frame.inc.php');
  95. ?>
  96. <?php if($isMaster): ?>
  97. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  98. <tr>
  99. <td width="1%" valign="middle"><a href="online_streaming.php"><img src="../img/conf.gif" border="0" alt="" title="<?php echo htmlentities(get_lang('Streaming')); ?>"></a></td>
  100. <td width="49%" align="left" nowrap="nowrap">&nbsp;<a href="online_streaming.php"><?php echo get_lang('Streaming'); ?></a></td>
  101. <td width="49%" align="right" nowrap="nowrap"><a href="online_htmlarea.php" target="online_working_area"><?php echo get_lang('WhiteBoard'); ?></a>&nbsp;</td>
  102. <td width="1%" valign="middle"><a href="online_htmlarea.php" target="online_working_area"><img src="../img/works.gif" border="0" alt="" title="<?php echo htmlentities(get_lang('WhiteBoard')); ?>"></a></td>
  103. </tr>
  104. </table>
  105. <br>
  106. <?php endif; ?>
  107. <table border="0" cellpadding="5" cellspacing="0" width="100%" <?php if(!$isMaster) echo 'height="100%"'; ?> >
  108. <tr>
  109. <?php if($isMaster || empty($stream_url)): ?>
  110. <td align="center" valign="middle"><img src="<?php if(empty($picture_uri)) echo '../img/unknown.jpg'; else echo $pictureURL.$picture_uri; ?>" border="0" height="120" alt=""></td>
  111. <?php elseif(!empty($stream_url) && $stream_type == 'mp3'): ?>
  112. <td width="1%" valign="middle"><img src="<?php if(empty($picture_uri)) echo '../img/unknown.jpg'; else echo $pictureURL.$picture_uri; ?>" border="0" height="120" alt=""></td>
  113. <td width="99%" valign="middle" align="center">
  114. <?php else: ?>
  115. <td align="center">
  116. <?php endif; ?>
  117. <?php
  118. if(!$isMaster && !empty($stream_url))
  119. {
  120. if($stream_type == 'mp3')
  121. {
  122. ?>
  123. <embed src="<?php echo $stream_url; ?>" width="30" height="60" autostart="true" loop="false" controls="PlayOnlyButton,StopButton" type="audio/x-pn-realaudio-plugin" pluginspage="http://www.real.com/player/index.html?src=000629realhome"></embed>
  124. <?php
  125. }
  126. elseif($stream_type == 'mp4')
  127. {
  128. ?>
  129. <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="160" height="120" type="application/x-oleobject">
  130. <param name="src" value="<?php echo $stream_url; ?>">
  131. <param name="autoplay" value="true">
  132. <param name="loop" value="true">
  133. <param name="cache" value="false">
  134. <embed src="<?php echo $stream_url; ?>" width="160" height="120" autoplay="true" loop="true" cache="false" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed>
  135. </object>
  136. <?php
  137. }
  138. elseif($stream_type == 'mov')
  139. {
  140. ?>
  141. <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="160" height="120" type="application/x-oleobject">
  142. <param name="src" value="<?php echo $stream_url; ?>">
  143. <param name="autoplay" value="true">
  144. <param name="loop" value="true">
  145. <param name="cache" value="false">
  146. <embed src="<?php echo $stream_url; ?>" width="160" height="120" autoplay="true" loop="true" cache="false" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed>
  147. </object>
  148. <?php
  149. }
  150. }
  151. ?>
  152. </td>
  153. </tr>
  154. </table>
  155. <?php if($isMaster): ?>
  156. <br>
  157. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  158. <tr>
  159. <td width="1%" valign="middle"><a href="online_links.php"><img src="../img/links.gif" border="0" alt="" title="<?php echo htmlentities(get_lang('Links')); ?>"></a></td>
  160. <td width="49%" align="left" nowrap="nowrap">&nbsp;<a href="online_links.php"><?php echo get_lang('Links'); ?></a></td>
  161. <td width="49%" align="right" nowrap="nowrap"><a href="online_working_area.php" target="online_working_area"><?php echo get_lang('Home'); ?></a>&nbsp;</td>
  162. <td width="1%" valign="middle"><a href="online_working_area.php" target="online_working_area"><img src="../img/home.gif" border="0" alt="" title="<?php echo htmlentities(get_lang('Home')); ?>"></a></td>
  163. </tr>
  164. </table>
  165. <?php endif; ?>
  166. <?php
  167. include('footer_frame.inc.php');
  168. ?>