dokeos-online
[ class tree: dokeos-online ] [ index: dokeos-online ] [ all elements ]

Source for file online_chat.php

Documentation is available at online_chat.php

  1. <?php
  2. /*
  3. ==============================================================================
  4.     Dokeos - elearning and course management software
  5.  
  6.     Copyright (c) 2004 Dokeos S.A.
  7.     Copyright (c) 2003 Ghent University (UGent)
  8.     Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9.     Copyright (c) Olivier Brouckaert
  10.  
  11.     For a full list of contributors, see "credits.txt".
  12.     The full license can be read in "license.txt".
  13.  
  14.     This program is free software; you can redistribute it and/or
  15.     modify it under the terms of the GNU General Public License
  16.     as published by the Free Software Foundation; either version 2
  17.     of the License, or (at your option) any later version.
  18.  
  19.     See the GNU General Public License for more details.
  20.  
  21.     Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  22. ==============================================================================
  23. */
  24. /**
  25. ==============================================================================
  26. *    Chat frame that shows the message list
  27. *
  28. *    @author Olivier Brouckaert
  29. *    @package dokeos.online
  30. ==============================================================================
  31. */
  32.  
  33. define('FRAME','chat');
  34.  
  35. // name of the language file that needs to be included 
  36. $language_file='chat';
  37.  
  38. include('../inc/global.inc.php');
  39.  
  40. $reset=$_GET['reset']?true:false;
  41.  
  42. $query="SELECT username FROM $tbl_user WHERE user_id='".$_user['user_id']."'";
  43. $result=api_sql_query($query,__FILE__,__LINE__);
  44.  
  45. list($pseudoUser)=mysql_fetch_row($result);
  46.  
  47. $isAllowed=(empty($pseudoUser|| !$_cid)?false:true;
  48. $isMaster=$is_courseAdmin?true:false;
  49.  
  50. if(!$isAllowed)
  51. {
  52.     exit();
  53. }
  54.  
  55. $dateNow=date('Y-m-d');
  56.  
  57. $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
  58. $onlinePath=$documentPath.'online_files/';
  59.  
  60. if(!file_exists($onlinePath.'messages-'.$dateNow.'.log'))
  61. {
  62.     fclose(fopen($onlinePath.'messages-'.$dateNow.'.log','w'));
  63. }
  64.  
  65. if($reset && $isMaster)
  66. {
  67.     $i=1;
  68.  
  69.     while(file_exists($onlinePath.'messages-'.$dateNow.'-'.$i.'.log'))
  70.     {
  71.         $i++;
  72.     }
  73.  
  74.     rename($onlinePath.'messages-'.$dateNow.'.log',$onlinePath.'messages-'.$dateNow.'-'.$i.'.log');
  75.  
  76.     fclose(fopen($onlinePath.'messages-'.$dateNow.'.log','w'));
  77. }
  78.  
  79. $content=file($onlinePath.'messages-'.$dateNow.'.log');
  80. $nbr_lines=sizeof($content);
  81. $remove=$nbr_lines-100;
  82.  
  83. if($remove 0)
  84. {
  85.     $remove=0;
  86. }
  87.  
  88. array_splice($content,0,$remove);
  89.  
  90. include('header_frame.inc.php');
  91.  
  92. foreach($content as $thisLine)
  93. {
  94.     echo "$thisLine<br>";
  95. }
  96. ?>
  97.  
  98. <a name="bottom" style="text-decoration:none;">&nbsp;</a>
  99.  
  100. <?php
  101. if($isMaster)
  102. {
  103.     $rand=mt_rand(1,1000);
  104. ?>
  105.  
  106. <br>
  107.  
  108. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  109. <tr>
  110.   <td width="1%" valign="middle"><a href="<?php echo api_get_self()?>?rand=<?php echo $rand?>&reset=1#bottom" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('ConfirmReset'),ENT_QUOTES,$charset))?>')) return false;"><img src="../img/delete.gif" border="0" alt="" title="<?php echo htmlentities(get_lang('ClearList'),ENT_QUOTES,$charset)?>"></a></td>
  111.   <td width="99%">&nbsp;<a href="<?php echo api_get_self()?>?rand=<?php echo $rand?>&reset=1#bottom" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('ConfirmReset'),ENT_QUOTES,$charset))?>')) return false;"><?php echo get_lang('ClearList')?></a></td>
  112. </tr>
  113. </table>
  114.  
  115. <?php
  116. }
  117.  
  118. include('footer_frame.inc.php');
  119. ?>

Documentation generated on Thu, 12 Jun 2008 14:08:18 -0500 by phpDocumentor 1.4.1