mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Some forum code cleanup
This commit is contained in:
@@ -25,6 +25,30 @@ if (!$e107->isInstalled('forum'))
|
||||
|
||||
e107::lan('forum', "front", true);
|
||||
|
||||
|
||||
class forum_front
|
||||
{
|
||||
private $sc;
|
||||
|
||||
function __construct($forum)
|
||||
{
|
||||
$this->init($forum);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
public function init($forum)
|
||||
{
|
||||
|
||||
global $FORUM_TEMPLATE, $FORUM_MAIN_FORUM, $forumList ;
|
||||
|
||||
$ns = e107::getRender();
|
||||
$tp = e107::getParser();
|
||||
|
||||
$text = '';
|
||||
|
||||
if(!deftrue('BOOTSTRAP'))
|
||||
{
|
||||
$bcDefs = array(
|
||||
@@ -37,8 +61,7 @@ if(!deftrue('BOOTSTRAP'))
|
||||
}
|
||||
|
||||
|
||||
require_once(e_PLUGIN.'forum/forum_class.php');
|
||||
$forum = new e107forum;
|
||||
|
||||
|
||||
if(e_AJAX_REQUEST)
|
||||
{
|
||||
@@ -60,10 +83,9 @@ if ($untrackId = varset($_REQUEST['untrack']))
|
||||
|
||||
if(isset($_GET['f']))
|
||||
{
|
||||
if(isset($_GET['id']))
|
||||
{
|
||||
$id = (int)$_GET['id'];
|
||||
}
|
||||
|
||||
$id = (isset($_GET['id'])) ? (int) $_GET['id'] : null;
|
||||
|
||||
|
||||
switch($_GET['f'])
|
||||
{
|
||||
@@ -96,9 +118,8 @@ else
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** @var forum_shortcodes $sc */
|
||||
$sc = e107::getScBatch('forum', true);
|
||||
/** @var forum_shortcodes $this->sc */
|
||||
$this->sc = e107::getScBatch('forum', true);
|
||||
|
||||
|
||||
if(empty($FORUM_TEMPLATE))
|
||||
@@ -151,14 +172,14 @@ require_once(HEADERF);
|
||||
$forumList = $forum->forumGetForumList();
|
||||
$newflag_list = $forum->forumGetUnreadForums();
|
||||
|
||||
$sc->newFlagList = $newflag_list;
|
||||
$this->sc->newFlagList = $newflag_list;
|
||||
|
||||
|
||||
if(!$forumList)
|
||||
{
|
||||
$ns->tablerender(LAN_PLUGIN_FORUM_NAME, LAN_FORUM_0067, 'forum-empty');
|
||||
require_once(FOOTERF);
|
||||
exit;
|
||||
return null;
|
||||
}
|
||||
|
||||
$forum_string = '';
|
||||
@@ -168,11 +189,11 @@ foreach ($forumList['parents'] as $parent)
|
||||
|
||||
$parent = (array) $parent;
|
||||
|
||||
$sc->setVars($parent);
|
||||
// $sc->setScVar('forumParent', $parent);
|
||||
$sc->wrapper('forum/main/parent');
|
||||
$this->sc->setVars($parent);
|
||||
// $this->sc->setScVar('forumParent', $parent);
|
||||
$this->sc->wrapper('forum/main/parent');
|
||||
|
||||
$forum_string .= $tp->parseTemplate($FORUM_MAIN_PARENT, true, $sc);
|
||||
$forum_string .= $tp->parseTemplate($FORUM_MAIN_PARENT, true, $this->sc);
|
||||
|
||||
$fid = $parent['forum_id'];
|
||||
if(empty($forumList['forums'][$parent['forum_id']]))
|
||||
@@ -186,29 +207,29 @@ foreach ($forumList['parents'] as $parent)
|
||||
{
|
||||
if($f['forum_class'] == e_UC_ADMIN && ADMIN)
|
||||
{
|
||||
$forum_string .= parse_forum($f, LAN_FORUM_0005);
|
||||
$forum_string .= $this->parse_forum($f, LAN_FORUM_0005);
|
||||
}
|
||||
elseif($f['forum_class'] == e_UC_MEMBER && USER)
|
||||
{
|
||||
$forum_string .= parse_forum($f, LAN_FORUM_0006);
|
||||
$forum_string .= $this->parse_forum($f, LAN_FORUM_0006);
|
||||
}
|
||||
elseif($f['forum_class'] == e_UC_READONLY)
|
||||
{
|
||||
$forum_string .= parse_forum($f, LAN_FORUM_0007);
|
||||
$forum_string .= $this->parse_forum($f, LAN_FORUM_0007);
|
||||
}
|
||||
elseif($f['forum_class'] && check_class($f['forum_class']))
|
||||
{
|
||||
$forum_string .= parse_forum($f, LAN_FORUM_0008);
|
||||
$forum_string .= $this->parse_forum($f, LAN_FORUM_0008);
|
||||
}
|
||||
elseif(!$f['forum_class'])
|
||||
{
|
||||
$forum_string .= parse_forum($f);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,22 +242,23 @@ foreach ($forumList['parents'] as $parent)
|
||||
|
||||
if(e_QUERY == 'new')
|
||||
{
|
||||
$forum_newstring = '';
|
||||
//-- $nVars = new e_vars;
|
||||
$newThreadList = $forum->threadGetNew(10);
|
||||
foreach($newThreadList as $thread)
|
||||
{
|
||||
$sc->setVars($thread);
|
||||
$forum_newstring .= $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $sc);
|
||||
$this->sc->setVars($thread);
|
||||
$forum_newstring .= $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $this->sc);
|
||||
}
|
||||
|
||||
if(empty($newThreadList))
|
||||
{
|
||||
$forum_newstring = $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $sc);
|
||||
$forum_newstring = $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $this->sc);
|
||||
|
||||
}
|
||||
|
||||
$forum_new_start = $tp->parseTemplate($FORUM_NEWPOSTS_START, true, $sc);
|
||||
$forum_new_end = $tp->parseTemplate($FORUM_NEWPOSTS_END, true, $sc);
|
||||
$forum_new_start = $tp->parseTemplate($FORUM_NEWPOSTS_START, true, $this->sc);
|
||||
$forum_new_end = $tp->parseTemplate($FORUM_NEWPOSTS_END, true, $this->sc);
|
||||
|
||||
if($forum->prefs->get('enclose'))
|
||||
{
|
||||
@@ -249,19 +271,18 @@ if (e_QUERY == 'new')
|
||||
}
|
||||
|
||||
|
||||
|
||||
$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);
|
||||
$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);
|
||||
|
||||
$sc->wrapper('forum/main/end');
|
||||
$forum_main_end = $tp->parseTemplate($FORUM_MAIN_END, true, $sc);
|
||||
$this->sc->wrapper('forum/main/end');
|
||||
$forum_main_end = $tp->parseTemplate($FORUM_MAIN_END, true, $this->sc);
|
||||
|
||||
if($forum->prefs->get('enclose'))
|
||||
{
|
||||
@@ -274,9 +295,12 @@ else
|
||||
|
||||
|
||||
require_once(FOOTERF);
|
||||
}
|
||||
|
||||
|
||||
function forum_rules($action = 'check')
|
||||
{
|
||||
|
||||
if(ADMIN == true)
|
||||
{
|
||||
$type = 'forum_rules_admin';
|
||||
@@ -290,7 +314,10 @@ function forum_rules($action = 'check')
|
||||
$type = 'forum_rules_guest';
|
||||
}
|
||||
$result = e107::getDb()->select('generic', 'gen_chardata', "gen_type = '$type' AND gen_intdata = 1");
|
||||
if ($action == 'check') { return $result; }
|
||||
if($action == 'check')
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
|
||||
if($result)
|
||||
{
|
||||
@@ -324,6 +351,7 @@ function forum_rules($action = 'check')
|
||||
|
||||
function forum_track()
|
||||
{
|
||||
|
||||
global $forum;
|
||||
|
||||
$trackPref = $forum->prefs->get('track');
|
||||
@@ -333,6 +361,7 @@ function forum_track()
|
||||
if(empty($trackPref))
|
||||
{
|
||||
echo "Disabled";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -451,7 +480,6 @@ function forum_track()
|
||||
$text = '';
|
||||
|
||||
|
||||
|
||||
$text .= $tracktext;
|
||||
$text .= "<div class='center'>" . e107::getForm()->pagination(e107::url('forum', 'index'), LAN_BACK) . "</div>";
|
||||
|
||||
@@ -462,11 +490,10 @@ function forum_track()
|
||||
}
|
||||
|
||||
|
||||
|
||||
function parse_forum($f, $restricted_string = '')
|
||||
private function parse_forum($f, $restricted_string = '')
|
||||
{
|
||||
|
||||
global $FORUM_MAIN_FORUM, $forumList, $sc;
|
||||
global $FORUM_MAIN_FORUM, $forumList;
|
||||
|
||||
$tp = e107::getParser();
|
||||
|
||||
@@ -474,7 +501,7 @@ function parse_forum($f, $restricted_string = '')
|
||||
{
|
||||
$lastPost = explode('.', $f['forum_lastpost_info']);
|
||||
$lastpost_datestamp = reset($lastPost);
|
||||
$ret = parse_subs($forumList, $f['forum_id'], $lastpost_datestamp);
|
||||
$ret = $this->parse_subs($forumList, $f['forum_id'], $lastpost_datestamp);
|
||||
|
||||
$f['forum_threads'] += $ret['threads'];
|
||||
$f['forum_replies'] += $ret['replies'];
|
||||
@@ -489,15 +516,14 @@ function parse_forum($f, $restricted_string = '')
|
||||
$f['text'] = $ret['text'];
|
||||
}
|
||||
|
||||
$sc->setVars($f);
|
||||
$this->sc->setVars($f);
|
||||
|
||||
$sc->wrapper('forum/main/forum');
|
||||
$this->sc->wrapper('forum/main/forum');
|
||||
|
||||
return $tp->parseTemplate($FORUM_MAIN_FORUM, true, $sc);
|
||||
return $tp->parseTemplate($FORUM_MAIN_FORUM, true, $this->sc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function parse_subs($forumList, $id, $lastpost_datestamp)
|
||||
{
|
||||
|
||||
@@ -539,5 +565,14 @@ function parse_subs($forumList, $id, $lastpost_datestamp)
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
require_once(e_PLUGIN . 'forum/forum_class.php');
|
||||
/** @var e107forum $forum */
|
||||
$forum = new e107forum;
|
||||
|
||||
new forum_front($forum);
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,222 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(__DIR__.'/../../class2.php');
|
||||
$e107 = e107::getInstance();
|
||||
if (!$e107->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 = "<div style='text-align:center'>".$message."
|
||||
<br />
|
||||
<a href='$url'>".LAN_FORUM_5007.'</a>
|
||||
</div>';
|
||||
$ns->tablerender(LAN_FORUM_5008, $text);
|
||||
require_once(FOOTERF);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($action == "delete_poll")
|
||||
{
|
||||
$text = "<div style='text-align:center'>
|
||||
".LAN_FORUM_5009."
|
||||
<br /><br />
|
||||
<form method='post' action='".e_SELF."?".e_QUERY."'>
|
||||
<input class='btn btn-default btn-secondary button' type='submit' name='deletecancel' value='".LAN_CANCEL."' />
|
||||
<input class='btn btn-default btn-secondary button' type='submit' name='deletepollconfirm' value='".LAN_FORUM_5010."' />
|
||||
</form>
|
||||
</div>";
|
||||
$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 = "
|
||||
<form class='forum-horizontal' method='post' action='".e_SELF.'?'.e_QUERY."'>
|
||||
<div style='text-align:center'>
|
||||
<table class='table table-striped' style='".ADMIN_WIDTH."'>
|
||||
<tr>
|
||||
<td>".LAN_FORUM_5019.": </td>
|
||||
<td>
|
||||
<select name='forum_move' class='tbox'>";
|
||||
|
||||
|
||||
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 .= "<option value='{$f['forum_id']}'>".$for_name."</option>";
|
||||
}
|
||||
}
|
||||
$text .= "</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td >".LAN_FORUM_5026."</td>
|
||||
<td><div class='radio'>
|
||||
".$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)). "
|
||||
<div class='form-inline'>".$frm->radio('rename_thread','rename', false, array('label'=>LAN_FORUM_5025))."
|
||||
".$frm->text('newtitle', $tp->toForm($threadInfo['thread_name']), 250)."
|
||||
</div>
|
||||
</div></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class='center'>
|
||||
<input class='btn btn-primary button' type='submit' name='move' value='".LAN_FORUM_5019."' />
|
||||
<input class='btn btn-default button' type='submit' name='movecancel' value='".LAN_CANCEL."' />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>";
|
||||
|
||||
|
||||
$threadName = $tp->toHTML($threadInfo['thread_name'], true);
|
||||
$threadText = $tp->toHTML($postInfo[0]['post_entry'], true);
|
||||
|
||||
$text .= "<h3>".$threadName."</h3><div>".$threadText."</div>"; // $e107->ns->tablerender(, ), '', true).$ns->tablerender('', $text, '', true);
|
||||
$ns->tablerender(LAN_FORUM_5019, $text);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
require_once(FOOTERF);
|
@@ -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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -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'];
|
||||
|
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
require_once(__DIR__.'/../../class2.php');
|
||||
require_once(e_PLUGIN.'forum/forum_class.php');
|
||||
|
||||
$timestart = microtime();
|
||||
$forum = new e107forum;
|
||||
|
||||
//for($i=1; $i<=7000; $i++) {
|
||||
// $x = $forum->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 "<br />script generation took $diff s";
|
||||
|
@@ -10,8 +10,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('e_ADMIN_AREA'))
|
||||
{
|
||||
define('e_ADMIN_AREA', true);
|
||||
require_once ('../../class2.php');
|
||||
}
|
||||
require_once(__DIR__ . '/../../class2.php');
|
||||
|
||||
if(!getperms('P'))
|
||||
{
|
||||
@@ -36,6 +39,7 @@ if (e_QUERY == "reset")
|
||||
$forum = new e107forum(true);
|
||||
$timestart = microtime();
|
||||
|
||||
global $f;
|
||||
$f = new forumUpgrade;
|
||||
|
||||
$sql = e107::getDb();
|
||||
@@ -50,7 +54,6 @@ if(!empty($_GET['reset']))
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(e_AJAX_REQUEST)
|
||||
{
|
||||
if(!vartrue($_GET['mode']))
|
||||
@@ -112,7 +115,7 @@ if (function_exists('step' . $currentStep))
|
||||
}
|
||||
|
||||
require(e_ADMIN . 'footer.php');
|
||||
exit ;
|
||||
|
||||
|
||||
function step1()
|
||||
{
|
||||
@@ -160,6 +163,7 @@ function step1()
|
||||
|
||||
function step2()
|
||||
{
|
||||
|
||||
$mes = e107::getMessage();
|
||||
$ns = e107::getRender();
|
||||
|
||||
@@ -173,6 +177,7 @@ function step2()
|
||||
</form>
|
||||
";
|
||||
$ns->tablerender('Step 2: Forum table creation', $text);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -231,10 +236,10 @@ function step2()
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FIXME - use e107::getPlugin()->manage_extended_field('add', $name, $attrib, $source)
|
||||
function step3()
|
||||
{
|
||||
|
||||
$ns = e107::getRender();
|
||||
$mes = e107::getMessage();
|
||||
$text = '';
|
||||
@@ -255,6 +260,7 @@ function step3()
|
||||
";
|
||||
|
||||
$ns->tablerender($stepCaption, $text);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -304,6 +310,7 @@ function step3()
|
||||
|
||||
function step4()
|
||||
{
|
||||
|
||||
global $pref;
|
||||
|
||||
$mes = e107::getMessage();
|
||||
@@ -323,6 +330,7 @@ function step4()
|
||||
</form>
|
||||
";
|
||||
$ns->tablerender($stepCaption, $text);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -366,7 +374,6 @@ function step4()
|
||||
// --------------------
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
'usercount' => 0,
|
||||
'viewcount' => 0,
|
||||
@@ -443,6 +450,7 @@ function step4()
|
||||
|
||||
function step5()
|
||||
{
|
||||
|
||||
$sql = e107::getDb();
|
||||
$ns = e107::getRender();
|
||||
$mes = e107::getMessage();
|
||||
@@ -459,6 +467,7 @@ function step5()
|
||||
</form>
|
||||
";
|
||||
$ns->tablerender($stepCaption, $mes->render() . $text);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -540,13 +549,12 @@ function step5()
|
||||
$ns->tablerender($stepCaption, $mes->render() . $text);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function step6()
|
||||
{
|
||||
|
||||
$sql = e107::getDb();
|
||||
$ns = e107::getRender();
|
||||
$mes = e107::getMessage();
|
||||
@@ -596,9 +604,9 @@ function renderProgress($caption, $step)
|
||||
}
|
||||
|
||||
|
||||
|
||||
function step6_ajax()
|
||||
{
|
||||
|
||||
global $f;
|
||||
$sql = e107::getDb();
|
||||
|
||||
@@ -644,10 +652,9 @@ function step6_ajax()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function step7()
|
||||
{
|
||||
|
||||
$ns = e107::getRender();
|
||||
$stepCaption = 'Step 7: Calculate user post counts';
|
||||
if(!isset($_POST['calculate_usercounts']))
|
||||
@@ -660,6 +667,7 @@ function step7()
|
||||
</form>
|
||||
";
|
||||
$ns->tablerender($stepCaption, $text);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -687,14 +695,9 @@ function step7()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function step8()
|
||||
{
|
||||
|
||||
$sql = e107::getDb();
|
||||
$mes = e107::getMessage();
|
||||
|
||||
@@ -713,6 +716,7 @@ function step8()
|
||||
$text .= renderProgress('Proceed with lastpost calculation', 8);
|
||||
|
||||
e107::getRender()->tablerender($stepCaption, $mes->render() . $text);
|
||||
|
||||
return;
|
||||
|
||||
|
||||
@@ -720,6 +724,7 @@ function step8()
|
||||
|
||||
function step8_ajax()
|
||||
{
|
||||
|
||||
$sql = e107::getDb();
|
||||
|
||||
$lastThread = vartrue($_SESSION['forumupdate']['lastpost_last'], 0);
|
||||
@@ -753,7 +758,6 @@ function step8_ajax()
|
||||
}
|
||||
|
||||
|
||||
|
||||
function step9()
|
||||
{
|
||||
|
||||
@@ -771,6 +775,7 @@ function step9()
|
||||
</form>
|
||||
";
|
||||
e107::getRender()->tablerender($stepCaption, $text);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -827,10 +832,9 @@ function step9()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function step10()
|
||||
{
|
||||
|
||||
$sql = e107::getDb();
|
||||
$ns = e107::getRender();
|
||||
$mes = e107::getMessage();
|
||||
@@ -853,6 +857,7 @@ function step10()
|
||||
</form>
|
||||
";
|
||||
$ns->tablerender($stepCaption, $text);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -875,6 +880,7 @@ function step10()
|
||||
*/
|
||||
function step10_ajax()//TODO
|
||||
{
|
||||
|
||||
$sql = e107::getDb();
|
||||
global $f;
|
||||
|
||||
@@ -960,7 +966,6 @@ function step10_ajax()//TODO
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if (preg_match_all('#\[link=(.*?)\]\[img.*?\](\.\./\.\./e107_files/public/.*?)\[/img\]\[/link\]#ms', $post['post_entry'], $matches, PREG_SET_ORDER))
|
||||
{
|
||||
@@ -1030,7 +1035,6 @@ function step10_ajax()//TODO
|
||||
//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))
|
||||
{
|
||||
@@ -1065,7 +1069,6 @@ function step10_ajax()//TODO
|
||||
*/
|
||||
|
||||
|
||||
|
||||
if(count($attachments))
|
||||
{
|
||||
$f->log("found " . count($attachments) . " attachments", true);
|
||||
@@ -1110,7 +1113,6 @@ function step10_ajax()//TODO
|
||||
echo $totalOutput;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
$debugRound = "
|
||||
forumupdate_attachment_count = ".$_SESSION['forumupdate']['attachment_count']."
|
||||
@@ -1132,6 +1134,7 @@ 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";
|
||||
@@ -1139,10 +1142,11 @@ function logAttachment($thread, $type, $attach)
|
||||
}
|
||||
|
||||
|
||||
|
||||
function step11()
|
||||
{
|
||||
|
||||
$ns = e107::getRender();
|
||||
$text = '';
|
||||
$stepCaption = 'Step 11: Delete old attachments';
|
||||
if(!isset($_POST['delete_orphans']))
|
||||
{
|
||||
@@ -1160,14 +1164,13 @@ function step11()
|
||||
</form>
|
||||
";
|
||||
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)
|
||||
@@ -1203,6 +1206,7 @@ function step11()
|
||||
</form>
|
||||
";
|
||||
$ns->tablerender($stepCaption, $text);
|
||||
|
||||
return;
|
||||
}
|
||||
$text = "There were {$numFiles} orphaned files found<br /><br />";
|
||||
@@ -1228,6 +1232,7 @@ function step11()
|
||||
|
||||
";
|
||||
$ns->tablerender($stepCaption, $text);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -1240,12 +1245,14 @@ function step11()
|
||||
</form>
|
||||
";
|
||||
$ns->tablerender($stepCaption, $text);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function step12()
|
||||
{
|
||||
|
||||
$sql = e107::getDb();
|
||||
$ns = e107::getRender();
|
||||
$mes = e107::getMessage();
|
||||
@@ -1267,6 +1274,7 @@ function step12()
|
||||
</form>
|
||||
";
|
||||
$ns->tablerender($stepCaption, $text);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1291,19 +1299,23 @@ function step12()
|
||||
$text = "<a class='btn btn-primary' href='" . e_ADMIN . "e107_update.php'>Return to e107 Update</a>";
|
||||
|
||||
$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';
|
||||
@@ -1312,6 +1324,7 @@ class forumUpgrade
|
||||
|
||||
public function log($msg, $append = true)
|
||||
{
|
||||
|
||||
// echo "logf = ".$this->logf."<br />";
|
||||
$txt = sprintf("%s - %s\n", date('m/d/Y H:i:s'), $msg);
|
||||
// echo $txt."<br />";
|
||||
@@ -1321,6 +1334,7 @@ class forumUpgrade
|
||||
|
||||
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/',
|
||||
@@ -1357,9 +1372,10 @@ class forumUpgrade
|
||||
|
||||
function getUpdateInfo()
|
||||
{
|
||||
|
||||
$sql = e107::getDb();
|
||||
|
||||
if ($_SESSION['forumUpgrade'])
|
||||
if(isset($_SESSION['forumUpgrade']))
|
||||
{
|
||||
$this->updateInfo = $_SESSION['forumUpgrade'];
|
||||
}
|
||||
@@ -1374,12 +1390,15 @@ class forumUpgrade
|
||||
|
||||
function setUpdateInfo()
|
||||
{
|
||||
|
||||
$_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'");
|
||||
@@ -1392,6 +1411,7 @@ class forumUpgrade
|
||||
|
||||
function migrateThread($threadId)
|
||||
{
|
||||
|
||||
global $forum;
|
||||
|
||||
$threadId = (int) $threadId;
|
||||
@@ -1430,6 +1450,7 @@ class forumUpgrade
|
||||
|
||||
function addThread(&$post)
|
||||
{
|
||||
|
||||
global $forum;
|
||||
|
||||
/*
|
||||
@@ -1527,9 +1548,9 @@ class forumUpgrade
|
||||
}
|
||||
|
||||
|
||||
|
||||
function addPost(&$post)
|
||||
{
|
||||
|
||||
global $forum;
|
||||
|
||||
$detected = mb_detect_encoding($post['thread_thread']); // 'ISO-8859-1'
|
||||
@@ -1570,6 +1591,7 @@ class forumUpgrade
|
||||
|
||||
function getUserInfo($info)
|
||||
{
|
||||
|
||||
$tmp = explode('.', $info);
|
||||
$id = (int) $tmp[0];
|
||||
|
||||
@@ -1599,6 +1621,7 @@ class forumUpgrade
|
||||
|
||||
function moveAttachment($attachment, $post, &$error)
|
||||
{
|
||||
|
||||
global $forum;
|
||||
set_time_limit(30);
|
||||
$tp = e107::getParser();
|
||||
@@ -1631,6 +1654,7 @@ class forumUpgrade
|
||||
{
|
||||
$error = 'Original attachment not found (orphaned?)';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1652,6 +1676,7 @@ class forumUpgrade
|
||||
{
|
||||
$error = 'Attachment file already exists';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1659,6 +1684,7 @@ class forumUpgrade
|
||||
{
|
||||
//File copy failed!
|
||||
$error = 'Moving of attachments failed';
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1689,12 +1715,14 @@ class forumUpgrade
|
||||
{
|
||||
$error = 'Thumb file already exists';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if(!$r)
|
||||
{
|
||||
//File copy failed
|
||||
$error = 'Moving of thumb failed';
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1722,8 +1750,10 @@ class forumUpgrade
|
||||
|
||||
}
|
||||
|
||||
|
||||
function createThreadLimitDropdown($count)
|
||||
{
|
||||
|
||||
$ret = "
|
||||
<select class='tbox' name='threadLimit'>
|
||||
";
|
||||
@@ -1744,11 +1774,13 @@ function createThreadLimitDropdown($count)
|
||||
}
|
||||
}
|
||||
$ret .= '</select>';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function forum_update_adminmenu()
|
||||
{
|
||||
|
||||
$action = 1;
|
||||
|
||||
$var[1]['text'] = '1 - Permissions';
|
||||
@@ -1809,7 +1841,6 @@ function forum_update_adminmenu()
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(isset($_GET['step']))
|
||||
{
|
||||
// $action = key($_POST['nextStep']);
|
||||
|
@@ -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))
|
||||
<form method='post' action='".e_SELF."'>
|
||||
<table style='width:98%'>
|
||||
<tr>
|
||||
<td class='fcaption'>".FRMUP_5."</td>
|
||||
<td class='fcaption'>".defset('LAN_FORUM_7010', "Filename")."</td>
|
||||
<td class='fcaption'>".LAN_FORUM_7006."</td>
|
||||
</tr>";
|
||||
foreach($fileList as $finfo)
|
||||
@@ -110,12 +110,15 @@ if(is_array($fileList))
|
||||
}
|
||||
$txt .= "</table>";
|
||||
}
|
||||
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);
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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 ------------
|
||||
|
Reference in New Issue
Block a user