Send a Text Message
body<=
";
$ret .= "
";
foreach my $p (LJ::TextMessage::providers()) {
my $info = LJ::TextMessage::provider_info($p);
$ret .= "$info->{'name'} (from: $info->{'fromlimit'}, msg: $info->{'msglimit'}, total: $info->{'totlimit'})
$info->{'notes'}";
}
$ret .= "
";
&add_footer();
return $ret;
}
unless ($user) {
$ret .= " p?>";
&add_footer();
return $ret;
}
my $u = LJ::load_user($user);
my $tminfo;
if ($u->{'txtmsg_status'} eq "on") {
my $dbr = LJ::get_db_reader();
$tminfo = $dbr->selectrow_hashref("SELECT provider, number, security ".
"FROM txtmsg WHERE userid=$u->{'userid'}")
}
unless (LJ::get_cap($u, "textmessaging")) {
$ret .= "";
&add_footer();
return $ret;
}
unless ($tminfo) {
$ret .= "";
&add_footer();
return $ret;
}
my $remote;
if ($tminfo->{'security'} ne "all") {
$remote = LJ::get_remote();
my $andbefriend;
if ($tminfo->{'security'} eq "friends") {
$andbefriend = " and be listed as their friend";
}
unless ($remote) {
$ret .= "logged in$andbefriend. p?>";
&add_footer();
return $ret;
}
if ($tminfo->{'security'} eq "friends" && $u->{'userid'} != $remote->{'userid'}) {
unless (LJ::is_friend($u->{'userid'}, $remote->{'userid'})) {
$ret .= "$u->{'user'} has selected \"friends only\" as the security level required to send text messages to them. p?>";
&add_footer();
return $ret;
}
}
}
###### authorized.
if ($FORM{'message'}) {
my $message = $FORM{'message'};
my $from = $tminfo->{'security'} eq "all" ? $FORM{'from'} : $remote->{'user'};
my $phone = new LJ::TextMessage { 'provider' => $tminfo->{'provider'},
'number' => $tminfo->{'number'},
'mailcommand' => $LJ::SENDMAIL,
'smtp' => $LJ::SMTP_SERVER,
};
my @errors;
$phone->send({ 'from' => $from,
'message' => $message, },
\@errors);
# strip numbers from error messages
s/(\d{3,})/'x'x length $1/eg foreach @errors;
return LJ::bad_input(@errors) if @errors;
$ret .= "";
&add_footer();
return $ret;
}
my $pinfo = LJ::TextMessage::provider_info($tminfo->{'provider'});
$ret .= "$u->{'user'}. p?>";
$ret .= "";
&add_footer();
return $ret;
sub add_footer
{
my $howwork = $LJ::HELP_URL{'textmessaging_about'} ? "How does this feature work? Read this.
" : "";
$ret .= "
$howworkDisclaimer: The reliability of text messaging should not be trusted in dealing with emergencies.";
}
}
_code?>
<=body
page?>
lib: LJ::TextMessage
link: htdocs/login.bml, htdocs/support/faqbrowse.bml
form: htdocs/tools/textmessage.bml
post: htdocs/tools/textmessage.bml
_c?>