1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 01:19:44 +01:00

More functionality working with new db schema

This commit is contained in:
mcfly 2008-12-10 21:00:48 +00:00
parent 43598f0e3d
commit 1cf4f67cc4
5 changed files with 258 additions and 296 deletions

View File

@ -11,14 +11,14 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum.php,v $
| $Revision: 1.9 $
| $Date: 2008-12-09 21:46:14 $
| $Revision: 1.10 $
| $Date: 2008-12-10 21:00:48 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
if(!defined("e107_INIT"))
if(!defined('e107_INIT'))
{
require_once("../../class2.php");
require_once('../../class2.php');
}
include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum.php');
@ -34,10 +34,10 @@ if ($untrackId = varset($_REQUEST['untrack']))
}
//Mark all threads as read
if (e_QUERY == "mark.all.as.read")
if (e_QUERY == 'mark.all.as.read')
{
$forum->forum_markasread('all');
header("location:".e_SELF);
header('location:'.e_SELF);
exit;
}
@ -45,7 +45,7 @@ if (e_QUERY == "mark.all.as.read")
if (varset($_REQUEST['mfar']))
{
$forum->forum_markasread((int)$_REQUEST['mfar']);
header("location:".e_SELF);
header('location:'.e_SELF);
exit;
}
@ -89,7 +89,7 @@ $total_replies = $sql->db_Count("forum_t", "(*)", " WHERE thread_parent!='0' ");
$total_members = $sql->db_Count("user");
$newest_member = $sql->db_Select("user", "*", "user_ban='0' ORDER BY user_join DESC LIMIT 0,1");
list($nuser_id, $nuser_name) = $sql->db_Fetch();
if(!defined("e_TRACKING_DISABLED"))
if(!defined('e_TRACKING_DISABLED'))
{
$member_users = $sql->db_Select("online", "*", "online_location REGEXP('forum.php') AND online_user_id!='0' ");
$guest_users = $sql->db_Select("online", "*", "online_location REGEXP('forum.php') AND online_user_id='0' ");
@ -177,37 +177,37 @@ if (USER == TRUE)
}
else
{
$INFO .= "";
$INFO .= '';
if (ANON == TRUE)
{
$INFO .= LAN_410."<br />".LAN_44." <a href='".e_SIGNUP."'>".LAN_437."</a> ".LAN_438;
$INFO .= LAN_410.'<br />'.LAN_44." <a href='".e_SIGNUP."'>".LAN_437."</a> ".LAN_438;
}
elseif(USER == FALSE)
{
$INFO .= LAN_410."<br />".LAN_45." <a href='".e_SIGNUP."'>".LAN_439."</a> ".LAN_440;
$INFO .= LAN_410.'<br />'.LAN_45." <a href='".e_SIGNUP."'>".LAN_439."</a> ".LAN_440;
}
}
if (USER && $allread != TRUE && $total_new_threads && $total_new_threads >= $total_read_threads)
{
$INFO .= "<br /><a href='".e_SELF."?mark.all.as.read'>".LAN_199."</a>".(e_QUERY != "new" ? ", <a href='".e_SELF."?new'>".LAN_421."</a>" : "");
$INFO .= "<br /><a href='".e_SELF."?mark.all.as.read'>".LAN_199.'</a>'.(e_QUERY != 'new' ? ", <a href='".e_SELF."?new'>".LAN_421."</a>" : '');
}
if (USER && USERREALM && e_QUERY != "track")
if (USER && varsettrue($pref['forum_track']) && e_QUERY != 'track')
{
$INFO .= "<br /><a href='".e_SELF."?track'>".LAN_393."</a>";
$INFO .= "<br /><a href='".e_SELF."?track'>".LAN_393.'</a>';
}
$FORUMINFO = LAN_192.($total_topics+$total_replies)." ".LAN_404." ($total_topics ".($total_topics == 1 ? LAN_411 : LAN_413).", $total_replies ".($total_replies == 1 ? LAN_412 : LAN_414).").".(!defined("e_TRACKING_DISABLED") ? "" : "<br />".$users." ".($users == 1 ? LAN_415 : LAN_416)." (".$member_users." ".($member_users == 1 ? LAN_417 : LAN_419).", ".$guest_users." ".($guest_users == 1 ? LAN_418 : LAN_420).")<br />".LAN_42.$total_members."<br />".LAN_41."<a href='".e_BASE."user.php?id.".$nuser_id."'>".$nuser_name."</a>.\n");
if (!isset($FORUM_MAIN_START))
{
if (file_exists(THEME."forum_template.php"))
if (file_exists(THEME.'forum_template.php'))
{
include_once(THEME."forum_template.php");
include_once(THEME.'forum_template.php');
}
}
include(e_PLUGIN."forum/templates/forum_template.php");
include(e_PLUGIN.'forum/templates/forum_template.php');
require_once(HEADERF);
$parent_list = $forum->forum_getparents();
@ -217,16 +217,18 @@ $newflag_list = $forum->forum_newflag_list();
if (!$parent_list)
{
$ns->tablerender(PAGE_NAME, "<div style='text-align:center'>".LAN_51."</div>", array('forum', '51'));
$ns->tablerender(PAGE_NAME, "<div style='text-align:center'>".LAN_51.'</div>', array('forum', '51'));
require_once(FOOTERF);
exit;
}
$forum_string = "";
foreach ($parent_list as $parent) {
$forum_string = '';
foreach ($parent_list as $parent)
{
$status = parse_parent($parent);
$PARENTSTATUS = $status[0];
if ($status[1]) {
if ($status[1])
{
$PARENTNAME = $parent['forum_name'];
$forum_string .= preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_MAIN_PARENT);
// $forums = $forum->forum_getforums($parent['forum_id']);
@ -275,7 +277,7 @@ function parse_parent($parent)
$status[1] = TRUE;
if(!check_class($parent['forum_postclass']))
{
$status[0] = "( ".LAN_405." )";
$status[0] = '( '.LAN_405.' )';
}
}
else
@ -285,7 +287,7 @@ function parse_parent($parent)
return $status;
}
function parse_forum($f, $restricted_string = "")
function parse_forum($f, $restricted_string = '')
{
global $FORUM_MAIN_FORUM, $gen, $forum, $tp, $newflag_list, $sub_list;
$e107 = e107::getInstance();
@ -366,7 +368,7 @@ function parse_subs($subList, $lastpost_datestamp)
$ret['text'] = "";
foreach($subList as $sub)
{
$ret['text'] .= ($ret['text'] ? ", " : "");
$ret['text'] .= ($ret['text'] ? ', ' : '');
$suburl = $e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id' => $sub['forum_id']));
$ret['text'] .= "<a href='{$suburl}'>".$e107->tp->toHTML($sub['forum_name']).'</a>';
$ret['threads'] += $sub['forum_threads'];
@ -390,7 +392,7 @@ if (e_QUERY == 'track')
// $sql2 = new db;
// $tmp = explode("-", USERREALM);
$viewed = $forum->threadGetUserViewed();
$qry = "
SELECT t.*, p.* from `#forum_thread` AS t
LEFT JOIN `#forum_post` AS p ON p.post_thread = t.thread_id AND p.post_datestamp = t.thread_datestamp
@ -401,63 +403,37 @@ if (e_QUERY == 'track')
{
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
{
var_dump($row);
}
}
}
/*
foreach($trackedThreads as $threadId)
{
if ($value)
{
if($sql->db_Select("forum_t", "thread_id, thread_datestamp, thread_name", "thread_id='".intval($value)."' "))
{
$row = $sql->db_Fetch();
//extract($row);
$NEWIMAGE = IMAGE_nonew_small;
if ($row['thread_datestamp'] > USERLV && (strpos(USERVIEWED, ".".$row['thread_id'].".") === FALSE))
if ($row['thread_datestamp'] > USERLV && !in_array($row['thread_id'], $viewed))
{
$NEWIMAGE = IMAGE_new_small;
}
elseif($sql2->db_SELECT("forum_t", "thread_id", "thread_parent='{$row['thread_id']}' AND thread_datestamp > '".USERLV."' "))
{
while ($xrow = $sql2->db_Fetch())
{
if (strpos(USERVIEWED, ".".$xrow['thread_id'].".") === FALSE)
{
$NEWIMAGE = IMAGE_new_small;
}
}
}
$result = preg_split("/\]/", $row['thread_name']);
$TRACKPOSTNAME = (($result[1] && $row['thread_name']{0} == "[") ? $result[0]."] <a href='".e_PLUGIN."forum/forum_viewtopic.php?{$row['thread_id']}'>".preg_replace("/\[.*\]/", "", $row['thread_name'])."</a>" : "<a href='".e_PLUGIN."forum/forum_viewtopic.php?{$row['thread_id']}'>".$row['thread_name']."</a>");
$url = $e107->url->getUrl('forum', 'thread', "func=view&id={$row['thread_id']}");
$TRACKPOSTNAME = "<a href='{$url}'>".$e107->tp->toHTML($row['thread_name']).'</a>';
$UNTRACK = "<a href='".e_SELF."?untrack.".$row['thread_id']."'>".LAN_392."</a>";
$forum_trackstring .= preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_TRACK_MAIN);
}
}
$forum_track_start = preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_TRACK_START);
$forum_track_end = preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_TRACK_END);
if ($pref['forum_enclose'])
{
$ns->tablerender($pref['forum_title'], $forum_track_start.$forum_trackstring.$forum_track_end, array('forum', 'main1'));
}
else
{
echo $forum_track_start.$forum_trackstring.$forum_track_end;
}
}
$forum_track_start = preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_TRACK_START);
$forum_track_end = preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_TRACK_END);
if ($pref['forum_enclose'])
{
$ns->tablerender($pref['forum_title'], $forum_track_start.$forum_trackstring.$forum_track_end, array('forum', 'main1'));
}
else
{
echo $forum_track_start.$forum_trackstring.$forum_track_end;
}
*/
}
if (e_QUERY == "new")
if (e_QUERY == 'new')
{
$newpostList = $forum->post_getnew(10);
foreach($newpostList as $post)
{
list($author_id, $author_info) = explode(".", $post['thread_user'], 2);
list($author_id, $author_info) = explode('.', $post['thread_user'], 2);
list($author_name, $tmp) = explode(chr(1), $author_info);
$datestamp = $gen->convert_date($post['thread_datestamp'], "forum");
if($author_id == 0)

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $
| $Revision: 1.21 $
| $Date: 2008-12-09 21:46:14 $
| $Revision: 1.22 $
| $Date: 2008-12-10 21:00:48 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@ -343,6 +343,23 @@ class e107forum
return $ret;
}
function threadGetUserViewed($uid = USERID)
{
$e107 = e107::getInstance();
if($uid == USERID)
{
$viewed = $e107->currentUser['plugin_forum_user_viewed'];
}
else
{
$tmp = get_user_data($uid);
$viewed = $tmp['plugin_forum_user_viewed'];
unset($tmp);
}
return explode(',', $viewed);
}
function thread_postnum($thread_id)
{

View File

@ -11,57 +11,52 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_stats.php,v $
| $Revision: 1.4 $
| $Date: 2008-10-19 11:35:00 $
| $Author: e107steved $
| $Revision: 1.5 $
| $Date: 2008-12-10 21:00:48 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
require_once('../../class2.php');
@include_once e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_stats.php';
@include_once e_PLUGIN.'forum/languages/English/lan_forum_stats.php';
@require_once(e_PLUGIN.'forum/forum_class.php');
include_lan(e_PLUGIN.'forum/languages/English/lan_forum_stats.php');
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");
$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');
require_once(HEADERF);
$total_posts = $sql -> db_Count("forum_t");
$total_topics = $sql -> db_Count("forum_t", "(*)", "WHERE thread_parent=0");
$total_replies = $sql -> db_Count("forum_t", "(*)", "WHERE thread_parent!=0");
$total_posts = $sql -> db_Count('forum_post');
$total_topics = $sql -> db_Count('forum_thread');
$total_replies = $total_posts - $total_topics;
$total_views = 0;
$query = "SELECT sum(thread_views) AS total FROM #forum_t "; // Try this way - original way didn't work for some users
$query = 'SELECT sum(thread_views) AS total FROM `#forum_thread` ';
if ($sql -> db_Select_gen($query))
//if($sql->db_Select("forum_t", "sum(thread_views) AS total", '', 'nowhere'))
{
$row = $sql->db_Fetch();
$total_views = $row['total'];
}
$firstpost = $sql -> db_Select("forum_t", "thread_datestamp", "thread_datestamp > 0 ORDER BY thread_datestamp ASC LIMIT 0,1");
$fp = $sql -> db_Fetch();
$firstpost = $sql -> db_Select('forum_post', 'post_datestamp', 'post_datestamp > 0 ORDER BY post_datestamp ASC LIMIT 0,1', 'default');
$fp = $sql->db_Fetch();
$open_ds = $fp['thread_datestamp'];
$open_date = $gen->convert_date($open_ds, "long");
$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}"; // Original line - doesn't like DB names with a '-' - enclose in backticks
//$query = "SHOW TABLE STATUS FROM `{$sql->mySQLdefaultdb}` LIKE '".MPREFIX."forum_t"."' "; // This selects the one table we want (but didn't always work)
$query = "SHOW TABLE STATUS FROM `{$mySQLdefaultdb}`"; // Original line with backticks added
$query = "SHOW TABLE STATUS FROM `{$mySQLdefaultdb}`";
$sql -> db_Select_gen($query);
$array = $sql -> db_getList();
//$table = $sql -> db_Fetch();
//echo $query."<br />Elements: ".count($array)."<br />";
foreach($array as $table)
{
if($table['Name'] == MPREFIX."forum_t")
if($table['Name'] == MPREFIX.'forum_post')
{
$db_size = $e107->parseMemorySize($table['Data_length']);
$avg_row_len = $e107->parseMemorySize($table['Avg_row_length']);
@ -69,7 +64,6 @@ foreach($array as $table)
}
}
$query = "
SELECT ft.thread_id, ft.thread_user, ft.thread_name, ft.thread_total_replies, ft.thread_datestamp, f.forum_class, u.user_name FROM #forum_t as ft
LEFT JOIN #user AS u ON ft.thread_user = u.user_id
@ -343,16 +337,13 @@ foreach($top_repliers as $ma)
";
$count++;
}
$text .= "</table>
$text .= '</table>
</div>
";
';
$ns -> tablerender(FSLAN_23, $text);
require_once(FOOTERF);
?>

224
top.php
View File

@ -11,59 +11,66 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/top.php,v $
| $Revision: 1.2 $
| $Date: 2007-04-05 01:54:17 $
| $Author: streaky $
| $Revision: 1.3 $
| $Date: 2008-12-10 21:00:48 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
require_once("class2.php");
if (!e_QUERY) {
$action = "top";
$subaction = "all";
require_once ('class2.php');
if (!e_QUERY)
{
$action = 'top';
$subaction = 'all';
$from = 0;
$view = 10;
} else {
$tmp = explode(".", e_QUERY);
}
else
{
$tmp = explode('.', e_QUERY);
$from = intval($tmp[0]);
$action = $tmp[1];
$subaction = $tmp[2];
$view = ($tmp[3] ? intval($tmp[3]) : 10);
}
if ($action == "top") {
define("e_PAGETITLE", ": ".LAN_8);
} elseif($action == "active") {
define("e_PAGETITLE", ": ".LAN_7);
if ($action == 'top')
{
define('e_PAGETITLE', ': '.LAN_8);
} elseif ($action == 'active')
{
define('e_PAGETITLE', ': '.LAN_7);
}
require_once(HEADERF);
if ($action == "active") {
require_once(e_HANDLER."userclass_class.php");
$query = "
SELECT
t.*, f.forum_name, f.forum_class, u.user_name, fp.forum_class FROM #forum_t AS t
LEFT JOIN #forum AS f
ON t.thread_forum_id = f.forum_id
LEFT JOIN #user AS u
ON SUBSTRING_INDEX(t.thread_user,'.',1) = u.user_id
LEFT JOIN #forum AS fp
ON fp.forum_id = f.forum_parent
WHERE
t.thread_parent = 0
AND fp.forum_class IN (".USERCLASS_LIST.")
AND f.forum_class IN (".USERCLASS_LIST.")
ORDER BY
t.thread_views DESC
LIMIT
{$from}, {$view}";
if ($sql->db_Select_gen($query)) {
require_once (HEADERF);
if ($action == 'active')
{
require_once (e_HANDLER.'userclass_class.php');
require_once (e_PLUGIN.'forum/forum_class.php');
$forum = new e107forum;
$forumList = implode(',', $forum->permList['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
{$from}, {$view}
";
if ($sql->db_Select_gen($qry))
{
$text = "<div style='text-align:center'>\n<table style='width:auto' class='fborder'>\n";
if (!is_object($gen)) {
if (!is_object($gen))
{
$gen = new convert;
}
$text .= "<tr>
<td style='width:5%' class='forumheader'>&nbsp;</td>
<td style='width:45%' class='forumheader'>".LAN_1."</td>
@ -72,56 +79,65 @@ if ($action == "active") {
<td style='width:5%; text-align:center' class='forumheader'>".LAN_4."</td>
<td style='width:25%; text-align:center' class='forumheader'>".LAN_5."</td>
</tr>\n";
while ($row = $sql->db_Fetch()) {
extract($row);
if (check_class($forum_class)) {
if($user_name)
{
$POSTER = "<a href='".e_HTTP."user.php?id.{$thread_user}'>{$user_name}</a>";
} else {
list($anonposter, $ipaddress) = explode(chr(1), $thread_anon);
$POSTER = $anonposter;
}
while ($row = $sql->db_Fetch(MYSQL_ASSOC))
{
if ($row['user_name'])
{
$POSTER = "<a href='".$e107->url->getUrl('core:user', 'main', "func=profile&id={$row['thread_user']}")."'>{$row['user_name']}</a>";
}
else
{
$POSTER = $row['thread_user_anon'];
}
$LINKTOTHREAD = e_PLUGIN_ABS."forum/forum_viewtopic.php?".$thread_id;
$LINKTOFORUM = e_PLUGIN_ABS."forum/forum_viewforum.php?".$thread_forum_id;
$lastpost_datestamp = $gen->convert_date($thread_lastpost, "forum");
list($lastpost_id, $lastpost_name) = explode('.', $thread_lastuser, 2);
if (!$lastpost_id) {
$LASTPOST = $lastpost_name.'<br />'.$lastpost_datestamp;
} else {
$LASTPOST = "<a href='".e_HTTP."user.php?id.".$lastpost_id."'>".$lastpost_name."</a><br />".$lastpost_datestamp;
}
$LINKTOTHREAD = $e107->url->getUrl('forum', 'thread', "func=view&id={$row['thread_id']}");
$LINKTOFORUM = $e107->url->getUrl('forum', 'forum', "func=view&id={$row['thread_forum_id']}");
$text .= "<tr>
$lastpost_datestamp = $gen->convert_date($row['thread_lastpost'], 'forum');
if ($row['user_last'])
{
$LASTPOST = "<a href='".$e107->url->getUrl('core:user', 'main', "func=profile&id={$row['thread_lastuser']}")."'>{$row['user_last']}</a><br />".$lastpost_datestamp;
}
else
{
$LASTPOST = $row['thread_lastuser_anon'].'<br />'.$lastpost_datestamp;
}
$text .= "<tr>
<td style='width:5%; text-align:center' class='forumheader3'><img src='".e_PLUGIN_ABS."forum/images/".IMODE."/new_small.png' alt='' /></td>
<td style='width:45%' class='forumheader3'><b><a href='{$LINKTOTHREAD}'>{$thread_name}</a></b> <span class='smalltext'>(<a href='{$LINKTOFORUM}'>{$forum_name}</a>)</span></td>
<td style='width:45%' class='forumheader3'><b><a href='{$LINKTOTHREAD}'>{$row['thread_name']}</a></b> <span class='smalltext'>(<a href='{$LINKTOFORUM}'>{$row['forum_name']}</a>)</span></td>
<td style='width:15%; text-align:center' class='forumheader3'>{$POSTER}</td>
<td style='width:5%; text-align:center' class='forumheader3'>{$thread_views}</td>
<td style='width:5%; text-align:center' class='forumheader3'>{$thread_total_replies}</td>
<td style='width:5%; text-align:center' class='forumheader3'>{$row['thread_views']}</td>
<td style='width:5%; text-align:center' class='forumheader3'>{$row['thread_total_replies']}</td>
<td style='width:25%; text-align:center' class='forumheader3'>{$LASTPOST}</td>
</tr>\n";
}
}
$text .= "</table>\n</div>";
$ns->tablerender(LAN_7, $text, "nfp");
require_once(e_HANDLER."np_class.php");
$ftotal = $sql->db_Count("forum_t", "(*)", "WHERE thread_parent = 0");
$ix = new nextprev("top.php", $from, $view, $ftotal, "", "active.forum.".$view."");
$ns->tablerender(LAN_7, $text, 'nfp');
require_once (e_HANDLER.'np_class.php');
$ftotal = $sql->db_Count('forum_thread', '(*)', 'WHERE 1');
$ix = new nextprev('top.php', $from, $view, $ftotal, '', 'active.forum.'.$view);
}
}
if ($action == "top") {
require_once(e_HANDLER."level_handler.php");
define("IMAGE_rank_main_admin_image", ($pref['rank_main_admin_image'] && file_exists(THEME."forum/".$pref['rank_main_admin_image']) ? "<img src='".THEME_ABS."forum/".$pref['rank_main_admin_image']."' alt='' />" : "<img src='".e_PLUGIN_ABS."forum/images/".IMODE."/main_admin.png' alt='' />"));
define("IMAGE_rank_admin_image", ($pref['rank_admin_image'] && file_exists(THEME."forum/".$pref['rank_admin_image']) ? "<img src='".THEME_ABS."forum/".$pref['rank_admin_image']."' alt='' />" : "<img src='".e_PLUGIN_ABS."forum/images/".IMODE."/admin.png' alt='' />"));
define("IMAGE_rank_moderator_image", ($pref['rank_moderator_image'] && file_exists(THEME."forum/".$pref['rank_moderator_image']) ? "<img src='".THEME_ABS."forum/".$pref['rank_moderator_image']."' alt='' />" : "<img src='".e_PLUGIN_ABS."forum/images/".IMODE."/moderator.png' alt='' />"));
if ($subaction == "forum" || $subaction == "all") {
$top_forum_posters = $sql->db_Select("user", "*", "`user_forums` > 0 ORDER BY user_forums DESC LIMIT ".$from.", ".$view."");
if ($action == 'top')
{
require_once (e_HANDLER.'level_handler.php');
define('IMAGE_rank_main_admin_image', ($pref['rank_main_admin_image'] && file_exists(THEME."forum/".$pref['rank_main_admin_image']) ? "<img src='".THEME_ABS."forum/".$pref['rank_main_admin_image']."' alt='' />" : "<img src='".e_PLUGIN_ABS."forum/images/".IMODE."/main_admin.png' alt='' />"));
define('IMAGE_rank_admin_image', ($pref['rank_admin_image'] && file_exists(THEME."forum/".$pref['rank_admin_image']) ? "<img src='".THEME_ABS."forum/".$pref['rank_admin_image']."' alt='' />" : "<img src='".e_PLUGIN_ABS."forum/images/".IMODE."/admin.png' alt='' />"));
define('IMAGE_rank_moderator_image', ($pref['rank_moderator_image'] && file_exists(THEME."forum/".$pref['rank_moderator_image']) ? "<img src='".THEME_ABS."forum/".$pref['rank_moderator_image']."' alt='' />" : "<img src='".e_PLUGIN_ABS."forum/images/".IMODE."/moderator.png' alt='' />"));
if ($subaction == 'forum' || $subaction == 'all')
{
$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 {$from}, {$view}
";
// $top_forum_posters = $sql->db_Select("user", "*", "`user_forums` > 0 ORDER BY user_forums DESC LIMIT ".$from.", ".$view."");
$text = "
<div style='text-align:center'>
<table style='width:95%' class='fborder'>
@ -132,28 +148,33 @@ if ($action == "top") {
<td style='width:30%; text-align:center' class='forumheader3'>".TOP_LAN_6."</td>
</tr>\n";
$counter = 1 + $from;
while ($row = $sql->db_Fetch()) {
extract($row);
$ldata = get_level($user_id, $user_forums, $user_comments, $user_chats, $user_visits, $user_join, $user_admin, $user_perms, $pref);
$text .= "<tr>
<td style='width:10%; text-align:center' class='forumheader3'>{$counter}</td>
<td style='width:50%' class='forumheader3'><a href='".e_HTTP."user.php?id.{$user_id}'>{$user_name}</a></td>
<td style='width:10%; text-align:center' class='forumheader3'>{$user_forums}</td>
<td style='width:30%; text-align:center' class='forumheader3'>".(strstr($ldata[0], "LAN") ? $ldata[1] : $ldata[0])."</td>
</tr>";
$counter++;
if ($e107->sql->db_Select_gen($qry))
{
while ($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
{
$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);
$text .= "<tr>
<td style='width:10%; text-align:center' class='forumheader3'>{$counter}</td>
<td style='width:50%' class='forumheader3'><a href='".e_HTTP."user.php?id.{$row['user_id']}'>{$row['user_name']}</a></td>
<td style='width:10%; text-align:center' class='forumheader3'>{$row['user_plugin_forum_posts']}</td>
<td style='width:30%; text-align:center' class='forumheader3'>".(strstr($ldata[0], "LAN") ? $ldata[1] : $ldata[0])."</td>
</tr>";
$counter++;
}
}
$text .= "</table>\n</div>";
$ns->tablerender(TOP_LAN_0, $text);
if ($subaction == "forum") {
require_once(e_HANDLER."np_class.php");
$ftotal = $sql->db_Count("user", "(*)", "WHERE `user_forums` > 0");
$ix = new nextprev("top.php", $from, $view, $ftotal, "Forum Posts", "top.forum.".$view."");
if ($subaction == 'forum')
{
require_once (e_HANDLER.'np_class.php');
$ftotal = $sql->db_Count('user_extended', '(*)', 'WHERE `user_plugin_forum_posts` > 0');
$ix = new nextprev('top.php', $from, $view, $ftotal, 'Forum Posts', 'top.forum.'.$view);
}
}
if ($subaction == "comment" || $subaction == "all") {
if ($subaction == 'comment' || $subaction == 'all')
{
$top_forum_posters = $sql->db_Select("user", "*", "`user_comments` > 0 ORDER BY user_comments DESC LIMIT 0, 10");
$text = "
<div style='text-align:center'>
@ -165,7 +186,8 @@ if ($action == "top") {
<td style='width:30%; text-align:center' class='forumheader3'>".TOP_LAN_6."</td>
</tr>\n";
$counter = 1;
while ($row = $sql->db_Fetch()) {
while ($row = $sql->db_Fetch())
{
extract($row);
$ldata = get_level($user_id, $user_forums, $user_comments, $user_chats, $user_visits, $user_join, $user_admin, $user_perms, $pref);
$text .= "<tr>
@ -179,8 +201,9 @@ if ($action == "top") {
$text .= "</table>\n</div>";
$ns->tablerender(TOP_LAN_3, $text);
}
if ($subaction == "chat" || $subaction == "all") {
if ($subaction == "chat" || $subaction == "all")
{
$top_forum_posters = $sql->db_Select("user", "*", "`user_chats` > 0 ORDER BY user_chats DESC LIMIT 0, 10");
$text = "
<div style='text-align:center'>
@ -192,7 +215,8 @@ if ($action == "top") {
<td style='width:30%; text-align:center' class='forumheader3'>".TOP_LAN_6."</td>
</tr>\n";
$counter = 1;
while ($row = $sql->db_Fetch()) {
while ($row = $sql->db_Fetch())
{
extract($row);
$ldata = get_level($user_id, $user_forums, $user_comments, $user_chats, $user_visits, $user_join, $user_admin, $user_perms, $pref);
$text .= "<tr>
@ -207,5 +231,5 @@ if ($action == "top") {
$ns->tablerender(TOP_LAN_5, $text);
}
}
require_once(FOOTERF);
require_once (FOOTERF);
?>

View File

@ -11,13 +11,13 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/userposts.php,v $
| $Revision: 1.7 $
| $Date: 2008-07-03 20:06:53 $
| $Author: e107steved $
| $Revision: 1.8 $
| $Date: 2008-12-10 21:00:48 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
require_once("class2.php");
require_once(e_HANDLER."comment_class.php");
require_once('class2.php');
require_once(e_HANDLER.'comment_class.php');
$cobj = new comment;
require_once(HEADERF);
@ -27,7 +27,7 @@ $_POST['f_query'] = trim($_POST['f_query']);
$action = 'exit';
if (e_QUERY)
{
$tmp = explode(".", e_QUERY);
$tmp = explode('.', e_QUERY);
$from = intval($tmp[0]); // Always defined
$action = varset($tmp[1],'exit');
if (!isset($tmp[2])) $action = 'exit';
@ -92,7 +92,7 @@ if ($action == "comments")
{ // Legacy decode (IPV4 address as it used to be stored - hex string)
$hexip = explode('.', chunk_split($dip, 2, '.'));
$dip = hexdec($hexip[0]). '.' . hexdec($hexip[1]) . '.' . hexdec($hexip[2]) . '.' . hexdec($hexip[3]);
}
$ccaption = UP_LAN_1.$dip;
$data = $cobj->getCommentData($amount='10', $from, "comment_ip = '".$id."'");
@ -121,15 +121,18 @@ if ($action == "comments")
if ($action == "forums" || isset($_POST['fsearch']))
if ($action == 'forums' || isset($_POST['fsearch']))
{
require_once (e_PLUGIN.'forum/forum_class.php');
$forum = new e107forum;
$forumList = implode(',', $forum->permList['view']);
if(is_numeric($id))
{
$user_id = intval($id);
$sql->db_Select("user", "user_name", "user_id=".$id);
$row = $sql->db_Fetch();
$fcaption = UP_LAN_0." ".$row['user_name'];
$uinfo = get_user_data($id);
$fcaption = UP_LAN_0.' '.$uinfo['user_name'];
}
else
{
@ -138,54 +141,36 @@ if ($action == "forums" || isset($_POST['fsearch']))
if (!$USERPOSTS_FORUM_TABLE)
{
if (file_exists(THEME."userposts_template.php"))
if (file_exists(THEME.'userposts_template.php'))
{
require_once(THEME."userposts_template.php");
require_once(THEME.'userposts_template.php');
}
else
{
require_once(e_BASE.$THEMES_DIRECTORY."templates/userposts_template.php");
require_once(e_BASE.$THEMES_DIRECTORY.'templates/userposts_template.php');
}
}
$s_info = "";
if (isset($_POST['f_query']) && $_POST['f_query'] != "")
$s_info = '';
if (isset($_POST['f_query']) && $_POST['f_query'] != '')
{
$f_query = $tp -> toDB($_POST['f_query']);
$s_info = "AND (ft.thread_name REGEXP('".$f_query."') OR ft.thread_thread REGEXP('".$f_query."'))";
$fcaption = UP_LAN_12." ".$row['user_name'];
$s_info = "AND (t.thread_name REGEXP('".$f_query."') OR p.post_entry REGEXP('".$f_query."'))";
$fcaption = UP_LAN_12.' '.$row['user_name'];
}
$qry = "
SELECT ft.*, f.* FROM #forum_t AS ft
LEFT JOIN #forum AS f ON ft.thread_forum_id = f.forum_id
LEFT JOIN #forum AS fp ON f.forum_parent = fp.forum_id
WHERE SUBSTRING_INDEX(ft.thread_user,'.',1) = {$user_id}
AND f.forum_class IN (".USERCLASS_LIST.")
AND fp.forum_class IN (".USERCLASS_LIST.")
SELECT SQL_CALC_FOUND_ROWS p.*, t.*, f.* FROM `#forum_post` AS p
LEFT JOIN `#forum_thread` AS t ON t.thread_id = p.post_thread
LEFT JOIN `#forum` AS f ON f.forum_id = p.post_forum
WHERE p.post_user = {$id}
AND p.post_forum IN ({$forumList})
{$s_info}
ORDER BY ft.thread_datestamp DESC LIMIT {$from}, 10
ORDER BY p.post_datestamp DESC LIMIT {$from}, 10
";
$total_qry = "
SELECT COUNT(*) AS count FROM #forum_t AS ft
LEFT JOIN #forum AS f ON ft.thread_forum_id = f.forum_id
LEFT JOIN #forum AS fp ON f.forum_parent = fp.forum_id
WHERE SUBSTRING_INDEX(ft.thread_user,'.',1) = {$user_id}
AND f.forum_class IN (".USERCLASS_LIST.")
AND fp.forum_class IN (".USERCLASS_LIST.")
{$s_info}
";
$ftotal = 0;
if($sql->db_Select_gen($total_qry))
{
$row = $sql->db_Fetch();
$ftotal = $row['count'];
}
if (!$sql->db_Select_gen($qry))
{
$ftext .= "<span class='mediumtext'>".UP_LAN_8."</span>";
$ftext .= "<span class='mediumtext'>".UP_LAN_8.'</span>';
}
else
{
@ -193,10 +178,27 @@ if ($action == "forums" || isset($_POST['fsearch']))
{
$gen = new convert;
}
$render = $sql -> db_getList();
foreach ($render as $row)
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
{
$userposts_forum_table_string .= parse_userposts_forum_table($row);
// var_dump($row);
$datestamp = $gen->convert_date($row['post_datestamp'], 'short');
if ($row['thread_datestamp'] = $row['post_datestamp'])
{
$USERPOSTS_FORUM_TOPIC_PRE = UP_LAN_2.': ';
}
else
{
$USERPOSTS_FORUM_TOPIC_PRE = UP_LAN_12.': ';
}
$USERPOSTS_FORUM_ICON = "<img src='".e_PLUGIN."forum/images/".IMODE."/new_small.png' alt='' />";
$USERPOSTS_FORUM_TOPIC_HREF_PRE = "<a href='".$e107->url->getUrl('forum', 'thread', "func=post&id={$row['post_id']}")."'>";
$USERPOSTS_FORUM_TOPIC = $tp->toHTML($row['thread_name'], true, 'USER_BODY', $id);
$USERPOSTS_FORUM_NAME_HREF_PRE = "<a href='".$e107->url->getUrl('forum', 'forum', "func=view&id={$row['post_forum']}")."'>";
$USERPOSTS_FORUM_NAME = $tp->toHTML($row['forum_name'], true, 'USER_BODY', $id);
$USERPOSTS_FORUM_THREAD = $tp->toHTML($row['post_entry'], true, 'USER_BODY', $id);
$USERPOSTS_FORUM_DATESTAMP = UP_LAN_11." ".$datestamp;
$userposts_forum_table_string .= preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_FORUM_TABLE);
}
$userposts_forum_table_start = preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_FORUM_TABLE_START);
$USERPOSTS_FORUM_SEARCH = "<input class='tbox' type='text' name='f_query' size='20' value='' maxlength='50' /> <input class='button' type='submit' name='fsearch' value='".UP_LAN_12."' />";
@ -204,7 +206,7 @@ if ($action == "forums" || isset($_POST['fsearch']))
$ftext .= $userposts_forum_table_start."".$userposts_forum_table_string."".$userposts_forum_table_end;
}
$ns->tablerender($fcaption, $ftext);
$ftotal = $e107->sql->total_results;
$parms = $ftotal.",10,".$from.",".e_SELF."?[FROM].forums.".$id;
$USERPOSTS_NEXTPREV = $tp->parseTemplate("{NEXTPREV={$parms}}");
echo preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_NP_TABLE);
@ -213,8 +215,6 @@ if ($action == "forums" || isset($_POST['fsearch']))
require_once(FOOTERF);
function parse_userposts_comments_table($row)
{
global $USERPOSTS_COMMENTS_TABLE, $pref, $gen, $tp, $menu_pref, $id, $sql2, $comment_files;
@ -231,50 +231,4 @@ function parse_userposts_comments_table($row)
return(preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_COMMENTS_TABLE));
}
function parse_userposts_forum_table($row)
{
global $USERPOSTS_FORUM_TABLE, $gen, $tp, $id;
extract($row);
$gen = new convert;
$sql2 = new db;
$poster = substr($thread_user, (strpos($thread_user, ".")+1));
$datestamp = $gen->convert_date($thread_datestamp, "short");
$DATESTAMP = $datestamp;
if ($thread_parent)
{
if ($cachevar[$thread_parent])
{
$thread_name = $cachevar[$thread_parent];
}
else
{
$sql2->db_Select("forum_t", "thread_name", "thread_id = ".intval($thread_parent));
list($thread_name) = $sql2->db_Fetch();
$cachevar[$thread_parent] = $thread_name;
}
$USERPOSTS_FORUM_TOPIC_PRE = UP_LAN_15.": ";
}
else
{
$USERPOSTS_FORUM_TOPIC_PRE = UP_LAN_2.": ";
}
$tmp = $thread_id;
$thread_thread = $tp->toHTML($thread_thread, TRUE, "USER_BODY", $id);
$USERPOSTS_FORUM_ICON = "<img src='".e_PLUGIN."forum/images/".IMODE."/new_small.png' alt='' />";
$USERPOSTS_FORUM_TOPIC_HREF_PRE = "<a href='".e_PLUGIN."forum/forum_viewtopic.php?".$tmp.".post'>";
$USERPOSTS_FORUM_TOPIC = $thread_name;
$USERPOSTS_FORUM_NAME_HREF_PRE = "<a href='".e_PLUGIN."forum/forum_viewforum.php?".$forum_id."'>";
$USERPOSTS_FORUM_NAME = $forum_name;
$USERPOSTS_FORUM_THREAD = $thread_thread;
$USERPOSTS_FORUM_DATESTAMP = UP_LAN_11." ".$datestamp;
return(preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_FORUM_TABLE));
}
?>
?>