online_hidden1.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  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. * Hidden frame that refreshes the visible frames when a modification occurs
  22. *
  23. * @author Olivier Brouckaert
  24. * @package dokeos.online
  25. ==============================================================================
  26. */
  27. define('FRAME','hidden1');
  28. $langFile='chat';
  29. include('../inc/global.inc.php');
  30. $this_section=SECTION_COURSES;
  31. $tbl_user=Database::get_main_table(MAIN_USER_TABLE);
  32. $tbl_online_connected=Database::get_course_table(ONLINE_CONNECTED_TABLE);
  33. $query="SELECT username FROM $tbl_user WHERE user_id='$_uid'";
  34. $result=api_sql_query($query,__FILE__,__LINE__);
  35. list($pseudoUser)=mysql_fetch_row($result);
  36. $isAllowed=(empty($pseudoUser) || !$_cid)?false:true;
  37. $isMaster=$is_courseAdmin?true:false;
  38. if(!$isAllowed)
  39. {
  40. exit();
  41. }
  42. $dateNow=date('Y-m-d');
  43. $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
  44. $onlinePath=$documentPath.'online_files/';
  45. $chat_size_old=intval($_POST['chat_size_old']);
  46. $chat_size_new=filesize($onlinePath.'messages-'.$dateNow.'.log');
  47. $query="REPLACE INTO $tbl_online_connected (user_id,last_connection) VALUES('$_uid',NOW())";
  48. api_sql_query($query,__FILE__,__LINE__);
  49. $query="SELECT COUNT(user_id) FROM $tbl_online_connected WHERE last_connection>'".date('Y-m-d H:i:s',time()-60*5)."'";
  50. $result=api_sql_query($query,__FILE__,__LINE__);
  51. $connected_old=intval($_POST['connected_old']);
  52. list($connected_new)=mysql_fetch_row($result);
  53. $streaming_old=$_POST['streaming_old'];
  54. $streaming_new=md5(print_r(@file($onlinePath.'streaming.txt'),true));
  55. if($isMaster)
  56. {
  57. $document=trim(stripslashes($_POST['document']));
  58. if(strstr($document,'online_htmlarea.php'))
  59. {
  60. $document.='?size='.filesize($onlinePath.'htmlarea.html');
  61. }
  62. $fp=fopen($onlinePath.'document_selected.txt','w');
  63. if(empty($document))
  64. {
  65. fputs($fp,api_get_path(WEB_CODE_PATH).'online/online_working_area.php');
  66. }
  67. else
  68. {
  69. fputs($fp,$document);
  70. }
  71. fclose($fp);
  72. }
  73. else
  74. {
  75. if(!list($document)=file($onlinePath.'document_selected.txt'))
  76. {
  77. $document=api_get_path(WEB_CODE_PATH).'online/online_working_area.php';
  78. }
  79. }
  80. include('header_frame.inc.php');
  81. ?>
  82. <form name="formHidden" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  83. <input type="hidden" name="document" value="<?php echo htmlentities($document); ?>">
  84. <input type="hidden" name="chat_size_old" value="<?php echo $chat_size_new; ?>">
  85. <input type="hidden" name="connected_old" value="<?php echo $connected_new; ?>">
  86. <input type="hidden" name="streaming_old" value="<?php echo $streaming_new; ?>">
  87. </form>
  88. <?php
  89. include('footer_frame.inc.php');
  90. ?>