From 98ee7c1e5c85712d1f31d4a0255c9b49212fded0 Mon Sep 17 00:00:00 2001 From: plegall Date: Fri, 15 Dec 2017 10:49:46 +0100 Subject: [PATCH] fixes #818, add remote_sync.pl script from piwigo.org forum (script written back in 2009) --- tools/remote_sync.pl | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tools/remote_sync.pl diff --git a/tools/remote_sync.pl b/tools/remote_sync.pl new file mode 100644 index 0000000000..09d01cb4e4 --- /dev/null +++ b/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); \ No newline at end of file