==== //ccare/main/LiveJournal/bin/maint/bday.pl#3 - /u0/jaffray/p4/LiveJournal/bin/maint/bday.pl ==== --- /tmp/tmp.29918.0 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/bin/maint/bday.pl Sat Jun 2 11:59:16 2001 @@ -12,16 +12,18 @@ while (my ($userid, $user, $name, $email, $allow_contactshow) = $sth->fetchrow_array) { print "$user ($userid) .. $name .. $email\n"; - open (MAIL, "|$SENDMAIL"); - print MAIL "From: webmaster\@livejournal.com (LiveJournal.com)\n"; - print MAIL "To: $email ($name)\n"; - print MAIL "Subject: Happy Birthday!\n\n"; - print MAIL "Happy Birthday $name!!\n\n"; - print MAIL "According to our records, today is your birthday... everybody here at LiveJournal.com would like to wish you a happy birthday!\n\n"; - print MAIL "If you got any interesting birthday stories to share, do let us know! Or better, email them to us and also update your LiveJournal with them. :) And if you have any questions/comments about the LiveJournal service in general, let us know too... we're real people, not a huge corporation, so we read and reply to all email.\n\n"; - print MAIL "Anyway... the point of this email was originally just HAPPY BIRTHDAY!\n\n"; - print MAIL "\nSincerely,\nLiveJournal.com Team\n\n--\nLiveJournal\nhttp://www.livejournal.com/\n"; - close MAIL; + my $body = qq{ +According to our records, today is your birthday... everybody here at LiveJournal.com would like to wish you a happy birthday! + +If you got any interesting birthday stories to share, do let us know! Or better, email them to us and also update your LiveJournal with them. :) And if you have any questions/comments about the LiveJournal service in general, let us know too... we're real people, not a huge corporation, so we read and reply to all email. + +Anyway... the point of this email was originally just HAPPY BIRTHDAY! +}; #' + send_admin_mail({to => $email, + toname => $name, + subject => "Happy Birthday!", + body => $body }); + $bday{$user} = { 'user' => $user, 'name' => $name, 'email' => $email, @@ -48,18 +50,16 @@ foreach $friend (grep { $user ne $_ } @{$friends{$user}}) { print "Mail $user about $friend...\n"; - open (MAIL, "|$SENDMAIL"); - print MAIL "From: webmaster\@livejournal.com (LiveJournal.com)\n"; - print MAIL "To: $email ($name)\n"; - print MAIL "Subject: Birthday Reminder!\n\n"; - print MAIL "$name,\n\n"; - $s = $bday{$friend}->{'name'} =~ /s$/i ? "'" : "'s"; - print MAIL "This is a reminder that today is $bday{$friend}->{'name'}$s birthday (LiveJournal user: $friend). You have $bday{$friend}->{'name'} listed as a friend in your LiveJournal, so we thought this reminder would be useful.\n"; + my $body = "$name,\n\n"; + my $s = $bday{$friend}->{'name'} =~ /s$/i ? "'" : "'s"; + $body .= "This is a reminder that today is $bday{$friend}->{'name'}$s birthday (LiveJournal user: $friend). You have $bday{$friend}->{'name'} listed as a friend in your LiveJournal, so we thought this reminder would be useful.\n"; if ($bday{$friend}->{'contactshow'} eq "Y") { - print MAIL "\nIf you'd like to mail this person and wish them a happy birthday, their email address is:\n\n $bday{$friend}->{'email'}\n\n"; + $body .= "\nIf you'd like to mail this person and wish them a happy birthday, their email address is:\n\n $bday{$friend}->{'email'}\n\n"; } - print MAIL "\nSincerely,\nLiveJournal.com Team\n\n--\nLiveJournal\nhttp://www.livejournal.com/\n"; - close MAIL; + send_admin_mail({to => $email, + toname => $name, + subject => "Birthday Reminder!", + body => $body}); } } ==== //ccare/main/LiveJournal/bin/maint/expiring.pl#3 - /u0/jaffray/p4/LiveJournal/bin/maint/expiring.pl ==== --- /tmp/tmp.29918.1 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/bin/maint/expiring.pl Sat Jun 2 12:10:16 2001 @@ -56,9 +56,7 @@ $email =~ s/%%email%%/$u->{'email'}/m; $email =~ s/%%user%%/$u->{'user'}/m; - open (MAIL, "|$SENDMAIL"); - print MAIL $email; - close MAIL; + send_mail_raw($email); $dbh->do("UPDATE user SET paidreminder=NOW() WHERE userid=$u->{'userid'}"); } ==== //ccare/main/LiveJournal/bin/maint/pay.pl#3 - /u0/jaffray/p4/LiveJournal/bin/maint/pay.pl ==== --- /tmp/tmp.29918.2 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/bin/maint/pay.pl Sat Jun 2 12:00:47 2001 @@ -22,7 +22,7 @@ print "$p->{'payid'}: Mailing $p->{'email'} ($howmany) ...\n"; $p->{'notes'} =~ s/\r//g; - open (MAIL, "|$SENDMAIL"); + open (MAIL, "|$LJ::SENDMAIL"); print MAIL "To: $p->{'email'}\n"; print MAIL "Bcc: brad\@livejournal.com\n"; print MAIL "From: brad\@livejournal.com (Brad Fitzpatrick)\n"; ==== //ccare/main/LiveJournal/cgi-bin/bml/scheme/dystopia/generic.look#5 - /u0/jaffray/p4/LiveJournal/cgi-bin/bml/scheme/dystopia/generic.look ==== --- /tmp/tmp.29918.3 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/cgi-bin/bml/scheme/dystopia/generic.look Sun Jun 3 00:11:50 2001 @@ -126,8 +126,7 @@ (=_CODE - - require 'ljlib.pl'; + # require 'ljlib.pl'; $page_remote = &get_remote_noauth(); return ""; _CODE=) ==== //ccare/main/LiveJournal/cgi-bin/lj-bml-init.pl#1 - /u0/jaffray/p4/LiveJournal/cgi-bin/lj-bml-init.pl ==== --- /tmp/tmp.29918.4 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/cgi-bin/lj-bml-init.pl Sat Jun 2 22:58:17 2001 @@ -18,3 +18,9 @@ &BML::register_block("DL", "DS", $dl); } +package BMLCodeBlock; + +require 'ljlib.pl'; +require 'ljprotocol.pl'; +require 'cleanhtml.pl'; +require 'propparse.pl'; ==== //ccare/main/LiveJournal/cgi-bin/ljconfig.pl#10 - /u0/jaffray/p4/LiveJournal/cgi-bin/ljconfig.pl ==== ==== //ccare/main/LiveJournal/cgi-bin/ljlang.pl#3 - /u0/jaffray/p4/LiveJournal/cgi-bin/ljlang.pl ==== --- /tmp/tmp.29918.5 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/cgi-bin/ljlang.pl Sat Jun 2 14:08:59 2001 @@ -21,7 +21,7 @@ sub enum_trans { my ($hash, $lang, $num) = @_; - return "" unless ($num); + return "" unless defined $num; unless (defined $hash->{$lang}) { $lang = "EN"; } return $hash->{$lang}->[$num-1]; } ==== //ccare/main/LiveJournal/cgi-bin/ljlib.pl#5 - /u0/jaffray/p4/LiveJournal/cgi-bin/ljlib.pl ==== --- /tmp/tmp.29918.6 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/cgi-bin/ljlib.pl Sat Jun 2 21:51:18 2001 @@ -3,40 +3,10 @@ use DBI; use Digest::MD5 qw(md5_hex); -######################## -# CONSTANTS -# - -@views = qw(lastn friends calendar day); -%viewinfo = ( - "lastn" => { - "creator" => \&create_view_lastn, - "des" => "Most Recent Events", - }, - "calendar" => { - "creator" => \&create_view_calendar, - "des" => "Calendar", - }, - "day" => { - "creator" => \&create_view_day, - "des" => "Day View", - }, - "friends" => { - "creator" => \&create_view_friends, - "des" => "Friends View", - }, - ); - require '/home/lj/cgi-bin/ljconfig.pl'; require '/home/lj/cgi-bin/ljlang.pl'; require '/home/lj/cgi-bin/ljpoll.pl'; -## for use in style system's %%cons:.+%% mapping -%constant_map = ('siteroot' => $LJ::SITEROOT, - 'sitename' => $LJ::SITENAME, - 'img' => $LJ::IMGPREFIX, - ); - $SIG{'HUP'} = sub { print STDERR "HUP caught. Clearing caches.\n"; %LJ::CACHE_STYLE = (); @@ -52,68 +22,69 @@ %LJ::CACHE_USERPROP = (); # {$prop}->{ 'upropid' => ... , 'indexed' => 0|1 }; }; -## deprecated: use LJ::Lang::* instead -%monthname = ( - 1=>"January", - 2=>"February", - 3=>"March", - 4=>"April", - 5=>"May", - 6=>"June", - 7=>"July", - 8=>"August", - 9=>"September", - 10=>"October", - 11=>"November", - 12=>"December", - ); - -## deprecated: use LJ::Lang::* instead -%monthshortname = ( - 1=>"Jan", - 2=>"Feb", - 3=>"Mar", - 4=>"Apr", - 5=>"May", - 6=>"Jun", - 7=>"Jul", - 8=>"Aug", - 9=>"Sep", - 10=>"Oct", - 11=>"Nov", - 12=>"Dec", - ); - -## deprecated: use LJ::Lang::* instead -%dayweekname = ( - 1=>"Sun", - 2=>"Mon", - 3=>"Tue", - 4=>"Wed", - 5=>"Thu", - 6=>"Fri", - 7=>"Sat", - ); - +# this isn't defined in package LJ because it refers to subs defined here. +%LJ::viewinfo = ( + "lastn" => { + "creator" => \&create_view_lastn, + "des" => "Most Recent Events", + }, + "calendar" => { + "creator" => \&create_view_calendar, + "des" => "Calendar", + }, + "day" => { + "creator" => \&create_view_day, + "des" => "Day View", + }, + "friends" => { + "creator" => \&create_view_friends, + "des" => "Friends View", + }, + ); + +sub send_mail_raw +{ + my $msg = shift; + open MAIL, "|$LJ::SENDMAIL"; + print MAIL $msg; + close MAIL; +} sub send_mail { my $opt = shift; - open (MAIL, "|$LJ::SENDMAIL"); + my $msg = ""; my $toname; if ($opt->{'toname'}) { $toname = " ($opt->{'toname'})"; } - print MAIL "To: $opt->{'to'}$toname\n"; - print MAIL "Cc: $opt->{'bcc'}\n" if ($opt->{'cc'}); - print MAIL "Bcc: $opt->{'bcc'}\n" if ($opt->{'bcc'}); - print MAIL "From: $opt->{'from'}"; + $msg .= "To: $opt->{'to'}$toname\n"; + $msg .= "Cc: $opt->{'bcc'}\n" if ($opt->{'cc'}); + $msg .= "Bcc: $opt->{'bcc'}\n" if ($opt->{'bcc'}); + $msg .= "From: $opt->{'from'}"; if ($opt->{'fromname'}) { - print MAIL " ($opt->{'fromname'})"; + $msg .= " ($opt->{'fromname'})"; } - print MAIL "\nSubject: $opt->{'subject'}\n\n"; - print MAIL $opt->{'body'}; - close MAIL; + $msg .= "\nSubject: $opt->{'subject'}\n\n"; + $opt->{'body'} =~ s/^\n*//; # strip leading newlines + $msg .= $opt->{'body'}; + send_mail_raw($msg); } +sub send_admin_mail +{ + my $opt = shift; + $opt->{from} = $LJ::ADMIN_EMAIL; + $opt->{fromname} = $LJ::SITENAME; + $opt->{body} .= qq{ +Regards, +$LJ::SITENAME Team + +-- +$LJ::SITENAME +$SITEROOT +}; + send_mail($opt); +} + ## for stupid AOL mail client, wraps a plain-text URL in an anchor tag since AOL ## incorrectly renders regular text as HTML. fucking AOL. die. @@ -373,7 +344,7 @@ %{$ref} = %{$LJ::CACHE_MOOD_THEME{$themeid}->{$moodid}}; if ($ref->{'pic'} =~ m!^/!) { $ref->{'pic'} =~ s!^/img!!; - $ref->{'pic'} = $IMGPREFIX . $ref->{'pic'}; + $ref->{'pic'} = $LJ::IMGPREFIX . $ref->{'pic'}; } $ref->{'moodid'} = $moodid; return 1; @@ -465,7 +436,7 @@ $styleid = $opts->{'styleid'}+0; } else { $view ||= "lastn"; # default view when none specified explicitly in URLs - if ($viewinfo{$view}) { + if ($LJ::viewinfo{$view}) { $styleid = -1; # to get past the return, then checked later for -1 and fixed, once user is loaded. $view = $view; } else { @@ -533,11 +504,11 @@ $overrides = ""; # instruct some function to make this specific view type - return "" unless (defined $viewinfo{$view}->{'creator'}); + return "" unless (defined $LJ::viewinfo{$view}->{'creator'}); my $ret = ""; # call the view creator w/ the buffer to fill and the construction variables - &{$viewinfo{$view}->{'creator'}}(\$ret, $u, \%vars, $remote, $opts); + &{$LJ::viewinfo{$view}->{'creator'}}(\$ret, $u, \%vars, $remote, $opts); # remove bad stuff unless ($opts->{'trusted_html'}) { @@ -834,35 +805,41 @@ return $data; } -sub fvp_transform { - my ($transform, $vars, $hashref, $attr) = @_; - my $ret = $hashref->{$attr}; - while ($transform =~ s/(\w+):$//) { - my $trans = $1; - if ($trans eq "ue") { - $ret = &eurl($ret); - } - elsif ($trans eq "xe") { - $ret = &exml($ret); - } - elsif ($trans eq "lc") { - $ret = lc($ret); - } - elsif ($trans eq "uc") { - $ret = uc($ret); - } - elsif ($trans eq "color") { - $ret = $vars->{"color-$attr"}; - } - elsif ($trans eq "cons") { - $ret = $constant_map{$attr}; - } - elsif ($trans eq "ad") { - $ret = ""; - } + my %constant_map = ('siteroot' => $LJ::SITEROOT, + 'sitename' => $LJ::SITENAME, + 'img' => $LJ::IMGPREFIX, + ); + sub fvp_transform + { + my ($transform, $vars, $hashref, $attr) = @_; + my $ret = $hashref->{$attr}; + while ($transform =~ s/(\w+):$//) { + my $trans = $1; + if ($trans eq "ue") { + $ret = &eurl($ret); + } + elsif ($trans eq "xe") { + $ret = &exml($ret); + } + elsif ($trans eq "lc") { + $ret = lc($ret); + } + elsif ($trans eq "uc") { + $ret = uc($ret); + } + elsif ($trans eq "color") { + $ret = $vars->{"color-$attr"}; + } + elsif ($trans eq "cons") { + $ret = $constant_map{$attr}; + } + elsif ($trans eq "ad") { + $ret = ""; + } + } + return $ret; } - return $ret; } sub eurl @@ -1218,6 +1195,10 @@ package LJ; +# +# CONSTANTS +# +@views = qw(lastn friends calendar day); %acct_name = ("paid" => "Paid Account", "off" => "Free Account", "early" => "Early Adopter", ==== //ccare/main/LiveJournal/cgi-bin/ljprotocol.pl#7 - /u0/jaffray/p4/LiveJournal/cgi-bin/ljprotocol.pl ==== --- /tmp/tmp.29918.7 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/cgi-bin/ljprotocol.pl Sun May 27 20:01:25 2001 @@ -1325,8 +1325,18 @@ } else { $lastupdate = "0000-00-00 00:00:00"; } + + my $sql = qq(SELECT MAX(u.timeupdate) + FROM user u, friends f + WHERE u.userid = f.friendid + AND f.userid = $userid); - $sth = $dbh->prepare("SELECT MAX(u.timeupdate) FROM user u, friends f WHERE u.userid=f.friendid AND f.userid=$userid"); + ## did they specify a valid (numeric) groupmask? + if ($req->{mask} and $req->{mask} !~ /\D/) { + $sql .= " AND f.groupmask & $req->{mask} > 0"; + } + + $sth = $dbh->prepare($sql); $sth->execute; my ($update) = $sth->fetchrow_array; $update ||= "0000-00-00 00:00:00"; ==== //ccare/main/LiveJournal/htdocs/admin/console/index.bml#3 - /u0/jaffray/p4/LiveJournal/htdocs/admin/console/index.bml ==== --- /tmp/tmp.29918.8 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/admin/console/index.bml Sat Jun 2 12:44:21 2001 @@ -1,7 +1,7 @@ (=_CODE use strict; - use vars qw($dbh %FORM %cmd $IMGPREFIX); + use vars qw($dbh %FORM %cmd); require 'ljlib.pl'; require 'console.pl'; @@ -131,7 +131,7 @@ $ret .= "[ console | reference ]

