W zwiazku z pojawieniem sie oferty w Job Offers umieszczam swój w pełni działający skrypt:
[php:1:fe607ab1d3]<?php
/*
* phpBB (2.x.x) Last Topics version 2.0.1 beta
*
* File name : class.phpBB-last_topics.php
* File description : Advanced and full configural script which shows
last phpBB topics
* File create : 2002-10-03 21:25:33
* File modified : 2003-07-01 16:00:00
*
* Author : Piotr 'kwiateek' Kwiatkowski
* E-mail : kwiateek@pcmaniak.pl
*
* Copyrights : © 2003 Piotr 'kwiateek' Kwiatkowski. All rights reserved.
* License : This program is free software; you can redistribute it and/
* or modify it under the terms of the GNU General Public
* License (GPL) as published by the Free Software Foundation;
* either version 2 of the License, or (at your option) any
* later version.
*
* To read the license please visit:
*
http://www.gnu.org/copyleft/gpl.html
*
* Instalation : Put this file into your classes directory. Include class
* and create a new object of phpbbLastTopics class.
*
* Example (default configuration):
* require_once('class.phpBB-last_topics.php');
* $phpbbLastTopics = new phpbbLastTopics();
*
* Example (with user configuration):
* require_once('class.phpBB-last_topics.php');
* $phpbbLastTopics = new phpbbLastTopics(0, 'forum_', 'forum/', 15, '...', 25, 'topic_id', 'ASC');
*
* Arguments to phpbbLastTopics's contrustor:
* $break_words - 0 false, 1 true
* $prefix - prefix to your db
* $path - path or url to your phpBB directory
* $topic_limit - limit of topics (if 0 then no limit)
* $topic_etc - extension string in the end of topic_title
* $topic_length - topic length
* $order_col - column order
* $order_type - type of order DESC or ASC
*
* Remember you must be connected with your dbase so
* you should add mysql_connect() and mysql_select_db() before you
* create object of phpbbLastTopics's class.
*
* Example:
* mysql_connect('example.com', 'test', 'test');
* mysql_select_db('test');
*
*/
class phpbbLastTopics
{
var $topic_list = array();
var $topic_count = 0;
var $break_words;
var $prefix;
var $path;
var $topic_limit;
var $topic_etc;
var $topic_length;
var $order_col;
var $order_type;
function phpbbLastTopics($break_words = 0, $prefix = 'phpBB_', $path = 'phpBB/', $topic_limit = 10, $topic_etc = '...', $topic_length = 25, $order_col = 'topic_time', $order_type = 'DESC')
{
$this->break_words = $break_words;
$this->prefix = $prefix;
$this->path = $path;
$this->topic_limit = $topic_limit;
$this->topic_etc = $topic_etc;
$this->topic_length = $topic_length;
$this->order_col = $order_col;
$this->order_type = $order_type;
$this->makeTopicList();
$this->showTopics();
}
function makeTopicList()
{
$query = 'SELECT topic_id, topic_last_post_id, ';
if($this->topic_limit != 0) {
if($this->break_words) {
$query .= 'SUBSTRING(topic_title, 1, ' . $this->topic_length . ') AS topic_title, LENGTH( topic_title ) AS topic_title_length ';
} else {
$query .= 'LENGTH( topic_title ) AS topic_title_length, LEFT( topic_title,
IF ( LENGTH(topic_title) < ' . $this->topic_length . ', LENGTH( topic_title ) ,
IF (LOCATE( ' ', topic_title, ' . $this->topic_length . ' ) = 0, LENGTH( topic_title ) , LOCATE( ' ', topic_title, ' . $this->topic_length . ' ) )
)
) AS topic_title ';
}
} else {
$query .= 'topic_title ';
}
$query .= 'FROM ' . $this->prefix . 'topics
ORDER BY ' . $this->order_col . ' ' . $this->order_type . '
LIMIT ' . $this->topic_limit . '';
$result = mysql_query($query);
if($result) {
while($row = mysql_fetch_array($result)) {
$this->topic_count++;
if($this->topic_limit != 0) {
if($row['topic_title_length'] > $this->topic_length) {
$topic_title[$this->topic_count] = $row['topic_title'] . $this->topic_etc;
} else {
$topic_title[$this->topic_count] = $row['topic_title'];
}
} else {
$topic_title[$this->topic_count] = $row['topic_title'];
}
$this->topic_list[$this->topic_count] = array('TopicId' => $row['topic_id'], 'TopicTitle' => $topic_title[$this->topic_count], 'TopicLastPostId' => $row['topic_last_post_id']);
}
return 1;
}
return 0;
}
function showTopics()
{
foreach($this->topic_list as $topic) {
echo '<a HREF="' . $this->path . 'viewtopic.php?t=' . $topic['TopicId'] . '#' . $topic['TopicLastPostId'] . '">' . $topic['TopicTitle'] . '</A><BR>';
}
}
}
?>[/php:1:fe607ab1d3]