| 1 | (=PAGE |
|---|
| 2 | TITLE=>Edit Personal Information |
|---|
| 3 | BODY<= |
|---|
| 4 | (=_CODE |
|---|
| 5 | |
|---|
| 6 | return LJ::server_down_html() if ($LJ::SERVER_DOWN); |
|---|
| 7 | |
|---|
| 8 | return "(=BADINPUT=)" unless LJ::text_in(\%FORM); |
|---|
| 9 | |
|---|
| 10 | my $dbs = LJ::get_dbs(); |
|---|
| 11 | my $dbh = $dbs->{'dbh'}; |
|---|
| 12 | my $dbr = $dbs->{'reader'}; |
|---|
| 13 | |
|---|
| 14 | my $ret; |
|---|
| 15 | my $remote = LJ::get_remote($dbs); |
|---|
| 16 | my $mode = $FORM{'mode'} || ($remote && $FORM{'authas'} ne "(other)" ? "modify" : "loginform"); |
|---|
| 17 | |
|---|
| 18 | if ($mode eq "loginform") |
|---|
| 19 | { |
|---|
| 20 | $ret .= "(=H1 Edit Personal Information H1=)(=P Enter your username and password to modify your personal information. P=)"; |
|---|
| 21 | $ret .= "<form action='editinfo.bml' method='post'>"; |
|---|
| 22 | $ret .= "<input type='hidden' name='mode' value='modify'>"; |
|---|
| 23 | $ret .= "(=STANDOUT <table> "; |
|---|
| 24 | $ret .= LJ::auth_fields_2($dbs, \%FORM, { 'shared' => 1, 'getother' => 1 }); |
|---|
| 25 | $ret .= "<tr><td colspan='2' align='center'><input type='submit' value='Proceed...'>"; |
|---|
| 26 | $ret .= "</td></tr></table> STANDOUT=)</form>\n"; |
|---|
| 27 | $ret .= "(=H1 Forget something? H1=)(=P If you forgot your username or password, "; |
|---|
| 28 | $ret .= "<a href='lostinfo.bml'>recover it here!</a>. P=)"; |
|---|
| 29 | return $ret; |
|---|
| 30 | } |
|---|
| 31 | my ($u, $user, $err); |
|---|
| 32 | my $user = LJ::get_effective_user($dbs, { |
|---|
| 33 | 'form' => \%FORM, |
|---|
| 34 | 'out_u' => \$u, |
|---|
| 35 | 'remote' => $remote, |
|---|
| 36 | 'out_err' => \$err, |
|---|
| 37 | }); |
|---|
| 38 | |
|---|
| 39 | return $LJ::MSG_READONLY_USER if LJ::get_cap($remote, "readonly"); |
|---|
| 40 | |
|---|
| 41 | return LJ::bad_input($err) if $err; |
|---|
| 42 | |
|---|
| 43 | $u ||= LJ::load_user($dbs, $user); |
|---|
| 44 | return LJ::bad_input("Invalid username") unless $u; |
|---|
| 45 | |
|---|
| 46 | my $hpassword = LJ::hash_password($u->{'password'}); |
|---|
| 47 | |
|---|
| 48 | LJ::load_user_props($dbr, $u, "opt_whatemailshow", |
|---|
| 49 | "opt_showtopicstuff", "country", "state", "city", |
|---|
| 50 | "zip", "icq", "aolim", "yahoo", "msn", "url", |
|---|
| 51 | "urlname", "gender", "jabber", "opt_blockrobots", |
|---|
| 52 | "opt_notalkicons", "opt_logcommentips", |
|---|
| 53 | "howhear", "opt_bdaymail", "opt_hidefriendofs", |
|---|
| 54 | "sidx_bdate", "sidx_loc", "mailencoding", |
|---|
| 55 | ); |
|---|
| 56 | |
|---|
| 57 | foreach (values %$u) { LJ::text_out(\$_); } |
|---|
| 58 | |
|---|
| 59 | my $quser = $dbr->quote($user); |
|---|
| 60 | |
|---|
| 61 | my $dbcs = $dbs; |
|---|
| 62 | my $clustered = $u->{'clusterid'}; |
|---|
| 63 | $dbcs = LJ::get_cluster_set($u) if $clustered; |
|---|
| 64 | |
|---|
| 65 | if ($u->{'has_bio'}) { |
|---|
| 66 | $u->{'bio'} = LJ::dbs_selectrow_array($dbcs, "SELECT bio FROM userbio ". |
|---|
| 67 | "WHERE userid=$u->{'userid'}"); |
|---|
| 68 | LJ::text_out(\$u->{'bio'}); |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | $sth = $dbr->prepare("SELECT i.interest, i.intid FROM interests i, userinterests ui WHERE i.intid=ui.intid AND ui.userid=$u->{'userid'}"); |
|---|
| 72 | $sth->execute; |
|---|
| 73 | my %interests = (); |
|---|
| 74 | while ($_ = $sth->fetchrow_hashref) { |
|---|
| 75 | $interests{$_->{'interest'}} = $_->{'intid'}; |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | my %countries; |
|---|
| 79 | my %states; |
|---|
| 80 | LJ::load_codes($dbs, { "country" => \%countries, "state" => \%states }); |
|---|
| 81 | |
|---|
| 82 | my $mode = $FORM{'mode'} || "modify"; |
|---|
| 83 | |
|---|
| 84 | if ($mode eq "modify") |
|---|
| 85 | { |
|---|
| 86 | my $ret = ""; |
|---|
| 87 | |
|---|
| 88 | if ($remote) { |
|---|
| 89 | $ret .= "<form method='post'>"; |
|---|
| 90 | $ret .= "(=H1 Switch Journal H1=)(=P Work with journal: "; |
|---|
| 91 | $ret .= LJ::make_shared_select($dbs, $remote, \%FORM); |
|---|
| 92 | $ret .= " <input type='submit' value='Switch'> P=)</form>"; |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | $ret .= "<FORM METHOD=POST>\n"; |
|---|
| 96 | $ret .= "<INPUT TYPE=HIDDEN NAME=mode VALUE=domodify>\n"; |
|---|
| 97 | $ret .= "<INPUT TYPE=HIDDEN NAME=user VALUE=(=_EH $user _EH=)>\n"; |
|---|
| 98 | $ret .= "<INPUT TYPE=HIDDEN NAME=hpassword VALUE=\"$hpassword\">\n"; |
|---|
| 99 | |
|---|
| 100 | ### personal information |
|---|
| 101 | $ret .= "(=H1 Personal Information H1=)(=P Fill in some quick information about yourself, for our own curiosity and statistical purposes. We're not going to do anything evil or annoying with this information, we'd just like to see who and where our users are. Please, fill it in correctly. If you're concerned, read our <A HREF=\"/legal/privacy.bml\">privacy policy</A>. P=)\n"; |
|---|
| 102 | |
|---|
| 103 | my %htmlu = (); |
|---|
| 104 | foreach my $v (qw(name email url urlname zip city url aolim jabber icq yahoo msn howhear bio)) |
|---|
| 105 | { |
|---|
| 106 | $htmlu{$v} = BMLUtil::escapeall($u->{$v}); |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | $ret .= "<P><TABLE WIDTH=100%>\n"; |
|---|
| 110 | |
|---|
| 111 | # name |
|---|
| 112 | $ret .= "<TR><TD ALIGN=RIGHT BGCOLOR=(=EMCOLOR=)>Name</TD><TD><INPUT NAME=name VALUE=\"$htmlu{'name'}\" MAXLENGTH=50></TD></TR>\n"; |
|---|
| 113 | |
|---|
| 114 | # birthday |
|---|
| 115 | $ret .= "<TR><TD ALIGN=RIGHT BGCOLOR=(=EMCOLOR=)>Birthday</TD><TD>"; |
|---|
| 116 | my %bdpart; |
|---|
| 117 | if ($u->{'bdate'} =~ /^(\d\d\d\d)-(\d\d)-(\d\d)$/) |
|---|
| 118 | { |
|---|
| 119 | ($bdpart{'year'}, $bdpart{'month'}, $bdpart{'day'}) = ($1, $2, $3); |
|---|
| 120 | if ($bdpart{'year'} eq "0000") { $bdpart{'year'} = ""; } |
|---|
| 121 | if ($bdpart{'day'} eq "00") { $bdpart{'day'} = ""; } |
|---|
| 122 | } |
|---|
| 123 | $ret .= "<SELECT NAME=\"month\"><OPTION VALUE=\"\">"; |
|---|
| 124 | for (my $i=1; $i<=12; $i++) { |
|---|
| 125 | my $sel = $bdpart{'month'} == $i ? " SELECTED" : ""; |
|---|
| 126 | $ret .= "<OPTION VALUE=$i$sel>" . LJ::Lang::month_long("EN", $i) . "\n"; |
|---|
| 127 | } |
|---|
| 128 | $ret .= "</SELECT> "; |
|---|
| 129 | $ret .= "<INPUT SIZE=3 MAXLENGTH=2 NAME=day VALUE=\"$bdpart{'day'}\">, <INPUT SIZE=5 MAXLENGTH=4 NAME=year VALUE=\"$bdpart{'year'}\"> (year is optional)"; |
|---|
| 130 | |
|---|
| 131 | $ret .= "</TD></TR>\n"; |
|---|
| 132 | |
|---|
| 133 | # gender |
|---|
| 134 | $ret .= "<TR><TD ALIGN=RIGHT BGCOLOR=(=EMCOLOR=)>Gender</TD><TD><SELECT NAME=\"gender\">"; |
|---|
| 135 | my @gender = ("U" => "(Unspecified)", "M" => "Male", "F" => "Female"); |
|---|
| 136 | while (my ($g, $gword)=splice(@gender, 0, 2)) |
|---|
| 137 | { |
|---|
| 138 | my $sel = $u->{'gender'} eq $g ? " SELECTED" : ""; |
|---|
| 139 | $ret .= "<OPTION VALUE=\"$g\"$sel>$gword\n"; |
|---|
| 140 | } |
|---|
| 141 | $ret .= "</SELECT></TD></TR>\n"; |
|---|
| 142 | |
|---|
| 143 | # email |
|---|
| 144 | $ret .= "<TR><TD ALIGN=RIGHT BGCOLOR=(=EMCOLOR=)>Email</TD><TD><INPUT NAME=email VALUE=\"$htmlu{'email'}\" MAXLENGTH=50 SIZE=40></TD></TR>\n"; |
|---|
| 145 | |
|---|
| 146 | # url |
|---|
| 147 | $ret .= "<TR><TD ALIGN=RIGHT BGCOLOR=(=EMCOLOR=)>Webpage URL</TD><TD><INPUT NAME=url VALUE=\"$htmlu{'url'}\" SIZE=40> (opt.)</TD></TR>\n"; |
|---|
| 148 | |
|---|
| 149 | # urlname |
|---|
| 150 | $ret .= "<TR><TD ALIGN=RIGHT BGCOLOR=(=EMCOLOR=)>Webpage Name</TD><TD><INPUT NAME=urlname VALUE=\"$htmlu{'urlname'}\" SIZE=40> (opt.)</TD></TR>\n"; |
|---|
| 151 | |
|---|
| 152 | # chat thingies |
|---|
| 153 | foreach my $p (["aolim", "AOL IM", 16], ["icq", "ICQ \#", 12], |
|---|
| 154 | ["yahoo", "Yahoo! ID", 33], ["msn", "MSN Messenger", 60], |
|---|
| 155 | ["jabber", "Jabber Address", 60]) |
|---|
| 156 | { |
|---|
| 157 | $ret .= "<TR><TD ALIGN=RIGHT BGCOLOR=(=EMCOLOR=)>$p->[1]</TD><TD><INPUT NAME=\"$p->[0]\" VALUE=\"$htmlu{$p->[0]}\" SIZE=20 MAXLENGTH=$p->[2]> (opt.)</TD></TR>\n"; |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | # country |
|---|
| 161 | $ret .= "<TR><TD ALIGN=RIGHT BGCOLOR=(=EMCOLOR=)>Country</TD><TD><SELECT NAME=country><OPTION VALUE=\"\">(Pick a country)\n"; |
|---|
| 162 | $ret .= "<OPTION VALUE=\"US\">United States\n"; |
|---|
| 163 | foreach (sort { $countries{$a} cmp $countries{$b} } keys %countries) |
|---|
| 164 | { |
|---|
| 165 | my $sel = $_ eq $u->{'country'} ? " SELECTED" : ""; |
|---|
| 166 | $ret .= "<OPTION VALUE=\"$_\"$sel>$countries{$_}\n"; |
|---|
| 167 | } |
|---|
| 168 | $ret .= "</SELECT></TD></TR>\n"; |
|---|
| 169 | |
|---|
| 170 | # city |
|---|
| 171 | $ret .= "<TR><TD ALIGN=RIGHT BGCOLOR=(=EMCOLOR=)>City</TD><TD><INPUT NAME=city VALUE=\"$htmlu{'city'}\"></TD></TR>\n"; |
|---|
| 172 | |
|---|
| 173 | # state |
|---|
| 174 | $ret .= "<TR><TD ALIGN=RIGHT BGCOLOR=(=EMCOLOR=)>State</TD><TD><SELECT NAME=statedrop><OPTION VALUE=\"\">(US States)\n"; |
|---|
| 175 | foreach (sort { $states{$a} cmp $states{$b} } keys %states) |
|---|
| 176 | { |
|---|
| 177 | my $sel = $_ eq $u->{'state'} ? " SELECTED" : ""; |
|---|
| 178 | $ret .= "<OPTION VALUE=\"$_\"$sel>$states{$_}\n"; |
|---|
| 179 | } |
|---|
| 180 | my $otherstate = BMLUtil::escapeall(defined($states{$u->{'state'}}) ? "" : $u->{'state'}); |
|---|
| 181 | $ret .= "</SELECT><BR>Or, type other state/province/territory: <INPUT NAME=stateother SIZE=20 MAXLENGTH=50 VALUE=\"$otherstate\"></TD></TR>\n"; |
|---|
| 182 | |
|---|
| 183 | # zip |
|---|
| 184 | $ret .= "<TR><TD ALIGN=RIGHT BGCOLOR=(=EMCOLOR=)>ZIP Code</TD><TD><INPUT NAME=zip VALUE=\"$htmlu{'zip'}\" SIZE=6 MAXLENGTH=5> (5 digit ZIP code; US residents only)</TD></TR>\n"; |
|---|
| 185 | |
|---|
| 186 | # text messaging |
|---|
| 187 | if (LJ::get_cap($u, "textmessaging")) |
|---|
| 188 | { |
|---|
| 189 | $sth = $dbr->prepare("SELECT provider, number, security FROM txtmsg WHERE userid=$u->{'userid'}"); |
|---|
| 190 | $sth->execute; |
|---|
| 191 | my $tminfo = $sth->fetchrow_hashref; |
|---|
| 192 | foreach (values %$tminfo) { LJ::text_out(\$_); } |
|---|
| 193 | |
|---|
| 194 | # text messaging |
|---|
| 195 | $ret .= "<TR VALIGN=TOP><TD ALIGN=RIGHT BGCOLOR=(=EMCOLOR=)>Text Messaging<BR>(<A HREF=\"/support/faqbrowse.bml?faqid=30\">about this feature</A>)</TD><TD>"; |
|---|
| 196 | $ret .= "<TABLE BORDER=0><TR><TD>"; |
|---|
| 197 | $ret .= "<INPUT TYPE=CHECKBOX NAME=\"use_txtmsg\" " . ($u->{'txtmsg_status'} eq "on" ? "CHECKED" : "") . "></TD><TD COLSPAN=2><B>Enable text messaging from other users.</B></TD></TR>"; |
|---|
| 198 | $ret .= "<TR><TD ROWSPAN=3> </TD><TD>Security Level:</TD><TD>"; |
|---|
| 199 | my %levels = ("all" => "Anybody", |
|---|
| 200 | "reg" => "Registered Users", |
|---|
| 201 | "friends" => "Friends only"); |
|---|
| 202 | my @levels = qw(all reg friends); |
|---|
| 203 | $ret .= "<SELECT NAME=\"txtmsg_security\">"; |
|---|
| 204 | foreach my $lev (@levels) { |
|---|
| 205 | my $sel = $tminfo->{'security'} eq $lev ? " SELECTED" : ""; |
|---|
| 206 | $ret .= "<OPTION VALUE=\"$lev\"$sel>$levels{$lev}\n"; |
|---|
| 207 | } |
|---|
| 208 | $ret .= "</SELECT>\n"; |
|---|
| 209 | $ret .= "</TD></TR>"; |
|---|
| 210 | $ret .= "<TR><TD>Service Provider:</TD><TD>"; |
|---|
| 211 | { |
|---|
| 212 | my @opts = ("", ""); |
|---|
| 213 | foreach my $p (LJ::TextMessage::providers()) { |
|---|
| 214 | my $info = LJ::TextMessage::provider_info($p); |
|---|
| 215 | push @opts, ($p, $info->{'name'}); |
|---|
| 216 | } |
|---|
| 217 | $ret .= LJ::html_select({ 'name' => 'txtmsg_provider', |
|---|
| 218 | 'selected' => $tminfo->{'provider'}, }, |
|---|
| 219 | @opts); |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | $ret .= " (<A HREF=\"/tools/textmessage.bml?mode=details\">details</A>)</TD></TR>"; |
|---|
| 223 | $ret .= "<TR><TD>Full phone #:</TD><TD><INPUT NAME=\"txtmsg_number\" SIZE=15 MAXLENGTH=40 VALUE=\"$tminfo->{'number'}\"></TD></TR>"; |
|---|
| 224 | $ret .= "</TABLE></TD></TR>\n"; |
|---|
| 225 | } |
|---|
| 226 | |
|---|
| 227 | # end personal info |
|---|
| 228 | $ret .= "</TABLE>\n"; |
|---|
| 229 | |
|---|
| 230 | ### User bio |
|---|
| 231 | $ret .= "(=H1 About You H1=)(=P Here you can enter a little mini-biography about yourself that will show up on your user-info page.... P=)"; |
|---|
| 232 | $ret .= "<UL><TEXTAREA NAME=bio ROWS=10 COLS=50 WRAP=SOFT>$htmlu{'bio'}</TEXTAREA></UL>"; |
|---|
| 233 | |
|---|
| 234 | ### How heard Settings |
|---|
| 235 | unless ($htmlu{'howhear'}) { |
|---|
| 236 | $ret .= "(=H1 Curiosity H1=)(=P Just for my own curiosity, where did you hear about $LJ::SITENAME from? If it was a specific person, enter their LiveJournal username, if it was from another source/article/link/website, tell us where.... "; |
|---|
| 237 | $ret .= "<UL><INPUT NAME=howhear VALUE=\"$htmlu{'ints'}\" SIZE=60 MAXLENGTH=100></UL>"; |
|---|
| 238 | $ret .= " P=)"; |
|---|
| 239 | } |
|---|
| 240 | |
|---|
| 241 | { |
|---|
| 242 | ### Interests |
|---|
| 243 | my $eints = BMLUtil::escapeall(join(", ", sort keys %interests)); |
|---|
| 244 | LJ::text_out(\$eints); |
|---|
| 245 | $ret .= "(=H1 Interests H1=)(=P If you want other people to be able to search the directory and find you by interest, list below everything you're interested in, separated by commas. Short single-word phrases are best. <B>Rule of thumb:</B> You should be able to put the interest in the sentence \"I like ________\". When referring to nouns, use the plural form for consistency. \"I like DVDs\" instead of \"I like DVD\". P=)"; |
|---|
| 246 | $ret .= "(=P <FONT COLOR=#009000><B>GOOD</B></FONT> Example: <B>biking, snow skiing, computers, dvds, mp3s, cheese, women</B> P=)"; |
|---|
| 247 | $ret .= "(=P <FONT COLOR=#FF0000><B>BAD</B></FONT> Example: <B>I like lots of bands and watching movies and talking to friends and going to clubs.</B> That sort of stuff goes in your bio above. P=)"; |
|---|
| 248 | $ret .= "<UL><TEXTAREA NAME=interests ROWS=10 COLS=50 WRAP=SOFT>$eints</TEXTAREA></UL>"; |
|---|
| 249 | } |
|---|
| 250 | #line 172 |
|---|
| 251 | |
|---|
| 252 | ### Picture Settings |
|---|
| 253 | $ret .= "(=H1 Your Picture H1=)(=P Below is the miniature picture you have uploaded to represent you throughout the LiveJournal site and in your journal and in your friends' journals... \n<P><CENTER>"; |
|---|
| 254 | if ($u->{'defaultpicid'}) |
|---|
| 255 | { |
|---|
| 256 | my $picid = $u->{'defaultpicid'}; |
|---|
| 257 | LJ::load_userpics($dbs, \%userpics, [ $picid ]); |
|---|
| 258 | $ret .= "<IMG SRC=\"/userpic/$picid\" WIDTH=$userpics{$picid}->{'width'} HEIGHT=$userpics{$picid}->{'height'}>"; |
|---|
| 259 | } else |
|---|
| 260 | { |
|---|
| 261 | $ret .= "<I>(no image uploaded)</I>"; |
|---|
| 262 | } |
|---|
| 263 | $ret .= "</CENTER><P>To delete this picture, or upload a new one, <A HREF=\"/uploadpic.bml\" TARGET=_blank>go here</A>. P=)\n"; |
|---|
| 264 | |
|---|
| 265 | |
|---|
| 266 | ### Permission Settings |
|---|
| 267 | $ret .= "(=H1 LiveJournal Options H1=)(=P Select below your personal privacy options and preferences. P=)"; |
|---|
| 268 | $ret .= "<P><TABLE>\n"; |
|---|
| 269 | |
|---|
| 270 | my $checked; |
|---|
| 271 | $checked = $u->{'allow_infoshow'} eq "Y" ? "CHECKED" : ""; |
|---|
| 272 | $ret .= "<TR VALIGN=MIDDLE><TD WIDTH=50 ALIGN=RIGHT><INPUT TYPE=CHECKBOX NAME=allow_infoshow $checked></TD><TD><B>Show location & birthday</B></TD></TR>\n"; |
|---|
| 273 | $ret .= "<TR><TD> </TD><TD>Turn this on if you want your city/state/country and birthday to be visible to other users.</TD></TR>\n"; |
|---|
| 274 | |
|---|
| 275 | $checked = $u->{'allow_contactshow'} ne "N" ? "CHECKED" : ""; |
|---|
| 276 | $ret .= "<tr valign=middle><td width=50 align=right><input type=checkbox name=allow_contactshow $checked></td><td><b>Show your contact information on your LiveJournal?</b></td></tr>\n"; |
|---|
| 277 | $ret .= "<tr><td> </td><td>You should keep this option enabled. This lets other people be able to contact you by showing your email address, ICQ number, and AOL Instant Messenger screenname all on your LiveJournal."; |
|---|
| 278 | |
|---|
| 279 | { |
|---|
| 280 | $ret .= "<p><b>Security:</b> "; |
|---|
| 281 | $ret .= LJ::html_select({ 'name' => 'contactshow_sec', |
|---|
| 282 | 'selected' => $u->{'allow_contactshow'}, |
|---|
| 283 | }, |
|---|
| 284 | "Y" => "Everybody", |
|---|
| 285 | "F" => "Friends only", |
|---|
| 286 | ); |
|---|
| 287 | |
|---|
| 288 | $ret .= "<p><b>If visible, email address to be displayed:</b><ul>"; |
|---|
| 289 | |
|---|
| 290 | my $cur = $u->{'opt_whatemailshow'} || "B"; |
|---|
| 291 | my @vals = ( ($LJ::USER_EMAIL && LJ::get_cap($u, "useremail")) |
|---|
| 292 | ? ("B" => "Both (actual + \@$LJ::USER_DOMAIN)", |
|---|
| 293 | "A" => "Actual address only", |
|---|
| 294 | "L" => "LiveJournal address only", |
|---|
| 295 | "N" => "Neither. Don't show any email address.") |
|---|
| 296 | : ("A" => "Show email address", |
|---|
| 297 | "N" => "Don't show email address")); |
|---|
| 298 | $ret .= "<SELECT NAME=\"opt_whatemailshow\">"; |
|---|
| 299 | while (my ($key, $des) = splice(@vals, 0, 2)) { |
|---|
| 300 | my $sel = $key eq $cur ? "SELECTED" : ""; |
|---|
| 301 | $ret .= "<OPTION VALUE=\"$key\" $sel>$des"; |
|---|
| 302 | } |
|---|
| 303 | $ret .= "</SELECT>"; |
|---|
| 304 | |
|---|
| 305 | $ret .= "</ul>If you checked the above option, you may also choose to hide your email address (while still showing other contact information)"; |
|---|
| 306 | $ret .= ($LJ::USER_EMAIL |
|---|
| 307 | ? ", only show your livejournal email address (<A HREF=\"$LJ::SITEROOT/paidaccounts/\">paid accounts</A> only), or to show them both." |
|---|
| 308 | : "."); |
|---|
| 309 | } |
|---|
| 310 | |
|---|
| 311 | $ret .= "</TD></TR>\n"; |
|---|
| 312 | |
|---|
| 313 | $checked = $u->{'opt_mangleemail'} eq "Y" ? "CHECKED" : ""; |
|---|
| 314 | $ret .= "<TR VALIGN=MIDDLE><TD WIDTH=50 ALIGN=RIGHT><INPUT TYPE=CHECKBOX NAME=opt_mangleemail $checked></TD><TD><B>Mangle your displayed email address</B></TD></TR>\n"; |
|---|
| 315 | $ret .= "<TR><TD> </TD><TD>If you have the above option selected and are afraid spam-robots will find your email address on LiveJournal, select this option and your email address will be modified so your email address won't be found by email-collecting robots.</TD></TR>\n"; |
|---|
| 316 | |
|---|
| 317 | $checked = $u->{'opt_blockrobots'} ? "CHECKED" : ""; |
|---|
| 318 | $ret .= "<TR VALIGN=MIDDLE><TD WIDTH=50 ALIGN=RIGHT><INPUT TYPE=CHECKBOX NAME=opt_blockrobots VALUE=1 $checked></TD><TD><B>Block Robots/Spiders from indexing your journal</B></TD></TR>\n"; |
|---|
| 319 | $ret .= "<TR><TD> </TD><TD>If you check this option, robots will be told to go away. Not all robots respect the rules, but the popular search sites' robots do.</TD></TR>\n"; |
|---|
| 320 | |
|---|
| 321 | $checked = $u->{'allow_getljnews'} eq "Y" ? "CHECKED" : ""; |
|---|
| 322 | $ret .= "<TR VALIGN=MIDDLE><TD WIDTH=50 ALIGN=RIGHT><INPUT TYPE=CHECKBOX NAME=allow_getljnews $checked></TD><TD><B>Send me LiveJournal news.</B></TD></TR>\n"; |
|---|
| 323 | $ret .= "<TR><TD> </TD><TD>If you want to know when we add some cool new feature to LiveJournal, check this box. The emails you get will be pretty rare, no more than once or twice a month usually. Your email address will not be visible to other users, and you can turn this off at anytime.</TD></TR>\n"; |
|---|
| 324 | |
|---|
| 325 | $checked = $u->{'opt_bdaymail'} ? "CHECKED" : ""; |
|---|
| 326 | $ret .= "<TR VALIGN=MIDDLE><TD WIDTH=50 ALIGN=RIGHT><INPUT TYPE=CHECKBOX NAME=opt_bdaymail $checked></TD><TD><B>Send me birthday reminders</B></TD></TR>\n"; |
|---|
| 327 | $ret .= "<TR><TD> </TD><TD>If you want to get email reminding you of birthdays for your friends on LiveJournal, click this box.</TD></TR>\n"; |
|---|
| 328 | |
|---|
| 329 | $checked = $u->{'opt_hidefriendofs'} ? "CHECKED" : ""; |
|---|
| 330 | $ret .= "<TR VALIGN=MIDDLE><TD WIDTH=50 ALIGN=RIGHT><INPUT TYPE=CHECKBOX NAME=opt_hidefriendofs $checked></TD><TD><B>Hide \"Friend of\" list</B></TD></TR>\n"; |
|---|
| 331 | $ret .= "<TR><TD> </TD><TD>If you check this, the list of people that list you as a friend is hidden on your profile page.</TD></TR>\n"; |
|---|
| 332 | |
|---|
| 333 | $checked = $u->{'opt_showtalklinks'} eq "Y" ? "CHECKED" : ""; |
|---|
| 334 | $ret .= "<TR VALIGN=MIDDLE><TD WIDTH=50 ALIGN=RIGHT><INPUT TYPE=CHECKBOX NAME=opt_showtalklinks $checked></TD><TD><B>Enable message boards</B></TD></TR>\n"; |
|---|
| 335 | $ret .= "<TR><TD> </TD><TD>Check this if you want people to be able to reply to journal entries you post. (the journal style you select must also support this)\n"; |
|---|
| 336 | |
|---|
| 337 | $ret .= "<P><B>Who can reply to your entries?</B> "; |
|---|
| 338 | $ret .= LJ::html_select({ 'name' => 'opt_whocanreply', 'selected' => $u->{'opt_whocanreply'}, }, |
|---|
| 339 | "all" => "Anybody", "reg" => "Registered Users", "friends" => "Friends only"); |
|---|
| 340 | |
|---|
| 341 | $ret .= "<P><B>Log IP addresses of people replying?</B> "; |
|---|
| 342 | $ret .= LJ::html_select({ 'name' => 'opt_logcommentips', 'selected' => $u->{'opt_logcommentips'}, }, |
|---|
| 343 | "N" => "No", "S" => "Anonymous posters only", "A" => "Always"); |
|---|
| 344 | |
|---|
| 345 | $ret .= "<P><TABLE>\n"; |
|---|
| 346 | |
|---|
| 347 | $checked = $u->{'opt_gettalkemail'} eq "Y" ? "CHECKED" : ""; |
|---|
| 348 | $ret .= "<TR VALIGN=MIDDLE><TD WIDTH=50 ALIGN=RIGHT><INPUT TYPE=CHECKBOX NAME=opt_gettalkemail $checked></TD><TD><B>Get message board replies</B></TD></TR>\n"; |
|---|
| 349 | $ret .= "<TR><TD> </TD><TD>Check this if you want to get email updates when people reply to your journal entries in the message boards.</TD></TR>\n"; |
|---|
| 350 | |
|---|
| 351 | $checked = $u->{'opt_htmlemail'} eq "Y" ? "CHECKED" : ""; |
|---|
| 352 | $ret .= "<TR VALIGN=MIDDLE><TD WIDTH=50 ALIGN=RIGHT><INPUT TYPE=CHECKBOX NAME=opt_htmlemail $checked></TD><TD><B>Send HTML Emails</B></TD></TR>\n"; |
|---|
| 353 | $ret .= "<TR><TD> </TD><TD>Check this if your email program fully supports HTML in your email. Many clients try to support it but fail horribly. If you uncheck it, LiveJournal will only send text emails.</TD></TR>\n"; |
|---|
| 354 | |
|---|
| 355 | $checked = $u->{'opt_notalkicons'} ? "" : "CHECKED"; |
|---|
| 356 | $ret .= "<TR VALIGN=MIDDLE><TD WIDTH=50 ALIGN=RIGHT><INPUT TYPE=CHECKBOX VALUE=1 NAME=opt_talkicons $checked></TD><TD><B>Show subject icons</B></TD></TR>\n"; |
|---|
| 357 | $ret .= "<TR><TD> </TD><TD>By default, a bunch of icons are shown that people can use when replying to your messages. A lot of users feel these are ugly and a waste of space, so uncheck this box if you'd like to never see them again. <TT>:-)</TT></TD></TR>\n"; |
|---|
| 358 | |
|---|
| 359 | $ret .= "</TABLE></TD></TR>\n"; |
|---|
| 360 | |
|---|
| 361 | $checked = $u->{'opt_showtopicstuff'} ne "N" ? "CHECKED" : ""; |
|---|
| 362 | $ret .= "<TR VALIGN=MIDDLE><TD WIDTH=50 ALIGN=RIGHT><INPUT TYPE=CHECKBOX NAME=opt_showtopicstuff $checked></TD><TD><B>Show Topic Stuff</B></TD></TR>\n"; |
|---|
| 363 | $ret .= "<TR><TD> </TD><TD>If you check this, other users will be able to easily add your journal entries to the hierarchial <A HREF=\"/topics/\">topic directory</A>.</TD></TR>\n"; |
|---|
| 364 | |
|---|
| 365 | $ret .= "</table>\n"; |
|---|
| 366 | |
|---|
| 367 | if ($LJ::UNICODE) { |
|---|
| 368 | $ret .= "(=H2 Encoding Options H2=)(=P Don't worry about this stuff. In general, only international users that write in several different languages will need to change anything here. P=)<table>\n"; |
|---|
| 369 | LJ::load_codes($dbs, { "encname" => \%LJ::CACHE_ENCNAMES } ) |
|---|
| 370 | unless %LJ::CACHE_ENCNAMES; |
|---|
| 371 | $ret .= "<tr><td width='50'> </td><td><p><b>Auto-translate older entries from: </b>"; |
|---|
| 372 | $ret .= LJ::html_select({'name'=>'oldenc', 'selected'=>$u->{'oldenc'}}, %LJ::CACHE_ENCNAMES); |
|---|
| 373 | $ret .= "</p><p>Use this option to tell LiveJournal which encoding to to assume for your entries and comments entered before the site was converted to Unicode. If you write in English, choose \"Western European\" here.</p></td></tr>"; |
|---|
| 374 | $ret .= "<tr><td> </td><td><p><b>Translate email notifications into: </b>"; |
|---|
| 375 | $ret .= LJ::html_select({'name'=>'mailencoding', 'selected'=>$u->{'mailencoding'}}, %LJ::CACHE_ENCNAMES); |
|---|
| 376 | $ret .= "</p><p>In case you chose to receive message board replies by email, and your email client doesn't handle Unicode (UTF-8) messages very well, use this option to specify a different encoding into which LiveJournal will automatically translate the text of comments sent to you.</p></td></tr>"; |
|---|
| 377 | $ret .= "</table>\n"; |
|---|
| 378 | } |
|---|
| 379 | |
|---|
| 380 | ####### let them un-ban users if they've banned users |
|---|
| 381 | my @banned = (); |
|---|
| 382 | my $quserid = $u->{'userid'}+0; |
|---|
| 383 | $sth = $dbr->prepare("SELECT b.banneduserid, u.user FROM ban b, user u WHERE b.banneduserid=u.userid AND b.userid=$quserid"); |
|---|
| 384 | $sth->execute; |
|---|
| 385 | push @banned, $_ while ($_ = $sth->fetchrow_hashref); |
|---|
| 386 | |
|---|
| 387 | if (@banned) { |
|---|
| 388 | $ret .= "(=H1 Unban Users H1=)(=P You have the following users banned from posting in your journal. Check the checkbox by their username to remove the ban on them. P=)"; |
|---|
| 389 | $ret .= "<UL>"; |
|---|
| 390 | foreach (@banned) { |
|---|
| 391 | $ret .= "<INPUT TYPE=CHECKBOX NAME=\"unban\" VALUE=\"$_->{'banneduserid'}\"> $_->{'user'}<BR>\n"; |
|---|
| 392 | } |
|---|
| 393 | $ret .= "</UL>"; |
|---|
| 394 | |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | ### ending submit block |
|---|
| 398 | $ret .= "(=H1 Done? H1=)(=P When done, press the \"Save Changes\" button below... P=)\n"; |
|---|
| 399 | $ret .= "(=STANDOUT <INPUT TYPE=SUBMIT VALUE=\"Save Changes\"> STANDOUT=)\n"; |
|---|
| 400 | $ret .= "</FORM>\n"; |
|---|
| 401 | |
|---|
| 402 | return $ret; |
|---|
| 403 | } |
|---|
| 404 | |
|---|
| 405 | if ($mode eq "domodify") |
|---|
| 406 | { |
|---|
| 407 | my @errors = (); |
|---|
| 408 | my $state = ""; |
|---|
| 409 | |
|---|
| 410 | my ($zipcity, $zipstate); |
|---|
| 411 | my $qzip = $dbr->quote($FORM{'zip'}); |
|---|
| 412 | if ($FORM{'country'} eq "US") { |
|---|
| 413 | $sth = $dbr->prepare("SELECT city, state FROM zip WHERE zip=$qzip"); |
|---|
| 414 | $sth->execute; |
|---|
| 415 | ($zipcity, $zipstate) = $sth->fetchrow_array; |
|---|
| 416 | } |
|---|
| 417 | |
|---|
| 418 | my $this_year = (localtime())[5]+1900; |
|---|
| 419 | |
|---|
| 420 | unless ($FORM{'name'}) { push @errors, "Your name is a required field. At least provide your first name, or a nickname or handle."; } |
|---|
| 421 | if ($FORM{'year'} && $FORM{'year'} < 100) { push @errors, "Invalid birthday year. Enter a 4-digit year."; } |
|---|
| 422 | if ($FORM{'year'} && $FORM{'year'} >= 100 && |
|---|
| 423 | ($FORM{'year'} < 1890 || $FORM{'year'} > $this_year)) { push @errors, "Invalid birthday year."; } |
|---|
| 424 | if ($FORM{'month'} && ($FORM{'month'} < 1 || $FORM{'month'} > 12)) { push @errors, "Invalid birthday month. Enter a month from 1-12. (Jan-Dec)"; } |
|---|
| 425 | if ($FORM{'day'} && ($FORM{'day'} < 1 || $FORM{'day'} > 31)) { push @errors, "Invalid birthday day. Enter a day from 1-31."; } |
|---|
| 426 | if (@errors == 0 && $FORM{'day'} > LJ::days_in_month($FORM{'month'}, $FORM{'year'})) { |
|---|
| 427 | push @errors, "Invalid day for that month."; |
|---|
| 428 | } |
|---|
| 429 | push @errors, "(=REQUIREPOST=)" unless LJ::did_post(); |
|---|
| 430 | |
|---|
| 431 | if ($FORM{'country'} ne "US" && $FORM{'zip'}) |
|---|
| 432 | { |
|---|
| 433 | push @errors, "You entered a zip-code but you did not select United States as you country. We only collect zip code information about people in the US. Please go back and remove the zip code or select United States as your country."; |
|---|
| 434 | } |
|---|
| 435 | if ($FORM{'country'} eq "US" && $FORM{'stateother'}) |
|---|
| 436 | { |
|---|
| 437 | push @errors, "You specified United States as your country, but you typed in a non-US state in the \"other state\" field."; |
|---|
| 438 | } elsif ($FORM{'country'} && $FORM{'country'} ne "US" && $FORM{'statedrop'}) |
|---|
| 439 | { |
|---|
| 440 | push @errors, "You specified a non-US country but selected a US state."; |
|---|
| 441 | } |
|---|
| 442 | |
|---|
| 443 | # zip-code validation stuff |
|---|
| 444 | if ($FORM{'country'} eq "US") |
|---|
| 445 | { |
|---|
| 446 | if ($FORM{'statedrop'} && $zipstate && $FORM{'statedrop'} ne $zipstate) { |
|---|
| 447 | push @errors, "Your zip code does not match the state you specified. Either correct the information, or erase one or both of the state and zip code fields."; |
|---|
| 448 | } |
|---|
| 449 | if ($zipcity) { |
|---|
| 450 | $FORM{'statedrop'} = $zipstate; |
|---|
| 451 | $FORM{'city'} = $zipcity; |
|---|
| 452 | } |
|---|
| 453 | } |
|---|
| 454 | |
|---|
| 455 | if ($FORM{'country'} && !defined($countries{$FORM{'country'}})) { |
|---|
| 456 | push @errors, "Somehow you selected an invalid country."; |
|---|
| 457 | } |
|---|
| 458 | |
|---|
| 459 | if ($FORM{'use_txtmsg'}) { |
|---|
| 460 | unless ($FORM{'txtmsg_provider'}) { |
|---|
| 461 | push @errors, "If you're going to use text messaging, you must select your service provider. If yours is not listed, please contact us with information about how your service's text messaging feature so we can add support for it."; |
|---|
| 462 | } |
|---|
| 463 | unless ($FORM{'txtmsg_number'}) { |
|---|
| 464 | push @errors, "If you're going to use text messaging, you must enter your phone number."; |
|---|
| 465 | } |
|---|
| 466 | } |
|---|
| 467 | |
|---|
| 468 | unless ($FORM{'email'}) { push @errors, "You must provide your email address"; } |
|---|
| 469 | if ($LJ::USER_EMAIL and $FORM{'email'} =~ /\@\Q$LJ::USER_DOMAIN\E$/i) { |
|---|
| 470 | push @errors, "You cannot enter an \@$LJ::USER_DOMAIN email address. Enter your real address in that field. If you're a paid user, your $u->{'user'}\@$LJ::USER_DOMAIN address will forward to your real address. To choose which email address (or both) is displayed publicly, see the option below the \"Show your Contact Information\" option."; |
|---|
| 471 | } |
|---|
| 472 | if ($FORM{'email'} =~ /\s/) { push @errors, "No spaces allowed in email address. If you're on AOL, remember that your Internet Email address is your screen name with all spaces removed, followed by <B>\@aol.com</B>"; } |
|---|
| 473 | unless (@errors) |
|---|
| 474 | { |
|---|
| 475 | &check_email($FORM{'email'}, \@errors); |
|---|
| 476 | } |
|---|
| 477 | |
|---|
| 478 | return LJ::bad_input(@errors) if @errors; |
|---|
| 479 | |
|---|
| 480 | $state = $FORM{'statedrop'} || $FORM{'stateother'}; |
|---|
| 481 | my $email_changed = ($u->{'email'} ne $FORM{'email'}); |
|---|
| 482 | if ($email_changed) { |
|---|
| 483 | # record old email address; |
|---|
| 484 | my $oldemail = $dbh->quote($u->{'email'}); |
|---|
| 485 | my $oldstatus = $dbh->quote($u->{'status'}); |
|---|
| 486 | $dbh->do("INSERT INTO infohistory (userid, what, oldvalue, timechange, other) VALUES ($u->{'userid'}, 'email', $oldemail, NOW(), $oldstatus)"); |
|---|
| 487 | } |
|---|
| 488 | |
|---|
| 489 | $FORM{'url'} =~ s/\s+$//; $FORM{'url'} =~ s/^\s+//; |
|---|
| 490 | if ($FORM{'url'}) { |
|---|
| 491 | unless ($FORM{'url'} =~ /^https?:\/\//) { |
|---|
| 492 | $FORM{'url'} =~ s/^http\W*//; |
|---|
| 493 | $FORM{'url'} = "http://$FORM{'url'}"; |
|---|
| 494 | } |
|---|
| 495 | } |
|---|
| 496 | |
|---|
| 497 | $FORM{'name'} =~ s/[\n\r]//g; |
|---|
| 498 | $FORM{'name'} = LJ::text_trim($FORM{'name'}, $LJ::BMAX_NAME, $LJ::CMAX_NAME); |
|---|
| 499 | |
|---|
| 500 | my $has_bio = ($FORM{'bio'} =~ /\S/) ? "Y" : "N"; |
|---|
| 501 | my $txtmsg_status = $FORM{'use_txtmsg'} ? "on" : "off"; |
|---|
| 502 | # setup what we're gonna update in the user table: |
|---|
| 503 | my %update = ( |
|---|
| 504 | 'name' => $FORM{'name'}, |
|---|
| 505 | 'bdate' => sprintf("%04d-%02d-%02d", $FORM{'year'}, $FORM{'month'}, $FORM{'day'}), |
|---|
| 506 | 'email' => $FORM{'email'}, |
|---|
| 507 | 'status' => ($email_changed && $u->{'status'} eq "A") ? "T" : $u->{'status'}, |
|---|
| 508 | 'has_bio' => $has_bio, |
|---|
| 509 | 'allow_infoshow' => $FORM{'allow_infoshow'} ? "Y" : "N", |
|---|
| 510 | 'allow_getljnews' => $FORM{'allow_getljnews'} ? "Y" : "N", |
|---|
| 511 | 'opt_showtalklinks' => $FORM{'opt_showtalklinks'} ? "Y" : "N", |
|---|
| 512 | 'opt_gettalkemail' => $FORM{'opt_gettalkemail'} ? "Y" : "N", |
|---|
| 513 | 'opt_htmlemail' => $FORM{'opt_htmlemail'} ? "Y" : "N", |
|---|
| 514 | 'opt_mangleemail' => $FORM{'opt_mangleemail'} ? "Y" : "N", |
|---|
| 515 | 'opt_whocanreply' => $FORM{'opt_whocanreply'}, |
|---|
| 516 | 'txtmsg_status' => $txtmsg_status, |
|---|
| 517 | ); |
|---|
| 518 | |
|---|
| 519 | if ($FORM{'allow_contactshow'}) { |
|---|
| 520 | $update{'allow_contactshow'} = "Y"; |
|---|
| 521 | $update{'allow_contactshow'} = "F" if ($FORM{'contactshow_sec'} eq "F"); |
|---|
| 522 | } else { |
|---|
| 523 | $update{'allow_contactshow'} = "N"; |
|---|
| 524 | } |
|---|
| 525 | |
|---|
| 526 | if (defined $FORM{'oldenc'}) { |
|---|
| 527 | $update{'oldenc'} = $FORM{'oldenc'}; |
|---|
| 528 | } |
|---|
| 529 | |
|---|
| 530 | # update 'user' table |
|---|
| 531 | my $sets = ""; |
|---|
| 532 | foreach (keys %update) |
|---|
| 533 | { |
|---|
| 534 | $sets .= "$_=" . $dbh->quote($update{$_}) . ","; |
|---|
| 535 | } |
|---|
| 536 | chop $sets; |
|---|
| 537 | |
|---|
| 538 | my $sql = "UPDATE user SET $sets WHERE user=$quser"; |
|---|
| 539 | $dbh->do($sql); |
|---|
| 540 | if ($dbh->err) { return "(=H1 Error! H1=)(=P A database error occurred: <B>" . $dbh->errstr . "</B> P=)"; } |
|---|
| 541 | |
|---|
| 542 | ### change any of the userprops ? |
|---|
| 543 | { |
|---|
| 544 | $FORM{'opt_showtopicstuff'} = $FORM{'opt_showtopicstuff'} ? "Y" : "N"; |
|---|
| 545 | $FORM{'opt_blockrobots'} = $FORM{'opt_blockrobots'} ? 1 : 0; |
|---|
| 546 | $FORM{'opt_bdaymail'} = $FORM{'opt_bdaymail'} ? 1 : 0; |
|---|
| 547 | $FORM{'opt_hidefriendofs'} = $FORM{'opt_hidefriendofs'} ? 1 : 0; |
|---|
| 548 | $FORM{'opt_notalkicons'} = $FORM{'opt_talkicons'} ? 0 : 1; # (negated) |
|---|
| 549 | if ($FORM{'opt_logcommentips'} ne "N" && |
|---|
| 550 | $FORM{'opt_logcommentips'} ne "S" && |
|---|
| 551 | $FORM{'opt_logcommentips'} ne "A") { $FORM{'opt_logcommentips'} = "N"; } |
|---|
| 552 | $FORM{'state'} = $state; |
|---|
| 553 | |
|---|
| 554 | # for the directory. |
|---|
| 555 | $FORM{'sidx_bdate'} = ""; |
|---|
| 556 | $FORM{'sidx_loc'} = ""; |
|---|
| 557 | if ($update{'allow_infoshow'} eq 'Y') { |
|---|
| 558 | if ($FORM{'year'}) { |
|---|
| 559 | $FORM{'sidx_bdate'} = sprintf("%04d-%02d-%02d", map { $FORM{$_} } |
|---|
| 560 | qw(year month day)); |
|---|
| 561 | } |
|---|
| 562 | |
|---|
| 563 | if ($FORM{'country'}) { |
|---|
| 564 | my $state; |
|---|
| 565 | if ($FORM{'country'} eq "US") { |
|---|
| 566 | $state = $FORM{'statedrop'}; |
|---|
| 567 | } else { |
|---|
| 568 | $state = $FORM{'stateother'}; |
|---|
| 569 | } |
|---|
| 570 | $FORM{'sidx_loc'} = sprintf("%2s-%s-%s", |
|---|
| 571 | $FORM{'country'}, |
|---|
| 572 | $state, |
|---|
| 573 | $FORM{'city'}); |
|---|
| 574 | } |
|---|
| 575 | } |
|---|
| 576 | |
|---|
| 577 | my @uprops = ( |
|---|
| 578 | "opt_whatemailshow", "opt_showtopicstuff", |
|---|
| 579 | "country", "state", "city", "zip", "icq", |
|---|
| 580 | "aolim", "yahoo", "msn", "url", "urlname", |
|---|
| 581 | "gender", "jabber", "opt_blockrobots", |
|---|
| 582 | "opt_notalkicons", "opt_logcommentips", |
|---|
| 583 | "opt_bdaymail", "opt_hidefriendofs", |
|---|
| 584 | "sidx_bdate", "sidx_loc", "mailencoding", |
|---|
| 585 | ); |
|---|
| 586 | |
|---|
| 587 | # this is only done once, then never appears again. |
|---|
| 588 | if ($FORM{'howhear'}) { |
|---|
| 589 | push @uprops, "howhear"; |
|---|
| 590 | } |
|---|
| 591 | |
|---|
| 592 | foreach my $uprop (@uprops) { |
|---|
| 593 | if ($FORM{$uprop} ne $u->{$uprop}) { |
|---|
| 594 | LJ::set_userprop($dbs, $u->{'userid'}, $uprop, $FORM{$uprop}); |
|---|
| 595 | } |
|---|
| 596 | } |
|---|
| 597 | } |
|---|
| 598 | |
|---|
| 599 | |
|---|
| 600 | #### update their bio text |
|---|
| 601 | if ($u->{'bio'} ne $FORM{'bio'}) { |
|---|
| 602 | my $db_bio = $dbcs->{'dbh'}; |
|---|
| 603 | if ($has_bio eq "N") { |
|---|
| 604 | $db_bio->do("DELETE FROM userbio WHERE userid=$u->{'userid'}"); |
|---|
| 605 | LJ::dudata_set($db_bio, $u->{'userid'}, 'B', 0, 0) if $clustered; |
|---|
| 606 | } else { |
|---|
| 607 | my $qbio = $dbh->quote($FORM{'bio'}); |
|---|
| 608 | $db_bio->do("REPLACE INTO userbio (userid, bio) VALUES ($u->{'userid'}, $qbio)"); |
|---|
| 609 | LJ::dudata_set($db_bio, $u->{'userid'}, 'B', 0, length($FORM{'bio'})) if $clustered; |
|---|
| 610 | } |
|---|
| 611 | } |
|---|
| 612 | |
|---|
| 613 | #### update their text messaging info |
|---|
| 614 | if ($txtmsg_status eq "off") { |
|---|
| 615 | if ($u->{'txtmsg_status'} eq "on") { |
|---|
| 616 | $dbh->do("DELETE FROM txtmsg WHERE userid=$u->{'userid'}"); |
|---|
| 617 | } |
|---|
| 618 | } elsif ($txtmsg_status eq "on") { |
|---|
| 619 | my $qnumber = $dbh->quote($FORM{'txtmsg_number'}); |
|---|
| 620 | my $qsec = $dbh->quote($FORM{'txtmsg_security'}); |
|---|
| 621 | my $qprov = $dbh->quote($FORM{'txtmsg_provider'}); |
|---|
| 622 | $dbh->do("REPLACE INTO txtmsg (userid, provider, number, security) VALUES ($u->{'userid'}, $qprov, $qnumber, $qsec)"); |
|---|
| 623 | } |
|---|
| 624 | |
|---|
| 625 | ### update interests |
|---|
| 626 | { |
|---|
| 627 | my %int_new = (); |
|---|
| 628 | my %int_del = %interests; |
|---|
| 629 | $FORM{'interests'} =~ s/^\s+//; |
|---|
| 630 | $FORM{'interests'} =~ s/\s+$//; |
|---|
| 631 | $FORM{'interests'} =~ s/\n/,/g; |
|---|
| 632 | my @ints = split (/\s*,\s*/, $FORM{'interests'}); |
|---|
| 633 | my $errorflag = 0; |
|---|
| 634 | my $intcount = scalar(@ints); |
|---|
| 635 | if ($intcount > 150) { |
|---|
| 636 | $errorflag = 1; |
|---|
| 637 | push @errors, "Sorry, you listed too many interests. The limit is 150, but you've listed $intcount. Any changes you made to your interests were not saved. Go back and cut down your list, then save again."; |
|---|
| 638 | } |
|---|
| 639 | else |
|---|
| 640 | { |
|---|
| 641 | foreach my $int (@ints) |
|---|
| 642 | { |
|---|
| 643 | $int = lc($int); |
|---|
| 644 | # The following two lines prevent diacritics in other languages, thus bad. |
|---|
| 645 | # $int =~ s/^[^\w]+//; |
|---|
| 646 | # $int =~ s/[^\w]+$//; |
|---|
| 647 | $int =~ s/^i like //; |
|---|
| 648 | next unless ($int); |
|---|
| 649 | next if ($int =~ / .+ .+ .+ /); |
|---|
| 650 | next if ($int =~ /[\<\>]/); |
|---|
| 651 | next if (length($int) > 35); |
|---|
| 652 | unless ($interests{$int}) { $int_new{$int} = 1; } |
|---|
| 653 | delete $int_del{$int}; |
|---|
| 654 | } |
|---|
| 655 | } |
|---|
| 656 | |
|---|
| 657 | ### were interests removed? |
|---|
| 658 | if (!$errorflag && %int_del) |
|---|
| 659 | { |
|---|
| 660 | ## easy, we know their IDs, so delete them en masse |
|---|
| 661 | |
|---|
| 662 | my $intid_in = join(", ", values %int_del); |
|---|
| 663 | $dbh->do("DELETE FROM userinterests WHERE userid=$u->{'userid'} AND intid IN ($intid_in)"); |
|---|
| 664 | $dbh->do("UPDATE interests SET intcount=intcount-1 WHERE intid IN ($intid_in)"); |
|---|
| 665 | } |
|---|
| 666 | |
|---|
| 667 | ### do we have new interests to add? |
|---|
| 668 | if (!$error_flag && %int_new) |
|---|
| 669 | { |
|---|
| 670 | ## difficult, have to find intids of interests, and create new ints for interests |
|---|
| 671 | ## that nobody has ever entered before |
|---|
| 672 | |
|---|
| 673 | my $int_in = join(", ", map { $dbh->quote($_); } keys %int_new); |
|---|
| 674 | my %int_exist; |
|---|
| 675 | my @new_intids = (); ## existing IDs we'll add for this user |
|---|
| 676 | |
|---|
| 677 | ## find existing IDs |
|---|
| 678 | $sth = $dbr->prepare("SELECT interest, intid FROM interests WHERE interest IN ($int_in)"); |
|---|
| 679 | $sth->execute; |
|---|
| 680 | while ($_ = $sth->fetchrow_hashref) { |
|---|
| 681 | push @new_intids, $_->{'intid'}; # - we'll add this later. |
|---|
| 682 | delete $int_new{$_->{'interest'}}; # - so we don't have to make a new intid for |
|---|
| 683 | # this next pass. |
|---|
| 684 | } |
|---|
| 685 | |
|---|
| 686 | if (@new_intids) { |
|---|
| 687 | my $sql = ""; |
|---|
| 688 | foreach my $newid (@new_intids) { |
|---|
| 689 | if ($sql) { $sql .= ", "; } |
|---|
| 690 | else { $sql = "REPLACE INTO userinterests (userid, intid) VALUES "; } |
|---|
| 691 | $sql .= "($u->{'userid'}, $newid)"; |
|---|
| 692 | } |
|---|
| 693 | $dbh->do($sql); |
|---|
| 694 | |
|---|
| 695 | my $intid_in = join(", ", @new_intids); |
|---|
| 696 | $dbh->do("UPDATE interests SET intcount=intcount+1 WHERE intid IN ($intid_in)"); |
|---|
| 697 | } |
|---|
| 698 | } |
|---|
| 699 | |
|---|
| 700 | ### do we STILL have interests to add? (must make new intids) |
|---|
| 701 | if (!$error_flag && %int_new) |
|---|
| 702 | { |
|---|
| 703 | foreach my $int (keys %int_new) |
|---|
| 704 | { |
|---|
| 705 | my $intid; |
|---|
| 706 | |
|---|
| 707 | ## need to do this atomically so we don't get duplicate interests (there's no unique |
|---|
| 708 | ## constraint on the interest column... that'd make for a big index) |
|---|
| 709 | $dbh->do("LOCK TABLES interests WRITE"); |
|---|
| 710 | my $qint = $dbh->quote($int); |
|---|
| 711 | |
|---|
| 712 | # let's double-check that some other connection didn't insert it since we last checked |
|---|
| 713 | $sth = $dbh->prepare("SELECT intid FROM interests WHERE interest=$qint"); |
|---|
| 714 | $sth->execute; |
|---|
| 715 | ($intid) = $sth->fetchrow_array; |
|---|
| 716 | |
|---|
| 717 | # more than likely it's still missing, so we have to make it: |
|---|
| 718 | unless ($intid) |
|---|
| 719 | { |
|---|
| 720 | $sth = $dbh->prepare("INSERT INTO interests (intid, intcount, interest) VALUES (NULL, 1, $qint)"); |
|---|
| 721 | $sth->execute; |
|---|
| 722 | $intid = $dbh->{'mysql_insertid'}; |
|---|
| 723 | } |
|---|
| 724 | $dbh->do("UNLOCK TABLES"); |
|---|
| 725 | |
|---|
| 726 | ## now we can actually insert it into the userinterests table: |
|---|
| 727 | $dbh->do("INSERT INTO userinterests (userid, intid) VALUES ($u->{'userid'}, $intid)"); |
|---|
| 728 | } |
|---|
| 729 | } |
|---|
| 730 | |
|---|
| 731 | } |
|---|
| 732 | |
|---|
| 733 | #### now unban users they selected to be unbanned |
|---|
| 734 | |
|---|
| 735 | if ($FORM{'unban'}) |
|---|
| 736 | { |
|---|
| 737 | my $bannedin = join(",", map { $dbh->quote($_); } split(/\0/, $FORM{'unban'})); |
|---|
| 738 | my $quserid = $u->{'userid'}+0; |
|---|
| 739 | $dbh->do("DELETE FROM ban WHERE userid=$quserid AND banneduserid IN ($bannedin)"); |
|---|
| 740 | } |
|---|
| 741 | |
|---|
| 742 | ##### /unban |
|---|
| 743 | |
|---|
| 744 | if ($email_changed) |
|---|
| 745 | { |
|---|
| 746 | my $aa = {}; |
|---|
| 747 | $aa = LJ::register_authaction($dbs, $u->{'userid'}, |
|---|
| 748 | "validateemail", $FORM{'email'}); |
|---|
| 749 | |
|---|
| 750 | open (MAIL, "|$LJ::SENDMAIL"); |
|---|
| 751 | print MAIL "To: $FORM{'email'}\n"; |
|---|
| 752 | print MAIL "From: $LJ::ADMIN_EMAIL\n"; |
|---|
| 753 | print MAIL "Subject: Email Address Changed\n\n"; |
|---|
| 754 | print MAIL "You have just changed your LiveJournal email address. To validate the change, please go to this address:\n\n"; |
|---|
| 755 | |
|---|
| 756 | print MAIL " $LJ::SITEROOT/confirm/$aa->{'aaid'}.$aa->{'authcode'}\n\n"; |
|---|
| 757 | |
|---|
| 758 | print MAIL "Regards,\n$LJ::SITENAME Team\n\n$LJ::SITEROOT/\n"; |
|---|
| 759 | close MAIL; |
|---|
| 760 | |
|---|
| 761 | } |
|---|
| 762 | |
|---|
| 763 | # tell the user all is well |
|---|
| 764 | my $ret = "(=H1 Success H1=)(=P Your information and <a href=\"/users/$user/\">journal</a> settings and <a href=\"/userinfo.bml?user=$user\">profile</a> have been updated. P=)"; |
|---|
| 765 | if (@errors) { |
|---|
| 766 | $ret .= "(=P However, one or more errors occured while processing your request:\n<ul>\n"; |
|---|
| 767 | foreach (@errors) { |
|---|
| 768 | $ret .= "<li>$_\n"; |
|---|
| 769 | } |
|---|
| 770 | $ret .= "</ul> P=)\n"; |
|---|
| 771 | } |
|---|
| 772 | return $ret; |
|---|
| 773 | } |
|---|
| 774 | |
|---|
| 775 | return "Unknown mode." |
|---|
| 776 | |
|---|
| 777 | _CODE=) |
|---|
| 778 | |
|---|
| 779 | <=BODY |
|---|
| 780 | PAGE=)(=_C <LJDEP> |
|---|
| 781 | lib: LJ::TextMessage, cgi-bin/ljlib.pl, cgi-bin/ljlang.pl |
|---|
| 782 | link: htdocs/legal/privacy.bml, htdocs/support/faqbrowse.bml, htdocs/tools/textmessage.bml, htdocs/uploadpic.bml |
|---|
| 783 | link: htdocs/paidaccounts/index.bml, htdocs/topics/index.bml, htdocs/users, htdocs/userinfo.bml |
|---|
| 784 | post: htdocs/editinfo.bml |
|---|
| 785 | img: htdocs/userpic |
|---|
| 786 | </LJDEP> _C=) |
|---|