| [ Index ] |
|
Code source de PHP NUKE 7.9 |
1 <?php 2 /*************************************************************************** 3 * prune.php 4 * ------------------- 5 * begin : Thursday, June 14, 2001 6 * copyright : (C) 2001 The phpBB Group 7 * email : support@phpbb.com 8 * 9 * Id: prune.php,v 1.19.2.6 2003/03/18 23:23:57 acydburn Exp 10 * 11 * 12 ***************************************************************************/ 13 /*************************************************************************** 14 * phpbb2 forums port version 2.0.5 (c) 2003 - Nuke Cops (http://nukecops.com) 15 * 16 * Ported by Nuke Cops to phpbb2 standalone 2.0.5 Test 17 * and debugging completed by the Elite Nukers and site members. 18 * 19 * You run this package at your sole risk. Nuke Cops and affiliates cannot 20 * be held liable if anything goes wrong. You are advised to test this 21 * package on a development system. Backup everything before implementing 22 * in a production environment. If something goes wrong, you can always 23 * backout and restore your backups. 24 * 25 * Installing and running this also means you agree to the terms of the AUP 26 * found at Nuke Cops. 27 * 28 * This is version 2.0.5 of the phpbb2 forum port for PHP-Nuke. Work is based 29 * on Tom Nitzschner's forum port version 2.0.6. Tom's 2.0.6 port was based 30 * on the phpbb2 standalone version 2.0.3. Our version 2.0.5 from Nuke Cops is 31 * now reflecting phpbb2 standalone 2.0.5 that fixes some bugs and the 32 * invalid_session error message. 33 ***************************************************************************/ 34 /*************************************************************************** 35 * This file is part of the phpBB2 port to Nuke 6.0 (c) copyright 2002 36 * by Tom Nitzschner (tom@toms-home.com) 37 * http://bbtonuke.sourceforge.net (or http://www.toms-home.com) 38 * 39 * As always, make a backup before messing with anything. All code 40 * release by me is considered sample code only. It may be fully 41 * functual, but you use it at your own risk, if you break it, 42 * you get to fix it too. No waranty is given or implied. 43 * 44 * Please post all questions/request about this port on http://bbtonuke.sourceforge.net first, 45 * then on my site. All original header code and copyright messages will be maintained 46 * to give credit where credit is due. If you modify this, the only requirement is 47 * that you also maintain all original copyright messages. All my work is released 48 * under the GNU GENERAL PUBLIC LICENSE. Please see the README for more information. 49 * 50 ***************************************************************************/ 51 52 /*************************************************************************** 53 * 54 * This program is free software; you can redistribute it and/or modify 55 * it under the terms of the GNU General Public License as published by 56 * the Free Software Foundation; either version 2 of the License, or 57 * (at your option) any later version. 58 * 59 ***************************************************************************/ 60 61 if ( !defined('IN_PHPBB') ) 62 { 63 die("Hacking attempt"); 64 } 65 66 if (defined('FORUM_ADMIN')) { 67 require("../../../includes/functions_search.php"); 68 } else { 69 require ("includes/functions_search.php"); 70 } 71 72 function prune($forum_id, $prune_date, $prune_all = false) 73 { 74 global $db, $lang; 75 76 $prune_all = ($prune_all) ? '' : 'AND t.topic_vote = 0 AND t.topic_type <> ' . POST_ANNOUNCE; 77 // 78 // Those without polls and announcements ... unless told otherwise! 79 // 80 $sql = "SELECT t.topic_id 81 FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t 82 WHERE t.forum_id = '$forum_id' 83 $prune_all 84 AND ( p.post_id = t.topic_last_post_id 85 OR t.topic_last_post_id = '0' )"; 86 if ( $prune_date != '' ) 87 { 88 $sql .= " AND p.post_time < '$prune_date'"; 89 } 90 91 if ( !($result = $db->sql_query($sql)) ) 92 { 93 message_die(GENERAL_ERROR, 'Could not obtain lists of topics to prune', '', __LINE__, __FILE__, $sql); 94 } 95 96 $sql_topics = ''; 97 while( $row = $db->sql_fetchrow($result) ) 98 { 99 $sql_topics .= ( ( $sql_topics != '' ) ? ', ' : '' ) . $row['topic_id']; 100 } 101 $db->sql_freeresult($result); 102 103 if( $sql_topics != '' ) 104 { 105 $sql = "SELECT post_id 106 FROM " . POSTS_TABLE . " 107 WHERE forum_id = '$forum_id' 108 AND topic_id IN ($sql_topics)"; 109 if ( !($result = $db->sql_query($sql)) ) 110 { 111 message_die(GENERAL_ERROR, 'Could not obtain list of posts to prune', '', __LINE__, __FILE__, $sql); 112 } 113 114 $sql_post = ''; 115 while ( $row = $db->sql_fetchrow($result) ) 116 { 117 $sql_post .= ( ( $sql_post != '' ) ? ', ' : '' ) . $row['post_id']; 118 } 119 $db->sql_freeresult($result); 120 121 if ( $sql_post != '' ) 122 { 123 $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " 124 WHERE topic_id IN ($sql_topics)"; 125 if ( !$db->sql_query($sql, BEGIN_TRANSACTION) ) 126 { 127 message_die(GENERAL_ERROR, 'Could not delete watched topics during prune', '', __LINE__, __FILE__, $sql); 128 } 129 130 $sql = "DELETE FROM " . TOPICS_TABLE . " 131 WHERE topic_id IN ($sql_topics)"; 132 if ( !$db->sql_query($sql) ) 133 { 134 message_die(GENERAL_ERROR, 'Could not delete topics during prune', '', __LINE__, __FILE__, $sql); 135 } 136 137 $pruned_topics = $db->sql_affectedrows(); 138 139 $sql = "DELETE FROM " . POSTS_TABLE . " 140 WHERE post_id IN ($sql_post)"; 141 if ( !$db->sql_query($sql) ) 142 { 143 message_die(GENERAL_ERROR, 'Could not delete post_text during prune', '', __LINE__, __FILE__, $sql); 144 } 145 146 $pruned_posts = $db->sql_affectedrows(); 147 148 $sql = "DELETE FROM " . POSTS_TEXT_TABLE . " 149 WHERE post_id IN ($sql_post)"; 150 if ( !$db->sql_query($sql) ) 151 { 152 message_die(GENERAL_ERROR, 'Could not delete post during prune', '', __LINE__, __FILE__, $sql); 153 } 154 155 remove_search_post($sql_post); 156 157 return array ('topics' => $pruned_topics, 'posts' => $pruned_posts); 158 } 159 } 160 161 return array('topics' => 0, 'posts' => 0); 162 } 163 164 // 165 // Function auto_prune(), this function will read the configuration data from 166 // the auto_prune table and call the prune function with the necessary info. 167 // 168 function auto_prune($forum_id = 0) 169 { 170 global $db, $lang; 171 172 $sql = "SELECT * 173 FROM " . PRUNE_TABLE . " 174 WHERE forum_id = '$forum_id'"; 175 if ( !($result = $db->sql_query($sql)) ) 176 { 177 message_die(GENERAL_ERROR, 'Could not read auto_prune table', '', __LINE__, __FILE__, $sql); 178 } 179 180 if ( $row = $db->sql_fetchrow($result) ) 181 { 182 if ( $row['prune_freq'] && $row['prune_days'] ) 183 { 184 $prune_date = time() - ( $row['prune_days'] * 86400 ); 185 $next_prune = time() + ( $row['prune_freq'] * 86400 ); 186 187 prune($forum_id, $prune_date); 188 sync('forum', $forum_id); 189 190 $sql = "UPDATE " . FORUMS_TABLE . " 191 SET prune_next = '$next_prune' 192 WHERE forum_id = '$forum_id'"; 193 if ( !$db->sql_query($sql) ) 194 { 195 message_die(GENERAL_ERROR, 'Could not update forum table', '', __LINE__, __FILE__, $sql); 196 } 197 } 198 } 199 200 return; 201 } 202 203 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Apr 1 11:11:59 2007 | par Balluche grâce à PHPXref 0.7 |