http://www.phpbbguru.net/community/viewtopic.php?t=1723
Код: Выделить всё
##############################################################
## MOD Title: Fix prune bugs
## MOD Author: chyduskam < chuduskam@debilarius.ru > (Egor Naklonyaeff) N/A
## MOD Description: Fix stupid SQL in prune.php
## MOD Version: 0.0.1
##
## Installation Level: Easy
## Installation Time: 2 Minutes
## Files To Edit: 1
## includes/prune.php
## Included Files: n/a
##############################################################
## For Security Purposes, Please Check: http://www.phpbbguru.net/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbbguru.net/mods/
##############################################################
## Author Notes: I'm too lazy to write something
##############################################################
## MOD History:
## 2005-04-08 - Version 0.0.1
## - initial release
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]-------------------------------------------------------
#
includes/prune.php
#
#-----[ FIND ]----------------------------------------
#
global $db, $lang;
$prune_all = ($prune_all) ? '' : 'AND t.topic_vote = 0 AND t.topic_type <> ' . POST_ANNOUNCE;
//
// Those without polls and announcements ... unless told otherwise!
//
$sql = "SELECT t.topic_id
FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t
WHERE t.forum_id = $forum_id
$prune_all
AND ( p.post_id = t.topic_last_post_id
OR t.topic_last_post_id = 0 )";
if ( $prune_date != '' )
{
$sql .= " AND p.post_time < $prune_date";
}
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain lists of topics to prune', '', __LINE__, __FILE__, $sql);
}
$sql_topics = '';
while( $row = $db->sql_fetchrow($result) )
{
$sql_topics .= ( ( $sql_topics != '' ) ? ', ' : '' ) . $row['topic_id'];
}
$db->sql_freeresult($result);
#
#-----[ REPLACE WITH ]----------------------------------
#
global $db, $lang;
$prune_all = ($prune_all) ? '' : 'AND t.topic_vote = 0 AND t.topic_type <> ' . POST_ANNOUNCE;
$sql_prune_data=( $prune_date != '' )? "AND p.post_time < $prune_date":'';
//
// Those without polls and announcements ... unless told otherwise!
//
$sql = "SELECT t.topic_id
FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t
WHERE t.forum_id = $forum_id
$prune_all
$sql_prune_data
AND p.post_id = t.topic_last_post_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain lists of topics to prune', '', __LINE__, __FILE__, $sql);
}
$sql_topics = '';
while( $row = $db->sql_fetchrow($result) )
{
$sql_topics .= ( ( $sql_topics != '' ) ? ', ' : '' ) . $row['topic_id'];
}
$db->sql_freeresult($result);
// Fix stupid bug
$sql = "SELECT t.topic_id
FROM " . TOPICS_TABLE . " t
WHERE t.forum_id = $forum_id
$prune_all
AND t.topic_last_post_id = 0";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain lists of topics to prune', '', __LINE__, __FILE__, $sql);
}
while( $row = $db->sql_fetchrow($result) )
{
$sql_topics .= ( ( $sql_topics != '' ) ? ', ' : '' ) . $row['topic_id'];
}
$db->sql_freeresult($result);
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM