From 1cf4f67cc409c1b1853426a06ed856142fa2f04f Mon Sep 17 00:00:00 2001 From: mcfly Date: Wed, 10 Dec 2008 21:00:48 +0000 Subject: [PATCH] More functionality working with new db schema --- e107_plugins/forum/forum.php | 110 ++++++-------- e107_plugins/forum/forum_class.php | 21 ++- e107_plugins/forum/forum_stats.php | 51 +++---- top.php | 224 ++++++++++++++++------------- userposts.php | 148 +++++++------------ 5 files changed, 258 insertions(+), 296 deletions(-) diff --git a/e107_plugins/forum/forum.php b/e107_plugins/forum/forum.php index a4fd8cb8b..8468c6a3f 100644 --- a/e107_plugins/forum/forum.php +++ b/e107_plugins/forum/forum.php @@ -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."
".LAN_44." ".LAN_437." ".LAN_438; + $INFO .= LAN_410.'
'.LAN_44." ".LAN_437." ".LAN_438; } elseif(USER == FALSE) { - $INFO .= LAN_410."
".LAN_45." ".LAN_439." ".LAN_440; + $INFO .= LAN_410.'
'.LAN_45." ".LAN_439." ".LAN_440; } } if (USER && $allread != TRUE && $total_new_threads && $total_new_threads >= $total_read_threads) { - $INFO .= "
".LAN_199."".(e_QUERY != "new" ? ", ".LAN_421."" : ""); + $INFO .= "
".LAN_199.''.(e_QUERY != 'new' ? ", ".LAN_421."" : ''); } -if (USER && USERREALM && e_QUERY != "track") +if (USER && varsettrue($pref['forum_track']) && e_QUERY != 'track') { - $INFO .= "
".LAN_393.""; + $INFO .= "
".LAN_393.''; } $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") ? "" : "
".$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).")
".LAN_42.$total_members."
".LAN_41."".$nuser_name.".\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, "
".LAN_51."
", array('forum', '51')); + $ns->tablerender(PAGE_NAME, "
".LAN_51.'
', 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'] .= "".$e107->tp->toHTML($sub['forum_name']).''; $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]."] ".preg_replace("/\[.*\]/", "", $row['thread_name'])."" : "".$row['thread_name'].""); + + $url = $e107->url->getUrl('forum', 'thread', "func=view&id={$row['thread_id']}"); + $TRACKPOSTNAME = "".$e107->tp->toHTML($row['thread_name']).''; $UNTRACK = "".LAN_392.""; $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) diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php index 5a81bf6c6..4eebc8d17 100644 --- a/e107_plugins/forum/forum_class.php +++ b/e107_plugins/forum/forum_class.php @@ -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) { diff --git a/e107_plugins/forum/forum_stats.php b/e107_plugins/forum/forum_stats.php index 9ef63f08a..80e80c00a 100644 --- a/e107_plugins/forum/forum_stats.php +++ b/e107_plugins/forum/forum_stats.php @@ -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."
Elements: ".count($array)."
"; 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 .= " +$text .= ' -"; +'; $ns -> tablerender(FSLAN_23, $text); - require_once(FOOTERF); - - ?> \ No newline at end of file diff --git a/top.php b/top.php index 343ca6b83..b32485cd1 100644 --- a/top.php +++ b/top.php @@ -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 = "
\n\n"; - if (!is_object($gen)) { + if (!is_object($gen)) + { $gen = new convert; } - + $text .= " @@ -72,56 +79,65 @@ if ($action == "active") { \n"; - - while ($row = $sql->db_Fetch()) { - extract($row); - if (check_class($forum_class)) { - if($user_name) - { - $POSTER = "{$user_name}"; - } else { - list($anonposter, $ipaddress) = explode(chr(1), $thread_anon); - $POSTER = $anonposter; - } + while ($row = $sql->db_Fetch(MYSQL_ASSOC)) + { + if ($row['user_name']) + { + $POSTER = "{$row['user_name']}"; + } + 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.'
'.$lastpost_datestamp; - } else { - $LASTPOST = "".$lastpost_name."
".$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 .= " + $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 .= "
  ".LAN_1."".LAN_4." ".LAN_5."
{$thread_name} ({$forum_name}){$row['thread_name']} ({$row['forum_name']}) {$POSTER}{$thread_views}{$thread_total_replies}{$row['thread_views']}{$row['thread_total_replies']} {$LASTPOST}
\n
"; - - $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']) ? "" : "")); - 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 ($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']) ? "" : "")); + 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 ($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 = "
@@ -132,28 +148,33 @@ if ($action == "top") { \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 .= " - - - - - "; - $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 .= " + + + + + "; + $counter++; + } } $text .= "
".TOP_LAN_6."
{$counter}{$user_name}{$user_forums}".(strstr($ldata[0], "LAN") ? $ldata[1] : $ldata[0])."
{$counter}{$row['user_name']}{$row['user_plugin_forum_posts']}".(strstr($ldata[0], "LAN") ? $ldata[1] : $ldata[0])."
\n
"; $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 = "
@@ -165,7 +186,8 @@ if ($action == "top") { ".TOP_LAN_6." \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 .= " @@ -179,8 +201,9 @@ if ($action == "top") { $text .= "\n
"; $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 = "
@@ -192,7 +215,8 @@ if ($action == "top") { ".TOP_LAN_6." \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 .= " @@ -207,5 +231,5 @@ if ($action == "top") { $ns->tablerender(TOP_LAN_5, $text); } } -require_once(FOOTERF); +require_once (FOOTERF); ?> \ No newline at end of file diff --git a/userposts.php b/userposts.php index 00a08a1d2..a980e1081 100644 --- a/userposts.php +++ b/userposts.php @@ -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 .= "".UP_LAN_8.""; + $ftext .= "".UP_LAN_8.''; } 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 = ""; + $USERPOSTS_FORUM_TOPIC_HREF_PRE = ""; + $USERPOSTS_FORUM_TOPIC = $tp->toHTML($row['thread_name'], true, 'USER_BODY', $id); + $USERPOSTS_FORUM_NAME_HREF_PRE = ""; + $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 = " "; @@ -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 = ""; - $USERPOSTS_FORUM_TOPIC_HREF_PRE = ""; - $USERPOSTS_FORUM_TOPIC = $thread_name; - $USERPOSTS_FORUM_NAME_HREF_PRE = ""; - $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)); -} - -?> +?> \ No newline at end of file