chat_hidden.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php // $Id: chat_hidden.php,v 1.8 2005/05/01 11:49:16 darkden81 Exp $
  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.chat
  25. ==============================================================================
  26. */
  27. define('FRAME','hidden');
  28. $language_file = array ('chat');
  29. require('../inc/global.inc.php');
  30. include_once '../inc/lib/course.lib.php';
  31. require_once 'chat_functions.lib.php';
  32. //$tbl_user=$mainDbName."`.`user";
  33. //$tbl_chat_connected=$_course['dbNameGlu'].'chat_connected';
  34. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  35. $tbl_chat_connected = Database::get_course_chat_connected_table();
  36. $query="SELECT username FROM $tbl_user WHERE user_id='".$_user['user_id']."'";
  37. $result=Database::query($query,__FILE__,__LINE__);
  38. list($pseudoUser)=Database::fetch_row($result);
  39. $isAllowed=(empty($pseudoUser) || !$_cid)?false:true;
  40. $isMaster=$is_courseAdmin?true:false;
  41. /*if(!$isAllowed)
  42. {
  43. exit();
  44. }*/
  45. $dateNow=date('Y-m-d');
  46. $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
  47. $chatPath=$documentPath.'chat_files/';
  48. $chat_size_old=intval($_POST['chat_size_old']);
  49. $chat_size_new=filesize($chatPath.'messages-'.$dateNow.'.log.html');
  50. $sql="SELECT user_id FROM $tbl_chat_connected WHERE user_id='".$_user['user_id']."'";
  51. $result=Database::query($sql);
  52. //The user_id exists so we must do an UPDATE and not a INSERT
  53. $current_time=date('Y-m-d H:i:s');
  54. if (Database::num_rows($result)==0) {
  55. $query="INSERT INTO $tbl_chat_connected(user_id,last_connection) VALUES('".$_user['user_id']."','".$current_time."')";
  56. } else {
  57. $query="UPDATE $tbl_chat_connected set last_connection='".$current_time."' WHERE user_id='".$_user['user_id']."'";
  58. }
  59. Database::query($query,__FILE__,__LINE__);
  60. $query="SELECT COUNT(user_id) FROM $tbl_chat_connected WHERE last_connection>'".date('Y-m-d H:i:s',time()-60*5)."'";
  61. $result=Database::query($query,__FILE__,__LINE__);
  62. $connected_old=intval($_POST['connected_old']);
  63. list($connected_new) = Database::fetch_row($result);
  64. /*disconnected user of chat*/
  65. disconnect_user_of_chat ();
  66. include("header_frame.inc.php");
  67. //navigation menu
  68. if(api_get_setting('show_navigation_menu') != 'false')
  69. {
  70. $course_id = api_get_course_id();
  71. if ( !empty($course_id) && ($course_id != -1) )
  72. {
  73. if( api_get_setting('show_navigation_menu') != 'icons')
  74. {
  75. echo '</div> <!-- end #center -->';
  76. echo '</div> <!-- end #centerwrap -->';
  77. }
  78. require_once(api_get_path(INCLUDE_PATH).'tool_navigation_menu.inc.php');
  79. show_navigation_menu();
  80. }
  81. }
  82. ?>
  83. <form name="formHidden" method="post" action="<?php echo api_get_self().'?cidReq='.$_GET['cidReq']; ?>">
  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. </form>
  87. <?php
  88. if ($_SESSION["origin"] == 'whoisonline') { //check if our target has denied our request or not
  89. $talk_to=$_SESSION["target"];
  90. $track_user_table = Database::get_main_table(TABLE_MAIN_USER);
  91. $sql="select chatcall_text from $track_user_table where ( user_id = $talk_to )";
  92. $result=Database::query($sql,__FILE__,__LINE__);
  93. $row=Database::fetch_array($result);
  94. if ($row['chatcall_text'] == 'DENIED') {
  95. echo "<script language=javascript> alert('".get_lang('ChatDenied')."'); </script>";
  96. $sql="update $track_user_table set chatcall_user_id = '', chatcall_date = '', chatcall_text='' where (user_id = $talk_to)";
  97. $result=Database::query($sql,__FILE__,__LINE__);
  98. }
  99. }
  100. include('footer_frame.inc.php');
  101. ?>