mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-25 19:00:03 +03:00
fixes #818, add remote_sync.pl script from piwigo.org forum (script written back in 2009)
This commit is contained in:
parent
b9f0f22395
commit
98ee7c1e5c
1 changed files with 59 additions and 0 deletions
59
tools/remote_sync.pl
Normal file
59
tools/remote_sync.pl
Normal file
|
@ -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);
|
Loading…
Add table
Add a link
Reference in a new issue