示例#1
0
 /**
  * Insert a new thread or a reply/quoted reply.
  */
 function insertPost()
 {
     $postInfo = array();
     $threadInfo = array();
     $threadOptions = array();
     $fp = new floodprotect();
     if (isset($_POST['newthread']) && trim($_POST['subject']) == '' || trim($_POST['post']) == '') {
         message_handler('ALERT', 5);
     } else {
         if ($fp->flood('forum_thread', 'thread_datestamp') == false && !ADMIN) {
             echo "<script type='text/javascript'>document.location.href='" . e_BASE . "index.php'</script>\n";
             exit;
         }
         $hasPoll = $this->action == 'nt' && varset($_POST['poll_title']) && $_POST['poll_option'][0] != '' && $_POST['poll_option'][1] != '';
         if (USER) {
             $postInfo['post_user'] = USERID;
             $threadInfo['thread_lastuser'] = USERID;
             $threadInfo['thread_user'] = USERID;
             $threadInfo['thread_lastuser_anon'] = '';
         } else {
             $postInfo['post_user_anon'] = $_POST['anonname'];
             $threadInfo['thread_lastuser_anon'] = $_POST['anonname'];
             $threadInfo['thread_user_anon'] = $_POST['anonname'];
         }
         $time = time();
         $postInfo['post_entry'] = $_POST['post'];
         $postInfo['post_forum'] = $this->data['forum_id'];
         $postInfo['post_datestamp'] = $time;
         $postInfo['post_ip'] = e107::getIPHandler()->getIP(FALSE);
         $threadInfo['thread_lastpost'] = $time;
         if (isset($_POST['no_emote'])) {
             $postInfo['post_options'] = serialize(array('no_emote' => 1));
         }
         //If we've successfully uploaded something, we'll have to edit the post_entry and post_attachments
         $newValues = array();
         if ($uploadResult = $this->processAttachments()) {
             foreach ($uploadResult as $ur) {
                 //$postInfo['post_entry'] .= $ur['txt'];
                 //	$_tmp = $ur['type'].'*'.$ur['file'];
                 //	if($ur['thumb']) { $_tmp .= '*'.$ur['thumb']; }
                 //	if($ur['fname']) { $_tmp .= '*'.$ur['fname']; }
                 $type = $ur['type'];
                 $newValues[$type][] = $ur['file'];
                 // $attachments[] = $_tmp;
             }
             //	$postInfo['_FIELD_TYPES']['post_attachments'] = 'array';
             $postInfo['post_attachments'] = e107::serialize($newValues);
             //FIXME XXX - broken encoding when saved to DB.
         }
         //		var_dump($uploadResult);
         switch ($this->action) {
             // Reply only.  Add the post, update thread record with latest post info.
             // Update forum with latest post info
             case 'rp':
                 $postInfo['post_thread'] = $this->id;
                 $newPostId = $this->forumObj->postAdd($postInfo);
                 break;
                 // New thread started.  Add the thread info (with lastest post info), add the post.
                 // Update forum with latest post info
             // New thread started.  Add the thread info (with lastest post info), add the post.
             // Update forum with latest post info
             case 'nt':
                 $threadInfo['thread_sticky'] = MODERATOR ? (int) $_POST['threadtype'] : 0;
                 $threadInfo['thread_name'] = $_POST['subject'];
                 $threadInfo['thread_forum_id'] = $this->id;
                 $threadInfo['thread_active'] = 1;
                 $threadInfo['thread_datestamp'] = $time;
                 if ($hasPoll) {
                     $threadOptions['poll'] = '1';
                 }
                 if (is_array($threadOptions) && count($threadOptions)) {
                     $threadInfo['thread_options'] = serialize($threadOptions);
                 } else {
                     $threadInfo['thread_options'] = '';
                 }
                 if ($postResult = $this->forumObj->threadAdd($threadInfo, $postInfo)) {
                     $newPostId = $postResult['postid'];
                     $newThreadId = $postResult['threadid'];
                     $this->data['thread_id'] = $newThreadId;
                     //	$this->data['thread_sef'] = $postResult['threadsef'];
                     $this->data['thread_sef'] = eHelper::title2sef($threadInfo['thread_name'], 'dashl');
                     if ($_POST['email_notify']) {
                         $this->forumObj->track('add', USERID, $newThreadId);
                     }
                 }
                 break;
         }
         e107::getMessage()->addDebug(print_a($postInfo, true));
         //	e107::getMessage()->addDebug(print_a($this,true));
         if ($postResult === -1 || $newPostId === -1) {
             require_once HEADERF;
             $message = LAN_FORUM_3006 . "<br ><a class='btn btn-default' href='" . $_SERVER['HTTP_REFERER'] . "'>Return</a>";
             $text = e107::getMessage()->addError($message)->render();
             e107::getRender()->tablerender(LAN_PLUGIN_FORUM_NAME, $text);
             // change to forum-title pref.
             require_once FOOTERF;
             exit;
         }
         $threadId = $this->action == 'nt' ? $newThreadId : $this->id;
         //If a poll was submitted, let's add it to the poll db
         if ($this->action == 'nt' && varset($_POST['poll_title']) && $_POST['poll_option'][0] != '' && $_POST['poll_option'][1] != '') {
             require_once e_PLUGIN . 'poll/poll_class.php';
             $_POST['iid'] = $threadId;
             $poll = new poll();
             $poll->submit_poll(2);
         }
         e107::getCache()->clear('newforumposts');
         //	$postInfo = $this->forumObj->postGet($newPostId, 'post');
         //	$forumInfo = $this->forumObj->forumGet($postInfo['post_forum']);
         //	$threadLink = e107::getUrl()->create('forum/thread/last', $postInfo);
         // 	$forumLink = e107::getUrl()->create('forum/forum/view', $forumInfo);
         $threadLink = e107::url('forum', 'topic', $this->data, 'full') . "&amp;last=1";
         $forumLink = e107::url('forum', 'forum', $this->data);
         if ($this->forumObj->prefs->get('redirect')) {
             $this->redirect($threadLink);
             //	header('location:'.e107::getUrl()->create('forum/thread/last', $postInfo, array('encode' => false, 'full' => true)));
             exit;
         } else {
             require_once HEADERF;
             $template = $this->getTemplate('posted');
             $SHORTCODES = array('THREADLINK' => $threadLink, 'FORUMLINK' => $forumLink);
             $txt = isset($_POST['newthread']) ? $template['thread'] : $template['reply'];
             $txt = e107::getParser()->parseTemplate($txt, true, $SHORTCODES);
             e107::getRender()->tablerender('Forums', e107::getMessage()->render() . $txt);
             require_once FOOTERF;
             exit;
         }
     }
 }
