diff --git a/e107_plugins/forum/forum.php b/e107_plugins/forum/forum.php
index 445772e03..236d6fdda 100644
--- a/e107_plugins/forum/forum.php
+++ b/e107_plugins/forum/forum.php
@@ -11,13 +11,13 @@
*/
if(!defined('e107_INIT'))
{
- require_once(__DIR__.'/../../class2.php');
+ require_once(__DIR__ . '/../../class2.php');
}
$e107 = e107::getInstance();
$tp = e107::getParser();
$sql = e107::getDb();
-if (!$e107->isInstalled('forum'))
+if(!$e107->isInstalled('forum'))
{
e107::redirect();
exit;
@@ -25,193 +25,214 @@ if (!$e107->isInstalled('forum'))
e107::lan('forum', "front", true);
-if(!deftrue('BOOTSTRAP'))
+
+class forum_front
{
- $bcDefs = array(
- 'FORLAN_11' => 'LAN_FORUM_0039',
- 'FORLAN_12' => 'LAN_FORUM_0040',
- 'FORLAN_18' => 'LAN_FORUM_0041',
- );
+ private $sc;
- e107::getLanguage()->bcDefs($bcDefs);
-}
-
-
-require_once(e_PLUGIN.'forum/forum_class.php');
-$forum = new e107forum;
-
-if(e_AJAX_REQUEST)
-{
- if(varset($_POST['action']) == 'track')
+ function __construct($forum)
{
- $forum->ajaxTrack();
+ $this->init($forum);
}
-}
-/*
-if ($untrackId = varset($_REQUEST['untrack']))
-{
- $forum->track('del', USERID, $untrackId);
- header('location:'.$e107->url->create('forum/thread/track', array(), 'full=1&encode=0'));
- exit;
-}
-*/
+ /**
-if(isset($_GET['f']))
-{
- if(isset($_GET['id']))
+ */
+ public function init($forum)
{
- $id = (int)$_GET['id'];
- }
- switch($_GET['f'])
- {
- case 'mfar':
- $forum->forumMarkAsRead($id);
- header('location:'.e_SELF);
- exit;
- break;
+ global $FORUM_TEMPLATE, $FORUM_MAIN_FORUM, $forumList ;
- case 'rules':
- include_once(HEADERF);
+ $ns = e107::getRender();
+ $tp = e107::getParser();
- forum_rules('show');
- include_once(FOOTERF);
- exit;
- break;
+ $text = '';
- case 'track':
- include_once(HEADERF);
-
- forum_track();
- include_once(FOOTERF);
- exit;
- break;
- }
-}
-else
-{
- e107::canonical('forum');
-}
-
-
-
-/** @var forum_shortcodes $sc */
-$sc = e107::getScBatch('forum', true);
-
-
-if(empty($FORUM_TEMPLATE))
-{
- // Override with theme template
- if(THEME_LEGACY !== true) //v2.x
- {
- $FORUM_TEMPLATE = e107::getTemplate('forum','forum'); // required to use v2.x wrapper shortcode wrappers.
- }
- elseif (file_exists(THEME.'forum_template.php')) //v1.x fallback.
- {
- include(e_PLUGIN.'forum/templates/forum_template.php');
- include_once(THEME.'forum_template.php');
- }
- elseif(file_exists(THEME.'templates/forum/forum_template.php'))
- {
- // $FORUM_TEMPLATE = e107::getTemplate('forum','forum');
- require_once(THEME.'templates/forum/forum_template.php');
- }
- else
- {
- require_once(e_PLUGIN.'forum/templates/forum_template.php');
- }
-}
-
-if(is_array($FORUM_TEMPLATE) && THEME_LEGACY !== true) // new v2.x format.
-{
-
- if(varset($FORUM_TEMPLATE['main-start'])) // correction of previous v2.x setup.
- {
- $FORUM_TEMPLATE['main']['start'] = $FORUM_TEMPLATE['main-start'];
- $FORUM_TEMPLATE['main']['parent'] = $FORUM_TEMPLATE['main-parent'];
- $FORUM_TEMPLATE['main']['forum'] = $FORUM_TEMPLATE['main-forum'];
- $FORUM_TEMPLATE['main']['end'] = $FORUM_TEMPLATE['main-end'];
- }
-
- $FORUM_MAIN_START = $FORUM_TEMPLATE['main']['start'];
- $FORUM_MAIN_PARENT = $FORUM_TEMPLATE['main']['parent'];
- $FORUM_MAIN_PARENT_END = varset($FORUM_TEMPLATE['main']['parent_end']);
- $FORUM_MAIN_FORUM = $FORUM_TEMPLATE['main']['forum'];
- $FORUM_MAIN_END = $FORUM_TEMPLATE['main']['end'];
-
- $FORUM_NEWPOSTS_START = $FORUM_TEMPLATE['main']['start']; // $FORUM_TEMPLATE['new-start'];
- $FORUM_NEWPOSTS_MAIN = $FORUM_TEMPLATE['main']['forum']; // $FORUM_TEMPLATE['new-main'];
- $FORUM_NEWPOSTS_END = $FORUM_TEMPLATE['main']['end']; // $FORUM_TEMPLATE['new-end'];
-}
-
-require_once(HEADERF);
-
-$forumList = $forum->forumGetForumList();
-$newflag_list = $forum->forumGetUnreadForums();
-
-$sc->newFlagList = $newflag_list;
-
-
-if (!$forumList)
-{
- $ns->tablerender(LAN_PLUGIN_FORUM_NAME, LAN_FORUM_0067, 'forum-empty');
- require_once(FOOTERF);
- exit;
-}
-
-$forum_string = '';
-
-foreach ($forumList['parents'] as $parent)
-{
-
- $parent = (array) $parent;
-
- $sc->setVars($parent);
-// $sc->setScVar('forumParent', $parent);
- $sc->wrapper('forum/main/parent');
-
- $forum_string .= $tp->parseTemplate($FORUM_MAIN_PARENT, true, $sc);
-
- $fid = $parent['forum_id'];
- if (empty($forumList['forums'][$parent['forum_id']]))
- {
- $text .= "
";
- }
- else
- {
- //TODO: Rework the restricted string
- foreach($forumList['forums'][$parent['forum_id']] as $f)
+ if(!deftrue('BOOTSTRAP'))
{
- if ($f['forum_class'] == e_UC_ADMIN && ADMIN)
+ $bcDefs = array(
+ 'FORLAN_11' => 'LAN_FORUM_0039',
+ 'FORLAN_12' => 'LAN_FORUM_0040',
+ 'FORLAN_18' => 'LAN_FORUM_0041',
+ );
+
+ e107::getLanguage()->bcDefs($bcDefs);
+ }
+
+
+
+
+ if(e_AJAX_REQUEST)
+ {
+ if(varset($_POST['action']) == 'track')
{
- $forum_string .= parse_forum($f, LAN_FORUM_0005);
+ $forum->ajaxTrack();
}
- elseif($f['forum_class'] == e_UC_MEMBER && USER)
+
+ }
+
+ /*
+ if ($untrackId = varset($_REQUEST['untrack']))
+ {
+ $forum->track('del', USERID, $untrackId);
+ header('location:'.$e107->url->create('forum/thread/track', array(), 'full=1&encode=0'));
+ exit;
+ }
+ */
+
+ if(isset($_GET['f']))
+ {
+
+ $id = (isset($_GET['id'])) ? (int) $_GET['id'] : null;
+
+
+ switch($_GET['f'])
{
- $forum_string .= parse_forum($f, LAN_FORUM_0006);
- }
- elseif($f['forum_class'] == e_UC_READONLY)
- {
- $forum_string .= parse_forum($f, LAN_FORUM_0007);
- }
- elseif($f['forum_class'] && check_class($f['forum_class']))
- {
- $forum_string .= parse_forum($f, LAN_FORUM_0008);
- }
- elseif(!$f['forum_class'])
- {
- $forum_string .= parse_forum($f);
+ case 'mfar':
+ $forum->forumMarkAsRead($id);
+ header('location:' . e_SELF);
+ exit;
+ break;
+
+ case 'rules':
+ include_once(HEADERF);
+
+ forum_rules('show');
+ include_once(FOOTERF);
+ exit;
+ break;
+
+ case 'track':
+ include_once(HEADERF);
+
+ forum_track();
+ include_once(FOOTERF);
+ exit;
+ break;
}
}
- if (isset($FORUM_MAIN_PARENT_END))
+ else
{
+ e107::canonical('forum');
+ }
+
+
+ /** @var forum_shortcodes $this->sc */
+ $this->sc = e107::getScBatch('forum', true);
+
+
+ if(empty($FORUM_TEMPLATE))
+ {
+ // Override with theme template
+ if(THEME_LEGACY !== true) //v2.x
+ {
+ $FORUM_TEMPLATE = e107::getTemplate('forum', 'forum'); // required to use v2.x wrapper shortcode wrappers.
+ }
+ elseif(file_exists(THEME . 'forum_template.php')) //v1.x fallback.
+ {
+ include(e_PLUGIN . 'forum/templates/forum_template.php');
+ include_once(THEME . 'forum_template.php');
+ }
+ elseif(file_exists(THEME . 'templates/forum/forum_template.php'))
+ {
+ // $FORUM_TEMPLATE = e107::getTemplate('forum','forum');
+ require_once(THEME . 'templates/forum/forum_template.php');
+ }
+ else
+ {
+ require_once(e_PLUGIN . 'forum/templates/forum_template.php');
+ }
+ }
+
+ if(is_array($FORUM_TEMPLATE) && THEME_LEGACY !== true) // new v2.x format.
+ {
+
+ if(varset($FORUM_TEMPLATE['main-start'])) // correction of previous v2.x setup.
+ {
+ $FORUM_TEMPLATE['main']['start'] = $FORUM_TEMPLATE['main-start'];
+ $FORUM_TEMPLATE['main']['parent'] = $FORUM_TEMPLATE['main-parent'];
+ $FORUM_TEMPLATE['main']['forum'] = $FORUM_TEMPLATE['main-forum'];
+ $FORUM_TEMPLATE['main']['end'] = $FORUM_TEMPLATE['main-end'];
+ }
+
+ $FORUM_MAIN_START = $FORUM_TEMPLATE['main']['start'];
+ $FORUM_MAIN_PARENT = $FORUM_TEMPLATE['main']['parent'];
+ $FORUM_MAIN_PARENT_END = varset($FORUM_TEMPLATE['main']['parent_end']);
+ $FORUM_MAIN_FORUM = $FORUM_TEMPLATE['main']['forum'];
+ $FORUM_MAIN_END = $FORUM_TEMPLATE['main']['end'];
+
+ $FORUM_NEWPOSTS_START = $FORUM_TEMPLATE['main']['start']; // $FORUM_TEMPLATE['new-start'];
+ $FORUM_NEWPOSTS_MAIN = $FORUM_TEMPLATE['main']['forum']; // $FORUM_TEMPLATE['new-main'];
+ $FORUM_NEWPOSTS_END = $FORUM_TEMPLATE['main']['end']; // $FORUM_TEMPLATE['new-end'];
+ }
+
+ require_once(HEADERF);
+
+ $forumList = $forum->forumGetForumList();
+ $newflag_list = $forum->forumGetUnreadForums();
+
+ $this->sc->newFlagList = $newflag_list;
+
+
+ if(!$forumList)
+ {
+ $ns->tablerender(LAN_PLUGIN_FORUM_NAME, LAN_FORUM_0067, 'forum-empty');
+ require_once(FOOTERF);
+ return null;
+ }
+
+ $forum_string = '';
+
+ foreach($forumList['parents'] as $parent)
+ {
+
+ $parent = (array) $parent;
+
+ $this->sc->setVars($parent);
+// $this->sc->setScVar('forumParent', $parent);
+ $this->sc->wrapper('forum/main/parent');
+
+ $forum_string .= $tp->parseTemplate($FORUM_MAIN_PARENT, true, $this->sc);
+
+ $fid = $parent['forum_id'];
+ if(empty($forumList['forums'][$parent['forum_id']]))
+ {
+ $text .= "";
+ }
+ else
+ {
+ //TODO: Rework the restricted string
+ foreach($forumList['forums'][$parent['forum_id']] as $f)
+ {
+ if($f['forum_class'] == e_UC_ADMIN && ADMIN)
+ {
+ $forum_string .= $this->parse_forum($f, LAN_FORUM_0005);
+ }
+ elseif($f['forum_class'] == e_UC_MEMBER && USER)
+ {
+ $forum_string .= $this->parse_forum($f, LAN_FORUM_0006);
+ }
+ elseif($f['forum_class'] == e_UC_READONLY)
+ {
+ $forum_string .= $this->parse_forum($f, LAN_FORUM_0007);
+ }
+ elseif($f['forum_class'] && check_class($f['forum_class']))
+ {
+ $forum_string .= $this->parse_forum($f, LAN_FORUM_0008);
+ }
+ elseif(!$f['forum_class'])
+ {
+ $forum_string .= $this->parse_forum($f);
+ }
+ }
+ if(isset($FORUM_MAIN_PARENT_END))
+ {
//-- $forum_string .= $tp->simpleParse($FORUM_MAIN_PARENT_END, $pVars);
- $forum_string .= $tp->parseTemplate($FORUM_MAIN_PARENT_END, true, $sc);
+ $forum_string .= $tp->parseTemplate($FORUM_MAIN_PARENT_END, true, $this->sc);
+ }
+ }
}
- }
-}
//if (e_QUERY == 'track')
@@ -219,325 +240,339 @@ foreach ($forumList['parents'] as $parent)
//}
-if (e_QUERY == 'new')
-{
-//-- $nVars = new e_vars;
- $newThreadList = $forum->threadGetNew(10);
- foreach($newThreadList as $thread)
- {
- $sc->setVars($thread);
- $forum_newstring .= $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $sc);
- }
-
- if (empty($newThreadList))
- {
- $forum_newstring = $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $sc);
-
- }
-
- $forum_new_start = $tp->parseTemplate($FORUM_NEWPOSTS_START, true, $sc);
- $forum_new_end = $tp->parseTemplate($FORUM_NEWPOSTS_END, true, $sc);
-
- if ($forum->prefs->get('enclose'))
- {
- $ns->tablerender($forum->prefs->get('title'), $forum_new_start.$forum_newstring.$forum_new_end, 'forum');
- }
- else
- {
- echo $forum_new_start.$forum_newstring.$forum_new_end;
- }
-}
-
-
-
-$breadarray = array(
- array('text'=> $forum->prefs->get('title'), 'url' => e107::url('forum','index') )
-);
-
-e107::breadcrumb($breadarray);
-
-$sc->wrapper('forum/main/start');
-$forum_main_start = $tp->parseTemplate($FORUM_MAIN_START, true, $sc);
-//-- $forum_main_end = $tp->simpleParse($FORUM_MAIN_END, $fVars);
-
-$sc->wrapper('forum/main/end');
-$forum_main_end = $tp->parseTemplate($FORUM_MAIN_END, true, $sc);
-
-if ($forum->prefs->get('enclose'))
-{
- $ns->tablerender($forum->prefs->get('title'), $forum_main_start.$forum_string.$forum_main_end, 'forum');
-}
-else
-{
- echo $forum_main_start.$forum_string.$forum_main_end;
-}
-
-
-require_once(FOOTERF);
-
-function forum_rules($action = 'check')
-{
- if (ADMIN == true)
- {
- $type = 'forum_rules_admin';
- }
- elseif(USER == true)
- {
- $type = 'forum_rules_member';
- }
- else
- {
- $type = 'forum_rules_guest';
- }
- $result = e107::getDb()->select('generic', 'gen_chardata', "gen_type = '$type' AND gen_intdata = 1");
- if ($action == 'check') { return $result; }
-
- if ($result)
- {
- $row = e107::getDb()->fetch();
- $rules_text = e107::getParser()->toHTML($row['gen_chardata'], true);
- }
- else
- {
- $rules_text = LAN_FORUM_0072;
- }
-
- $text = '';
-
- if(deftrue('BOOTSTRAP'))
- {
- $breadarray = array(
- array('text'=> e107::pref('forum','title', LAN_PLUGIN_FORUM_NAME), 'url' => e107::url('forum','index') ),
- array('text'=>LAN_FORUM_0016, 'url'=>null)
- );
-
- $text = e107::getForm()->breadcrumb($breadarray);
- e107::breadcrumb($breadarray); // assign to {---BREADCRUMB---}
- }
-
- $text .= "".$rules_text."
";
- $text .= "".e107::getForm()->pagination(e107::url('forum','index'), LAN_BACK)."
";
-
- e107::getRender()->tablerender(LAN_FORUM_0016, $text, 'forum-rules');
-}
-
-
-function forum_track()
-{
- global $forum;
-
- $trackPref = $forum->prefs->get('track');
- $trackEmailPref = $forum->prefs->get('trackemail',true);
-
-
- if(empty($trackPref))
- {
- echo "Disabled";
- return false;
- }
-
-
- $FORUM_TEMPLATE = null;
-
- include(e_PLUGIN.'forum/templates/forum_template.php');
-
- // Override with theme template
- if (file_exists(THEME.'forum_template.php'))
- {
- include(THEME.'forum_template.php');
- }
- elseif(file_exists(THEME.'templates/forum/forum_template.php'))
- {
- require(THEME.'templates/forum/forum_template.php');
- }
-
- $IMAGE_nonew_small = IMAGE_nonew_small;
- $IMAGE_new_small = IMAGE_new_small;
-
- if(is_array($FORUM_TEMPLATE) && deftrue('BOOTSTRAP',false)) // new v2.x format.
- {
- $FORUM_TRACK_START = $FORUM_TEMPLATE['track']['start']; // $FORUM_TEMPLATE['track-start'];
- $FORUM_TRACK_MAIN = $FORUM_TEMPLATE['track']['item']; // $FORUM_TEMPLATE['track-main'];
- $FORUM_TRACK_END = $FORUM_TEMPLATE['track']['end']; // $FORUM_TEMPLATE['track-end'];
-
- $IMAGE_nonew_small = IMAGE_nonew;
- $IMAGE_new_small = IMAGE_new;
-
- }
-
- $sql = e107::getDb();
- $tp = e107::getParser();
-
- $trackDiz = ($trackEmailPref) ? LAN_FORUM_3040 : LAN_FORUM_3041;
-
-
- if($trackedThreadList = $forum->getTrackedThreadList(USERID, 'list'))
- {
-
- $viewed = $forum->threadGetUserViewed();
-
- $qry = "SELECT t.*,th.*, f.*,u.user_name FROM `#forum_track` AS t
- LEFT JOIN `#forum_thread` AS th ON t.track_thread = th.thread_id
- LEFT JOIN `#forum` AS f ON th.thread_forum_id = f.forum_id
- LEFT JOIN `#user` AS u ON th.thread_lastuser = u.user_id
- WHERE t.track_userid = ".USERID." ORDER BY th.thread_lastpost DESC";
-
- $forum_trackstring = '';
- $data = array();
- if($sql->gen($qry))
+ if(e_QUERY == 'new')
{
- while($row = $sql->fetch())
+ $forum_newstring = '';
+//-- $nVars = new e_vars;
+ $newThreadList = $forum->threadGetNew(10);
+ foreach($newThreadList as $thread)
{
- // e107::getDebug()->log($row);
- $row['thread_sef'] = eHelper::title2sef($row['thread_name'],'dashl');
+ $this->sc->setVars($thread);
+ $forum_newstring .= $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $this->sc);
+ }
- $data['NEWIMAGE'] = $IMAGE_nonew_small;
+ if(empty($newThreadList))
+ {
+ $forum_newstring = $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $this->sc);
- if ($row['thread_datestamp'] > USERLV && !in_array($row['thread_id'], $viewed))
- {
- $data['NEWIMAGE'] = $IMAGE_new_small;
- }
+ }
- $data['LASTPOSTUSER'] = !empty($row['user_name']) ? " $row['user_name'], 'id' => $row['thread_lastuser']))."'>".$row['user_name']." " : LAN_ANONYMOUS;
- $data['LASTPOSTDATE'] = $tp->toDate($row['thread_lastpost'],'relative');
+ $forum_new_start = $tp->parseTemplate($FORUM_NEWPOSTS_START, true, $this->sc);
+ $forum_new_end = $tp->parseTemplate($FORUM_NEWPOSTS_END, true, $this->sc);
- $buttonId = "forum-track-button-".intval($row['thread_id']);
-
- $forumUrl = e107::url('forum','forum',$row);
- $threadUrl = e107::url('forum','topic',$row, array('query'=>array('last'=>1))); // ('forum/thread/view', $row); // configs will be able to map thread_* vars to the url
- $data['TRACKPOSTNAME'] = "". $row['forum_name']." / ".$tp->toHTML($row['thread_name'], false, 'TITLE').' ';
- // $data['UNTRACK'] = "".LAN_FORUM_0070." ";
-
-
- $data['UNTRACK'] = "".IMAGE_track." ";
-
- $data['_WRAPPER_'] = 'forum/track/item';
- $forum_trackstring .= $tp->parseTemplate($FORUM_TRACK_MAIN, true, $data);
+ if($forum->prefs->get('enclose'))
+ {
+ $ns->tablerender($forum->prefs->get('title'), $forum_new_start . $forum_newstring . $forum_new_end, 'forum');
+ }
+ else
+ {
+ echo $forum_new_start . $forum_newstring . $forum_new_end;
}
}
- // print_a($FORUM_TRACK_START);
+ $breadarray = array(
+ array('text' => $forum->prefs->get('title'), 'url' => e107::url('forum', 'index'))
+ );
+
+ e107::breadcrumb($breadarray);
+
+ $this->sc->wrapper('forum/main/start');
+ $forum_main_start = $tp->parseTemplate($FORUM_MAIN_START, true, $this->sc);
+//-- $forum_main_end = $tp->simpleParse($FORUM_MAIN_END, $fVars);
+
+ $this->sc->wrapper('forum/main/end');
+ $forum_main_end = $tp->parseTemplate($FORUM_MAIN_END, true, $this->sc);
+
+ if($forum->prefs->get('enclose'))
+ {
+ $ns->tablerender($forum->prefs->get('title'), $forum_main_start . $forum_string . $forum_main_end, 'forum');
+ }
+ else
+ {
+ echo $forum_main_start . $forum_string . $forum_main_end;
+ }
+
+
+ require_once(FOOTERF);
+ }
+
+
+ function forum_rules($action = 'check')
+ {
+
+ if(ADMIN == true)
+ {
+ $type = 'forum_rules_admin';
+ }
+ elseif(USER == true)
+ {
+ $type = 'forum_rules_member';
+ }
+ else
+ {
+ $type = 'forum_rules_guest';
+ }
+ $result = e107::getDb()->select('generic', 'gen_chardata', "gen_type = '$type' AND gen_intdata = 1");
+ if($action == 'check')
+ {
+ return $result;
+ }
+
+ if($result)
+ {
+ $row = e107::getDb()->fetch();
+ $rules_text = e107::getParser()->toHTML($row['gen_chardata'], true);
+ }
+ else
+ {
+ $rules_text = LAN_FORUM_0072;
+ }
+
+ $text = '';
+
if(deftrue('BOOTSTRAP'))
{
$breadarray = array(
- array('text'=> e107::pref('forum','title', LAN_PLUGIN_FORUM_NAME), 'url' => e107::url('forum','index') ),
- array('text'=>LAN_FORUM_0030, 'url'=>null)
+ array('text' => e107::pref('forum', 'title', LAN_PLUGIN_FORUM_NAME), 'url' => e107::url('forum', 'index')),
+ array('text' => LAN_FORUM_0016, 'url' => null)
);
+ $text = e107::getForm()->breadcrumb($breadarray);
e107::breadcrumb($breadarray); // assign to {---BREADCRUMB---}
-
- $data['FORUM_BREADCRUMB'] = e107::getForm()->breadcrumb($breadarray);
}
- $data['_WRAPPER_'] = 'forum/track/start';
- $forum_track_start = $tp->parseTemplate($FORUM_TRACK_START, true, $data);
+ $text .= "" . $rules_text . "
";
+ $text .= "" . e107::getForm()->pagination(e107::url('forum', 'index'), LAN_BACK) . "
";
- $data['_WRAPPER_'] = 'forum/track/end';
- $forum_track_end = $tp->parseTemplate($FORUM_TRACK_END, true, $data);
-
-
- // if ($forum->prefs->get('enclose'))
- {
- // $ns->tablerender($forum->prefs->get('title'), $forum_track_start.$forum_trackstring.$forum_track_end, array('forum', 'main1'));
- }
- // else
- {
- $tracktext = $forum_track_start.$forum_trackstring.$forum_track_end;
- }
+ e107::getRender()->tablerender(LAN_FORUM_0016, $text, 'forum-rules');
}
- $text ='';
-
-
-
- $text .= $tracktext;
- $text .= "".e107::getForm()->pagination(e107::url('forum','index'), LAN_BACK)."
";
-
-
- e107::getRender()->tablerender(LAN_FORUM_0030, $text, 'forum-track');
-
- return null;
-}
-
-
-
-function parse_forum($f, $restricted_string = '')
-{
-
- global $FORUM_MAIN_FORUM, $forumList, $sc;
-
- $tp = e107::getParser();
-
- if(!empty($forumList['subs']) && is_array($forumList['subs'][$f['forum_id']]))
+ function forum_track()
{
- $lastPost = explode('.', $f['forum_lastpost_info']);
- $lastpost_datestamp = reset($lastPost);
- $ret = parse_subs($forumList, $f['forum_id'], $lastpost_datestamp);
- $f['forum_threads'] += $ret['threads'];
- $f['forum_replies'] += $ret['replies'];
- if(isset($ret['lastpost_info']))
+ global $forum;
+
+ $trackPref = $forum->prefs->get('track');
+ $trackEmailPref = $forum->prefs->get('trackemail', true);
+
+
+ if(empty($trackPref))
{
- $f['forum_lastpost_info'] = $ret['lastpost_info'];
- $f['forum_lastpost_user'] = $ret['lastpost_user'];
- $f['forum_lastpost_user_anon'] = $ret['lastpost_user_anon'];
- $f['user_name'] = $ret['user_name'];
+ echo "Disabled";
+
+ return false;
}
- $f['text'] = $ret['text'];
+
+ $FORUM_TEMPLATE = null;
+
+ include(e_PLUGIN . 'forum/templates/forum_template.php');
+
+ // Override with theme template
+ if(file_exists(THEME . 'forum_template.php'))
+ {
+ include(THEME . 'forum_template.php');
+ }
+ elseif(file_exists(THEME . 'templates/forum/forum_template.php'))
+ {
+ require(THEME . 'templates/forum/forum_template.php');
+ }
+
+ $IMAGE_nonew_small = IMAGE_nonew_small;
+ $IMAGE_new_small = IMAGE_new_small;
+
+ if(is_array($FORUM_TEMPLATE) && deftrue('BOOTSTRAP', false)) // new v2.x format.
+ {
+ $FORUM_TRACK_START = $FORUM_TEMPLATE['track']['start']; // $FORUM_TEMPLATE['track-start'];
+ $FORUM_TRACK_MAIN = $FORUM_TEMPLATE['track']['item']; // $FORUM_TEMPLATE['track-main'];
+ $FORUM_TRACK_END = $FORUM_TEMPLATE['track']['end']; // $FORUM_TEMPLATE['track-end'];
+
+ $IMAGE_nonew_small = IMAGE_nonew;
+ $IMAGE_new_small = IMAGE_new;
+
+ }
+
+ $sql = e107::getDb();
+ $tp = e107::getParser();
+
+ $trackDiz = ($trackEmailPref) ? LAN_FORUM_3040 : LAN_FORUM_3041;
+
+
+ if($trackedThreadList = $forum->getTrackedThreadList(USERID, 'list'))
+ {
+
+ $viewed = $forum->threadGetUserViewed();
+
+ $qry = "SELECT t.*,th.*, f.*,u.user_name FROM `#forum_track` AS t
+ LEFT JOIN `#forum_thread` AS th ON t.track_thread = th.thread_id
+ LEFT JOIN `#forum` AS f ON th.thread_forum_id = f.forum_id
+ LEFT JOIN `#user` AS u ON th.thread_lastuser = u.user_id
+ WHERE t.track_userid = " . USERID . " ORDER BY th.thread_lastpost DESC";
+
+ $forum_trackstring = '';
+ $data = array();
+ if($sql->gen($qry))
+ {
+ while($row = $sql->fetch())
+ {
+ // e107::getDebug()->log($row);
+ $row['thread_sef'] = eHelper::title2sef($row['thread_name'], 'dashl');
+
+ $data['NEWIMAGE'] = $IMAGE_nonew_small;
+
+ if($row['thread_datestamp'] > USERLV && !in_array($row['thread_id'], $viewed))
+ {
+ $data['NEWIMAGE'] = $IMAGE_new_small;
+ }
+
+ $data['LASTPOSTUSER'] = !empty($row['user_name']) ? " $row['user_name'], 'id' => $row['thread_lastuser'])) . "'>" . $row['user_name'] . " " : LAN_ANONYMOUS;
+ $data['LASTPOSTDATE'] = $tp->toDate($row['thread_lastpost'], 'relative');
+
+ $buttonId = "forum-track-button-" . intval($row['thread_id']);
+
+ $forumUrl = e107::url('forum', 'forum', $row);
+ $threadUrl = e107::url('forum', 'topic', $row, array('query' => array('last' => 1))); // ('forum/thread/view', $row); // configs will be able to map thread_* vars to the url
+ $data['TRACKPOSTNAME'] = "" . $row['forum_name'] . " / " . $tp->toHTML($row['thread_name'], false, 'TITLE') . ' ';
+ // $data['UNTRACK'] = "".LAN_FORUM_0070." ";
+
+
+ $data['UNTRACK'] = "" . IMAGE_track . " ";
+
+ $data['_WRAPPER_'] = 'forum/track/item';
+ $forum_trackstring .= $tp->parseTemplate($FORUM_TRACK_MAIN, true, $data);
+ }
+ }
+ // print_a($FORUM_TRACK_START);
+
+
+ if(deftrue('BOOTSTRAP'))
+ {
+ $breadarray = array(
+ array('text' => e107::pref('forum', 'title', LAN_PLUGIN_FORUM_NAME), 'url' => e107::url('forum', 'index')),
+ array('text' => LAN_FORUM_0030, 'url' => null)
+ );
+
+ e107::breadcrumb($breadarray); // assign to {---BREADCRUMB---}
+
+ $data['FORUM_BREADCRUMB'] = e107::getForm()->breadcrumb($breadarray);
+ }
+
+ $data['_WRAPPER_'] = 'forum/track/start';
+ $forum_track_start = $tp->parseTemplate($FORUM_TRACK_START, true, $data);
+
+ $data['_WRAPPER_'] = 'forum/track/end';
+ $forum_track_end = $tp->parseTemplate($FORUM_TRACK_END, true, $data);
+
+
+ // if ($forum->prefs->get('enclose'))
+ {
+ // $ns->tablerender($forum->prefs->get('title'), $forum_track_start.$forum_trackstring.$forum_track_end, array('forum', 'main1'));
+ }
+ // else
+ {
+ $tracktext = $forum_track_start . $forum_trackstring . $forum_track_end;
+ }
+ }
+
+
+ $text = '';
+
+
+ $text .= $tracktext;
+ $text .= "" . e107::getForm()->pagination(e107::url('forum', 'index'), LAN_BACK) . "
";
+
+
+ e107::getRender()->tablerender(LAN_FORUM_0030, $text, 'forum-track');
+
+ return null;
}
- $sc->setVars($f);
- $sc->wrapper('forum/main/forum');
-
- return $tp->parseTemplate($FORUM_MAIN_FORUM, true, $sc);
-}
-
-
-
-function parse_subs($forumList, $id, $lastpost_datestamp)
-{
-
- $tp = e107::getParser();
- $ret = array();
-
- $subList = $forumList['subs'][$id];
-
- $ret['text'] = '';
- $ret['threads'] = 0;
- $ret['replies'] = 0;
-
- foreach($subList as $sub)
+ private function parse_forum($f, $restricted_string = '')
{
- // print_a($sub);
- $ret['text'] .= ($ret['text'] ? ', ' : '');
+ global $FORUM_MAIN_FORUM, $forumList;
- $urlData = $sub;
- $urlData['parent_sef'] = $forumList['all'][$sub['forum_sub']]['forum_sef']; // = array('parent_sef'=>
- $suburl = e107::url('forum','forum', $urlData);
+ $tp = e107::getParser();
- $ret['text'] .= "".$tp->toHTML($sub['forum_name']).' ';
- $ret['threads'] += $sub['forum_threads'];
- $ret['replies'] += $sub['forum_replies'];
- $tmp = explode('.', $sub['forum_lastpost_info']);
-
- if($tmp[0] > $lastpost_datestamp)
+ if(!empty($forumList['subs']) && is_array($forumList['subs'][$f['forum_id']]))
{
- $ret['lastpost_info'] = $sub['forum_lastpost_info'];
- $ret['lastpost_user'] = $sub['forum_lastpost_user'];
- $ret['lastpost_user_anon'] = $sub['forum_lastpost_user_anon'];
- $ret['user_name'] = $sub['user_name'];
- $lastpost_datestamp = $tmp[0];
+ $lastPost = explode('.', $f['forum_lastpost_info']);
+ $lastpost_datestamp = reset($lastPost);
+ $ret = $this->parse_subs($forumList, $f['forum_id'], $lastpost_datestamp);
+
+ $f['forum_threads'] += $ret['threads'];
+ $f['forum_replies'] += $ret['replies'];
+ if(isset($ret['lastpost_info']))
+ {
+ $f['forum_lastpost_info'] = $ret['lastpost_info'];
+ $f['forum_lastpost_user'] = $ret['lastpost_user'];
+ $f['forum_lastpost_user_anon'] = $ret['lastpost_user_anon'];
+ $f['user_name'] = $ret['user_name'];
+ }
+
+ $f['text'] = $ret['text'];
}
+
+ $this->sc->setVars($f);
+
+ $this->sc->wrapper('forum/main/forum');
+
+ return $tp->parseTemplate($FORUM_MAIN_FORUM, true, $this->sc);
}
- return $ret;
+ function parse_subs($forumList, $id, $lastpost_datestamp)
+ {
+
+ $tp = e107::getParser();
+ $ret = array();
+
+ $subList = $forumList['subs'][$id];
+
+ $ret['text'] = '';
+ $ret['threads'] = 0;
+ $ret['replies'] = 0;
+
+ foreach($subList as $sub)
+ {
+ // print_a($sub);
+
+ $ret['text'] .= ($ret['text'] ? ', ' : '');
+
+ $urlData = $sub;
+ $urlData['parent_sef'] = $forumList['all'][$sub['forum_sub']]['forum_sef']; // = array('parent_sef'=>
+ $suburl = e107::url('forum', 'forum', $urlData);
+
+ $ret['text'] .= "" . $tp->toHTML($sub['forum_name']) . ' ';
+ $ret['threads'] += $sub['forum_threads'];
+ $ret['replies'] += $sub['forum_replies'];
+ $tmp = explode('.', $sub['forum_lastpost_info']);
+
+ if($tmp[0] > $lastpost_datestamp)
+ {
+ $ret['lastpost_info'] = $sub['forum_lastpost_info'];
+ $ret['lastpost_user'] = $sub['forum_lastpost_user'];
+ $ret['lastpost_user_anon'] = $sub['forum_lastpost_user_anon'];
+ $ret['user_name'] = $sub['user_name'];
+ $lastpost_datestamp = $tmp[0];
+ }
+ }
+
+
+ return $ret;
+ }
+
}
+require_once(e_PLUGIN . 'forum/forum_class.php');
+/** @var e107forum $forum */
+$forum = new e107forum;
+
+new forum_front($forum);
+
+
diff --git a/e107_plugins/forum/forum_admin.php b/e107_plugins/forum/forum_admin.php
index bd2f01255..7b5117906 100644
--- a/e107_plugins/forum/forum_admin.php
+++ b/e107_plugins/forum/forum_admin.php
@@ -28,18 +28,9 @@ e107::css('inline',"
");
-$legacy = false;
-if(E107_DEBUG_LEVEL > 0 && $legacy == true)
-{
- define('OLD_FORUMADMIN', true);
- //e107::getMessage()->addwarning("Experimental code now active. Using this page in debug mode active could break your forum configuration.");
-}
-// Generated e107 Plugin Admin Area
-if(!deftrue('OLD_FORUMADMIN'))
-{
class forum_admin extends e_admin_dispatcher
{
@@ -1222,1629 +1213,11 @@ if(!deftrue('OLD_FORUMADMIN'))
}
}
- new forum_admin();
+new forum_admin();
- require_once(e_ADMIN."auth.php");
- e107::getAdminUI()->runPage();
+require_once(e_ADMIN."auth.php");
+e107::getAdminUI()->runPage();
+require_once(e_ADMIN."footer.php");
- require_once(e_ADMIN."footer.php");
- exit;
-}
-
-/*
-$e_sub_cat = 'forum';
-
-require_once(e_ADMIN.'auth.php');
-require_once(e_HANDLER.'userclass_class.php');
-require_once(e_HANDLER.'form_handler.php');
-require_once(e_PLUGIN.'forum/forum_class.php');
-
-$for = new e107forum;
-$forum = new forumAdmin;
-
-$mes = e107::getMessage();
-$sql = e107::getDb();
-$tp = e107::getParser();
-
-$fPref = e107::getPlugConfig('forum', '', false);
-
-print_a($fPref);
-
-define('IMAGE_new', " ");
-define('IMAGE_sub', " ");
-define('IMAGE_nosub', " ");
-
-$deltest = array_flip($_POST);
-
-if (e_QUERY)
-{
- $tmp = explode('.', e_QUERY);
- $action = $tmp[0];
- $sub_action = $tmp[1];
- $id = $tmp[2];
- unset($tmp);
-}
-
-if(isset($_POST['delete']))
-{
- $tmp = array_pop(array_flip($_POST['delete']));
- list($delete, $del_id) = explode('_', $tmp);
-}
-
-if(isset($_POST['setMods']))
-{
- foreach($_POST['mods'] as $fid => $modid)
- {
- if($sql->update('forum',"forum_moderators = '{$modid}' WHERE forum_id = {$fid}"))
- {
- $mes->addSuccess(LAN_UPDATED);
- }
- else
- {
- $mes->addError(LAN_UPDATED_FAILED);
- }
-
- }
-
- $ns->tablerender($caption, $mes->render().$text);
-}
-
-
-if(isset($_POST['tools']))
-{
- $msg = '';
- if(isset($_POST['forum_all']))
- {
- $fList[]='all';
- }
- else
- {
- foreach(array_keys($_POST['forumlist']) as $k)
- {
- $fList[] = $k;
- }
- }
- foreach($fList as $fid)
- {
- if(isset($_POST['counts']))
- {
- $for->forumUpdateCounts($fid, $_POST['counts_threads']);
- $msg .= FORLAN_167.": $fid ";
- }
- if(isset($_POST['lastpost']))
- {
- $with_threads = (isset($_POST['lastpost_nothread'])) ? FALSE : TRUE;
- $for->forumUpdateLastpost('forum', $fid, $with_threads);
- $msg .= FORLAN_168.": $fid ";
- }
- }
- if(isset($_POST['userpostcounts']))
- {
- require_once(e_HANDLER.'user_extended_class.php');
- $ue = new e107_user_extended;
-
- $list = $for->getUserCounts();
- foreach($list as $uid => $cnt)
- {
- $ue->user_extended_setvalue($uid, 'user_plugin_forum_posts', $cnt, 'int');
- }
- $msg .= FORLAN_169.' ';
- }
- $mes->addSuccess($msg);
- $ns->tablerender($caption, $mes->render().$text);
-}
-
-
-
-if(isset($_POST['create_sub']))
-{
- $fid = (int)($sub_action);
- $tmp = array();
- $tmp['forum_name'] = $tp->toDB($_POST['subname_new']);
- $tmp['forum_description'] = $tp->toDB($_POST['subdesc_new']);
- $tmp['forum_order'] = (int)$_POST['suborder_new'];
-
- if($tmp['forum_name'] != '' && $sql->select('forum', '*', "forum_id = {$fid}"))
- {
- $row = $sql->fetch();
- $tmp['forum_parent'] = $row['forum_parent'];
- $tmp['forum_moderators'] = $row['forum_moderators'];
- $tmp['forum_class'] = $row['forum_class'];
- $tmp['forum_postclass'] = $row['forum_postclass'];
- $tmp['forum_sub'] = $fid;
- if($sql->insert('forum', $tmp))
- {
- $mes->addSuccess(LAN_CREATED);
- }
- else
- {
- $mes->addError(LAN_CREATED_FAILED);
- }
- }
- $ns->tablerender($caption, $mes->render().$text);
-}
-
-
-if(isset($_POST['update_subs']))
-{
- $msg = "";
- foreach(array_keys($_POST['subname']) as $id)
- {
- if($_POST['subname'][$id] == "")
- {
- if ($sql->delete("forum", "forum_id='$id' "))
- {
- $msg .= LAN_FORUM_1002." ". LAN_ID.":"." ".$id." ".LAN_DELETED." ";
- $cnt = $sql->delete("forum_thread", "thread_forum_id = {$id}");
- $msg .= $cnt." ".FORLAN_152." ".LAN_DELETED." ";
- }
- }
- else
- {
- $_name = $tp->toDB($_POST['subname'][$id]);
- $_desc = $tp->toDB($_POST['subdesc'][$id]);
- $_order = (int)$_POST['suborder'][$id];
- if($sql->update('forum', "forum_name='{$_name}', forum_description='{$_desc}', forum_order='{$_order}' WHERE forum_id = {$id}"))
- {
- $msg .= LAN_FORUM_1002 ." ". LAN_ID.":"." ".$id." ".LAN_UPDATED." ";
- }
- }
- }
- if($msg)
- {
- $mes->addSuccess($msg);
- $ns->tablerender($caption, $mes->render().$text);
- }
-}
-
-if(isset($_POST['submit_parent']))
-{
- unset($insert);
- $insert = array(
- 'forum_name' => $tp->toDB($_POST['forum_name']),
- 'forum_datestamp' => time(),
- 'forum_class' => (int)$_POST['forum_class'],
- 'forum_postclass' => (int)$_POST['forum_postclass'],
- 'forum_threadclass' => (int)$_POST['forum_threadclass'],
- );
-
- if($sql->insert('forum', $insert))
- {
- $mes->addSuccess(LAN_CREATED);
- }
- else
- {
- $mes->addError(LAN_CREATED_FAILED);
- }
-
- $ns->tablerender($caption, $mes->render().$text);
-}
-
-
-
-if(isset($_POST['update_parent']))
-{
- unset($update);
- $update = array(
- 'forum_name' => $tp->toDb($_POST['forum_name']),
- 'forum_datestamp' => time(),
- 'forum_class' => (int)$_POST['forum_class'],
- 'forum_postclass' => (int)$_POST['forum_postclass'],
- 'forum_threadclass' => (int)$_POST['forum_threadclass'],
- 'WHERE' => 'forum_id = '.(int)$id
- );
-
- if($sql->update('forum', $update))
- {
- $mes->addSuccess(LAN_UPDATED);
- }
- else
- {
- $mes->addError(LAN_UPDATED_FAILED);
- }
-
- $action = 'main';
- $ns->tablerender($caption, $mes->render().$text);
-}
-
-
-
-if(isset($_POST['submit_forum']))
-{
- $tmp = array();
- $tmp['forum_moderators'] = (int)$_POST['forum_moderators'];
- $tmp['forum_name'] = $tp->toDB($_POST['forum_name']);
- $tmp['forum_description'] = $tp->toDB($_POST['forum_description']);
- $tmp['forum_datestamp'] = time();
- $tmp['forum_class'] = (int)$_POST['forum_class'];
- $tmp['forum_postclass'] = (int)$_POST['forum_postclass'];
- $tmp['forum_threadclass'] = (int)$_POST['forum_threadclass'];
- $tmp['forum_parent'] = (int)$_POST['forum_parent'];
-
- if($sql->insert('forum', $tmp))
- {
- $mes->addSuccess(LAN_CREATED);
- }
- else
- {
- $mes->addError(LAN_CREATED_FAILED);
- }
- $ns->tablerender($caption, $mes->render().$text);
-}
-
-
-
-if(isset($_POST['update_forum']))
-{
- unset($_POST['update_forum']);
- $tmp['data'] = $_POST;
- $tmp['WHERE'] = 'forum_id = '.(int)$id;
-
- $tmp2['forum_moderators'] = $tmp['forum_moderators'];
- $tmp2['forum_class'] = $tmp['forum_class'];
- $tmp2['forum_postclass'] = $tmp['forum_postclass'];
- $tmp2['forum_threadclass'] = $tmp['forum_threadclass'];
- $tmp2['WHERE'] = 'forum_sub = '.(int)$id;
-
- $sql->update('forum', $tmp);
- $sql->update('forum', $tmp2);
-
- $mes->addSuccess(LAN_UPDATED);
- $ns->tablerender($caption, $mes->render().$text);
- $action = 'main';
-}
-
-
-
-if (isset($_POST['update_order']))
-{
- while (list($key, $id) = each($_POST['forum_order']))
- {
- $tmp = explode('.', $id);
- $sql->update('forum', "forum_order=".$tmp[1]." WHERE forum_id=".$tmp[0]);
- }
- $mes->addSuccess(LAN_UPDATED);
- $ns->tablerender($caption, $mes->render().$text);
-}
-
-
-
-if (isset($_POST['updateoptions']))
-{
- $fPref->set('notify', $_POST['email_notify']);
- $fPref->set('notify_on', $_POST['email_notify_on']);
- $fPref->set('poll', $_POST['forum_poll']);
- $fPref->set('popular', $_POST['forum_popular']);
- $fPref->set('track', $_POST['forum_track']);
- $fPref->set('eprefix', $_POST['forum_eprefix']);
- $fPref->set('enclose', $_POST['forum_enclose']);
- $fPref->set('title', $_POST['forum_title']);
- $fPref->set('postspage', $_POST['forum_postspage']);
- $fPref->set('threadspage', $_POST['forum_threadspage']);
- $fPref->set('html_post', $_POST['html_post']);
- $fPref->set('attach', $_POST['forum_attach']);
- $fPref->set('redirect', $_POST['forum_redirect']);
- $fPref->set('reported_post_email', $_POST['reported_post_email']);
- $fPref->set('tooltip', $_POST['forum_tooltip']);
- $fPref->set('tiplength', $_POST['forum_tiplength']);
- $fPref->set('hilightsticky', $_POST['forum_hilightsticky']);
- $fPref->set('maxwidth', $_POST['forum_maxwidth']);
- $fPref->set('linkimg', $_POST['forum_linkimg']);
- $fPref->save(true, true);
-
- $mes->addSuccess();
- $ns->tablerender($caption, $mes->render().$text);
-}
-
-
-
-if (isset($_POST['do_prune']))
-{
- $msg = $for->forumPrune($_POST['prune_type'], $_POST['prune_days'], $_POST['pruneForum']);
- $mes->addSuccess($msg);
- $action = 'main';
- $ns->tablerender($caption, $mes->render().$text);
-
-}
-
-
-if (isset($_POST['frsubmit']))
-{
- $guestrules = $tp->toDB($_POST['guestrules']);
- $memberrules = $tp->toDB($_POST['memberrules']);
- $adminrules = $tp->toDB($_POST['adminrules']);
- if(!$sql->update("generic", "gen_chardata ='$guestrules', gen_intdata='".$_POST['guest_active']."' WHERE gen_type='forum_rules_guest' "))
- {
- $sql->insert("generic", "0, 'forum_rules_guest', '".time()."', 0, '', '".$_POST['guest_active']."', '$guestrules' ");
- }
- if(!$sql->update("generic", "gen_chardata ='$memberrules', gen_intdata='".$_POST['member_active']."' WHERE gen_type='forum_rules_member' "))
- {
- $sql->insert("generic", "0, 'forum_rules_member', '".time()."', 0, '', '".$_POST['member_active']."', '$memberrules' ");
- }
- if(!$sql->update("generic", "gen_chardata ='$adminrules', gen_intdata='".$_POST['admin_active']."' WHERE gen_type='forum_rules_admin' "))
- {
- $sql->insert("generic", "0, 'forum_rules_admin', '".time()."', 0, '', '".$_POST['admin_active']."', '$adminrules' ");
- }
- $ns->tablerender($caption, $mes->render().$text);
-}
-
-if (vartrue($delete) == 'main') {
- if ($sql->delete('forum', "forum_id='$del_id' "))
- {
- $mes->addSuccess(LAN_DELETED);
- }
- else
- {
- $mes->addError(LAN_DELETED_FAILED);
- }
- $ns->tablerender($caption, $mes->render().$text);
-}
-
-
-if (vartrue($action) == 'create')
-{
- if ($sql->select('forum', '*', "forum_parent='0' "))
- {
- $forum->create_forums($sub_action, $id);
- }
- else
- {
- header('location:'.e_ADMIN.'forum.php');
- exit;
- }
-}
-
-if ($delete == 'cat')
-{
- if ($sql->delete('forum', "forum_id='$del_id' "))
- {
- $sql->delete('forum', "forum_parent='$del_id' ");
- $mes->addSuccess(LAN_DELETED);
- $action = 'main';
- }
- else
- {
- $mes->addError(LAN_DELETED_FAILED);
- }
-
- $ns->tablerender($caption, $mes->render().$text);
-}
-
-
-
-switch($action)
-{
- case 'delete':
- $forum->delete_item(intval($sub_action));
- break;
-
- case 'cat':
- $forum->create_parents($sub_action, $id);
- break;
-
- case 'order':
- $forum->show_existing_forums($sub_action, $id, true);
- break;
-
- case 'opt':
- $forum->show_prefs();
- break;
-
- case 'mods':
- $forum->show_mods();
- break;
-
- case 'tools':
- $forum->show_tools();
- break;
-
- case 'prune':
- $forum->show_prune();
- break;
-
- case 'rules':
- $forum->show_rules();
- break;
-
- case 'subs':
- $forum->show_subs($sub_action);
- break;
-
- case 'sr':
- $forum->show_reported($sub_action);
- break;
-}
-
-
-if ($delete == 'reported')
-{
- $sql->delete("generic", "gen_id='$del_id' ");
- $mes->addSuccess(LAN_DELETED);
-}
-
-
-if (!e_QUERY || $action == 'main')
-{
- $forum->show_existing_forums(vartrue($sub_action), vartrue($id));
-}
-
-require_once(e_ADMIN.'footer.php');
-// function headerjs()
-// {
-// $e107 = e107::getInstance();
-// $tp = e107::getParser();
-
-// // These functions need to be removed and replaced with the generic jsconfirm() function.
-// $headerjs = "";
-// return $headerjs;
-// }
-
-function forum_admin_adminmenu()
-{
- global $forum;
- global $action;
- $forum->show_options($action);
-}
-
-
-
-
-class forumAdmin
-{
-
- function show_options($action)
- {
-
- $sql = e107::getDb();
- if ($action == '') { $action = 'main'; }
-
- // ##### Display options ---------------------------------------------------------------------------------------------------------
- $var['main']['text'] = FORLAN_76;
- $var['main']['link'] = e_SELF;
- $var['cat']['text'] = FORLAN_83;
- $var['cat']['link'] = e_SELF.'?cat';
- if ($sql->select('forum', 'forum_id', "forum_parent='0' LIMIT 1"))
- {
- $var['create']['text'] = FORLAN_77;
- $var['create']['link'] = e_SELF.'?create';
- }
- $var['order']['text'] = FORLAN_78;
- $var['order']['link'] = e_SELF.'?order';
- $var['opt']['text'] = LAN_PREFS;
- $var['opt']['link'] = e_SELF.'?opt';
- $var['prune']['text'] = LAN_PRUNE;
- $var['prune']['link'] = e_SELF.'?prune';
- $var['rules']['text'] = LAN_FORUM_0016;
- $var['rules']['link'] = e_SELF.'?rules';
- $var['sr']['text'] = FORLAN_116;
- $var['sr']['link'] = e_SELF.'?sr';
- $var['mods']['text'] = LAN_FORUM_2003;
- $var['mods']['link'] = e_SELF.'?mods';
- $var['tools']['text'] = FORLAN_153;
- $var['tools']['link'] = e_SELF.'?tools';
-
- show_admin_menu(FORLAN_7, $action, $var);
- }
-
- // Initial delete function. Determines which delete routine should be applied.
- function delete_item($id)
- {
- // If a delete routine is cancelled, redirect back to forum listing
- if($_POST['cancel'])
- {
- $this->show_existing_forums(vartrue($sub_action), vartrue($id));
- return;
- }
-
- $sql = e107::getDb();
- $id = (int)$id;
-
- $confirm = isset($_POST['confirm']) ? true : false;
-
- if($confirm)
- {
- e107::getRender()->tablerender('Forums', e107::getMessage()->render().$txt);
- }
- else
- {
- $this->delete_show_confirm($txt);
- }
-
- if($row = $sql->retrieve('forum', 'forum_parent, forum_sub', "forum_id = {$id}"))
- {
- $txt = "";
-
- // is parent
- if($row['forum_parent'] == 0)
- {
- $txt .= $this->delete_parent($id, $confirm);
- }
- // is subforum
- elseif($row['forum_sub'] > 0)
- {
- $txt .= $this->delete_sub($id, $confirm);
- }
- // is forum
- else
- {
- $txt .= $this->delete_forum($id, $confirm);
- }
- }
- // forum_id not found, should not happen.
- else
- {
- $this->show_existing_forums(vartrue($sub_action), vartrue($id));
- return;
- }
- }
-
- function delete_parent($id, $confirm = false)
- {
- $sql = e107::getDb();
- $mes = e107::getMessage();
- $ns = e107::getRender();
-
- // check if parent contains forums and delete them if needed
- if($sql->select('forum', 'forum_id', 'forum_parent = '.$id))
- {
- $fList = $sql->rows();
- foreach($fList as $f)
- {
- $this->delete_forum($f['forum_id'], $confirm);
- }
- }
-
- if($confirm)
- {
- if($sql->delete('forum', "forum_id = {$id}"))
- {
- $mes->addSuccess(LAN_DELETED);
- }
- else
- {
- $mes->addError(LAN_DELETED_FAILED);
- }
- }
- }
-
- // function deleteForum($forumId)
- // {
- // $sql = e107::getDb();
- // $forumId = (int)$forumId;
-
- // // Check for any sub forums
- // if($sql->select('forum', 'forum_id', "forum_sub = {$forumId}"))
- // {
- // $list = $sql->rows();
- // foreach($list as $f)
- // {
- // $ret .= $this->deleteForum($f['forum_id']);
- // }
- // }
- // require_once(e_PLUGIN.'forum/forum_class.php');
- // $f = new e107Forum;
- // if($sql->delete('forum_thread', 'thread_id','thread_forum_id='.$forumId))
- // {
- // $list = $sql->rows();
- // foreach($list as $t)
- // {
- // $f->threadDelete($t['thread_id'], false);
- // }
- // }
- // return $sql->delete('forum', 'forum_id = '.$forumId);
- // }
-
- // delete forum
- function delete_forum($id, $confirm = false)
- {
- $sql = e107::getDb();
- $tp = e107::getParser();
- $ns = e107::getRender();
- $mes = e107::getMessage();
-
- // check if forum contains subforums
- if($sql->select('forum', 'forum_id', 'forum_sub = '.$id))
- {
- $fList = $sql->rows();
- foreach($fList as $f)
- {
- $this->delete_sub($f['forum_id'], $confirm);
- }
- }
- if($confirm)
- {
- if($this->deleteForum($id))
- {
- $mes->addSuccess(LAN_DELETED);
- }
- else
- {
- $mes->addError(LAN_DELETED_FAILED);
- }
- }
-
- $sql->select('forum', 'forum_name, forum_threads, forum_replies', 'forum_id = '.$id);
- $row = $sql->fetch();
-
- $mes->addInfo("Forum {$id} [".$tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads and {$row['forum_replies']} replies.");
- }
-
- function delete_sub($id, $confirm = FALSE)
- {
- $sql = e107::getDb();
- $tp = e107::getParser();
- $mes = e107::getMessage();
- $ns = e107::getRender();
-
- if($confirm)
- {
- if($this->deleteForum($id))
- {
- $mes->addSuccess(LAN_DELETED);
- }
- else
- {
- $mes->addError(LAN_DELETED);
- }
- }
-
- $sql->select('forum', '*', 'forum_id = '.$id);
- $row = $sql->fetch();
- $mes->addInfo("Sub-forum {$id} [".$tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads, {$row['forum_replies']} replies.");
- }
-
- function delete_show_confirm($message)
- {
- $mes = e107::getMessage();
-
- $mes->addInfo($message);
-
- $text = "
-
- ";
- e107::getRender()->tablerender('Forum'.SEP.'Delete forum(s)', $mes->render().$text);
- }
-
- function show_subs($id)
- {
- $sql = e107::getDb();
- $tp = e107::getParser();
- $ns = e107::getRender();
- $frm = e107::getForm();
- $txt = "
- ";
-
- $ns->tablerender(LAN_FORUM_0069, $txt);
- }
-
- function show_existing_forums($sub_action, $id, $mode = false)
- {
- global $for; // $e107
- $frm = e107::getForm();
- $sql = e107::getDb();
- $tp = e107::getParser();
- $mes = e107::getMessage();
- $ns = e107::getRender();
-
- $subList = $for->forumGetSubs();
-
- if (!$mode)
- {
- $text = "";
- }
- else
- {
- $text = "
";
- }
-
- if (!$parent_amount = $sql->select('forum', '*', "forum_parent='0' ORDER BY forum_order ASC"))
- {
- //$text .= "".FORLAN_29." ";
- $mes->addInfo(FORLAN_29);
- }
- else
- {
- $text .= "
-
-
- ".LAN_FORUM_1001."
- ".LAN_OPTIONS."
- ";
- while ($row = $sql->fetch())
- {
- $parentList[] = $row;
- }
- foreach($parentList as $parent)
- {
- $text .= "
-
- ".$parent['forum_name']."
- ".FORLAN_140.": ".e107::getUserClass()->getName($parent['forum_class'])." ".LAN_FORUM_2015.": ".e107::getUserClass()->getName($parent['forum_postclass'])."
- ";
-
- $text .= "";
-
- if ($mode)
- {
- $text .= "\n";
- for($a = 1; $a <= $parent_amount; $a++)
- {
- $text .= ($parent['forum_order'] == $a ? "$a \n" : "$a \n");
- }
- $text .= " ";
- }
- else
- {
- $text .= "
-
- ";
- }
- $text .= " ";
-
- $forumCount = $sql->select('forum', '*', "forum_parent='".$parent['forum_id']."' AND forum_sub = 0 ORDER BY forum_order ASC");
- if (!$forumCount)
- {
- $text .= "".FORLAN_29." ";
- }
- else
- {
- $forumList = array();
- while ($row = $sql->fetch())
- {
- $forumList[] = $row;
- }
- foreach($forumList as $forum)
- {
- $text .= "
-
- ".IMAGE_new." \n".$tp->toHTML($forum['forum_name'])." ";
-// ".IMAGE_new." \n".$tp->toHTML($forum['forum_name'])." ";
-
- $text .= "
- ".$tp->toHTML($forum['forum_description'])."
- ".FORLAN_140.": ".e107::getUserClass()->getName($forum['forum_class'])." ".LAN_FORUM_2015.": ".e107::getUserClass()->getName($forum['forum_postclass'])."
-
-
-
- ";
-
- if ($mode)
- {
- $text .= "\n";
- for($a = 1; $a <= $forumCount; $a++)
- {
- $sel = ($forum['forum_order'] == $a ? "selected='selected'" : '');
- $text .= "{$a} \n";
- }
- $text .= " ";
- }
- else
- {
- //$sub_img = count($subList[$forum['forum_parent']][$forum['forum_id']]) ? IMAGE_sub : IMAGE_nosub;
- $sub_img = ADMIN_DOWN_ICON;
- $sub_total = count($subList[$forum['forum_parent']][$forum['forum_id']]);
- $text .= "
-
- ";
- }
- $text .= " \n ";
- }
- }
- }
- }
-
- if (!$mode)
- {
- $text .= "
";
- $ns->tablerender(FORLAN_30, $mes->render() . $text);
- }
- else
- {
- $text .= "".$frm->admin_button('update_order', LAN_UPDATE, 'update')."
";
- $ns->tablerender(LAN_ORDER, $mes->render() . $text);
- }
-
- }
-
-
- function create_parents($sub_action, $id)
- {
- $frm = e107::getForm();
- $sql = e107::getDb();
- $tp = e107::getParser();
- $ns = e107::getRender();
-
- $id = (int)$id;
- if ($sub_action == 'edit' && !$_POST['update_parent'])
- {
- if ($sql->select('forum', '*', "forum_id=$id"))
- {
- $row = $sql->fetch();
- }
- }
- else
- {
- $row = array();
- $row['forum_name'] = '';
- $row['forum_class'] = e_UC_PUBLIC;
- $row['forum_postclass'] = e_UC_MEMBER;
- $row['forum_threadclass'] = e_UC_MEMBER;
- }
-
- $text = "
-
-
- ";
- if ($sub_action == 'edit')
- {
- $text .= $frm->admin_button('update_parent', LAN_UPDATE, 'update');
- }
- else
- {
- $text .= $frm->admin_button('submit_parent', LAN_CREATE, 'submit');
- }
- $text .= "
-
- ";
-
- $ns->tablerender(FORLAN_75, $text);
- }
-
- function create_forums($sub_action, $id)
- {
- //global $e107;
- $frm = e107::getForm();
- $sql = e107::getDb();
- $tp = e107::getParser();
- $ns = e107::getRender();
-
- $id = (int)$id;
- if ($sub_action == 'edit' && !$_POST['update_forum'])
- {
- if ($sql->select('forum', '*', "forum_id=$id"))
- {
- $fInfo = $sql->fetch();
- }
- }
- else
- {
- $fInfo = array(
- 'forum_parent' => 0,
- 'forum_moderators' => e_UC_ADMIN,
- 'forum_class' => e_UC_PUBLIC,
- 'forum_postclass' => e_UC_MEMBER,
- 'forum_threadclass' => e_UC_MEMBER
- );
- }
-
- $text = "
- \n
-
-
- ";
- if ($sub_action == "edit")
- {
- $text .= $frm->admin_button('update_forum', LAN_UPDATE, 'update');
- }
- else
- {
- $text .= $frm->admin_button('submit_forum', LAN_CREATE, 'submit');
- }
- $text .= "
-
-
-";
- $ns->tablerender(LAN_FORUM_1001, $text);
- }
-
-
- // function show_message($message)
- // {
-
- // e107::getRender();->tablerender('', $message);
- // }
-
-
- function show_tools()
- {
- $sql = e107::getDb();
- $ns = e107::getRender();
- $tp = e107::getParser();
- $frm = e107::getForm();
-
- $txt = "
-
-
-
- ".$frm->admin_button('tools', LAN_GO, 'submit')."
-
-
- ";
- $ns->tablerender(FORLAN_166, $txt);
- }
-
- function show_prefs()
- {
- global $fPref;
- $ns = e107::getRender();
- $sql = e107::getDb();
- //$e107 = e107::getInstance();
- $frm = e107::getForm();
- $mes = e107::getMessage();
-
- $poll_installed = e107::isInstalled('poll');
-
-
- if(!$poll_installed)
- {
- if($fPref->get('poll') == 1)
- {
- $fPref['forum_poll'] = e_UC_NOBODY;
- $fPref->save(false, true);
- }
- }
-
- $text = "
- \n
-
-
-
- ".$frm->admin_button('updateoptions', LAN_UPDATE, 'update')."
-
-
-";
- $ns->tablerender(FORLAN_7, $mes->render() . $text);
- }
-
- function show_reported($sub_action)
- {
- $rs = new form;
- $sql = e107::getDb();
- $ns = e107::getRender();
- $tp = e107::getParser();
- $mes = e107::getMessage();
-
- if ($sub_action) {
- $sql->select("generic", "*", "gen_id='".$sub_action."'");
- $row = $sql->fetch();
- $sql->select("user", "*", "user_id='". $row['gen_user_id']."'");
- $user = $sql->fetch();
- //$con = new convert;
- $text = "
-
-
-
-
-
-
- ".FORLAN_171.":
- #".$row['gen_intdata']."
-
-
- ".FORLAN_173.":
- ".$row['gen_ip']."
-
-
- ".FORLAN_174.":
- ".$user['user_name']."
-
-
-
- ".FORLAN_175.":
- ".e107::getDate()->convert_date($row['gen_datestamp'], "long")."
-
-
- ".LAN_FORUM_2046.":
- ".$row['gen_chardata']."
-
-
-
- ".$rs->form_open("post", e_SELF."?sr", "", "", "", " onsubmit=\"return confirm_('sr',".$row['gen_datestamp'].")\"")."
- ".$rs->form_button("submit", "delete[reported_{$row['gen_id']}]", FORLAN_172)."
- ".$rs->form_close()."
-
-
-
";
-
- $ns->tablerender(FORLAN_116, $text);
-
- }
- else
- {
- if ($reported_total = $sql->select("generic", "*", "gen_type='reported_post' OR gen_type='Reported Forum Post'"))
- {
- $text = "
-
-
- ".FORLAN_170."
- ".LAN_OPTIONS."
- ";
- while ($row = $sql->fetch())
- {
- $text .= "
-
- ".FORLAN_171." #".$row['gen_intdata']."
-
- ".$rs->form_open("post", e_SELF."?sr", "", "", "", " onsubmit=\"return confirm_('sr',".$row['gen_datestamp'].")\"")."
- ".$rs->form_button("submit", "delete[reported_{$row['gen_id']}]", FORLAN_172)."
- ".$rs->form_close()."
-
- ";
- }
- $text .= "
";
- }
- else
- {
- //$text = "".FORLAN_121."
";
- $mes->addInfo(FORLAN_121);
- }
- $ns->tablerender(FORLAN_116, $mes->render().$text);
- }
- }
-
- function show_prune()
- {
- $ns = e107::getRender();
- $sql = e107::getDB();
- $frm = e107::getForm();
-
- // $sql->select("forum", "forum_id, forum_name", "forum_parent!=0 ORDER BY forum_order ASC");
- $qry = "
- SELECT f.forum_id, f.forum_name, sp.forum_name AS sub_parent, fp.forum_name AS forum_parent
- FROM #forum AS f
- LEFT JOIN #forum AS sp ON sp.forum_id = f.forum_sub
- LEFT JOIN #forum AS fp ON fp.forum_id = f.forum_parent
- WHERE f.forum_parent != 0
- ORDER BY f.forum_parent ASC, f.forum_sub, f.forum_order ASC
- ";
- $sql->gen($qry);
- $forums = $sql->db_getList();
-
- $text = "
- \n
-
-
- ".$frm->admin_button('do_prune', LAN_PRUNE, 'submit')."
-
- ";
- $ns->tablerender(LAN_PRUNE, $text);
- }
-
-
- function show_mods()
- {
- global $for;
- $ns = e107::getRender();
- $sql = e107::getDB();
- //$e107 = e107::getInstance();
- $forumList = $for->forum_getforums('all');
- $parentList = $for->forum_getparents('list');
- $subList = $for->forumGetSubs('bysub');
- $frm = e107::getForm();
- $tp = e107::getParser();
-
- $txt = "
-
-
-
-
- ";
-
- foreach($parentList as $p)
- {
- $txt .= "
-
- ".$tp->toHTML($p['forum_name'])."
-
- ";
-
- foreach($forumList[$p['forum_id']] as $f)
- {
- $txt .= "
-
- {$f['forum_name']}
- ".e107::getUserClass()->uc_dropdown("mods[{$f['forum_id']}]", $f['forum_moderators'], 'admin,classes')."
-
- ";
- foreach($subList[$f['forum_id']] as $s)
- {
- $txt .= "
-
- {$s['forum_name']}
- ".e107::getUserClass()->uc_dropdown("mods[{$s['forum_id']}]", $s['forum_moderators'], 'admin,classes')."
-
- ";
- }
- }
- }
- $txt .= "
-
-
- ".$frm->admin_button('setMods', LAN_UPDATE, 'update')."
-
- ";
- $ns->tablerender(LAN_FORUM_2003, $txt);
- }
-*/
- //
-/*
- function show_rules()
- {
- $pref = e107::getPref();
- $ns = e107::getRender();
- $sql = e107::getDB();
- $tp = e107::getParser();
- $frm = e107::getForm();
-*/
- /*
- $sql->select("wmessage");
- list($null) = $sql->fetch();
- list($null) = $sql->fetch();
- list($null) = $sql->fetch();
- list($id, $guestrules, $wm_active4) = $sql->fetch();
- list($id, $memberrules, $wm_active5) = $sql->fetch();
- list($id, $adminrules, $wm_active6) = $sql->fetch();
- */
-
-/*
- if($sql->select('generic','*',"gen_type='forum_rules_guest'"))
- {
- $guest_rules = $sql->fetch();
- }
- if($sql->select('generic','*',"gen_type='forum_rules_member'"))
- {
- $member_rules = $sql->fetch();
- }
- if($sql->select('generic','*',"gen_type='forum_rules_admin'"))
- {
- $admin_rules = $sql->fetch();
- }
-
- $guesttext = $tp->toForm(vartrue($guest_rules['gen_chardata']));
- $membertext = $tp->toForm(vartrue($member_rules['gen_chardata']));
- $admintext = $tp->toForm(vartrue($admin_rules['gen_chardata']));
-
- $text = "
-
-
-
- ".$frm->admin_button('frsubmit', LAN_UPDATE, 'submit')."
-
- ";
-
- $ns->tablerender(WMGLAN_5, $text);
-
- echo "
-
- ";
-
- }
- }
- */
-
diff --git a/e107_plugins/forum/forum_conf.php b/e107_plugins/forum/forum_conf.php
deleted file mode 100644
index 64814a853..000000000
--- a/e107_plugins/forum/forum_conf.php
+++ /dev/null
@@ -1,222 +0,0 @@
-isInstalled('forum'))
-{
- e107::redirect('admin');
- exit;
-}
-
-$ns = e107::getRender();
-$tp = e107::getParser();
-
-require_once(e_PLUGIN.'forum/forum_class.php');
-$forum = new e107forum;
-
-e107::lan('forum', 'admin');
-//include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_conf.php');
-
-$e_sub_cat = 'forum';
-
-if(!USER || !isset($_GET['f']) || !isset($_GET['id']))
-{
- header('location:'.$e107::getUrl()->create('/'), array(), array('encode' => false, 'full' => 1));
- exit;
-}
-
-$id = (int)$_GET['id'];
-$action = $_GET['f'];
-
-$qry = "
-SELECT t.*, f.*, fp.forum_id AS forum_parent_id FROM #forum_thread as t
-LEFT JOIN #forum AS f ON t.thread_forum_id = f.forum_id
-LEFT JOIN #forum AS fp ON fp.forum_id = f.forum_parent
-WHERE t.thread_id = {$thread_id}
-";
-
-$threadInfo = $forum->threadGet($id);
-$modList = $forum->forumGetMods($threadInfo->forum_moderators);
-
-//var_dump($threadInfo);
-//var_dump($modList);
-
-//If user is not a moderator of indicated forum, redirect to index page
-if(!in_array(USERID, array_keys($modList)))
-{
- header('location:'.$e107::getUrl()->create('/'), array(), array('encode' => false, 'full' => 1));
- exit;
-}
-
-require_once(HEADERF);
-
-if (isset($_POST['deletepollconfirm']))
-{
- $sql->delete("poll", "poll_id='".intval($thread_parent)."' ");
- $sql->select("forum_thread", "*", "thread_id='".$thread_id."' ");
- $row = $sql->fetch();
- extract($row);
- $thread_name = str_replace("[poll] ", "", $thread_name);
- $sql->update("forum_thread", "thread_name='$thread_name' WHERE thread_id='$thread_id' ");
- $message = LAN_FORUM_5001;
- $url = e_PLUGIN."forum/forum_viewtopic.php?".$thread_id;
-}
-
-
-
-// Moved to forum_post.php
-/*
-if (isset($_POST['move']))
-{
-// print_a($_POST);
- require_once(e_PLUGIN.'forum/forum_class.php');
- $forum = new e107forum;
-
- $newThreadTitle = '';
- if($_POST['rename_thread'] == 'add')
- {
- $newThreadTitle = '['.LAN_FORUM_5021.']';
- $newThreadTitleType = 0;
- }
- elseif($_POST['rename_thread'] == 'rename' && trim($_POST['newtitle']) != '')
- {
- $newThreadTitle = $tp->toDB($_POST['newtitle']);
- $newThreadTitleType = 1;
- }
-
- $threadId = $_GET['id'];
- $toForum = $_POST['forum_move'];
-
- $forum->threadMove($threadId, $toForum, $newThreadTitle, $newThreadTitleType);
-
- $message = LAN_FORUM_5005;// XXX _URL_ thread name
- $url = $e107::getUrl()->create('forum/thread/view', 'id='.$threadId);
-}
-
-if (isset($_POST['movecancel']))
-{
- require_once(e_PLUGIN.'forum/forum_class.php');
- $forum = new e107forum;
- $postInfo = $forum->postGet($id, 0, 1);
-
- $message = LAN_FORUM_5006;
-// $url = e_PLUGIN."forum/forum_viewforum.php?".$info['forum_id'];
- $url = $e107::getUrl()->create('forum/forum/view', 'id='.$postInfo[0]['post_forum']);// XXX _URL_ thread name
-}
-
-
-
-*/
-
-
-
-if ($message)
-{
- $text = "';
- $ns->tablerender(LAN_FORUM_5008, $text);
- require_once(FOOTERF);
- exit;
-}
-
-if ($action == "delete_poll")
-{
- $text = "
- ".LAN_FORUM_5009."
-
-
-
-
-
- ";
- $ns->tablerender(LAN_UI_DELETE_LABEL, $text);
- require_once(FOOTERF);
- exit;
-}
-/*
-if ($action == 'move')
-{
- $postInfo = $forum->postGet($id, 0, 1);
-
- $frm = e107::getForm();
-
- $qry = "
- SELECT f.forum_id, f.forum_name, fp.forum_name AS forum_parent, sp.forum_name AS sub_parent
- FROM `#forum` AS f
- LEFT JOIN `#forum` AS fp ON f.forum_parent = fp.forum_id
- LEFT JOIN `#forum` AS sp ON f.forum_sub = sp.forum_id
- WHERE f.forum_parent != 0
- AND f.forum_id != ".(int)$threadInfo['thread_forum_id']."
- ORDER BY f.forum_parent ASC, f.forum_sub, f.forum_order ASC
- ";
-
- $sql->gen($qry);
- $fList = $sql->db_getList();
-
- $text = "
-
-
-
-
- ".LAN_FORUM_5019.":
-
- ";
-
-
- foreach($fList as $f)
- {
- if(substr($f['forum_name'], 0, 1) != '*')
- {
- $f['sub_parent'] = ltrim($f['sub_parent'], '*');
- $for_name = $f['forum_parent'].' > ';
- $for_name .= ($f['sub_parent'] ? $f['sub_parent'].' > ' : '');
- $for_name .= $f['forum_name'];
- $text .= "".$for_name." ";
- }
- }
- $text .= "
-
-
-
- ".LAN_FORUM_5026."
-
- ".$frm->radio('rename_thread','none',true, 'label='.LAN_FORUM_5022)."
- ".$frm->radio('rename_thread', 'add', false, array('label'=> LAN_ADD.' ['.LAN_FORUM_5021.'] '.LAN_FORUM_5024)). "
-
".$frm->radio('rename_thread','rename', false, array('label'=>LAN_FORUM_5025))."
- ".$frm->text('newtitle', $tp->toForm($threadInfo['thread_name']), 250)."
-
-
-
-
-
-
-
-
-
-
- ";
-
-
- $threadName = $tp->toHTML($threadInfo['thread_name'], true);
- $threadText = $tp->toHTML($postInfo[0]['post_entry'], true);
-
- $text .= "".$threadName." ".$threadText."
"; // $e107->ns->tablerender(, ), '', true).$ns->tablerender('', $text, '', true);
- $ns->tablerender(LAN_FORUM_5019, $text);
-
-}
-*/
-
-
-
-
-require_once(FOOTERF);
diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php
index 78213e9e6..9ea19139a 100644
--- a/e107_plugins/forum/forum_post.php
+++ b/e107_plugins/forum/forum_post.php
@@ -128,7 +128,7 @@ class forum_post_handler
if (!e_QUERY || empty($_GET['id']))
{
- $url = e107::url('forum','index',null,'full');
+ $url = e107::url('forum','index',null,['mode'=>'full']);
$this->redirect($url);
// header('Location:'.e107::getUrl()->create('forum/forum/main', array(), 'full=1&encode=0'));
exit;
@@ -183,7 +183,7 @@ class forum_post_handler
break;
default:
- $url = e107::url('forum','index',null,'full');
+ $url = e107::url('forum','index',null,['mode'=>'full']);
$this->redirect($url);
// header("Location:".e107::getUrl()->create('forum/forum/main', array(), 'full=1&encode=0'));
exit;
@@ -1756,7 +1756,7 @@ class forum_post_handler
require_once(HEADERF);
new forum_post_handler;
require_once(FOOTERF);
-exit;
+
diff --git a/e107_plugins/forum/forum_stats.php b/e107_plugins/forum/forum_stats.php
index a0afcc5f0..c8c167b9a 100644
--- a/e107_plugins/forum/forum_stats.php
+++ b/e107_plugins/forum/forum_stats.php
@@ -66,7 +66,7 @@ class forumStats
$firstpost = $sql->select('forum_post', 'post_datestamp', 'post_datestamp > 0 ORDER BY post_datestamp ASC LIMIT 0,1', 'default');
$fp = $sql->fetch();
- $open_ds = $fp['post_datestamp'];
+ $open_ds = (int) varset($fp['post_datestamp']);
$open_date = $gen->convert_date($open_ds, 'long');
$open_since = $gen -> computeLapse($open_ds);
$open_days = floor((time()-$open_ds) / 86400);
@@ -77,6 +77,8 @@ class forumStats
$query = "SHOW TABLE STATUS FROM `{$mySQLdefaultdb}`";
$sql->gen($query);
$array = $sql -> db_getList();
+ $db_size = 0;
+ $avg_row_len = 0;
foreach($array as $table)
{
if($table['Name'] == MPREFIX.'forum_post')
@@ -153,6 +155,7 @@ class forumStats
$top_repliers_data_c = $sql->db_getList('ALL', false, false, 'user_id');
$top_repliers = array();
+ $top_repliers_sort = array();
foreach($top_repliers_data as $uid => $poster)
{
$poster['post_count'] = $poster['post_count'] - $top_repliers_data_c[$uid]['thread_count'];
diff --git a/e107_plugins/forum/forum_test.php b/e107_plugins/forum/forum_test.php
deleted file mode 100644
index 041516672..000000000
--- a/e107_plugins/forum/forum_test.php
+++ /dev/null
@@ -1,20 +0,0 @@
-update_lastpost('thread',$i);
-//}
-
-set_time_limit(240);
-$forum->update_lastpost('forum', 'all');
-//$x = $forum->update_lastpost('forum',16);
-
-
-$timeend = microtime();
-$diff = number_format(((substr($timeend, 0, 9)) + (substr($timeend, -10)) - (substr($timestart, 0, 9)) - (substr($timestart, -10))), 4);
-echo " script generation took $diff s";
-
diff --git a/e107_plugins/forum/forum_update.php b/e107_plugins/forum/forum_update.php
index c3420bb6d..454a429aa 100644
--- a/e107_plugins/forum/forum_update.php
+++ b/e107_plugins/forum/forum_update.php
@@ -10,20 +10,23 @@
*
*/
-define('e_ADMIN_AREA', true);
-require_once ('../../class2.php');
+if(!defined('e_ADMIN_AREA'))
+{
+ define('e_ADMIN_AREA', true);
+}
+require_once(__DIR__ . '/../../class2.php');
-if (!getperms('P'))
+if(!getperms('P'))
{
e107::redirect();
- exit ;
+ exit;
}
-require_once (e_PLUGIN . 'forum/forum_class.php');
-require_once (e_ADMIN . 'auth.php');
+require_once(e_PLUGIN . 'forum/forum_class.php');
+require_once(e_ADMIN . 'auth.php');
-if (e_QUERY == "reset")
+if(e_QUERY == "reset")
{
unset($_SESSION['forumUpgrade']);
unset($_SESSION['forumupdate']);
@@ -36,6 +39,7 @@ if (e_QUERY == "reset")
$forum = new e107forum(true);
$timestart = microtime();
+global $f;
$f = new forumUpgrade;
$sql = e107::getDb();
@@ -44,24 +48,23 @@ if(!empty($_GET['reset']))
{
unset($_SESSION['forumUpgrade']);
unset($_SESSION['forumupdate']);
- $f -> updateInfo['currentStep'] = intval($_GET['reset']);
- $f -> setUpdateInfo();
+ $f->updateInfo['currentStep'] = intval($_GET['reset']);
+ $f->setUpdateInfo();
}
-
-if (e_AJAX_REQUEST)
+if(e_AJAX_REQUEST)
{
- if (!vartrue($_GET['mode']))
+ if(!vartrue($_GET['mode']))
{
echo "data-progress-mode not set!";
- exit ;
+ exit;
}
$func = 'step' . intval($_GET['mode']) . "_ajax";
- if (function_exists($func))
+ if(function_exists($func))
{
call_user_func($func);
}
@@ -70,69 +73,69 @@ if (e_AJAX_REQUEST)
echo $func . "() doesn't exist!";
}
- exit ;
+ exit;
}
-$upgradeNeeded = $f -> checkUpdateNeeded();
+$upgradeNeeded = $f->checkUpdateNeeded();
$upgradeNeeded = true;
-if (!$upgradeNeeded)
+if(!$upgradeNeeded)
{
$mes = e107::getMessage();
- $mes -> addInfo("The forum is already at the most recent version, no upgrade is required");
- $ns -> tablerender('Forum Upgrade', $mes -> render());
- require (e_ADMIN . 'footer.php');
- exit ;
+ $mes->addInfo("The forum is already at the most recent version, no upgrade is required");
+ $ns->tablerender('Forum Upgrade', $mes->render());
+ require(e_ADMIN . 'footer.php');
+ exit;
}
-if (isset($_POST) && count($_POST))
+if(isset($_POST) && count($_POST))
{
- if (isset($_POST['skip_attach']))
+ if(isset($_POST['skip_attach']))
{
- $f -> updateInfo['skip_attach'] = 1;
- $f -> updateInfo['currentStep'] = 2;
- $f -> setUpdateInfo();
+ $f->updateInfo['skip_attach'] = 1;
+ $f->updateInfo['currentStep'] = 2;
+ $f->setUpdateInfo();
}
- if (isset($_POST['nextStep']))
+ if(isset($_POST['nextStep']))
{
$tmp = array_keys($_POST['nextStep']);
- $f -> updateInfo['currentStep'] = $tmp[0];
- $f -> setUpdateInfo();
+ $f->updateInfo['currentStep'] = $tmp[0];
+ $f->setUpdateInfo();
}
}
-$currentStep = (isset($f -> updateInfo['currentStep']) ? $f -> updateInfo['currentStep'] : 1);
+$currentStep = (isset($f->updateInfo['currentStep']) ? $f->updateInfo['currentStep'] : 1);
$stepParms = (isset($stepParms) ? $stepParms : '');
//echo "currentStep = $currentStep ";
-if (function_exists('step' . $currentStep))
+if(function_exists('step' . $currentStep))
{
$result = call_user_func('step' . $currentStep, $stepParms);
}
-require (e_ADMIN . 'footer.php');
-exit ;
+require(e_ADMIN . 'footer.php');
+
function step1()
{
global $f;
- $f -> updateInfo['currentStep'] = 1;
- $f -> setUpdateInfo();
+ $f->updateInfo['currentStep'] = 1;
+ $f->setUpdateInfo();
$mes = e107::getMessage();
//Check attachment dir permissions
- if (!isset($f -> updateInfo['skip_attach']))
+ if(!isset($f->updateInfo['skip_attach']))
{
- $f -> checkAttachmentDirs();
- if (isset($f -> error['attach']))
+ $f->checkAttachmentDirs();
+ if(isset($f->error['attach']))
{
$text = "
ERROR:
The following errors have occured. These issues must be resolved if you ever want to enable attachment or image uploading in your forums. If you do not ever plan on enabling this setting in your forum, you may click the 'skip' button
";
- foreach ($f->error['attach'] as $e)
+ foreach($f->error['attach'] as $e)
{
$text .= '** ' . $e . ' ';
}
@@ -147,23 +150,24 @@ function step1()
}
else
{
- $mes -> addSuccess("Attachment and attachment/thumb directories are writable");
+ $mes->addSuccess("Attachment and attachment/thumb directories are writable");
$text = "
";
}
- e107::getRender() -> tablerender('Step 1: Attachment directory permissions', $mes -> render() . $text);
+ e107::getRender()->tablerender('Step 1: Attachment directory permissions', $mes->render() . $text);
}
}
function step2()
{
+
$mes = e107::getMessage();
$ns = e107::getRender();
- if (!isset($_POST['create_tables']))
+ if(!isset($_POST['create_tables']))
{
$text = "
This step will create the new forum_thread, forum_post, and forum_attach tables. It will also create a forum_new table that will become the 'real' forum table once the data from the current table is migrated.
@@ -172,26 +176,27 @@ function step2()
";
- $ns -> tablerender('Step 2: Forum table creation', $text);
+ $ns->tablerender('Step 2: Forum table creation', $text);
+
return;
}
// FIXME - use db_verify. ??
- require_once (e_HANDLER . 'db_table_admin_class.php');
+ require_once(e_HANDLER . 'db_table_admin_class.php');
$db = new db_table_admin;
$tabList = array(
- 'forum' => 'forum_new',
+ 'forum' => 'forum_new',
'forum_thread' => '',
- 'forum_post' => '',
- 'forum_track' => ''
+ 'forum_post' => '',
+ 'forum_track' => ''
);
//
$ret = '';
$failed = false;
$text = '';
$sql = e107::getDb();
- foreach ($tabList as $name => $rename)
+ foreach($tabList as $name => $rename)
{
$message = 'Creating table ' . ($rename ? $rename : $name);
@@ -199,26 +204,26 @@ function step2()
if($sql->isTable($curTable) && $sql->isEmpty($curTable))
{
- $mes -> addSuccess("Skipping table ".$name." (already exists)");
+ $mes->addSuccess("Skipping table " . $name . " (already exists)");
continue;
}
$result = $db->createTable(e_PLUGIN . 'forum/forum_sql.php', $name, true, $rename);
- if ($result === true)
+ if($result === true)
{
- $mes -> addSuccess($message);
+ $mes->addSuccess($message);
// $text .= 'Success ';
}
- elseif ($result !== true)
+ elseif($result !== true)
{
// $text .= 'Failed ';
- $mes -> addError($message);
+ $mes->addError($message);
$failed = true;
}
}
- if ($failed)
+ if($failed)
{
- $mes -> addError("Creation of table(s) failed. You can not continue until these are created successfully!");
+ $mes->addError("Creation of table(s) failed. You can not continue until these are created successfully!");
}
else
@@ -227,20 +232,20 @@ function step2()
";
}
- $ns -> tablerender('Step 2: Forum table creation', $mes -> render() . $text);
+ $ns->tablerender('Step 2: Forum table creation', $mes->render() . $text);
}
-
// FIXME - use e107::getPlugin()->manage_extended_field('add', $name, $attrib, $source)
function step3()
{
+
$ns = e107::getRender();
$mes = e107::getMessage();
$text = '';
$stepCaption = 'Step 3: Extended user field creation';
- if (!isset($_POST['create_extended']))
+ if(!isset($_POST['create_extended']))
{
$text = "
This step will create the new extended user fields required for the new forum code:
@@ -254,39 +259,40 @@ function step3()
";
- $ns -> tablerender($stepCaption, $text);
+ $ns->tablerender($stepCaption, $text);
+
return;
}
$fieldList = array(
- 'plugin_forum_posts' => 'integer',
+ 'plugin_forum_posts' => 'integer',
'plugin_forum_viewed' => 'radio'
);
$failed = false;
$ext = e107::getUserExt();
- foreach ($fieldList as $fieldName => $fieldType)
+ foreach($fieldList as $fieldName => $fieldType)
{
$result = $ext->user_extended_add_system($fieldName, $fieldType);
- if ($result === true)
+ if($result === true)
{
- $mes -> addSuccess('Creating extended user field user_' . $fieldName);
+ $mes->addSuccess('Creating extended user field user_' . $fieldName);
}
else
{
- $mes -> addError('Creating extended user field user_' . $fieldName);
- $mes->addDebug(print_a($result,true));
+ $mes->addError('Creating extended user field user_' . $fieldName);
+ $mes->addDebug(print_a($result, true));
$failed = true;
}
}
- if ($failed)
+ if($failed)
{
- $mes -> addError("Creation of extended field(s) failed. You can not continue until these are create successfully!");
+ $mes->addError("Creation of extended field(s) failed. You can not continue until these are create successfully!");
}
else
@@ -298,19 +304,20 @@ function step3()
";
}
- $ns -> tablerender($stepCaption, $mes -> render() . $text);
+ $ns->tablerender($stepCaption, $mes->render() . $text);
}
function step4()
{
+
global $pref;
$mes = e107::getMessage();
$ns = e107::getRender();
$stepCaption = 'Step 4: Move user specific forum data and forum prefs';
- if (!isset($_POST['move_user_data']))
+ if(!isset($_POST['move_user_data']))
{
$text = "
This step will move the main forum preferences into its own table row. It will also move all user_viewed data from user table into the user extended table.
@@ -322,7 +329,8 @@ function step4()
";
- $ns -> tablerender($stepCaption, $text);
+ $ns->tablerender($stepCaption, $text);
+
return;
}
@@ -330,14 +338,14 @@ function step4()
$fconf = e107::getPlugConfig('forum', '', false);
$coreConfig = e107::getConfig();
$old_prefs = array();
- foreach ($pref as $k => $v)
+ foreach($pref as $k => $v)
{
- if (substr($k, 0, 6) == 'forum_')
+ if(substr($k, 0, 6) == 'forum_')
{
$nk = substr($k, 6);
- $mes -> addDebug("Converting $k to $nk");
+ $mes->addDebug("Converting $k to $nk");
$old_prefs[$nk] = $v;
- $coreConfig -> remove($k);
+ $coreConfig->remove($k);
}
}
@@ -348,15 +356,15 @@ function step4()
//'email_notify_on'
);
- foreach ($forumPrefList as $_fp)
+ foreach($forumPrefList as $_fp)
{
- $mes -> addDebug("converting $_fp to $_fp");
- $old_prefs[$_fp] = $coreConfig -> get($_fp);
- $coreConfig -> remove($_fp);
+ $mes->addDebug("converting $_fp to $_fp");
+ $old_prefs[$_fp] = $coreConfig->get($_fp);
+ $coreConfig->remove($_fp);
}
- $fconf -> setPref($old_prefs) -> save(false, true);
- $coreConfig -> save(false, true);
+ $fconf->setPref($old_prefs)->save(false, true);
+ $coreConfig->save(false, true);
// -----Upgrade old menu prefs ----------------
@@ -366,22 +374,21 @@ function step4()
// --------------------
-
$result = array(
- 'usercount' => 0,
- 'viewcount' => 0,
+ 'usercount' => 0,
+ 'viewcount' => 0,
'trackcount' => 0
);
$db = new db;
- if ($db -> select('user', 'user_id, user_viewed, user_realm', "user_viewed != '' OR user_realm != ''"))
+ if($db->select('user', 'user_id, user_viewed, user_realm', "user_viewed != '' OR user_realm != ''"))
{
- require_once (e_HANDLER . 'user_extended_class.php');
+ require_once(e_HANDLER . 'user_extended_class.php');
$ue = new e107_user_extended;
- while ($row = $db -> fetch())
+ while($row = $db->fetch())
{
$result['usercount']++;
- $userId = (int)$row['user_id'];
+ $userId = (int) $row['user_id'];
$viewed = $row['user_viewed'];
$viewed = trim($viewed, '.');
@@ -397,35 +404,35 @@ function step4()
$debug .= 'viewed = ' . $viewed . ' ';
$debug .= 'realm = ' . $realm . ' ';
$debug .= 'tracking = ' . implode(',', $trackList) . ' ';
- // $debug .= print_a($trackList, true);
- // $mes -> addDebug($debug);
+ // $debug .= print_a($trackList, true);
+ // $mes -> addDebug($debug);
- if ($viewed != '')
+ if($viewed != '')
{
$ue->user_extended_setvalue($userId, 'plugin_forum_viewed', ($viewed));
$result['viewcount']++;
}
- if (is_array($trackList) && count($trackList))
+ if(is_array($trackList) && count($trackList))
{
- foreach ($trackList as $threadId)
+ foreach($trackList as $threadId)
{
$result['trackcount']++;
- $threadId = (int)$threadId;
- if ($threadId > 0)
+ $threadId = (int) $threadId;
+ if($threadId > 0)
{
$tmp = array();
$tmp['track_userid'] = $userId;
$tmp['track_thread'] = $threadId;
- e107::getDb() -> insert('forum_track', $tmp);
+ e107::getDb()->insert('forum_track', $tmp);
}
}
}
}
}
- $mes -> addSuccess("User data move results:
+ $mes->addSuccess("User data move results:
Number of users processed: {$result['usercount']}
Number of viewed data processed: {$result['viewcount']}
@@ -437,18 +444,19 @@ function step4()
";
- $ns -> tablerender($stepCaption, $mes -> render() . $text);
+ $ns->tablerender($stepCaption, $mes->render() . $text);
}
function step5()
{
+
$sql = e107::getDb();
$ns = e107::getRender();
$mes = e107::getMessage();
$stepCaption = 'Step 5: Migrate forum data';
- if (!isset($_POST['move_forum_data']))
+ if(!isset($_POST['move_forum_data']))
{
$text = "This step will copy all of your forum configuration from the `forum` table into the `forum_new` table.
Once the information is successfully copied, the existing 1.0 forum table will be renamed `forum_old` and the newly created `forum_new` table will be renamed `forum`.
@@ -458,29 +466,30 @@ function step5()
";
- $ns -> tablerender($stepCaption, $mes -> render() . $text);
+ $ns->tablerender($stepCaption, $mes->render() . $text);
+
return;
}
$counts = array(
'parents' => 0,
- 'forums' => 0,
- 'subs' => 0
+ 'forums' => 0,
+ 'subs' => 0
);
//XXX Typo on 'parents' ?
- if ($sql -> select('forum'))
+ if($sql->select('forum'))
{
- $forumList = $sql -> db_getList();
+ $forumList = $sql->db_getList();
$sefs = array();
- foreach ($forumList as $forum)
+ foreach($forumList as $forum)
{
- if ($forum['forum_parent'] == 0)
+ if($forum['forum_parent'] == 0)
{
$counts['parents']++;
}
- elseif ($forum['forum_sub'] != 0)
+ elseif($forum['forum_sub'] != 0)
{
$counts['subs']++;
}
@@ -492,19 +501,19 @@ function step5()
$tmp = $forum;
$tmp['forum_threadclass'] = $tmp['forum_postclass'];
$tmp['forum_options'] = '_NULL_';
- $forum_sef = eHelper::title2sef($forum['forum_name'],'dashl');
+ $forum_sef = eHelper::title2sef($forum['forum_name'], 'dashl');
if(isset($sefs[$forum_sef]))
- {
- $forum_sef .= "-2";
- }
+ {
+ $forum_sef .= "-2";
+ }
$tmp['forum_sef'] = $forum_sef;
- $sefs[$forum_sef] = true;
+ $sefs[$forum_sef] = true;
// $tmp['_FIELD_TYPES'] = $ftypes['_FIELD_TYPES'];
- if (!$sql -> insert('forum_new', $tmp))
+ if(!$sql->insert('forum_new', $tmp))
{
$mes->addDebug("Insert failed on " . print_a($tmp, true));
$mes->addError($sql->getLastErrorText());
@@ -514,9 +523,9 @@ function step5()
}
else
{
- $counts = array('parents'=>'n/a', 'forums'=>'n/a', 'subs'=>'n/a');
+ $counts = array('parents' => 'n/a', 'forums' => 'n/a', 'subs' => 'n/a');
}
- $mes -> addSuccess("
+ $mes->addSuccess("
Forum data move results:
Number of forum parents processed: {$counts['parents']}
@@ -525,35 +534,34 @@ function step5()
");
- $result = $sql -> gen('RENAME TABLE `#forum` TO `#forum_old` ') ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
- $mes -> add("Renaming forum to forum_old", $result);
+ $result = $sql->gen('RENAME TABLE `#forum` TO `#forum_old` ') ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
+ $mes->add("Renaming forum to forum_old", $result);
- $result = $sql -> gen('RENAME TABLE `#forum_new` TO `#forum` ') ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
- $mes -> add("Renaming forum_new to forum", $result);
+ $result = $sql->gen('RENAME TABLE `#forum_new` TO `#forum` ') ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
+ $mes->add("Renaming forum_new to forum", $result);
- $text = "
+ $text = "
";
- $ns -> tablerender($stepCaption, $mes -> render() . $text);
-
+ $ns->tablerender($stepCaption, $mes->render() . $text);
}
-
function step6()
{
+
$sql = e107::getDb();
$ns = e107::getRender();
$mes = e107::getMessage();
-
+
$stepCaption = 'Step 6: Thread and post data';
- $_SESSION['forumupdate']['thread_total'] = $sql -> count('forum_t', '(*)', "WHERE thread_parent = 0");
+ $_SESSION['forumupdate']['thread_total'] = $sql->count('forum_t', '(*)', "WHERE thread_parent = 0");
$_SESSION['forumupdate']['thread_count'] = 0;
$_SESSION['forumupdate']['thread_last'] = 0;
@@ -561,22 +569,22 @@ function step6()
Depending on your forum size and speed of server, this could take some time. ";
$text .= renderProgress("Begin thread data move", 6);
- $ns->tablerender($stepCaption, $mes -> render() . $text);
+ $ns->tablerender($stepCaption, $mes->render() . $text);
}
function renderProgress($caption, $step)
{
-
+
if(!$step)
{
- return "No step entered in function";
+ return "No step entered in function";
}
-
- $thisStep = 'step'.$step;
- $nextStep = 'step'.($step + 1);
-
+
+ $thisStep = 'step' . $step;
+ $nextStep = 'step' . ($step + 1);
+
$text = '
';
- $text .= "
-
- ";
-
+ $text .= "
+
+ ";
+
return $text;
}
-
function step6_ajax()
{
+
global $f;
$sql = e107::getDb();
@@ -612,16 +620,16 @@ function step6_ajax()
LIMIT 0, 300
";
- if ($sql -> gen($qry))
+ if($sql->gen($qry))
{
- $threadList = $sql -> db_getList();
+ $threadList = $sql->db_getList();
- foreach ($threadList as $t)
+ foreach($threadList as $t)
{
- $id = (int)$t['thread_id'];
- $result = $f -> migrateThread($id);
+ $id = (int) $t['thread_id'];
+ $result = $f->migrateThread($id);
- if ($result === false)
+ if($result === false)
{
echo "Error";
}
@@ -644,13 +652,12 @@ function step6_ajax()
}
-
-
function step7()
{
+
$ns = e107::getRender();
$stepCaption = 'Step 7: Calculate user post counts';
- if (!isset($_POST['calculate_usercounts']))
+ if(!isset($_POST['calculate_usercounts']))
{
$text = "
This step will calculate post count information for all users, as well as recount all for thread and reply counts.
@@ -659,20 +666,21 @@ function step7()
";
- $ns -> tablerender($stepCaption, $text);
+ $ns->tablerender($stepCaption, $text);
+
return;
}
global $forum;
- require_once (e_HANDLER . 'user_extended_class.php');
+ require_once(e_HANDLER . 'user_extended_class.php');
$ue = new e107_user_extended;
- $counts = $forum -> getUserCounts();
- foreach ($counts as $uid => $count)
+ $counts = $forum->getUserCounts();
+ foreach($counts as $uid => $count)
{
- $ue -> user_extended_setvalue($uid, 'user_plugin_forum_posts', $count, 'int');
+ $ue->user_extended_setvalue($uid, 'user_plugin_forum_posts', $count, 'int');
}
- $forum -> forumUpdateCounts('all', true);
+ $forum->forumUpdateCounts('all', true);
// var_dump($counts);
@@ -683,54 +691,51 @@ function step7()
";
- $ns -> tablerender($stepCaption, $text);
+ $ns->tablerender($stepCaption, $text);
}
-
-
-
-
-
-
function step8()
{
+
$sql = e107::getDb();
$mes = e107::getMessage();
-
+
$stepCaption = 'Step 8: Calculate last post information';
-
-
- $_SESSION['forumupdate']['lastpost_total'] = $sql -> count('forum', '(*)', "WHERE forum_parent != 0");
+
+
+ $_SESSION['forumupdate']['lastpost_total'] = $sql->count('forum', '(*)', "WHERE forum_parent != 0");
$_SESSION['forumupdate']['lastpost_count'] = 0;
$_SESSION['forumupdate']['lastpost_last'] = 0;
-
- $mes->addDebug("Total LastPost: ".$_SESSION['forumupdate']['lastpost_total']);
-
+
+ $mes->addDebug("Total LastPost: " . $_SESSION['forumupdate']['lastpost_total']);
+
$text = "
This step will recalculate all thread and forum lastpost information";
-
- $text .= renderProgress('Proceed with lastpost calculation',8);
-
- e107::getRender() -> tablerender($stepCaption, $mes->render(). $text);
+
+ $text .= renderProgress('Proceed with lastpost calculation', 8);
+
+ e107::getRender()->tablerender($stepCaption, $mes->render() . $text);
+
return;
-
+
}
function step8_ajax()
{
+
$sql = e107::getDb();
-
+
$lastThread = vartrue($_SESSION['forumupdate']['lastpost_last'], 0);
-
+
global $forum;
$parentList = [];
- if ($sql->select('forum', 'forum_id', 'forum_parent != 0 AND forum_id > '.$lastThread.' ORDER BY forum_id LIMIT 2'))
+ if($sql->select('forum', 'forum_id', 'forum_parent != 0 AND forum_id > ' . $lastThread . ' ORDER BY forum_id LIMIT 2'))
{
- while ($row = $sql->fetch())
+ while($row = $sql->fetch())
{
$parentList[] = $row['forum_id'];
}
@@ -753,15 +758,14 @@ function step8_ajax()
}
-
function step9()
{
$sql = e107::getDb();
$text = '';
-
+
$stepCaption = 'Step 9: Migrate poll information';
- if (!isset($_POST['migrate_polls']))
+ if(!isset($_POST['migrate_polls']))
{
$text = "
This step will recalculate all poll information that has been entered in the forums.
@@ -770,7 +774,8 @@ function step9()
";
- e107::getRender() -> tablerender($stepCaption, $text);
+ e107::getRender()->tablerender($stepCaption, $text);
+
return;
}
@@ -783,18 +788,18 @@ function step9()
$threadList = [];
- if ($sql -> gen($qry))
+ if($sql->gen($qry))
{
- while ($row = $sql -> fetch())
+ while($row = $sql->fetch())
{
$threadList[] = $row['thread_id'];
}
- foreach ($threadList as $threadId)
+ foreach($threadList as $threadId)
{
- if ($sql -> select('forum_thread', 'thread_options', 'thread_id = ' . $threadId, 'default'))
+ if($sql->select('forum_thread', 'thread_options', 'thread_id = ' . $threadId, 'default'))
{
- $row = $sql -> fetch();
- if ($row['thread_options'])
+ $row = $sql->fetch();
+ if($row['thread_options'])
{
$opts = unserialize($row['thread_options']);
$opts['poll'] = 1;
@@ -807,7 +812,7 @@ function step9()
$tmp['thread_options'] = serialize($opts);
$tmp['WHERE'] = 'thread_id = ' . $threadId;
// $tmp['_FIELD_TYPES']['thread_options'] = 'escape';
- $sql -> update('forum_thread', $tmp);
+ $sql->update('forum_thread', $tmp);
}
}
}
@@ -823,14 +828,13 @@ function step9()
";
- e107::getRender() -> tablerender($stepCaption, $text);
+ e107::getRender()->tablerender($stepCaption, $text);
}
-
-
function step10()
{
+
$sql = e107::getDb();
$ns = e107::getRender();
$mes = e107::getMessage();
@@ -838,12 +842,12 @@ function step10()
global $f;
$stepCaption = 'Step 10: Migrate forum attachments';
-
- $_SESSION['forumupdate']['attachment_total'] = $sql -> count('forum_post', '(*)', "WHERE post_entry LIKE '%public/%' ");
+
+ $_SESSION['forumupdate']['attachment_total'] = $sql->count('forum_post', '(*)', "WHERE post_entry LIKE '%public/%' ");
$_SESSION['forumupdate']['attachment_count'] = 0;
$_SESSION['forumupdate']['attachment_last'] = 0;
- if ($_SESSION['forumupdate']['attachment_total'] == 0)
+ if($_SESSION['forumupdate']['attachment_total'] == 0)
{
$text = "
No forum attachments found.
@@ -852,7 +856,8 @@ function step10()
";
- $ns -> tablerender($stepCaption, $text);
+ $ns->tablerender($stepCaption, $text);
+
return;
}
@@ -862,31 +867,32 @@ function step10()
";
- $text .= renderProgress("Begin attachment migration",10);
+ $text .= renderProgress("Begin attachment migration", 10);
- file_put_contents(e_LOG."forum_upgrade_attachments.log",''); // clear the log.
+ file_put_contents(e_LOG . "forum_upgrade_attachments.log", ''); // clear the log.
- $ns -> tablerender($stepCaption, $mes -> render() . $text);
+ $ns->tablerender($stepCaption, $mes->render() . $text);
}
/**
- * Attachments
+ * Attachments
*/
function step10_ajax()//TODO
{
+
$sql = e107::getDb();
global $f;
$lastPost = vartrue($_SESSION['forumupdate']['attachment_last'], 0);
$errorText = '';
-/*
- $qry = "
- SELECT post_id, post_thread, post_entry, post_user FROM `#forum_post`
- WHERE post_entry REGEXP '_[[:digit:]]'
- AND post_id > {$lastPost} ORDER BY post_id LIMIT 50
- ";
-*/
+ /*
+ $qry = "
+ SELECT post_id, post_thread, post_entry, post_user FROM `#forum_post`
+ WHERE post_entry REGEXP '_[[:digit:]]'
+ AND post_id > {$lastPost} ORDER BY post_id LIMIT 50
+ ";
+ */
$qry = "
SELECT post_id, post_thread, post_entry, post_user FROM `#forum_post`
@@ -896,18 +902,18 @@ function step10_ajax()//TODO
// file_put_contents(e_LOG."forum_update_step10.log",$qry."\n",FILE_APPEND);
$postList = [];
-
- if ($sql->gen($qry))
+
+ if($sql->gen($qry))
{
- while ($row = $sql->fetch())
+ while($row = $sql->fetch())
{
$postList[] = $row;
}
$i = 0;
$pcount = 0;
- $f -> log("Found " . count($postList) . " posts with attachments");
+ $f->log("Found " . count($postList) . " posts with attachments");
- foreach ($postList as $post)
+ foreach($postList as $post)
{
// echo htmlentities($post['post_entry'])." ";
$_SESSION['forumupdate']['attachment_last'] = $post['post_id'];
@@ -922,85 +928,84 @@ function step10_ajax()//TODO
//[link={e_FILE}public/1230091080_1_FT0_julia.jpg][img:width=60&height=45]{e_FILE}public/1230091080_1_FT0_julia_.jpg[/img][/link][br]
//Check for images with thumbnails linking to full size
-
- // if (preg_match_all('#\[link=(.*?)\]\[img.*?\]({e_FILE}.*?)\[/img\]\[/link\]#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
-
- if (preg_match_all('#\[link=([^\]]*?)\]\s*?\[img.*?\](({e_FILE}|e107_files|\.\./\.\./e107_files)[^\]]*)\[/img\]\s*?\[/link\]#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
- {
- foreach ($matches as $match)
- {
- $att = array();
- $att['thread_id'] = $post['post_thread'];
- $att['type'] = 'img';
- $att['html'] = $match[0];
- $att['name'] = str_replace (array("\r\n", "\n", "\r"), '', $match[1]);
- $att['thumb'] = $match[2];
- $attachments[] = $att;
- $foundFiles[] = $match[1];
- $foundFiles[] = $match[2];
- logAttachment($att['thread_id'],'link', $att['name']);
- }
- }
-
- if (preg_match_all('#\[lightbox=([^\]]*?)\]\s*?\[img.*?\](({e_FILE}|e107_files|\.\./\.\./e107_files)[^\]]*)\[/img\]\s*?\[/lightbox\]#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
- {
- foreach ($matches as $match)
- {
- $att = array();
- $att['thread_id'] = $post['post_thread'];
- $att['type'] = 'img';
- $att['html'] = $match[0];
- $att['name'] = str_replace (array("\r\n", "\n", "\r"), '', $match[1]);
- $att['thumb'] = $match[2];
- $attachments[] = $att;
- $foundFiles[] = $match[1];
- $foundFiles[] = $match[2];
- logAttachment($att['thread_id'],'lightbox', $att['name']);
- }
- }
-
-
-/*
- if (preg_match_all('#\[link=(.*?)\]\[img.*?\](\.\./\.\./e107_files/public/.*?)\[/img\]\[/link\]#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
+ // if (preg_match_all('#\[link=(.*?)\]\[img.*?\]({e_FILE}.*?)\[/img\]\[/link\]#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
+
+ if(preg_match_all('#\[link=([^\]]*?)\]\s*?\[img.*?\](({e_FILE}|e107_files|\.\./\.\./e107_files)[^\]]*)\[/img\]\s*?\[/link\]#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
{
- foreach ($matches as $match)
+ foreach($matches as $match)
{
$att = array();
$att['thread_id'] = $post['post_thread'];
$att['type'] = 'img';
$att['html'] = $match[0];
- $att['name'] = $match[1];
+ $att['name'] = str_replace(array("\r\n", "\n", "\r"), '', $match[1]);
$att['thumb'] = $match[2];
$attachments[] = $att;
$foundFiles[] = $match[1];
$foundFiles[] = $match[2];
- logAttachment($att['thread_id'],'link2', $att['name']);
+ logAttachment($att['thread_id'], 'link', $att['name']);
}
}
- */
+
+ if(preg_match_all('#\[lightbox=([^\]]*?)\]\s*?\[img.*?\](({e_FILE}|e107_files|\.\./\.\./e107_files)[^\]]*)\[/img\]\s*?\[/lightbox\]#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
+ {
+ foreach($matches as $match)
+ {
+ $att = array();
+ $att['thread_id'] = $post['post_thread'];
+ $att['type'] = 'img';
+ $att['html'] = $match[0];
+ $att['name'] = str_replace(array("\r\n", "\n", "\r"), '', $match[1]);
+ $att['thumb'] = $match[2];
+ $attachments[] = $att;
+ $foundFiles[] = $match[1];
+ $foundFiles[] = $match[2];
+ logAttachment($att['thread_id'], 'lightbox', $att['name']);
+ }
+ }
+
+
+ /*
+ if (preg_match_all('#\[link=(.*?)\]\[img.*?\](\.\./\.\./e107_files/public/.*?)\[/img\]\[/link\]#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
+ {
+ foreach ($matches as $match)
+ {
+ $att = array();
+ $att['thread_id'] = $post['post_thread'];
+ $att['type'] = 'img';
+ $att['html'] = $match[0];
+ $att['name'] = $match[1];
+ $att['thumb'] = $match[2];
+ $attachments[] = $att;
+ $foundFiles[] = $match[1];
+ $foundFiles[] = $match[2];
+ logAttachment($att['thread_id'],'link2', $att['name']);
+ }
+ }
+ */
//[img:width=604&height=453]{e_FILE}public/1229562306_1_FT0_julia.jpg[/img]
//Check for attached full-size images
-
+
;
-
- // if (preg_match_all('#\[img.*?\]({e_FILE}.*?_FT\d+_.*?)\[/img\]#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
- if (preg_match_all('#\[img[^\]]*?\]\s*?(({e_FILE}|e107_files|\.\./\.\./e107_files)[^\[]*)\s*?\[/img\]#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
+
+ // if (preg_match_all('#\[img.*?\]({e_FILE}.*?_FT\d+_.*?)\[/img\]#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
+ if(preg_match_all('#\[img[^\]]*?\]\s*?(({e_FILE}|e107_files|\.\./\.\./e107_files)[^\[]*)\s*?\[/img\]#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
{
- foreach ($matches as $match)
+ foreach($matches as $match)
{
//Ensure it hasn't already been handled above
- if (!in_array($match[1], $foundFiles))
+ if(!in_array($match[1], $foundFiles))
{
$att = array();
$att['thread_id'] = $post['post_thread'];
$att['type'] = 'img';
$att['html'] = $match[0];
- $att['name'] = str_replace (array("\r\n", "\n", "\r"), '', $match[1]);
+ $att['name'] = str_replace(array("\r\n", "\n", "\r"), '', $match[1]);
$att['thumb'] = '';
$attachments[] = $att;
- logAttachment($att['thread_id'],'img', $att['name']);
+ logAttachment($att['thread_id'], 'img', $att['name']);
}
}
}
@@ -1024,17 +1029,16 @@ function step10_ajax()//TODO
}
}
*/
-
-
+
+
//[file={e_FILE}public/1230090820_1_FT0_julia.zip]julia.zip[/file]
//Check for attached file (non-images)
-
-
-
- // if (preg_match_all('#\[file=({e_FILE}.*?)\](.*?)\[/file\]#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
- if (preg_match_all('#\[file=(({e_FILE}|e107_files|\.\./\.\./e107_files)[^\]]*)#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
+
+
+ // if (preg_match_all('#\[file=({e_FILE}.*?)\](.*?)\[/file\]#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
+ if(preg_match_all('#\[file=(({e_FILE}|e107_files|\.\./\.\./e107_files)[^\]]*)#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
{
- foreach ($matches as $match)
+ foreach($matches as $match)
{
$att = array();
$att['thread_id'] = $post['post_thread'];
@@ -1043,8 +1047,8 @@ function step10_ajax()//TODO
$att['name'] = $match[1];
$att['thumb'] = '';
$attachments[] = $att;
-
- logAttachment($att['thread_id'],'file', $att['name']);
+
+ logAttachment($att['thread_id'], 'file', $att['name']);
}
}
@@ -1063,21 +1067,20 @@ function step10_ajax()//TODO
}
}
*/
-
-
- if (count($attachments))
+
+ if(count($attachments))
{
$f->log("found " . count($attachments) . " attachments", true);
$newValues = array();
$info = array();
$info['post_entry'] = $post['post_entry'];
-
- foreach ($attachments as $attachment)
+
+ foreach($attachments as $attachment)
{
$error = '';
- // $f->log($attachment['name'], true);
- if ($f->moveAttachment($attachment, $post, $error))
+ // $f->log($attachment['name'], true);
+ if($f->moveAttachment($attachment, $post, $error))
{
$type = $attachment['type'];
$newValues[$type][] = basename($attachment['name']);
@@ -1086,41 +1089,40 @@ function step10_ajax()//TODO
else
{
$errorText .= "Failure processing post {$post['post_id']} - file {$attachment['name']} - {$error} ";
- $f -> log("Failure processing post {$post['post_id']} - file {$attachment['name']} - {$error}", true);
+ $f->log("Failure processing post {$post['post_id']} - file {$attachment['name']} - {$error}", true);
}
}
// echo $errorText." ";
// Did we make any changes at all?
- if (count($newValues))
+ if(count($newValues))
{
$info['WHERE'] = 'post_id = ' . $post['post_id'];
$info['post_attachments'] = e107::serialize($newValues);
- // $sql->update('forum_post', $info); // XXX FIXME TODO screwed up due to _FIELD_DEFS
-
- $sql->update('forum_post',"post_entry = \"".$info['post_entry']."\", post_attachments=\"".$info['post_attachments']."\" WHERE post_id = ".$post['post_id']."");
+ // $sql->update('forum_post', $info); // XXX FIXME TODO screwed up due to _FIELD_DEFS
+
+ $sql->update('forum_post', "post_entry = \"" . $info['post_entry'] . "\", post_attachments=\"" . $info['post_attachments'] . "\" WHERE post_id = " . $post['post_id'] . "");
}
-
+
}
-
+
}
-
- $totalOutput = round(($_SESSION['forumupdate']['attachment_count'] / $_SESSION['forumupdate']['attachment_total']) * 100, 1);
- echo $totalOutput;
-
-
-
- /*
- $debugRound = "
- forumupdate_attachment_count = ".$_SESSION['forumupdate']['attachment_count']."
- forumupdate_attachment_total = ".$_SESSION['forumupdate']['attachment_total']."
- calculated = ".$totalOutput."
-
- ";
-
- file_put_contents(e_LOG."forum_update_step10.log",$debugRound,FILE_APPEND);
- */
+
+ $totalOutput = round(($_SESSION['forumupdate']['attachment_count'] / $_SESSION['forumupdate']['attachment_total']) * 100, 1);
+ echo $totalOutput;
+
+
+ /*
+ $debugRound = "
+ forumupdate_attachment_count = ".$_SESSION['forumupdate']['attachment_count']."
+ forumupdate_attachment_total = ".$_SESSION['forumupdate']['attachment_total']."
+ calculated = ".$totalOutput."
+
+ ";
+
+ file_put_contents(e_LOG."forum_update_step10.log",$debugRound,FILE_APPEND);
+ */
}
else
{
@@ -1132,19 +1134,21 @@ function step10_ajax()//TODO
function logAttachment($thread, $type, $attach)
{
- $tab = ($type == 'img') ? "\t\t\t" : "\t\t";
-
- $text = $thread."\t\t".$type.$tab.$attach."\n";
- file_put_contents(e_LOG."forum_upgrade_attachments.log",$text, FILE_APPEND);
+
+ $tab = ($type == 'img') ? "\t\t\t" : "\t\t";
+
+ $text = $thread . "\t\t" . $type . $tab . $attach . "\n";
+ file_put_contents(e_LOG . "forum_upgrade_attachments.log", $text, FILE_APPEND);
}
-
-
+
function step11()
{
+
$ns = e107::getRender();
+ $text = '';
$stepCaption = 'Step 11: Delete old attachments';
- if (!isset($_POST['delete_orphans']))
+ if(!isset($_POST['delete_orphans']))
{
$text = "
The previous versions of the forum had difficulty deleting attachment files when posts or threads were deleted.
@@ -1159,29 +1163,28 @@ function step11()
";
- e107::getRender() -> tablerender($stepCaption, $text);
+ e107::getRender()->tablerender($stepCaption, $text);
+
return;
}
global $forum;
- require_once (e_HANDLER . 'file_class.php');
- $f = new e_file;
- $flist = $f -> get_files(e_FILE . 'public', '_\d+_FT\d+_');
+ $flist = e107::getFile()->get_files(e_FILE . 'public', '_\d+_FT\d+_');
$numFiles = count($flist);
- if ($numFiles)
+ if($numFiles)
{
- if ($_POST['delete_orphans'] == 'Delete files')
+ if($_POST['delete_orphans'] == 'Delete files')
{
//Do the deletion
$success = 0;
$failText = '';
- foreach ($flist as $file)
+ foreach($flist as $file)
{
$fileName = e_FILE . 'public/' . $file['fname'];
$r = unlink($fileName);
- if ($r)
+ if($r)
{
$success++;
}
@@ -1190,7 +1193,7 @@ function step11()
$failText .= "Deletion failed: {$file['fname']} ";
}
}
- if ($failText)
+ if($failText)
{
$failText = " The following failures occured: " . $failText;
}
@@ -1202,14 +1205,15 @@ function step11()
";
- $ns -> tablerender($stepCaption, $text);
+ $ns->tablerender($stepCaption, $text);
+
return;
}
$text = "There were {$numFiles} orphaned files found ";
- if ($_POST['delete_orphans'] == 'Show files' || $numFiles < 31)
+ if($_POST['delete_orphans'] == 'Show files' || $numFiles < 31)
{
$i = 1;
- foreach ($flist as $file)
+ foreach($flist as $file)
{
$text .= $i++ . ') ' . $file['fname'] . ' ';
}
@@ -1227,7 +1231,8 @@ function step11()
";
- $ns -> tablerender($stepCaption, $text);
+ $ns->tablerender($stepCaption, $text);
+
return;
}
else
@@ -1239,13 +1244,15 @@ function step11()
";
- $ns -> tablerender($stepCaption, $text);
+ $ns->tablerender($stepCaption, $text);
+
return;
}
}
function step12()
{
+
$sql = e107::getDb();
$ns = e107::getRender();
$mes = e107::getMessage();
@@ -1254,7 +1261,7 @@ function step12()
$stepCaption = 'Step 12: Delete old forum data';
- if (!isset($_POST['delete_old']) && !isset($_POST['skip_delete_old']))
+ if(!isset($_POST['delete_old']) && !isset($_POST['skip_delete_old']))
{
$text = "
The forum upgrade should now be complete. During the upgrade process the old forum tables were
@@ -1266,61 +1273,68 @@ function step12()
";
- $ns -> tablerender($stepCaption, $text);
+ $ns->tablerender($stepCaption, $text);
+
return;
}
- if (vartrue($_POST['delete_old']))
+ if(vartrue($_POST['delete_old']))
{
$qryArray = array(
"DROP TABLE `#forum_old`",
"DROP TABLE `#forum_t`",
);
- foreach ($qryArray as $qry)
+ foreach($qryArray as $qry)
{
- $sql -> gen($qry);
+ $sql->gen($qry);
}
}
-
- unset($_SESSION['forumUpgrade']);
- $ret = $f -> setNewVersion();
- $mes -> addSuccess("Congratulations, the forum upgrade is now completed! {$ret}");
-
- $text = "Return to e107 Update ";
-
- $ns -> tablerender($stepCaption, $mes -> render() . $text);
+ unset($_SESSION['forumUpgrade']);
+ $ret = $f->setNewVersion();
+
+ $mes->addSuccess("Congratulations, the forum upgrade is now completed! {$ret}");
+
+ $text = "Return to e107 Update ";
+
+ $ns->tablerender($stepCaption, $mes->render() . $text);
+
return;
}
+
class forumUpgrade
{
+
private $newVersion = '2.0';
var $error = array();
- public $updateInfo;
+ public $updateInfo = array();
private $attachmentData;
private $logf;
public function __construct()
{
- $this -> updateInfo['lastThread'] = 0;
- $this -> attachmentData = array();
- $this -> logf = e_LOG . 'forum_upgrade.log';
- $this -> getUpdateInfo();
+
+ $this->updateInfo['lastThread'] = 0;
+ $this->attachmentData = array();
+ $this->logf = e_LOG . 'forum_upgrade.log';
+ $this->getUpdateInfo();
}
public function log($msg, $append = true)
{
+
// echo "logf = ".$this->logf." ";
$txt = sprintf("%s - %s\n", date('m/d/Y H:i:s'), $msg);
// echo $txt." ";
$flag = ($append ? FILE_APPEND : '');
- file_put_contents($this -> logf, $txt, $flag);
+ file_put_contents($this->logf, $txt, $flag);
}
public function checkUpdateNeeded()
{
+
return true;
// include_once(e_PLUGIN.'forum/forum_update_check.php');
// $needed = update_forum_08('check');
@@ -1329,6 +1343,7 @@ class forumUpgrade
function checkAttachmentDirs()
{
+
$dirs = array(
e_MEDIA . 'plugins/',
e_MEDIA . 'plugins/forum/',
@@ -1336,20 +1351,20 @@ class forumUpgrade
e_MEDIA . 'plugins/forum/attachments/thumb'
);
- foreach ($dirs as $dir)
+ foreach($dirs as $dir)
{
- if (!file_exists($dir))
+ if(!file_exists($dir))
{
- if (!mkdir($dir, 0755, true))
+ if(!mkdir($dir, 0755, true))
{
- $this -> error['attach'][] = "Directory '{$dir}' does not exist and I was unable to create it";
+ $this->error['attach'][] = "Directory '{$dir}' does not exist and I was unable to create it";
}
}
else
{
- if (!is_writable($dir))
+ if(!is_writable($dir))
{
- $this -> error['attach'][] = "Directory '{$dir}' exits, but is not writeable";
+ $this->error['attach'][] = "Directory '{$dir}' exits, but is not writeable";
}
}
}
@@ -1357,15 +1372,16 @@ class forumUpgrade
function getUpdateInfo()
{
+
$sql = e107::getDb();
- if ($_SESSION['forumUpgrade'])
+ if(isset($_SESSION['forumUpgrade']))
{
- $this -> updateInfo = $_SESSION['forumUpgrade'];
+ $this->updateInfo = $_SESSION['forumUpgrade'];
}
else
{
- $this -> updateInfo = array();
+ $this->updateInfo = array();
}
return;
@@ -1374,16 +1390,19 @@ class forumUpgrade
function setUpdateInfo()
{
- $_SESSION['forumUpgrade'] = $this -> updateInfo;
+
+ $_SESSION['forumUpgrade'] = $this->updateInfo;
+
return;
}
function setNewVersion()
{
+
// $sql = e107::getDb();
- // $sql -> update('plugin', "plugin_version = '{$this->newVersion}' WHERE plugin_name='Forum' OR plugin_name = 'LAN_PLUGIN_FORUM_NAME'");
- // e107::getConfig()->setPref('plug_installed/forum', $this->newVersion)->save(false,true,false);
+ // $sql -> update('plugin', "plugin_version = '{$this->newVersion}' WHERE plugin_name='Forum' OR plugin_name = 'LAN_PLUGIN_FORUM_NAME'");
+ // e107::getConfig()->setPref('plug_installed/forum', $this->newVersion)->save(false,true,false);
e107::getPlugin()->refresh('forum');
@@ -1392,29 +1411,30 @@ class forumUpgrade
function migrateThread($threadId)
{
+
global $forum;
- $threadId = (int)$threadId;
+ $threadId = (int) $threadId;
$result = false;
$sql = e107::getDb();
- if ($sql->select('forum_t', '*', "thread_parent = {$threadId} OR thread_id = {$threadId}", 'default'))
+ if($sql->select('forum_t', '*', "thread_parent = {$threadId} OR thread_id = {$threadId}", 'default'))
{
$threadData = $sql->db_getList();
- foreach ($threadData as $post)
+ foreach($threadData as $post)
{
- if ($post['thread_parent'] == 0)
+ if($post['thread_parent'] == 0)
{
- $result = $this -> addThread($post);
- if ($result)
+ $result = $this->addThread($post);
+ if($result)
{
- $result = $this -> addPost($post);
+ $result = $this->addPost($post);
}
}
else
{
- $result = $this -> addPost($post);
+ $result = $this->addPost($post);
}
}
@@ -1430,6 +1450,7 @@ class forumUpgrade
function addThread(&$post)
{
+
global $forum;
/*
@@ -1469,9 +1490,9 @@ class forumUpgrade
* thread_sef
*/
- $detected = mb_detect_encoding($post['thread_name']); // 'ISO-8859-1'
- $threadName = iconv($detected,'UTF-8', $post['thread_name']);
-
+ $detected = mb_detect_encoding($post['thread_name']); // 'ISO-8859-1'
+ $threadName = iconv($detected, 'UTF-8', $post['thread_name']);
+
$thread = array();
$thread['thread_id'] = $post['thread_id'];
$thread['thread_name'] = $threadName;
@@ -1481,18 +1502,18 @@ class forumUpgrade
$thread['thread_views'] = $post['thread_views'];
$thread['thread_active'] = $post['thread_active'];
$thread['thread_sticky'] = $post['thread_s'];
- $thread['thread_lastuser'] = $this->getLastUser($post['thread_lastuser']);
+ $thread['thread_lastuser'] = $this->getLastUser($post['thread_lastuser']);
$thread['thread_total_replies'] = $post['thread_total_replies'];
- $userInfo = $this -> getUserInfo($post['thread_user']);
+ $userInfo = $this->getUserInfo($post['thread_user']);
$thread['thread_user'] = $userInfo['user_id'];
$thread['thread_user_anon'] = $userInfo['anon_name'];
// If thread marked as 'tracked by starter', we must convert to using
// forum_track table
- if ($thread['thread_active'] == 99 && $thread['thread_user'] > 0)
+ if($thread['thread_active'] == 99 && $thread['thread_user'] > 0)
{
- $forum -> track('add', $thread['thread_user'], $thread['thread_id'], true);
+ $forum->track('add', $thread['thread_user'], $thread['thread_id'], true);
$thread['thread_active'] = 1;
}
@@ -1520,34 +1541,34 @@ class forumUpgrade
return 0;
}
- list($num,$name) = explode(".",$string,2);
+ list($num, $name) = explode(".", $string, 2);
return intval($num);
}
-
function addPost(&$post)
{
+
global $forum;
-
- $detected = mb_detect_encoding($post['thread_thread']); // 'ISO-8859-1'
- $postEntry = iconv($detected,'UTF-8', $post['thread_thread']);
+
+ $detected = mb_detect_encoding($post['thread_thread']); // 'ISO-8859-1'
+ $postEntry = iconv($detected, 'UTF-8', $post['thread_thread']);
$newPost = array();
- $newPost['post_id'] = $post['thread_id'];
- $newPost['post_thread'] = ($post['thread_parent'] == 0 ? $post['thread_id'] : $post['thread_parent']);
- $newPost['post_entry'] = $postEntry;
- $newPost['post_forum'] = $post['thread_forum_id'];
- $newPost['post_datestamp'] = $post['thread_datestamp'];
+ $newPost['post_id'] = $post['thread_id'];
+ $newPost['post_thread'] = ($post['thread_parent'] == 0 ? $post['thread_id'] : $post['thread_parent']);
+ $newPost['post_entry'] = $postEntry;
+ $newPost['post_forum'] = $post['thread_forum_id'];
+ $newPost['post_datestamp'] = $post['thread_datestamp'];
$newPost['post_edit_datestamp'] = ($post['thread_edit_datestamp'] ? $post['thread_edit_datestamp'] : '_NULL_');
- $userInfo = $this -> getUserInfo($post['thread_user']);
+ $userInfo = $this->getUserInfo($post['thread_user']);
- $newPost['post_user'] = $userInfo['user_id'];
- $newPost['post_user_anon'] = $userInfo['anon_name'];
- $newPost['post_ip'] = $userInfo['user_ip'];
+ $newPost['post_user'] = $userInfo['user_id'];
+ $newPost['post_user_anon'] = $userInfo['anon_name'];
+ $newPost['post_ip'] = $userInfo['user_ip'];
// $newPost['_FIELD_TYPES'] = $forum->fieldTypes['forum_post'];
// $newPost['_FIELD_TYPES']['post_entry'] = 'escape'; //use escape to prevent
@@ -1555,7 +1576,7 @@ class forumUpgrade
// print_a($newPost);
// exit;
- $sql = e107::getDb() ;
+ $sql = e107::getDb();
$result = $sql->insert('forum_post', $newPost);
@@ -1570,35 +1591,37 @@ class forumUpgrade
function getUserInfo($info)
{
- $tmp = explode('.', $info);
- $id = (int)$tmp[0];
- // Set default values
- $ret = array(
- 'user_id' => 0,
- 'user_ip' => '_NULL_',
- 'anon_name' => '_NULL_'
- );
+ $tmp = explode('.', $info);
+ $id = (int) $tmp[0];
- // Check if post is done anonymously (ID = 0, and there should be a chr(1) value between the username and IP address)
- if(strpos($info, chr(1)) !== false && $id == 0)
- {
- $anon = explode(chr(1), $info);
- $anon_name = explode('.', $anon[0]);
+ // Set default values
+ $ret = array(
+ 'user_id' => 0,
+ 'user_ip' => '_NULL_',
+ 'anon_name' => '_NULL_'
+ );
- $ret['anon_name'] = $anon_name[1];
- $ret['user_ip'] = e107::getIPHandler()->ipEncode($anon[1]);
- }
- // User id is known - NOT anonymous
- {
- $ret['user_id'] = $id;
- }
+ // Check if post is done anonymously (ID = 0, and there should be a chr(1) value between the username and IP address)
+ if(strpos($info, chr(1)) !== false && $id == 0)
+ {
+ $anon = explode(chr(1), $info);
+ $anon_name = explode('.', $anon[0]);
- return $ret;
+ $ret['anon_name'] = $anon_name[1];
+ $ret['user_ip'] = e107::getIPHandler()->ipEncode($anon[1]);
+ }
+ // User id is known - NOT anonymous
+ {
+ $ret['user_id'] = $id;
+ }
+
+ return $ret;
}
function moveAttachment($attachment, $post, &$error)
{
+
global $forum;
set_time_limit(30);
$tp = e107::getParser();
@@ -1606,7 +1629,7 @@ class forumUpgrade
$post_id = $post['post_id'];
$newPath = $forum->getAttachmentPath($post['post_user']);
- if (!is_dir($newPath))
+ if(!is_dir($newPath))
{
mkdir($newPath, 0755);
}
@@ -1621,49 +1644,52 @@ class forumUpgrade
$new = $newPath . "/" . $fileInfo['basename'];
$hash = md5($new);
- if (!file_exists($old))
+ if(!file_exists($old))
{
- if (isset($this -> attachmentData[$hash]))
+ if(isset($this->attachmentData[$hash]))
{
- $error = "Post {$post_id} - Attachment already migrated with post: " . $this -> attachmentData[$hash];
+ $error = "Post {$post_id} - Attachment already migrated with post: " . $this->attachmentData[$hash];
}
else
{
$error = 'Original attachment not found (orphaned?)';
}
+
return false;
}
- if (!file_exists($new))
+ if(!file_exists($new))
{
- $this -> log("Copying [{$old}] -> [{$new}]");
+ $this->log("Copying [{$old}] -> [{$new}]");
$r = rename($old, $new);
- $this -> attachmentData[$hash] = $post_id;
+ $this->attachmentData[$hash] = $post_id;
// $r = true;
}
else
{
//File already exists, show some sort of error
- if (isset($this -> attachmentData[$hash]))
+ if(isset($this->attachmentData[$hash]))
{
- $error = "Post {$post_id} - Attachment already migrated with post: " . $this -> attachmentData[$hash];
+ $error = "Post {$post_id} - Attachment already migrated with post: " . $this->attachmentData[$hash];
}
else
{
$error = 'Attachment file already exists';
}
+
return false;
}
- if (!$r)
+ if(!$r)
{
//File copy failed!
$error = 'Moving of attachments failed';
+
return false;
}
$oldThumb = '';
- if ($attachment['thumb'])
+ if($attachment['thumb'])
{
$tmp = explode('/', $attachment['thumb']);
$fileInfo = pathinfo($attachment['thumb']);
@@ -1673,7 +1699,7 @@ class forumUpgrade
$newThumb = e_MEDIA . 'files/plugins/forum/attachments/thumb/' . $fileInfo['basename'];
$hash = md5($newThumb);
- if (!file_exists($newThumb))
+ if(!file_exists($newThumb))
{
$r = rename($oldThumb, $newThumb);
// $r = true;
@@ -1681,20 +1707,22 @@ class forumUpgrade
else
{
//File already exists, show some sort of error
- if (isset($this -> attachmentData[$hash]))
+ if(isset($this->attachmentData[$hash]))
{
- $error = "Post {$post_id} - Thumb already migrated with post: " . $this -> attachmentData[$hash];
+ $error = "Post {$post_id} - Thumb already migrated with post: " . $this->attachmentData[$hash];
}
else
{
$error = 'Thumb file already exists';
}
+
return false;
}
- if (!$r)
+ if(!$r)
{
//File copy failed
$error = 'Moving of thumb failed';
+
return false;
}
}
@@ -1703,52 +1731,56 @@ class forumUpgrade
// $r = true;
// $r = unlink($old);
//if (!$r)
- // {
- // $error = 'Was unable to delete old attachment: '.$old;
- // return false;
- // }
- // if ($oldThumb)
- // {
- // $r = true;
- // $r = unlink($oldThumb);
- //if (!$r)
// {
- // $error = 'Was unable to delete old thumb: '.$oldThumb;
- // return false;
+ // $error = 'Was unable to delete old attachment: '.$old;
+ // return false;
+ // }
+ // if ($oldThumb)
+ // {
+ // $r = true;
+ // $r = unlink($oldThumb);
+ //if (!$r)
+ // {
+ // $error = 'Was unable to delete old thumb: '.$oldThumb;
+ // return false;
+ // }
// }
- // }
return true;
}
}
+
function createThreadLimitDropdown($count)
{
+
$ret = "
";
$last = min($count, 10000);
- if ($count < 2000)
+ if($count < 2000)
{
$ret .= "{$count} ";
}
else
{
- for ($i = 2000; $i < $count; $i += 2000)
+ for($i = 2000; $i < $count; $i += 2000)
{
$ret .= "{$i} ";
}
- if ($count < 10000)
+ if($count < 10000)
{
$ret .= "{$count} ";
}
}
$ret .= ' ';
+
return $ret;
}
function forum_update_adminmenu()
{
+
$action = 1;
$var[1]['text'] = '1 - Permissions';
@@ -1786,11 +1818,11 @@ function forum_update_adminmenu()
$var[12]['text'] = '12 - Delete old forum data';
$var[12]['link'] = '#';
-
+
if(E107_DEBUG_LEVEL)
{
$var[13]['divider'] = true;
-
+
$var[14]['text'] = 'Reset';
$var[14]['link'] = e_SELF . "?reset";
@@ -1802,15 +1834,14 @@ function forum_update_adminmenu()
$var[17]['text'] = 'Reset to 7';
$var[17]['link'] = e_SELF . "?step=7&reset=7";
-
+
$var[18]['text'] = 'Reset to 10';
$var[18]['link'] = e_SELF . "?step=10&reset=10";
-
- }
-
-
- if (isset($_GET['step']))
+ }
+
+
+ if(isset($_GET['step']))
{
// $action = key($_POST['nextStep']);
$action = intval($_GET['step']);
diff --git a/e107_plugins/forum/forum_uploads.php b/e107_plugins/forum/forum_uploads.php
index f6a957957..dcbf3c6d6 100644
--- a/e107_plugins/forum/forum_uploads.php
+++ b/e107_plugins/forum/forum_uploads.php
@@ -26,7 +26,7 @@ e107::lan('forum', "front", true);
-if(is_array($_POST['delete']))
+if(!empty($_POST['delete']) && is_array($_POST['delete']))
{
foreach(array_keys($_POST['delete']) as $fname)
{
@@ -48,7 +48,7 @@ if(is_array($_POST['delete']))
include_once(e_HANDLER."file_class.php");
include_once(HEADERF);
-if($msg)
+if(!empty($msg))
{
$ns->tablerender(LAN_FORUM_7004, $msg);
}
@@ -68,7 +68,7 @@ if(is_array($fileList))
- ".FRMUP_5."
+ ".defset('LAN_FORUM_7010', "Filename")."
".LAN_FORUM_7006."
";
foreach($fileList as $finfo)
@@ -110,12 +110,15 @@ if(is_array($fileList))
}
$txt .= "
";
}
-if(!$filecount) {
+if(!$filecount)
+{
$ns->tablerender(LAN_FORUM_7001,LAN_FORUM_7009);
- include_once(FOOTERF);
- exit;
+}
+else
+{
+ $ns->tablerender(LAN_FORUM_7001, $txt);
}
-$ns->tablerender(LAN_FORUM_7001, $txt);
-include_once(FOOTERF);
+
+require_once(FOOTERF);
diff --git a/e107_plugins/forum/forum_viewforum.php b/e107_plugins/forum/forum_viewforum.php
index ada8fd2e6..500ae0d50 100644
--- a/e107_plugins/forum/forum_viewforum.php
+++ b/e107_plugins/forum/forum_viewforum.php
@@ -86,7 +86,7 @@
$sc = e107::getScBatch('viewforum', 'forum');
- $forumId = (int) $_REQUEST['id'];
+ $forumId = (int) varset($_REQUEST['id']);
if(!$forumId && e_QUERY) // BC Fix for old links.
{
@@ -98,10 +98,8 @@
if(!$forum->checkPerm($forumId, 'view'))
{
- // header('Location:'.e107::getUrl()->create('forum/forum/main'));
-
$url = e107::url('forum', 'index', null, ['mode'=>'full']);
-
+/*
if(E107_DEBUG_LEVEL > 0)
{
print_a($_REQUEST);
@@ -110,7 +108,7 @@
echo " forumId: " . $forumId;
exit;
}
-
+*/
e107::getRedirect()->go($url);
diff --git a/e107_plugins/forum/languages/English/English_front.php b/e107_plugins/forum/languages/English/English_front.php
index 8952f23f0..88b3e0648 100644
--- a/e107_plugins/forum/languages/English/English_front.php
+++ b/e107_plugins/forum/languages/English/English_front.php
@@ -305,7 +305,7 @@ define("LAN_FORUM_7006","Result"); // LAN_FORUM_7006
define("LAN_FORUM_7007","Found in thread"); // LAN_FORUM_7007
define("LAN_FORUM_7008","NOT FOUND"); // LAN_FORUM_7008
define("LAN_FORUM_7009","No uploaded files found"); // LAN_FORUM_7009
-
+define("LAN_FORUM_7010", "Filename");
// -------- Tracking Email ------------