Security fixes + minor update from 1.11.x

pull/4101/head
Julio Montoya 5 years ago
parent ada2efd99f
commit bd76b1f8cb
  1. 2
      main/admin/statistics/index.php
  2. 25
      main/admin/user_edit.php
  3. 2
      main/badge/assign.php
  4. 12
      main/calendar/agenda_js.php
  5. 8
      main/calendar/agenda_list.php
  6. 5
      main/document/create_document.php
  7. 9
      main/document/download.php
  8. 1
      main/document/download_uploaded_files.php
  9. 4
      main/document/remote.php
  10. 2
      main/document/save_pixlr.php
  11. 21
      main/forum/viewthread.php
  12. 23
      main/inc/ajax/agenda.ajax.php
  13. 1
      main/inc/ajax/extra_field.ajax.php
  14. 85
      main/inc/ajax/user_manager.ajax.php
  15. 6
      main/inc/lib/database.lib.php
  16. 23
      main/inc/lib/document.lib.php
  17. 1
      main/inc/lib/events.lib.php
  18. 2
      main/inc/lib/export.lib.inc.php
  19. 4
      main/inc/lib/extra_field.lib.php
  20. 2
      main/inc/lib/extra_field_value.lib.php
  21. 2
      main/inc/lib/message.lib.php
  22. 6
      main/inc/lib/model.lib.php
  23. 42
      main/inc/lib/pear/HTML/QuickForm.php
  24. 16
      main/inc/lib/security.lib.php
  25. 22
      main/inc/lib/social.lib.php
  26. 19
      main/inc/lib/template.lib.php
  27. 10
      main/lp/aicc.class.php
  28. 5
      main/lp/lp_upload.php
  29. 14
      main/lp/scorm.class.php
  30. 22
      main/template/default/social/user_block.tpl
  31. 17
      main/ticket/report.php
  32. 40
      src/Chamilo/CoreBundle/Component/Editor/Driver/PersonalDriver.php

@ -231,7 +231,7 @@ in_array(
$dateEnd = Security::remove_XSS($_REQUEST['range_end']);
}
$statusId = (int) $_REQUEST['status_id'];
$statusId = isset($_REQUEST['status_id']) ? (int) $_REQUEST['status_id'] : 0;
$conditions = "&date_start=$dateStart&date_end=$dateEnd&status=$statusId";

