LJR::Gate
body<=
color_names;
my $err = sub {
my $txt = shift;
return "
";
};
my $update_export_settings = sub {
my ($iremote) = @_;
my $ret;
my $e;
my $dbh = LJ::get_db_writer();
if (!$dbh) {
return $err->("Can't get database writer!");
}
my $dbr = LJ::get_db_reader();
if (!$dbr) {
return $err->("Can't get database reader!");
}
my $iserver;
if ($POST{'server'} eq "lj") {
$iserver = "www.livejournal.com";
}
# elsif ($POST{'server'} eq "gj") {
# $iserver = "www.greatestjournal.com";
# }
else {
$ret .= $err->("Invalid server specified!");
$e = 1;
}
my $iuser = LJ::canonical_username($POST{'username'});
if (!$iuser) {
$ret .= $err->("Invalid user name!");
$e = 1;
}
my $ipassword = $POST{'password'};
unless (LJ::is_ascii($ipassword) && $ipassword ne "") {
$ret .= $err->("Invalid password!");
$e = 1;
}
return $ret if $e;
my $xmlrpc = LJR::Gate::Authenticate ($iserver, $iuser, $ipassword);
print STDERR
"Error in LJR::Gate::Authenticate for user " . $iuser . "\n" . $xmlrpc->{'err_text'} . "\n"
if $xmlrpc->{'err_text'};
return $err->($xmlrpc->{'err_text'}) if $xmlrpc->{'err_text'};
my $ru = LJR::Distributed::get_remote_server($iserver);
return $err->($ru->{"errtext"}) if $ru->{"err"};
$ru->{'username'} = $iuser;
$ru = LJR::Distributed::get_cached_user($ru);
return $err->($ru->{"errtext"}) if $ru->{"err"};
my $r = LJR::Distributed::update_export_settings($iremote, $ru->{'ru_id'}, $ipassword);
return $r->{'errtext'} if $r->{'err'};
my $cu = LJ::load_user($iremote, 1);
return $err->("Error logging export modification for [$iremote]!") unless $cu;
$cu->log_event('ljr_export_configured', {
remote => $cu,
actiontarget => $ru->{'ru_id'},
method => 'web',
});
return;
};
my $cancel_export = sub {
my ($iremote) = @_;
my $dbr = LJ::get_db_reader();
return $err->("Can't get database reader!") unless $dbr;
my $dbh = LJ::get_db_writer();
return $err->("Can't get database writer!") unless $dbh;
my $sth1;
$sth1 = $dbr->prepare("SELECT * FROM ljr_export_settings WHERE user=?");
$sth1->execute($iremote);
my $r = $sth1->fetchrow_hashref;
$sth1 = $dbr->prepare("DELETE FROM ljr_export_settings WHERE user=?");
$sth1->execute($iremote);
$sth1->finish;
my $cu = LJ::load_user($iremote, 1);
return $err->("Error logging export modification for [$iremote]!") unless $cu;
$cu->log_event('ljr_export_unconfigured', {
remote => $cu,
actiontarget => $r->{'ru_id'},
method => 'web',
});
return;
};
my $export_options = sub {
my ($iremote) = @_;
my %h_font_names;
@h_font_names{map {"gd" . $_ . "Font"} @font_names} = ();
if (! exists $h_font_names{$POST{'font_name'}}) {
return $err->("Invalid font name: " . $POST{'font_name'});
}
my %h_color_names;
@h_color_names{@color_names} = ();
if (! exists $h_color_names{$POST{'font_color'}}) {
return $err->("Invalid color name: " . $POST{'font_color'});
}
my $dbh = LJ::get_db_writer();
return $err->("Can't get database writer!") unless $dbh;
my $sth1;
$sth1 = $dbh->prepare("UPDATE ljr_export_settings SET update_time=NOW(), last_status='OK: updated options', font_name=?, font_color=? WHERE user=?");
$sth1->execute($POST{'font_name'}, $POST{'font_color'}, $iremote);
$sth1->finish;
return;
};
return LJ::server_down_html() if $LJ::SERVER_DOWN;
my $remote = LJ::get_remote();
return LJ::bad_input("You must be logged in to access this page.")
unless $remote;
my $authas = $GET{'authas'} || $remote->{'user'};
my $u = LJ::get_authas_user($authas);
return LJ::bad_input("You could not be authenticated as the specified user.")
unless $u;
my $iremote = $remote->{'user'};
return $LJ::MSG_READONLY_USER if $u->readonly;
my $ret;
$ret = "{'user'} . " h1?>\n
";
my $iremote_is_protected = 0;
foreach (@LJ::PROTECTED_USERNAMES) {
if ($iremote =~ $_) {
$iremote_is_protected = 1;
}
}
if ($iremote_is_protected) {
$ret .= $err->("Invalid local user: export not allowed!");
return $ret;
}
if (LJ::did_post()) {
if ($POST{'cancel_export'}) {
$ret .= $cancel_export->($iremote);
return BML::redirect("index.bml");
}
elsif ($POST{'export_options'}) {
$ret .= $export_options->($iremote);
return BML::redirect("index.bml") unless $ret;
}
else {
$ret .= $update_export_settings->($iremote);
}
}
my $dbh = LJ::get_db_writer();
if (!$dbh) {
return $err->("Can't get database writer!");
}
my $dbr = LJ::get_db_reader();
if (!$dbr) {
return $err->("Can't get database reader!");
}
my $sth1;
$sth1 = $dbr->prepare("SELECT * FROM ljr_export_settings WHERE user=?");
$sth1->execute($iremote);
my $r = $sth1->fetchrow_hashref;
$sth1->finish;
if (! $r->{'enabled'}) {
$ret .= "
Количество комментариев | |
Размер шрифта: | |
Цвет шрифта: | |