здравейте, трябва ми код за извеждане на последни теми от форума за IPB.
намрих тука нещо но май не работи:
CODE
намрих тука нещо но май не работи:
CODE
PHP:
<?php
/*
Edit parameters below
*/
$sqlHost = "localhost";
$sqlUser = "user";
$sqlPassword = "pass";
$sqlDatabase = "database";
$sqlTablePrefix = "ibf";
$sqlTopics = 10;
$htmlPattern = '<a href="http://forum.com/index.php?showtopic={{tid}}" target="_blank">{{title}} <{{posts}}></a>';
/*
Please, do not edit this
*/
$sqlQuery = "
SELECT
`prefix_topics`.*,
`prefix_forums`.`name` AS `forum_name`,
`prefix_categories`.`name` AS `category_name`
FROM `prefix_topics`, `prefix_forums`, `prefix_categories`
WHERE
`prefix_topics`.`forum_id` = `prefix_forums`.`id`
AND
`prefix_forums`.`category` = `prefix_categories`.`id`
ORDER BY `prefix_topics`.`start_date` DESC
LIMIT 0, " . $sqlTopics;
$sqlLink = @mysql_connect($sqlHost, $sqlUser, $sqlPassword, true);
if ($sqlLink === false) {
trigger_error("Could not connect to SQL host on `" . htmlspecialchars($sqlHost) . "`", E_USER_ERROR);
}
if (@mysql_select_db($sqlDatabase, $sqlLink) === false) {
trigger_error("Could not select database `" . htmlspecialchars($sqlDatabase) . "` on SQL host `" . htmlspecialchars($sqlHost) . "`", E_USER_ERROR);
}
$sqlResult = @mysql_query(str_replace("prefix_", $sqlTablePrefix . "_", $sqlQuery), $sqlLink);
if ($sqlResult === false) {
trigger_error("You have error in your query; database `" . htmlspecialchars($sqlDatabase) . "`; SQL host `" . htmlspecialchars($sqlHost) . "`", E_USER_NOTICE);
}
$topics = array();
while ($row = @mysql_fetch_array($sqlResult, MYSQL_ASSOC)) {
if (empty($row)) {
continue;
}
$topics[] = $row;
}
if (!empty($topics)) {
$pattern = "/\{\{([a-zA-Z0-9_]+)\}\}/i";
foreach ($topics as $topic) {
$htmlCode = $htmlPattern;
$iterate = 0;
while (preg_match($pattern, $htmlCode, $reg)) {
$strReplace = isset($topic[$reg[1]]) ? $topic[$reg[1]] : null;
$htmlCode = preg_replace($pattern, $strReplace, $htmlCode, 1);
if (++$iterate > 25) { break; }
}
echo $htmlCode;
}
} else {
trigger_error("No topics; database `" . htmlspecialchars($sqlDatabase) . "`; SQL host `" . htmlspecialchars($sqlHost) . "`", E_USER_NOTICE);
}
mysql_close($sqlLink);
?>