示例#2
0
$mes = e107::getMessage();
if (isset($_POST['reset'])) {
    unset($poll_id, $_POST['poll_title'], $_POST['poll_option'], $_POST['activate'], $_POST['multipleChoice'], $_POST['showResults'], $_POST['startday'], $_POST['startmonth'], $_POST['startyear'], $_POST['endday'], $_POST['endmonth'], $_POST['endyear']);
    define("RESET", TRUE);
}
if (varset($_POST['delete'])) {
    $poll->delete_poll(key($_POST['delete']));
    // TODO check security?
    $mes->addSuccess(LAN_DELETED);
    unset($poll_id, $_POST['poll_title'], $_POST['poll_option'], $_POST['activate']);
    $_GET['mode'] = 'list';
}
if (isset($_POST['submit'])) {
    if ($_POST['poll_title']) {
        define("POLLID", $_POST['poll_id']);
        $poll->submit_poll();
        $mes->addSuccess(LAN_CREATED);
        unset($_POST['poll_title'], $_POST['poll_option'], $_POST['activate'], $_POST['poll_comment']);
    } else {
        $mes->addError(LAN_REQUIRED_BLANK);
    }
    $_GET['mode'] = 'list';
}
if (isset($_POST['preview'])) {
    // Can't have everyone voting if tracking method is user ID
    if ($_POST['pollUserclass'] == e_UC_PUBLIC && $_POST['storageMethod'] == 2) {
        $_POST['pollUserclass'] = e_UC_MEMBER;
    }
    $poll->render_poll($_POST, "preview");
}
if (varset($_POST['edit']) || varset($_GET['mode']) == 'create' && !varset($_POST['submit'])) {
示例#3
0
$rs = new form();
$poll = new poll();
if (isset($_POST['reset'])) {
    unset($poll_id, $_POST['poll_title'], $_POST['poll_option'], $_POST['activate'], $_POST['multipleChoice'], $_POST['showResults'], $_POST['startday'], $_POST['startmonth'], $_POST['startyear'], $_POST['endday'], $_POST['endmonth'], $_POST['endyear']);
    define("RESET", TRUE);
}
$emessage = eMessage::getInstance();
if (varset($_POST['delete'])) {
    $message = $poll->delete_poll(key($_POST['delete']));
    unset($poll_id, $_POST['poll_title'], $_POST['poll_option'], $_POST['activate']);
    $_GET['mode'] = 'list';
}
if (isset($_POST['submit'])) {
    if ($_POST['poll_title']) {
        define("POLLID", $_POST['poll_id']);
        $emessage->add($poll->submit_poll(), E_MESSAGE_SUCCESS);
        unset($_POST['poll_title'], $_POST['poll_option'], $_POST['activate'], $_POST['poll_comment']);
    } else {
        $emessage->add(POLLAN_46, E_MESSAGE_SUCCESS);
    }
    $_GET['mode'] = 'list';
}
if (isset($_POST['preview'])) {
    // Can't have everyone voting if tracking method is user ID
    if ($_POST['pollUserclass'] == e_UC_PUBLIC && $_POST['storageMethod'] == 2) {
        $_POST['pollUserclass'] = e_UC_MEMBER;
    }
    $poll->render_poll($_POST, "preview");
}
if (varset($_POST['edit']) || varset($_GET['mode']) == 'create' && !varset($_POST['submit'])) {
    $_GET['mode'] = 'create';
示例#4
0
 //		print_a($threadInfo);
 //		print_a($postInfo);
 //		exit;
 if ($postResult === -1) {
     require_once HEADERF;
     $ns->tablerender('', LAN_FORUM_2);
     require_once FOOTERF;
     exit;
 }
 $threadId = $action == 'nt' ? $newThreadId : $id;
 //If a poll was submitted, let's add it to the poll db
 if ($action == 'nt' && varset($_POST['poll_title']) && $_POST['poll_option'][0] != '' && $_POST['poll_option'][1] != '') {
     require_once e_PLUGIN . 'poll/poll_class.php';
     $_POST['iid'] = $threadId;
     $poll = new poll();
     $poll->submit_poll(2);
 }
 $e107cache->clear('newforumposts');
 $postInfo = $forum->postGet($newPostId, 'post');
 $forumInfo = $forum->forumGet($postInfo['post_forum']);
 $threadLink = $e107->url->create('forum/thread/last', $postInfo);
 $forumLink = $e107->url->create('forum/forum/view', $forumInfo);
 if ($forum->prefs->get('redirect')) {
     header('location:' . $e107->url->create('forum/thread/last', $postInfo, array('encode' => false, 'full' => true)));
     exit;
 } else {
     require_once HEADERF;
     if (!$FORUMPOST) {
         if (file_exists(THEME . "forum_posted_template.php")) {
             require_once THEME . "forum_posted_template.php";
         } else {