This is a simple script originally written for Beta Archive and posted here in the hope that someone else might find it useful, heres the source code, note it was written and tested in PHP5 and may not run in PHP4, but i dont know :)
<?php ##################################################################### # Project Name : GetNewTopics # # Description : Displays new topics in phpBB3 # # Author : Lawrence Cook # # Date : 19th March 2010 # # Email : theonesupercookie@gmail.com # # License : GPL 2.0 # ##################################################################### //Remember, make sure nothing is outputted above this line //Config shit $limit = 25; $dbpasswd = ''; $site = "CHANGEME"; //No trailing slash //Feel free to change these //Syntax: $switch['var'] = true|false; $switch['reply_count_grey'] = true; $switch['reply_poster_grey'] = true; $switch['truncate_topic_username'] = true; $switch['truncate_reply_username'] = true; $switch['truncate_topic_subject'] = true; $switch['show_all_topics'] = false; //When set to false, users will only see topics they have read access to. $switch['indicate_locked_topics'] = true; //When set to true, will show an image of your choice next to a locked topic //These are values, you can set these to whatever you like //Syntax: $value['var'] = value; $value['truncate_topic_username'] = 20; $value['truncate_reply_username'] = 12; $value['truncate_topic_subject'] = 40; $value['truncate_suffix'] = "…"; //Note that this isnt three dots, its the unicode Ellipsis symbol(…) $value['ignore_ids'] = ""; //forum ids to hide $value['indicate_locked_topics_img'] = "./padlock3.png"; $value['white_space'] = "./padding.gif"; //But think twice about changing this //Default: false $switch['dev_mode'] = false; //*********************************************** // DO NOT MOVE THIS CODE, OR IT WILL MAKE ERRORS //*********************************************** define('IN_PHPBB', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); include($phpbb_root_path . 'includes/functions_display.' . $phpEx); @include("config.php"); $prefix = $table_prefix; $user->session_begin(); $auth->acl($user->data); $user->setup(); //*********************************************** //You can edit the html below this line for styles and stuff ?> <!-- Written by kichimi/Lawrence Cook for BetaArchive.co.uk --> <style type="text/css"> body{ margin: 0px; padding: 0px; font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; font-size: 11px; } .latesttopic{ font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; font-size: 11px; } .latestposter{ font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; font-size: 11px; } .latestreplies{ font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; font-size: 11px; text-align: center; } a:link{ color: #324B64; text-decoration: none; } a:visited{ color: #6C4D80; text-decoration: none; } a:active{ color: #324B64; text-decoration: none; } a:hover{ color: #324B64; text-decoration: underline; } </style> <?php //DONT CHANGE ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING! //Custom Functions if($switch['dev_mode']==true){ //Don't change this, its to save me time every time i go to edit the script $site = "http://127.0.0.1:81/phpBB3/"; echo "<pre>Developer Mode</pre>\n"; chdir("./"); } if ($user->data['user_id'] == ANONYMOUS) { echo "<!-- Not logged in -->\n"; } else { echo '<!-- Logged in as ' . $user->data['username_clean']. "-->\n"; } //die(); //SQL Connection Shitter mysql_connect("localhost", $dbuser, $dbpasswd) or die("ERROR"); mysql_select_db($dbname) or die("ERROR"); function left($string, $count){ return substr($string, 0, $count); } function len($string){ return strlen($string); } function right($value, $count){ return substr($value, ($count*-1)); } function id2username($id){ global $prefix; $sql = "SELECT * FROM `".$prefix."users` WHERE user_id=$id"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ if($row['user_id']==$id){ $buffer = $row['username']; }else{ $buffer = "Unknown"; } } return $buffer; } /* function gid2colour($gid){ global $prefix; $sql = "SELECT * FROM `".$prefix."groups` WHERE group_id=$gid"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ if($row['group_id']==$gid){ $buffer = $row['group_colour']; }else{ $buffer = -1; } } return $buffer; } function uid2gid($id){ global $prefix; $sql = "SELECT * FROM `".$prefix."users` WHERE user_id=$id"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ if($row['user_id']==$id){ $buffer = $row['group_id']; }else{ $buffer = -1; } } return $buffer; } */ //The shiz nizz echo "<center>Quick Actions: <a href='http://www.betaarchive.co.uk/forum/search.php?search_id=newposts' target='_parent'>View New Posts</a> | <a href='http://www.betaarchive.co.uk/forum/search.php?search_id=unanswered' target='_parent'>View Unanswered Posts</a> | <a href='http://www.betaarchive.co.uk/forum/search.php?search_id=active_topics' target='_parent'>View Active Topics</a><br /></center> <TABLE align=center class=latestposts width=510> <TR class=latestposts> <TD class=latesttopic><center><font size='1' color='#c0c0c0'><b>Subject</b></TD> <TD class=latestreplies width=75><center><font size='1' color='#c0c0c0'><b>Replies</b></center></TD> <TD class=latestposter><center><font size='1' color='#c0c0c0'><b>Last Reply</b></TD></TR>\n"; //Grab a list of all forum ID's if($switch['show_all_topics'] == false){ $sql = "SELECT * FROM `".$prefix."forums`"; $result = mysql_query($sql); //$result = mysql_fetch_array( $result ); //$result = array_reverse($result); while($row = mysql_fetch_array($result)){ if (!$auth->acl_get('f_read', $row['forum_id'])){ if($value['ignore_ids']){ $value['ignore_ids'] = $value['ignore_ids'].",".$row['forum_id']; }else{ $value['ignore_ids'] = $row['forum_id']; } } } } if($value['ignore_ids']){ $arrignore = split(",",$value['ignore_ids']); $condition = "WHERE"; //printf($arrignore); foreach($arrignore as $key => $number){ $condition = $condition." forum_id != ".$number." AND"; } $condition = left($condition,len($condition)-4); //Lazyness so i can get rid of the "AND " from the end of $condition } //echo $condition; $sql = "SELECT * FROM `".$prefix."topics` $condition ORDER BY topic_id DESC LIMIT 0, $limit"; $result = mysql_query($sql); //$result = mysql_fetch_array( $result ); if($switch['dev_mode']==true){ echo "<!--\n"; print_r($switch); print_r($value); echo "-->\n"; } //$result = array_reverse($result); while($row = mysql_fetch_array($result)){ $subject = $row['topic_title']; $topicid = $row['topic_id']; $posterid = $row['topic_poster']; $poster = id2username($posterid); $status = $row['topic_status']; $postercolour = $row['topic_first_poster_colour']; $topicdate = $row['topic_time']; //eg. 1231892798 $topicdate2 = date('l jS F Y h:i:s A', $topicdate); //eg. Wednesday 14th January 2009 10:05:13 $topicdate3 = date("j M @ h:i", $topicdate); //eg. 14 Jan @ 10:05 $replies = $row['topic_replies']; $lastposter = $row['topic_last_poster_name']; $lastposterid = $row['topic_last_poster_id']; $lastpostdate = $row['topic_last_post_time']; //eg. 1231892798 $lastpostdate2 = date('l jS F Y h:i:s A', $lastpostdate); //eg. Wednesday 14th January 2009 10:05:13 $lastpostdate3 = date("j M @ h:i", $lastpostdate); //eg. 14 Jan @ 10:05 $lastpostercolour = $row['topic_last_poster_colour']; $lastposter = "<a href=".$site."/memberlist.php?mode=viewprofile&u=$lastposterid target=_blank><font color=#$lastpostercolour>$lastposter</font></a>"; if($replies=='0'){ global $switch; if($switch['reply_count_grey']==true){ $replies = "<font color=C0C0C0>$replies</font>"; } if($switch['reply_poster_grey'] ==true){ $lastposter = "<i>No Replies</i>"; $lastpostercolour = "C0C0C0"; } if($lastpostdate==$topicdate){ $lastpostdate2 = ""; $lastpostdate3 = ""; } } if($switch['truncate_topic_username']==true){ $length = $value['truncate_topic_username']; if(len($poster)>$length){ $poster = left($poster, $length).$value['truncate_suffix']; } } if($switch['truncate_reply_username']==true){ $length = $value['truncate_reply_username']; if(len($lastposter)>$length){ if(!left($lastposter,3)=="<i>"){ $lastposter = left($lastposter, $length).$value['truncate_suffix']; } } } if($switch['truncate_topic_subject']==true){ $length = $value['truncate_topic_subject']; if(len($subject)>$length){ $subject = left($subject, $length).$value['truncate_suffix']; } } if($postercolour==""){ $postercolour="000000"; } if($switch['indicate_locked_topics']==true){ if($status==1){ $spacer = "<img src='".$value['indicate_locked_topics_img']."' />"; }else{ $spacer = "<img src='".$value['white_space']."' />"; } } if($i<$limit){ echo " <tr> <td class='latesttopic'> <a href=$site/viewtopic.php?t=$topicid target=_parent><b>$subject</b></a><br> <font size=1 color=#c0c0c0>$spacer by <a href=".$site."/memberlist.php?mode=viewprofile&u=$posterid target=_blank><font color=$postercolour>$poster</font></a> on $topicdate3</font> </td> <td class='latestreplies'> <center>$replies</center> </td> <td class='latestposter'> <font color='#$lastpostercolour' size=1>$lastposter</font><br> <font size=1 color=#c0c0c0>$lastpostdate3</font> </td> </tr> <tr> <td style='border-bottom: 1px solid #c0c0c0;' colspan='3' height='1'> <span style='font-size: 1px;'> </font> </td> </tr> \n"; } $i++; } ?> </TABLE>
This software is licensed under the GNU General Public License