body<=
";
};
use strict;
use LJR::Distributed;
use vars qw(%POST %GET);
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 import 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;
my $e = 0;
my $dbr;
$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: import not allowed!");
return $ret;
}
if (LJ::did_post()) {
my $dbh = LJ::get_db_writer();
if (!$dbh) {
$ret .= $err->("Can't get database writer!");
$e = 1;
}
$dbr = LJ::get_db_reader();
if (!$dbr) {
$ret .= $err->("Can't get database reader!");
$e = 1;
}
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;
}
$iuser =~ s/\-/\_/;
my $ipassword = $POST{'password'};
unless (LJ::is_ascii($ipassword) && $ipassword ne "") {
$ret .= $err->("Invalid password!");
$e = 1;
}
my $iprotocol = $POST{'protocol'};
if ($iprotocol ne "flat" && $iprotocol ne "xml") {
$ret .= $err->("Invalid protocol specified!");
$e = 1;
}
# my $is_gated = LJR::Distributed::is_gated_remote ($iserver, $iuser);
# if ($is_gated) {
# $ret .= $err->("LJR::Gated users are currently not allowed to be imported. Sorry.");
# $e = 1;
# }
# $sth1 = $dbr->prepare("SELECT * FROM ljgate.alien WHERE alien=?");
# $sth1->execute($iuser);
# if ($sth1->fetchrow_hashref) {
# $ret .= $err->("Gated users are currently not allowed to be imported. Sorry.");
# $e = 1;
# }
# $sth1->finish;
my $sth1;
if (!$e) {
$sth1 = $dbr->prepare("SELECT * FROM ljr_iqueue WHERE local_user=?");
$sth1->execute($iremote);
if ($sth1->fetchrow_hashref) {
$dbh->do(
"update ljr_iqueue set remote_site=?, remote_user=?, remote_pass=?, remote_protocol=? " .
"where local_user=?;", undef, $iserver, $iuser, $ipassword, $iprotocol, $iremote);
return $err->($dbh->errstr) if $dbh->err;
}
else {
$sth1 = $dbr->prepare(
"SELECT * FROM ljr_ihistory WHERE local_user=?" .
" and idate > DATE_SUB(CURDATE(), INTERVAL 1 DAY);");
$sth1->execute($iremote);
my $num_actions = 0;
my $num_incorrect_logins = 0;
while (my $r = $sth1->fetchrow_hashref) {
if ($r->{istatus} =~ /Invalid password/) {
$num_incorrect_logins = $num_incorrect_logins + 1;
}
else {
$num_actions = $num_actions + 1;
}
}
if ($num_actions > 10 or $num_incorrect_logins > 5) {
$ret .= "
Извините, вы ввели слишком много заявок.
";
$ret .= "Возможность вводить новые заявки у вас появится завтра.";
return $ret;
}
else {
$dbh->do(
"insert into ljr_iqueue " .
"(remote_site, remote_user, remote_pass, remote_protocol, local_user, " .
"opt_overwrite, opt_comments, qdate) VALUES " .
"(?, ?, ?, ?, ?, '0', '1', now());",
undef, $iserver, $iuser, $ipassword, $iprotocol, $iremote);
return $err->($dbh->errstr) if $dbh->err;
}
}
$ret .= "
Ваша заявка успешно добавлена.";
$ret .= "
Вы можете просмотреть статус ваших заявок здесь.";
return $ret;
}
}
$ret .= "