Ver código fonte

Fixing token bug

Julio Montoya 12 anos atrás
pai
commit
7d760729ee

+ 9 - 4
main/announcements/announcements.php

@@ -28,6 +28,12 @@ $use_anonymous = true;
 
 // setting the global file that gets the general configuration, the databases, the languages, ...
 require_once '../inc/global.inc.php';
+
+/* 	Sessions */
+
+$ctok = Security::getCurrentToken();
+$stok = Security::get_token();
+
 $current_course_tool = TOOL_ANNOUNCEMENT;
 $this_section = SECTION_COURSES;
 $nameTools = get_lang('ToolAnnouncement');
@@ -127,10 +133,8 @@ if (!empty($group_id)) {
     $_SESSION['select_groupusers'] = 'hide';
 }
 
-/* 	Sessions */
 
-$ctok = Security::getCurrentToken();
-$stok = Security::get_token();
+
 $to = null;
 $email_ann = null;
 
@@ -351,6 +355,7 @@ if (AnnouncementManager::user_can_edit_announcement()) {
         $error_message = get_lang('TitleIsRequired');
         $content_to_modify = $newContent;
     } else {
+
         if ($submitAnnouncement) {
             $selected_form = isset($_POST['selectedform']) ? $_POST['selectedform'] : null;
 
@@ -376,7 +381,7 @@ if (AnnouncementManager::user_can_edit_announcement()) {
                 }
             } else {
                 //insert mode
-                if ($ctok == $_POST['sec_token']) {
+                if ($ctok == $_REQUEST['sec_token']) {
                     $file = $_FILES['user_upload'];
                     $file_comment = $_POST['file_comment'];
 

+ 1 - 1
main/inc/lib/announcements.inc.php

@@ -137,6 +137,7 @@ class AnnouncementManager
      */
     public static function display_announcement($announcement_id)
     {
+        global $stok;
         if ($announcement_id != strval(intval($announcement_id))) {
             return false;
         }
@@ -216,7 +217,6 @@ class AnnouncementManager
                     $image_visibility = "invisible";
                     $alt_visibility = get_lang('Visible');
                 }
-                global $stok;
 
                 $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq(
                 )."&origin=".(!empty($_GET['origin']) ? Security::remove_XSS(