Witam.
Używam systemu newsów Cutenews i dodatkowo skryptu który wyświetla ostatnie komentarze. Nie wiem jak zmienić poniższy skrypt żeby wyświetlał tylko np. 200 pierwszych znaków komentarza?
Bardzo proszę o pomoc.
[php:1:21fb06812f]<?php
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
//number of latest comments to show
if(!isset($comments_number)) $comments_number = 10;
//URL to where you include your news, example: http://site.com/news.php
$site_url = 'http://www.moja-ostroleka.pl/index.php';
//more help on the format: http://www.php.net/manual/en/function.date.php
$date_format = 'd.m.y, H:i';
//In your template you can use: {url}, {name}, {date}, {comment}, {ip}, {mail}, {newsid}, {comid}
$template = '<a class="ostatnie_komentarze" title="idĽ do tego komentarza" href="{url}"><I>napisał </i> <b>{name}</B><I> dnia {date}:</i> {comment}</a><br><br>';
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
END - END - END - END - END - END / don't edit below /
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
$latest_comments = array_fill(1, $comments_number, array('newsid'=>'0','comid'=>'0','name'=>'','mail'=>'','ip'=>'','comment'=>''));
function check_latest_comment($comment_line, $newsid){
global $latest_comments;
$tmp_latest_comments = $latest_comments;
$comment_arr = explode("|", $comment_line);
foreach($latest_comments as $key=>$latest_comment){
if($latest_comment['comid'] < $comment_arr[0]){
$previous = $latest_comments[$key];
foreach($latest_comments as $my_key=>$latest_comment_arr){
if($key < $my_key){
$current = $latest_comments[$my_key];
$latest_comments[$my_key] = $previous;
$previous = $current;
}
}
$latest_comments[$key] = array(
'newsid' => $newsid,
'comid' => $comment_arr[0],
'name' => $comment_arr[1],
'mail' => $comment_arr[2],
'ip' => $comment_arr[3],
'comment'=> $comment_arr[4],
);
}
}
}
$all_comments = file("cutenews/data/comments.txt");
foreach($all_comments as $comment_line)
{
$comment_line_arr = explode("|>|", $comment_line);
$newsid = $comment_line_arr[0];
$comment_arr = explode("||", $comment_line_arr[1]);
foreach($comment_arr as $single_comment)
{
check_latest_comment($single_comment, $newsid);
}
}
foreach($latest_comments as $comment){
$output = $template;
$output = str_replace("{url}", $site_url."?subaction=showcomments&id={newsid}#{comid}", $output);
$output = str_replace("{name}", $comment['name'], $output);
$output = str_replace("{mail}", $comment['mail'], $output);
$output = str_replace("{ip}", $comment['ip'], $output);
$output = str_replace("{comment}", $comment['comment'], $output);
$output = str_replace("{date}", date($date_format, $comment['comid']), $output);
$output = str_replace("{newsid}", $comment['newsid'], $output);
$output = str_replace("{comid}", $comment['comid'], $output);
echo $output;
}
?>[/php:1:21fb06812f]