diff --git a/e107_plugins/forum/e_url.php b/e107_plugins/forum/e_url.php
index 99c1222cb..43280bbaf 100644
--- a/e107_plugins/forum/e_url.php
+++ b/e107_plugins/forum/e_url.php
@@ -25,6 +25,18 @@ class forum_url // plugin-folder + '_url'
{
$config = array();
+ $config['rules'] = array(
+ 'regex' => '^forum/rules/?',
+ 'sef' => 'forum/rules',
+ 'redirect' => '{e_PLUGIN}forum/forum.php?f=rules',
+ );
+
+ $config['stats'] = array(
+ 'regex' => '^forum/stats/?',
+ 'sef' => 'forum/stats',
+ 'redirect' => '{e_PLUGIN}forum/forum_stats.php',
+ );
+
$config['post'] = array(
'regex' => '^forum/post/?',
'sef' => 'forum/post/',
diff --git a/e107_plugins/forum/forum.css b/e107_plugins/forum/forum.css
index 90c47ed29..c7d09cb8b 100644
--- a/e107_plugins/forum/forum.css
+++ b/e107_plugins/forum/forum.css
@@ -9,7 +9,7 @@
#forum-viewtopic li.forum-viewtopic-post:nth-child(odd) { background: #F5F5F5 }
#forum-viewtopic li ul.thumbnails { margin-top:15px }
#forum-viewtopic li img.user-avatar { margin-bottom:10px; display:inline-block }
-
+#forum, #forum-stats, #forum-rules { min-height: 500px; }
.forum-attachment-file { margin-top:15px; }
-.forum-user-combo { padding-bottom:5px }
\ No newline at end of file
+.forum-user-combo { padding-bottom:5px }
diff --git a/e107_plugins/forum/forum.php b/e107_plugins/forum/forum.php
index fc7007d32..bb42efbde 100644
--- a/e107_plugins/forum/forum.php
+++ b/e107_plugins/forum/forum.php
@@ -53,6 +53,7 @@ if(isset($_GET['f']))
case 'rules':
include_once(HEADERF);
+
forum_rules('show');
include_once(FOOTERF);
exit;
@@ -74,6 +75,7 @@ $fVars->NEWIMAGE = IMAGE_new_small;
$fVars->TRACKTITLE = LAN_FORUM_0073;
$rules_text = forum_rules('check');
+
$fVars->USERINFO = "".LAN_FORUM_0010." | ".LAN_FORUM_0011."";
if(USER)
{
@@ -83,10 +85,27 @@ if(USER)
$fVars->USERINFO .= " | ".LAN_FORUM_0015."";
}
}
-if($rules_text != '')
+if(!empty($rules_text))
{
- $fVars->USERINFO .= " | ".LAN_FORUM_0016.'';
+ $fVars->USERINFO .= " | ".LAN_FORUM_0016.'';
}
+
+
+// v2.x --------------------
+$uInfo = array();
+$uInfo[0] = "".LAN_FORUM_6013.'';
+
+if(!empty($rules_text))
+{
+ $uInfo[1] = "".LAN_FORUM_0016.'';
+}
+
+$fVars->USERINFOX = implode(" | ",$uInfo);
+// -----------
+
+
+
+
$total_topics = $sql->count("forum_thread", "(*)");
$total_replies = $sql->count("forum_post", "(*)");
$total_members = $sql->count("user");
@@ -562,7 +581,23 @@ function forum_rules($action = 'check')
{
$rules_text = LAN_FORUM_0072;
}
- e107::getRender()->tablerender(LAN_FORUM_0016, "
{$rules_text}
", array('forum', 'forum_rules'));
+
+ $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);
+ }
+
+ $text .= "".$rules_text."
";
+ $text .= "".e107::getForm()->pagination(e107::url('forum','index'), LAN_BACK)."
";
+
+ e107::getRender()->tablerender(LAN_FORUM_0016, $text, array('forum', 'forum_rules'));
}
?>
\ No newline at end of file
diff --git a/e107_plugins/forum/forum_admin.php b/e107_plugins/forum/forum_admin.php
index 56d83da95..71aa266ad 100644
--- a/e107_plugins/forum/forum_admin.php
+++ b/e107_plugins/forum/forum_admin.php
@@ -375,7 +375,7 @@ if(!deftrue('OLD_FORUMADMIN'))
public function beforeUpdate($new_data, $old_data, $id)
{
- if(empty($new_data['forum_sef']))
+ if(empty($new_data['forum_sef']) && !empty($new_data['forum_name']))
{
$new_data['forum_sef'] = eHelper::title2sef($new_data['forum_name']);
}
diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php
index 265b43e3e..7a814b37d 100644
--- a/e107_plugins/forum/forum_class.php
+++ b/e107_plugins/forum/forum_class.php
@@ -747,7 +747,7 @@ class e107forum
$info = array();
// $info['_FIELD_TYPES'] = $this->fieldTypes['forum_thread'];
- $threadInfo['thread_sef'] = eHelper::title2sef($threadInfo['thread_name']);
+ // $threadInfo['thread_sef'] = eHelper::title2sef($threadInfo['thread_name'],'dashl');
$info['data'] = $threadInfo;
@@ -758,6 +758,8 @@ class e107forum
$postInfo['post_thread'] = $newThreadId;
$newPostId = $this->postAdd($postInfo, false);
$this->threadMarkAsRead($newThreadId);
+ $threadInfo['thread_sef'] = eHelper::title2sef($threadInfo['thread_name'],'dashl');
+
return array('postid' => $newPostId, 'threadid' => $newThreadId, 'threadsef'=>$threadInfo['thread_sef']);
}
return false;
@@ -783,7 +785,7 @@ class e107forum
else
{
//Replace title
- $threadTitle = ", thread_name = '{$threadTitle}', thread_sef='".eHelper::title2sef($threadTitle,'dashl')."' ";
+ $threadTitle = ", thread_name = '{$threadTitle}' "; // , thread_sef='".eHelper::title2sef($threadTitle,'dashl')."' ";
}
}
@@ -808,7 +810,7 @@ class e107forum
function threadUpdate($threadId, $threadInfo)
{
$info = array();
- $threadInfo['thread_sef'] = eHelper::title2sef($threadInfo['thread_name']);
+ // $threadInfo['thread_sef'] = eHelper::title2sef($threadInfo['thread_name'],'dashl');
$info['data'] = $threadInfo;
// $info['_FIELD_TYPES'] = $this->fieldTypes['forum_thread'];
@@ -878,6 +880,9 @@ class e107forum
{
$tmp['thread_options'] = unserialize($tmp['thread_options']);
}
+
+ $tmp['thread_sef'] = eHelper::title2sef($tmp['thread_name'],'dashl');
+
return $tmp;
}
}
@@ -898,7 +903,7 @@ class e107forum
if('post' === $start)
{
$qry = '
- SELECT u.user_name, t.thread_active, t.thread_datestamp, t.thread_name, t.thread_sef, t.thread_user, t.thread_id, p.* FROM `#forum_post` AS p
+ SELECT u.user_name, t.thread_active, t.thread_datestamp, t.thread_name, t.thread_user, t.thread_id, p.* FROM `#forum_post` AS p
LEFT JOIN `#forum_thread` AS t ON t.thread_id = p.post_thread
LEFT JOIN `#user` AS u ON u.user_id = p.post_user
WHERE p.post_id = '.$id;
@@ -926,6 +931,7 @@ class e107forum
$ret = array();
while($row = $sql->fetch(MYSQL_ASSOC))
{
+ $row['thread_sef'] = eHelper::title2sef($row['thread_name'],'dashl');
$ret[] = $row;
}
}
@@ -1591,6 +1597,7 @@ class e107forum
{
while ($row = $sql->fetch(MYSQL_ASSOC))
{
+ // $row['thread_sef'] = eHelper::title2sef($row['thread_name']);
$ret[] = $row;
}
}
@@ -1604,7 +1611,7 @@ class e107forum
$sql = e107::getDb();
$id = (int)$id;
$qry = "
- SELECT p.post_user, p.post_id, p.post_user_anon, p.post_datestamp, p.post_thread, t.thread_sef, u.user_name FROM `#forum_post` AS p
+ SELECT p.post_user, p.post_id, p.post_user_anon, p.post_datestamp, p.post_thread, t.thread_name, u.user_name FROM `#forum_post` AS p
LEFT JOIN `#forum_thread` AS t ON p.post_thread = t.thread_id
LEFT JOIN `#user` AS u ON u.user_id = p.post_user
WHERE p.post_thread = {$id}
@@ -1612,7 +1619,9 @@ class e107forum
";
if ($sql->gen($qry))
{
- return $sql->fetch(MYSQL_ASSOC);
+ $row = $sql->fetch(MYSQL_ASSOC);
+ $row['thread_sef'] = eHelper::title2sef($row['thread_name'],'dashl');
+ return $row;
}
return false;
}
@@ -1635,7 +1644,7 @@ class e107forum
$qry = "
- SELECT t.thread_id, t.thread_sef, f.forum_id, f.forum_sef FROM `#forum_thread` AS t
+ SELECT t.thread_id, t.thread_name, f.forum_id, f.forum_sef FROM `#forum_thread` AS t
LEFT JOIN `#forum` AS f ON t.thread_forum_id = f.forum_id
WHERE t.thread_forum_id = $forumId
AND t.thread_lastpost {$dir} $lastpost
@@ -1649,6 +1658,7 @@ class e107forum
if ($sql->gen($qry))
{
$row = $sql->fetch();
+ $row['thread_sef'] = eHelper::title2sef($row['thread_name'],'dashl');
// e107::getMessage()->addInfo(ucfirst($which).print_a($row,true));
return $row;
// return $row['thread_id'];
diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php
index 8d47755d3..1795e0417 100644
--- a/e107_plugins/forum/forum_post.php
+++ b/e107_plugins/forum/forum_post.php
@@ -824,7 +824,9 @@ class forum_post_handler
$newThreadId = $postResult['threadid'];
$this->data['thread_id'] = $newThreadId;
- $this->data['thread_sef'] = $postResult['threadsef'];
+ // $this->data['thread_sef'] = $postResult['threadsef'];
+ $this->data['thread_sef'] = eHelper::title2sef($threadInfo['thread_name'],'dashl');
+
if($_POST['email_notify'])
diff --git a/e107_plugins/forum/forum_setup.php b/e107_plugins/forum/forum_setup.php
index c2982aace..846238da3 100644
--- a/e107_plugins/forum/forum_setup.php
+++ b/e107_plugins/forum/forum_setup.php
@@ -59,6 +59,11 @@ class forum_setup
{
return true; // true to trigger an upgrade alert, and false to not.
}
+
+ if(e107::getDb()->field('forum_thread', 'thread_sef'))
+ {
+ e107::getDb()->gen("ALTER TABLE `#forum_thread` DROP `thread_sef` ");
+ }
}
diff --git a/e107_plugins/forum/forum_sql.php b/e107_plugins/forum/forum_sql.php
index 5461d7ff1..0ccc8b4b1 100644
--- a/e107_plugins/forum/forum_sql.php
+++ b/e107_plugins/forum/forum_sql.php
@@ -37,7 +37,6 @@ CREATE TABLE forum_thread (
`thread_lastuser_anon` varchar(30) default NULL,
`thread_total_replies` int(10) unsigned NOT NULL default '0',
`thread_options` text,
- `thread_sef` varchar(250) default NULL,
PRIMARY KEY (`thread_id`),
KEY `thread_forum_id` (`thread_forum_id`),
KEY `thread_sticky` (`thread_sticky`),
diff --git a/e107_plugins/forum/forum_stats.php b/e107_plugins/forum/forum_stats.php
index fe8c4f554..1888f9d92 100644
--- a/e107_plugins/forum/forum_stats.php
+++ b/e107_plugins/forum/forum_stats.php
@@ -8,412 +8,668 @@
*
*/
-require_once('../../class2.php');
+if(!defined('e107_INIT'))
+{
+ require_once('../../class2.php');
+}
-$e107 = e107::getInstance();
-$sql = e107::getDb();
-
-if (!$e107->isInstalled('forum'))
+if (!e107::isInstalled('forum'))
{
header('Location: '.e_BASE.'index.php');
exit;
}
-//TODO: Investigate the queries used here
-include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_stats.php');
-e107::lan('forum','front');
+class forumStats
+{
+
+ private $from = 0;
+ private $view = 20;
-require_once(e_PLUGIN.'forum/forum_class.php');
-$gen = new convert;
-$forum = new e107forum;
-$barl = (file_exists(THEME.'images/barl.png') ? THEME.'images/barl.png' : e_PLUGIN.'poll/images/barl.png');
-$barr = (file_exists(THEME.'images/barr.png') ? THEME.'images/barr.png' : e_PLUGIN.'poll/images/barr.png');
-$bar = (file_exists(THEME.'images/bar.png') ? THEME.'images/bar.png' : e_PLUGIN.'poll/images/bar.png');
+ function __construct()
+ {
+ include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_stats.php');
+ e107::lan('forum','front');
+ e107::css('forum', 'forum.css');
+ }
+
+ function init()
+ {
+
+ $sql = e107::getDb();
+ $tp = e107::getParser();
+ $ns = e107::getRender();
+ $frm = e107::getForm();
+
+
+ require_once(e_PLUGIN.'forum/forum_class.php');
+ $gen = e107::getDate();
+
+ $forum = new e107forum;
+
+ $total_posts = $sql->count('forum_post');
+ $total_topics = $sql->count('forum_thread');
+ $total_replies = $total_posts - $total_topics;
+ $total_views = 0;
+
+ $query = 'SELECT sum(thread_views) AS total FROM `#forum_thread` ';
+ if ($sql->gen($query))
+ {
+ $row = $sql->fetch();
+ $total_views = $row['total'];
+ }
+
+ $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_date = $gen->convert_date($open_ds, 'long');
+ $open_since = $gen -> computeLapse($open_ds);
+ $open_days = floor((time()-$open_ds) / 86400);
+ $postsperday = ($open_days < 1 ? $total_posts : round($total_posts / $open_days));
+
+ global $mySQLdefaultdb;
+
+ $query = "SHOW TABLE STATUS FROM `{$mySQLdefaultdb}`";
+ $sql->gen($query);
+ $array = $sql -> db_getList();
+ foreach($array as $table)
+ {
+ if($table['Name'] == MPREFIX.'forum_post')
+ {
+ $db_size = eHelper::parseMemorySize($table['Data_length']);
+ $avg_row_len = eHelper::parseMemorySize($table['Avg_row_length']);
+ break;
+ }
+ }
+
+ $query = "
+ SELECT ft.thread_id, ft.thread_user, ft.thread_name, ft.thread_total_replies, ft.thread_datestamp, f.forum_sef, f.forum_class, u.user_name, u.user_id FROM #forum_thread as ft
+ LEFT JOIN #user AS u ON ft.thread_user = u.user_id
+ LEFT JOIN #forum AS f ON f.forum_id = ft.thread_forum_id
+ WHERE ft.thread_active > 0
+ AND f.forum_class IN (".USERCLASS_LIST.")
+ ORDER BY ft.thread_total_replies DESC LIMIT 0,10";
+
+ $sql->gen($query);
+ $most_activeArray = $sql->db_getList();
+
+ $query = "
+ SELECT ft.*, f.forum_class, f.forum_sef, u.user_name, u.user_id FROM #forum_thread as ft
+ LEFT JOIN #user AS u ON ft.thread_user = u.user_id
+ LEFT JOIN #forum AS f ON f.forum_id = ft.thread_forum_id
+ WHERE f.forum_class IN (".USERCLASS_LIST.")
+ ORDER BY ft.thread_views DESC LIMIT 0,10";
+
+ $sql->gen($query);
+ $most_viewedArray = $sql->db_getList();
+
+ /*$sql->db_Select("user", "user_id, user_name, user_forums", "ORDER BY user_forums DESC LIMIT 0, 10", "no_where");
+ $posters = $sql -> db_getList();
+ $top_posters = array();
+ foreach($posters as $poster)
+ {
+ $percen = round(($poster['user_forums'] / $total_posts) * 100, 2);
+ $top_posters[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['user_forums'], "percentage" => $percen);
+ }*/
+
+
+
+ // get all replies
+ $query = "
+ SELECT COUNT(fp.post_id) AS post_count, u.user_name, u.user_id, fp.post_thread FROM #forum_post as fp
+ LEFT JOIN #user AS u ON fp.post_user = u.user_id
+ GROUP BY fp.post_user
+ ORDER BY post_count DESC LIMIT 0,10";
+
+ $sql->gen($query);
+ $top_repliers_data = $sql->db_getList('ALL', false, false, 'user_id');
+
+ // build top posters meanwhile
+ $top_posters = array();
+ foreach($top_repliers_data as $poster)
+ {
+ $percent = round(($poster['post_count'] / $total_posts) * 100, 2);
+ $top_posters[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['post_count'], "percentage" => $percent);
+ }
+ // end build top posters
+
+ $ids = implode(',', array_keys($top_repliers_data));
+
+ // find topics by top 10 users
+ $query = "
+ SELECT COUNT(ft.thread_id) AS thread_count, u.user_id FROM #forum_thread as ft
+ LEFT JOIN #user AS u ON ft.thread_user = u.user_id
+ WHERE u.user_id IN ({$ids})
+ GROUP BY ft.thread_user";
+
+ $sql->gen($query);
+ $top_repliers_data_c = $sql->db_getList('ALL', false, false, 'user_id');
+
+ $top_repliers = array();
+ foreach($top_repliers_data as $uid => $poster)
+ {
+ $poster['post_count'] = $poster['post_count'] - $top_repliers_data_c[$uid]['thread_count'];
+ $percent = round(($poster['post_count'] / $total_replies) * 100, 2);
+ $top_repliers_sort[$uid] = $poster['post_count'];
+ //$top_repliers[$uid] = $poster;
+ $top_repliers_data[$uid]['user_forums'] = $poster['post_count'];
+ $top_repliers_data[$uid]['percentage'] = $percent;
+ //$top_repliers_data[$uid] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['post_count'], "percentage" => $percent);
+ }
+
+ // sort
+
+ arsort($top_repliers_sort, SORT_NUMERIC);
+
+ // build top repliers
+ foreach ($top_repliers_sort as $uid => $c)
+ {
+ $top_repliers[] = $top_repliers_data[$uid];
+ }
+
+ // get all replies
+ $query = "
+ SELECT COUNT(ft.thread_id) AS thread_count, u.user_name, u.user_id FROM #forum_thread as ft
+ LEFT JOIN #user AS u ON ft.thread_user = u.user_id
+ GROUP BY ft.thread_user
+ ORDER BY thread_count DESC LIMIT 0,10";
+
+ $sql->gen($query);
+ $top_topic_starters_data = $sql->db_getList();
+ $top_topic_starters = array();
+
+ foreach($top_topic_starters_data as $poster)
+ {
+ $percent = round(($poster['thread_count'] / $total_topics) * 100, 2);
+ $top_topic_starters[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['thread_count'], "percentage" => $percent);
+ }
+
+ /*
+ $query = "
+ SELECT SUBSTRING_INDEX(thread_user,'.',1) AS t_user, COUNT(SUBSTRING_INDEX(ft.thread_user,'.',1)) AS ucount, u.user_name, u.user_id FROM #forum_t as ft
+ LEFT JOIN #user AS u ON SUBSTRING_INDEX(ft.thread_user,'.',1) = u.user_id
+ WHERE ft.thread_parent=0
+ GROUP BY t_user
+ ORDER BY ucount DESC
+ LIMIT 0,10";
+ $sql -> db_Select_gen($query);
+ $posters = $sql -> db_getList();
+ $top_topic_starters = array();
+ foreach($posters as $poster)
+ {
+ $percen = round(($poster['ucount'] / $total_topics) * 100, 2);
+ $top_topic_starters[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['ucount'], "percentage" => $percen);
+ }*/
+
+ /*
+ $query = "
+ SELECT SUBSTRING_INDEX(thread_user,'.',1) AS t_user, COUNT(SUBSTRING_INDEX(ft.thread_user,'.',1)) AS ucount, u.user_name, u.user_id FROM #forum_t as ft
+ LEFT JOIN #user AS u ON SUBSTRING_INDEX(ft.thread_user,'.',1) = u.user_id
+ WHERE ft.thread_parent!=0
+ GROUP BY t_user
+ ORDER BY ucount DESC
+ LIMIT 0,10";
+ $sql -> db_Select_gen($query);
+ $posters = $sql -> db_getList();
+
+ $top_repliers = array();
+ foreach($posters as $poster)
+ {
+ $percen = round(($poster['ucount'] / $total_replies) * 100, 2);
+ $top_repliers[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['ucount'], "percentage" => $percen);
+ }
+ */
+
+
+
+
+
+ $text_0 = "
+
+ ".LAN_FORUM_6001.": | {$open_date} |
+ ".LAN_FORUM_6002.": | {$open_since} |
+ ".LAN_FORUM_6003.": | {$total_posts} |
+ ".LAN_FORUM_1007.": | {$total_topics} |
+ ".LAN_FORUM_6004.": | {$total_replies} |
+ ".LAN_FORUM_6005.": | {$total_views} |
+ ".LAN_FORUM_6014.": | {$postsperday} |
+ ".LAN_FORUM_6006.": | {$db_size} |
+ ".LAN_FORUM_6007.": | {$avg_row_len} |
+
";
+
+
+
+
+ $text_1 = "
+
+
+
+ ".LAN_FORUM_6008." |
+ ".LAN_FORUM_1003." |
+ ".LAN_FORUM_0003." |
+ ".LAN_FORUM_6009." |
+ ".LAN_DATE." |
+
+
+ ";
+
+ $count=1;
+
+ foreach($most_activeArray as $ma)
+ {
+ if($ma['user_name'])
+ {
+ $uinfo = "{$ma['user_name']}"; //TODO SEf Url .
+ }
+ else
+ {
+ $tmp = explode(chr(1), $ma['thread_anon']);
+ $uinfo = $tp->toHTML($tmp[0]);
+ }
+
+ $ma['thread_sef'] = eHelper::title2sef($ma['thread_name'],'dashl');
+ $url = e107::url('forum','topic', $ma);
+
+ $text_1 .= "
+
+
+
+
+
+
+
+ ";
+
+ $count++;
+ }
+
+ $text_1 .= "
";
+
+
+ $text_2 = "
+
+
+
+ ".LAN_FORUM_6008." |
+ ".LAN_FORUM_1003." |
+ ".LAN_FORUM_1005." |
+ ".LAN_FORUM_6009." |
+ ".LAN_DATE." |
+
+
+ ";
+
+ $count=1;
+
+ foreach($most_viewedArray as $ma)
+ {
+ if($ma['user_name'])
+ {
+ $uinfo = "".$ma['user_name'].""; //TODO SEf Url .
+ }
+ else
+ {
+ $tmp = explode(chr(1), $ma['thread_anon']);
+ $uinfo = $tp->toHTML($tmp[0]);
+ }
+
+ $ma['thread_sef'] = eHelper::title2sef($ma['thread_name'],'dashl');
+ $url = e107::url('forum','topic', $ma);
+
+ $text_2 .= "
+
+
+
+
+
+
+
+ ";
+ $count++;
+ }
+
+ $text_2 .= "
";
+
+
+
+
+ $text_3 = "
+
+
+
+ ".LAN_FORUM_6008." |
+ ".LAN_NAME." |
+ ".LAN_FORUM_2032." |
+ % |
+ |
+
+
+
+ ";
+
+ $count=1;
+ foreach($top_posters as $ma)
+ {
+ extract($ma); // TODO Remove me.
+
+ //TODO SEf Url .
+ $text_3 .= "
+
+
+
+
+
+
+ ";
+
+ $count++;
+ }
+
+ $text_3 .= "
+
+ ";
+
+
+ $text_4 = "
+
+
+
+ ".LAN_FORUM_6008." |
+ ".LAN_NAME." |
+ ".LAN_FORUM_2032." |
+ % |
+ |
+
+
+ ";
+
+ $count=1;
+ foreach($top_topic_starters as $ma)
+ {
+ extract($ma); // TODO Remove me.
+ //TODO SEf Url .
+
+
+ $text_4 .= "
+
+
+
+
+
+
+ ";
+ $count++;
+ }
+
+ $text_4 .= "
";
+
+
+ $text_5 = "
+
+
+
+ ".LAN_FORUM_6008." |
+ ".LAN_NAME." |
+ ".LAN_FORUM_2032." |
+ % |
+ |
+
+
+ ";
+
+ $count=1;
+ foreach($top_repliers as $ma)
+ {
+ extract($ma); // TODO Remove me.
+ //TODO SEf Url .
+
+ $text_5 .= "
+
+
+
+
+
+
+
+ ";
+
+ $count++;
+ }
+
+ $text_5 .= '
';
+
+
+ if(deftrue('BOOTSTRAP'))
+ {
+ $tabs = array();
+
+ $tabs[0] = array('caption'=>LAN_FORUM_6000, 'text'=>$text_0);
+ $tabs[1] = array('caption'=>LAN_FORUM_0011, 'text'=>$text_1);
+ $tabs[2] = array('caption'=>LAN_FORUM_6010, 'text'=>$text_2);
+ $tabs[3] = array('caption'=>LAN_FORUM_0010, 'text'=>$text_3);
+ $tabs[4] = array('caption'=>LAN_FORUM_6011, 'text'=>$text_4);
+ $tabs[5] = array('caption'=>LAN_FORUM_6012, 'text'=>$text_5);
+
+ $frm = e107::getForm();
+
+ $breadarray = array(
+ array('text'=> e107::pref('forum','title', LAN_PLUGIN_FORUM_NAME), 'url' => e107::url('forum','index') ),
+ array('text'=>LAN_FORUM_6013, 'url'=>null)
+ );
+
+ $text = $frm->breadcrumb($breadarray);
+
+
+ $text = "". $text . e107::getForm()->tabs($tabs)."
";
+ }
+ else
+ {
+ $text ="
+ ".LAN_FORUM_6000."
". $text_0 .
+ "".LAN_FORUM_0011."
". $text_1 .
+ "".LAN_FORUM_6010."
". $text_2 .
+ "".LAN_FORUM_0010."
".$text_3 .
+ "".LAN_FORUM_6011."
". $text_4 .
+ "".LAN_FORUM_6012."
". $text_5;
+ }
+
+ $text .= "".e107::getForm()->pagination(e107::url('forum','index'), LAN_BACK)."
";
+
+ $ns -> tablerender(LAN_FORUM_6013, $text);
+
+ }
+
+ function showBar($perc)
+ {
+ return e107::getForm()->progressBar('prog',$perc);
+ }
+
+
+ function topPosters() // from top.php - unused.
+ {
+ $pref = e107::pref('core');
+ $rank = e107::getRank();
+ $sql = e107::getDb();
+ $sql2 = e107::getDb('sql2');
+ $ns = e107::getRender();
+ $tp = e107::getParser();
+
+
+ define('IMAGE_rank_main_admin_image', ($pref['rank_main_admin_image'] && file_exists(THEME."forum/".$pref['rank_main_admin_image']) ? "
" : "
"));
+ define('IMAGE_rank_admin_image', ($pref['rank_admin_image'] && file_exists(THEME."forum/".$pref['rank_admin_image']) ? "
" : "
"));
+ define('IMAGE_rank_moderator_image', ($pref['rank_moderator_image'] && file_exists(THEME."forum/".$pref['rank_moderator_image']) ? "
" : "
"));
+
+ if ($this->subaction == 'forum' || $this->subaction == 'all')
+ {
+ require_once (e_PLUGIN.'forum/forum_class.php');
+ $forum = new e107forum();
+
+ $qry = "
+ SELECT ue.*, u.* FROM `#user_extended` AS ue
+ LEFT JOIN `#user` AS u ON u.user_id = ue.user_extended_id
+ WHERE ue.user_plugin_forum_posts > 0
+ ORDER BY ue.user_plugin_forum_posts DESC LIMIT {$this->from}, {$this->view}
+ ";
+
+ // $top_forum_posters = $sql->db_Select("user", "*", "`user_forums` > 0 ORDER BY user_forums DESC LIMIT ".$from.", ".$view."");
+ $text = "
+
+
+
+
+
+
+
+
\n";
+
+ $counter = 1 + $this->from;
+
+ if ($sql2->gen($qry))
+ {
+ while ($row = $sql2->fetch())
+ {
+ //$ldata = get_level($row['user_id'], $row['user_plugin_forum_posts'], $row['user_comments'], $row['user_chats'], $row['user_visits'], $row['user_join'], $row['user_admin'], $row['user_perms'], $pref);
+ $ldata = $rank->getRanks($row, (USER && $forum->isModerator(USERID)));
+
+ if(vartrue($ldata['special']))
+ {
+ $r = $ldata['special'];
+ }
+ else
+ {
+ $r = $ldata['pic'] ? $ldata['pic'] : defset($ldata['name'], $ldata['name']);
+ }
+
+ if(!$r) $r = 'n/a';
+
+ $text .= "
+
+
+
+
+
";
+
+ $counter++;
+ }
+ }
+
+ $text .= "
\n
";
+
+ if ($this->subaction == 'forum')
+ {
+ $ftotal = $sql->count('user', '(*)', 'WHERE `user_forums` > 0');
+ $parms = "{$ftotal},{$this->view},{$this->from},".e_SELF.'?[FROM].top.forum.'.$this->view;
+ $text .= "".$tp->parseTemplate("{NEXTPREV={$parms}}").'
';
+ }
+
+ $ns->tablerender(TOP_LAN_0, $text);
+
+
+ }
+ }
+
+
+
+
+ function mostActiveTopics() // from top.php - unused.
+ {
+ //require_once (e_HANDLER.'userclass_class.php');
+
+ $sql = e107::getDb();
+ $tp = e107::getParser();
+ $ns = e107::getRender();
+
+ require_once (e_PLUGIN.'forum/forum_class.php');
+ $forum = new e107forum();
+
+ $forumList = implode(',', $forum->getForumPermList('view'));
+
+ $qry = "
+ SELECT
+ t.*, u.user_name, ul.user_name AS user_last, f.forum_name
+ FROM `#forum_thread` as t
+ LEFT JOIN `#forum` AS f ON f.forum_id = t.thread_forum_id
+ LEFT JOIN `#user` AS u ON u.user_id = t.thread_user
+ LEFT JOIN `#user` AS ul ON ul.user_id = t.thread_lastuser
+ WHERE t.thread_forum_id IN ({$forumList})
+ ORDER BY t.thread_views DESC
+ LIMIT
+ {$this->from}, {$this->view}
+ ";
+
+ if ($sql->gen($qry))
+ {
+ $text = "\n
\n";
+ $gen = e107::getDate();
+
+ $text .= "
+
+
+
+
+
+
+
\n";
+
+ while ($row = $sql->fetch(MYSQL_ASSOC))
+ {
+ if ($row['user_name'])
+ {
+ $POSTER = "{$row['user_name']}";
+ }
+ else
+ {
+ $POSTER = $row['thread_user_anon'];
+ }
+
+ $LINKTOTHREAD = e107::getUrl()->create('forum/thread/view', array('id' =>$row['thread_id'])); //$e107->url->getUrl('forum', 'thread', "func=view&id={$row['thread_id']}");
+ $LINKTOFORUM = e107::getUrl()->create('forum/forum/view', array('id' => $row['thread_forum_id'])); //$e107->url->getUrl('forum', 'forum', "func=view&id={$row['thread_forum_id']}");
+
+ $lastpost_datestamp = $gen->convert_date($row['thread_lastpost'], 'forum');
+
+ if ($row['user_last'])
+ {
+ $LASTPOST = "{$row['user_last']}
".$lastpost_datestamp;
+ }
+ else
+ {
+ $LASTPOST = $row['thread_lastuser_anon'].'
'.$lastpost_datestamp;
+ }
+
+ $text .= "
+
+
+
+
+
+
+
\n";
+ }
+
+ $text .= "
\n
";
+
+ $ftotal = $sql->count('forum_thread', '(*)', 'WHERE `thread_parent` = 0');
+ $parms = "{$ftotal},{$this->view},{$this->from},".e_SELF.'?[FROM].active.forum.'.$this->view;
+ $text .= "".$tp->parseTemplate("{NEXTPREV={$parms}}").'
';
+
+ $ns->tablerender(LAN_7, $text, 'nfp');
+
+
+ }
+
+
+ }
+
+}
+
+
+$frmStats = new forumStats;
require_once(HEADERF);
+$frmStats->init();
-$total_posts = $sql->count('forum_post');
-$total_topics = $sql->count('forum_thread');
-$total_replies = $total_posts - $total_topics;
-$total_views = 0;
-$query = 'SELECT sum(thread_views) AS total FROM `#forum_thread` ';
-if ($sql->gen($query))
-{
- $row = $sql->fetch();
- $total_views = $row['total'];
-}
-
-$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_date = $gen->convert_date($open_ds, 'long');
-$open_since = $gen -> computeLapse($open_ds);
-$open_days = floor((time()-$open_ds) / 86400);
-$postsperday = ($open_days < 1 ? $total_posts : round($total_posts / $open_days));
-
-
-$query = "SHOW TABLE STATUS FROM `{$mySQLdefaultdb}`";
-$sql->gen($query);
-$array = $sql -> db_getList();
-foreach($array as $table)
-{
- if($table['Name'] == MPREFIX.'forum_post')
- {
- $db_size = $e107->parseMemorySize($table['Data_length']);
- $avg_row_len = $e107->parseMemorySize($table['Avg_row_length']);
- break;
- }
-}
-
-$query = "
-SELECT ft.thread_id, ft.thread_user, ft.thread_name, ft.thread_total_replies, ft.thread_datestamp, f.forum_class, u.user_name, u.user_id FROM #forum_thread as ft
-LEFT JOIN #user AS u ON ft.thread_user = u.user_id
-LEFT JOIN #forum AS f ON f.forum_id = ft.thread_forum_id
-WHERE ft.thread_active > 0
-AND f.forum_class IN (".USERCLASS_LIST.")
-ORDER BY ft.thread_total_replies DESC LIMIT 0,10";
-$sql->gen($query);
-$most_activeArray = $sql->db_getList();
-
-$query = "
-SELECT ft.*, f.forum_class, u.user_name, u.user_id FROM #forum_thread as ft
-LEFT JOIN #user AS u ON ft.thread_user = u.user_id
-LEFT JOIN #forum AS f ON f.forum_id = ft.thread_forum_id
-WHERE f.forum_class IN (".USERCLASS_LIST.")
-ORDER BY ft.thread_views DESC LIMIT 0,10";
-
-$sql->gen($query);
-$most_viewedArray = $sql->db_getList();
-
-/*$sql->db_Select("user", "user_id, user_name, user_forums", "ORDER BY user_forums DESC LIMIT 0, 10", "no_where");
-$posters = $sql -> db_getList();
-$top_posters = array();
-foreach($posters as $poster)
-{
- $percen = round(($poster['user_forums'] / $total_posts) * 100, 2);
- $top_posters[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['user_forums'], "percentage" => $percen);
-}*/
-
-// get all replies
-$query = "
-SELECT COUNT(fp.post_id) AS post_count, u.user_name, u.user_id, fp.post_thread FROM #forum_post as fp
-LEFT JOIN #user AS u ON fp.post_user = u.user_id
-GROUP BY fp.post_user
-ORDER BY post_count DESC LIMIT 0,10";
-$sql->gen($query);
-$top_repliers_data = $sql->db_getList('ALL', false, false, 'user_id');
-
-// build top posters meanwhile
-$top_posters = array();
-foreach($top_repliers_data as $poster)
-{
- $percent = round(($poster['post_count'] / $total_posts) * 100, 2);
- $top_posters[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['post_count'], "percentage" => $percent);
-}
-// end build top posters
-
-$ids = implode(',', array_keys($top_repliers_data));
-
-// find topics by top 10 users
-$query = "
-SELECT COUNT(ft.thread_id) AS thread_count, u.user_id FROM #forum_thread as ft
-LEFT JOIN #user AS u ON ft.thread_user = u.user_id
-WHERE u.user_id IN ({$ids})
-GROUP BY ft.thread_user";
-$sql->gen($query);
-$top_repliers_data_c = $sql->db_getList('ALL', false, false, 'user_id');
-
-$top_repliers = array();
-foreach($top_repliers_data as $uid => $poster)
-{
- $poster['post_count'] = $poster['post_count'] - $top_repliers_data_c[$uid]['thread_count'];
- $percent = round(($poster['post_count'] / $total_replies) * 100, 2);
- $top_repliers_sort[$uid] = $poster['post_count'];
- //$top_repliers[$uid] = $poster;
- $top_repliers_data[$uid]['user_forums'] = $poster['post_count'];
- $top_repliers_data[$uid]['percentage'] = $percent;
- //$top_repliers_data[$uid] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['post_count'], "percentage" => $percent);
-}
-// sort
-arsort($top_repliers_sort, SORT_NUMERIC);
-// build top repliers
-foreach ($top_repliers_sort as $uid => $c)
-{
- $top_repliers[] = $top_repliers_data[$uid];
-}
-
-// get all replies
-$query = "
-SELECT COUNT(ft.thread_id) AS thread_count, u.user_name, u.user_id FROM #forum_thread as ft
-LEFT JOIN #user AS u ON ft.thread_user = u.user_id
-GROUP BY ft.thread_user
-ORDER BY thread_count DESC LIMIT 0,10";
-$sql->gen($query);
-$top_topic_starters_data = $sql->db_getList();
-$top_topic_starters = array();
-foreach($top_topic_starters_data as $poster)
-{
- $percent = round(($poster['thread_count'] / $total_topics) * 100, 2);
- $top_topic_starters[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['thread_count'], "percentage" => $percent);
-}
-
-/*
-$query = "
-SELECT SUBSTRING_INDEX(thread_user,'.',1) AS t_user, COUNT(SUBSTRING_INDEX(ft.thread_user,'.',1)) AS ucount, u.user_name, u.user_id FROM #forum_t as ft
-LEFT JOIN #user AS u ON SUBSTRING_INDEX(ft.thread_user,'.',1) = u.user_id
-WHERE ft.thread_parent=0
-GROUP BY t_user
-ORDER BY ucount DESC
-LIMIT 0,10";
-$sql -> db_Select_gen($query);
-$posters = $sql -> db_getList();
-$top_topic_starters = array();
-foreach($posters as $poster)
-{
- $percen = round(($poster['ucount'] / $total_topics) * 100, 2);
- $top_topic_starters[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['ucount'], "percentage" => $percen);
-}*/
-
-/*
-$query = "
-SELECT SUBSTRING_INDEX(thread_user,'.',1) AS t_user, COUNT(SUBSTRING_INDEX(ft.thread_user,'.',1)) AS ucount, u.user_name, u.user_id FROM #forum_t as ft
-LEFT JOIN #user AS u ON SUBSTRING_INDEX(ft.thread_user,'.',1) = u.user_id
-WHERE ft.thread_parent!=0
-GROUP BY t_user
-ORDER BY ucount DESC
-LIMIT 0,10";
-$sql -> db_Select_gen($query);
-$posters = $sql -> db_getList();
-
-$top_repliers = array();
-foreach($posters as $poster)
-{
- $percen = round(($poster['ucount'] / $total_replies) * 100, 2);
- $top_repliers[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['ucount'], "percentage" => $percen);
-}
-*/
-
-
-function showBar($perc)
-{
-
- return "";
-
-//
-//
-//
-
-
-}
-
-
-$text = "
-
-
-
-
-
- ".LAN_FORUM_6001.": | {$open_date} |
- ".LAN_FORUM_6002.": | {$open_since} |
- ".LAN_FORUM_6003.": | {$total_posts} |
- ".LAN_FORUM_1007.": | {$total_topics} |
- ".LAN_FORUM_6004.": | {$total_replies} |
- ".LAN_FORUM_6005.": | {$total_views} |
- ".LAN_FORUM_6014.": | {$postsperday} |
- ".LAN_FORUM_6006.": | {$db_size} |
- ".LAN_FORUM_6007.": | {$avg_row_len} |
-
-
-
-
-
-
-
-
-
-".LAN_FORUM_6008." |
-".LAN_FORUM_1003." |
-".LAN_FORUM_0003." |
-".LAN_FORUM_6009." |
-".LAN_DATE." |
-
-";
-
-$count=1;
-foreach($most_activeArray as $ma)
-{
- if($ma['user_name'])
- {
- $uinfo = "{$ma['user_name']}";
- }
- else
- {
- $tmp = explode(chr(1), $ma['thread_anon']);
- $uinfo = $tp->toHTML($tmp[0]);
- }
-
- $text .= "
-
-
-
-
-
-
-
- ";
- $count++;
-}
-$text .= "
-
-
-
-
-
-
-
-
-".LAN_FORUM_6008." |
-".LAN_FORUM_1003." |
-".LAN_FORUM_1005." |
-".LAN_FORUM_6009." |
-".LAN_DATE." |
-
-";
-
-$count=1;
-foreach($most_viewedArray as $ma)
-{
- if($ma['user_name'])
- {
- $uinfo = "{$ma['user_name']}";
- }
- else
- {
- $tmp = explode(chr(1), $ma['thread_anon']);
- $uinfo = $tp->toHTML($tmp[0]);
- }
-
- $text .= "
-
-
-
-
-
-
-
- ";
- $count++;
-}
-$text .= "
-
-
-
-
-
-
-
-
-
-".LAN_FORUM_6008." |
-".LAN_NAME." |
-".LAN_FORUM_2032." |
-% |
- |
-
-
-
-";
-
-$count=1;
-foreach($top_posters as $ma)
-{
- extract($ma);
- $text .= "
-
-
-
-
-
-
- ";
- $count++;
-}
-$text .= "
-
-
-
-
-
-
-
-
-
-".LAN_FORUM_6008." |
-".LAN_NAME." |
-".LAN_FORUM_2032." |
-% |
- |
-
-";
-
-$count=1;
-foreach($top_topic_starters as $ma)
-{
- extract($ma);
- $text .= "
-
-
-
-
-
-
- ";
- $count++;
-}
-$text .= "
-
-
-
-
-
-
-
-
-
-".LAN_FORUM_6008." |
-".LAN_NAME." |
-".LAN_FORUM_2032." |
-% |
- |
-
-";
-
-$count=1;
-foreach($top_repliers as $ma)
-{
- extract($ma);
- $text .= "
-
-
-
-
-
-
- ";
- $count++;
-}
-$text .= '
-
-';
-
-$ns -> tablerender(LAN_FORUM_6013, $text);
-
-require_once(FOOTERF);
-?>
\ No newline at end of file
+require_once(FOOTERF);
\ No newline at end of file
diff --git a/e107_plugins/forum/forum_viewforum.php b/e107_plugins/forum/forum_viewforum.php
index e551ed590..dacffef9b 100644
--- a/e107_plugins/forum/forum_viewforum.php
+++ b/e107_plugins/forum/forum_viewforum.php
@@ -469,6 +469,8 @@ function parse_thread($thread_info)
$tVars->LASTPOSTUSER = $thread_info['lastpost_username']; // $lastpost_name;
+ $thread_info['thread_sef'] = eHelper::title2sef($thread_info['thread_name'],'dashl');
+
$urlData = array('forum_sef'=>$thread_info['forum_sef'], 'thread_id'=>$thread_info['thread_id'],'thread_sef'=>$thread_info['thread_sef']);
$url = e107::url('forum', 'topic', $urlData);
$url .= (strpos($url,'?')!==false) ? '&' : '?';
@@ -534,6 +536,7 @@ function parse_thread($thread_info)
// $url = e107::getUrl()->create('forum/thread/view', array('id' => $threadId, 'name' => $thread_name));
+ $thread_info['thread_sef'] = eHelper::title2sef($thread_info['thread_name'],'dashl');
$url = e107::url('forum','topic', $thread_info);
$tVars->THREADNAME = "{$thread_name}";
@@ -793,6 +796,7 @@ function fpages($thread_info, $replies)
global $forum;
$pages = ceil(($replies)/$forum->prefs->get('postspage'));
+ $thread_info['thread_sef'] = eHelper::title2sef($thread_info['thread_name'],'dashl');
$urlparms = $thread_info;
if ($pages > 1)
diff --git a/e107_plugins/forum/templates/forum_template.php b/e107_plugins/forum/templates/forum_template.php
index 19b58d417..31576698b 100644
--- a/e107_plugins/forum/templates/forum_template.php
+++ b/e107_plugins/forum/templates/forum_template.php
@@ -86,7 +86,7 @@ $FORUM_TEMPLATE['main-start'] = "{FORUM_BREADCRUMB}
{SEARCH}
-
+
@@ -115,7 +115,8 @@ $FORUM_TEMPLATE['main-forum'] = "
{LASTPOSTUSER} {LASTPOSTDATE} |
";
-$FORUM_TEMPLATE['main-end'] = "
";
+$FORUM_TEMPLATE['main-end'] = "
{USERINFOX}
";
+
/*
$FORUM_TEMPLATE['main-end'] .= "
diff --git a/top.php b/top.php
index 31b232785..7088c8865 100644
--- a/top.php
+++ b/top.php
@@ -72,18 +72,18 @@ if ($action == 'active')
{$from}, {$view}
";
- if ($sql->db_Select_gen($qry))
+ if ($sql->gen($qry))
{
- $text = "\n
\n";
- $gen = e107::getDateConvert();
+ $text = "\n
\n";
+ $gen = e107::gethateConvert();
$text .= "
-
-
-
-
-
-
+
+
+
+
+
+
\n";
while ($row = $sql->db_Fetch(MYSQL_ASSOC))
@@ -155,17 +155,17 @@ if ($action == 'top')
";
// $top_forum_posters = $sql->db_Select("user", "*", "`user_forums` > 0 ORDER BY user_forums DESC LIMIT ".$from.", ".$view."");
$text = "
-
-
+
+
-
-
-
-
+
+
+
+
\n";
$counter = 1 + $from;
$sql2 = e107::getDb('sql2');
- if ($sql2->db_Select_gen($qry))
+ if ($sql2->gen($qry))
{
while ($row = $sql2->db_Fetch(MYSQL_ASSOC))
{