crea un file (es. news.php) e inserisci quanto sotto
Codice PHP:
<?php
$root_path = "./";
$templates_dir = "./ssi_templates";
$max_show = 100; // Maximum number of topics possible to show...
$allow_syndication = 1; // To turn off, use $allow_syndication = 0;
error_reporting (E_ERROR | E_WARNING | E_PARSE);
set_magic_quotes_runtime(0);
class info {
var $input = array();
var $base_url = "";
var $vars = "";
function info() {
global $sess, $std, $DB, $root_path, $INFO;
$this->vars = &$INFO;
}
}
require $root_path."conf_global.php";
require $root_path."sources/functions.php";
$std = new FUNC;
$INFO['sql_driver'] = !$INFO['sql_driver'] ? 'mySQL' : $INFO['sql_driver'];
$to_require = $root_path."sources/Drivers/".$INFO['sql_driver'].".php";
require ($to_require);
$DB = new db_driver;
$DB->obj['sql_database'] = $INFO['sql_database'];
$DB->obj['sql_user'] = $INFO['sql_user'];
$DB->obj['sql_pass'] = $INFO['sql_pass'];
$DB->obj['sql_host'] = $INFO['sql_host'];
$DB->obj['sql_tbl_prefix'] = $INFO['sql_tbl_prefix'];
// Get a DB connection
$DB->connect();
$ibforums = new info();
$ibforums->input = $std->parse_incoming();
$ibforums->base_url = $ibforums->vars['board_url'].'/index.'.$ibforums->vars['php_ext'];
function do_news()
{
global $DB, $ibforums, $root_path, $templates_dir, $std, $max_show;
if ( (! $ibforums->vars['news_forum_id']) or ($ibforums->vars['news_forum_id'] == "" ) )
{
fatal_error("No news forum assigned");
}
require $root_path."sources/lib/post_parser.php";
$parser = new post_parser();
$perpage = intval($ibforums->input['show']) > 0 ? intval($ibforums->input['show']) : 10;
$perpage = ( $perpage > $max_show ) ? $max_show : $perpage;
// Load the template...
$template = load_template("news.html");
$to_echo = "";
// Get the topics, member info and other stuff
$DB->query("SELECT m.name as member_name, m.id as member_id,m.title as member_title, m.avatar, m.avatar_size, m.posts, t.*, p.*, g.g_dohtml, f.use_html
FROM ibf_topics t
LEFT JOIN ibf_posts p ON (p.new_topic=1 AND p.topic_id=t.tid)
LEFT JOIN ibf_members m ON (m.id=t.starter_id)
LEFT JOIN ibf_groups g ON (g.g_id=m.mgroup)
LEFT JOIN ibf_forums f ON (t.forum_id=f.id)
WHERE t.forum_id={$ibforums->vars['news_forum_id']} AND t.approved=1 ORDER BY t.tid DESC LIMIT 0, $perpage");
if ( ! $DB->get_num_rows() )
{
fatal_error("Could not get the information from the database");
}
while ( $row = $DB->fetch_row() )
{
$row['post'] = str_replace( '<br>', '<br />', $row['post'] );
$to_echo .= parse_template( $template,
array (
'profile_link' => $ibforums->base_url."?act=Profile&CODE=03&MID=".$row['member_id'],
'member_name' => $row['member_name'],
'post_date' => $std->get_date( $row['start_date'], 'LONG' ),
'topic_title' => $row['title'],
'post' => $parser->post_db_parse($row['post'], ($row['use_html'] AND $row['g_dohtml']) ? 1 : 0 ),
'comments' => $row['posts'],
'view_all_link' => $ibforums->base_url."?act=ST&f={$row['forum_id']}&t={$row['tid']}"
)
);
}
echo $to_echo;
exit();
}
function parse_template( $template, $assigned=array() )
{
foreach( $assigned as $word => $replace)
{
$template = preg_replace( "/\{$word\}/i", "$replace", $template );
}
return $template;
}
function load_template($template="")
{
global $templates_dir;
$filename = $templates_dir."/".$template;
if ( file_exists($filename) )
{
if ( $FH = fopen($filename, 'r') )
{
$template = fread( $FH, filesize($filename) );
fclose($FH);
}
else
{
fatal_error("Couldn't open the template file");
}
}
else
{
fatal_error("Template file does not exist");
}
return $template;
}
function fatal_error($message="") {
echo("An error occured whilst processing this directive");
if ($message)
{
echo("<br>$message");
}
exit();
}
?>
poi includi il file creato