1
0
mirror of https://github.com/e107inc/e107.git synced 2025-02-13 11:04:38 +01:00
php-e107/e107_plugins/forum/forum_viewtopic.php

638 lines
20 KiB
PHP
Raw Normal View History

2006-12-02 04:36:16 +00:00
<?php
2008-12-04 21:36:09 +00:00
2006-12-02 04:36:16 +00:00
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| <EFBFBD>Steve Dunstan 2001-2002
| http://e107.org
| jalist@e107.org
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $
2008-12-11 21:50:18 +00:00
| $Revision: 1.13 $
| $Date: 2008-12-11 21:50:18 $
2006-12-02 04:36:16 +00:00
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
2008-12-04 21:36:09 +00:00
require_once ('../../class2.php');
2006-12-02 04:36:16 +00:00
if (isset($_POST['fjsubmit']))
{
2008-12-04 21:36:09 +00:00
header('location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id' => $_POST['forumjump'])));
2006-12-02 04:36:16 +00:00
exit;
}
$highlight_search = isset($_POST['highlight_search']);
2006-12-02 04:36:16 +00:00
if (!e_QUERY)
{
//No paramters given, redirect to forum home
2008-12-04 21:36:09 +00:00
header('Location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'main')));
2006-12-02 04:36:16 +00:00
exit;
}
2008-12-04 21:36:09 +00:00
include_lan(e_PLUGIN . 'forum/languages/English/lan_forum_viewtopic.php');
include_once (e_PLUGIN . 'forum/forum_class.php');
2008-12-07 00:21:21 +00:00
include_lan(e_PLUGIN . 'forum/templates/forum_icons_template.php');
2008-12-02 21:34:18 +00:00
$forum = new e107forum;
2008-12-04 21:36:09 +00:00
$thread = new e107ForumThread;
2008-12-02 21:34:18 +00:00
2008-12-04 21:36:09 +00:00
$thread->init();
2008-12-08 02:33:34 +00:00
if(isset($_POST['track_toggle']))
{
$thread->toggle_track();
exit;
}
//print_a($_POST);
2008-12-04 21:36:09 +00:00
if(isset($_GET['f']))
{
2008-12-04 21:36:09 +00:00
$thread->processFunction();
$thread->init();
2006-12-02 04:36:16 +00:00
}
2008-12-04 21:36:09 +00:00
require_once (e_PLUGIN . 'forum/forum_shortcodes.php');
2006-12-02 04:36:16 +00:00
$pm_installed = plugInstalled('pm');
2008-12-01 21:11:01 +00:00
//Only increment thread views if not being viewed by thread starter
2008-12-04 21:36:09 +00:00
if (USER || USER != $threadInfo['thread_user'] || !$thread->noInc)
2008-12-01 21:11:01 +00:00
{
$forum->threadIncview($threadId);
}
2008-12-04 21:36:09 +00:00
define('e_PAGETITLE', LAN_01 . ' / ' . $e107->tp->toHTML($thread->threadInfo['forum_name'], true, 'no_hook, emotes_off') . " / " . $tp->toHTML($thread->threadInfo['thread_name'], true, 'no_hook, emotes_off'));
$modArray = $forum->forum_getmods($thread->threadInfo['forum_moderators']);
define('MODERATOR', (USER && is_array($modArray) && in_array(USERID, array_keys($modArray))));
2006-12-02 04:36:16 +00:00
2008-12-02 21:34:18 +00:00
if (MODERATOR && isset($_POST['mod']))
2006-12-02 04:36:16 +00:00
{
2008-12-04 21:36:09 +00:00
require_once (e_PLUGIN . 'forum/forum_mod.php');
$thread->message = forum_thread_moderate($_POST);
$thread->threadInfo = $forum->threadGet($thread->threadId);
2006-12-02 04:36:16 +00:00
}
$postList = $forum->PostGet($thread->threadId, $thread->page * $thread->perPage, $thread->perPage);
2008-12-02 21:34:18 +00:00
2008-12-04 21:36:09 +00:00
//var_dump($thread->threadInfo);
require_once (e_HANDLER . 'level_handler.php');
2008-12-02 21:34:18 +00:00
$gen = new convert;
2008-12-04 21:36:09 +00:00
if ($thread->message)
2006-12-02 04:36:16 +00:00
{
2008-12-04 21:36:09 +00:00
$ns->tablerender('', $thread->message, array('forum_viewtopic', 'msg'));
2006-12-02 04:36:16 +00:00
}
2008-12-04 21:36:09 +00:00
if (isset($thread->threadInfo['thread_options']['poll']))
2006-12-02 04:36:16 +00:00
{
2008-12-04 21:36:09 +00:00
if (!defined('POLLCLASS'))
{
include (e_PLUGIN . 'poll/poll_class.php');
}
$_qry = 'SELECT * FROM `#polls` WHERE `poll_datestamp` = ' . $thread->threadId;
2006-12-02 04:36:16 +00:00
$poll = new poll;
2008-12-04 21:36:09 +00:00
$pollstr = "<div class='spacer'>" . $poll->render_poll($_qry, 'forum', 'query', true) . '</div>';
2006-12-02 04:36:16 +00:00
}
//Load forum templates
2008-12-04 21:36:09 +00:00
if (file_exists(THEME . 'forum_design.php'))
{
include_once (THEME . 'forum_design.php');
}
2008-12-02 21:34:18 +00:00
if (!$FORUMSTART)
{
2008-12-04 21:36:09 +00:00
if (file_exists(THEME . 'forum_viewtopic_template.php'))
2006-12-02 04:36:16 +00:00
{
2008-12-04 21:36:09 +00:00
require_once (THEME . 'forum_viewtopic_template.php');
2008-12-07 00:21:21 +00:00
}
elseif (file_exists(THEME . 'forum_template.php'))
2006-12-02 04:36:16 +00:00
{
2008-12-04 21:36:09 +00:00
require_once (THEME . 'forum_template.php');
2006-12-02 04:36:16 +00:00
}
else
{
2008-12-04 21:36:09 +00:00
require_once (e_PLUGIN . 'forum/templates/forum_viewtopic_template.php');
2006-12-02 04:36:16 +00:00
}
}
// get info for main thread -------------------------------------------------------------------------------------------------------------------------------------------------------------------
2008-12-01 21:11:01 +00:00
$forum->set_crumb(true); // Set $BREADCRUMB (and BACKLINK)
2008-12-04 21:36:09 +00:00
$THREADNAME = $e107->tp->toHTML($thread->threadInfo['thread_name'], true, 'no_hook, emotes_off');
$NEXTPREV = "&lt;&lt; <a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'prev', 'id' => $thread->threadId)) . "'>" . LAN_389 . "</a>";
2008-12-01 21:11:01 +00:00
$NEXTPREV .= ' | ';
2008-12-04 21:36:09 +00:00
$NEXTPREV .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'next', 'id' => $thread->threadId)) . "'>" . LAN_390 . "</a> &gt;&gt;";
2006-12-02 04:36:16 +00:00
if ($pref['forum_track'] && USER)
{
2008-12-07 04:16:39 +00:00
$img = ($thread->threadInfo['track_userid'] ? IMAGE_track : IMAGE_untrack);
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $thread->threadId));
2008-12-07 04:16:39 +00:00
$TRACK .= "
2008-12-07 00:21:21 +00:00
<span id='forum-track-trigger-container'>
2008-12-07 04:16:39 +00:00
<a href='{$url}' id='forum-track-trigger'>{$img}</a>
2008-12-07 00:21:21 +00:00
</span>
<script type='text/javascript'>
2008-12-08 02:33:34 +00:00
e107.runOnLoad(function(){
2008-12-07 00:21:21 +00:00
//put this in header_js or as inline script just after the markup above
$('forum-track-trigger').observe('click', function(e) {
e.stop();
2008-12-07 04:16:39 +00:00
new e107Ajax.Updater('forum-track-trigger-container', '{$url}', {
2008-12-08 02:33:34 +00:00
method: 'post',
parameters: { //send query parameters here
'track_toggle': 1
},
2008-12-07 00:21:21 +00:00
overlayPage: $(document.body)
});
});
2008-12-08 02:33:34 +00:00
}, document, true);
2008-12-07 00:21:21 +00:00
</script>
2008-12-07 04:16:39 +00:00
";
2006-12-02 04:36:16 +00:00
}
2008-12-04 21:36:09 +00:00
$MODERATORS = LAN_321 . implode(', ', $modArray);
2006-12-02 04:36:16 +00:00
2008-12-04 21:36:09 +00:00
$THREADSTATUS = (!$thread->threadInfo['thread_active'] ? LAN_66 : '');
2008-12-01 21:11:01 +00:00
2008-12-04 21:36:09 +00:00
//$pages = ceil(($threadInfo['thread_total_replies'] + 1) / $perPage);
2006-12-02 04:36:16 +00:00
2008-12-04 21:36:09 +00:00
if ($thread->pages > 1)
2006-12-02 04:36:16 +00:00
{
2008-12-04 21:36:09 +00:00
$parms = ($thread->threadInfo['thread_total_replies'] + 1) . ",{$perPage},{$topic_from}," . e_SELF . '?' . $this->threadId . '.[FROM],off';
2006-12-02 04:36:16 +00:00
$GOTOPAGES = $tp->parseTemplate("{NEXTPREV={$parms}}");
}
2008-12-01 21:11:01 +00:00
$BUTTONS = '';
2008-12-04 21:36:09 +00:00
if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread->threadInfo['thread_active'])
2006-12-02 04:36:16 +00:00
{
2008-12-04 21:36:09 +00:00
$BUTTONS .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'rp', 'id' => $thread->threadId)) . "'>" . IMAGE_reply . "</a>";
2008-12-01 21:11:01 +00:00
}
2008-12-04 21:36:09 +00:00
if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'thread'))
2008-12-01 21:11:01 +00:00
{
2008-12-04 21:36:09 +00:00
$BUTTONS .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'nt', 'id' => $thread->threadInfo['thread_forum_id'])) . "'>" . IMAGE_newthread . "</a>";
2006-12-02 04:36:16 +00:00
}
$POLL = $pollstr;
$FORUMJUMP = forumjump();
$forstr = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMSTART);
unset($forrep);
if (!$FORUMREPLYSTYLE) $FORUMREPLYSTYLE = $FORUMTHREADSTYLE;
2008-12-01 21:11:01 +00:00
$alt = false;
2008-12-04 21:36:09 +00:00
$i = $thread->page;
2008-12-01 21:11:01 +00:00
global $postInfo;
2008-12-04 21:36:09 +00:00
foreach ($postList as $postInfo)
2006-12-02 04:36:16 +00:00
{
if($postInfo['post_options'])
{
$postInfo['post_options'] = unserialize($postInfo['post_options']);
}
2008-12-01 21:11:01 +00:00
$loop_uid = (int)$postInfo['post_user'];
$i++;
2008-12-02 21:34:18 +00:00
//TODO: Look into fixing this, to limit to a single query per pageload
2008-12-04 21:36:09 +00:00
$e_hide_query = "SELECT post_id FROM `#forum_post` WHERE (`post_thread` = {$threadId} AND post_user= " . USERID . ' LIMIT 1';
2006-12-02 04:36:16 +00:00
$e_hide_hidden = FORLAN_HIDDEN;
$e_hide_allowed = USER;
2008-12-04 21:36:09 +00:00
if ($i > 1)
2006-12-02 04:36:16 +00:00
{
2008-12-08 02:33:34 +00:00
$postInfo['thread_start'] = false;
2006-12-02 04:36:16 +00:00
$alt = !$alt;
2008-12-11 21:50:18 +00:00
if($postInfo['post_s'])
2006-12-02 04:36:16 +00:00
{
2008-12-11 21:50:18 +00:00
$_style = (isset($FORUMDELETEDSTYLE_ALT) && $alt ? $FORUMDELETEDSTYLE_ALT : $FORUMDELETEDSTYLE);
2006-12-02 04:36:16 +00:00
}
else
{
2008-12-11 21:50:18 +00:00
$_style = (isset($FORUMREPLYSTYLE_ALT) && $alt ? $FORUMREPLYSTYLE_ALT : $FORUMREPLYSTYLE);
2006-12-02 04:36:16 +00:00
}
2008-12-11 21:50:18 +00:00
$forrep .= $e107->tp->parseTemplate($_style, true, $forum_shortcodes) . "\n";
2006-12-02 04:36:16 +00:00
}
else
{
2008-12-08 02:33:34 +00:00
$postInfo['thread_start'] = true;
2008-12-04 21:36:09 +00:00
$forthr = $e107->tp->parseTemplate($FORUMTHREADSTYLE, true, $forum_shortcodes) . "\n";
2006-12-02 04:36:16 +00:00
}
}
unset($loop_uid);
2008-12-04 21:36:09 +00:00
if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread->threadInfo['thread_active'])
2006-12-02 04:36:16 +00:00
{
if (!$forum_quickreply)
{
2008-12-04 21:36:09 +00:00
$QUICKREPLY = "
<form action='" . $e107->url->getUrl('forum', 'thread', array('func' => 'rp', 'id' => $thread->threadId)) . "' method='post'>
<p>" . LAN_393 . ":<br />
<textarea cols='60' rows='4' class='tbox' name='post' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'></textarea>
<br />
<input type='submit' name='fpreview' value='" . LAN_394 . "' class='button' /> &nbsp;
<input type='submit' name='reply' value='" . LAN_395 . "' class='button' />
<input type='hidden' name='thread_id' value='$thread_parent' />
</p>
</form>";
2006-12-02 04:36:16 +00:00
}
else
{
$QUICKREPLY = $forum_quickreply;
}
}
$forend = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMEND);
2008-12-04 21:36:09 +00:00
$forumstring = $forstr . $forthr . $forrep . $forend;
2006-12-02 04:36:16 +00:00
2008-12-08 02:33:34 +00:00
require_once (HEADERF);
2008-12-02 21:34:18 +00:00
//If last post came after USERLV and not yet marked as read, mark the thread id as read
2008-12-04 21:36:09 +00:00
if ($thread->threadInfo['thread_lastpost'] > USERLV && (strpos($currentUser['user_plugin_forum_viewed'], '.' . $thread->threadId . '.') === false))
2008-12-02 21:34:18 +00:00
{
2008-12-04 21:36:09 +00:00
$tst = $forum->threadMarkAsRead($thread->threadId);
2006-12-02 04:36:16 +00:00
}
2008-12-01 21:11:01 +00:00
if ($pref['forum_enclose'])
{
2006-12-02 04:36:16 +00:00
$ns->tablerender(LAN_01, $forumstring, array('forum_viewtopic', 'main'));
2008-12-01 21:11:01 +00:00
}
else
{
2006-12-02 04:36:16 +00:00
echo $forumstring;
}
// end -------------------------------------------------------------------------------------------------------------------------------------------------------------------
echo "<script type=\"text/javascript\">
function confirm_(mode, forum_id, thread_id, thread) {
2008-12-11 16:02:05 +00:00
if (mode == 'Thread') {
2008-12-04 21:36:09 +00:00
return confirm(\"" . $tp->toJS(LAN_409) . "\");
2006-12-02 04:36:16 +00:00
} else {
2008-12-04 21:36:09 +00:00
return confirm(\"" . $tp->toJS(LAN_410) . " [ " . $tp->toJS(LAN_411) . "\" + thread + \" ]\");
2006-12-02 04:36:16 +00:00
}
}
</script>";
2008-12-04 21:36:09 +00:00
require_once (FOOTERF);
2006-12-02 04:36:16 +00:00
function showmodoptions()
{
2008-12-11 16:02:05 +00:00
global $thread, $postInfo;
// var_dump($thread);
// var_dump($postInfo);
$e107 = e107::getInstance();
$forum_id = $thread->threadInfo['forum_id'];
if ($postInfo['thread_start'])
2006-12-02 04:36:16 +00:00
{
2008-12-11 16:02:05 +00:00
$type = 'Thread';
$ret = "<form method='post' action='" . $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $postInfo['post_thread']))."' id='frmMod_{$postInfo['post_forum']}_{$postInfo['post_thread']}'>";
$delId = $postInfo['post_thread'];
2006-12-02 04:36:16 +00:00
}
else
{
2008-12-11 16:02:05 +00:00
$type = 'Post';
$ret = "<form method='post' action='" . e_SELF . '?' . e_QUERY . "' id='frmMod_{$postInfo['post_forum']}_{$postInfo['post_thread']}'>";
$delId = $postInfo['post_id'];
2006-12-02 04:36:16 +00:00
}
$ret .= "
<div>
2008-12-11 16:02:05 +00:00
<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'edit', 'id' => $postInfo['post_id']))."'>" . IMAGE_admin_edit . "</a>
<input type='image' " . IMAGE_admin_delete . " name='delete{$type}_{$delId}' value='thread_action' onclick=\"return confirm_('{$type}', {$postInfo['post_forum']}, {$postInfo['post_thread']}, '{$postInfo['user_name']}')\" />
<input type='hidden' name='mod' value='1'/>
2006-12-02 04:36:16 +00:00
";
2008-12-11 16:02:05 +00:00
if ($type == 'Thread')
2006-12-02 04:36:16 +00:00
{
2008-12-11 16:02:05 +00:00
$ret .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'move', 'id' => $postInfo['post_id']))."'>" . IMAGE_admin_move2 . "</a>";
2006-12-02 04:36:16 +00:00
}
$ret .= "
</div>
</form>";
return $ret;
}
function forumjump()
{
global $forum;
$jumpList = $forum->forum_get_allowed();
2008-12-04 21:36:09 +00:00
$text = "<form method='post' action='" . e_SELF . "'><p>" . LAN_65 . ": <select name='forumjump' class='tbox'>";
foreach ($jumpList as $key => $val)
2006-12-02 04:36:16 +00:00
{
2008-12-04 21:36:09 +00:00
$text .= "\n<option value='" . $key . "'>" . $val . "</option>";
2006-12-02 04:36:16 +00:00
}
2008-12-04 21:36:09 +00:00
$text .= "</select> <input class='button' type='submit' name='fjsubmit' value='" . LAN_03 . "' />&nbsp;&nbsp;&nbsp;&nbsp;<a href='" . e_SELF . "?" . e_QUERY . "#top' onclick=\"window.scrollTo(0,0);\">" . LAN_10 . "</a></p></form>";
2006-12-02 04:36:16 +00:00
return $text;
}
function rpg($user_join, $user_forums)
{
global $FORUMTHREADSTYLE;
2008-12-04 21:36:09 +00:00
if (strpos($FORUMTHREADSTYLE, '{RPG}') == false)
2006-12-02 04:36:16 +00:00
{
return '';
}
// rpg mod by Ikari ( kilokan1@yahoo.it | http://artemanga.altervista.org )
$lvl_post_mp_cost = 2.5;
$lvl_mp_regen_per_day = 4;
$lvl_avg_ppd = 5;
$lvl_bonus_redux = 5;
2008-12-04 21:36:09 +00:00
$lvl_user_days = max(1, round((time() - $user_join) / 86400));
2006-12-02 04:36:16 +00:00
$lvl_ppd = $user_forums / $lvl_user_days;
2008-12-04 21:36:09 +00:00
if ($user_forums < 1)
{
2006-12-02 04:36:16 +00:00
$lvl_level = 0;
}
2008-12-04 21:36:09 +00:00
else
{
$lvl_level = floor(pow(log10($user_forums), 3)) + 1;
}
if ($lvl_level < 1)
{
2006-12-02 04:36:16 +00:00
$lvl_hp = "0 / 0";
$lvl_hp_percent = 0;
2008-12-04 21:36:09 +00:00
}
else
{
$lvl_max_hp = floor((pow($lvl_level, (1 / 4))) * (pow(10, pow($lvl_level + 2, (1 / 3)))) / (1.5));
2006-12-02 04:36:16 +00:00
2008-12-04 21:36:09 +00:00
if ($lvl_ppd >= $lvl_avg_ppd)
{
$lvl_hp_percent = floor((.5 + (($lvl_ppd - $lvl_avg_ppd) / ($lvl_bonus_redux * 2))) * 100);
}
else
{
$lvl_hp_percent = floor($lvl_ppd / ($lvl_avg_ppd / 50));
2006-12-02 04:36:16 +00:00
}
2008-12-04 21:36:09 +00:00
if ($lvl_hp_percent > 100)
{
$lvl_max_hp += floor(($lvl_hp_percent - 100) * pi());
2006-12-02 04:36:16 +00:00
$lvl_hp_percent = 100;
2008-12-04 21:36:09 +00:00
}
else
{
2006-12-02 04:36:16 +00:00
$lvl_hp_percent = max(0, $lvl_hp_percent);
}
2008-12-04 21:36:09 +00:00
$lvl_cur_hp = floor($lvl_max_hp * ($lvl_hp_percent / 100));
2006-12-02 04:36:16 +00:00
$lvl_cur_hp = max(0, $lvl_cur_hp);
$lvl_cur_hp = min($lvl_max_hp, $lvl_cur_hp);
$lvl_hp = $lvl_cur_hp . '/' . $lvl_max_hp;
}
2008-12-04 21:36:09 +00:00
if ($lvl_level < 1)
{
2006-12-02 04:36:16 +00:00
$lvl_mp = '0 / 0';
$lvl_mp_percent = 0;
2008-12-04 21:36:09 +00:00
}
else
{
$lvl_max_mp = floor((pow($lvl_level, (1 / 4))) * (pow(10, pow($lvl_level + 2, (1 / 3)))) / (pi()));
2006-12-02 04:36:16 +00:00
$lvl_mp_cost = $user_forums * $lvl_post_mp_cost;
$lvl_mp_regen = max(1, $lvl_user_days * $lvl_mp_regen_per_day);
$lvl_cur_mp = floor($lvl_max_mp - $lvl_mp_cost + $lvl_mp_regen);
$lvl_cur_mp = max(0, $lvl_cur_mp);
$lvl_cur_mp = min($lvl_max_mp, $lvl_cur_mp);
$lvl_mp = $lvl_cur_mp . '/' . $lvl_max_mp;
2008-12-04 21:36:09 +00:00
$lvl_mp_percent = floor($lvl_cur_mp / $lvl_max_mp * 100);
2006-12-02 04:36:16 +00:00
}
2008-12-04 21:36:09 +00:00
if ($lvl_level < 1)
{
2006-12-02 04:36:16 +00:00
$lvl_exp = "0 / 0";
$lvl_exp_percent = 100;
2008-12-04 21:36:09 +00:00
}
else
{
$lvl_posts_for_next = floor(pow(10, pow($lvl_level, (1 / 3))));
if ($lvl_level == 1)
{
$lvl_posts_for_this = max(1, floor(pow(10, (($lvl_level - 1)))));
}
else
{
$lvl_posts_for_this = max(1, floor(pow(10, pow(($lvl_level - 1), (1 / 3)))));
2006-12-02 04:36:16 +00:00
}
$lvl_exp = ($user_forums - $lvl_posts_for_this) . "/" . ($lvl_posts_for_next - $lvl_posts_for_this);
2008-12-04 21:36:09 +00:00
$lvl_exp_percent = floor((($user_forums - $lvl_posts_for_this) / max(1, ($lvl_posts_for_next - $lvl_posts_for_this))) * 100);
2006-12-02 04:36:16 +00:00
}
2008-12-04 21:36:09 +00:00
$bar_image = THEME . "images/bar.jpg";
if (!is_readable($bar_image))
2006-12-02 04:36:16 +00:00
{
2008-12-04 21:36:09 +00:00
$bar_image = e_PLUGIN . "forum/images/" . IMODE . "/bar.jpg";
2006-12-02 04:36:16 +00:00
}
$rpg_info .= "<div style='padding:2px; white-space:nowrap'>";
2008-12-04 21:36:09 +00:00
$rpg_info .= "<b>Level = " . $lvl_level . "</b><br />";
$rpg_info .= "HP = " . $lvl_hp . "<br /><img src='{$bar_image}' alt='' style='border:#345487 1px solid; height:10px; width:" . $lvl_hp_percent . "%'><br />";
$rpg_info .= "EXP = " . $lvl_exp . "<br /><img src='{$bar_image}' alt='' style='border:#345487 1px solid; height:10px; width:" . $lvl_exp_percent . "%'><br />";
$rpg_info .= "MP = " . $lvl_mp . "<br /><img src='{$bar_image}' alt='' style='border:#345487 1px solid; height:10px; width:" . $lvl_mp_percent . "%'><br />";
2006-12-02 04:36:16 +00:00
$rpg_info .= "</div>";
return $rpg_info;
}
2008-12-04 21:36:09 +00:00
class e107ForumThread
2008-12-02 21:34:18 +00:00
{
2008-12-04 21:36:09 +00:00
var $message, $threadId, $threadInfo, $forumId, $perPage, $noInc;
function init()
2008-12-02 21:34:18 +00:00
{
2008-12-04 21:36:09 +00:00
global $pref, $forum;
$e107 = e107::getInstance();
$this->threadId = (int)varset($_GET['id']);
$this->perPage = (varset($_GET['perpage']) ? (int)$_GET['perpage'] : $pref['forum_postspage']);
$this->page = (varset($_GET['p']) ? (int)$_GET['p'] : 0);
//If threadId doesn't exist, or not given, redirect to main forum page
if (!$this->threadId || !$this->threadInfo = $forum->threadGet($this->threadId))
2008-12-02 21:34:18 +00:00
{
2008-12-04 21:36:09 +00:00
header('Location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'main')));
2008-12-02 21:34:18 +00:00
exit;
}
2008-12-04 21:36:09 +00:00
//If not permitted to view forum, redirect to main forum page
if (!$forum->checkPerm($this->threadInfo['thread_forum_id'], 'view'))
{
header('Location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
$this->noInc = false;
2008-12-02 21:34:18 +00:00
}
2008-12-08 02:33:34 +00:00
function toggle_track()
{
global $forum, $thread;
$e107 = e107::getInstance();
if (!USER || !isset($_GET['id'])) { return; }
if($thread->threadInfo['track_userid'])
{
$forum->track('del', USERID, $_GET['id']);
$img = IMAGE_untrack;
}
else
{
$forum->track('add', USERID, $_GET['id']);
$img = IMAGE_track;
}
if(e_AJAX_REQUEST)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $thread->threadId));
2008-12-08 02:33:34 +00:00
echo "<a href='{$url}' id='forum-track-trigger'>{$img}</a>";
exit();
}
}
2008-12-04 21:36:09 +00:00
function processFunction()
2008-12-02 21:34:18 +00:00
{
2008-12-07 00:21:21 +00:00
global $forum, $thread;
2008-12-04 21:36:09 +00:00
$e107 = e107::getInstance();
if (!isset($_GET['f']))
2008-12-02 21:34:18 +00:00
{
2008-12-04 21:36:09 +00:00
return;
2008-12-02 21:34:18 +00:00
}
2008-12-04 21:36:09 +00:00
$function = trim($_GET['f']);
switch ($function)
{
case 'post':
if ($thread_id)
{
$post_num = $forum->thread_postnum($thread_id);
$pages = ceil(($post_num['post_num'] + 1) / $pref['forum_postspage']);
$topic_from = ($pages - 1) * $pref['forum_postspage'];
if ($post_num['parent'] != $thread_id)
{
header("location: " . e_SELF . "?{$post_num['parent']}.{$topic_from}#post_{$thread_id}");
exit;
}
}
else
{
header('Location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
break;
2008-12-08 02:33:34 +00:00
/*
2008-12-04 21:36:09 +00:00
case 'track':
2008-12-07 00:21:21 +00:00
if (!USER || !isset($_GET['id'])) { return; }
$forum->track('add', USERID, $_GET['id']);
2008-12-07 00:21:21 +00:00
if(e_AJAX_REQUEST)
2008-12-04 21:36:09 +00:00
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'untrack', 'id' => $thread->threadId));
2008-12-07 00:21:21 +00:00
echo "<a href='{$url}' id='forum-track-trigger'>".IMAGE_untrack."</a>";
exit();
2008-12-04 21:36:09 +00:00
}
break;
case 'untrack':
2008-12-07 00:21:21 +00:00
if (!USER || !isset($_GET['id'])) { return; }
$forum->track('del', USERID, $_GET['id']);
if(e_AJAX_REQUEST)
2008-12-04 21:36:09 +00:00
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'track', 'id' => $thread->threadId));
2008-12-07 00:21:21 +00:00
echo "<a href='{$url}' id='forum-track-trigger'>".IMAGE_track."</a>";
exit();
2008-12-04 21:36:09 +00:00
}
break;
2008-12-08 02:33:34 +00:00
*/
2008-12-07 04:16:39 +00:00
2008-12-04 21:36:09 +00:00
case 'last':
// $pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10);
$pages = ceil(($this->threadInfo['thread_total_replies'] + 1) / $this->perPage);
$this->page = ($pages - 1) * $this->perPage;
break;
case 'next':
$next = $forum->threadGetNextPrev('next', $this->threadId, $this->threadInfo['forum_id'], $this->threadInfo['thread_lastpost']);
if ($next)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $next));
header("location: {$url}");
exit;
}
else
{
$this->message = LAN_405;
}
break;
case 'prev':
$prev = $forum->threadGetNextPrev('prev', $this->threadId, $this->threadInfo['forum_id'], $this->threadInfo['thread_lastpost']);
if ($prev)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $prev));
header("location: {$url}");
exit;
}
else
{
$this->message = LAN_404;
}
break;
case 'report':
$thread_info = $forum->thread_get_postinfo($thread_id, true);
if (isset($_POST['report_thread']))
{
$report_add = $tp->toDB($_POST['report_add']);
if ($pref['reported_post_email'])
{
require_once (e_HANDLER . "mail.php");
$report = LAN_422 . SITENAME . " : " . (substr(SITEURL, -1) == "/" ? SITEURL : SITEURL . "/") . $PLUGINS_DIRECTORY . "forum/forum_viewtopic.php?" . $thread_id . ".post\n" . LAN_425 . USERNAME . "\n" . $report_add;
$subject = LAN_421 . " " . SITENAME;
sendemail(SITEADMINEMAIL, $subject, $report);
}
$sql->db_Insert('generic', "0, 'reported_post', " . time() . ", '" . USERID . "', '{$thread_info['head']['thread_name']}', " . intval($thread_id) . ", '{$report_add}'");
define("e_PAGETITLE", LAN_01 . " / " . LAN_428);
require_once (HEADERF);
$text = LAN_424 . "<br /><br /><a href='forum_viewtopic.php?" . $thread_id . ".post'>" . LAN_429 . "</a";
$ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report'));
}
else
{
$thread_name = $tp->toHTML($thread_info['head']['thread_name'], true, 'no_hook, emotes_off');
define("e_PAGETITLE", LAN_01 . " / " . LAN_426 . " " . $thread_name);
require_once (HEADERF);
$text = "<form action='" . e_PLUGIN . "forum/forum_viewtopic.php?" . e_QUERY . "' method='post'> <table style='width:100%'>
<tr>
<td style='width:50%' >
" . LAN_415 . ": " . $thread_name . " <a href='" . e_PLUGIN . "forum/forum_viewtopic.php?" . $thread_id . ".post'><span class='smalltext'>" . LAN_420 . " </span>
</a>
</td>
<td style='text-align:center;width:50%'>
</td>
</tr>
<tr>
<td>" . LAN_417 . "<br />" . LAN_418 . "
</td>
<td style='text-align:center;'>
<textarea cols='40' rows='10' class='tbox' name='report_add'></textarea>
</td>
</tr>
<tr>
<td colspan='2' style='text-align:center;'><br />
<input class='button' type='submit' name='report_thread' value='" . LAN_419 . "' />
</td>
</tr>
</table>";
$ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report2'));
}
require_once (FOOTERF);
exit;
break;
2008-12-02 21:34:18 +00:00
2008-12-04 21:36:09 +00:00
}
}
2008-12-02 21:34:18 +00:00
}
2006-12-02 04:36:16 +00:00
?>