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

Source for file online_message.php

Documentation is available at online_message.php

  1. <?php // $Id: online_message.php 13296 2007-09-27 02:19:40Z yannoo $
  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. *    Allows to type the messages that will be displayed on online_chat.php
  27. *
  28. *    @author Olivier Brouckaert
  29. *    @package dokeos.online
  30. ==============================================================================
  31. */
  32.  
  33. define('FRAME','message');
  34.  
  35. // name of the language file that needs to be included 
  36. $language_file='chat';
  37.  
  38. include('../inc/global.inc.php');
  39. $this_section=SECTION_COURSES;
  40.  
  41.  
  42. /*
  43. -----------------------------------------------------------
  44.     Constants and variables
  45. -----------------------------------------------------------
  46. */
  47. $sent $_REQUEST['sent'];
  48. $question $_REQUEST['question'];
  49.  
  50.  
  51. $query="SELECT username FROM $tbl_user WHERE user_id='".$_user['user_id']."'";
  52. $result=api_sql_query($query,__FILE__,__LINE__);
  53.  
  54. list($pseudoUser)=mysql_fetch_row($result);
  55.  
  56. $isAllowed=(empty($pseudoUser|| !$_cid)?false:true;
  57. $isMaster=$is_courseAdmin?true:false;
  58.  
  59. if(!$isAllowed)
  60. {
  61.     exit();
  62. }
  63.  
  64. $timeNow=date('H:i');
  65. $dateNow=date('Y-m-d');
  66.  
  67. $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
  68. $onlinePath=$documentPath.'online_files/';
  69.  
  70. if(!is_dir($onlinePath))
  71. {
  72.     if(is_file($onlinePath))
  73.     {
  74.         @unlink($onlinePath);
  75.     }
  76.  
  77.     @mkdir($onlinePath,0777);
  78.     @chmod($onlinePath,0777);
  79. }
  80.  
  81. $chat_size=0;
  82.  
  83. if($sent)
  84. {
  85.     $message=trim(htmlspecialchars(stripslashes($_POST['message']),ENT_QUOTES,$charset));
  86.  
  87.     if(!empty($message))
  88.     {
  89.         $message=make_clickable($message);
  90.  
  91.         if($question)
  92.         {
  93.             $message='<span class="question"><b>'.get_lang('Question').' :</b> '.$message.'</span>';
  94.         }
  95.  
  96.         $fp=fopen($onlinePath.'messages-'.$dateNow.'.log','a');
  97.  
  98.         if($isMaster)
  99.         {
  100.             fputs($fp,"[$timeNow] <span class=\"master\"><b>$pseudoUser</b></span> : $message\n");
  101.         }
  102.         else
  103.         {
  104.             fputs($fp,"[$timeNow] <b>$pseudoUser</b> : $message\n");
  105.         }
  106.  
  107.         fclose($fp);
  108.  
  109.         $chat_size=filesize($onlinePath.'messages-'.$dateNow.'.log');
  110.     }
  111. }
  112.  
  113. include('header_frame.inc.php');
  114. ?>
  115.  
  116. <form name="formMessage" method="post" action="<?php echo api_get_self()?>" onsubmit="javascript:if(document.formMessage.message.value == '') { alert('<?php echo addslashes(htmlentities(get_lang('TypeMessage'),ENT_QUOTES,$charset))?>'); document.formMessage.message.focus(); return false; }" autocomplete="off">
  117. <input type="hidden" name="sent" value="1">
  118. <table border="0" cellpadding="5" cellspacing="0" width="100%">
  119. <tr>
  120.   <td width="90%"><input type="text" name="message" size="50" value="" style="width: 100%;"></td>
  121.   <td width="9%" nowrap="nowrap"><?php echo get_lang('Question')?>&nbsp;<input type="checkbox" name="question" value="1" style="vertical-align: middle;" onclick="javascript:if(this.checked == true && !confirm('<?php echo addslashes(htmlentities(get_lang('OnlyCheckForImportantQuestion'),ENT_QUOTES,$charset))?>')) this.checked=false; document.formMessage.message.focus();"></td>
  122.   <td width="1%"><input type="submit" value="OK" style="width: 30px;"></td>
  123. </tr>
  124. </table>
  125. </form>
  126.  
  127. <?php
  128. include('footer_frame.inc.php');
  129. ?>

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