$forum = $request['dba']->getRow("SELECT * FROM " . K4FORUMS . " WHERE forum_id = " . intval($post['forum_id']));
            /* Check the forum data given */
            if (!$forum || !is_array($forum) || empty($forum)) {
                $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
                return $action->execute($request);
            }
            /* Make sure the we are trying to delete from a forum */
            if (!($forum['row_type'] & FORUM)) {
                $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
                return $action->execute($request);
            }
            /* If the number of replies on this topic is greater than the posts per page for this forum */
            if ($topic['num_replies'] > $forum['postsperpage']) {
                $whereinline = $request['dba']->getValue("SELECT COUNT(*) FROM " . K4POSTS . " WHERE parent_id = " . intval($post['parent_id']) . " AND row_order <= " . intval($post['created']) . " ORDER BY created ASC");
                $page = ceil($whereinline / $forum['postsperpage']);
                $page = $page <= 0 ? 1 : $page;
                header("Location: viewtopic.php?id=" . $post['post_id'] . "&page=" . intval($page) . "&limit=" . $forum['postsperpage'] . "&order=ASC&sort=created&daysprune=0&p=" . $post['post_id'] . "#p" . $post['post_id']);
                return;
            } else {
                header("Location: viewtopic.php?id=" . $post['parent_id'] . "&p=" . $post['post_id'] . "#p" . $post['post_id']);
                return;
            }
        }
        return TRUE;
    }
}
$app = new K4controller('forum_base.html');
$app->setAction('', new K4DefaultAction());
$app->setDefaultEvent('');
$app->execute();
ob_flush();
                    $num_attachments = $request['template']->getVar('nummaxattaches') - $num_attachments;
                    $attach_inputs = '';
                    for ($i = 1; $i <= $num_attachments; $i++) {
                        $attach_inputs .= '<br /><input type="file" class="inputbox" name="attach' . $i . '" id="attach' . $i . '" value="" size="55" />';
                    }
                    $request['template']->setVar('attach_inputs', $attach_inputs);
                }
            }
        }
        /* Create our editor */
        create_editor($request, $body_text, 'post', $forum);
        /* set the breadcrumbs bit */
        k4_bread_crumbs($request['template'], $request['dba'], 'L_POSTTOPIC', $forum);
        /* Set the post topic form */
        $request['template']->setVar('is_topic', 1);
        $request['template']->setFile('content', 'newtopic.html');
        $request['template']->setVar('forum_forum_id', $forum['forum_id']);
        $request['template']->setVisibility('post_topic', TRUE);
        $request['template']->setVar('L_TITLETOOSHORT', sprintf($request['template']->getVar('L_TITLETOOSHORT'), $request['template']->getVar('topicminchars'), $request['template']->getVar('topicmaxchars')));
        return TRUE;
    }
}
$app = new K4controller('forum_base.html');
$app->setAction('', new K4DefaultAction());
$app->setDefaultEvent('');
$app->setAction('posttopic', new InsertPost(TOPIC));
$app->setAction('postdraft', new PostDraft());
$app->setAction('deletedraft', new DeleteDraft());
$app->setAction('edittopic', new EditTopic());
$app->setAction('updatetopic', new UpdatePost(TOPIC));
$app->execute();
}
class K4PollAnswersIterator extends FAProxyIterator
{
    var $num_votes, $dba;
    function K4PollAnswersIterator(&$result, &$dba, $num_votes)
    {
        $this->__construct($result, $dba, $num_votes);
    }
    function __construct(&$result, &$dba, $num_votes)
    {
        $this->num_votes = $num_votes;
        $this->dba =& $dba;
        parent::__construct($result);
    }
    function current()
    {
        global $_QUERYPARAMS;
        $temp = parent::current();
        //$result					= $this->dba->getValue("SELECT * FROM ". K4POLLVOTES ." WHERE answer_id = ". intval($temp['id']));
        $result = $this->dba->executeQuery("SELECT " . $_QUERYPARAMS['user'] . ", u.id as user_id FROM " . K4POLLVOTES . " pv LEFT JOIN " . K4USERS . " u ON u.id=pv.user_id WHERE pv.answer_id = " . intval($temp['id']));
        $temp['users'] =& new UsersIterator($result);
        $temp['num_votes'] = intval($result->numRows());
        $temp['percent'] = @ceil($temp['num_votes'] / $this->num_votes * 100);
        return $temp;
    }
}
$app = new K4controller('forum_base.html');
$app->setAction('', new K4DefaultAction());
$app->setDefaultEvent('');
$app->setAction('vote', new K4VoteOnPoll());
$app->execute();
Exemple #4
0
class AdminMenuSection extends FAAction
{
    function execute(&$request)
    {
        if ($request['user']->isMember() && $request['user']->get('perms') >= ADMIN) {
            k4_bread_crumbs($request['template'], $request['dba'], 'L_WELCOME');
            $request['template']->setVar('adv_view', 1);
            $request['template']->setFile('content', 'admin_menu.html');
        } else {
            no_perms_error($request);
            return TRUE;
        }
        return TRUE;
    }
}
$app = new K4controller('admin/admin_base.html');
$app->setAction('', new K4DefaultAction());
$app->setDefaultEvent('');
/* Frameset */
$app->setAction('admin_header', new AdminHeadSection());
$app->setAction('admin_menu', new AdminMenuSection());
/* Admin File Browser */
$app->setAction('file_browser', new AdminFileBrowser());
/* Options */
$app->setAction('options', new AdminOptionGroups());
$app->setAction('options_view', new AdminSettings());
$app->setAction('update_options', new AdminUpdateOptions());
/* Cache Control */
$app->setAction('cache', new AdminManageCache());
$app->setAction('cache_refresh', new AdminRefreshCache());
/* The GUI for the K4MAPS permission system */
                     */
                } else {
                    $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
                    return $action->execute($request);
                }
            }
        }
        /**
         * Can we post in here?
         */
        $can_post_in_forum = 1;
        if ($forum['forum_id'] == GARBAGE_BIN || $forum['row_type'] > GALLERY) {
            $can_post_in_forum = 0;
        }
        $request['template']->setVar('can_post_in_forum', $can_post_in_forum);
        // urls
        $request['template']->setVar('U_FORUMRSSURL', K4Url::getGenUrl('rss', 'f=' . $forum['forum_id']));
        /* Add the cookies for this forum's topics */
        bb_execute_topiccache();
        // show the midsection of the forum
        $request['template']->setVisibility('forum_midsection', TRUE);
        return TRUE;
    }
}
$app = new K4controller('forum_base.html');
$app->setAction('', new K4DefaultAction());
$app->setDefaultEvent('');
$app->setAction('markforum', new MarkForumsRead());
$app->setAction('track', new SubscribeForum());
$app->setAction('untrack', new UnsubscribeForum());
$app->execute();
Exemple #6
0
* @author Peter Goodman
* @version $Id: mod.php 110 2005-06-13 20:48:58Z Peter Goodman $
* @package k42
*/
ob_start();
require "includes/filearts/filearts.php";
require "includes/k4bb/k4bb.php";
class K4DefaultAction extends FAAction
{
    function execute(&$request)
    {
        no_perms_error($request);
        return TRUE;
    }
}
$app = new K4controller('forum_base.html');
$app->setAction('', new K4DefaultAction());
$app->setDefaultEvent('');
$app->setAction('deletetopic', new DeletePost(TOPIC));
$app->setAction('deletereply', new DeletePost(REPLY));
$app->setAction('locktopic', new LockTopic(1));
$app->setAction('unlocktopic', new LockTopic(0));
$app->setAction('moderate_forum', new ModerateForum());
$app->setAction('topic_simpleupdate', new SimpleUpdateTopic());
$app->setAction('get_topic_title', new getTopicTitle());
$app->setAction('move_topics', new MoveTopics());
/* Bad post reports */
$app->setAction('viewbpreports', new ViewBadPostReports());
$app->setAction('deletereport', new DeleteBadPostReport());
/* User related moderations */
$app->setAction('findusers', new ModFindUsers());
        k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
        $mode = 0;
        $modes = array('threaded', 'linear', 'vertical', 'normal');
        $mode_var = 'topic_display';
        if (isset($_REQUEST['mode']) && in_array($_REQUEST['mode'], $modes)) {
            if ($_REQUEST['mode'] == 'linear' || $_REQUEST['mode'] == 'threaded') {
                $mode = 1;
            }
            if ($_REQUEST['mode'] == 'threaded' || $_REQUEST['mode'] == 'normal') {
                $mode_var = 'topic_threaded';
            }
            if ($request['user']->isMember()) {
                if ($request['user']->get($mode_var) != $mode) {
                    $request['dba']->executeUpdate("UPDATE " . K4USERSETTINGS . " SET {$mode_var}={$mode} WHERE user_id = " . intval($request['user']->get('id')));
                }
            }
        }
        $action = new K4InformationAction(new K4LanguageElement('L_UPDATEDTOPICVIEWS'), 'content', TRUE, referer(), 3);
        return $action->execute($request);
    }
}
$app = new K4controller('forum_base.html');
$app->setAction('', new K4DefaultAction());
$app->setDefaultEvent('');
$app->setAction('track', new SubscribeTopic());
$app->setAction('untrack', new UnsubscribeTopic());
$app->setAction('rate_topic', new RateTopic());
$app->setAction('changeview', new ChangeTopicView());
$app->setAction('report_post', new ReportBadPost());
$app->setAction('send_report', new SendBadPostReport());
$app->execute();
        }
        /* Set the title variable */
        $request['template']->setVar('post_name', $request['template']->getVar('L_RE') . ': ' . (isset($reply) ? $reply['name'] : $topic['name']));
        $request['template']->setVar('L_TITLETOOSHORT', sprintf($request['template']->getVar('L_TITLETOOSHORT'), $request['template']->getVar('topicminchars'), $request['template']->getVar('topicmaxchars')));
        /* set the breadcrumbs bit */
        k4_bread_crumbs($request['template'], $request['dba'], 'L_POSTREPLY', $parent, $forum);
        foreach ($parent as $key => $val) {
            $request['template']->setVar('parent_' . $key, $val);
        }
        $query = "SELECT * FROM " . K4POSTS . " WHERE post_id = " . intval($topic['post_id']) . " ORDER BY created DESC LIMIT 10";
        $replies = $request['dba']->executeQuery($query);
        /* Set the form actiob */
        $request['template']->setVar('newreply_act', 'newreply.php?act=postreply');
        $it =& new TopicReviewIterator($request['dba'], $topic, $replies, $request['user']->getInfoArray());
        $request['template']->setList('topic_review', $it);
        /* Set the post topic form */
        $request['template']->setFile('content', 'newreply.html');
        /* Create our editor */
        create_editor($request, $body_text, 'post', $forum);
        /* Clear up some memory */
        unset($it, $body_text, $forum, $replies, $bbcode, $last_topic, $last_reply, $topic);
        return TRUE;
    }
}
$app = new K4controller('forum_base.html');
$app->setAction('', new K4DefaultAction());
$app->setDefaultEvent('');
$app->setAction('postreply', new InsertPost(REPLY));
$app->setAction('editreply', new EditReply());
$app->setAction('updatereply', new UpdatePost(REPLY));
$app->execute();
            }
            /* Outside valid page range, redirect */
            if (!$pager->hasPage($page) && $num_pages > 0) {
                $action = new K4InformationAction(new K4LanguageElement('L_PASTPAGELIMIT'), 'content', FALSE, 'usergroups.php?id=' . $group['id'] . '&limit=' . $perpage . '&page=' . $num_pages, 3);
                return $action->execute($request);
            }
            /* Get the members for this usergroup */
            $start = ($page - 1) * $perpage;
            /* Get the members of this usergroup */
            if ($num_results > 0) {
                $result = $request['dba']->executeQuery("SELECT " . $_QUERYPARAMS['user'] . $_QUERYPARAMS['userinfo'] . " FROM " . K4USERS . " u LEFT JOIN " . K4USERINFO . " ui ON u.id=ui.user_id WHERE u.usergroups LIKE '%|" . intval($group['id']) . "|%' AND u.id <> " . intval($group['mod_id']) . " LIMIT " . intval($start) . ", " . intval($perpage));
                $users =& new UsersIterator($result);
                $request['template']->setList('users_in_usergroup', $users);
            }
            $request['template']->setVar('num_group_members', $num_results);
            if ($request['user']->get('id') == $group['mod_id']) {
                $request['template']->setVisibility('add_user', TRUE);
                $request['template']->setVar('is_mod', 1);
            }
            k4_bread_crumbs($request['template'], $request['dba'], $group['name']);
            $request['template']->setFile('content', 'lookup_usergroup.html');
        }
        return TRUE;
    }
}
$app = new K4controller('forum_base.html');
$app->setAction('', new K4DefaultAction());
$app->setDefaultEvent('');
$app->setAction('add_user_to_group', new AddUserToGroup());
$app->setAction('remove_user_from_group', new RemoveUserFromGroup());
$app->execute();