@ -99,28 +99,29 @@ $form = new FormValidator(
api_get_self().'?user_id='.$user_id,
''
);
$form->protect();
$form->addElement('header', $tool_name);
$form->addElement('hidden', 'user_id', $user_id);
if (api_is_western_name_order()) {
// Firstname
$form->addElement('text', 'firstname', get_lang('FirstName'));
$form->addElement('text', 'firstname', get_lang('FirstName'), ['autocomplete' => 'off']);
$form->applyFilter('firstname', 'html_filter');
$form->applyFilter('firstname', 'trim');
$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
// Lastname
$form->addElement('text', 'lastname', get_lang('LastName'));
$form->addElement('text', 'lastname', get_lang('LastName'), ['autocomplete' => 'off']);
$form->applyFilter('lastname', 'html_filter');
$form->applyFilter('lastname', 'trim');
$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
} else {
// Lastname
$form->addElement('text', 'lastname', get_lang('LastName'));
$form->addElement('text', 'lastname', get_lang('LastName'), ['autocomplete' => 'off']);
$form->applyFilter('lastname', 'html_filter');
$form->applyFilter('lastname', 'trim');
$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
// Firstname
$form->addElement('text', 'firstname', get_lang('FirstName'));
$form->addElement('text', 'firstname', get_lang('FirstName'), ['autocomplete' => 'off']);
$form->applyFilter('firstname', 'html_filter');
$form->applyFilter('firstname', 'trim');
$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
@ -132,7 +133,7 @@ $form->applyFilter('official_code', 'html_filter');
$form->applyFilter('official_code', 'trim');
// Email
$form->addElement('text', 'email', get_lang('Email'));
$form->addElement('text', 'email', get_lang('Email'), ['autocomplete' => 'off']);
$form->addRule('email', get_lang('EmailWrong'), 'email');
if (api_get_setting('registration', 'email') == 'true') {
$form->addRule('email', get_lang('EmailWrong'), 'required');
@ -149,7 +150,7 @@ if (api_get_setting('openid_authentication') == 'true') {
}
// Phone
$form->addElement('text', 'phone', get_lang('PhoneNumber'));
$form->addElement('text', 'phone', get_lang('PhoneNumber'), ['autocomplete' => 'off']);
// Picture
$form->addFile(
@ -369,7 +370,7 @@ $error_drh = false;
// Validate form
if ($form->validate()) {
$user = $form->getSubmitValues(1);
$reset_password = intval($user['reset_password']);
$reset_password = (int) $user['reset_password'];
if ($reset_password == 2 && empty($user['password'])) {
Display::addFlash(Display::return_message(get_lang('PasswordIsTooShort')));
header('Location: '.api_get_self().'?user_id='.$user_id);
@ -404,10 +405,10 @@ if ($form->validate()) {
$email = $user['email'];
$phone = $user['phone'];
$username = isset($user['username']) ? $user['username'] : $userInfo['username'];
$status = intval($user['status']);
$platform_admin = intval($user['platform_admin']);
$send_mail = intval($user['send_mail']);
$reset_password = intval($user['reset_password']);
$status = (int) $user['status'];
$platform_admin = (int) $user['platform_admin'];
$send_mail = (int) $user['send_mail'];
$reset_password = (int) $user['reset_password'];
$hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null;
$language = $user['language'];
$address = isset($user['address']) ? $user['address'] : null;
@ -424,7 +425,7 @@ if ($form->validate()) {
$status = COURSEMANAGER;
}
if (api_get_setting('login_is_email') == 'true') {
if (api_get_setting('login_is_email') === 'true') {
$username = $email;
}

@ -8,8 +8,6 @@ use Skill as SkillManager;
* Page for assign skills to a user.
*
* @author: Jose Loguercio <jose.loguercio@beeznest.com>
*
* @package chamilo.badge
*/
require_once __DIR__.'/../inc/global.inc.php';

@ -1,9 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.calendar
*/
// use anonymous mode when accessing this course tool
$use_anonymous = true;
@ -12,7 +9,7 @@ $typeList = ['personal', 'course', 'admin', 'platform'];
$type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], $typeList) ? $_REQUEST['type'] : 'personal';
$userId = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : null;
if ($type == 'personal' || $type == 'admin') {
if ('personal' == $type || 'admin' == $type) {
$cidReset = true; // fixes #5162
}
require_once __DIR__.'/../inc/global.inc.php';
@ -115,7 +112,7 @@ switch ($type) {
$tpl->assign('js_format_date', 'll');
$region_value = api_get_language_isocode();
if ($region_value == 'en') {
if ('en' == $region_value) {
$region_value = 'en-GB';
}
$tpl->assign('region_value', $region_value);
@ -225,13 +222,14 @@ if (!empty($userId)) {
$agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?type='.$type;
}
if ($type == 'course' && !empty($courseId)) {
if ('course' === $type && !empty($courseId)) {
$agenda_ajax_url .= '&'.api_get_cidreq();
}
if (isset($_GET['session_id'])) {
$agenda_ajax_url .= '&session_id='.intval($_GET['session_id']);
}
$agenda_ajax_url .= '&sec_token='.Security::get_token();
$tpl->assign('web_agenda_ajax_url', $agenda_ajax_url);
@ -274,7 +272,7 @@ $form->addHtmlEditor(
]
);
if ($agenda->type === 'course') {
if ('course' === $agenda->type) {
$form->addHtml('<div id="add_as_announcement_div" style="display: none">');
$form->addElement('checkbox', 'add_as_annonuncement', null, get_lang('AddAsAnnouncement'));
$form->addHtml('</div>');

@ -1,22 +1,18 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.calendar
*/
require_once __DIR__.'/../inc/global.inc.php';
$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : 'calendar_list';
$logInfo = [
'tool' => TOOL_CALENDAR_EVENT,
'tool_id' => 0,
'tool_id_detail' => 0,
'action' => $action,
];
Event::registerLog($logInfo);
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null;
$typeList = ['personal', 'course', 'admin', 'platform'];
$type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], $typeList, true) ? $_REQUEST['type'] : null;
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type='.Security::remove_XSS($type),

@ -506,14 +506,10 @@ if ($form->validate()) {
// Setting the title
$title = $values['title'];
// Setting the extension
$extension = 'html';
$content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY);
/*if (strpos($content, '/css/frames.css') == false) {
$content = str_replace('</head>', '<link rel="stylesheet" href="./css/frames.css" type="text/css" /><style> body{margin:50px;}</style></head>', $content);
}*/
// Don't create file with the same name.
@ -631,7 +627,6 @@ if ($form->validate()) {
}
Display :: display_header($nameTools, "Doc");
// actions
// link back to the documents overview
if ($is_certificate_mode) {
$actionsLeft = '<a href="document.php?certificate=true&id='.$folder_id.'&selectcat='.Security::remove_XSS($_GET['selectcat']).'">'.

@ -3,15 +3,12 @@
/**
* This file is responsible for passing requested documents to the browser.
* Many functions updated and moved to lib/document.lib.php.
*
* @package chamilo.document
*/
session_cache_limiter('none');
require_once __DIR__.'/../inc/global-min.inc.php';
$this_section = SECTION_COURSES;
// Protection
api_protect_course_script();
$_course = api_get_course_info();
@ -38,9 +35,7 @@ foreach ($docUrlParts as $docUrlPart) {
}
if (empty($doc_url)) {
api_not_allowed(
!empty($_GET['origin']) && $_GET['origin'] === 'learnpath'
);
api_not_allowed(!empty($_GET['origin']) && $_GET['origin'] === 'learnpath');
}
// Dealing with image included into survey: when users receive a link towards a
@ -84,7 +79,7 @@ if (substr($refer_script, 0, 15) == '/fillsurvey.php') {
$path_info = pathinfo($doc_url);
$fix_file_name = false;
if (isset($path_info['extension']) && $path_info['extension'] == 'swf') {
if (isset($path_info['extension']) && $path_info['extension'] === 'swf') {
$fixed_url = str_replace('-', '_', $doc_url);
$doc_id = DocumentManager::get_document_id(api_get_course_info(), $doc_url);
if (!$doc_id) {

@ -16,6 +16,7 @@ $courseInfo = api_get_course_info($courseCode);
if (empty($courseInfo)) {
$courseInfo = api_get_course_info();
}
$type = preg_replace("/[^a-zA-Z_]+/", '', $type);
if (empty($courseInfo) || empty($type) || empty($file)) {
api_not_allowed(true);
}

@ -33,7 +33,7 @@ $user_id = api_get_user_id();
$coursePath = api_get_path(SYS_COURSE_PATH).$cidReq.'/document';
$_course = api_get_course_info($cidReq);
if (empty($_course)) {
die("problem when fetching course information");
exit("problem when fetching course information");
}
// stupid variable initialisation for old version of DocumentManager functions.
$_course['path'] = $_course['directory'];
@ -60,7 +60,7 @@ if (strlen($cwd) == 0) {
$cwd = '/';
}
if (Security::check_abs_path($cwd, api_get_path(SYS_PATH))) {
die();
exit();
}
if ($action == 'list') {
/*==== List files ====*/

@ -88,7 +88,7 @@ if ($contents === false) {
// Extension security
if ($extension != 'jpg' && $extension != 'png' && $extension != 'pxd') {
die();
exit();
}
if ($extension == 'pxd') {
echo "pxd file type does not supported";

@ -6,8 +6,6 @@ use Chamilo\CourseBundle\Entity\CForumPost;
/**
* @author Julio Montoya <gugli100@gmail.com> UI Improvements + lots of bugfixes
*
* @package chamilo.forum
*/
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_FORUM;
@ -151,7 +149,7 @@ if (!empty($groupId)) {
];
} else {
$my_search = isset($_GET['search']) ? $_GET['search'] : '';
if ($origin != 'learnpath') {
if ($origin !== 'learnpath') {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'forum/index.php?'.api_get_cidreq().'&search='.Security::remove_XSS(
urlencode($my_search)
@ -187,14 +185,14 @@ if (!api_is_allowed_to_edit(false, true) &&
// this increases the number of times the thread has been viewed
increase_thread_view($threadId);
if ($origin == 'learnpath') {
if ($origin === 'learnpath') {
$template = new Template('', false, false, true, true, false);
} else {
$template = new Template();
}
$actions = '<span style="float:right;">'.search_link().'</span>';
if ($origin != 'learnpath') {
if ($origin !== 'learnpath') {
$actions .= '<a href="'.$forumUrl.'viewforum.php?forum='.$forumId.'&'.api_get_cidreq().'">'
.Display::return_icon('back.png', get_lang('BackToForum'), '', ICON_SIZE_MEDIUM).'</a>';
}
@ -307,7 +305,7 @@ foreach ($posts as $post) {
}
$post['user_data'] = '';
if ($origin != 'learnpath') {
if ($origin !== 'learnpath') {
if ($allowUserImageForum) {
$post['user_data'] = '<div class="thumbnail">'.
display_user_image($posterId, $name, $origin).'</div>';
@ -338,7 +336,7 @@ foreach ($posts as $post) {
);
}
if ($origin != 'learnpath') {
if ($origin !== 'learnpath') {
$post['user_data'] .= Display::tag(
'p',
Display::dateToStringAgoAndLongDate($post['post_date']),
@ -685,10 +683,17 @@ if ($current_forum['forum_of_group'] != 0) {
}
if ($showForm) {
$values = [
'post_title' => Security::remove_XSS($current_thread['thread_title']),
'post_text' => '',
'post_notification' => '',
'thread_sticky' => '',
'thread_peer_qualify' => '',
];
$form = show_add_post_form(
$current_forum,
'replythread',
null,
$values,
false
);
$formToString = $form->returnForm();

@ -35,6 +35,9 @@ switch ($action) {
if (!$agenda->getIsAllowedToEdit()) {
break;
}
if (false === Security::check_token('get')) {
exit;
}
$add_as_announcement = isset($_REQUEST['add_as_annonuncement']) ? $_REQUEST['add_as_annonuncement'] : null;
$title = isset($_REQUEST['title']) ? $_REQUEST['title'] : null;
$content = isset($_REQUEST['content']) ? $_REQUEST['content'] : null;
@ -49,9 +52,9 @@ switch ($action) {
$content,
$userToSend,
$add_as_announcement,
null, //$parentEventId = null,
[], //$attachmentArray = array(),
null, //$attachmentComment = null,
null,
[],
null,
$comment
);
break;
@ -59,6 +62,9 @@ switch ($action) {
if (!$agenda->getIsAllowedToEdit()) {
break;
}
if (false === Security::check_token('get')) {
exit;
}
$id_list = explode('_', $_REQUEST['id']);
$id = $id_list[1];
$agenda->editEvent(
@ -74,6 +80,9 @@ switch ($action) {
if (!$agenda->getIsAllowedToEdit()) {
break;
}
if (false === Security::check_token('get')) {
exit;
}
$id_list = explode('_', $_REQUEST['id']);
$id = $id_list[1];
$deleteAllEventsFromSerie = isset($_REQUEST['delete_all_events']) ? true : false;
@ -83,6 +92,9 @@ switch ($action) {
if (!$agenda->getIsAllowedToEdit()) {
break;
}
if (false === Security::check_token('get')) {
exit;
}
$minute_delta = $_REQUEST['minute_delta'];
$id = explode('_', $_REQUEST['id']);
$id = $id[1];
@ -92,6 +104,9 @@ switch ($action) {
if (!$agenda->getIsAllowedToEdit()) {
break;
}
if (false === Security::check_token('get')) {
exit;
}
$minute_delta = $_REQUEST['minute_delta'];
$allDay = $_REQUEST['all_day'];
$id = explode('_', $_REQUEST['id']);
@ -124,7 +139,7 @@ switch ($action) {
echo $events;
break;
case 'get_user_agenda':
//Used in the admin user list
// Used in the admin user list.
api_protect_admin_script();
if (api_is_allowed_to_edit(null, true)) {

@ -151,7 +151,6 @@ switch ($action) {
dataType: "json",
data: "values="+save,
success: function(data) {
console.log(data);
}
});

@ -4,12 +4,15 @@
use Chamilo\UserBundle\Entity\User;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Query\Expr\Join;
use Symfony\Component\HttpFoundation\Request as HttpRequest;
/**
* Responses to AJAX calls.
*/
require_once __DIR__.'/../global.inc.php';
$request = HttpRequest::createFromGlobals();
$isRequestByAjax = $request->isXmlHttpRequest();
$action = $_GET['a'];
switch ($action) {
@ -33,39 +36,72 @@ switch ($action) {
}
break;
case 'get_user_popup':
$courseId = isset($_REQUEST['course_id']) ? (int) $_REQUEST['course_id'] : 0;
$sessionId = isset($_REQUEST['session_id']) ? (int) $_REQUEST['session_id'] : 0;
if (!$isRequestByAjax) {
break;
}
$courseId = (int) $request->get('course_id');
$sessionId = (int) $request->get('session_id');
$userId = (int) $request->get('user_id');
$user_info = api_get_user_info($userId);
if (empty($user_info)) {
break;
}
if ($courseId) {
$courseInfo = api_get_course_info_by_id($courseId);
$user_info = api_get_user_info($_REQUEST['user_id']);
if (empty($courseInfo)) {
break;
}
}
if ($sessionId) {
$sessionInfo = api_get_session_info($sessionId);
if (empty($sessionInfo)) {
break;
}
}
$isAnonymous = api_is_anonymous();
if ($isAnonymous && $courseId) {
if ('false' === api_get_setting('course_catalog_published')) {
break;
}
$coursesNotInCatalog = CoursesAndSessionsCatalog::getCoursesToAvoid();
if (in_array($courseId, $coursesNotInCatalog)) {
break;
}
}
echo '<div class="row">';
echo '<div class="col-sm-5">';
echo '<div class="thumbnail">';
echo '<img src="'.$user_info['avatar'].'" /> ';
echo Display::img($user_info['avatar'], $user_info['complete_name']);
echo '</div>';
echo '</div>';
echo '<div class="col-sm-7">';
if (api_get_setting('show_email_addresses') == 'false') {
if ($isAnonymous || api_get_setting('show_email_addresses') == 'false') {
$user_info['mail'] = ' ';
} else {
$user_info['mail'] = ' '.$user_info['mail'].' ';
}
if ($isAnonymous) {
$user_info['mail'] = ' ';
}
$userData = '<h3>'.$user_info['complete_name'].'</h3>'
.PHP_EOL
.$user_info['mail']
.PHP_EOL
.$user_info['official_code'];
$userData = '<h3>'.$user_info['complete_name'].'</h3>'.$user_info['mail'].$user_info['official_code'];
if ($isAnonymous) {
// Only allow anonymous users to see user popup if the popup user
// is a teacher (which might be necessary to illustrate a course)
if ($user_info['status'] === COURSEMANAGER) {
if ((int) $user_info['status'] === COURSEMANAGER) {
echo $userData;
} else {
echo '<h3>-</h3>';
}
} else {
echo Display::url(
@ -76,7 +112,15 @@ switch ($action) {
echo '</div>';
echo '</div>';
$url = api_get_path(WEB_AJAX_PATH).'message.ajax.php?a=send_message&user_id='.$user_info['user_id'].'&course_id='.$courseId.'&session_id='.$sessionId;
$url = api_get_path(WEB_AJAX_PATH).'message.ajax.php?'
.http_build_query(
[
'a' => 'send_message',
'user_id' => $user_info['user_id'],
'course_id' => $courseId,
'session_id' => $sessionId,
]
);
if ($isAnonymous === false &&
api_get_setting('allow_message_tool') == 'true'
@ -228,17 +272,6 @@ switch ($action) {
$additionalParameters
);
/*$result = api_mail_html(
$recipientName,
$user_info['mail'],
$subject,
$body,
$sender_name,
$emailAdmin,
null,
null,
$additionalParameters
);*/
Event::addEvent(LOG_USER_ENABLE, LOG_USER_ID, $user_id);
} else {
Event::addEvent(LOG_USER_DISABLE, LOG_USER_ID, $user_id);

@ -551,13 +551,17 @@ class Database
$option = 'ASSOC',
$debug = false
) {
if ($type_result === 'count') {
$conditions['LIMIT'] = null;
$conditions['limit'] = null;
}
$conditions = self::parse_conditions($conditions);
//@todo we could do a describe here to check the columns ...
if (is_array($columns)) {
$clean_columns = implode(',', $columns);
} else {
if ($columns == '*') {
if ($columns === '*') {
$clean_columns = '*';
} else {
$clean_columns = (string) $columns;

@ -9,8 +9,6 @@ use ChamiloSession as Session;
* It is / will be used to provide a service layer to all document-using tools.
* and eliminate code duplication fro group documents, scorm documents, main documents.
* Include/require it in your code to use its functionality.
*
* @package chamilo.library
*/
class DocumentManager
{
@ -1069,7 +1067,7 @@ class DocumentManager
// Deleting from the DB
$user_id = api_get_user_id();
$document_id = intval($document_id);
$document_id = (int) $document_id;
if (empty($course_info)) {
$course_info = api_get_course_info();
@ -1135,12 +1133,13 @@ class DocumentManager
) {
$TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
$groupId = intval($groupId);
$documentId = (int) $documentId;
$groupId = (int) $groupId;
if (empty($groupId)) {
$groupId = api_get_group_id();
}
$sessionId = intval($sessionId);
$sessionId = (int) $sessionId;
if (empty($sessionId)) {
$sessionId = api_get_session_id();
}
@ -1177,8 +1176,6 @@ class DocumentManager
$path = $docInfo['path'];
}
$documentId = intval($documentId);
if (empty($path) || empty($docInfo) || empty($documentId)) {
return false;
}
@ -1359,7 +1356,7 @@ class DocumentManager
*
* @return int id of document / false if no doc found
*/
public static function get_document_id($courseInfo, $path, $sessionId = null)
public static function get_document_id($courseInfo, $path, $sessionId = null, $forceFileTypeFolder = false)
{
$table = Database::get_course_table(TABLE_DOCUMENT);
$courseId = $courseInfo['real_id'];
@ -1372,11 +1369,16 @@ class DocumentManager
$path = Database::escape_string($path);
if (!empty($courseId) && !empty($path)) {
$folderCondition = '';
if ($forceFileTypeFolder) {
$folderCondition = ' AND filetype = "folder" ';
}
$sql = "SELECT id FROM $table
WHERE
c_id = $courseId AND
path LIKE BINARY '$path' AND
session_id = $sessionId
$folderCondition
LIMIT 1";
$result = Database::query($sql);
@ -1595,8 +1597,8 @@ class DocumentManager
$course_id = $course['real_id'];
// note the extra / at the end of doc_path to match every path in
// the document table that is part of the document path
$session_id = (int) $session_id;
$session_id = intval($session_id);
$condition = "AND d.session_id IN ('$session_id', '0') ";
// The " d.filetype='file' " let the user see a file even if the folder is hidden see #2198
@ -1876,7 +1878,8 @@ class DocumentManager
$sessionId,
$is_preview = false
) {
$user_id = intval($user_id);
$user_id = (int) $user_id;
$sessionId = (int) $sessionId;
$course_info = api_get_course_info($course_code);
$tbl_document = Database::get_course_table(TABLE_DOCUMENT);
$course_id = $course_info['real_id'];

@ -1,7 +1,6 @@
<?php
/* See license terms in /license.txt */
//use Chamilo\UserBundle\Entity\User;
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use ChamiloSession as Session;

@ -15,8 +15,6 @@ use Symfony\Component\Filesystem\Filesystem;
* This is the export library for Chamilo.
* Include/require it in your code to use its functionality.
* Several functions below are adaptations from functions distributed by www.nexen.net.
*
* @package chamilo.library
*/
class Export
{

@ -604,14 +604,14 @@ class ExtraField extends Model
$fields = $this->get_all();
$field_values = new ExtraFieldValue($this->type);
if (!empty($fields) > 0) {
if (!empty($fields)) {
foreach ($fields as $field) {
$field_value = $field_values->get_values_by_handler_and_field_id(
$itemId,
$field['id']
);
if ($field['field_type'] == self::FIELD_TYPE_TAG) {
if (self::FIELD_TYPE_TAG == $field['field_type']) {
$tags = UserManager::get_user_tags_to_string(
$itemId,
$field['id'],

@ -11,8 +11,6 @@ use ChamiloSession as Session;
* Class ExtraFieldValue
* Declaration for the ExtraFieldValue class, managing the values in extra
* fields for any data type.
*
* @package chamilo.library
*/
class ExtraFieldValue extends Model
{

@ -10,8 +10,6 @@ use ChamiloSession as Session;
*
* This class provides methods for messages management.
* Include/require it in your code to use its features.
*
* @package chamilo.library
*/
class MessageManager
{

@ -2,12 +2,10 @@
/* For licensing terms, see /license.txt */
/**
* Class Model
* Class Model.
* This class provides basic methods to implement a CRUD for a new table in the
* database see examples in: career.lib.php and promotion.lib.php
* Include/require it in your code to use its features.
*
* @package chamilo.library
*/
class Model
{
@ -65,7 +63,7 @@ class Model
// Database table definition
$result = Database::delete($this->table, $params);
if ($result != 1) {
if (1 != $result) {
return false;
}

@ -63,6 +63,7 @@ class HTML_QuickForm extends HTML_Common
{
const MAX_ELEMENT_ARGUMENT = 10;
private $dateTimePickerLibraryAdded;
private $token;
/**
* Array containing the form fields
@ -214,7 +215,8 @@ class HTML_QuickForm extends HTML_Common
* @param string $action (optional)Form's action
* @param string $target (optional)Form's target defaults to '_self'
* @param mixed $attributes (optional)Extra attributes for <form> tag
* @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field
* @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a
* special hidden field
* @access public
*/
public function __construct(
@ -225,6 +227,7 @@ class HTML_QuickForm extends HTML_Common
$attributes = null,
$trackSubmit = false
) {
$this->token = null;
parent::__construct($attributes);
$method = (strtoupper($method) == 'GET') ? 'get' : 'post';
$action = ($action == '') ? api_get_self() : $action;
@ -237,7 +240,7 @@ class HTML_QuickForm extends HTML_Common
'action' => $action,
'method' => $method,
'name' => $formName,
'id' => $form_id
'id' => $form_id,
) + $target;
$this->updateAttributes($attributes);
if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) {
@ -268,6 +271,28 @@ class HTML_QuickForm extends HTML_Common
}
}
public function protect()
{
$token = $this->getSubmitValue('protect_token');
if (null === $token) {
$token = Security::get_token();
} else {
$token = Security::get_existing_token();
}
$this->addHidden('protect_token', $token);
$this->setToken($token);
}
public function setToken($token)
{
$this->token = $token;
}
public function getToken()
{
return $this->token;
}
/**
* Returns the current API version
*
@ -1066,7 +1091,8 @@ class HTML_QuickForm extends HTML_Common
* @param string $format (optional)Required for extra rule data
* @param int $howmany (optional)How many valid elements should be in the group
* @param string $validation (optional)Where to perform validation: "server", "client"
* @param bool $reset Client-side: whether to reset the element's value to its original state if validation failed.
* @param bool $reset Client-side: whether to reset the element's value to its original state if
* validation failed.
* @since 2.5
* @access public
* @throws HTML_QuickForm_Error
@ -1396,6 +1422,14 @@ class HTML_QuickForm extends HTML_Common
return false;
}
if (null !== $this->getToken()) {
$check = Security::check_token('form', $this);
Security::clear_token();
if (false === $check) {
return false;
}
}
$registry =& HTML_QuickForm_RuleRegistry::singleton();
foreach ($this->_rules as $target => $rules) {
@ -1638,7 +1672,7 @@ class HTML_QuickForm extends HTML_Common
"\t" => '\t',
"'" => "\\'",
'"' => '\"',
'\\' => '\\\\'
'\\' => '\\\\',
);
foreach ($this->_rules as $elementName => $rules) {

@ -22,8 +22,6 @@ use ChamiloSession as Session;
* For basic filtering, use filter()
* For files inclusions (using dynamic paths) use check_rel_path() and check_abs_path()
*
* @package chamilo.library
*
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
@ -59,6 +57,8 @@ class Security
return false;
}
// Clean $abs_path.
$abs_path = str_replace(['//', '../'], ['/', ''], $abs_path);
$true_path = str_replace("\\", '/', realpath($abs_path));
$checker_path = str_replace("\\", '/', realpath($checker_path));
@ -143,7 +143,7 @@ class Security
*
* @return bool True if it's the right token, false otherwise
*/
public static function check_token($request_type = 'post')
public static function check_token($request_type = 'post', FormValidator $form = null)
{
$sessionToken = Session::read('sec_token');
switch ($request_type) {
@ -164,6 +164,14 @@ class Security
return true;
}
return false;
case 'form':
$token = $form->getSubmitValue('protect_token');
if (!empty($sessionToken) && !empty($token) && $sessionToken === $token) {
return true;
}
return false;
default:
if (!empty($sessionToken) && isset($request_type) && $sessionToken === $request_type) {
@ -478,7 +486,7 @@ class Security
* this method encourages a safe practice for generating icon paths, without using heavy solutions
* based on HTMLPurifier for example.
*
* @param string $img_path the input path of the image, it could be relative or absolute URL
* @param string $image_path the input path of the image, it could be relative or absolute URL
*
* @return string returns sanitized image path or an empty string when the image path is not secure
*

@ -12,8 +12,6 @@ use Zend\Feed\Reader\Reader;
*
* This class provides methods for the social network management.
* Include/require it in your code to use its features.
*
* @package chamilo.social
*/
class SocialManager extends UserManager
{
@ -293,13 +291,19 @@ class SocialManager extends UserManager
} else {
// invitation already exist
$sql = 'SELECT COUNT(*) AS count, id FROM '.$tbl_message.'
WHERE user_sender_id='.$user_id.' AND user_receiver_id='.$friend_id.' AND msg_status = 7';
WHERE
user_sender_id='.$user_id.' AND
user_receiver_id='.$friend_id.' AND
msg_status = 7';
$res_if_exist = Database::query($sql);
$row_if_exist = Database::fetch_array($res_if_exist, 'ASSOC');
if ($row_if_exist['count'] == 1) {
$sql = 'UPDATE '.$tbl_message.' SET
msg_status=5, content = "'.$clean_message_content.'"
WHERE user_sender_id='.$user_id.' AND user_receiver_id='.$friend_id.' AND msg_status = 7 ';
WHERE
user_sender_id='.$user_id.' AND
user_receiver_id='.$friend_id.' AND
msg_status = 7 ';
Database::query($sql);
return true;
@ -583,7 +587,7 @@ class SocialManager extends UserManager
return '';
}
$feeds = explode(';', $feed['rssfeeds']);
if (count($feeds) == 0) {
if (0 == count($feeds)) {
return '';
}
$res = '';
@ -864,9 +868,7 @@ class SocialManager extends UserManager
);
}
$skillBlock = $template->get_template('social/avatar_block.tpl');
return $template->fetch($skillBlock);
return $template->fetch($template->get_template('social/avatar_block.tpl'));
}
/**
@ -2564,7 +2566,7 @@ class SocialManager extends UserManager
*/
public static function getCountWallMessagesByUser($userId, $groupList = [], $friendList = [], $threadList = [])
{
$count = self::getWallMessages(
return self::getWallMessages(
$userId,
0,
$groupList,
@ -2575,8 +2577,6 @@ class SocialManager extends UserManager
true,
$threadList
);
return $count;
}
/**

@ -148,6 +148,7 @@ class Template
'api_get_user_info',
'api_get_configuration_value',
'api_get_setting',
'api_get_course_setting',
'api_get_plugin_setting',
[
'name' => 'return_message',
@ -262,6 +263,9 @@ class Template
$this->assign('language_form', api_display_language_form());
}
if (api_get_configuration_value('notification_event')) {
$this->assign('notification_event', '1');
}
// Chamilo plugins
if ($this->show_header) {
if ($this->load_plugins) {
@ -576,6 +580,7 @@ class Template
'system_version' => api_get_configuration_value('system_version'),
'site_name' => api_get_setting('siteName'),
'institution' => api_get_setting('Institution'),
'institution_url' => api_get_setting('InstitutionUrl'),
'date' => api_format_date('now', DATE_FORMAT_LONG),
'timezone' => api_get_timezone(),
'gamification_mode' => api_get_setting('gamification_mode'),
@ -814,7 +819,7 @@ class Template
}
foreach ($bowerJsFiles as $file) {
$js_file_to_string .= '<script type="text/javascript" src="'.api_get_cdn_path(api_get_path(WEB_PUBLIC_PATH).'assets/'.$file).'"></script>'."\n";
$js_file_to_string .= '<script src="'.api_get_cdn_path(api_get_path(WEB_PUBLIC_PATH).'assets/'.$file).'"></script>'."\n";
}
foreach ($js_files as $file) {
@ -1169,7 +1174,7 @@ class Template
// Minimum options using all defaults (including defaults for Image_Text):
//$options = array('callback' => 'qfcaptcha_image.php');
$captcha_question = $form->addElement('CAPTCHA_Image', 'captcha_question', '', $options);
$captchaQuestion = $form->addElement('CAPTCHA_Image', 'captcha_question', '', $options);
$form->addHtml(get_lang('ClickOnTheImageForANewOne'));
$form->addElement(
@ -1188,7 +1193,7 @@ class Template
'captcha',
get_lang('TheTextYouEnteredDoesNotMatchThePicture'),
'CAPTCHA',
$captcha_question
$captchaQuestion
);
}
}
@ -1253,9 +1258,10 @@ class Template
return implode(CourseManager::USER_SEPARATOR, $names);
}
/*s
/**
* Returns the teachers name for the current course
* Function to use in Twig templates
* Function to use in Twig templates.
*
* @return string
*/
public static function returnTeachersNames()
@ -1291,9 +1297,6 @@ class Template
$this->responseCode = $code;
}
/**
* @param string $code
*/
public function getResponseCode()
{
return $this->responseCode;

@ -5,12 +5,8 @@
* Class aicc
* Defines the AICC class, which is meant to contain the aicc items (nuclear elements).
*
* @package chamilo.learnpath
*
* @author Yannick Warnier <ywarnier@beeznest.org>
* @license GNU/GPL
*
* @package chamilo.learnpath
*/
class aicc extends learnpath
{
@ -341,7 +337,7 @@ class aicc extends learnpath
}
// Now update previous item to change next_item_id.
if ($previous != 0) {
if (0 != $previous) {
$upd = "UPDATE $new_lp_item SET next_item_id = $item_id WHERE c_id = $course_id AND id = $previous";
Database::query($upd);
// Update the previous item id.
@ -1017,7 +1013,7 @@ class aicc extends learnpath
break;
case "\r":
if (!$enclosed && $data[$i + 1] == "\n") {
continue;
break;
}
// no break
case "\n":
@ -1031,7 +1027,7 @@ class aicc extends learnpath
break;
case "\\r":
if (!$enclosed && $data[$i + 1] == "\\n") {
continue;
break;
}
// no break
case "\\n":

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Component\CourseCopy\CourseArchiver;
@ -7,8 +8,6 @@ use Chamilo\CourseBundle\Component\CourseCopy\CourseRestorer;
/**
* Script managing the learnpath upload. To best treat the uploaded file, make sure we can identify it.
*
* @package chamilo.learnpath
*
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
require_once __DIR__.'/../inc/global.inc.php';
@ -42,7 +41,7 @@ if (isset($_POST) && $is_error) {
return false;
unset($_FILES['user_file']);
} elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && count($_FILES) > 0 && !empty($_FILES['user_file']['name'])) {
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST' && count($_FILES) > 0 && !empty($_FILES['user_file']['name'])) {
// A file upload has been detected, now deal with the file...
// Directory creation.
$stopping_error = false;

@ -6,8 +6,6 @@ use Symfony\Component\DomCrawler\Crawler;
/**
* Defines the scorm class, which is meant to contain the scorm items (nuclear elements).
*
* @package chamilo.learnpath
*
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
class scorm extends learnpath
@ -118,7 +116,7 @@ class scorm extends learnpath
if ($root->hasAttributes()) {
$attributes = $root->attributes;
if ($attributes->length !== 0) {
if (0 !== $attributes->length) {
foreach ($attributes as $attrib) {
// <manifest> element attributes
$this->manifest[$attrib->name] = $attrib->value;
@ -128,10 +126,10 @@ class scorm extends learnpath
$this->manifest['name'] = $root->tagName;
if ($root->hasChildNodes()) {
$children = $root->childNodes;
if ($children->length !== 0) {
if (0 !== $children->length) {
foreach ($children as $child) {
// <manifest> element children (can be <metadata>, <organizations> or <resources> )
if ($child->nodeType == XML_ELEMENT_NODE) {
if (XML_ELEMENT_NODE == $child->nodeType) {
switch ($child->tagName) {
case 'metadata':
// Parse items from inside the <metadata> element.
@ -143,7 +141,7 @@ class scorm extends learnpath
$orgs_attribs = $child->attributes;
foreach ($orgs_attribs as $orgs_attrib) {
// Attributes of the <organizations> element.
if ($orgs_attrib->nodeType == XML_ATTRIBUTE_NODE) {
if (XML_ATTRIBUTE_NODE == $orgs_attrib->nodeType) {
$this->manifest['organizations'][$orgs_attrib->name] = $orgs_attrib->value;
}
}
@ -752,6 +750,10 @@ class scorm extends learnpath
$callBack = 'cleanZipFilesAllowHtaccess';
}
if (api_get_configuration_value('skip_scorm_package_clean_up')) {
$callBack = 'cleanZipFilesNoRename';
}
$zipFile->extract(
PCLZIP_CB_PRE_EXTRACT,
$callBack

@ -98,27 +98,31 @@
{% set linkedin_url = '' %}
{% for extra in user.extra %}
{% if extra.value.getField().getVariable() == 'skype' %}
{% set skype_account = extra.value.getValue() %}
{% set skype_account %}
<a href="skype:{{ extra.value.getValue() }}?chat">
<span class="fa fa-skype fa-fw" aria-hidden="true"></span> {{ 'Skype'|get_lang }}
</a>
{% endset %}
{% endif %}
{% if extra.value.getField().getVariable() == 'linkedin_url' %}
{% set linkedin_url = extra.value.getValue() %}
{% set linkedin_url %}
<a href="{{ extra.value.getValue() }}" target="_blank">
<span class="fa fa-linkedin fa-fw" aria-hidden="true"></span> {{ 'LinkedIn'|get_lang }}
</a>
{% endset %}
{% endif %}
{% endfor %}
{% if 'allow_show_skype_account'|api_get_setting == 'true' and not skype_account is empty %}
<li class="item">
<a href="skype:{{ skype_account }}?chat">
<span class="fa fa-skype fa-fw" aria-hidden="true"></span> {{ 'Skype'|get_lang }}
</a>
{{ skype_account | remove_xss}}
</li>
{% endif %}
{% if 'allow_show_linkedin_url'|api_get_setting == 'true' and not linkedin_url is empty %}
<li class="item">
<a href="{{ linkedin_url }}" target="_blank">
<span class="fa fa-linkedin fa-fw" aria-hidden="true"></span> {{ 'LinkedIn'|get_lang }}
</a>
{{ linkedin_url | remove_xss}}
</li>
{% endif %}
{% endif %}
@ -140,7 +144,7 @@
{% for item in extra_info %}
{% if item.variable != 'langue_cible' %}
<dt>{{ item.label }}:</dt>
<dd>{{ item.value }}</dd>
<dd>{{ item.value | remove_xss }}</dd>
{% endif %}
{% endfor %}
</dl>

@ -87,17 +87,6 @@ $tools['student_publication'] = ['id' => 'student_publication', 'name' => get_la
$tools['user'] = ['id' => 'user', 'name' => get_lang('User')];
$tools['forum'] = ['id' => 'forum', 'name' => get_lang('Forum')];
/**
* Returns the escaped string.
*
* @param string $s
*
* @return string
*/
function js_str($s)
{
return '"'.addcslashes($s, "\0..\37\"\\").'"';
}
/**
* This function is to show the ticket form.
*
@ -220,9 +209,9 @@ function get_user_data($from, $number_of_items, $column, $direction)
if (!in_array($direction, ['ASC', 'DESC'])) {
$direction = 'ASC';
}
$column = intval($column);
$from = intval($from);
$number_of_items = intval($number_of_items);
$column = (int) $column;
$from = (int) $from;
$number_of_items = (int) $number_of_items;
$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from, $number_of_items";

@ -7,8 +7,6 @@ namespace Chamilo\CoreBundle\Component\Editor\Driver;
* Class PersonalDriver.
*
* @todo add more checks in upload/rm
*
* @package Chamilo\CoreBundle\Component\Editor\Driver
*/
class PersonalDriver extends Driver implements DriverInterface
{
@ -44,6 +42,14 @@ class PersonalDriver extends Driver implements DriverInterface
// Adding user personal files
$dir = \UserManager::getUserPathById($userId, 'system');
$dirWeb = \UserManager::getUserPathById($userId, 'web');
$mimeType = [
'application',
'text/html',
'text/javascript',
'text/ecmascript',
'image/svg+xml',
'image/svg',
];
$driver = [
'driver' => 'PersonalDriver',
@ -51,6 +57,7 @@ class PersonalDriver extends Driver implements DriverInterface
'path' => $dir.'my_files',
'URL' => $dirWeb.'my_files',
'accessControl' => [$this, 'access'],
'uploadDeny' => $mimeType,
'disabled' => [
'duplicate',
//'rename',
@ -66,6 +73,35 @@ class PersonalDriver extends Driver implements DriverInterface
'resize',
],
];
if (api_get_configuration_value('social_myfiles_office_files_upload_allowed')) {
//Allow all office suite documents to be uploaded in the "My files" section of the social network
$driver['uploadOrder'] = ['deny', 'allow'];
$driver['uploadAllow'] = [
'application/pdf',
'application/msword',
'application/vnd.ms-excel',
'application/vnd.ms-excel.addin.macroEnabled.12',
'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
'application/vnd.ms-excel.sheet.macroEnabled.12',
'application/vnd.ms-excel.template.macroEnabled.12',
'application/vnd.ms-powerpoint',
'application/vnd.ms-powerpoint.addin.macroEnabled.12',
'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
'application/vnd.ms-powerpoint.slide.macroenabled.12',
'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
'application/vnd.ms-powerpoint.template.macroEnabled.12',
'application/vnd.ms-word.document.macroEnabled.12',
'application/vnd.ms-word.template.macroEnabled.12',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.openxmlformats-officedocument.presentationml.slide',
'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
'application/vnd.openxmlformats-officedocument.presentationml.template',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
];
}
return $driver;
}

Loading…
Cancel
Save