"; $ret .= "

"; - $ret .= ""; + $ret .= ""; $ret .= ""; $ret .= ""; ==== //ccare/main/LiveJournal/htdocs/birthdays.bml#3 - /u0/jaffray/p4/LiveJournal/htdocs/birthdays.bml ==== --- /tmp/tmp.29918.9 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/birthdays.bml Sat Jun 2 14:25:58 2001 @@ -22,11 +22,11 @@ if ($bday->{'month'} != $lastmon) { if ($lastmon) { $body .= "\n"; } $lastmon = $bday->{'month'}; - $body .= "(=H1 " . $monthname{$lastmon} . " H1=)
    \n"; + $body .= "(=H1 " . LJ::Lang::month_long("EN", $lastmon) . " H1=)
      \n"; } my $day = sprintf("%2s", $bday->{'day'}); $day =~ s/ / /; - $body .= "$day: {'user'}\"> {'user'}/\">$bday->{'user'} - $bday->{'name'}
      "; + $body .= "$day: {'user'}\"> {'user'}/\">$bday->{'user'} - $bday->{'name'}
      "; } ==== //ccare/main/LiveJournal/htdocs/changepassword_do.bml#4 - /u0/jaffray/p4/LiveJournal/htdocs/changepassword_do.bml ==== --- /tmp/tmp.29918.10 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/changepassword_do.bml Sat Jun 2 13:04:41 2001 @@ -4,7 +4,7 @@ $body = ""; require 'ljlib.pl'; - if ($SERVER_DOWN) { + if ($LJ::SERVER_DOWN) { $body = &server_down_html(); $title = "Sorry..."; return ""; @@ -57,17 +57,16 @@ $qnewpass = $dbh->quote($FORM{'newpass1'}); $dbh->do("UPDATE user SET password=$qnewpass WHERE user=$quser"); - open (MAIL, "|$SENDMAIL"); - print MAIL "To: $u->{'email'}\n"; - print MAIL "From: $LJ::ADMIN_EMAIL ($LJ::SITENAME)\n"; - print MAIL "Subject: Change of Password\n\n"; - print MAIL "This is a reminder of your password change at $LJ::SITENAME.\n\n"; - print MAIL " Username: $u->{'user'}\n"; - print MAIL " Password: $FORM{'newpass1'}\n"; - print MAIL " EMail Address: $u->{'email'}\n\n"; + my $email_body = qq{ +This is a reminder of your password change at $LJ::SITENAME. - print MAIL "Regards,\n$LJ::SITENAME Team\n\n$LJ::SITEROOT/\n"; - close MAIL; + Username: $u->{user} + Password: $FORM{newpass1} + Email Address: $u->{email} +}; + send_admin_mail({to => $u->{email}, + subject => "Password Change", + body => $email_body}); $body = "(=H1 Success H1=)(=P Your password has been changed and email has been sent to you with a reminder message. P=)"; ==== //ccare/main/LiveJournal/htdocs/create_do.bml#6 - /u0/jaffray/p4/LiveJournal/htdocs/create_do.bml ==== --- /tmp/tmp.29918.11 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/create_do.bml Sat Jun 2 13:05:04 2001 @@ -6,7 +6,7 @@ require 'ljlib.pl'; require 'emailcheck.pl'; - return &server_down_html() if ($SERVER_DOWN); + return &server_down_html() if ($LJ::SERVER_DOWN); my @errors = (); my $user = lc($FORM{'user'}); @@ -111,9 +111,7 @@ $etemp =~ s/%%(\w+?)%%/$replace{$1}/ge; - open (MAIL, "|$SENDMAIL"); - print MAIL $etemp; - close MAIL; + send_mail_raw($etemp); $ret = "(=H1 Success! H1=)(=P Your journal has been created. Important registration information has been emailed to $email containing further instructions. Note: You have exactly seven days to confirm your journal creation. If you still haven't gone and set it up after seven days the username of $user will be automaticaly deleted and somebody else may use it. P=)"; $ret .= "(=P Your LiveJournal will be available at: P=)(=STANDOUT $LJ::SITEROOT/users/$user/ STANDOUT=)"; ==== //ccare/main/LiveJournal/htdocs/dev/directory.sbml#1 - /u0/jaffray/p4/LiveJournal/htdocs/dev/directory.sbml ==== --- /tmp/tmp.29918.12 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/dev/directory.sbml Sat Jun 2 13:05:14 2001 @@ -8,7 +8,7 @@ (=_CODE require 'ljlib.pl'; - return &server_down_html() if ($SERVER_DOWN); + return &server_down_html() if ($LJ::SERVER_DOWN); require 'directorylib.pl'; my @errors = (); @@ -41,7 +41,7 @@ $ret .= "\n"; - $ret .= "\n"; + $ret .= "\n"; $sth = $dbh->prepare("SELECT statcat, statkey, statval FROM stats WHERE statcat IN ('country', 'stateus')"); $sth->execute; @@ -249,9 +249,9 @@ $ret .= "{'user'}\">"; if ($rec->{'journaltype'} eq "C") { - $ret .= ""; + $ret .= ""; } else { - $ret .= ""; + $ret .= ""; } $ret .= " "; $ret .= "{'user'}/\">$rec->{'user'} - $rec->{'name'}, Updated "; @@ -270,9 +270,9 @@ $ret .= "
"; $ret .= ""; $ret .= ""; @@ -280,9 +280,9 @@ my $color; if ($rec->{'membership'} eq "open") { $color = "green"; } else { $color = "red"; } - $ret .= ""; + $ret .= ""; if ($rec->{'postlevel'} eq "members") { $color = "green"; } else { $color = "red"; } - $ret .= ""; + $ret .= ""; $ret .= ""; } @@ -339,9 +339,9 @@ $ret .= "{'user'}\">"; if ($rec->{'journaltype'} eq "C") { - $ret .= ""; + $ret .= ""; } else { - $ret .= ""; + $ret .= ""; } $ret .= " "; ==== //ccare/main/LiveJournal/htdocs/directory.sbml#3 - /u0/jaffray/p4/LiveJournal/htdocs/directory.sbml ==== --- /tmp/tmp.29918.13 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/directory.sbml Sat Jun 2 13:06:48 2001 @@ -8,7 +8,7 @@ (=_CODE require 'ljlib.pl'; - return &server_down_html() if ($SERVER_DOWN); + return &server_down_html() if ($LJ::SERVER_DOWN); require 'directorylib.pl'; my @errors = (); ==== //ccare/main/LiveJournal/htdocs/editinfo_do.bml#5 - /u0/jaffray/p4/LiveJournal/htdocs/editinfo_do.bml ==== --- /tmp/tmp.29918.14 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/editinfo_do.bml Sat Jun 2 14:10:53 2001 @@ -16,7 +16,7 @@ require 'emailcheck.pl'; use LJ::TextMessage; - return &server_down_html() if ($SERVER_DOWN); + return &server_down_html() if ($LJ::SERVER_DOWN); my @errors = (); my $user = lc($FORM{'user'}); @@ -107,7 +107,7 @@ $ret .= " "; $ret .= ", (year is optional)"; @@ -680,17 +680,14 @@ my $aa = {}; $aa = ®ister_authaction($u->{'userid'}, "validateemail"); - open (MAIL, "|$SENDMAIL"); - print MAIL "To: $FORM{'email'}\n"; - print MAIL "From: $LJ::ADMIN_EMAIL\n"; - print MAIL "Subject: Email Address Changed\n\n"; - print MAIL "You have just changed your LiveJournal email address. To validate the change, please go to this address:\n\n"; + my $body = qq{ +You have just changed your LiveJournal email address. To validate the change, please go to this address: - print MAIL " $LJ::SITEROOT/confirm/$aa->{'aaid'}.$aa->{'authcode'}\n\n"; - - print MAIL "Regards,\n$LJ::SITENAME Team\n\n$LJ::SITEROOT/\n"; - close MAIL; - + $LJ::SITEROOT/confirm/$aa->{'aaid'}.$aa->{'authcode'} +}; + send_admin_mail({to => $FORM{email}, + subject => "Email Address Change", + body => $body}); } # tell the user all is well ==== //ccare/main/LiveJournal/htdocs/editjournal_do.bml#4 - /u0/jaffray/p4/LiveJournal/htdocs/editjournal_do.bml ==== --- /tmp/tmp.29918.15 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/editjournal_do.bml Sat Jun 2 13:07:31 2001 @@ -8,7 +8,7 @@ require 'ljlib.pl'; require 'ljprotocol.pl'; - return &server_down_html() if ($SERVER_DOWN); + return &server_down_html() if ($LJ::SERVER_DOWN); &connect_db(); my $user = lc($FORM{'user'}); ==== //ccare/main/LiveJournal/htdocs/editstyle_do.bml#3 - /u0/jaffray/p4/LiveJournal/htdocs/editstyle_do.bml ==== --- /tmp/tmp.29918.16 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/editstyle_do.bml Sat Jun 2 14:18:39 2001 @@ -134,7 +134,7 @@ unless ($sty) { return "(=H1 Error H1=)(=P Style not found. P=)"; } $ret .= "
command console."; $ret .= "

welcome to the livejournal console. from here administrators can do administrative type things. you will forget the commands, so there is a reference.

{'user'}\">"; if ($rec->{'journaltype'} eq "C") { - $ret .= ""; + $ret .= ""; } else { - $ret .= ""; + $ret .= ""; } $ret .= "{'user'}/\">$rec->{'user'}
\n"; - $ret .= "\n"; + $ret .= "\n"; $ret .= "\n"; + $ret .= "\n"; } $ret .= "
Style View Type:$viewinfo{$sty->{'type'}}->{'des'} -- $sty->{'type'}
Style View Type:$LJ::viewinfo{$sty->{'type'}}->{'des'} -- $sty->{'type'}
Style ID Number:$sty->{'styleid'}"; if ($sty->{'type'} eq "lastn" || $sty->{'type'} eq "calendar" || $sty->{'type'} eq "search" || $sty->{'type'} eq "friends") ==== //ccare/main/LiveJournal/htdocs/friends/edit_do.bml#3 - /u0/jaffray/p4/LiveJournal/htdocs/friends/edit_do.bml ==== --- /tmp/tmp.29918.17 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/friends/edit_do.bml Sat Jun 2 13:07:42 2001 @@ -81,7 +81,7 @@ require 'ljlib.pl'; require 'ljprotocol.pl'; - return &server_down_html() if ($SERVER_DOWN); + return &server_down_html() if ($LJ::SERVER_DOWN); my @errors = (); my $user = lc($FORM{'user'}); ==== //ccare/main/LiveJournal/htdocs/interests.bml#3 - /u0/jaffray/p4/LiveJournal/htdocs/interests.bml ==== --- /tmp/tmp.29918.18 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/interests.bml Sat Jun 2 12:46:22 2001 @@ -11,6 +11,16 @@ my $qinterest = $dbh->quote($FORM{'int'}); my $interest; + sub print_interest { + my $interest = shift; + my $eint = &BMLUtil::eurl($interest); + return "$interest"; + } + sub db_error { + my $dbh = shift; + return "(=H1 Error H1=)(=P Database error: " . $dbh->errstr . " P=)"; + } + if ($FORM{'view'} eq "popular") { my $ret = ""; @@ -23,8 +33,7 @@ while (my ($int, $count) = $sth->fetchrow_array) { next if ($count == 1); - my $eint = &BMLUtil::eurl($int); - $ret .= "
$int$count
" . print_interest($int) . "$count
\n"; return $ret; @@ -63,39 +72,66 @@ return $ret; } + # there is room to optimize the main query of this mode. + # since the most popular interests take the most time to query for but are also + # the least significant, you can query for matches to everything except the most + # popular few interests, then come up with a list of candidate users for the top 100, + # and query on the really popular interests restricting it to those candidates. + # i'd estimate a potential 2-3x speedup. -- alanj 2001/05/24 + if ($FORM{'mode'} eq "findsim_do") { + my $rows; my $ret = ""; + + # get userid my $quser = $dbh->quote(lc($FORM{'user'})); $sth = $dbh->prepare("SELECT userid FROM user WHERE user=$quser"); $sth->execute; - my ($userid) = $sth->fetchrow_array; - return "(=H1 Error H1=)(=P Unknown user P=)" unless ($userid); - - $sth = $dbh->prepare("SELECT intid FROM userinterests WHERE userid=$userid"); - $sth->execute; - my @intids = (); - push @intids, $_->{'intid'} while ($_ = $sth->fetchrow_hashref); + my ($userid) = $sth->fetchrow_array + or return "(=H1 Error H1=)(=P Unknown user P=)"; - return "(=H1 Error H1=)(=P User $FORM{'user'} has no defined interests. P=)" unless (@intids); - + # get interests + $rows = $dbh->selectall_arrayref("SELECT intid FROM userinterests WHERE userid=$userid") + or return db_error($dbh); + my @intids = map {$_->[0]} @$rows + or return "(=H1 Error H1=)(=P User $FORM{'user'} has no defined interests. P=)"; my $intid_in = join(", ", @intids); - $ret .= "(=H1 Similar Users H1=)(=P The following are the most related users to $FORM{'user'}. P=)"; - $sth = $dbh->prepare("SELECT u.user, COUNT(*) AS 'count' FROM user u, userinterests ui WHERE u.userid=ui.userid AND u.statusvis='V' AND ui.intid IN ($intid_in) GROUP BY 1 ORDER BY 2 DESC, 1 ASC LIMIT 100"); - $sth->execute; - $ret .= "

\n"; - my $total = @intids; - my $count=0; - while ($_ = $sth->fetchrow_hashref) - { - $count++; - my $percent = sprintf("%.1f", $_->{'count'}*100/$total); - $ret .= ""; - $ret .= ""; - $ret .= ""; - $ret .= "\n"; + + # get number of users on the system + $rows = $dbh->selectall_arrayref("SELECT COUNT(*) FROM user") + or return db_error($dbh); + my $log_total_users = log($rows->[0][0])/log(2); + + # get top matches + my $match_rows = $dbh->selectall_hashref("SELECT u.user, ui.userid, ROUND(SUM($log_total_users - LOG(i.intcount)/LOG(2))) AS 'score' FROM user u, userinterests ui, interests i WHERE u.userid=ui.userid AND ui.intid = i.intid AND u.statusvis='V' AND ui.intid IN ($intid_in) GROUP BY 1 ORDER BY 3 DESC, 1 ASC LIMIT 100") + or return db_error($dbh); + my $userid_in = join(", ", map {$_->{userid}} @$match_rows); + + # get common interests for top matches + $rows = $dbh->selectall_hashref("SELECT ui.userid, i.interest FROM userinterests ui, interests i WHERE ui.intid = i.intid AND ui.userid IN ($userid_in) AND i.intid IN ($intid_in)") + or return db_error($dbh); + my %common_interests = (); + foreach my $row (@$rows) { + push @{$common_interests{$row->{userid}}}, $row->{interest}; } - $ret .= "
#UserSimiliar
Interests
Percent Match
$count(=LJUSER $_->{'user'} LJUSER=)$_->{'count'}($percent%)
\n"; + + $ret .= "(=H1 Similar Users H1=)(=P The following are the most related users to $FORM{'user'}. P=)"; + $ret .= "

\n"; + my $count = 0; + foreach my $match (@$match_rows) { + $count++; + $ret .= ""; + $ret .= ""; + $ret .= ""; + $ret .= ""; + $ret .= ""; + $ret .= "\n"; + } + $ret .= "
#UserScoreCommon Interests
$count(=LJUSER $match->{'user'} LJUSER=)$match->{'score'}"; + $ret .= join(", ", map {print_interest($_)} + sort @{$common_interests{$match->{userid}}}); + $ret .= "
\n"; return $ret; } @@ -120,7 +156,7 @@ $sth->execute; while ($_ = $sth->fetchrow_hashref) { $count++; - $list .= "

  • {'user'}\"> {'user'}/\">$_->{'user'} - $_->{'name'}\n"; + $list .= "
  • {'user'}\"> {'user'}/\">$_->{'user'} - $_->{'name'}\n"; } my $s = $count > 1 ? "es" : ""; @@ -146,7 +182,7 @@ $sth->execute; while ($_ = $sth->fetchrow_hashref) { $count++; - $list .= "
  • {'user'}\"> {'user'}/\">$_->{'user'} - $_->{'name'}\n"; + $list .= "
  • {'user'}\"> {'user'}/\">$_->{'user'} - $_->{'name'}\n"; } $list .= "\n"; ==== //ccare/main/LiveJournal/htdocs/lostinfo_do.bml#4 - /u0/jaffray/p4/LiveJournal/htdocs/lostinfo_do.bml ==== --- /tmp/tmp.29918.19 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/lostinfo_do.bml Sat Jun 2 13:07:57 2001 @@ -7,7 +7,7 @@ (=_CODE require 'ljlib.pl'; - return &server_down_html() if ($SERVER_DOWN); + return &server_down_html() if ($LJ::SERVER_DOWN); &connect_db; my $useroremail = &trim(lc($FORM{'useroremail'})); @@ -36,7 +36,7 @@ return $ret; } - open (MAIL, "|$SENDMAIL") || die "Couldn't send mail"; + open (MAIL, "|$LJ::SENDMAIL") || die "Couldn't send mail"; print MAIL "To: $rec->{'email'}\n"; print MAIL "From: $LJ::ADMIN_EMAIL ($LJ::SITENAME)\n"; print MAIL "Subject: Lost Password\n\n"; ==== //ccare/main/LiveJournal/htdocs/modify_do.bml#4 - /u0/jaffray/p4/LiveJournal/htdocs/modify_do.bml ==== --- /tmp/tmp.29918.20 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/modify_do.bml Sat Jun 2 14:18:52 2001 @@ -5,7 +5,7 @@ (=_CODE require 'ljlib.pl'; - return &server_down_html() if ($SERVER_DOWN); + return &server_down_html() if ($LJ::SERVER_DOWN); my @errors = (); my $user = lc($FORM{'user'}); @@ -67,9 +67,9 @@ $sth->execute; push @{$styles{$_->{'type'}}}, $_ while ($_ = $sth->fetchrow_hashref); - foreach my $view (@views) + foreach my $view (@LJ::views) { - $ret .= "$viewinfo{$view}->{'des'}\n"; foreach (grep { $_->{'user'} eq "system" } @{$styles{$view}}) { my $selected = $_->{'styleid'}==$u->{"${view}_style"} ? " SELECTED" : ""; @@ -275,7 +275,7 @@ # set all the styles { my @picked = (); - foreach my $view (@views) + foreach my $view (@LJ::views) { my $sid = $FORM{"${view}_style"}+0; if ($sid) { ==== //ccare/main/LiveJournal/htdocs/moodlist_add.bml#4 - /u0/jaffray/p4/LiveJournal/htdocs/moodlist_add.bml ==== --- /tmp/tmp.29918.21 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/moodlist_add.bml Sat Jun 2 12:14:23 2001 @@ -7,7 +7,7 @@ my $from = $FORM{'email'} || $LJ::ADMIN_EMAIL; require 'ljlib.pl'; - open (MAIL, "|$SENDMAIL"); + open (MAIL, "|$LJ::SENDMAIL"); print MAIL "To: $LJ::ADMIN_EMAIL\n"; print MAIL "From: $from\n"; print MAIL "Subject: Mood Suggestion\n\n"; ==== //ccare/main/LiveJournal/htdocs/protocol.dat#4 - /u0/jaffray/p4/LiveJournal/htdocs/protocol.dat ==== --- /tmp/tmp.29918.22 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/protocol.dat Sun May 27 08:53:00 2001 @@ -528,6 +528,9 @@ .des The time that this mode request returned last time you called it. If this is the first time you've ever called it (since your client has been running), leave this blank. It's strongly recommended that you do not remember this value across invocations of your client, as it's very likely your friends will update since the client was running so the notification is pointless... the user probably read his/her friends page already before starting the client. } +{ mask +.des +Optional. The friend group(s) in which the client is checking for new entries, represented as a 32-bit unsigned int. Turn on any combination of bits 1-30 to check for entries by friends in the respective friend groups. Turn on bit 0, or leave the mask off entirely, to check for entries by any friends. .response { lastupdate .des ==== //ccare/main/LiveJournal/htdocs/styles/create.bml#3 - /u0/jaffray/p4/LiveJournal/htdocs/styles/create.bml ==== --- /tmp/tmp.29918.23 Sun Jun 3 00:14:02 2001 +++ /u0/jaffray/p4/LiveJournal/htdocs/styles/create.bml Sat Jun 2 14:19:04 2001 @@ -36,9 +36,9 @@ $sth->execute; push @{$styles{$_->{'type'}}}, $_ while ($_ = $sth->fetchrow_hashref); - foreach my $view (@views) + foreach my $view (@LJ::views) { - $ret .= "

    $viewinfo{$view}->{'des'}\n"; + $ret .= "

    $LJ::viewinfo{$view}->{'des'}\n"; $ret .= "

      Choose base style to start with and edit: