| [ PHPXref.com ] | [ Generated: Sun Jul 20 20:57:59 2008 ] | [ vtiger Forums 1.1 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 ####################################################################### 3 ## ## 4 ## phpBB Fetch All - displays phpBB on any page ## 5 ## ----------------------------------------------------------------- ## 6 ## A portal example file. ## 7 ## ## 8 ####################################################################### 9 ## ## 10 ## Authors: Volker 'Ca5ey' Rattel <ca5ey@clanunity.net> ## 11 ## http://clanunity.net/portal.php ## 12 ## ## 13 ## This file is free software; you can redistribute it and/or modify ## 14 ## it under the terms of the GNU General Public License as published ## 15 ## by the Free Software Foundation; either version 2, or (at your ## 16 ## option) any later version. ## 17 ## ## 18 ## This file is distributed in the hope that it will be useful, ## 19 ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## 20 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## 21 ## GNU General Public License for more details. ## 22 ## ## 23 ####################################################################### 24 25 26 $phpbb_root_path = './'; 27 28 define ('IN_PHPBB', true); 29 30 if (!file_exists($phpbb_root_path . 'extension.inc')) 31 { 32 die ('<tt><b>phpBB Fetch All:</b> 33 $phpbb_root_path is wrong and does not point to your forum.</tt>'); 34 } 35 36 // 37 // phpBB related files 38 // 39 40 include_once ($phpbb_root_path . 'extension.inc'); 41 include_once ($phpbb_root_path . 'common.' . $phpEx); 42 include_once ($phpbb_root_path . 'includes/bbcode.' . $phpEx); 43 44 45 // 46 // Fetch All related files - we do need all these because the portal is a 47 // huge example 48 // 49 include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/common.' . $phpEx); 50 include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/stats.' . $phpEx); 51 include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/users.' . $phpEx); 52 include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/polls.' . $phpEx); 53 include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/posts.' . $phpEx); 54 include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/forums.' . $phpEx); 55 56 // 57 // start session management 58 // 59 60 $userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length); 61 init_userprefs($userdata); 62 63 // 64 // since we are demonstrating span pages we need to set the page offset 65 // 66 67 if (isset($HTTP_GET_VARS['start']) or isset($HTTP_POST_VARS['start'])) { 68 $CFG['posts_span_pages_offset'] = isset($HTTP_GET_VARS['start']) ? $HTTP_GET_VARS['start'] : $HTTP_POST_VARS['start']; 69 } 70 71 // sorting variable getting from post or get method, added by ashley. 72 $order_type = $HTTP_POST_VARS['order_type'] ? $HTTP_POST_VARS['order_type'] : $HTTP_GET_VARS['order_type']; 73 $order_column = $HTTP_POST_VARS['order_column'] ? $HTTP_POST_VARS['order_column'] : $HTTP_GET_VARS['order_column']; 74 //Added By David For Sorting : 75 if ($order_column != "") 76 { 77 setcookie("cookie_order", "$order_column", time() + 31536000,"/"); 78 } 79 else 80 $order_column = $_COOKIE['cookie_order']; 81 if ($order_type != "") 82 { 83 setcookie("cookie_type", "$order_type", time() + 31536000,"/"); 84 } 85 else 86 $order_type = $_COOKIE['cookie_type']; 87 88 if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) ) 89 { 90 $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; 91 } 92 else 93 { 94 $mode = 'allforums'; 95 } 96 97 //for span pages 98 $script_name_self = 'index.php?mode=' .$mode; 99 100 // fetch new posts since last visit 101 $new_posts = phpbb_fetch_new_posts(); 102 103 // fetch user online, total posts, etc 104 //$stats = phpbb_fetch_stats(); 105 106 // fetch statistics like most viewed, replied, active forums etc 107 // cached for all forums tab in portal_core hence checking for mode != allforums here - Isaac 108 109 $CFG['posts_trim_topic_number'] = 35; 110 $top_poster = phpbb_fetch_top_poster(); 111 $CFG['posts_trim_topic_number'] = 30; 112 $mostvisit_topics = phpbb_fetch_mostvisited_topics(); 113 $topreplied_topics = phpbb_mostreplied_topics(); 114 $CFG['posts_trim_topic_number'] = 50; 115 $active_forums = phpbb_active_forums(); 116 117 //fetch valuable posts 118 //$CFG['posts_trim_topic_number'] = 35; 119 //$valuable_posts = phpbb_mostvalued_posts(); 120 121 122 // fetch a random user 123 //$random_user = phpbb_fetch_random_user(); 124 125 // fetch latest postings 126 $CFG['posts_trim_topic_number'] = 33; 127 128 129 // fetch postings 130 $CFG['posts_trim_topic_number'] = 0; 131 $CFG['posts_span_pages'] = true; 132 133 134 $CFG['posts_limit'] = 50; 135 136 switch( $mode ) 137 { 138 case 'myforum': 139 if (!$userdata['session_logged_in']) 140 { 141 $redirect = ( isset($start) ) ? "&start=$start" : ''; 142 redirect(append_sid("login.$phpEx?redirect=index.$phpEx" . "?mode=myforum" . $redirect, true)); 143 } 144 else 145 { 146 $sql = "SELECT forum_id FROM " . FORUMS_WATCH_TABLE . " WHERE user_id =" . $userdata['user_id']; 147 if ( !($result = $db->sql_query($sql)) ) 148 { 149 message_die(GENERAL_ERROR, 'Could not obtain forum IDs for recent posts', '', __LINE__, __FILE__, $sql); 150 } 151 $forumids = array(); 152 while ( $row = $db->sql_fetchrow($result) ) 153 { 154 $forumids[] = $row['forum_id']; 155 } 156 $CFG['posts_limit'] = 30; 157 $recent = phpbb_fetch_posts($forumids, POSTS_FETCH_LAST); 158 } 159 break; 160 161 case 'allforums': 162 $CFG['posts_trim_topic_number'] = 22; 163 $forums = phpbb_fetch_forums(); 164 $CFG['posts_trim_topic_number'] = 50; 165 $CFG['trim_forum_name'] = 8; 166 $CFG['trim_username'] = 8; 167 $recent = phpbb_fetch_posts(null, POSTS_FETCH_LAST); 168 break; 169 } 170 171 echo "<html> 172 <head> 173 <title>Welcome : vtiger Forums</title> 174 <style type=\"text/css\">"; 175 176 include_once ('templates/advSilver/advSilver1.css'); 177 include ('includes/page_header.php'); 178 179 ?> 180 181 </style> 182 <script language="javascript"> 183 <!-- 184 function SetLastVisit() 185 { 186 if (!document.LastVisitFrm.search_time.options[0].selected) 187 { 188 document.LastVisitFrm.submit(); 189 } 190 return true; 191 } 192 --> 193 </script> 194 </head> 195 <body bgcolor="#E5E5E5" text="#000000" link="#006699" vlink="#5493B4"> 196 197 <table bgcolor="#FFFFFF" border="0" cellpadding="0" cellspacing="0" width="100%"> 198 <tr> 199 <td bgcolor="#FFFFFF"><img src="images/spacer.gif" width="20" height="5" border="0" /></td> 200 </tr> 201 202 <tr class="bodyline"> 203 <td colspan="3" cellpadding="0" cellspacing="0" border="0"> 204 <!-- USER --> 205 <?php if ($userdata) { ?> 206 <center> 207 <table width="100%" cellpadding="3" cellspacing="1" border="0"> 208 <?php if ($userdata['session_logged_in']) { ?> 209 <span class="gensmall"> 210 <tr> 211 <td align="right" class="gensmall"><b><a class="gensmall" href="<?php echo $phpbb_root_path; ?>privmsg.php?folder=inbox">You have 212 <?php if ($userdata['user_new_privmsg']) { echo $userdata['user_new_privmsg']; } else { echo 'no'; } ?> new message<?php echo $userdata['user_new_privmsg'] == 1 ? '' : 's' ?></a></b></td> 213 <td align="right" class="gensmall"><b><a class="gensmall" href="<?php echo $phpbb_root_path; ?>search.php?search_id=newposts">View posts since last visit 214 (<?php echo $new_posts['total']; ?>)</a></b></td> 215 <td align="right" class="gensmall"><b><a class="gensmall" href="<?php echo $phpbb_root_path; ?>search.php?search_id=egosearch">View your posts and drafts</a></b></td> 216 <td align="right" class="gensmall"><b><a class="gensmall" href="<?php echo $phpbb_root_path; ?>search.php?search_id=unanswered">View unanswered posts</a></b></td> 217 </span> 218 </tr> 219 </table> 220 </center> 221 <?php } } ?> 222 <!-- USER --> 223 </td> 224 </tr> 225 226 <tr> 227 228 <?php 229 if ($mode == "myforum") 230 { 231 echo "<td valign=\"top\" width=\"100%\">"; 232 } 233 else 234 { 235 echo "<td valign=\"top\" width=\"50%\">"; 236 } 237 ?> 238 239 <!-- MY POSTS --> 240 241 <!-- ALL FORUMS --> 242 243 <?php if ($mode != "myforum") 244 { ?> 245 <table border="0" width="100%" cellpadding="0" cellspacing="0"> 246 <tr> 247 <td> 248 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 249 <tr> 250 <td bgcolor="#BDCEBA" height="20" align="center" width="6%"><a href="javascript:ShowHide('cat_snap','cat2_snap','catrow_snap')" ><img id="img_cat_snap" src="images/down.gif" border=\"0\"></a></td><td bgcolor="#BDCEBA" valign="middle"><a href="javascript:ShowHide('cat_snap','cat2_snap','catrow_snap')" class="gensmall"><font color="#000000">Weekly Snapshot</font></a></font></span></td> 251 </tr> 252 </table> 253 </td> 254 </tr> 255 <tr><td><div id="cat_snap" style="display: '';"> 256 257 <table width="100%" border="0"> 258 <tr> 259 <td width="50%" valign="top"> 260 <!-- MOST VIEWED TOPICS --> 261 <?php if (isset($mostvisit_topics)) { ?> 262 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 263 <tr> 264 <td width="6"><img src="images/tb-top-left.gif" width="6" height="25"></td> 265 <td class="tblinetop" height="20"> <?php echo $lang['Top_Viewed_Topics']; ?></a></span></td> 266 <td width="6"><img src="images/tb-top-right.gif" width="6" height="25"></td> 267 </tr> 268 269 <tr> 270 <td class="tblineleft"><img src="images/spacer.gif" width="1" height="1"></td> 271 <td> 272 <div id="cat_mostviewed" style="display: ''; position: relative;"> 273 <table width="100%"> 274 <?php $bgcolor="#FFFFFF"; for ($i = 0; $i < count($mostvisit_topics); $i++) { $bgcolor = ( $bgcolor == "#FFFFFF") ? "#FFFFFF" : "#FFFFFF"; ?> 275 <tr> 276 <td bgcolor="<?php echo $bgcolor; ?>"><span class="gensmall"><a class="gensmall" href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t='.$mostvisit_topics[$i]['topic_id']); ?>"><?php echo $mostvisit_topics[$i]['topic_title']; ?></a><?php if ($mostvisit_topics[$i]['topic_trimmed']) { echo '...'; } ?><br />by <a class="gensmall" href="<?php echo append_sid($phpbb_root_path . 'profile.php?mode=viewprofile&u=' . $mostvisit_topics[$i]['topic_poster']); ?>"><?php echo $mostvisit_topics[$i]['username']; ?></a> - <?php echo $mostvisit_topics[$i]['topic_views']; ?></span></td> 277 278 </tr> 279 <?php } ?> 280 <tr> 281 <td align="right" colspan=3><span class="gensmall"><a class="gensmall" href="<?php echo append_sid($phpbb_root_path . 'alltopics.php?sorder=topic_views&type=ASC'); ?>"><?php echo 'More...'; ?></span></td> 282 </tr> 283 </table> 284 </div> 285 </td> 286 <td class="tblineright"><img src="images/spacer.gif" width="1" height="1"></td> 287 </tr> 288 <tr> 289 <td width="6" height="6"><img src="images/tb-bottom-left.gif" width="6" height="6"></td> 290 <td class="tblinebottom"><img src="images/spacer.gif" width="1" height="1"></td> 291 <td width="6"><img src="images/tb-bottom-right.gif" width="6" height="6"></td> 292 </tr> 293 294 </table> 295 <?php } ?> 296 <!-- MOST VIEWED TOPICS --> 297 </td> 298 299 300 <td width="50%" valign="top"> 301 <!-- MOST REPLIED TOPICS --> 302 <?php if (isset($topreplied_topics)) { ?> 303 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 304 <tr> 305 <td width="6"><img src="images/tb-top-left.gif" width="6" height="25"></td> 306 <td class="tblinetop" height="20"> <?php echo $lang['Top_Replied_Topics']; ?></a></span></td> 307 <td width="6"><img src="images/tb-top-right.gif" width="6" height="25"></td> 308 </tr> 309 310 <tr> 311 <td class="tblineleft"><img src="images/spacer.gif" width="1" height="1"></td> 312 <td> 313 <div id="cat_mostreplied" style="display: ''; position: relative;"> 314 <table width="100%"> 315 <?php $bgcolor="#FFFFFF"; for ($i = 0; $i < count($topreplied_topics); $i++) { $bgcolor = ( $bgcolor == "#FFFFFF") ? "#FFFFFF" : "#FFFFFF"; ?> 316 <tr> 317 <td bgcolor="<?php echo $bgcolor; ?>"><span class="gensmall"><a class="gensmall" href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t='.$topreplied_topics[$i]['topic_id']); ?>"><?php echo $topreplied_topics[$i]['topic_title']; ?></a><?php if ($topreplied_topics[$i]['topic_trimmed']) { echo '..'; } ?><br /> by <a class="gensmall" href="<?php echo append_sid($phpbb_root_path . 'profile.php?mode=viewprofile&u=' . $topreplied_topics[$i]['topic_poster']); ?>"><?php echo $topreplied_topics[$i]['username']; ?></a> - <?php echo $topreplied_topics[$i]['topic_replies']; ?></span></td> 318 </tr> 319 <?php } ?> 320 <tr> 321 <td colspan=3 align="right"><span class="gensmall"><a class="gensmall" href="<?php echo append_sid($phpbb_root_path . 'alltopics.php?sorder=topic_replies&type=ASC'); ?>"><?php echo 'More...'; ?></span></td> 322 </tr> 323 </table> 324 </div> 325 </td> 326 <td class="tblineright"><img src="images/spacer.gif" width="1" height="1"></td> 327 </tr> 328 <tr> 329 <td width="6" height="6"><img src="images/tb-bottom-left.gif" width="6" height="6"></td> 330 <td class="tblinebottom"><img src="images/spacer.gif" width="1" height="1"></td> 331 <td width="6"><img src="images/tb-bottom-right.gif" width="6" height="6"></td> 332 </tr> 333 334 </table> 335 <?php } ?> 336 <!-- MOST REPLIED TOPICS --> 337 </td> 338 </tr> 339 </table></div></td></tr> 340 341 <tr><td> </td></tr> 342 <tr> 343 <td> 344 <table width="100%" cellpadding="0" cellspacing="0" border="0" class="tableline1"> 345 <tr> 346 <td colspan="2" bgcolor="#BDCEBA" height="20"><span class="genmed"><font color="#000000"> ::: Forums</font></span></td> 347 </tr> 348 </table> 349 </td> 350 </tr> 351 352 353 <!-- FORUMS --> 354 355 <?php 356 357 if ($forums) 358 { 359 $bgcolor ="#FFFFFF" ?> 360 <!-- table width="100%" cellpadding="3" cellspacing="1" border="0" class="tableline" --> 361 <?php 362 $last_cat = -1; 363 for ($i = 0; $i < count($forums); $i++) 364 { 365 $bgcolor = "#FFFFFF"; 366 367 if ($last_cat != $forums[$i]['cat_id']) 368 { 369 if ($i != "0" ) 370 { 371 ?> 372 </table></div> 373 <script language="javascript" type="text/javascript"> 374 <!-- 375 tmp = 'catrow_<?php echo $last_cat; ?>'; 376 if(GetCookie(tmp) == '2') 377 { 378 ShowHide('cat_<?php echo $last_cat; ?>','cat2_<?php echo $last_cat; ?>','catrow_<?php echo $last_cat; ?>'); 379 } 380 381 if(GetCookie(tmp) == '' || GetCookie(tmp) == null) 382 { 383 ShowHide('cat_<?php echo $last_cat; ?>','cat2_<?php echo $last_cat; ?>','catrow_<?php echo $last_cat; ?>'); 384 } 385 386 --> 387 </script> 388 389 <?php } 390 $last_cat = $forums[$i]['cat_id']; 391 ?> 392 <table width="100%" cellpadding="2" cellspacing="0" border="0" class="tableline1"> 393 <tr> 394 <td bgcolor="#E7E8C8" align="middle" width="6%" height="20"><a href="javascript:ShowHideCat('cat_<?php echo $forums[$i]['cat_id']; ?>','cat2_<?php echo $forums[$i]['cat_id']; ?>','catrow_<?php echo $forums[$i]['cat_id']; ?>');" class="cattitle"><img id="img_cat_<?php echo $forums[$i]['cat_id']; ?>" src="images/side-arrow.gif" border=\"0\"></a><td bgcolor="#E7E8C8"><a href="javascript:ShowHideCat('cat_<?php echo $forums[$i]['cat_id']; ?>','cat2_<?php echo $forums[$i]['cat_id']; ?>','catrow_<?php echo $forums[$i]['cat_id']; ?>');" class="cattitle"><?php echo $forums[$i]['cat_title']; ?></a></span></td> 395 </tr> 396 </table> 397 <div id="cat_<?php echo $forums[$i]['cat_id']; ?>" style="display: ''; position: relative;"> 398 <table width="100%" cellpadding="0" cellspacing="0" border="0" class="tableline"> 399 <?php } ?> 400 <tr> 401 <td nowrap bgcolor="<?php echo($bgcolor) ?>" align="center" width="6%" height="25"> 402 <a href="javascript:ShowHide('forum_<?php echo $forums[$i]['forum_id']; ?>','forum2_<?php echo $forums[$i]['forum_id']; ?>','forumrow_<?php echo $forums[$i]['forum_id']; ?>');"><img id="img_forum_<?php echo $forums[$i]['forum_id']; ?>" src="images/side-arrow.gif" border=\"0\"></a></td> 403 <td bgcolor="<?php echo($bgcolor) ?>" valign="middle"> 404 <a class="genmed" href="<?php echo append_sid($phpbb_root_path . 'viewforum.php?f=' . $forums[$i]['forum_id']); ?>" ><?php echo $forums[$i]['forum_name']; ?><?php if ($forums[$i]['topic_trimmed']) { echo '...'; } ?></a> 405 <span class="gensmaller"><?php if ( $forums[$i]['forum_topics'] > 0 ) { echo '(' . $forums[$i]['forum_topics'] . ')'; } ?></span> 406 <a class="gensmaller" href="<?php echo append_sid($phpbb_root_path . 'posting.php?f=' . $forums[$i]['forum_id'] . '&mode=newtopic'); ?>">New Post</a></span> 407 408 <?php 409 $desc=$forums[$i]['forum_desc']; 410 $desc=strstr($desc, "<a"); ?> 411 <span class="gensmaller"><?php echo $desc; ?></span></td> 412 </tr> 413 </td> 414 </tr> 415 <tr> 416 <td colspan="3"> 417 <div id="forum_<?php echo $forums[$i]['forum_id']; ?>" style="display: none;"> 418 <table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td bgcolor="#EAEFE4"><img src="images/spacer.gif" width="19" height="1"></td><td bgcolor="#EAEFE4"> 419 <?php 420 $sql = "SELECT topic_title, topic_id, topic_replies, topic_views FROM " . TOPICS_TABLE . " 421 WHERE forum_id =" . $forums[$i]['forum_id'] . " ORDER BY topic_time DESC LIMIT 0,5"; 422 if ( !($result = $db->sql_query($sql)) ) 423 { 424 message_die(GENERAL_ERROR, 'Could not obtain recent topics', '', __LINE__, __FILE__, $sql); 425 } 426 427 while ( $row = $db->sql_fetchrow($result) ) 428 { 429 echo '<a class="spac" href=' . $phpbb_root_path . 'viewtopic.php?t=' .$row['topic_id'] . '>' .$row['topic_title'].'</a><span class="gensmaller"> <font color="#853b3b">' . $row['topic_replies'] . ' replies</font></span><br>'; 430 } ?> 431 </td></tr></table></div> 432 433 </td> 434 </tr> 435 436 437 <?php 438 if ($i == (count($forums) - 1)) 439 { ?> 440 </table></div> 441 <script language="javascript" type="text/javascript"> 442 <!-- 443 tmp = 'catrow_<?php echo $last_cat; ?>'; 444 if(GetCookie(tmp) == '2') 445 { 446 ShowHide('cat_<?php echo $last_cat; ?>','cat2_<?php echo $last_cat; ?>','catrow_<?php echo $last_cat; ?>'); 447 } 448 449 if(GetCookie(tmp) == '' || GetCookie(tmp) == null) 450 { 451 ShowHide('cat_<?php echo $last_cat; ?>','cat2_<?php echo $last_cat; ?>','catrow_<?php echo $last_cat; ?>'); 452 } 453 //--> 454 </script> 455 <?php } 456 457 } ?> 458 459 <p/> 460 <?php } ?> 461 <!-- FORUMS --> 462 463 <table border="0" width="100%"> 464 465 <tr> 466 <td> 467 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 468 <tr> 469 <td colspan="2" bgcolor="#BDCEBA" height="20"><span class="genmed"><font color="#000000"> ::: Forums Tid bits</font></span></td> 470 </tr> 471 </table> 472 </td> 473 </tr> 474 475 <tr> 476 <td width="100%"> 477 <!-- ACTIVE FORUMS --> 478 <?php if (isset($active_forums)) { ?> 479 <table width="100%" cellpadding="0" cellspacing="0" border="0" class="tableline"> 480 <tr> 481 <td> 482 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 483 <tr> 484 <td bgcolor="#E7E8C8" height="20" align="center" width="6%"><span class="cattitle"><a href="javascript:ShowHide('cat_activeforums','cat2_activeforums','catrow_activeforums')" class="cattitle"><img id="img_cat_activeforums" src="images/down.gif" border=\"0\"></td><td bgcolor="#E7E8C8" valign="middle"><a href="javascript:ShowHide('cat_activeforums','cat2_activeforums','catrow_activeforums')" class="cattitle"><?php echo $lang['Active_Forums']; ?></span></a></td> 485 </tr> 486 </table> 487 </td> 488 </tr> 489 <tr> 490 <td class="row1" align="left" width="100%"> 491 <div id="cat_activeforums" style="display: ''; position: relative;"> 492 <table width="100%" cellpadding="3" cellspacing="0" border="0"> 493 <tr><td align="center" bgcolor="#eff2f9" class="gensmall">Forum</td><td align="center" bgcolor="#eff2f9" class="gensmall">Posts</td><td bgcolor="#eff2f9" align="center" class="gensmall">Topics</td></tr> 494 <?php $bgcolor="#FFFFFF"; for ($i = 0; $i < count($active_forums); $i++) { $bgcolor = ( $bgcolor == "#FFFFFF") ? "#FFFFFF" : "#FFFFFF"; ?> 495 <tr> 496 <td bgcolor="<?php echo $bgcolor; ?>"><span class="gensmall"><a class="gensmall" href="<?php echo append_sid($phpbb_root_path . 'viewforum.php?f='.$active_forums[$i]['forum_id']); ?>"><?php echo $active_forums[$i]['forum_name']; ?></a><?php if ($active_forums[$i]['topic_trimmed']) { echo '..'; } ?></span></td><td align="center" bgcolor="<?php echo $bgcolor; ?>"><span class="gensmall"><?php echo $active_forums[$i]['forum_posts']; ?></span></td><td align="center" bgcolor="<?php echo $bgcolor; ?>"><span class="gensmall"><?php echo $active_forums[$i]['forum_topics']; ?></span></td> 497 </tr> 498 <?php } ?> 499 </table> 500 </div> 501 </td> 502 </tr> 503 </table> 504 505 <?php } ?> 506 <!-- ACTIVE FORUMS --> 507 </td> 508 </tr> 509 510 <tr> 511 <td width="100%"> 512 <!-- TOP POSTER --> 513 <?php 514 // 515 // Top Posting Users This Week (History Mod adaption) 516 // 517 include_once($phpbb_root_path . 'includes/functions_stats.' . $phpEx); 518 include_once($phpbb_root_path . 'includes/functions_module.' . $phpEx); 519 520 $statistics->init_bars(); 521 522 $month = array(); 523 $current_time = time(); 524 $year = create_date('Y', $current_time, $board_config['board_timezone']); 525 $month [0] = mktime (0,0,0,1,1, $year); 526 $month [1] = $month [0] + 2678400; 527 $month [2] = mktime (0,0,0,3,1, $year); 528 $month [3] = $month [2] + 2678400; 529 $month [4] = $month [3] + 2592000; 530 $month [5] = $month [4] + 2678400; 531 $month [6] = $month [5] + 2592000; 532 $month [7] = $month [6] + 2678400; 533 $month [8] = $month [7] + 2678400; 534 $month [9] = $month [8] + 2592000; 535 $month [10] = $month [9] + 2678400; 536 $month [11] = $month [10] + 2592000; 537 $month [12] = $month [11] + 2592000; 538 $arr_num = (date('n')-1); 539 $time_thismonth = $month[$arr_num - 1]; 540 541 $l_this_month = create_date('F', $time_thismonth, $board_config['board_timezone']); 542 543 $template->set_filenames(array( 544 'body' => 'top_poster.tpl') 545 ); 546 547 $template->assign_vars(array( 548 'L_MODULE_NAME' => $lang['module_name'], 549 'MONTH' => sprintf($lang['Month'], ($l_this_month . ' ' . create_date('Y', $time_thismonth, $board_config['board_timezone'])) ), 550 'L_RANK' => $lang['Rank'], 551 'L_PERCENTAGE' => $lang['Percent'], 552 'L_GRAPH' => $lang['Graph'], 553 'L_USERNAME' => $lang['Username'], 554 'L_POSTS' => $lang['Posts']) 555 ); 556 557 $sql = "select u.user_id, u.username, count(u.user_id) as user_posts 558 FROM " . USERS_TABLE . " u, " . POSTS_TABLE . " p 559 WHERE (u.user_id = p.poster_id) AND (p.post_time > '" . $time_thismonth . "') AND (u.user_id <> " . ANONYMOUS . ") 560 GROUP BY user_id, username 561 ORDER BY user_posts DESC"; 562 563 if ($CFG['users_limit']) 564 { 565 $sql .= ' 566 LIMIT 567 0,' . $CFG['users_limit']; 568 } 569 570 if ( !($result = $db->sql_query($sql)) ) 571 { 572 message_die(GENERAL_ERROR, "Couldn't retrieve topposters data", "", __LINE__, __FILE__, $sql); 573 } 574 575 $total_posts_thismonth = 0; 576 $user_count = $db->sql_numrows($result); 577 $user_data = $db->sql_fetchrowset($result); 578 $firstcount = $user_data[0]['user_posts']; 579 $bgcolor = "#FFFFFF"; 580 581 for ($i = 0; $i < $user_count; $i++) 582 { 583 $total_posts_thismonth += $user_data[$i]['user_posts']; 584 } 585 586 for ($i = 0; $i < $user_count; $i++) 587 { 588 $class = ($i % 2) ? $theme['td_class2'] : $theme['td_class1']; 589 $bgcolor = ($bgcolor == "#FFFFFF") ? "#FFFFFF" : "#FFFFFF"; 590 $statistics->do_math($firstcount, $user_data[$i]['user_posts'], $total_posts_thismonth); 591 592 $template->assign_block_vars('top_posters', array( 593 'RANK' =>