Get all last article info from database, not overview flat file
This commit is contained in:
parent
e101fdd81b
commit
ff97f617df
|
@ -682,7 +682,7 @@ function formatTreeText($tree) {
|
||||||
* format the subject inside the thread
|
* format the subject inside the thread
|
||||||
*/
|
*/
|
||||||
function thread_format_subject($c,$group,$highlightids=false) {
|
function thread_format_subject($c,$group,$highlightids=false) {
|
||||||
global $file_article, $thread_maxSubject, $frame_article, $thread_show, $spooldir, $ovfile, $CONFIG;
|
global $file_article, $thread_maxSubject, $frame_article, $thread_show, $spooldir, $CONFIG;
|
||||||
if(isset($_COOKIE['tzo'])) {
|
if(isset($_COOKIE['tzo'])) {
|
||||||
$offset=$_COOKIE['tzo'];
|
$offset=$_COOKIE['tzo'];
|
||||||
} else {
|
} else {
|
||||||
|
@ -810,36 +810,21 @@ function thread_format_author($c,$group='',$lastmessage=1) {
|
||||||
* format the last message info in the thread
|
* format the last message info in the thread
|
||||||
*/
|
*/
|
||||||
function thread_format_lastmessage($c,$group='') {
|
function thread_format_lastmessage($c,$group='') {
|
||||||
global $thread_show,$anonym_address,$spooldir,$ovcache,$ovfile,$CONFIG;
|
global $thread_show,$anonym_address,$spooldir,$CONFIG;
|
||||||
$ovfound = 0;
|
$ovfound = 0;
|
||||||
$thiscache = array_slice($ovcache,-5);
|
if($CONFIG['article_database'] == '1') {
|
||||||
if(!empty($thiscache)) {
|
$database = $spooldir.'/'.$group.'-articles.db3';
|
||||||
$ovcache = $thiscache;
|
$table = 'articles';
|
||||||
}
|
$dbh = article_db_open($database, $table);
|
||||||
foreach($ovcache as $cacheline) {
|
$stmt = $dbh->prepare("SELECT * FROM $table WHERE date=:date ORDER BY date DESC");
|
||||||
$line = preg_split("/(:#rsl#:|\t)/", $cacheline);
|
$stmt->bindParam(':date', $c->date_thread);
|
||||||
if(intval($c->date_thread) == strtotime($line[3])) {
|
$stmt->execute();
|
||||||
$ovfound = 1;
|
if($found = $stmt->fetch()) {
|
||||||
break;
|
$ovfound = 1;
|
||||||
}
|
};
|
||||||
}
|
$dbh = null;
|
||||||
if($ovfound == 0) {
|
|
||||||
$ovcache = array();
|
$fromline = address_decode(headerDecode($found['name']),"nirgendwo");
|
||||||
while($overviewline = fgets($ovfile)) {
|
|
||||||
$line = preg_split("/(:#rsl#:|\t)/", $overviewline);
|
|
||||||
$ovcache[] = $overviewline;
|
|
||||||
if(intval($c->date_thread) == strtotime($line[3])) {
|
|
||||||
$ovfound = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if($ovfound == 0) {
|
|
||||||
pclose($ovfile);
|
|
||||||
$overviewfile = $spooldir.'/'.$group.'-overview';
|
|
||||||
$ovfile = popen($CONFIG['tac'].' '.$overviewfile, 'r');
|
|
||||||
}
|
|
||||||
$fromline = address_decode(headerDecode($line[2]),"nirgendwo");
|
|
||||||
if (!isset($fromline[0]["host"])) $fromline[0]["host"]="";
|
if (!isset($fromline[0]["host"])) $fromline[0]["host"]="";
|
||||||
$name_from=$fromline[0]["mailbox"]."@".$fromline[0]["host"];
|
$name_from=$fromline[0]["mailbox"]."@".$fromline[0]["host"];
|
||||||
$name_username=$fromline[0]["mailbox"];
|
$name_username=$fromline[0]["mailbox"];
|
||||||
|
@ -856,8 +841,9 @@ function thread_format_lastmessage($c,$group='') {
|
||||||
$poster_name = $fromoutput[0];
|
$poster_name = $fromoutput[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if($ovfound == 1) {
|
if($ovfound == 1) {
|
||||||
$url = 'article-flat.php?id='.$line[0].'&group='.urlencode($group).'#'.$line[0];
|
$url = 'article-flat.php?id='.$found['number'].'&group='.urlencode($group).'#'.$found['number'];
|
||||||
$return.='<p class=np_posted_date_left><a href="'.$url.'">'.get_date_interval(date("D, j M Y H:i T",$c->date_thread)).'</a>';
|
$return.='<p class=np_posted_date_left><a href="'.$url.'">'.get_date_interval(date("D, j M Y H:i T",$c->date_thread)).'</a>';
|
||||||
} else {
|
} else {
|
||||||
$return.='<p class=np_posted_date_left>'.get_date_interval(date("D, j M Y H:i T",$c->date_thread)).'</p>';
|
$return.='<p class=np_posted_date_left>'.get_date_interval(date("D, j M Y H:i T",$c->date_thread)).'</p>';
|
||||||
|
|
|
@ -1387,16 +1387,13 @@ function article_db_open($database) {
|
||||||
subject TEXT,
|
subject TEXT,
|
||||||
search_snippet TEXT,
|
search_snippet TEXT,
|
||||||
article TEXT)");
|
article TEXT)");
|
||||||
|
|
||||||
$stmt = $dbh->query('CREATE INDEX IF NOT EXISTS db_number on articles(number)');
|
$stmt = $dbh->query('CREATE INDEX IF NOT EXISTS db_number on articles(number)');
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
$stmt = $dbh->query('CREATE INDEX IF NOT EXISTS db_date on articles(date)');
|
||||||
// TEMPORARY
|
|
||||||
$stmt = $dbh->query('DROP INDEX IF EXISTS db_date');
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt = $dbh->query('DROP INDEX IF EXISTS db_newsgroup');
|
$stmt = $dbh->query('CREATE INDEX IF NOT EXISTS db_name on articles(name)');
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt = $dbh->query('DROP INDEX IF EXISTS db_name');
|
|
||||||
// TEMPORARY
|
|
||||||
|
|
||||||
$dbh->exec("CREATE VIRTUAL TABLE IF NOT EXISTS search_fts USING fts5(
|
$dbh->exec("CREATE VIRTUAL TABLE IF NOT EXISTS search_fts USING fts5(
|
||||||
newsgroup,
|
newsgroup,
|
||||||
|
|
|
@ -33,10 +33,6 @@ if((!function_exists("npreg_group_has_read_access") ||
|
||||||
(!function_exists("npreg_group_is_visible") ||
|
(!function_exists("npreg_group_is_visible") ||
|
||||||
npreg_group_is_visible($group))) {
|
npreg_group_is_visible($group))) {
|
||||||
|
|
||||||
$overviewfile = $spooldir.'/'.$group.'-overview';
|
|
||||||
$ovfile = popen($CONFIG['tac'].' '.$overviewfile, 'r');
|
|
||||||
$ovcache = array();
|
|
||||||
|
|
||||||
if(isset($frames_on) && $frames_on === true) {
|
if(isset($frames_on) && $frames_on === true) {
|
||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
|
@ -136,7 +132,6 @@ if(isset($frames_on) && $frames_on === true) {
|
||||||
echo '<td class="np_pages" width="100%" align="right">';
|
echo '<td class="np_pages" width="100%" align="right">';
|
||||||
thread_pageselect($group,$pagecount,$first);
|
thread_pageselect($group,$pagecount,$first);
|
||||||
echo '</td></tr></table>';
|
echo '</td></tr></table>';
|
||||||
pclose($ovfile);
|
|
||||||
} else {
|
} else {
|
||||||
echo $text_register["no_access_group"];
|
echo $text_register["no_access_group"];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue