Автор: Stifi
Здравейте , това ми е първият урок и се надявам да го предам добре и да го разберете
има такъв урок , но е пълен с грешки
<?
/////////////////////////////
// User Editable variables //
/////////////////////////////
// по колко поста да показва в случея са 10
$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;
// Only useful if the above varaible is set to 1.
$topiclength = 40;
// 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 = "38,37,71,73,69,44,75,108,74";
/*
времето което ще показва
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";
//////////////
// Свързване с базата данни//
//////////////
$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
<a href="$INFO[board_url]/index.php?showtopic=$post[tid]&view=getnewpost">$post[short_title]</a> by
<a href="$INFO[board_url]/index.php?showuser=$post[last_poster_id]">$post[last_poster_name]</a> <BR>
$datefield, with $post[posts] replies.<P>
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;
}
?>
Слагате тоя при папката с IPB-то
или да има достап до
conf_global.php
накрая го инглудваме
<?php include("http://your-domain.NET/forum/latest_posts.php");?>
надявам се да нямам бан за това , че ви предоставям този скрипт
не е изцяло преведен защото не ме бива много с чуждите езици