diff --git a/main/blog/blog.php b/main/blog/blog.php index 47332afaf4..a2b0a4a593 100644 --- a/main/blog/blog.php +++ b/main/blog/blog.php @@ -20,7 +20,6 @@ $this_section=SECTION_COURSES; // notice for unauthorized people. api_protect_course_script(true); - //session if(isset($_GET['id_session'])) { $_SESSION['id_session'] = intval($_GET['id_session']); @@ -43,16 +42,15 @@ $current_page = $_GET['action']; PROCESSING */ -$safe_post_title = Security::remove_XSS($_POST['post_title']); -$safe_post_file_comment = Security::remove_XSS($_POST['post_file_comment']); -$safe_post_full_text = Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['post_full_text'])), COURSEMANAGERLOWSECURITY); -$safe_comment_text = Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['comment_text'])), COURSEMANAGERLOWSECURITY); -$safe_comment_title = Security::remove_XSS($_POST['comment_title']); -$safe_task_name = Security::remove_XSS($_POST['task_name']); -$safe_task_description = Security::remove_XSS($_POST['task_description']); +$safe_post_title = Security::remove_XSS($_POST['post_title']); +$safe_post_file_comment = Security::remove_XSS($_POST['post_file_comment']); +$safe_post_full_text = Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['post_full_text'])), COURSEMANAGERLOWSECURITY); +$safe_comment_text = Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['comment_text'])), COURSEMANAGERLOWSECURITY); +$safe_comment_title = Security::remove_XSS($_POST['comment_title']); +$safe_task_name = Security::remove_XSS($_POST['task_name']); +$safe_task_description = Security::remove_XSS($_POST['task_description']); -if (!empty($_POST['new_post_submit']) AND !empty($_POST['post_title'])) -{ +if (!empty($_POST['new_post_submit']) AND !empty($_POST['post_title'])) { Blog :: create_post($safe_post_title, $safe_post_full_text, $safe_post_file_comment,$blog_id); $return_message = array('type' => 'confirmation', 'message' => get_lang('BlogAdded')); } @@ -352,6 +350,8 @@ if ($flag == '1') $user_task = false; +$course_id = api_get_course_int_id(); + if (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) { $task_id = (int)$_GET['task_id']; } else { @@ -361,6 +361,7 @@ if (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) { $sql = "SELECT COUNT(*) as number FROM ".$tbl_blogs_tasks_rel_user." WHERE + c_id = $course_id AND blog_id = ".$blog_id." AND user_id = ".api_get_user_id()." AND task_id = ".$task_id; diff --git a/main/forum/iframe_thread.php b/main/forum/iframe_thread.php old mode 100755 new mode 100644 index 215b6d981b..82b9168033 --- a/main/forum/iframe_thread.php +++ b/main/forum/iframe_thread.php @@ -85,6 +85,8 @@ if (!api_is_allowed_to_edit(false, true) AND ($current_forum['visibility'] == 0 } } +$course_id = api_get_course_int_id(); + /* Display Forum Category and the Forum information */ // We are getting all the information about the current forum and forum category. @@ -92,7 +94,9 @@ if (!api_is_allowed_to_edit(false, true) AND ($current_forum['visibility'] == 0 // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table. $sql = "SELECT * FROM $table_posts posts, $table_users users - WHERE posts.thread_id='".$current_thread['thread_id']."' + WHERE + posts.c_id = $course_id AND + posts.thread_id='".$current_thread['thread_id']."' AND posts.poster_id=users.user_id ORDER BY posts.post_id ASC"; $result = Database::query($sql); diff --git a/main/forum/viewforum.php b/main/forum/viewforum.php index 3df1df97f9..293964e094 100644 --- a/main/forum/viewforum.php +++ b/main/forum/viewforum.php @@ -326,6 +326,8 @@ $threads = get_threads($my_forum); // Note: This has to be cleaned first. $whatsnew_post_info = isset($_SESSION['whatsnew_post_info']) ? $_SESSION['whatsnew_post_info'] : null; +$course_id = api_get_course_int_id(); + $counter = 0; if (is_array($threads)) { foreach ($threads as $row) { @@ -393,7 +395,7 @@ if (is_array($threads)) { $attachment_list = get_attachment($row['post_id']); $id_attach = !empty($attachment_list) ? $attachment_list['id'] : ''; - $sql_post_id = "SELECT post_id FROM $table_posts WHERE post_title='".Database::escape_string($row['thread_title'])."'"; + $sql_post_id = "SELECT post_id FROM $table_posts WHERE c_id = $course_id AND post_title='".Database::escape_string($row['thread_title'])."'"; $result_post_id = Database::query($sql_post_id); $row_post_id = Database::fetch_array($result_post_id); diff --git a/main/inc/ajax/lp.ajax.php b/main/inc/ajax/lp.ajax.php index 7862705e06..dbf105114e 100644 --- a/main/inc/ajax/lp.ajax.php +++ b/main/inc/ajax/lp.ajax.php @@ -8,6 +8,8 @@ require_once '../global.inc.php'; api_protect_course_script(true); $action = $_REQUEST['a']; +$course_id = api_get_course_int_id(); + switch ($action) { case 'update_lp_item_order': if (api_is_allowed_to_edit(null, true)) { @@ -34,7 +36,7 @@ switch ($action) { $params['previous_item_id'] = isset($new_array[$i-1]) && isset($new_array[$i-1]['id']) ? $new_array[$i-1]['id'] : 0; $params['next_item_id'] = isset($new_array[$i+1]) && isset($new_array[$i+1]['id']) ? $new_array[$i+1]['id'] : 0; $params['parent_item_id'] = $parent_id; - Database::update($tbl_lp_item, $params, array('id = ? '=>intval($id))); + Database::update($tbl_lp_item, $params, array('id = ? AND c_id = ? '=> array(intval($id), $course_id))); $counter ++; } Display::display_confirmation_message(get_lang('Saved')); diff --git a/main/inc/lib/blog.lib.php b/main/inc/lib/blog.lib.php index a5298c2372..ccf924e03c 100644 --- a/main/inc/lib/blog.lib.php +++ b/main/inc/lib/blog.lib.php @@ -25,13 +25,15 @@ class Blog { * @return String Blog Title */ public static function get_blog_title ($blog_id) { + $course_id = api_get_course_int_id(); + if(is_numeric($blog_id)) { // init $tbl_blogs = Database::get_course_table(TABLE_BLOGS); $sql = "SELECT blog_name FROM " . $tbl_blogs . " - WHERE blog_id = " . intval($blog_id); + WHERE c_id = $course_id AND blog_id = " . intval($blog_id); $result = Database::query($sql); $blog = Database::fetch_array($result); @@ -51,7 +53,8 @@ class Blog { public static function get_blog_subtitle ($blog_id) { // init $tbl_blogs = Database::get_course_table(TABLE_BLOGS); - $sql = "SELECT blog_subtitle FROM $tbl_blogs WHERE blog_id ='".intval($blog_id)."'"; + $course_id = api_get_course_int_id(); + $sql = "SELECT blog_subtitle FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".intval($blog_id)."'"; $result = Database::query($sql); $blog = Database::fetch_array($result); return stripslashes($blog['blog_subtitle']); @@ -237,12 +240,12 @@ class Blog { if(!empty($_FILES['user_upload']['name'])) { - require_once('fileUpload.lib.php'); - $upload_ok = process_uploaded_file($_FILES['user_upload']); + require_once 'fileUpload.lib.php'; + $upload_ok = process_uploaded_file($_FILES['user_upload']); $has_attachment=true; } - if($upload_ok) { + if ($upload_ok) { // Table Definitions $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); @@ -264,12 +267,9 @@ class Blog { // user's file name $file_name =$_FILES['user_upload']['name']; - if (!filter_extension($new_file_name)) - { + if (!filter_extension($new_file_name)) { Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); - } - else - { + } else { $new_file_name = uniqid(''); $new_path=$updir.'/'.$new_file_name; $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); @@ -280,8 +280,7 @@ class Blog { $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. "VALUES ($course_id, '".Database::escape_string($file_name)."', '".Database::escape_string($comment)."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; $result=Database::query($sql); - $message.=' / '.get_lang('AttachmentUpload'); - exit; + $message.=' / '.get_lang('AttachmentUpload'); } } } @@ -1335,8 +1334,9 @@ class Blog { */ public static function display_task_list ($blog_id) { global $charset; - if(api_is_allowed('BLOG_' . $blog_id, 'article_add')) - { + $course_id = api_get_course_int_id(); + + if(api_is_allowed('BLOG_' . $blog_id, 'article_add')) { // Init $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); $counter = 0; @@ -1360,8 +1360,7 @@ class Blog { "\n"; - $sql = " - SELECT + $sql = " SELECT blog_id, task_id, blog_id, @@ -1370,10 +1369,8 @@ class Blog { color, system_task FROM " . $tbl_blogs_tasks . " - WHERE blog_id = " . (int)$blog_id . " - ORDER BY - system_task, - title"; + WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " + ORDER BY system_task, title"; $result = Database::query($sql); @@ -1665,8 +1662,7 @@ class Blog { $year = date("Y"); global $MonthsLong; - $course_id = api_get_course_int_id(); - + $course_id = api_get_course_int_id(); // Get users in this blog / make select list of it $sql = "SELECT user.user_id, user.firstname, user.lastname FROM $tbl_users user @@ -1693,10 +1689,8 @@ class Blog { color, system_task FROM " . $tbl_blogs_tasks . " - WHERE blog_id = " . (int)$blog_id . " - ORDER BY - system_task, - title"; + WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " + ORDER BY system_task, title"; $result = Database::query($sql); $select_task_list = '