Advertisement
Guest User

Working News Export!

a guest
Apr 15th, 2012
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     // Path to forum and necessary initial vars
  2.     define('IN_PHPBB', true);
  3.     define('NO_KILL_ON_DB_ERROR',true);
  4.     $phpEx = "php";
  5.     $starttime = 0;
  6.     $phpbb_root_path = "forum/";
  7.    
  8.     // Include common functions.
  9.     include_once($phpbb_root_path . 'common.' . $phpEx);
  10.     // Start session management.
  11.     $user->session_begin();
  12.     $user->setup('viewforum');
  13.    
  14.     // Require config for DB credentials.
  15.     require("$phpbb_root_path" . "config.php");
  16.     // Connect to database.
  17.     $dbc = @mysql_connect($dbhost,$dbuser,$dbpasswd);
  18.    
  19.     // Error if connection could not be made.
  20.     if (!$dbc) { echo "             <p>Our forums are currently down. No recent news is available.</p>"; }
  21.     else {
  22.         // Grab 10 latest posts
  23.         $db_selected = @mysql_select_db($dbname);
  24.         $sql = 'SELECT topic_id,topic_title,topic_time,topic_first_poster_name,topic_replies,topic_first_post_id FROM `' . $table_prefix . 'topics` where `forum_id` = 2 ORDER BY `topic_id` DESC LIMIT 10';
  25.         $result = @mysql_query("$sql");
  26.    
  27.         // Format posts in $allnews array
  28.         while ($row = @mysql_fetch_array($result)) {
  29.             $time = date("M j/y",$row[2]);
  30.             $post_info = mysql_fetch_array(mysql_query("SELECT * FROM `{$table_prefix}posts` where `post_id` = {$row[5]}"));
  31.             // The "7" flags on emoticons, BBCode, and magicURLs
  32.             $post = generate_text_for_display($post_info['post_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], 7);
  33.             $comments = "<a href=\"http://rly.cc/forum/viewtopic.php?t={$row[0]}\">({$row[4]})</a> ";
  34.             $allnews[$row[2]] = "
  35.                 <p>{$comments}<b>{$time} by {$row[3]}:</b> {$post} {$commentline}";
  36.         }
  37.    
  38.         // Close that DB!
  39.         @mysql_close($dbc);
  40.        
  41.         // Output our news!
  42.         foreach ($allnews as $i => $data) echo $data;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement