2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-20 23:59:00 +00:00
* e107 website system
*
2011-01-14 18:29:06 +00:00
* Copyright ( C ) 2008 - 2011 e107 Inc ( e107 . org )
2008-12-20 23:59:00 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
2009-09-08 02:48:48 +00:00
* Forum View Topic
2008-12-20 23:59:00 +00:00
*
2010-03-14 00:50:27 +00:00
* $URL $
* $Id $
2008-12-20 23:59:00 +00:00
*
2006-12-02 04:36:16 +00:00
*/
2008-12-04 21:36:09 +00:00
require_once ( '../../class2.php' );
2011-01-14 18:29:06 +00:00
$e107 = e107 :: getInstance ();
if ( ! $e107 -> isInstalled ( 'forum' ))
{
header ( 'Location: ' . e_BASE . 'index.php' );
exit ;
}
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 ;
}
2008-11-29 01:24:27 +00:00
$highlight_search = isset ( $_POST [ 'highlight_search' ]);
2006-12-02 04:36:16 +00:00
if ( ! e_QUERY )
{
2010-02-01 03:41:59 +00:00
//No parameters 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-01 01:10:50 +00:00
2009-11-19 15:31:59 +00:00
include_lan ( e_PLUGIN . 'forum/languages/' . e_LANGUAGE . '/lan_forum_viewtopic.php' );
2009-09-08 02:00:48 +00:00
include_once ( e_PLUGIN . 'forum/forum_class.php' );
2009-11-19 15:31:59 +00:00
include_once ( e_PLUGIN . 'forum/templates/forum_icons_template.php' );
2008-12-01 01:10:50 +00:00
2009-09-08 02:00:48 +00:00
$forum = new e107forum ;
$thread = new e107ForumThread ;
if ( isset ( $_GET [ 'f' ]) && $_GET [ 'f' ] == 'post' )
{
$thread -> processFunction ();
}
2006-12-02 04:36:16 +00:00
2009-09-08 02:00:48 +00:00
$thread -> init ();
2009-09-06 04:30:46 +00:00
2009-09-08 02:00:48 +00:00
if ( isset ( $_POST [ 'track_toggle' ]))
{
$thread -> toggle_track ();
exit ;
}
if ( isset ( $_GET [ 'f' ]))
{
2010-03-14 19:07:57 +00:00
$ret = $thread -> processFunction ();
if ( $ret ) {
require_once ( HEADERF );
echo $ret ;
require_once ( FOOTERF );
exit ;
}
2009-09-08 02:00:48 +00:00
if ( $_GET [ 'f' ] != 'last' ) { $thread -> init (); }
}
2010-04-25 22:30:26 +00:00
//e107::getScParser();
//require_once (e_PLUGIN . 'forum/forum_shortcodes.php');
//setScVar('forum_shortcodes', 'thread', $thread);
2010-04-26 15:07:30 +00:00
e107 :: getScBatch ( 'view' , 'forum' ) -> setScVar ( 'thread' , $thread );
2009-09-08 02:00:48 +00:00
$pm_installed = plugInstalled ( 'pm' );
2008-12-01 01:10:50 +00:00
2008-12-01 21:11:01 +00:00
//Only increment thread views if not being viewed by thread starter
2009-09-08 02:00:48 +00:00
if ( USER && ( USERID != $thread -> threadInfo [ 'thread_user' ] || $thread -> threadInfo [ 'thread_total_replies' ] > 0 ) || ! $thread -> noInc )
2008-12-01 21:11:01 +00:00
{
2009-09-08 02:00:48 +00:00
$forum -> threadIncview ( $threadId );
2008-12-01 21:11:01 +00:00
}
2009-09-08 02:00:48 +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' ));
2009-01-25 17:44:13 +00:00
$forum -> modArray = $forum -> forumGetMods ( $thread -> threadInfo [ 'forum_moderators' ]);
define ( 'MODERATOR' , ( USER && $forum -> isModerator ( USERID )));
2010-04-25 22:30:26 +00:00
2010-04-26 15:07:30 +00:00
e107 :: getScBatch ( 'view' , 'forum' ) -> setScVar ( 'forum' , $forum );
2010-04-25 22:30:26 +00:00
//var_dump(e107::getScBatch('forum', 'forum'));
//setScVar('forum_shortcodes', 'forum', $forum);
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' );
2009-09-08 02:00:48 +00:00
$thread -> message = forum_thread_moderate ( $_POST );
$thread -> threadInfo = $forum -> threadGet ( $thread -> threadId );
2006-12-02 04:36:16 +00:00
}
2009-09-08 02:00:48 +00:00
$postList = $forum -> PostGet ( $thread -> threadId , $thread -> page * $thread -> perPage , $thread -> perPage );
2008-12-02 21:34:18 +00:00
$gen = new convert ;
2009-09-08 02:00:48 +00:00
if ( $thread -> message )
2006-12-02 04:36:16 +00:00
{
2009-09-08 02:00:48 +00:00
$ns -> tablerender ( '' , $thread -> message , array ( 'forum_viewtopic' , 'msg' ));
2006-12-02 04:36:16 +00:00
}
2009-09-08 02:00:48 +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' );
}
2009-09-08 02:00:48 +00:00
$_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 -------------------------------------------------------------------------------------------------------------------------------------------------------------------
2010-02-01 03:41:59 +00:00
$tVars = new e_vars ;
$forum -> set_crumb ( true , '' , $tVars ); // Set $BREADCRUMB (and BACKLINK)
//$tVars->BREADCRUMB = $crumbs['breadcrumb'];
//$tVars->BACKLINK = $tVars->BREADCRUMB;
//$tVars->FORUM_CRUMB = $crumbs['forum_crumb'];
$tVars -> THREADNAME = $e107 -> tp -> toHTML ( $thread -> threadInfo [ 'thread_name' ], true , 'no_hook, emotes_off' );
$tVars -> NEXTPREV = " << <a href=' " . $e107 -> url -> getUrl ( 'forum' , 'thread' , array ( 'func' => 'prev' , 'id' => $thread -> threadId )) . " '> " . LAN_389 . " </a> " ;
$tVars -> NEXTPREV .= ' | ' ;
$tVars -> NEXTPREV .= " <a href=' " . $e107 -> url -> getUrl ( 'forum' , 'thread' , array ( 'func' => 'next' , 'id' => $thread -> threadId )) . " '> " . LAN_390 . " </a> >> " ;
2006-12-02 04:36:16 +00:00
2010-03-10 01:23:57 +00:00
if ( $forum -> prefs -> get ( 'track' ) && USER )
2006-12-02 04:36:16 +00:00
{
2009-09-08 02:00:48 +00:00
$img = ( $thread -> threadInfo [ 'track_userid' ] ? IMAGE_track : IMAGE_untrack );
$url = $e107 -> url -> getUrl ( 'forum' , 'thread' , array ( 'func' => 'view' , 'id' => $thread -> threadId ));
2010-02-01 03:41:59 +00:00
$tVars -> 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-09 21:46:14 +00:00
$ ( '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
}
2010-02-01 03:41:59 +00:00
$tVars -> MODERATORS = LAN_321 . implode ( ', ' , $forum -> modArray );
2006-12-02 04:36:16 +00:00
2010-02-01 03:41:59 +00:00
$tVars -> THREADSTATUS = ( ! $thread -> threadInfo [ 'thread_active' ] ? LAN_66 : '' );
2008-12-01 21:11:01 +00:00
2009-09-08 02:00:48 +00:00
if ( $thread -> pages > 1 )
2006-12-02 04:36:16 +00:00
{
2009-09-08 02:00:48 +00:00
$parms = ( $thread -> pages ) . " ,1, { $thread -> page } ,url::forum::thread::func=view&id= { $thread -> threadId } &page=[FROM],off " ;
2010-02-01 03:41:59 +00:00
$tVars -> GOTOPAGES = $tp -> parseTemplate ( " { NEXTPREV= { $parms } } " );
2006-12-02 04:36:16 +00:00
}
2010-02-01 03:41:59 +00:00
$tVars -> BUTTONS = '' ;
2009-09-08 02:00:48 +00:00
if ( $forum -> checkPerm ( $thread -> threadInfo [ 'thread_forum_id' ], 'post' ) && $thread -> threadInfo [ 'thread_active' ])
2006-12-02 04:36:16 +00:00
{
2010-02-01 03:41:59 +00:00
$tVars -> 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
}
2009-09-08 02:00:48 +00:00
if ( $forum -> checkPerm ( $thread -> threadInfo [ 'thread_forum_id' ], 'thread' ))
2008-12-01 21:11:01 +00:00
{
2010-02-01 03:41:59 +00:00
$tVars -> 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
}
2010-02-01 03:41:59 +00:00
$tVars -> POLL = $pollstr ;
2009-09-08 02:00:48 +00:00
2010-02-01 03:41:59 +00:00
$tVars -> FORUMJUMP = forumjump ();
2006-12-02 04:36:16 +00:00
2010-02-01 03:41:59 +00:00
$forstr = $tp -> simpleParse ( $FORUMSTART , $tVars );
2006-12-02 04:36:16 +00:00
2009-09-08 02:00:48 +00:00
unset ( $forrep );
if ( ! $FORUMREPLYSTYLE ) $FORUMREPLYSTYLE = $FORUMTHREADSTYLE ;
$alt = false ;
2008-12-01 21:11:01 +00:00
2009-09-08 02:00:48 +00:00
$i = $thread -> page ;
foreach ( $postList as $postInfo )
{
if ( $postInfo [ 'post_options' ])
{
$postInfo [ 'post_options' ] = unserialize ( $postInfo [ 'post_options' ]);
}
$loop_uid = ( int ) $postInfo [ 'post_user' ];
$i ++ ;
//TODO: Look into fixing this, to limit to a single query per pageload
$e_hide_query = " SELECT post_id FROM `#forum_post` WHERE (`post_thread` = { $threadId } AND post_user= " . USERID . ' LIMIT 1' ;
$e_hide_hidden = FORLAN_HIDDEN ;
$e_hide_allowed = USER ;
if ( $i > 1 )
{
$postInfo [ 'thread_start' ] = false ;
$alt = ! $alt ;
if ( $postInfo [ 'post_status' ])
{
$_style = ( isset ( $FORUMDELETEDSTYLE_ALT ) && $alt ? $FORUMDELETEDSTYLE_ALT : $FORUMDELETEDSTYLE );
}
else
{
$_style = ( isset ( $FORUMREPLYSTYLE_ALT ) && $alt ? $FORUMREPLYSTYLE_ALT : $FORUMREPLYSTYLE );
}
2010-04-25 22:30:26 +00:00
// setScVar('forum_shortcodes', 'postInfo', $postInfo);
2010-04-26 15:07:30 +00:00
e107 :: getScBatch ( 'view' , 'forum' ) -> setScVar ( 'postInfo' , $postInfo );
2009-09-08 02:00:48 +00:00
$forrep .= $e107 -> tp -> parseTemplate ( $_style , true , $forum_shortcodes ) . " \n " ;
}
else
{
$postInfo [ 'thread_start' ] = true ;
2010-04-26 15:07:30 +00:00
e107 :: getScBatch ( 'view' , 'forum' ) -> setScVar ( 'postInfo' , $postInfo );
2009-09-08 02:00:48 +00:00
$forthr = $e107 -> tp -> parseTemplate ( $FORUMTHREADSTYLE , true , $forum_shortcodes ) . " \n " ;
}
}
unset ( $loop_uid );
if ( $forum -> checkPerm ( $thread -> threadInfo [ 'thread_forum_id' ], 'post' ) && $thread -> threadInfo [ 'thread_active' ])
2006-12-02 04:36:16 +00:00
{
if ( ! $forum_quickreply )
{
2010-02-01 03:41:59 +00:00
$tVars -> QUICKREPLY = "
2008-12-04 21:36:09 +00:00
< 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
{
2010-02-01 03:41:59 +00:00
$tVars -> QUICKREPLY = $forum_quickreply ;
2006-12-02 04:36:16 +00:00
}
}
2010-02-01 03:41:59 +00:00
$forend = $tp -> simpleParse ( $FORUMEND , $tVars );
2009-09-08 02:00:48 +00:00
$forumstring = $forstr . $forthr . $forrep . $forend ;
2006-12-02 04:36:16 +00:00
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-15 00:29:20 +00:00
$threadsViewed = explode ( ',' , $currentUser [ 'user_plugin_forum_viewed' ]);
2009-09-08 02:00:48 +00:00
if ( $thread -> threadInfo [ 'thread_lastpost' ] > USERLV && ! in_array ( $thread -> threadId , $threadsViewed ))
2008-12-02 21:34:18 +00:00
{
2009-09-08 02:00:48 +00:00
$tst = $forum -> threadMarkAsRead ( $thread -> threadId );
2006-12-02 04:36:16 +00:00
}
2008-12-17 04:22:37 +00:00
require_once ( HEADERF );
2010-03-10 01:23:57 +00:00
if ( $forum -> prefs -> get ( 'enclose' ))
2008-12-01 21:11:01 +00:00
{
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
2009-09-08 02:00:48 +00:00
function showmodoptions ()
{
global $thread , $postInfo ;
$e107 = e107 :: getInstance ();
$forum_id = $thread -> threadInfo [ 'forum_id' ];
if ( $postInfo [ 'thread_start' ])
{
$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' ];
}
else
{
$type = 'Post' ;
$ret = " <form method='post' action=' " . e_SELF . '?' . e_QUERY . " ' id='frmMod_ { $postInfo [ 'post_forum' ] } _ { $postInfo [ 'post_thread' ] } '> " ;
$delId = $postInfo [ 'post_id' ];
}
$ret .= "
< div >
< 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' />
" ;
if ( $type == 'Thread' )
{
$ret .= " <a href=' " . $e107 -> url -> getUrl ( 'forum' , 'thread' , array ( 'func' => 'move' , 'id' => $postInfo [ 'post_id' ])) . " '> " . IMAGE_admin_move2 . " </a> " ;
}
else
{
$ret .= " <a href=' " . $e107 -> url -> getUrl ( 'forum' , 'thread' , array ( 'func' => 'split' , 'id' => $postInfo [ 'post_id' ])) . " '> " . IMAGE_admin_split . '</a>' ;
}
$ret .= "
</ div >
</ form > " ;
return $ret ;
}
2006-12-02 04:36:16 +00:00
function forumjump ()
{
global $forum ;
2008-12-18 14:08:33 +00:00
$jumpList = $forum -> forumGetAllowed ();
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 . " ' /> <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-18 14:08:33 +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 ;
}
2009-09-08 02:00:48 +00:00
class e107ForumThread
{
var $message , $threadId , $forumId , $perPage , $noInc , $pages ;
function init ()
{
2010-03-10 01:23:57 +00:00
global $forum ;
2009-09-08 02:00:48 +00:00
$e107 = e107 :: getInstance ();
$this -> threadId = ( int ) varset ( $_GET [ 'id' ]);
2010-03-10 01:23:57 +00:00
$this -> perPage = ( varset ( $_GET [ 'perpage' ]) ? ( int ) $_GET [ 'perpage' ] : $forum -> prefs -> get ( 'postspage' ));
2009-09-08 02:00:48 +00:00
$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 ))
{
header ( 'Location:' . $e107 -> url -> getUrl ( 'forum' , 'forum' , array ( 'func' => 'main' )));
exit ;
}
//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 -> pages = ceil (( $this -> threadInfo [ 'thread_total_replies' ] + 1 ) / $this -> perPage );
$this -> noInc = false ;
}
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 ));
echo " <a href=' { $url } ' id='forum-track-trigger'> { $img } </a> " ;
exit ();
}
}
function processFunction ()
{
2010-03-10 01:23:57 +00:00
global $forum , $thread ;
2009-09-08 02:00:48 +00:00
$e107 = e107 :: getInstance ();
if ( ! isset ( $_GET [ 'f' ]))
{
return ;
}
$function = trim ( $_GET [ 'f' ]);
switch ( $function )
{
case 'post' :
$postId = varset ( $_GET [ 'id' ]);
$postInfo = $forum -> postGet ( $postId , 'post' );
$postNum = $forum -> postGetPostNum ( $postInfo [ 'post_thread' ], $postId );
2010-03-10 01:23:57 +00:00
$postPage = ceil ( $postNum / $forum -> prefs -> get ( 'postspage' )) - 1 ;
2009-09-08 02:00:48 +00:00
$url = $e107 -> url -> getUrl ( 'forum' , 'thread' , " func=view&id= { $postInfo [ 'post_thread' ] } &page= $postPage " );
header ( 'location: ' . $url );
exit ;
break ;
case 'last' :
$pages = ceil (( $thread -> threadInfo [ 'thread_total_replies' ] + 1 ) / $thread -> perPage );
$thread -> page = ( $pages - 1 );
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 ;
}
$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 ;
}
$this -> message = LAN_404 ;
break ;
case 'report' :
2010-03-14 19:07:57 +00:00
$threadId = ( int ) $_GET [ 'id' ];
$postId = ( int ) $_GET [ 'post' ];
2009-09-08 02:00:48 +00:00
$postInfo = $forum -> postGet ( $postId , 'post' );
if ( isset ( $_POST [ 'report_thread' ]))
{
$report_add = $e107 -> tp -> toDB ( $_POST [ 'report_add' ]);
2010-03-10 01:23:57 +00:00
if ( $forum -> prefs -> get ( 'reported_post_email' ))
2009-09-08 02:00:48 +00:00
{
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 );
}
$e107 -> 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 );
2010-03-14 19:07:57 +00:00
$url = $e107 -> url -> getUrl ( 'forum' , 'thread' , 'func=post&id=' . $postId );
$text = LAN_424 . " <br /><br /><a href=' { $url } '> " . LAN_429 . '</a>' ;
return $e107 -> ns -> tablerender ( LAN_414 , $text , array ( 'forum_viewtopic' , 'report' ), true );
2009-09-08 02:00:48 +00:00
}
else
{
$thread_name = $e107 -> tp -> toHTML ( $postInfo [ 'thread_name' ], true , 'no_hook, emotes_off' );
define ( 'e_PAGETITLE' , LAN_01 . ' / ' . LAN_426 . ' ' . $thread_name );
$url = $e107 -> url -> getUrl ( 'forum' , 'thread' , 'func=post&id=' . $postId );
2010-03-14 19:07:57 +00:00
$actionUrl = $e107 -> url -> getUrl ( 'forum' , 'thread' , " func=report&id= { $threadId } &post= { $postId } " );
2009-09-08 02:00:48 +00:00
$text = " <form action=' " . $actionUrl . " ' method='post'>
< table style = 'width:100%' >
< tr >
< td style = 'width:50%' >
" . LAN_415 . ': ' . $thread_name . " < a href = '".$url."' >< 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 >
2010-03-14 19:07:57 +00:00
</ tr >
< tr >
2009-09-08 02:00:48 +00:00
< 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 > " ;
2010-03-14 19:07:57 +00:00
return $e107 -> ns -> tablerender ( LAN_414 , $text , array ( 'forum_viewtopic' , 'report2' ), true );
2009-09-08 02:00:48 +00:00
}
2010-03-14 19:07:57 +00:00
// require_once (FOOTERF);
2009-09-08 02:00:48 +00:00
exit ;
break ;
}
}
}
?>