translate_path() only needs one parameters. remove unused second one
[phpfspot.git] / gen_thumbs.php
1 #!/usr/bin/php
2 <?php
3
4 /***************************************************************************
5  *
6  * phpfspot, presents your F-Spot photo collection in Web browsers.
7  *
8  * Copyright (c) by Andreas Unterkircher
9  *
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  any later version.
14  *
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program; if not, write to the Free Software
22  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  *
24  ***************************************************************************/
25
26 if(!isset($_SERVER["TERM"])) {
27    print "<br /><br />This script should only be invoked from command line!<br />\n";
28    die;
29 }
30
31 require_once "phpfspot.class.php";
32
33 $fspot = new PHPFSPOT;
34 $fspot->fromcmd = true;
35
36 $overwrite = false;
37
38 $short_options = "";
39 $short_options.= "h"; /* help */
40 $short_options.= "o"; /* overwrite */
41 $short_options.= "c"; /* cleanup */
42
43 $long_options = array(
44    "help",
45    "overwrite",
46    "cleanup",
47 );
48
49 /* command line option specified? */
50 if(isset($_SERVER['argc']) && $_SERVER['argc'] > 1) {
51    /* validate */
52    $con = new Console_Getopt;
53    $args = $con->readPHPArgv(); 
54    $options = $con->getopt($args, $short_options, $long_options);
55
56    if(PEAR::isError($options)) {
57       die ("Error in command line: " . $options->getMessage() . "\n");
58    }
59
60    foreach($options[0] as $opt) {
61       switch($opt[0]) {
62          case 'h':
63          case '--help':
64             print "we need some help here!\n";
65             exit(0);
66             break;
67          case 'o':
68          case '--overwrite':
69             print "Overwrite flag set!\n";
70             $overwrite = true;
71             break;
72          case 'c':
73          case '--cleanup':
74             $fspot->cleanup_phpfspot_db();
75             exit(0);
76             break;
77          default:
78             print "invalid option";
79             exit(1);
80             break;
81       }
82    }
83 }
84
85 $all = $fspot->getPhotoSelection();
86
87 foreach($all as $photo) {
88    $fspot->gen_thumb($photo, $overwrite);
89 }
90
91 ?>