Skip to content

Commit

Permalink
fixes #818, add remote_sync.pl script from piwigo.org forum (script w…
Browse files Browse the repository at this point in the history
…ritten back in 2009)
  • Loading branch information
plegall committed Dec 15, 2017
1 parent b9f0f22 commit 98ee7c1
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tools/remote_sync.pl
@@ -0,0 +1,59 @@
#!/usr/bin/perl

# perl remote_sync.pl --base_url=http://localhost/piwigo/dev/branches/2.0 --username=plg --password=plg

use strict;
use warnings;

use LWP::UserAgent;
use Getopt::Long;

my %opt = ();
GetOptions(
\%opt,
qw/
base_url=s
username=s
password=s
/
);

our $ua = LWP::UserAgent->new;
$ua->agent('Mozilla/remote_sync.pl');
$ua->cookie_jar({});

$ua->default_headers->authorization_basic(
$opt{username},
$opt{password}
);

my $form = {
method => 'pwg.session.login',
username => $opt{username},
password => $opt{password},
};

my $result = $ua->post(
$opt{base_url}.'/ws.php?format=json',
$form
);

# perform the synchronization
$form = {
'sync' => 'files',
'display_info' => 1,
'add_to_caddie' => 1,
'privacy_level' => 0,
'sync_meta' => 1, # remove this parameter, turning to 0 is not enough
'simulate' => 0,
'subcats-included' => 1,
'submit' => 1,
};

$result = $ua->post(
$opt{base_url}.'/admin.php?page=site_update&site=1',
$form
);

use Data::Dumper;
print Dumper($result);

0 comments on commit 98ee7c1

Please sign in to comment.