sibtracker/system/modules/comments-last.php

37 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2019-05-18 13:46:03 +08:00
<?php
if(!defined('DATALIFEENGINE')){die("Hacking attempt!");}
$commentslast = $cache->open( "comments-last", $config['skin'] );
if( ! $commentslast ) {
$sql = $db->query( "SELECT
comments.id AS comment_id, comments.post_id, comments.autor, post.title, post.alt_name, post.comm_num, comments.date
FROM " . PREFIX . "_post AS post
RIGHT JOIN
(SELECT *
FROM " . PREFIX . "_comments AS c
WHERE 1=1
ORDER BY c.date DESC) AS comments
ON post.id = comments.post_id AND post.approve=1
GROUP BY post.id ORDER BY comments.date DESC LIMIT 0, 15");
while( $row = $db->get_row() ) {
if( strlen( $row['autor']) > 10 )
$user = substr( $row['autor'], 0, 10 );
else $user = $row['autor'];
if( strlen( $row['title']) > 15 )
$title = substr( $row['title'], 0, 15 ) . "...";
else $title = $row['title'];
$autor = "<a href=\"" . $config['http_home_url'] . "user/" . urlencode( $row['autor'] ) . "/\">" . $user . "</a>";
$full_link = $config['http_home_url'] . $row['post_id'] . "-" . $row['alt_name'] . ".html";
$post = "<a href=\"" . $full_link . "#comment\">" . stripslashes( $title ) . "</a>" ;
$lcomm .= "<li><strong title='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'>{$row['comm_num']}</strong>{$autor} - {$post}</li>";
}
$commentslast= "<ul class=\"lastcomm\">".$lcomm."</ul>";
$db->free();
$cache->save( "comments-last", $commentslast, $config['skin'] );
}
?>