Search Singles body<= \%countries, "state" => \%states }); # query page. unless ($GET{'status'}) { my ($status, $country, $state, $city, $age); if ($remote) { LJ::load_user_props($remote, "single_status", "single_pickw", "city", "country", "state"); ($status, $country, $state, $city, $age) = split(/\|/, $remote->{'single_status'}); $country ||= $remote->{'country'}; $state ||= $remote->{'state'}; $city ||= $remote->{'city'}; if (! $age && $remote->{'bdate'} =~ /^(\d\d\d\d)-(\d\d)-(\d\d)$/ && $3) { $age = int($dbr->selectrow_array("SELECT (unix_timestamp()-unix_timestamp('$remote->{'bdate'}'))/(60*60*24*365)")); $age = "" unless $age; } } $ret .= "
"; $ret .= " 'status', 'selected' => $status, }, "", "(Select Search Mode)", "MF", "Male; seeking female", "FM", "Female; seeking male", "MM", "Male; seeking male", "FF", "Female; seeking female", ); $ret .= "p?>"; $ret .= ""; $ret .= "Country: "; $ret .= LJ::html_select({ 'name' => 'country', 'selected' => $country }, '', '(Select Country)', map { $_, $countries{$_} } "US", sort { $countries{$a} cmp $countries{$b} } keys %countries); $ret .= " p?>"; my $estate = LJ::ehtml($state); $ret .= "State: p?>\n"; my $ecity = LJ::ehtml($city); $ret .= "City: p?>\n"; $ret .= " and p?>\n"; # search results $ret .= "
"; if (LJ::get_cap($remote, "paid")) { $ret .= " Text "; $ret .= " Pictures"; } else { $ret .= " Text "; $ret .= " Pictures (paid users only)"; } $ret .= "
"; # done $ret .= ""; $ret .= "

"; $ret .= "
"; return $ret; } # verify/clean search data. if ($GET{'country'} eq "US" && length($GET{'state'}) > 2) { foreach (keys %states) { $GET{'state'} = $_ if (lc($states{$_}) eq $GET{'state'}); } } return LJ::bad_input("Must enter min and max ages") unless ($GET{'age1'} && $GET{'age2'}); return LJ::bad_input("LiveJournal Singles is for users 18 years of age and older.") unless ($GET{'age1'} >= 18 && $GET{'age2'} >= 18); my $revstatus = { 'MF' => 'FM', 'FM' => 'MF', 'MM' => 'MM', 'FF' => 'FF', }->{$GET{'status'}}; my $prefix = join("|", $revstatus, map { $GET{$_} } qw(country state city)); my $propid = $dbr->selectrow_array("SELECT upropid FROM userproplist WHERE name='single_status'"); return "Missing db lookup info" unless $propid; my $matches = $dbr->selectcol_arrayref("SELECT userid FROM userprop WHERE upropid=$propid ". "AND value BETWEEN ? AND ? LIMIT 5000", undef, "$prefix|$GET{'age1'}", "$prefix|$GET{'age2'}"); unless ($matches && @$matches) { return ""; } my %page = BML::paging($matches, $GET{'page'}, 100); $ret .= "

<< New Search"; $ret .= "Page $page{'page'} of $page{'pages'} $page{'nextlink'} standout?>"; my @userids = @{$page{'items'}}; # who's on this page. my $userid_in = join(",", @userids); my %user; # info on those people my $sth; # pics to load my %userpic; # base info. $sth = $dbr->prepare("SELECT * FROM user WHERE userid IN ($userid_in) AND statusvis = 'V'"); $sth->execute; while ($_ = $sth->fetchrow_hashref) { $user{$_->{'userid'}} = $_; $userpic{$_->{'defaultpicid'}} = undef if $_->{'defaultpicid'}; } unless (%user) { return ""; } # get ages of just this page $sth = $dbr->prepare("SELECT userid, value FROM userprop WHERE upropid=$propid ". "AND userid IN ($userid_in)"); $sth->execute; while (my ($id, $val) = $sth->fetchrow_array) { next unless $val =~ /\|(\d+)$/; next unless $user{$id}; $user{$id}->{'age'} = $1; } # preferred pictures? $propid = $dbr->selectrow_array("SELECT upropid FROM userproplist WHERE name='single_pickw'"); return "Missing db lookup info" unless $propid; $sth = $dbr->prepare(qq{ SELECT m.userid, m.picid FROM userpicmap m, userproplite u, keywords k WHERE u.userid IN ($userid_in) AND upropid=$propid AND u.value=k.keyword AND u.userid=m.userid AND m.kwid=k.kwid }); $sth->execute; my @userpic_load; while (my ($userid, $picid) = $sth->fetchrow_array) { next unless $user{$userid}; delete $userpic{$user{$userid}->{'defaultpicid'}}; $user{$userid}->{'defaultpicid'} = $picid; $userpic{$picid} = undef; push @userpic_load, [ $user{$userid}, $picid ]; } # load pictures LJ::load_userpics(\%userpic, \@userpic_load); my $with_pics = $GET{'mode'} eq "pics" && LJ::get_cap($remote, "paid"); if ($with_pics) { $ret .= "\n"; } else { $ret .= ""; } else { $ret .= "
  • " . LJ::ljuser($u) . ", $u->{'age'} - " . LJ::ehtml($u->{'name'}) . ""; } } if ($with_pics) { $ret .= "
  • "; if ($u->{'defaultpicid'}) { my $id = $u->{'defaultpicid'}; $ret .= ""; } $ret .= "" . LJ::ljuser($u) . ", $u->{'age'} - " . LJ::ehtml($u->{'name'}) . "
    \n"; } else { $ret .= ""; } return $ret; } _code?> <=body page?>