root / find_dups.php

View | Annotate | Download (1.8 KB)

1 c1820df7 Andreas
 #!/usr/bin/php
2 c1820df7 Andreas
 <?php
3 c1820df7 Andreas
4 c1820df7 Andreas
 /***************************************************************************
5 c1820df7 Andreas
  *
6 7617d447 Andreas
  * phpfspot, presents your F-Spot photo collection in Web browsers.
7 7617d447 Andreas
  *
8 7617d447 Andreas
  * Copyright (c) by Andreas Unterkircher
9 c1820df7 Andreas
  *
10 c1820df7 Andreas
  *  This program is free software; you can redistribute it and/or modify
11 c1820df7 Andreas
  *  it under the terms of the GNU General Public License as published by
12 c1820df7 Andreas
  *  the Free Software Foundation; either version 2 of the License, or
13 c1820df7 Andreas
  *  any later version.
14 c1820df7 Andreas
  *
15 c1820df7 Andreas
  *  This program is distributed in the hope that it will be useful,
16 c1820df7 Andreas
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 c1820df7 Andreas
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 c1820df7 Andreas
  *  GNU General Public License for more details.
19 c1820df7 Andreas
  *
20 c1820df7 Andreas
  *  You should have received a copy of the GNU General Public License
21 c1820df7 Andreas
  *  along with this program; if not, write to the Free Software
22 c1820df7 Andreas
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 c1820df7 Andreas
  *
24 c1820df7 Andreas
  ***************************************************************************/
25 c1820df7 Andreas
26 55677896 Andreas
 /**
27 55677896 Andreas
  * find_dups.php
28 55677896 Andreas
  *
29 55677896 Andreas
  * find duplicated photos based on MD5 checksum
30 55677896 Andreas
  *
31 55677896 Andreas
  * @package phpfspot
32 55677896 Andreas
  */
33 c1820df7 Andreas
 if(!isset($_SERVER["TERM"])) {
34 c1820df7 Andreas
    print "<br /><br />This script should only be invoked from command line!<br />\n";
35 c1820df7 Andreas
    die;
36 c1820df7 Andreas
 }
37 c1820df7 Andreas
38 c1820df7 Andreas
 require_once "phpfspot.class.php";
39 c1820df7 Andreas
40 c1820df7 Andreas
 $fspot = new PHPFSPOT;
41 c1820df7 Andreas
 $fspot->fromcmd = true;
42 c1820df7 Andreas
43 c1820df7 Andreas
 $all_dups = $fspot->cfg_db->db_query("
44 c1820df7 Andreas
    SELECT i1.img_idx as i1, i2.img_idx as i2
45 c1820df7 Andreas
    FROM images i1
46 c1820df7 Andreas
    INNER JOIN images i2
47 c1820df7 Andreas
       ON (
48 c1820df7 Andreas
          i1.img_md5=i2.img_md5
49 c1820df7 Andreas
       AND
50 c1820df7 Andreas
          i1.img_idx!=i2.img_idx
51 c1820df7 Andreas
       )
52 c1820df7 Andreas
    ORDER BY i1.img_idx ASC
53 c1820df7 Andreas
 ");
54 c1820df7 Andreas
55 c1820df7 Andreas
 while($row = $fspot->cfg_db->db_fetch_object($all_dups)) {
56 c1820df7 Andreas
    if($photo1 = $fspot->getphotoname($row['i1'])) {
57 c1820df7 Andreas
       print "Dups for ". $photo1 ."\n";
58 c1820df7 Andreas
       if($photo2 = $fspot->getphotoname($row['i2'])) {
59 c1820df7 Andreas
          print "\t". $photo2 ."\n";
60 c1820df7 Andreas
       }
61 c1820df7 Andreas
    }
62 c1820df7 Andreas
 }
63 c1820df7 Andreas
64 c1820df7 Andreas
 ?>