Jump to content

Will This Export Script Work With 4.0?


WestTac1

Recommended Posts

I hope I'm posting this in the right forum. If not, please move it to the correct forum.

This script is crucial to my forum. It exports recent topics to my HTML portal site http://www.emtbravo.com . Would it still work with 4.0? If it doesn't, is there any way to update it? Does anyone know how to contact the original authors?

Seth

Quote

 


<?
// **************************************** //
// Original mod submitted by Miles Johnson. //
// Completely rewritten by Anthony Petito.. //
// V2.6:  15 January 2007.................. //
// V2.51: 13 June 2006..................... //
// V2.5:  03 June 2006..................... //
// V2.1:  10 April 2005.................... //
// V2.0:  04 April 2005.................... //
// **************************************** //

// This mod will pull the latest X posts from your forum and display them on your website. 
// This new version will also handle forums that you do not wish to show (excluded forums)

// Put this file where your FORUMS are located (e.g, http://domain.tld/forum).
// This should be in the same path as your conf_global.php file
// I've commented most of the code so that it's fairly understandable, however,
// if you're unsure of what's going on here, stick to the comments on where to edit this file for your site.

// For this to work properly, copy the following code into your website.  Change it to match the link to THIS filename and path.
/* <?php include("http://domain.tld/forum/latest_posts.php");?> */

/////////////////////////////
// User Editable variables //
/////////////////////////////

// Change this to the number of posts you would like to show.
$posts = 10;

// If you would like this mod to cut topics after a certain character length, leave this at 1.  Otherwise, change it to 0.
$showtopiclength = 1;

// Length of title to display before cutting off.  If topic title length exceeds this value, it is followed by ellipses (...)
// Only useful if the above varaible is set to 1.
$topiclength = 75;

// Add forumid's to exclude from.  For example, you might want to exclude your private forums so that posts from it
// do not show up.  Seperate each forumid by a comma and ensure there's no spaces in between. 
$forumexclude = "205,202,79,207,211,212,157,158,159,160,161,162,163,164,165,166,167,168,169,157,158,155,152,153,154,155,148,149,150,151,140,141,142,143,144,145,73,134,135,136,137,138,139,140,141,142,143,144,133,121,122,123,124,125,126,127,128,129,130,131,132,105,106,107,108,109,110,112,113,114,115,116,118,119,120,100,101,102,103,104,99,1,2,3,4,5,6,7,8,9,10,11,12,13,64,14,15,16,18,19,20,21,22,23,24,25,26,27,28,29,31,32,33,34,35,36,37,38,39,40,42,41,43,44,45,55,62,59,60,67,68,69,70,71,75, 77,79,81,30,60,82,83,93,94,95,96,97,98,80,173,183,220,221,222,223,94,224,225,226,227,228,229,124,230,231,228,232,233";

/*
TIME INTERVAL DISPLAY
,232
0 = only days
1 = only hours
2 = only minutes
3 = only seconds  *** NOT WORKING ***
4 = hours and minutes
5 = hours and seconds
6 = minutes and seconds
7 = hours, minutes, seconds

Please select which interval to use (besides option 3, which is not working correctly):
*/

$interval = 6;

/*
This will display the time interval between posts
Example: posted 3 minutes ago
Example: posted 2 hours and 3 minutes ago
Example: 1 day, 5 hours ago
*/
 
//OR display date only
// The following 2 lines can be changed to however you want the date and time to be displayed. 
// Default date: dd month year
// Default time: hh:mm ampm TIMEZONE (12 hour time)
// For more information on how the next 2 lines can be changed, please reference the README file.
// If you elect to show the date and time it was posted instead of the way shown above ONLY, change the $showtime variable to 1.
$showtime = 0;
$datedisplay = 'd F Y';
$timedisplay = 'h:i A T';

//////////////
// Required //
//////////////

require "conf_global.php";

//////////////
// Database //
//////////////

$mysql = mysql_connect( $INFO['sql_host'], $INFO['sql_user'], $INFO['sql_pass'] /*, $INFO['sql_driver'] */ );
if ( !$mysql ) {
    die( "<b>mysql_connect()</b>: ". mysql_error() );
}

$select_db = mysql_select_db( $INFO['sql_database'], $mysql );
if ( !$select_db ) {
    die( "<b>mysql_select_db()</b>: ". mysql_error() );
}


// Query the DB with the supplied user inputted variables.
if ($forumexclude <> "") {
    $getposts = mysql_query("SELECT posts, last_poster_name, last_poster_id, title, tid, forum_id, last_post FROM ibf_topics WHERE (forum_id NOT IN ($forumexclude)) ORDER BY last_post DESC LIMIT $posts") OR DIE (mysql_error());
    }
else {
    $getposts = mysql_query("SELECT posts, last_poster_name, last_poster_id, title, tid, forum_id, last_post FROM ibf_topics ORDER BY last_post DESC LIMIT $posts") OR DIE (mysql_error());
}

