Beispiel #1
0
 public function get_query_str()
 {
     global $lang_admin_maintenance;
     $query_str = '';
     $per_page = $this->request->get('i_per_page') ? intval($this->request->get('i_per_page')) : 0;
     $start_at = $this->request->get('i_start_at') ? intval($this->request->get('i_start_at')) : 0;
     require FEATHER_ROOT . 'include/search_idx.php';
     // Fetch posts to process this cycle
     $select_get_query_str = array('p.id', 'p.message', 't.subject', 't.first_post_id');
     $result = DB::for_table('posts')->table_alias('p')->select_many($select_get_query_str)->inner_join('topics', array('t.id', '=', 'p.topic_id'), 't')->where_gte('p.id', $start_at)->order_by_asc('p.id')->limit($per_page)->find_many();
     $end_at = 0;
     foreach ($result as $cur_item) {
         echo '<p><span>' . sprintf($lang_admin_maintenance['Processing post'], $cur_item['id']) . '</span></p>' . "\n";
         if ($cur_item['id'] == $cur_item['first_post_id']) {
             update_search_index('post', $cur_item['id'], $cur_item['message'], $cur_item['subject']);
         } else {
             update_search_index('post', $cur_item['id'], $cur_item['message']);
         }
         $end_at = $cur_item['id'];
     }
     // Check if there is more work to do
     if ($end_at > 0) {
         $id = DB::for_table('posts')->where_gt('id', $end_at)->order_by_asc('id')->find_one_col('id');
         if ($id) {
             $query_str = '?action=rebuild&i_per_page=' . $per_page . '&i_start_at=' . intval($id);
         }
     }
     $pdo = DB::get_db();
     $pdo = null;
     return $query_str;
 }
