annotate dbcleanup.php @ 12:7917bd536187 draft

Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
author Ivo Smits <Ivo@UCIS.nl>
date Wed, 12 Jun 2013 22:22:07 +0200
parents 005339a1b2ce
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
1 #!/usr/bin/php
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
2 <?php
8
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
3 /* Copyright 2010 Ivo Smits <Ivo@UCIS.nl>. All rights reserved.
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
4 Redistribution and use in source and binary forms, with or without modification, are
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
5 permitted provided that the following conditions are met:
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
6
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
7 1. Redistributions of source code must retain the above copyright notice, this list of
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
8 conditions and the following disclaimer.
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
9
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
10 2. Redistributions in binary form must reproduce the above copyright notice, this list
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
11 of conditions and the following disclaimer in the documentation and/or other materials
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
12 provided with the distribution.
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
13
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
14 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
15 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
17 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
18 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
19 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
20 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
21 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
22 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
23
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
24 The views and conclusions contained in the software and documentation are those of the
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
25 authors and should not be interpreted as representing official policies, either expressed
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
26 or implied, of Ivo Smits.*/
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 4
diff changeset
27
4
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
28 chdir(__DIR__);
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
29 require_once './common.php';
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
30
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
31 docleanup('Orphaned peergroups', 'DELETE FROM `peergroups` WHERE `group` NOT IN (SELECT `id` FROM `groups`)');
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
32 docleanup('Orphaned peergroups', 'DELETE FROM `peergroups` WHERE `peer` NOT IN (SELECT `id` FROM `peers`)');
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
33 docleanup('Orphaned groupmessages', 'DELETE FROM `groupmessages` WHERE `group` NOT IN (SELECT `id` FROM `groups`)');
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
34 docleanup('Orphaned messages', 'DELETE FROM `messages` WHERE `id` NOT IN (SELECT `message` FROM `groupmessages`)');
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
35 docleanup('Orphaned groupmessages', 'DELETE FROM `groupmessages` WHERE `message` NOT IN (SELECT `id` FROM `messages`)');
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
36 docleanup('Optimize', 'OPTIMIZE TABLE `groupmessages`, `groups`, `messages`, `peergroups`, `peer`');
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
37
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
38 function docleanup($comment, $query) {
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
39 global $db;
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
40 $count = $db->update($query);
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
41 print($comment.': '.$count."\n");
dc5a8e316e21 Add database cleanup script
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
42 }