// Format and display the results.
while ( $post = mysql_fetch_array($getposts)) {

 $post[full_title] = $post[title];
 if ($showtopiclength == 1 AND strlen($post[full_title]) > $topiclength) {
  $post[short_title] = substr($post[full_title],0,$topiclength);
  $post[short_title] = $post[short_title]."...";
 }
 else {
  $post[short_title] = $post[full_title]; 
 }
 
 $posted_on = date($datedisplay, $post[last_post]); // Need to change mySQL timestamp to something more human readable.
 $today_date = date($datedisplay, time()); // Grab today's date so we can compare it against the posted date
 
 if ($showtime == 0) {
  $showtimediff =  timediff($interval,time(),$post[last_post]);
  $datefield = $showtimediff;
 }
 else {
 
  // If it was posted today, we want to display "Today, hh:mm AMPM"
  If ($posted_on == $today_date) {
   $datefield = "Today";
   $datefield = $datefield . ", " . date($timedisplay, $post[last_post]);
  }
  
  // If it was posted yesterday, we want to display "Yesterday, hh:mm AMPM"
  elseif (date('d F Y',strtotime("-1 day")) == $posted_on) {
   $datefield = "Yesterday";
   $datefield = $datefield . ", " . date($timedisplay, $post[last_post]);
  }
  
  else {
   $datefield = $posted_on;
  }
 }

 echo
 /////////////////
 // Post Format //
 /////////////////
 // Between the EOD markers you can put whatever you want in HTML format.  Just ensure that the link stays somewhat the same.
<<<EOD

<table width="100%" border="5" bordercolor="#a5070a" cellspacing="7" cellpadding="7" bgcolor="c0c0c0">
  <tr>
    <td><center>
<a href="$INFO[board_url]/index.php?showtopic=$post[tid]&view=getnewpost">$post[short_title]</a>  <br>
<i><b><font color="#222e3e"> </td>
  </tr>
</table>

 


EOD;
}

function timediff($interval, $starttime, $endtime) {

 $timediff = $starttime - $endtime;
 $days=intval($timediff/86400);
 $remain=$timediff%86400;
 $hours=intval($remain/3600);
 $remain=$remain%3600;
 $mins=intval($remain/60);
 $secs=$remain%60;
 
 $pluraldays  = ($days < 2) ? " day " : " days ";
 $pluralhours  = ($hours < 2) ? " hour " : " hours ";
 $pluralmins  = ($mins < 2) ? " minute " : " minutes ";
 $pluralsecs  = ($secs < 2) ? " second " : " seconds ";
 $hourcount = ($hours == 0) ? 1 : 0;
 $minscount = ($mins == 0) ? 1 : 0;
 $secscount = ($secs == 0) ? 1 : 0;
 
 if ($days > 1) {
 // If a post is older than Yesterday we want to display the the date and time it was created rather than how long ago.
 // This makes it easier to display rather than having it say 3 days, 5 hours ago, for example.
  $timediff = $posted_on;
 }
 elseif ($days == 1) {
 // The post is within 1 day old.  In this case, I've decided it may be best to show only 1 day, 5 hours ago, for example.
  $timediff = "posted ".$days." day and ".$hours.$pluralhours." ago";
 }
 else {
 // Less than 1 day has passed and here we use the interval that was set above.
  if ($interval == 0) {  $timediff = "posted ".$days.$pluraldays." ago";} // show only days
  elseif ($interval == 1) { $timediff = "posted ".$hours.$pluralhours." ago";} // show only hours
  elseif ($interval == 2) { $timediff = "posted ".$mins.$pluralmins." ago";} // show only minutes
  elseif ($interval == 3) { $timediff = "posted ".$secs.$pluralsecs." ago";} // show only seconds
  
  elseif ($interval == 4) { // show hours and minutes
   if ($hourcount) { $timediff = "posted ".$mins." ".$pluralmins." ago"; }
   else if ($minscount) { $timediff = "posted ".$hours." ".$pluralhours." ago"; }
   else { $timediff = "posted ".$hours.$pluralhours." and ".$mins." ".$pluralmins." ago"; }
  }
  elseif ($interval == 5) { // show hours and seconds
   if ($hourscount) { $timediff = "posted ".$secs." ".$pluralsecs." ago"; }
   else if ($secscount) { $timediff = "posted ".$hours." ".$pluralhours." ago"; }
   else { $timediff = "posted ".$hours.$pluralhours." and ".$sec." ".$pluralsecs." ago"; }
  }
  elseif ($interval == 6) { // show minutes and seconds 
   if ($minscount == 1) { $timediff = "posted ".$secs." ".$pluralsecs." ago"; }
   else if ($secscount == 1 ) { $timediff = "posted ".$mins." ".$pluralmins." ago"; }
   else { $timediff = "posted ".$mins.$pluralmins." and ".$secs." ".$pluralsecs." ago"; }
  }
  else { // show hours, minutes and seconds
   $timediff = "posted ".$hours.$pluralhours.", ".$mins." ".$pluralmins." and".$secs." ".$pluralsecs." ago";
  }
 }
 
 return $timediff;


?>

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
×
×
  • Create New...