function add_post($post_info, &$new_pid)
{
    global $forum_db, $db_type, $forum_config, $lang_common;
    $return = ($hook = get_hook('fn_add_post_start')) ? eval($hook) : null;
    if ($return != null) {
        return;
    }
    // Add the post
    $query = array('INSERT' => 'poster, poster_id, poster_ip, message, hide_smilies, posted, topic_id', 'INTO' => 'posts', 'VALUES' => '\'' . $forum_db->escape($post_info['poster']) . '\', ' . $post_info['poster_id'] . ', \'' . $forum_db->escape(get_remote_address()) . '\', \'' . $forum_db->escape($post_info['message']) . '\', ' . $post_info['hide_smilies'] . ', ' . $post_info['posted'] . ', ' . $post_info['topic_id']);
    // If it's a guest post, there might be an e-mail address we need to include
    if ($post_info['is_guest'] && $post_info['poster_email'] != null) {
        $query['INSERT'] .= ', poster_email';
        $query['VALUES'] .= ', \'' . $forum_db->escape($post_info['poster_email']) . '\'';
    }
    ($hook = get_hook('fn_add_post_qr_add_post')) ? eval($hook) : null;
    $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $new_pid = $forum_db->insert_id();
    if (!$post_info['is_guest']) {
        // Subscribe or unsubscribe?
        if ($post_info['subscr_action'] == 1) {
            $query = array('INSERT' => 'user_id, topic_id', 'INTO' => 'subscriptions', 'VALUES' => $post_info['poster_id'] . ' ,' . $post_info['topic_id']);
            ($hook = get_hook('fn_add_post_qr_add_subscription')) ? eval($hook) : null;
            $forum_db->query_build($query) or error(__FILE__, __LINE__);
        } else {
            if ($post_info['subscr_action'] == 2) {
                $query = array('DELETE' => 'subscriptions', 'WHERE' => 'topic_id=' . $post_info['topic_id'] . ' AND user_id=' . $post_info['poster_id']);
                ($hook = get_hook('fn_add_post_qr_delete_subscription')) ? eval($hook) : null;
                $forum_db->query_build($query) or error(__FILE__, __LINE__);
            }
        }
    }
    // Count number of replies in the topic
    $query = array('SELECT' => 'COUNT(p.id)', 'FROM' => 'posts AS p', 'WHERE' => 'p.topic_id=' . $post_info['topic_id']);
    ($hook = get_hook('fn_add_post_qr_get_topic_reply_count')) ? eval($hook) : null;
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $num_replies = $forum_db->result($result, 0) - 1;
    // Update topic
    $query = array('UPDATE' => 'topics', 'SET' => 'num_replies=' . $num_replies . ', last_post=' . $post_info['posted'] . ', last_post_id=' . $new_pid . ', last_poster=\'' . $forum_db->escape($post_info['poster']) . '\'', 'WHERE' => 'id=' . $post_info['topic_id']);
    ($hook = get_hook('fn_add_post_qr_update_topic')) ? eval($hook) : null;
    $forum_db->query_build($query) or error(__FILE__, __LINE__);
    sync_forum($post_info['forum_id']);
    if (!defined('FORUM_SEARCH_IDX_FUNCTIONS_LOADED')) {
        require FORUM_ROOT . 'include/search_idx.php';
    }
    update_search_index('post', $new_pid, $post_info['message']);
    send_subscriptions($post_info, $new_pid);
    // Increment user's post count & last post time
    if (isset($post_info['update_user'])) {
        if ($post_info['is_guest']) {
            $query = array('UPDATE' => 'online', 'SET' => 'last_post=' . $post_info['posted'], 'WHERE' => 'ident=\'' . $forum_db->escape(get_remote_address()) . '\'');
        } else {
            $query = array('UPDATE' => 'users', 'SET' => 'num_posts=num_posts+1, last_post=' . $post_info['posted'], 'WHERE' => 'id=' . $post_info['poster_id']);
        }
        ($hook = get_hook('fn_add_post_qr_update_last_post')) ? eval($hook) : null;
        $forum_db->query_build($query) or error(__FILE__, __LINE__);
    }
    // If the posting user is logged in update his/her unread indicator
    if (!$post_info['is_guest'] && isset($post_info['update_unread']) && $post_info['update_unread']) {
        $tracked_topics = get_tracked_topics();
        $tracked_topics['topics'][$post_info['topic_id']] = time();
        set_tracked_topics($tracked_topics);
    }
    ($hook = get_hook('fn_add_post_end')) ? eval($hook) : null;
}
Beispiel #3
0
 if (!$luna_user['is_guest']) {
     // To subscribe or not to subscribe, that ...
     if ($luna_config['o_thread_subscriptions'] == '1' && $subscribe) {
         $db->query('INSERT INTO ' . $db->prefix . 'thread_subscriptions (user_id, thread_id) VALUES(' . $luna_user['id'] . ' ,' . $new_tid . ')') or error('Unable to add subscription', __FILE__, __LINE__, $db->error());
     }
     // Create the comment ("thread comment")
     $db->query('INSERT INTO ' . $db->prefix . 'comments (commenter, commenter_id, commenter_ip, message, hide_smilies, commented, thread_id) VALUES(\'' . $db->escape($username) . '\', ' . $luna_user['id'] . ', \'' . $db->escape(get_remote_address()) . '\', \'' . $db->escape($message) . '\', ' . $hide_smilies . ', ' . $now . ', ' . $new_tid . ')') or error('Unable to create comment', __FILE__, __LINE__, $db->error());
 } else {
     // Create the comment ("thread comment")
     $email_sql = $luna_config['p_force_guest_email'] == '1' || $email != '' ? '\'' . $db->escape($email) . '\'' : 'NULL';
     $db->query('INSERT INTO ' . $db->prefix . 'comments (commenter, commenter_ip, commenter_email, message, hide_smilies, commented, thread_id) VALUES(\'' . $db->escape($username) . '\', \'' . $db->escape(get_remote_address()) . '\', ' . $email_sql . ', \'' . $db->escape($message) . '\', ' . $hide_smilies . ', ' . $now . ', ' . $new_tid . ')') or error('Unable to create comment', __FILE__, __LINE__, $db->error());
 }
 $new_pid = $db->insert_id();
 // Update the thread with last_comment_id
 $db->query('UPDATE ' . $db->prefix . 'threads SET last_comment_id=' . $new_pid . ', first_comment_id=' . $new_pid . ' WHERE id=' . $new_tid) or error('Unable to update thread', __FILE__, __LINE__, $db->error());
 update_search_index('comment', $new_pid, $message, $subject);
 update_forum($fid);
 // Should we send out notifications?
 if ($luna_config['o_forum_subscriptions'] == '1') {
     // Get any subscribed users that should be notified (banned users are excluded)
     $result = $db->query('SELECT u.id, u.email, u.notify_with_comment, u.language FROM ' . $db->prefix . 'users AS u INNER JOIN ' . $db->prefix . 'forum_subscriptions AS s ON u.id=s.user_id LEFT JOIN ' . $db->prefix . 'forum_perms AS fp ON (fp.forum_id=' . $cur_commenting['fid'] . ' AND fp.group_id=u.group_id) LEFT JOIN ' . $db->prefix . 'bans AS b ON u.username=b.username WHERE b.username IS NULL AND (fp.read_forum IS NULL OR fp.read_forum=1) AND s.forum_id=' . $cur_commenting['fid'] . ' AND u.id!=' . $luna_user['id']) or error('Unable to fetch subscription info', __FILE__, __LINE__, $db->error());
     if ($db->num_rows($result)) {
         require_once LUNA_ROOT . 'include/email.php';
         $notification_emails = array();
         if ($luna_config['o_censoring'] == '1') {
             $cleaned_message = bbcode2email($censored_message, -1);
         } else {
             $cleaned_message = bbcode2email($message, -1);
         }
         // Loop through subscribed users and send emails
         while ($cur_subscriber = $db->fetch_assoc($result)) {
Beispiel #4
0
                 break;
             case 'pgsql':
                 $db->query('SELECT setval(\'' . $db->prefix . 'search_words_id_seq\', 1, false)') or error('Unable to update sequence', __FILE__, __LINE__, $db->error());
                 break;
         }
     }
     require LUNA_ROOT . 'include/search_idx.php';
     // Fetch comments to process this cycle
     $result = $db->query('SELECT p.id, p.message, t.subject, t.first_comment_id FROM ' . $db->prefix . 'comments AS p INNER JOIN ' . $db->prefix . 'threads AS t ON t.id=p.thread_id WHERE p.id > ' . $start_at . ' ORDER BY p.id ASC LIMIT ' . PER_PAGE) or error('Unable to fetch comments', __FILE__, __LINE__, $db->error());
     $end_at = 0;
     while ($cur_item = $db->fetch_assoc($result)) {
         echo sprintf(__('Rebuilding index for %1$s %2$s', 'luna'), __('comment', 'luna'), $cur_item['id']) . '<br />' . "\n";
         if ($cur_item['id'] == $cur_item['first_comment_id']) {
             update_search_index('comment', $cur_item['id'], $cur_item['message'], $cur_item['subject']);
         } else {
             update_search_index('comment', $cur_item['id'], $cur_item['message']);
         }
         $end_at = $cur_item['id'];
     }
     // Check if there is more work to do
     if ($end_at > 0) {
         $result = $db->query('SELECT 1 FROM ' . $db->prefix . 'comments WHERE id > ' . $end_at . ' ORDER BY id ASC LIMIT 1') or error('Unable to fetch next ID', __FILE__, __LINE__, $db->error());
         if ($db->num_rows($result) > 0) {
             $query_str = '?stage=rebuild_idx&start_at=' . $end_at;
         }
     }
     break;
     // Show results page
 // Show results page
 case 'finish':
     // Give a "Success" notifcation
Beispiel #5
0
                        if ($db->num_rows($tagged_res)) {
                            $tagged_id = $db->fetch_assoc($tagged_res);
                            if ($tagged_id['block_notif'] == 0) {
                                $db->query('INSERT INTO `#^notifications` (type, user, send_time, contents, arguments)
							VALUES (\'notification\', ' . intval($tagged_id['id']) . ', ' . time() . ', ' . $pid . ', \'' . $futurebb_user['username'] . ',' . $db->escape($cur_topic['subject']) . '\')');
                            }
                        }
                    }
                }
            }
            // Continue posting
            $db->query('UPDATE `#^topics` SET last_post=' . time() . ',last_post_id=' . $pid . ',num_replies=num_replies+1 WHERE id=' . $tid) or error('Failed to update topic info', __FILE__, __LINE__, $db->error());
            $db->query('UPDATE `#^forums` SET last_post=' . time() . ',last_post_id=' . $pid . ($cur_topic['deleted'] ? '' : ',num_posts=num_posts+1') . ' WHERE id=' . $cur_topic['f_id']) or error('Failed to forum last post', __FILE__, __LINE__, $db->error());
            $db->query('DELETE FROM `#^read_tracker` WHERE (forum_id=' . $cur_topic['f_id'] . ' OR topic_id=' . $tid . ') AND user_id<>' . $futurebb_user['id']) or error('Failed to update read tracker', __FILE__, __LINE__, $db->error());
            $db->query('UPDATE `#^users` SET num_posts=num_posts+1 WHERE id=' . $futurebb_user['id']) or error('Failed to update number of posts', __FILE__, __LINE__, $db->error());
            update_search_index($pid, $_POST['message']);
            ExtensionConfig::run_hooks('new_post', array('id' => $pid, 'topic' => $cur_topic['subject'], 'topic_url' => $cur_topic['url'], 'poster' => $futurebb_user['username'], 'message' => $_POST['message'], 'forum_url' => $cur_topic['forum_url'], 'forum' => $cur_topic['forum_name']));
            redirect($base_config['baseurl'] . '/posts/' . $pid);
            return;
        } else {
            if (isset($_POST['preview']) && empty($errors)) {
                echo '<div class="quotebox preview">' . BBCodeController::parse_msg($_POST['message'], !isset($_POST['hidesmilies']), true, $futurebb_config['enable_bbcode']) . '</div>';
            }
        }
    }
}
if (isset($errors) && !empty($errors)) {
    echo '<p>' . translate('errordesc') . '<ul>';
    foreach ($errors as $val) {
        echo '<li>' . $val . '</li>';
    }
                 break;
             case 'pgsql':
                 $db->query('SELECT setval(\'' . $db->prefix . 'search_words_id_seq\', 1, false)') or error('Unable to update sequence', __FILE__, __LINE__, $db->error());
                 break;
         }
     }
     require PUN_ROOT . 'include/search_idx.php';
     // Fetch posts to process this cycle
     $result = $db->query('SELECT p.id, p.message, t.subject, t.first_post_id FROM ' . $db->prefix . 'posts AS p INNER JOIN ' . $db->prefix . 'topics AS t ON t.id=p.topic_id WHERE p.id > ' . $start_at . ' ORDER BY p.id ASC LIMIT ' . PER_PAGE) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
     $end_at = 0;
     while ($cur_item = $db->fetch_assoc($result)) {
         echo sprintf($lang_update['Rebuilding index item'], $lang_update['post'], $cur_item['id']) . '<br />' . "\n";
         if ($cur_item['id'] == $cur_item['first_post_id']) {
             update_search_index('post', $cur_item['id'], $cur_item['message'], $cur_item['subject']);
         } else {
             update_search_index('post', $cur_item['id'], $cur_item['message']);
         }
         $end_at = $cur_item['id'];
     }
     // Check if there is more work to do
     if ($end_at > 0) {
         $result = $db->query('SELECT 1 FROM ' . $db->prefix . 'posts WHERE id > ' . $end_at . ' ORDER BY id ASC LIMIT 1') or error('Unable to fetch next ID', __FILE__, __LINE__, $db->error());
         if ($db->num_rows($result) > 0) {
             $query_str = '?stage=rebuild_idx&start_at=' . $end_at;
         }
     }
     break;
     // Show results page
 // Show results page
 case 'finish':
     // We update the version number
    // Fetch posts to process
    $result = $db->query('SELECT DISTINCT t.id, p.id, p.message FROM ' . $db->prefix . 'topics AS t INNER JOIN ' . $db->prefix . 'posts AS p ON t.id=p.topic_id WHERE t.id>=' . $start_at . ' AND t.id<' . $end_at . ' ORDER BY t.id') or error('Unable to fetch topic/post info', __FILE__, __LINE__, $db->error());
    $cur_topic = 0;
    while ($cur_post = $db->fetch_row($result)) {
        if ($cur_post[0] != $cur_topic) {
            // Fetch subject and ID of first post in topic
            $result2 = $db->query('SELECT p.id, t.subject, MIN(p.posted) AS first FROM ' . $db->prefix . 'posts AS p INNER JOIN ' . $db->prefix . 'topics AS t ON t.id=p.topic_id WHERE t.id=' . $cur_post[0] . ' GROUP BY p.id, t.subject ORDER BY first LIMIT 1') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
            list($first_post, $subject) = $db->fetch_row($result2);
            $cur_topic = $cur_post[0];
        }
        echo 'Processing post <strong>' . $cur_post[1] . '</strong> in topic <strong>' . $cur_post[0] . '</strong><br />' . "\n";
        if ($cur_post[1] == $first_post) {
            // This is the "topic post" so we have to index the subject as well
            update_search_index('post', $cur_post[1], $cur_post[2], $subject);
        } else {
            update_search_index('post', $cur_post[1], $cur_post[2]);
        }
    }
    // Check if there is more work to do
    $result = $db->query('SELECT id FROM ' . $db->prefix . 'topics WHERE id>' . $end_at) or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
    $query_str = $db->num_rows($result) ? '?i_per_page=' . $per_page . '&i_start_at=' . $end_at : '';
    $db->end_transaction();
    $db->close();
    exit('<script type="text/javascript">window.location="admin_maintenance.php' . $query_str . '"</script><br />JavaScript redirect unsuccessful. Click <a href="admin_maintenance.php' . $query_str . '">here</a> to continue.');
}
// Get the first post ID from the db
$result = $db->query('SELECT id FROM ' . $db->prefix . 'topics ORDER BY id LIMIT 1') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result)) {
    $first_id = $db->result($result);
}
$page_title = pun_htmlspecialchars($pun_config['o_board_title']) . ' / Admin / Maintenance';
Beispiel #8
0
                message($lang_admin_deleted['topic has been deleted']);
            }
            $update = array('deleted' => 0);
            $post_data = array(':id' => $post_id);
            $db->update('posts', $update, 'id=:id', $post_data);
            if (!defined('PANTHER_CJK_HANGUL_REGEX')) {
                require PANTHER_ROOT . 'include/search_idx.php';
            }
            update_search_index('post', $post_id, $post['message']);
            $ps = $db->select('posts', 'id, poster, posted', $topic_data, 'topic_id=:id AND approved=1 AND deleted=0', 'id DESC LIMIT 1');
            list($last_id, $poster, $posted) = $ps->fetch(PDO::FETCH_NUM);
            $ps = $db->select('topics', 'num_replies', $topic_data, 'id=:id');
            $num_replies = $ps->fetchColumn();
            $update = array('num_replies' => $num_replies + 1, 'last_post' => $posted, 'last_post_id' => $last_id, 'last_poster' => $poster);
            $db->update('topics', $update, 'id=:id', $topic_data);
            update_search_index('post', $post_id, $post['message']);
            update_forum($post['forum_id']);
            redirect(panther_link($panther_url['admin_deleted']), $lang_admin_deleted['Post approved redirect']);
        }
    } else {
        if ($is_topic_post) {
            permanently_delete_topic($post['topic_id']);
            redirect(panther_link($panther_url['admin_deleted']), $lang_admin_deleted['Topic deleted redirect']);
        } else {
            permanently_delete_post($post_id);
            redirect(panther_link($panther_url['admin_deleted']), $lang_admin_deleted['Post deleted redirect']);
        }
    }
}
$ps = $db->run('SELECT t.id AS topic_id, t.forum_id, p.poster, p.poster_id, p.posted, p.message, p.id AS pid, p.hide_smilies, t.subject, f.forum_name FROM ' . $db->prefix . 'posts AS p LEFT JOIN ' . $db->prefix . 'topics AS t ON p.topic_id=t.id LEFT JOIN ' . $db->prefix . 'forums AS f ON t.forum_id=f.id WHERE p.deleted=1 OR t.deleted=1 ORDER BY p.posted DESC');
require PANTHER_ROOT . 'include/parser.php';
Beispiel #9
0
 // Insert some other default data
 $query = array('INSERT' => 'cat_name, disp_position', 'INTO' => 'categories', 'VALUES' => '\'' . $lang_install['Default category name'] . '\', 1');
 $forum_db->query_build($query) or error(__FILE__, __LINE__);
 $query = array('INSERT' => 'forum_name, forum_desc, num_topics, num_posts, last_post, last_post_id, last_poster, disp_position, cat_id', 'INTO' => 'forums', 'VALUES' => '\'' . $lang_install['Default forum name'] . '\', \'' . $lang_install['Default forum descrip'] . '\', 1, 1, ' . $now . ', 1, \'' . $forum_db->escape($username) . '\', 1, ' . $forum_db->insert_id() . '');
 $forum_db->query_build($query) or error(__FILE__, __LINE__);
 $query = array('INSERT' => 'poster, subject, posted, first_post_id, last_post, last_post_id, last_poster, forum_id', 'INTO' => 'topics', 'VALUES' => '\'' . $forum_db->escape($username) . '\', \'' . $lang_install['Default topic subject'] . '\', ' . $now . ', 1, ' . $now . ', 1, \'' . $forum_db->escape($username) . '\', ' . $forum_db->insert_id() . '');
 $forum_db->query_build($query) or error(__FILE__, __LINE__);
 $query = array('INSERT' => 'poster, poster_id, poster_ip, message, posted, topic_id', 'INTO' => 'posts', 'VALUES' => '\'' . $forum_db->escape($username) . '\', ' . $new_uid . ', \'127.0.0.1\', \'' . $lang_install['Default post contents'] . '\', ' . $now . ', ' . $forum_db->insert_id() . '');
 if ($db_type != 'pgsql') {
     $query['INSERT'] .= ', id';
     $query['VALUES'] .= ', 1';
 }
 $forum_db->query_build($query) or error(__FILE__, __LINE__);
 // Add new post to search table
 require FORUM_ROOT . 'include/search_idx.php';
 update_search_index('post', $forum_db->insert_id(), $lang_install['Default post contents'], $lang_install['Default topic subject']);
 // Insert the default ranks
 $query = array('INSERT' => 'rank, min_posts', 'INTO' => 'ranks', 'VALUES' => '\'' . $lang_install['Default rank 1'] . '\', 0');
 $forum_db->query_build($query) or error(__FILE__, __LINE__);
 $query = array('INSERT' => 'rank, min_posts', 'INTO' => 'ranks', 'VALUES' => '\'' . $lang_install['Default rank 2'] . '\', 10');
 $forum_db->query_build($query) or error(__FILE__, __LINE__);
 $forum_db->end_transaction();
 $alerts = array();
 // Check if the cache directory is writable and clear cache dir
 if (is_writable(FORUM_ROOT . 'cache/')) {
     $cache_dir = dir(FORUM_ROOT . 'cache/');
     if ($cache_dir) {
         while (($entry = $cache_dir->read()) !== false) {
             if (substr($entry, strlen($entry) - 4) == '.php') {
                 @unlink(FORUM_ROOT . 'cache/' . $entry);
             }
Beispiel #10
0
        message('No Forums Selected');
    }
    $now = time();
    $i = 0;
    $_POST['message'] = pun_linebreaks(pun_trim($_POST['message']));
    while ($i < count($_POST['forums'])) {
        $db->query('INSERT INTO ' . $db->prefix . 'topics (poster, subject, posted, last_post, last_poster, forum_id, sticky, closed)
			VALUES(\'' . $db->escape($pun_user['username']) . '\', \'' . $db->escape($_POST['subject']) . '\', ' . $now . ', ' . $now . ',
			       \'' . $db->escape($pun_user['username']) . '\', ' . $_POST['forums'][$i] . ', ' . $_POST['sticky'] . ', ' . $_POST['close'] . ')') or error('Unable to create topic', __FILE__, __LINE__, $db->error());
        $new_tid = $db->insert_id();
        $db->query('INSERT INTO ' . $db->prefix . 'posts (poster, poster_id, poster_ip, message, hide_smilies, posted, topic_id)
			VALUES(\'' . $db->escape($pun_user['username']) . '\', ' . $pun_user['id'] . ', \'' . get_remote_address() . '\',
			       \'' . $db->escape($_POST['message']) . '\', \'0\', ' . $now . ', ' . $new_tid . ')') or error('Unable to create post', __FILE__, __LINE__, $db->error());
        $new_pid = $db->insert_id();
        $db->query('UPDATE ' . $db->prefix . 'topics SET last_post_id=' . $new_pid . ' WHERE id=' . $new_tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
        update_search_index('post', $new_pid, $_POST['message'], $_POST['subject']);
        update_forum($_POST['forums'][$i]);
        $i++;
    }
    redirect('admin_loader.php?plugin=AMP_Global_topic.php', 'Topic(s) Added');
} elseif (isset($_POST['update'])) {
    if (empty($_POST['subject']) || empty($_POST['message'])) {
        message('Missing Fields');
    }
    $_POST['message'] = pun_linebreaks(pun_trim($_POST['message']));
    $db->query('UPDATE ' . $db->prefix . 'topics SET subject=\'' . $db->escape($_POST['subject']) . '\'
		WHERE subject=\'' . $db->escape($_POST['old_subject']) . '\' AND posted=' . $db->escape($_POST['old_posted'])) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
    $result = $db->query('SELECT p.id FROM ' . $db->prefix . 'posts as p LEFT JOIN ' . $db->prefix . 'topics as t ON t.id=p.topic_id
		WHERE t.subject=\'' . $db->escape($_POST['subject']) . '\' AND t.posted=' . $db->escape($_POST['old_posted'])) or error('Unable to get post ids', __FILE__, __LINE__, $db->error());
    while ($cur_post = $db->fetch_assoc($result)) {
        $db->query('UPDATE ' . $db->prefix . 'posts SET message=\'' . $db->escape($_POST['message']) . '\' WHERE id=' . $cur_post['id']) or error('Unable to update post', __FILE__, __LINE__, $db->error());
Beispiel #11
0
 public function edit_post($id, $can_edit_subject, $post, $cur_post, $is_admmod)
 {
     require FEATHER_ROOT . 'include/search_idx.php';
     if ($can_edit_subject) {
         // Update the topic and any redirect topics
         $where_topic = array(array('id' => $cur_post['tid']), array('moved_to' => $cur_post['tid']));
         $update_topic = array('subject' => $post['subject'], 'sticky' => $post['stick_topic']);
         DB::for_table('topics')->where_any_is($where_topic)->find_one()->set($update_topic)->save();
         // We changed the subject, so we need to take that into account when we update the search words
         update_search_index('edit', $id, $post['message'], $post['subject']);
     } else {
         update_search_index('edit', $id, $post['message']);
     }
     // Update the post
     $update_post = array('message' => $post['message'], 'hide_smilies' => $post['hide_smilies']);
     if (!$this->request->post('silent') || !$is_admmod) {
         $update_post['edited'] = time();
         $update_post['edited_by'] = $this->user->username;
     }
     DB::for_table('posts')->where('id', $id)->find_one()->set($update_post)->save();
 }
Beispiel #12
0
 $folders = array($lang_install['New'], $lang_install['Inbox'], $lang_install['Archived']);
 foreach ($folders as $folder) {
     $insert = array('name' => $folder, 'user_id' => 1);
     $db->insert('folders', $insert);
 }
 $insert = array('cat_name' => $lang_install['Test category'], 'disp_position' => 1);
 $db->insert('categories', $insert);
 $insert = array('forum_name' => $lang_install['Test forum'], 'forum_desc' => $lang_install['This is just a test forum'], 'num_topics' => 1, 'num_posts' => 1, 'last_post' => $now, 'last_post_id' => 1, 'last_topic' => sprintf($lang_install['Test post'], FORUM_VERSION), 'last_topic_id' => 1, 'last_poster' => $username, 'disp_position' => 1, 'cat_id' => 1, 'quickjump' => 1);
 $db->insert('forums', $insert);
 $insert = array('poster' => $username, 'subject' => sprintf($lang_install['Test post'], FORUM_VERSION), 'posted' => $now, 'first_post_id' => 1, 'last_post' => $now, 'last_post_id' => 1, 'last_poster' => $username, 'forum_id' => 1);
 $db->insert('topics', $insert);
 $insert = array('poster' => $username, 'poster_id' => 2, 'poster_ip' => get_remote_address(), 'message' => $lang_install['Message'], 'posted' => $now, 'topic_id' => 1);
 $db->insert('posts', $insert);
 // Index the test post so searching for it works
 require PANTHER_ROOT . 'include/search_idx.php';
 update_search_index('post', 1, $lang_install['Message'], $lang_install['Test post']);
 $db->end_transaction();
 // Check if we disabled uploading avatars because file_uploads was disabled
 if ($avatars == '0') {
     $alerts[] = $lang_install['Alert upload'];
 }
 // Generate the config.php file data
 $file = generate_config_file($config);
 // Attempt to write config.php and serve it up for download if writing fails
 $written = false;
 if (forum_is_writable(PANTHER_ROOT . 'include')) {
     $fh = @fopen(PANTHER_ROOT . 'include/config.php', 'wb');
     if ($fh) {
         fwrite($fh, $file);
         fclose($fh);
         $written = true;
Beispiel #13
0
         strip_search_index($second_post_id);
         update_search_index('movepost', $second_post_id, $second_message, $subject);
     }
 } elseif (isset($post_ids) && $new_subject) {
     require_once PUN_ROOT . 'include/search_idx.php';
     update_search_index('movepost', $post_id, $message, $new_subject);
     // update message and subject
 }
 if ($is_reception_post_new) {
     require_once PUN_ROOT . 'include/search_idx.php';
     // update the post which was first one on the reception topic (and second now)
     strip_search_index($reception_topic_first_post_id);
     update_search_index('movepost', $reception_topic_first_post_id, $reception_first_message);
     // update the post which is now the first one on the reception topic
     strip_search_index($post_id);
     update_search_index('movepost', $post_id, $message, $reception_subject);
 }
 //Update topics and forum if required
 update_topic($new_topic_id);
 if ($is_topic_post || $all_id) {
     delete_topic($old_topic_id);
     update_forum($old_fid);
     // Update the forum FROM which the topic was moved
     if ($new_forum) {
         update_forum($new_fid);
         // Update the forum FROM which the topic was moved
     }
 } else {
     update_topic($old_topic_id);
     update_forum($old_fid);
     // Update the forum FROM which the topic was moved
             $cur_topic = $cur_post[0];
         }
         echo 'Processing post <strong>' . $cur_post[1] . '</strong> in topic <strong>' . $cur_post[0] . '</strong><br />' . "\n";
         if ($cur_post[1] == $first_post) {
             update_search_index('post', $cur_post[1], $cur_post[2], $subject);
         } else {
             update_search_index('post', $cur_post[1], $cur_post[2]);
         }
     }
 } else {
     $result = $db->query('SELECT DISTINCT t.id, t.subject FROM ' . $db->prefix . 'topics AS t WHERE t.id>=' . $start_at . ' AND t.id<' . $end_at . ' ORDER BY t.id') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
     while ($cur_topic = $db->fetch_row($result)) {
         $result2 = $db->query('SELECT p.id, MIN(p.posted) AS first FROM ' . $db->prefix . 'posts AS p INNER JOIN ' . $db->prefix . 'topics AS t ON t.id=p.topic_id WHERE t.id=' . $cur_topic[0] . ' GROUP BY p.id ORDER BY first LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
         $cur_post = $db->fetch_row($result2);
         echo 'Processing topic <strong>' . $cur_topic[0] . '</strong><br />' . "\n";
         update_search_index('post', $cur_post[0], "", $cur_topic[1]);
     }
 }
 // Check if there is more work to do
 $result = $db->query('SELECT id FROM ' . $db->prefix . 'topics WHERE id>' . $end_at) or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
 if ($db->num_rows($result)) {
     $query_str = '?i_per_page=' . $per_page . '&i_start_at=' . $end_at;
     if ($subject_only) {
         $query_str .= '&i_subject_only=1';
     }
 } else {
     $query_str = '';
 }
 $db->end_transaction();
 $db->close();
 exit('<script type="text/javascript">window.location="admin_maintenance.php' . $query_str . '"</script><br />JavaScript redirect unsuccessful. Click <a href="admin_maintenance.php' . $query_str . '">here</a> to continue.');
Beispiel #15
0
         // Create the redirect topic
         $insert = array('poster' => $moved_to['poster'], 'subject' => $moderation['add_start'] . $moved_to['subject'] . $moderation['add_end'], 'posted' => $moved_to['posted'], 'last_post' => $moved_to['last_post'], 'moved_to' => $tid, 'forum_id' => $moved_to['forum_id']);
         $db->insert('topics', $insert);
     }
 }
 //We may (not) need some of this, but we might as well get it all in one query regardless
 $data = array(':id' => $tid);
 $ps = $db->run('SELECT t.subject, p.message, p.poster_email, p.poster_id, u.email, u.id AS uid, u.language FROM ' . $db->prefix . 'posts AS p INNER JOIN ' . $db->prefix . 'topics AS t ON t.first_post_id=p.id LEFT JOIN ' . $db->prefix . 'users AS u ON p.poster_id=u.id WHERE t.id=:id', $data);
 $topic = $ps->fetch();
 $email = !is_null($topic['poster_email']) ? $topic['poster_email'] : $topic['email'];
 if ($moderation['add_start'] != '' || $moderation['add_end'] != '') {
     $update['subject'] = $moderation['add_start'] . $topic['subject'] . $moderation['add_end'];
     if (!defined('PANTHER_CJK_HANGUL_REGEX')) {
         require PANTHER_ROOT . 'include/search_idx.php';
     }
     update_search_index('edit', $tid, $topic['message'], $moderation['add_start'] . $topic['subject'] . $moderation['add_end']);
 }
 if (!empty($update)) {
     $data = array(':id' => $tid);
     $db->update('topics', $update, 'id=:id', $data);
 }
 $data = array(':id' => $tid);
 $ps = $db->select('posts', 'COUNT(id)', $data, 'topic_id=:id AND approved=1 AND deleted=0');
 $num_replies = $ps->fetchColumn() - 1;
 // Get last_post, last_post_id and last_poster
 $data = array(':id' => $tid);
 $ps = $db->select('posts', 'posted, id, poster, poster_id', $data, 'topic_id=:id AND approved=1 AND deleted=0', 'id DESC LIMIT 1');
 $last_topic = $ps->fetch();
 // Update topic
 $update = array('num_replies' => $num_replies, 'last_post' => $last_topic['posted'], 'last_post_id' => $last_topic['id'], 'last_poster' => $last_topic['poster']);
 $data = array(':id' => $tid);
Beispiel #16
0
        if (!$db->num_rows($result)) {
            header('Location: ' . $base_config['baseurl'] . '/admin/maintenance');
            return;
        }
        echo '<div class="forum_content">';
        $first = true;
        $outid = 0;
        while (list($id, $content) = $db->fetch_row($result)) {
            if ($first) {
                echo '<p style="border: 1px solid #000; margin-left:5%; margin-right:5%; padding:0px;">
						<span style="width:' . $id / $post_count * 100 . '%; background-color: #39F; display:block; padding-left: 1px; padding-top: 1px; padding-bottom: 1px; margin-left:0px">&nbsp;</span>
				</p>
				<h3>' . translate('rebuildingsearch') . '</h3>';
                $first = false;
            }
            update_search_index($id, $content);
            echo '<p>' . translate('procpost', $id) . '</p>';
            $outid = $id;
        }
        echo '<p>' . translate('redirmsg', '?start=' . ($_GET['start'] + $per_page)) . '</p>';
        echo '</div>';
        header('Refresh: 1; url=' . $base_config['baseurl'] . '/admin/maintenance/rebuildsearch?start=' . ($_GET['start'] + $per_page));
        return;
    case 'update_user_post_counts':
        $per_page = 300;
        if (!isset($_GET['start'])) {
            $_GET['start'] = 0;
            $db->query('UPDATE `#^users` SET num_posts=-1') or error('Failed to erase search index', __FILE__, __LINE__, $db->error());
        }
        $result = $db->query('SELECT MAX(id) FROM `#^users`') or error('Failed to find post count', __FILE__, __LINE__, $db->error());
        list($user_count) = $db->fetch_row($result);
Beispiel #17
0
             $urllist[] = $url;
         }
         $ok = false;
         $add_num = 0;
         while (!$ok) {
             $ok = true;
             if (in_array($name, $urllist)) {
                 $add_num++;
                 $name = $base_name . '-' . $add_num;
                 $ok = false;
             }
         }
         $db->query('UPDATE `#^topics` SET subject=\'' . $db->escape($_POST['subject']) . '\',url=\'' . $db->escape($name) . '\' WHERE id=' . $cur_post['tid']) or error('Failed to update topic subject', __FILE__, __LINE__, $db->error());
         $db->query('INSERT INTO `#^topics`(url,redirect_id) VALUES(\'' . $db->escape($cur_post['turl']) . '\',' . $cur_post['tid'] . ')') or error('Failed to create redirect topic', __FILE__, __LINE__, $db->error());
     }
     update_search_index($pid, $_POST['content']);
     if (isset($_POST['silentedit']) && ($futurebb_user['g_mod_privs'] || $futurebb_user['g_admin_privs'])) {
         $last_edited_sql = '';
     } else {
         $last_edited_sql = 'last_edited=' . time() . ',last_edited_by=' . $futurebb_user['id'] . ',';
     }
     $db->query('UPDATE `#^posts` SET content=\'' . $db->escape($_POST['content']) . '\',parsed_content=\'' . $db->escape(BBCodeController::parse_msg($_POST['content'], !isset($_POST['hidesmilies']))) . '\',' . $last_edited_sql . 'disable_smilies=' . intval(isset($_POST['hidesmilies'])) . ' WHERE id=' . $pid) or error('Failed to update post', __FILE__, __LINE__, $db->error());
     redirect($base_config['baseurl'] . '/posts/' . $pid);
     return;
 } else {
     if (isset($_POST['preview']) && empty($errors)) {
         echo '<div class="quotebox preview">' . BBCodeController::parse_msg($_POST['content'], !isset($_POST['hidesmilies'])) . '</div>';
     } else {
         echo '<p>' . translate('errordesc') . '<ul>';
         foreach ($errors as $val) {
             echo '<li>' . $val . '</li>';
Beispiel #18
0
    }
    $hide_smilies = isset($_POST['hide_smilies']) ? intval($_POST['hide_smilies']) : 0;
    if ($hide_smilies != '1') {
        $hide_smilies = '0';
    }
    // Did everything go according to plan?
    if (empty($errors) && !isset($_POST['preview'])) {
        $edited_sql = !isset($_POST['silent']) || !$is_admmod ? $edited_sql = ', edited=' . time() . ', edited_by=\'' . $db->escape($pun_user['username']) . '\'' : '';
        require PUN_ROOT . 'include/search_idx.php';
        if ($can_edit_subject) {
            // Update the topic and any redirect topics
            $db->query('UPDATE ' . $db->prefix . 'topics SET subject=\'' . $db->escape($subject) . '\' WHERE id=' . $cur_post['tid'] . ' OR moved_to=' . $cur_post['tid']) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
            // We changed the subject, so we need to take that into account when we update the search words
            update_search_index('edit', $id, $message, $subject);
        } else {
            update_search_index('edit', $id, $message);
        }
        // Update the post
        $db->query('UPDATE ' . $db->prefix . 'posts SET message=\'' . $db->escape($message) . '\', hide_smilies=\'' . $hide_smilies . '\'' . $edited_sql . ' WHERE id=' . $id) or error('Unable to update post', __FILE__, __LINE__, $db->error());
        redirect('viewtopic.php?pid=' . $id . '#p' . $id, $lang_post['Edit redirect']);
    }
}
$page_title = pun_htmlspecialchars($pun_config['o_board_title']) . ' / ' . $lang_post['Edit post'];
$required_fields = array('req_subject' => $lang_common['Subject'], 'req_message' => $lang_common['Message']);
$focus_element = array('edit', 'req_message');
require PUN_ROOT . 'header.php';
$cur_index = 1;
?>
<div class="linkst">
	<div class="inbox">
		<ul><li><a href="index.php"><?php 
Beispiel #19
0
 public function insert_topic($post, $fid)
 {
     $new = array();
     // Create the topic
     $insert_topic = array('poster' => $post['username'], 'subject' => $post['subject'], 'posted' => $post['time'], 'last_post' => $post['time'], 'last_poster' => $post['username'], 'sticky' => $post['stick_topic'], 'forum_id' => $fid);
     DB::for_table('topics')->create()->set($insert_topic)->save();
     $new['tid'] = DB::get_db()->lastInsertId($this->feather->prefix . 'topics');
     if (!$this->user->is_guest) {
         // To subscribe or not to subscribe, that ...
         if ($this->config['o_topic_subscriptions'] == '1' && $post['subscribe']) {
             $insert_subscription = array('user_id' => $this->user->id, 'topic_id' => $new['tid']);
             DB::for_table('topic_subscriptions')->create()->set($insert_subscription)->save();
         }
         // Create the post ("topic post")
         $insert_post = array('poster' => $post['username'], 'poster_id' => $this->user->id, 'poster_ip' => get_remote_address(), 'message' => $post['message'], 'hide_smilies' => $post['hide_smilies'], 'posted' => $post['time'], 'topic_id' => $new['tid']);
         DB::for_table('posts')->create()->set($insert_post)->save();
     } else {
         // It's a guest
         // Create the post ("topic post")
         $insert_post = array('poster' => $post['username'], 'poster_ip' => get_remote_address(), 'message' => $post['message'], 'hide_smilies' => $post['hide_smilies'], 'posted' => $post['time'], 'topic_id' => $new['tid']);
         if ($this->config['p_force_guest_email'] == '1' || $post['email'] != '') {
             $insert_post['poster_email'] = $post['email'];
         }
         DB::for_table('posts')->create()->set($insert_post)->save();
     }
     $new['pid'] = DB::get_db()->lastInsertId($this->feather->prefix . 'topics');
     // Update the topic with last_post_id
     $update_topic = array('last_post_id' => $new['pid'], 'first_post_id' => $new['pid']);
     DB::for_table('topics')->where('id', $new['tid'])->find_one()->set($update_topic)->save();
     update_search_index('post', $new['pid'], $post['message'], $post['subject']);
     update_forum($fid);
     return $new;
 }
Beispiel #20
0
         if (!$pun_user['is_guest']) {
             // To subscribe or not to subscribe, that ...
             if ($pun_config['o_subscriptions'] == 1 && $_POST['subscribe'] == 1) {
                 $db->query('INSERT INTO ' . $db->prefix . 'subscriptions (user_id, topic_id) VALUES(' . $pun_user['id'] . ' ,' . $new_tid . ')') or error('Unable to add subscription', __FILE__, __LINE__, $db->error());
             }
             // Create the post ("topic post")
             $db->query('INSERT INTO ' . $db->prefix . 'posts (poster, poster_id, poster_ip, message, hide_smilies, posted, topic_id) VALUES(\'' . $db->escape($username) . '\', ' . $pun_user['id'] . ', \'' . get_remote_address() . '\', \'' . $db->escape($message) . '\', \'' . $hide_smilies . '\', ' . $_SERVER['REQUEST_TIME'] . ', ' . $new_tid . ')') or error('Unable to create post', __FILE__, __LINE__, $db->error());
         } else {
             // Create the post ("topic post")
             $email_sql = $pun_config['p_force_guest_email'] == 1 || $email ? '\'' . $db->escape($email) . '\'' : 'NULL';
             $db->query('INSERT INTO ' . $db->prefix . 'posts (poster, poster_ip, poster_email, message, hide_smilies, posted, topic_id) VALUES(\'' . $db->escape($username) . '\', \'' . get_remote_address() . '\', ' . $email_sql . ', \'' . $db->escape($message) . '\', \'' . $hide_smilies . '\', ' . $_SERVER['REQUEST_TIME'] . ', ' . $new_tid . ')') or error('Unable to create post', __FILE__, __LINE__, $db->error());
         }
         $new_pid = $db->insert_id();
         // Update the topic with last_post_id
         $db->query('UPDATE ' . $db->prefix . 'topics SET last_post_id=' . $new_pid . ' WHERE id=' . $new_tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
         update_search_index('post', $new_pid, $message, $subject);
         update_forum($fid);
     }
 }
 generate_rss();
 $uploaded = 0;
 $upload_result = process_uploaded_files($fid ? $new_tid : $tid, $new_pid, $uploaded);
 // If the posting user is logged in, increment his/her post count
 // MERGE POSTS BEGIN
 if (!$pun_user['is_guest']) {
     if ($uploaded) {
         $add_files = 'num_files=num_files+' . $uploaded . ', ';
     } else {
         $add_files = '';
     }
     if ($merged) {
Beispiel #21
0
 $avatars = in_array(strtolower(@ini_get('file_uploads')), array('on', 'true', '1')) ? 1 : 0;
 // Insert config data
 $pun_config = array('o_cur_version' => FORUM_VERSION, 'o_database_revision' => FORUM_DB_REVISION, 'o_searchindex_revision' => FORUM_SI_REVISION, 'o_parser_revision' => FORUM_PARSER_REVISION, 'o_board_title' => $title, 'o_board_desc' => $description, 'o_default_timezone' => 0, 'o_time_format' => 'H:i:s', 'o_date_format' => 'Y-m-d', 'o_timeout_visit' => 1800, 'o_timeout_online' => 300, 'o_redirect_delay' => 1, 'o_show_version' => 0, 'o_show_user_info' => 1, 'o_show_post_count' => 1, 'o_signatures' => 1, 'o_smilies' => 1, 'o_smilies_sig' => 1, 'o_make_links' => 1, 'o_default_lang' => $default_lang, 'o_default_style' => $default_style, 'o_default_user_group' => 4, 'o_topic_review' => 15, 'o_disp_topics_default' => 30, 'o_disp_posts_default' => 25, 'o_indent_num_spaces' => 4, 'o_quote_depth' => 3, 'o_quickpost' => 1, 'o_users_online' => 1, 'o_censoring' => 0, 'o_show_dot' => 0, 'o_topic_views' => 1, 'o_quickjump' => 1, 'o_gzip' => 0, 'o_additional_navlinks' => '', 'o_report_method' => 0, 'o_regs_report' => 0, 'o_default_email_setting' => 1, 'o_mailing_list' => $email, 'o_avatars' => $avatars, 'o_avatars_dir' => 'img/avatars', 'o_avatars_width' => 60, 'o_avatars_height' => 60, 'o_avatars_size' => 10240, 'o_search_all_forums' => 1, 'o_base_url' => $base_url, 'o_admin_email' => $email, 'o_webmaster_email' => $email, 'o_forum_subscriptions' => 1, 'o_topic_subscriptions' => 1, 'o_smtp_host' => NULL, 'o_smtp_user' => NULL, 'o_smtp_pass' => NULL, 'o_smtp_ssl' => 0, 'o_regs_allow' => 1, 'o_regs_verify' => 0, 'o_announcement' => 0, 'o_announcement_message' => $lang_install['Announcement'], 'o_rules' => 0, 'o_rules_message' => $lang_install['Rules'], 'o_maintenance' => 0, 'o_maintenance_message' => $lang_install['Maintenance message'], 'o_default_dst' => 0, 'o_feed_type' => 2, 'o_feed_ttl' => 0, 'p_message_bbcode' => 1, 'p_message_img_tag' => 1, 'p_message_all_caps' => 1, 'p_subject_all_caps' => 1, 'p_sig_all_caps' => 1, 'p_sig_bbcode' => 1, 'p_sig_img_tag' => 0, 'p_sig_length' => 400, 'p_sig_lines' => 4, 'p_allow_banned_email' => 1, 'p_allow_dupe_email' => 0, 'p_force_guest_email' => 1);
 foreach ($pun_config as $conf_name => $conf_value) {
     $db->query('INSERT INTO ' . $db_prefix . 'config (conf_name, conf_value) VALUES(\'' . $conf_name . '\', ' . (is_null($conf_value) ? 'NULL' : '\'' . $db->escape($conf_value) . '\'') . ')') or error('Unable to insert into table ' . $db_prefix . 'config. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
 }
 // Insert some other default data
 $subject = $lang_install['Test post'];
 $message = $lang_install['Message'];
 $db->query('INSERT INTO ' . $db_prefix . 'categories (cat_name, disp_position) VALUES(\'' . $db->escape($lang_install['Test category']) . '\', 1)') or error('Unable to insert into table ' . $db_prefix . 'categories. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
 $db->query('INSERT INTO ' . $db_prefix . 'forums (forum_name, forum_desc, num_topics, num_posts, last_post, last_post_id, last_poster, disp_position, cat_id) VALUES(\'' . $db->escape($lang_install['Test forum']) . '\', \'' . $db->escape($lang_install['This is just a test forum']) . '\', 1, 1, ' . $now . ', 1, \'' . $db->escape($username) . '\', 1, 1)') or error('Unable to insert into table ' . $db_prefix . 'forums. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
 $db->query('INSERT INTO ' . $db_prefix . 'topics (poster, subject, posted, first_post_id, last_post, last_post_id, last_poster, forum_id) VALUES(\'' . $db->escape($username) . '\', \'' . $db->escape($subject) . '\', ' . $now . ', 1, ' . $now . ', 1, \'' . $db->escape($username) . '\', 1)') or error('Unable to insert into table ' . $db_prefix . 'topics. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
 $db->query('INSERT INTO ' . $db_prefix . 'posts (poster, poster_id, poster_ip, message, posted, topic_id) VALUES(\'' . $db->escape($username) . '\', 2, \'' . $db->escape(get_remote_address()) . '\', \'' . $db->escape($message) . '\', ' . $now . ', 1)') or error('Unable to insert into table ' . $db_prefix . 'posts. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
 // Index the test post so searching for it works
 require PUN_ROOT . 'include/search_idx.php';
 update_search_index('post', 1, $message, $subject);
 $db->end_transaction();
 $alerts = array();
 // Check if we disabled uploading avatars because file_uploads was disabled
 if ($avatars == '0') {
     $alerts[] = $lang_install['Alert upload'];
 }
 // Add some random bytes at the end of the cookie name to prevent collisions
 $cookie_name = 'pun_cookie_' . random_key(6, false, true);
 // Generate the config.php file data
 $config = generate_config_file();
 // Attempt to write config.php and serve it up for download if writing fails
 $written = false;
 if (forum_is_writable(PUN_ROOT)) {
     $fh = @fopen(PUN_ROOT . 'config.php', 'wb');
     if ($fh) {
Beispiel #22
0
     //Update topics and forum if required
     update_topic($new_topic_id);
     if ($del_old_topic || $all_id) {
         delete_topic($old_topic_id);
         update_forum($old_fid);
         // Update the forum FROM which the topic was moved
         if ($new_forum) {
             update_forum($new_fid);
         }
         // Update the forum FROM which the topic was moved
         require PUN_ROOT . 'include/search_idx.php';
         // Bit silly should be probably improved: in order to remove the subject from the old topic, we need:
         // 1. remove all the words (message and subject) from the search tables
         // 2. add the words from the message only in the search tables !!!
         strip_search_index($post_id);
         update_search_index('post', $post_id, $message);
     } else {
         update_topic($old_topic_id);
         if ($new_forum) {
             update_forum($old_fid);
             // Update the forum FROM which the topic was moved
             update_forum($new_fid);
             // Update the forum TO which the topic was moved
         }
     }
     redirect('viewtopic.php?pid=' . $post_id . '#p' . $post_id, $lang_movepost['Mark move redirect']);
 } else {
     //Count the topics to diplayed
     $result = $db->query('SELECT count(id) FROM ' . $db->prefix . 'topics WHERE forum_id =' . $fid . ' AND moved_to IS NULL') or error('Unable to count topics in forum', __FILE__, __LINE__, $db->error());
     $num_topics = $db->result($result);
     //Not add the original topic
Beispiel #23
0
function create_topic($subject, $message, $user, $forum, $hidesmiliespostentry)
{
    //creates a new topic, returns the URL of that topic (just the topic, not the forum, so something like "my-great-topic")
    global $futurebb_config, $db;
    $name = URLEngine::make_friendly($subject);
    $base_name = $name;
    //check for forums with the same URL
    $result = $db->query('SELECT url FROM `#^topics` WHERE url LIKE \'' . $db->escape($name) . '%\'') or error('Failed to check for similar URLs', __FILE__, __LINE__, $db->error());
    $urllist = array();
    while (list($url) = $db->fetch_row($result)) {
        $urllist[] = $url;
    }
    $ok = false;
    $add_num = 0;
    while (!$ok) {
        $ok = true;
        if (in_array($name, $urllist)) {
            $add_num++;
            $name = $base_name . '-' . $add_num;
            $ok = false;
        }
    }
    $db->query('INSERT INTO `#^topics`(subject,url,forum_id) VALUES(\'' . $db->escape($subject) . '\',\'' . $db->escape($name) . '\',' . $forum . ')') or error('Failed to create topic', __FILE__, __LINE__, $db->error());
    $tid = $db->insert_id();
    $parsedtext = BBCodeController::parse_msg($message, !$hidesmiliespostentry, $futurebb_config['enable_bbcode']);
    $db->query('INSERT INTO `#^posts`(poster,poster_ip,content,parsed_content,posted,topic_id,disable_smilies) VALUES(' . $user . ',\'' . $db->escape($_SERVER['REMOTE_ADDR']) . '\',\'' . $db->escape($message) . '\',\'' . $db->escape($parsedtext) . '\',' . time() . ',' . $tid . ',' . intval($hidesmiliespostentry) . ')') or error('Failed to make first post<br />' . $q, __FILE__, __LINE__, $db->error());
    $pid = $db->insert_id();
    // Let's take a break to fire any notifications from @ tags
    if ($futurebb_config['allow_notifications'] == 1) {
        if (preg_match_all('%@([a-zA-Z0-9_\\-]+)%', $parsedtext, $matches)) {
            array_slice($matches[1], 0, 8);
            foreach ($matches[1] as $tagged_user) {
                $tagged_res = $db->query('SELECT id, block_notif FROM `#^users` WHERE username = \'' . $tagged_user . '\'') or error('Failed to find users to tag', __FILE__, __LINE__, $db->error());
                if ($db->num_rows($tagged_res)) {
                    $tagged_id = $db->fetch_assoc($tagged_res);
                    if ($tagged_id['block_notif'] == 0) {
                        $db->query('INSERT INTO `#^notifications` (type, user, send_time, contents, arguments)
						VALUES (\'notification\', ' . intval($tagged_id['id']) . ', ' . time() . ', ' . $pid . ', \'' . $futurebb_user['username'] . ',' . $db->escape($subject) . '\')');
                    }
                }
            }
        }
    }
    // Continue posting
    $db->query('UPDATE `#^topics` SET last_post=' . time() . ',last_post_id=' . $pid . ',first_post_id=' . $pid . ' WHERE id=' . $tid) or error('Failed to update topic info', __FILE__, __LINE__, $db->error());
    $db->query('UPDATE `#^forums` SET last_post=' . time() . ',last_post_id=' . $pid . ',num_posts=num_posts+1,num_topics=num_topics+1 WHERE id=' . $forum) or error('Failed to update forum last post', __FILE__, __LINE__, $db->error());
    $db->query('DELETE FROM `#^read_tracker` WHERE forum_id=' . $forum . ' AND user_id<>' . $user) or error('Failed to update read tracker', __FILE__, __LINE__, $db->error());
    $db->query('UPDATE `#^users` SET num_posts=num_posts+1 WHERE id=' . $user) or error('Failed to update number of posts', __FILE__, __LINE__, $db->error());
    update_search_index($pid, $_POST['message']);
    return $name;
}