2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-20 23:59:00 +00:00
* e107 website system
*
2014-08-04 12:24:35 +02:00
* Copyright ( C ) 2008 - 2014 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
*
2006-12-02 04:36:16 +00:00
*/
2015-04-25 12:57:00 -07:00
if ( ! defined ( 'e107_INIT' ))
{
require_once ( '../../class2.php' );
}
2015-08-22 16:40:38 +02:00
e107 :: lan ( 'forum' , " front " , true );
2016-01-13 18:07:05 -08:00
if ( ! deftrue ( 'BOOTSTRAP' ))
{
$bcDefs = array (
'LAN_413' => 'LAN_FORUM_2046' ,
'LAN_400' => 'LAN_EDIT' ,
'LAN_401' => 'LAN_FORUM_2041' ,
'LAN_406' => 'LAN_EDIT' ,
'LAN_435' => 'LAN_DELETE' ,
'LAN_397' => 'LAN_FORUM_2044' ,
'LAN_398' => 'LAN_FORUM_4007'
);
e107 :: getLanguage () -> bcDefs ( $bcDefs );
}
2013-05-17 16:43:14 -07:00
define ( 'NAVIGATION_ACTIVE' , 'forum' );
2014-08-04 12:24:35 +02:00
2011-01-14 18:29:06 +00:00
$e107 = e107 :: getInstance ();
2011-04-21 13:20:22 +00:00
$tp = e107 :: getParser ();
2011-04-25 11:29:21 +00:00
$ns = e107 :: getRender ();
2011-04-21 13:20:22 +00:00
2016-01-13 18:07:05 -08:00
if ( ! e107 :: isInstalled ( 'forum' ))
2011-01-14 18:29:06 +00:00
{
2016-01-13 19:17:37 -08:00
e107 :: redirect ();
2011-01-14 18:29:06 +00:00
exit ;
}
2006-12-02 04:36:16 +00:00
2016-06-14 13:34:52 +01:00
//---- orphan $highlight_search??????
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
2015-05-22 15:37:46 -07:00
$url = e107 :: url ( 'forum' , 'index' , 'full' );
e107 :: getRedirect () -> go ( $url );
2006-12-02 04:36:16 +00:00
exit ;
}
2008-12-01 01:10:50 +00:00
2014-08-04 12:24:35 +02:00
include_once ( e_PLUGIN . 'forum/forum_class.php' );
2008-12-01 01:10:50 +00:00
2011-04-25 11:29:21 +00:00
$forum = new e107forum ();
$thread = new e107ForumThread ();
2009-09-08 02:00:48 +00:00
2014-08-04 12:24:35 +02:00
// check if user wants to download a file
2013-03-31 00:06:21 -07:00
if ( vartrue ( $_GET [ 'id' ]) && isset ( $_GET [ 'dl' ]))
{
$forum -> sendFile ( $_GET );
exit ;
}
2016-01-31 14:39:41 -08:00
if ( e_AJAX_REQUEST )
2013-03-14 02:26:47 -07:00
{
2016-01-31 14:39:41 -08:00
if ( varset ( $_POST [ 'action' ]) == 'quickreply' )
{
$forum -> ajaxQuickReply ();
}
if ( varset ( $_POST [ 'action' ]) == 'track' )
{
$forum -> ajaxTrack ();
}
if ( MODERATOR )
{
$forum -> ajaxModerate ();
}
2013-03-14 02:26:47 -07:00
}
2016-01-31 14:39:41 -08:00
2013-03-14 02:26:47 -07:00
2011-04-25 14:13:45 +00:00
if ( isset ( $_GET [ 'last' ]))
{
$_GET [ 'f' ] = 'last' ;
}
2009-09-08 02:00:48 +00:00
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
2016-01-31 14:39:41 -08:00
/*
2009-09-08 02:00:48 +00:00
if ( isset ( $_POST [ 'track_toggle' ]))
{
$thread -> toggle_track ();
exit ;
2016-01-31 14:39:41 -08:00
} */
2009-09-08 02:00:48 +00:00
2015-04-13 19:38:25 -07:00
if ( ! empty ( $_GET [ 'f' ]))
2009-09-08 02:00:48 +00:00
{
2015-04-13 19:38:25 -07:00
$retext = $thread -> processFunction ();
if ( $retext )
{
2010-03-14 19:07:57 +00:00
require_once ( HEADERF );
2015-04-13 19:38:25 -07:00
// e107::getMessage()->addWarning($retext);
// echo e107::getmessage()->render();
echo $retext ;
2010-03-14 19:07:57 +00:00
require_once ( FOOTERF );
exit ;
}
2015-04-13 19:38:25 -07:00
2009-09-08 02:00:48 +00:00
if ( $_GET [ 'f' ] != 'last' ) { $thread -> init (); }
}
2010-04-25 22:30:26 +00:00
2012-11-02 01:50:28 +00:00
2016-06-14 13:34:52 +01:00
//---- getScBatch here??????
2010-04-26 15:07:30 +00:00
e107 :: getScBatch ( 'view' , 'forum' ) -> setScVar ( 'thread' , $thread );
2009-09-08 02:00:48 +00:00
2016-06-14 13:34:52 +01:00
//---- orphan $pm_installed??????
2015-02-07 13:38:29 -08:00
$pm_installed = e107 :: isInstalled ( '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
{
2011-04-26 11:27:36 +00:00
$forum -> threadIncview ( $thread -> threadInfo [ 'thread_id' ]);
2008-12-01 21:11:01 +00:00
}
2013-06-12 21:37:54 +02:00
define ( 'e_PAGETITLE' , strip_tags ( $tp -> toHTML ( $thread -> threadInfo [ 'thread_name' ], true , 'no_hook, emotes_off' )) . ' / ' . $tp -> toHTML ( $thread -> threadInfo [ 'forum_name' ], true , 'no_hook, emotes_off' ) . ' / ' . LAN_FORUM_1001 );
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'));
2012-11-02 01:50:28 +00:00
2014-08-04 12:24:35 +02:00
if ( MODERATOR && isset ( $_POST [ 'mod' ]))
2006-12-02 04:36:16 +00:00
{
2013-06-12 21:37:54 +02: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
}
2011-06-28 12:14:45 +00:00
$num = $thread -> page ? $thread -> page - 1 : 0 ;
$postList = $forum -> PostGet ( $thread -> threadId , $num * $thread -> perPage , $thread -> perPage );
2008-12-02 21:34:18 +00:00
2011-06-28 12:58:26 +00:00
// SEO - meta description (auto)
if ( count ( $postList ))
{
define ( " META_DESCRIPTION " , $tp -> text_truncate (
str_replace (
array ( '"' , " ' " ), '' , strip_tags ( $tp -> toHTML ( $postList [ 0 ][ 'post_entry' ]))
), 250 , '...' ));
}
2016-06-14 13:34:52 +01:00
//---- Orphan $gen????
2008-12-02 21:34:18 +00:00
$gen = new convert ;
2014-08-04 12:24:35 +02:00
if ( $thread -> message )
2006-12-02 04:36:16 +00:00
{
2011-06-28 12:14:45 +00:00
//$ns->tablerender('', $thread->message, array('forum_viewtopic', 'msg'));
e107 :: getMessage () -> add ( $thread -> message );
2006-12-02 04:36:16 +00:00
}
2013-03-25 23:00:32 -07:00
//if (isset($thread->threadInfo['thread_options']['poll'])) //XXX Currently Failing - misconfigured thread-options.
//{
2014-05-26 12:15:30 +02:00
if ( e107 :: isInstalled ( 'poll' ))
{
2016-03-23 16:43:41 -07:00
$_qry = 'SELECT p.*, u.user_id, u.user_name FROM `#polls` AS p LEFT JOIN `#user` AS u ON p.poll_admin_id = u.user_id WHERE p.poll_datestamp = ' . $thread -> threadId ;
2013-03-25 23:00:32 -07:00
if ( $sql -> gen ( $_qry ))
2008-12-04 21:36:09 +00:00
{
2013-03-25 23:00:32 -07:00
if ( ! defined ( 'POLLCLASS' ))
{
include_once ( e_PLUGIN . 'poll/poll_class.php' );
}
$poll = new poll ;
$pollstr = " <div class='spacer'> " . $poll -> render_poll ( $_qry , 'forum' , 'query' , true ) . '</div>' ;
2008-12-04 21:36:09 +00:00
}
2014-05-26 12:15:30 +02:00
}
2013-03-25 23:00:32 -07:00
//}
2014-08-04 12:24:35 +02:00
2006-12-02 04:36:16 +00:00
//Load forum templates
2011-04-25 11:29:21 +00:00
// FIXME - new template paths!
2014-08-04 12:24:35 +02:00
if ( file_exists ( THEME . 'forum_design.php' )) // legacy file
2008-12-04 21:36:09 +00:00
{
2014-08-04 12:24:35 +02:00
include_once ( THEME . 'forum_design.php' );
2008-12-04 21:36:09 +00:00
}
2014-08-04 12:24:35 +02:00
2006-12-02 04:36:16 +00:00
2013-03-12 04:22:09 -07:00
// New in v2.x
2016-04-05 13:15:58 -07:00
if ( deftrue ( 'BOOTSTRAP' , false ))
2013-03-12 04:22:09 -07:00
{
2016-04-05 13:15:58 -07:00
$FORUM_VIEWTOPIC_TEMPLATE = e107 :: getTemplate ( 'forum' , 'forum_viewtopic' );
// print_a($FORUM_VIEWTOPIC_TEMPLATE);
2016-11-16 20:52:53 +00:00
$FORUMCAPTION = $FORUM_VIEWTOPIC_TEMPLATE [ 'caption' ];
2013-03-13 02:39:00 -07:00
$FORUMSTART = $FORUM_VIEWTOPIC_TEMPLATE [ 'start' ];
$FORUMTHREADSTYLE = $FORUM_VIEWTOPIC_TEMPLATE [ 'thread' ];
$FORUMEND = $FORUM_VIEWTOPIC_TEMPLATE [ 'end' ];
2016-03-26 15:17:11 -07:00
$FORUMREPLYSTYLE = $FORUM_VIEWTOPIC_TEMPLATE [ 'replies' ];
$FORUMDELETEDSTYLE = $FORUM_VIEWTOPIC_TEMPLATE [ 'deleted' ];
2013-03-12 04:22:09 -07:00
}
2016-04-05 13:15:58 -07:00
else
{
if ( ! vartrue ( $FORUMSTART ))
{
if ( file_exists ( THEME . 'forum_viewtopic_template.php' ))
{
require_once ( THEME . 'forum_viewtopic_template.php' );
}
elseif ( file_exists ( THEME . 'templates/forum/forum_viewtopic_template.php' ))
{
require_once ( THEME . 'templates/forum/forum_viewtopic_template.php' );
}
elseif ( file_exists ( THEME . 'forum_template.php' ))
{
require_once ( THEME . 'forum_template.php' );
}
else
{
require_once ( e_PLUGIN . 'forum/templates/forum_viewtopic_template.php' );
}
}
}
2013-03-12 04:22:09 -07:00
2015-05-26 12:00:43 -07:00
//TODO Clean up this mess!!
2013-03-12 04:22:09 -07:00
2006-12-02 04:36:16 +00:00
// get info for main thread -------------------------------------------------------------------------------------------------------------------------------------------------------------------
2016-06-14 13:34:52 +01:00
//---- Moved here to enclose $tVars.....
$sc = e107 :: getScBatch ( 'view' , 'forum' );
//---- $tVars = new e_vars;
//---- $forum->set_crumb(true, '', $tVars); // Set $BREADCRUMB (and BACKLINK)
$forum -> set_crumb ( true , '' , $thread -> threadInfo ); // Set $BREADCRUMB (and BACKLINK)
2010-02-01 03:41:59 +00:00
//$tVars->BREADCRUMB = $crumbs['breadcrumb'];
//$tVars->BACKLINK = $tVars->BREADCRUMB;
//$tVars->FORUM_CRUMB = $crumbs['forum_crumb'];
2016-06-14 13:34:52 +01:00
//---- $tVars->THREADNAME = $tp->toHTML($thread->threadInfo['thread_name'], true, 'no_hook, emotes_off');
2015-05-26 12:00:43 -07:00
2016-06-14 13:34:52 +01:00
/*----
2015-05-26 12:00:43 -07:00
$prev = $forum -> threadGetNextPrev ( 'prev' , $thread -> threadId , $thread -> threadInfo [ 'forum_id' ], $thread -> threadInfo [ 'thread_lastpost' ]);
$next = $forum -> threadGetNextPrev ( 'next' , $thread -> threadId , $thread -> threadInfo [ 'forum_id' ], $thread -> threadInfo [ 'thread_lastpost' ]);
$options = array ();
if ( $prev !== false )
{
$options [] = " <a class='btn btn-default btn-sm btn-small' href=' " . e107 :: url ( 'forum' , 'topic' , $prev ) . " '>« " . LAN_FORUM_2001 . " </a> " ;
}
if ( $next !== false )
{
$options [] = " <a class='btn btn-default btn-sm btn-small' href=' " . e107 :: url ( 'forum' , 'topic' , $next ) . " '> " . LAN_FORUM_2002 . " »</a> " ;
}
$tVars -> NEXTPREV = implode ( " | " , $options );
2016-06-14 13:34:52 +01:00
----*/
2015-05-26 12:00:43 -07:00
/*
2015-03-28 14:10:28 -07:00
$tVars -> NEXTPREV = " <a class='btn btn-default btn-sm btn-small' href=' " . $e107 -> url -> create ( 'forum/thread/prev' , array ( 'id' => $thread -> threadId )) . " '>« " . LAN_FORUM_2001 . " </a> " ;
2013-06-12 21:37:54 +02:00
$tVars -> NEXTPREV .= ' | ' ; // enabled to make it look better on v1 templates
2015-03-28 14:10:28 -07:00
$tVars -> NEXTPREV .= " <a class='btn btn-default btn-sm btn-small' href=' " . $e107 -> url -> create ( 'forum/thread/prev' , array ( 'id' => $thread -> threadId )) . " '> " . LAN_FORUM_2002 . " »</a> " ;
2015-05-26 12:00:43 -07:00
*/
2006-12-02 04:36:16 +00:00
2016-06-14 13:34:52 +01:00
/*----
2010-03-10 01:23:57 +00:00
if ( $forum -> prefs -> get ( 'track' ) && USER )
2006-12-02 04:36:16 +00:00
{
2016-03-26 11:41:52 -07:00
// BC Fix for old template.
if ( ! defined ( 'IMAGE_track' ))
{
define ( 'IMAGE_track' , '<img src="' . img_path ( 'track.png' ) . '" alt="' . LAN_FORUM_4009 . '" title="' . LAN_FORUM_4009 . '" class="icon S16 action" />' );
}
if ( ! defined ( 'IMAGE_untrack' ))
{
define ( 'IMAGE_untrack' , '<img src="' . img_path ( 'untrack.png' ) . '" alt="' . LAN_FORUM_4010 . '" title="' . LAN_FORUM_4010 . '" class="icon S16 action" />' );
}
2009-09-08 02:00:48 +00:00
$img = ( $thread -> threadInfo [ 'track_userid' ] ? IMAGE_track : IMAGE_untrack );
2016-01-31 14:39:41 -08:00
2016-03-26 11:41:52 -07:00
2016-01-31 14:39:41 -08:00
/*
2011-11-28 14:19:19 +00:00
$url = $e107 -> url -> create ( 'forum/thread/view' , array ( 'id' => $thread -> threadId ), 'encode=0' ); // encoding could break AJAX call
2016-01-31 14:39:41 -08:00
$url = e107 :: url ( 'forum' , 'index' );
$tVars -> TRACK .= "
2008-12-07 00:21:21 +00:00
< span id = 'forum-track-trigger-container' >
2016-01-31 14:39:41 -08:00
< a class = 'btn btn-default btn-sm btn-small e-ajax' data - target = 'forum-track-trigger' 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 >
2016-01-13 18:07:05 -08:00
" ;*/
2016-04-05 11:21:53 -07:00
2016-06-14 13:34:52 +01:00
/*----
2016-04-05 11:21:53 -07:00
$trackDiz = ( $forum -> prefs -> get ( 'trackemail' , true )) ? LAN_FORUM_3040 : LAN_FORUM_3041 ;
$tVars -> TRACK = " <a id='forum-track-button' href='#' title= \" " . $trackDiz . " \" data-token=' " . deftrue ( 'e_TOKEN' , '' ) . " ' data-forum-insert='forum-track-button' data-forum-post=' " . $thread -> threadInfo [ 'thread_forum_id' ] . " ' data-forum-thread=' " . $thread -> threadInfo [ 'thread_id' ] . " ' data-forum-action='track' name='track' class='e-tip btn btn-default' > " . $img . " </a>
2016-01-31 14:39:41 -08:00
" ;
2006-12-02 04:36:16 +00:00
}
2016-06-14 13:34:52 +01:00
----*/
2006-12-02 04:36:16 +00:00
2016-06-14 13:34:52 +01:00
/*----
2016-02-28 13:08:43 -08:00
$modUser = array ();
foreach ( $forum -> modArray as $user )
{
$modUser [] = " <a href=' " . e107 :: getUrl () -> create ( 'user/profile/view' , $user ) . " '> " . $user [ 'user_name' ] . " </a> " ;
}
2013-03-12 04:22:09 -07:00
2016-02-28 13:08:43 -08:00
$tVars -> MODERATORS = LAN_FORUM_2003 . " : " . implode ( ', ' , $modUser );
unset ( $modUser );
2016-06-14 13:34:52 +01:00
----*/
2006-12-02 04:36:16 +00:00
2016-06-14 13:34:52 +01:00
//---- $tVars->THREADSTATUS = (!$thread->threadInfo['thread_active'] ? LAN_FORUM_2004 : '');
2008-12-01 21:11:01 +00:00
2016-06-14 13:34:52 +01:00
/*----
2009-09-08 02:00:48 +00:00
if ( $thread -> pages > 1 )
2006-12-02 04:36:16 +00:00
{
2011-04-21 13:20:22 +00:00
if ( ! $thread -> page ) $thread -> page = 1 ;
2015-04-25 12:57:00 -07:00
// $url = rawurlencode(e107::getUrl()->create('forum/thread/view', array('name' => $thread->threadInfo['thread_name'], 'id' => $thread->threadId, 'page' => '[FROM]')));
2015-05-09 13:22:27 -07:00
// $url = e_REQUEST_SELF."?p=[FROM]"; // SEF URL Friendly.
$url = e107 :: url ( 'forum' , 'topic' , $thread -> threadInfo ) . " &p=[FROM] " ;
$parms = " total= { $thread -> pages } &type=page¤t= { $thread -> page } &url= " . urlencode ( $url ) . " &caption=off&tmpl=default&navcount=4&glyphs=1 " ;
2013-03-13 02:57:31 -07:00
//XXX FIXME - pull-down template not practical here. Can we force another?
2015-05-07 11:49:36 -07:00
2010-02-01 03:41:59 +00:00
$tVars -> GOTOPAGES = $tp -> parseTemplate ( " { NEXTPREV= { $parms } } " );
2011-04-21 13:20:22 +00:00
/*
$parms = ( $thread -> pages ) . " ,1, { $thread -> page } ,url::forum::thread::func=view&id= { $thread -> threadId } &page=[FROM],off " ;
2016-06-14 13:34:52 +01:00
$tVars -> GOTOPAGES = $tp -> parseTemplate ( " { NEXTPREV= { $parms } } " );
2006-12-02 04:36:16 +00:00
}
2016-06-14 13:34:52 +01:00
----*/
2006-12-02 04:36:16 +00:00
2016-06-14 13:34:52 +01: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
{
2015-05-22 15:37:46 -07:00
// print_a($thread->threadInfo);
$url = e107 :: url ( 'forum' , 'post' ) . " ?f=rp&id= " . $thread -> threadInfo [ 'thread_id' ] . " &post= " . $thread -> threadId ;
// $url = $e107->url->create('forum/thread/reply', array('id' => $thread->threadId));
$tVars -> BUTTONS .= " <a href=' " . $url . " '> " . 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
{
2015-05-22 15:37:46 -07:00
$ntUrl = e107 :: url ( 'forum' , 'post' ) . " ?f=nt&id= " . $thread -> threadInfo [ 'thread_forum_id' ];
// $ntUrl = $e107->url->create('forum/thread/new', array('id' => $thread->threadInfo['thread_forum_id']));
$tVars -> BUTTONS .= " <a href=' " . $ntUrl . " '> " . IMAGE_newthread . " </a> " ;
2006-12-02 04:36:16 +00:00
}
2016-06-14 13:34:52 +01:00
----*/
/*----
2013-03-12 04:22:09 -07:00
$tVars -> BUTTONSX = forumbuttons ( $thread );
function forumbuttons ( $thread )
{
global $forum ;
2015-05-22 15:37:46 -07:00
2013-03-12 04:22:09 -07:00
if ( $forum -> checkPerm ( $thread -> threadInfo [ 'thread_forum_id' ], 'post' ) && $thread -> threadInfo [ 'thread_active' ])
{
2015-05-22 15:37:46 -07:00
$url = e107 :: url ( 'forum' , 'post' ) . " ?f=rp&id= " . $thread -> threadInfo [ 'thread_id' ] . " &post= " . $thread -> threadId ;
// $url = e107::getUrl()->create('forum/thread/reply', array('id' => $thread->threadId));
$replyUrl = " <a class='btn btn-primary' href=' " . $url . " '> " . LAN_FORUM_2006 . " </a> " ;
2013-03-12 04:22:09 -07:00
}
if ( $forum -> checkPerm ( $thread -> threadInfo [ 'thread_forum_id' ], 'thread' ))
{
2015-05-22 15:37:46 -07:00
$ntUrl = e107 :: url ( 'forum' , 'post' ) . " ?f=nt&id= " . $thread -> threadInfo [ 'thread_forum_id' ];
// $ntUrl = e107::getUrl()->create('forum/thread/new', array('id' => $thread->threadInfo['thread_forum_id']));
$options [] = " <a href=' " . $ntUrl . " '> " . LAN_FORUM_2005 . " </a> " ;
2013-03-12 04:22:09 -07:00
}
2015-05-26 12:00:43 -07:00
// $options[] = "<a href='" . e107::getUrl()->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2001."</a>";
// $options[] = "<a href='" . e107::getUrl()->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2002."</a>";
$prev = $forum -> threadGetNextPrev ( 'prev' , $thread -> threadId , $thread -> threadInfo [ 'forum_id' ], $thread -> threadInfo [ 'thread_lastpost' ]);
$next = $forum -> threadGetNextPrev ( 'next' , $thread -> threadId , $thread -> threadInfo [ 'forum_id' ], $thread -> threadInfo [ 'thread_lastpost' ]);
if ( $prev !== false )
{
$options [] = " <a href=' " . e107 :: url ( 'forum' , 'topic' , $prev ) . " '> " . LAN_FORUM_1017 . " " . LAN_FORUM_2001 . " </a> " ;
}
if ( $next !== false )
{
$options [] = " <a href=' " . e107 :: url ( 'forum' , 'topic' , $next ) . " '> " . LAN_FORUM_1017 . " " . LAN_FORUM_2002 . " </a> " ;
}
2013-03-12 04:22:09 -07:00
$text = ' < div class = " btn-group " >
'.$replyUrl.'
< button class = " btn btn-primary dropdown-toggle " data - toggle = " dropdown " >
< span class = " caret " ></ span >
</ button >
2013-04-18 12:43:22 -07:00
< ul class = " dropdown-menu pull-right " >
2013-03-12 04:22:09 -07:00
' ;
foreach ( $options as $key => $val )
{
$text .= '<li>' . $val . '</li>' ;
}
$jumpList = $forum -> forumGetAllowed ();
$text .= " <li class='divider'></li> " ;
foreach ( $jumpList as $key => $val )
{
2015-05-26 12:00:43 -07:00
$text .= '<li><a href ="' . e107 :: url ( 'forum' , 'forum' , $val ) . '">' . LAN_FORUM_1017 . " " . $val [ 'forum_name' ] . '</a></li>' ;
2013-03-12 04:22:09 -07:00
}
$text .= '
</ ul >
</ div > ' ;
return $text ;
}
2016-06-14 13:34:52 +01:00
----*/
2013-03-12 04:22:09 -07:00
2016-06-14 13:34:52 +01:00
//---- $tVars->POLL = vartrue($pollstr);
2013-03-12 04:22:09 -07:00
2016-06-14 13:34:52 +01:00
//---- $tVars->FORUMJUMP = forumjump();
2006-12-02 04:36:16 +00:00
2016-06-14 13:34:52 +01:00
//---- $tVars->MESSAGE = $thread->message;
2011-06-28 12:14:45 +00:00
2016-06-14 13:34:52 +01:00
$sc -> setVars ( $thread -> threadInfo );
//$forum->set_crumb(true, '', $sc); // Set $BREADCRUMB (and BACKLINK)
2013-03-12 04:22:09 -07:00
2016-06-14 13:34:52 +01:00
//---- $forstr = $tp->simpleParse($FORUMSTART, $tVars);
$forstr = $tp -> parseTemplate ( $FORUMSTART , true , $sc );
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 ;
2016-04-05 13:15:58 -07:00
2016-06-14 13:34:52 +01:00
//---- Moved upwards, to enclose $tVars...
//---- $sc = e107::getScBatch('view', 'forum');
2016-04-05 13:15:58 -07:00
2016-06-30 14:56:30 +01:00
$mes = e107 :: getMessage ();
// $sc->setVars($thread->threadInfo);
//--->$forend = $tp->simpleParse($FORUMEND, $tVars);
$forend = $tp -> parseTemplate ( $FORUMEND , true , $sc );
2016-05-04 09:13:46 -07:00
foreach ( $postList as $c => $postInfo )
2009-09-08 02:00:48 +00:00
{
if ( $postInfo [ 'post_options' ])
{
$postInfo [ 'post_options' ] = unserialize ( $postInfo [ 'post_options' ]);
}
$loop_uid = ( int ) $postInfo [ 'post_user' ];
2016-05-04 09:13:46 -07:00
2016-06-14 13:34:52 +01:00
//---- Orphan $tnum????
2011-06-27 09:23:34 +00:00
$tnum = $i ;
2016-05-04 09:13:46 -07:00
2009-09-08 02:00:48 +00:00
$i ++ ;
//TODO: Look into fixing this, to limit to a single query per pageload
2011-06-27 09:23:34 +00:00
$threadId = $thread -> threadInfo [ 'thread_id' ];
2009-09-08 02:00:48 +00:00
$e_hide_query = " SELECT post_id FROM `#forum_post` WHERE (`post_thread` = { $threadId } AND post_user= " . USERID . ' LIMIT 1' ;
2013-06-12 21:37:54 +02:00
$e_hide_hidden = LAN_FORUM_2008 ;
2009-09-08 02:00:48 +00:00
$e_hide_allowed = USER ;
2016-05-04 09:13:46 -07:00
$sc -> wrapper ( 'forum_viewtopic/replies' ); // default.
if ( $thread -> page == 1 && $c == 0 )
2009-09-08 02:00:48 +00:00
{
2016-05-04 09:13:46 -07:00
$postInfo [ 'thread_start' ] = true ;
$sc -> setScVar ( 'postInfo' , $postInfo );
$sc -> setVars ( $postInfo ); // compatibility
$sc -> wrapper ( 'forum_viewtopic/thread' );
// $forum_shortcodes = e107::getScBatch('view', 'forum')->setScVar('postInfo', $postInfo)->wrapper('forum/viewtopic');
$forthr = $tp -> parseTemplate ( $FORUMTHREADSTYLE , true , $sc ) . " \n " ;
}
else
{
2009-09-08 02:00:48 +00:00
$postInfo [ 'thread_start' ] = false ;
$alt = ! $alt ;
2016-04-05 13:15:58 -07:00
$sc -> setScVar ( 'postInfo' , $postInfo );
2016-04-22 09:44:01 -07:00
$sc -> setVars ( $postInfo ); // compatibility
2016-04-05 13:15:58 -07:00
2009-09-08 02:00:48 +00:00
if ( $postInfo [ 'post_status' ])
{
$_style = ( isset ( $FORUMDELETEDSTYLE_ALT ) && $alt ? $FORUMDELETEDSTYLE_ALT : $FORUMDELETEDSTYLE );
2016-04-05 13:15:58 -07:00
$sc -> wrapper ( 'forum_viewtopic/deleted' );
2009-09-08 02:00:48 +00:00
}
else
{
$_style = ( isset ( $FORUMREPLYSTYLE_ALT ) && $alt ? $FORUMREPLYSTYLE_ALT : $FORUMREPLYSTYLE );
2016-04-05 13:15:58 -07:00
$sc -> wrapper ( 'forum_viewtopic/replies' );
2009-09-08 02:00:48 +00:00
}
2016-05-04 09:13:46 -07:00
2016-04-05 13:15:58 -07:00
// $forum_shortcodes = e107::getScBatch('view', 'forum')->setScVar('postInfo', $postInfo)->wrapper('forum/viewtopic');
$forrep .= $tp -> parseTemplate ( $_style , true , $sc ) . " \n " ;
2016-05-04 09:13:46 -07:00
2009-09-08 02:00:48 +00:00
}
2016-05-04 09:13:46 -07:00
2009-09-08 02:00:48 +00:00
}
unset ( $loop_uid );
2016-06-30 14:56:30 +01:00
/*---->
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
{
2013-03-13 02:39:00 -07:00
//XXX Show only on the last page??
2012-12-08 20:22:05 +01:00
if ( ! vartrue ( $forum_quickreply ))
2006-12-02 04:36:16 +00:00
{
2013-04-19 01:41:38 -07:00
$ajaxInsert = ( $thread -> pages == $thread -> page || $thread -> pages == 0 ) ? 1 : 0 ;
2015-05-08 12:50:30 -07:00
// $ajaxInsert = 1;
2013-04-19 01:41:38 -07:00
// echo "AJAX-INSERT=".$ajaxInsert ."(".$thread->pages." vs ".$thread->page.")";
2013-06-19 19:54:29 -07:00
$frm = e107 :: getForm ();
2016-05-24 12:39:45 -07:00
$urlParms = array ( 'f' => 'rp' , 'id' => $thread -> threadInfo [ 'thread_id' ], 'post' => $thread -> threadInfo [ 'thread_id' ]);
$url = e107 :: url ( 'forum' , 'post' , null , array ( 'query' => $urlParms ));; // ."?f=rp&id=".$thread->threadInfo['thread_id']."&post=".$thread->threadInfo['thread_id'];
2010-02-01 03:41:59 +00:00
$tVars -> QUICKREPLY = "
2016-05-25 15:10:00 -07:00
< form action = '" . $url . "' method = 'post' >
2015-01-30 02:50:37 -08:00
< div class = 'form-group' >
< textarea cols = '80' placeholder = '".LAN_FORUM_2007."' rows = '4' id = 'forum-quickreply-text' class = 'tbox input-xxlarge form-control' name = 'post' onselect = 'storeCaret(this);' onclick = 'storeCaret(this);' onkeyup = 'storeCaret(this);' ></ textarea >
</ div >
< div class = 'center text-center form-group' >
< input type = 'submit' data - token = '".e_TOKEN."' data - forum - insert = '".$ajaxInsert."' data - forum - post = '".$thread->threadInfo[' thread_forum_id ']."' data - forum - thread = '".$threadId."' data - forum - action = 'quickreply' name = 'reply' value = '".LAN_FORUM_2006. "' class = 'btn btn-success button' />
2016-01-13 18:07:05 -08:00
< input type = 'hidden' name = 'thread_id' value = '".$threadId."' />
2013-03-13 02:57:31 -07:00
</ div >
2015-01-30 02:50:37 -08:00
2008-12-04 21:36:09 +00:00
</ form > " ;
2015-05-08 12:50:30 -07:00
if ( E107_DEBUG_LEVEL > 0 )
{
// echo "<div class='alert alert-info'>Thread id: ".$threadId."</div>";
// print_a($this);
}
2013-06-19 19:54:29 -07:00
2014-02-07 07:33:33 -08:00
// Preview should be reserved for the full 'Post reply' page. <input type='submit' name='fpreview' value='" . Preview . "' />
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
}
}
2016-06-30 14:56:30 +01:00
<----*/
2006-12-02 04:36:16 +00:00
2016-06-30 14:56:30 +01:00
/*--->
2015-04-22 00:16:52 -07:00
$mes = e107 :: getMessage ();
2016-06-30 14:56:30 +01:00
$sc -> setVars ( $thread -> threadInfo );
//--->$forend = $tp->simpleParse($FORUMEND, $tVars);
$forend = $tp -> parseTemplate ( $FORUMEND , true , $sc );
<---*/
2012-12-08 20:22:05 +01:00
$forumstring = $forstr . $forthr . vartrue ( $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
2016-06-14 13:34:52 +01:00
//---- Orphan $currentUser???
2008-12-15 00:29:20 +00:00
$threadsViewed = explode ( ',' , $currentUser [ 'user_plugin_forum_viewed' ]);
2015-04-22 00:16:52 -07:00
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 );
2015-04-22 00:16:52 -07:00
$mes -> addDebug ( " Marking Forum as read: " . $thread -> threadId . " result: " . $tst );
2006-12-02 04:36:16 +00:00
}
2015-04-22 00:16:52 -07:00
else
{
$ret = array ( 'lastpost' => $thread -> threadInfo [ 'thread_lastpost' ], 'lastvisit' => USERLV , 'thread' => $thread -> threadId , 'viewed' => $threadsViewed );
$mes -> addDebug ( print_a ( $ret , true ));
unset ( $ret );
}
2008-12-17 04:22:37 +00:00
require_once ( HEADERF );
2013-03-14 04:05:33 -07:00
2010-03-10 01:23:57 +00:00
if ( $forum -> prefs -> get ( 'enclose' ))
2008-12-01 21:11:01 +00:00
{
2016-12-01 22:10:41 +00:00
$forumTitle = empty ( $FORUMCAPTION ) ? e107 :: pref ( 'forum' , 'title' , LAN_PLUGIN_FORUM_NAME ) : $tp -> parseTemplate ( $FORUMCAPTION , TRUE , $sc );
2016-03-23 20:13:26 -07:00
$ns -> tablerender ( $forumTitle , $mes -> render () . $forumstring , array ( 'forum_viewtopic' , 'main' ));
2008-12-01 21:11:01 +00:00
}
else
{
2013-03-14 04:05:33 -07:00
echo $mes -> render () . $forumstring ;
2006-12-02 04:36:16 +00:00
}
// 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' ) {
2013-06-12 21:37:54 +02:00
return confirm ( \ " " . $tp -> toJS ( LAN_FORUM_2009 ) . " \" );
2006-12-02 04:36:16 +00:00
} else {
2013-06-12 21:37:54 +02:00
return confirm ( \ " " . $tp -> toJS ( LAN_FORUM_2010 ) . " [ " . $tp -> toJS ( LAN_FORUM_0074 ) . " \" + 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 ();
2016-06-14 13:34:52 +01:00
//---- Orphan $forum_id????
2009-09-08 02:00:48 +00:00
$forum_id = $thread -> threadInfo [ 'forum_id' ];
if ( $postInfo [ 'thread_start' ])
{
$type = 'Thread' ;
2011-11-28 14:19:19 +00:00
// XXX _URL_ thread name?
$ret = " <form method='post' action=' " . $e107 -> url -> create ( 'forum/thread/view' , array ( 'id' => $postInfo [ 'post_thread' ])) . " ' id='frmMod_ { $postInfo [ 'post_forum' ] } _ { $postInfo [ 'post_thread' ] } '> " ;
2009-09-08 02:00:48 +00:00
$delId = $postInfo [ 'post_thread' ];
}
else
{
$type = 'Post' ;
2011-04-25 11:29:21 +00:00
$ret = " <form method='post' action=' " . e_SELF . '?' . e_QUERY . " ' id='frmMod_ { $postInfo [ 'post_thread' ] } _ { $postInfo [ 'post_id' ] } '> " ;
2009-09-08 02:00:48 +00:00
$delId = $postInfo [ 'post_id' ];
}
2016-01-13 18:07:05 -08:00
$editQRY = array ( 'f' => 'edit' , 'id' => $postInfo [ 'post_thread' ], 'post' => $postInfo [ 'post_id' ]);
$editURL = e107 :: url ( 'forum' , 'post' , '' , array ( 'query' => $editQRY ));
// $e107->url->create('forum/thread/edit', array('id' => $postInfo['post_id']))
2009-09-08 02:00:48 +00:00
$ret .= "
< div >
2016-01-13 18:07:05 -08:00
< a class = 'e-tip' href = '" . $editURL."' title = \ " " . LAN_EDIT . " \" > " . IMAGE_admin_edit . " </a>
2009-09-08 02:00:48 +00:00
< 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' )
{
2016-01-13 18:07:05 -08:00
$moveUrl = e107 :: url ( 'forum' , 'move' , array ( 'thread_id' => $postInfo [ 'post_thread' ]));
2015-06-26 10:26:47 -07:00
$ret .= " <a href=' " . $moveUrl . " '> " . IMAGE_admin_move2 . " </a> " ;
2009-09-08 02:00:48 +00:00
}
else
{
2016-01-13 18:07:05 -08:00
$ret .= " <a href=' " . $e107 -> url -> create ( 'forum/thread/split' , array ( 'id' => $postInfo [ 'post_id' ])) . " '> " . defset ( 'IMAGE_admin_split' ) . '</a>' ;
2009-09-08 02:00:48 +00:00
}
$ret .= "
</ div >
</ form > " ;
return $ret ;
}
2016-06-14 13:34:52 +01:00
/*----
2006-12-02 04:36:16 +00:00
function forumjump ()
{
global $forum ;
2008-12-18 14:08:33 +00:00
$jumpList = $forum -> forumGetAllowed ();
2013-06-12 21:37:54 +02:00
$text = " <form method='post' action=' " . e_SELF . " '><p> " . LAN_FORUM_1017 . " : <select name='forumjump' class='tbox'> " ;
2008-12-04 21:36:09 +00:00
foreach ( $jumpList as $key => $val )
2006-12-02 04:36:16 +00:00
{
2015-05-26 12:00:43 -07:00
$text .= " \n <option value=' " . e107 :: url ( 'forum' , 'forum' , $val ) . " '> " . $val [ 'forum_name' ] . " </option> " ;
2006-12-02 04:36:16 +00:00
}
2014-02-07 07:33:33 -08:00
$text .= " </select> <input class='btn btn-default button' type='submit' name='fjsubmit' value=' " . LAN_GO . " ' /></p></form> " ;
2006-12-02 04:36:16 +00:00
return $text ;
}
2016-06-14 13:34:52 +01:00
----*/
2006-12-02 04:36:16 +00:00
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
}
2015-05-26 12:00:43 -07: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
{
2011-04-26 11:27:36 +00:00
public $message ;
public $threadId ;
public $forumId ;
public $perPage ;
public $noInc ;
public $pages ;
2015-05-07 11:49:36 -07:00
public $page ;
2009-09-08 02:00:48 +00:00
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' ));
2011-04-25 11:29:21 +00:00
$this -> page = ( varset ( $_GET [ 'p' ]) ? ( int ) $_GET [ 'p' ] : 1 );
2009-09-08 02:00:48 +00:00
2013-04-19 01:41:38 -07:00
if ( ! $this -> threadId && e_QUERY ) //BC Links fix.
{
list ( $id , $page ) = explode ( " . " , e_QUERY );
$this -> threadId = intval ( $id );
$this -> page = intval ( $page );
}
2009-09-08 02:00:48 +00:00
//If threadId doesn't exist, or not given, redirect to main forum page
if ( ! $this -> threadId || ! $this -> threadInfo = $forum -> threadGet ( $this -> threadId ))
{
2015-05-22 15:37:46 -07:00
if ( E107_DEBUG_LEVEL > 0 )
{
2015-06-27 12:07:41 -07:00
e107 :: getMessage () -> addError ( " Thread not found or query error: " . __METHOD__ . ' Line: ' . __LINE__ );
return ;
// exit;
2015-05-22 15:37:46 -07:00
}
$url = e107 :: url ( 'forum' , 'index' , 'full' );
e107 :: getRedirect () -> go ( $url );
// header('Location:' . $e107->url->create('forum/forum/main', array(), 'encode=0&full=1'));
2009-09-08 02:00:48 +00:00
exit ;
}
//If not permitted to view forum, redirect to main forum page
if ( ! $forum -> checkPerm ( $this -> threadInfo [ 'thread_forum_id' ], 'view' ))
{
2015-05-22 15:37:46 -07:00
if ( E107_DEBUG_LEVEL > 0 )
{
echo __METHOD__ . ' Line: ' . __LINE__ ;
exit ;
}
$url = e107 :: url ( 'forum' , 'index' , 'full' );
e107 :: getRedirect () -> go ( $url );
// header('Location:' . $e107->url->create('forum/forum/main', array(), 'encode=0&full=1'));
2009-09-08 02:00:48 +00:00
exit ;
}
2015-05-07 11:49:36 -07:00
2015-12-18 09:25:12 +01:00
$totalPosts = $this -> threadInfo [ 'thread_total_replies' ] + 1 ; // add +1 for the original post. ie. not a reply.
2015-05-07 11:49:36 -07:00
$this -> pages = ceil (( $totalPosts ) / $this -> perPage );
2009-09-08 02:00:48 +00:00
$this -> noInc = false ;
}
2016-01-31 14:39:41 -08:00
/*
2015-05-07 11:49:36 -07:00
2009-09-08 02:00:48 +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 )
{
2011-11-28 14:19:19 +00:00
$url = $e107 -> url -> create ( 'forum/thread/view' , array ( 'name' => $this -> threadInfo [ 'thread_name' ], 'id' => $thread -> threadId ));
2009-09-08 02:00:48 +00:00
echo " <a href=' { $url } ' id='forum-track-trigger'> { $img } </a> " ;
exit ();
}
}
2016-01-31 14:39:41 -08:00
*/
2009-09-08 02:00:48 +00:00
2015-04-13 19:38:25 -07:00
/**
* @ return bool | null | string | void
*/
2009-09-08 02:00:48 +00:00
function processFunction ()
{
2015-04-13 19:38:25 -07:00
2010-03-10 01:23:57 +00:00
global $forum , $thread ;
2015-04-13 19:38:25 -07:00
// $e107 = e107::getInstance();
2013-03-25 18:48:48 +01:00
$ns = e107 :: getRender ();
$sql = e107 :: getDb ();
2013-03-26 12:33:03 +01:00
$tp = e107 :: getParser ();
2016-06-30 15:49:00 +01:00
//Orphan $frm variable???? $frm = e107::getForm();
2015-04-13 19:38:25 -07:00
if ( empty ( $_GET [ 'f' ]))
2009-09-08 02:00:48 +00:00
{
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 );
2011-04-25 16:52:20 +00:00
$postPage = ceil ( $postNum / $forum -> prefs -> get ( 'postspage' ));
2016-02-01 20:29:46 -08:00
$url = e107 :: url ( 'forum' , 'topic' , $postInfo , array (
'query' => array (
'p' => $postPage , // proper page number
),
'fragment' => 'post-' . $postId , // jump page to post
'mode' => 'full'
));
e107 :: redirect ( $url );
2009-09-08 02:00:48 +00:00
exit ;
break ;
case 'last' :
2015-05-07 11:49:36 -07:00
$pages = ceil (( $thread -> threadInfo [ 'thread_total_replies' ] + 1 ) / $thread -> perPage );
2011-06-28 10:33:12 +00:00
$thread -> page = $_GET [ 'p' ] = $pages ;
2009-09-08 02:00:48 +00:00
break ;
2015-05-26 12:00:43 -07:00
/* // Now linked directly - no more redirect.
case 'next' :
2009-09-08 02:00:48 +00:00
$next = $forum -> threadGetNextPrev ( 'next' , $this -> threadId , $this -> threadInfo [ 'forum_id' ], $this -> threadInfo [ 'thread_lastpost' ]);
if ( $next )
{
2015-04-13 19:38:25 -07:00
$url = e107 :: getUrl () -> create ( 'forum/thread/view' , array ( 'id' => $next ), array ( 'encode' => false , 'full' => 1 )); // no thread name info at this time
2009-09-08 02:00:48 +00:00
header ( " location: { $url } " );
exit ;
}
2013-06-12 21:37:54 +02:00
$this -> message = LAN_FORUM_2013 ;
2009-09-08 02:00:48 +00:00
break ;
2015-05-26 12:00:43 -07:00
case 'prev' :
2009-09-08 02:00:48 +00:00
$prev = $forum -> threadGetNextPrev ( 'prev' , $this -> threadId , $this -> threadInfo [ 'forum_id' ], $this -> threadInfo [ 'thread_lastpost' ]);
if ( $prev )
{
2015-04-13 19:38:25 -07:00
$url = e107 :: getUrl () -> create ( 'forum/thread/view' , array ( 'id' => $prev ), array ( 'encode' => false , 'full' => 1 )); // no thread name info at this time
2009-09-08 02:00:48 +00:00
header ( " location: { $url } " );
exit ;
}
2013-06-12 21:37:54 +02:00
$this -> message = LAN_FORUM_2012 ;
2009-09-08 02:00:48 +00:00
break ;
2015-05-26 12:00:43 -07:00
*/
2009-09-08 02:00:48 +00:00
2015-05-26 12:00:43 -07:00
// Moved to form_post.php
/*
2009-09-08 02:00:48 +00:00
case 'report' :
2014-07-05 16:40:09 +02:00
$threadId = ( int ) $_GET [ 'id' ];
$postId = ( int ) $_GET [ 'post' ];
$postInfo = $forum -> postGet ( $postId , 'post' );
2009-09-08 02:00:48 +00:00
2015-04-13 19:38:25 -07:00
if ( ! empty ( $_POST [ 'report_thread' ]))
2009-09-08 02:00:48 +00:00
{
2013-03-26 12:33:03 +01:00
$report_add = $tp -> toDB ( $_POST [ 'report_add' ]);
2015-04-13 19:38:25 -07:00
2015-05-26 12:00:43 -07:00
if ( $forum -> prefs -> get ( 'reported_post_email' ))
2009-09-08 02:00:48 +00:00
{
2014-07-05 16:40:09 +02:00
require_once ( e_HANDLER . 'mail.php' );
2013-06-12 21:37:54 +02:00
$report = LAN_FORUM_2018 . " " . SITENAME . " : " . ( substr ( SITEURL , - 1 ) == " / " ? SITEURL : SITEURL . " / " ) . $e107 -> getFolder ( 'plugins' ) . " forum/forum_viewtopic.php? " . $this -> threadId . " .post \n
" .LAN_FORUM_2019. " : " .USERNAME. " \n " . $report_add ;
$subject = LAN_FORUM_2020 . " " . SITENAME ;
2009-09-08 02:00:48 +00:00
sendemail ( SITEADMINEMAIL , $subject , $report );
}
2011-04-25 11:29:21 +00:00
// no reference of 'head' $threadInfo['head']['thread_name']
2015-04-13 19:38:25 -07:00
$insert = array (
'gen_id' => 0 ,
'gen_type' => 'reported_post' ,
'gen_datestamp' => time (),
'gen_user_id' => USERID ,
'gen_ip' => $tp -> toDB ( $postInfo [ 'thread_name' ]),
'gen_intdata' => intval ( $this -> threadId ),
'gen_chardata' => $report_add ,
);
$url = e107 :: getUrl () -> create ( 'forum/thread/post' , array ( 'id' => $postId , 'name' => $postInfo [ 'thread_name' ], 'thread' => $threadId )); // both post info and thread info contain thread name
$result = $sql -> insert ( 'generic' , $insert );
if ( $result )
{
$text = " <div class='alert alert-block alert-success'><h4> " . LAN_FORUM_2021 . " </h4><a href=' { $url } '> " . LAN_FORUM_2022 . '</a></div>' ;
}
else
{
$text = " <div class='alert alert-block alert-error'><h4> " . LAN_FORUM_2021 . " </h4><a href=' { $url } '> " . LAN_FORUM_2022 . '</a></div>' ;
}
2013-06-12 21:37:54 +02:00
define ( 'e_PAGETITLE' , LAN_FORUM_1001 . " / " . LAN_FORUM_2021 );
2015-04-13 19:38:25 -07:00
return $ns -> tablerender ( LAN_FORUM_2023 , $text , array ( 'forum_viewtopic' , 'report' ), true );
2009-09-08 02:00:48 +00:00
}
else
{
2013-03-25 18:48:48 +01:00
$thread_name = e107 :: getParser () -> toHTML ( $postInfo [ 'thread_name' ], true , 'no_hook, emotes_off' );
2013-06-12 21:37:54 +02:00
define ( 'e_PAGETITLE' , LAN_FORUM_1001 . ' / ' . LAN_FORUM_2024 . ': ' . $thread_name );
2015-04-13 19:38:25 -07:00
$url = e107 :: getUrl () -> create ( 'forum/thread/post' , array ( 'id' => $postId , 'name' => $postInfo [ 'thread_name' ], 'thread' => $threadId ));
$actionUrl = e107 :: getUrl () -> create ( 'forum/thread/report' , " id= { $threadId } &post= { $postId } " );
if ( deftrue ( 'BOOTSTRAP' )) //v2.x
{
$text = $frm -> open ( 'forum-report-thread' , 'post' );
$text .= "
< div >
< div class = 'alert alert-block alert-warning' >
< h4 > " .LAN_FORUM_2025.': '. $thread_name . " </ h4 >
" .LAN_FORUM_2027. " < br /> " .str_replace(array('[', ']'), array('<b>', '</b>'), LAN_FORUM_2028). "
< a class = 'pull-right btn btn-xs btn-primary e-expandit' href = '#post-info' > View Post </ a >
</ div >
< div id = 'post-info' class = 'e-hideme alert alert-block alert-danger' >
" . $tp->toHtml ( $postInfo['post_entry'] ,true). "
</ div >
< div class = 'form-group' >
< div class = 'col-md-12' >
" . $frm->textarea ('report_add','',10,35,array('size'=>'xxlarge')). "
</ div >
</ div >
< div class = 'form-group' >
< div class = 'col-md-12' >
" . $frm->button ('report_thread',1,'submit',LAN_FORUM_2029). "
</ div >
</ div >
</ div > " ;
$text .= $frm -> close ();
// $text .= print_a($postInfo['post_entry'],true);
}
else //v1.x legacy layout.
{
$text = " <form action=' " . $actionUrl . " ' method='post'>
< table class = 'table' style = 'width:100%' >
< tr >
< td style = 'width:50%' >
" .LAN_FORUM_2025.': '. $thread_name . " < a href = '".$url."' >< span class = 'smalltext' > " .LAN_FORUM_2026. " </ span ></ a >
</ td >
< td style = 'text-align:center;width:50%' ></ td >
</ tr >
< tr >
< td > " .LAN_FORUM_2027. " < br /> " .str_replace(array('[', ']'), array('<b>', '</b>'), LAN_FORUM_2028). " </ td >
</ tr >
< tr >
< 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 = 'btn btn-default button' type = 'submit' name = 'report_thread' value = '".LAN_FORUM_2029."' /></ td >
</ tr >
</ table >
</ form > " ;
}
return e107 :: getRender () -> tablerender ( LAN_FORUM_2023 , $text , array ( 'forum_viewtopic' , 'report2' ), true );
2009-09-08 02:00:48 +00:00
}
2013-06-12 21:37:54 +02:00
2009-09-08 02:00:48 +00:00
exit ;
2015-05-26 12:00:43 -07:00
break ; */
2009-09-08 02:00:48 +00:00
}
}
}
2016-11-16 20:52:53 +00:00
?>