header('Location: document.php?id=' . $document_data['parent_id']); exit; } else { $msgError = get_lang('Impossible'); } } else { $msgError = get_lang('Impossible'); } } else { if ($document_id) { FileManager::update_existing_document($_course, $document_id, $file_size, $read_only_flag); } } } else { if ($document_id) { FileManager::update_existing_document($_course, $document_id, $file_size, $read_only_flag); } } } } } // Replace relative paths by absolute web paths (e.g. './' => 'http://www.chamilo.org/courses/ABC/document/') if (file_exists($document_data['absolute_path'])) { $path_info = pathinfo($document_data['absolute_path']); $filename = $path_info['filename']; $extension = $path_info['extension']; if (in_array($extension, array('html', 'htm'))) { $content = file($document_data['absolute_path']); $content = implode('', $content); //$path_to_append = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir; // $content = str_replace('="./', '="'.$path_to_append, $content);
file_put_contents($documentPath, $contents); //add document to database $doc_id = FileManager::add_document($_course, $relativeUrlPath . '/' . $paintFileName, 'file', filesize($documentPath), $title); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id); } elseif ($currentTool == 'document/editpaint') { $documentPath = $saveDir . '/' . $paintFileName; //add new document to disk file_put_contents($documentPath, $contents); //check path if (!isset($_SESSION['paint_file'])) { api_not_allowed(); die; } if ($_SESSION['paint_file'] == $paintFileName) { $document_id = DocumentManager::get_document_id($_course, $relativeUrlPath . '/' . $paintFileName); FileManager::update_existing_document($_course, $document_id, filesize($documentPath), null); api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentUpdated', $_user['user_id'], $groupId, null, null, null, $current_session_id); } else { //add a new document $doc_id = FileManager::add_document($_course, $relativeUrlPath . '/' . $paintFileName, 'file', filesize($documentPath), $title); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id); } } //delete temporal file $temp_file_2delete = $_SESSION['temp_realpath_image']; unlink($temp_file_2delete); //Clean sessions and return to Chamilo file list unset($_SESSION['paint_dir']); unset($_SESSION['paint_file']); unset($_SESSION['whereami']); unset($_SESSION['temp_realpath_image']);
$basename_chat = 'messages-' . $date_now; } } if ($reset && $isMaster) { $i = 1; while (file_exists($chat_path . $basename_chat . '-' . $i . '.log.html')) { $i++; } @rename($chat_path . $basename_chat . '.log.html', $chat_path . $basename_chat . '-' . $i . '.log.html'); @fclose(fopen($chat_path . $basename_chat . '.log.html', 'w')); $doc_id = FileManager::add_document($_course, $basepath_chat . '/' . $basename_chat . '-' . $i . '.log.html', 'file', filesize($chat_path . $basename_chat . '-' . $i . '.log.html'), $basename_chat . '-' . $i . '.log.html'); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $group_id, null, null, null, $session_id); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'], $group_id, null, null, null, $session_id); FileManager::item_property_update_on_folder($_course, $basepath_chat, $_user['user_id']); $doc_id = DocumentManager::get_document_id($_course, $basepath_chat . '/' . $basename_chat . '.log.html'); FileManager::update_existing_document($_course, $doc_id, 0); } $remove = 0; $content = array(); if (file_exists($chat_path . $basename_chat . '.log.html')) { $content = file($chat_path . $basename_chat . '.log.html'); $nbr_lines = sizeof($content); $remove = $nbr_lines - 100; } if ($remove < 0) { $remove = 0; } array_splice($content, 0, $remove); require 'header_frame.inc.php'; if (isset($_GET['origin']) && $_GET['origin'] == 'whoisonline') { //the caller
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'], $group_id, null, null, null, $session_id); FileManager::item_property_update_on_folder($_course, $basepath_chat, $_user['user_id']); } else { $doc_id = DocumentManager::get_document_id($_course, $basepath_chat . '/' . $basename_chat . '.log.html'); } $fp = fopen($chat_path . $basename_chat . '.log.html', 'a'); if ($isMaster) { $photo = '<img src="' . api_get_path(WEB_IMG_PATH) . 'teachers.gif" alt="' . get_lang('Teacher') . '" width="11" height="11" align="top" title="' . get_lang('Teacher') . '" />'; fputs($fp, '<span style="color:#999; font-size: smaller;">[' . $timeNow . ']</span>' . $photo . ' <span id="chat_login_name"><b>' . api_get_person_name($firstname, $lastname) . '</b></span> : <i>' . $message . '</i><br />' . "\n"); } else { $photo = '<img src="' . api_get_path(WEB_IMG_PATH) . 'students.gif" alt="' . get_lang('Student') . '" width="11" height="11" align="top" title="' . get_lang('Student') . '" />'; fputs($fp, '<span style="color:#999; font-size: smaller;">[' . $timeNow . ']</span>' . $photo . ' <b>' . api_get_person_name($firstname, $lastname) . '</b> : <i>' . $message . '</i><br />' . "\n"); } fclose($fp); $chat_size = filesize($chat_path . $basename_chat . '.log.html'); FileManager::update_existing_document($_course, $doc_id, $chat_size); FileManager::item_property_update_on_folder($_course, $basepath_chat, $_user['user_id']); } } } ?> <form name="formMessage" method="post" action="<?php echo api_get_self() . '?' . api_get_cidreq(); ?> " onsubmit="javascript: if(document.formMessage.message.value == '') { alert('<?php echo addslashes(api_htmlentities(get_lang('TypeMessage'), ENT_QUOTES)); ?> '); document.formMessage.message.focus(); return false; }" autocomplete="off"> <input type="hidden" name="sent" value="1"> <table border="0" cellpadding="5" cellspacing="0" width="100%">