Skip to content

Commit

Permalink
Forum: Do not trust userid from hidden form field, use $USER->id inst…
Browse files Browse the repository at this point in the history
…ead for db inserts
  • Loading branch information
mjollnir_ committed Nov 23, 2004
1 parent b442f81 commit 1a0c7e4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mod/forum/lib.php
Expand Up @@ -2028,8 +2028,11 @@ function forum_add_attachment($post, $newfile) {


function forum_add_new_post($post) { function forum_add_new_post($post) {


global $USER;

$post->created = $post->modified = time(); $post->created = $post->modified = time();
$post->mailed = "0"; $post->mailed = "0";
$post->userid = $USER->id;


$newfile = $post->attachment; $newfile = $post->attachment;
$post->attachment = ""; $post->attachment = "";
Expand All @@ -2051,7 +2054,10 @@ function forum_add_new_post($post) {


function forum_update_post($post) { function forum_update_post($post) {


global $USER;

$post->modified = time(); $post->modified = time();
$post->userid = $USER->id;


if (!$post->parent) { // Post is a discussion starter - update discussion title too if (!$post->parent) { // Post is a discussion starter - update discussion title too
set_field("forum_discussions", "name", $post->subject, "id", $post->discussion); set_field("forum_discussions", "name", $post->subject, "id", $post->discussion);
Expand Down Expand Up @@ -2108,6 +2114,7 @@ function forum_add_discussion($discussion) {
$discussion->firstpost = $post->id; $discussion->firstpost = $post->id;
$discussion->timemodified = $timenow; $discussion->timemodified = $timenow;
$discussion->usermodified = $post->userid; $discussion->usermodified = $post->userid;
$discussion->userid = $USER->id;


if (! $discussion->id = insert_record("forum_discussions", $discussion) ) { if (! $discussion->id = insert_record("forum_discussions", $discussion) ) {
delete_records("forum_posts", "id", $post->id); delete_records("forum_posts", "id", $post->id);
Expand Down

0 comments on commit 1a0c7e4

Please sign in to comment.