} elseif (strlen($title) > 60) {
                $ERRORS[] = 'There is a maxlength=60 on that field for a reason.';
            }
            if ($text == null) {
                $ERRORS[] = 'No message specified. It is possible that your HTML was so badly mal-formed that it was dropped by the HTML filter.';
            }
            if (strtotime($User->getDatetimeLastPost()) + $APP_CONFIG['post_interval'] > time()) {
                $text = secondsToMinutes($APP_CONFIG['post_interval']);
                $ERRORS[] = "You may only post once every {$text}.";
            }
            // end user posted too quickly
            if (sizeof($ERRORS) > 0) {
                draw_errors($ERRORS);
                $POST = array('board_id' => stripinput($_REQUEST['board_id']), 'title' => $title, 'message' => $text);
                $renderer->assign('post', $POST);
                $renderer->display('boards/new_thread_error.tpl');
            } else {
                $thread = new BoardThread($db);
                $thread->create(array('board_id' => $board->getBoardId(), 'thread_name' => $title, 'user_id' => $User->getUserId(), 'thread_created_datetime' => $thread->sysdate(), 'thread_last_posted_datetime' => $thread->sysdate(), 'stickied' => 1, 'locked' => 'N'));
                $post = new BoardPost($db);
                $post->create(array('board_thread_id' => $thread->getBoardThreadId(), 'user_id' => $User->getUserId(), 'posted_datetime' => $post->sysdate(), 'post_text' => $text));
                $_SESSION['board_notice'] = 'Your thread has been created.';
                redirect(null, null, "threads/{$board->getBoardId()}");
            }
            // end create thread
            break;
            // end post
    }
    // end switch
}
// end no issues with the board
Esempio n. 2
0
                    $image = new BoardImage($db);
                    try {
                        $image->create($_FILES['image']);
                        $image_id = $image->getBoardThreadPostImageId();
                    } catch (UploadError $e) {
                        $ERRORS[] = "{$e->getMessage()} (code {$e->getCode()})";
                    }
                }
                // process image
            }
            // end do not process image if errors in post
            if (sizeof($ERRORS) > 0) {
                draw_errors($ERRORS);
                $POST = array('board_id' => stripinput($_REQUEST['board_id']), 'title' => $title, 'message' => $text);
                $renderer->assign('post', $POST);
                $renderer->display('boards/new_thread_error.tpl');
            } else {
                $thread = new BoardThread($db);
                $thread->create(array('board_id' => $board->getBoardId(), 'thread_name' => $title, 'user_id' => $User->getUserId(), 'thread_created_datetime' => $thread->sysdate(), 'thread_last_posted_datetime' => $thread->sysdate(), 'stickied' => 1, 'locked' => 'N', 'poster_type' => $identity));
                $post = new BoardPost($db);
                $post->create(array('board_thread_id' => $thread->getBoardThreadId(), 'user_id' => $User->getUserId(), 'posted_datetime' => $post->sysdate(), 'post_text' => $text, 'poster_type' => $identity, 'board_thread_post_image_id' => $image_id));
                $_SESSION['board_notice'] = 'Your thread has been created.';
                redirect(null, null, "board/{$board->getBoardShortName()}");
            }
            // end create thread
            break;
            // end post
    }
    // end switch
}
// end no issues with the board