Skip to content

Commit

Permalink
Remove some more unused code
Browse files Browse the repository at this point in the history
None of this is used in production Dreamwidth, hasn't been for years, so
let's remove it to simplify our codebase. We can always revive things we
end up deciding we want.
  • Loading branch information
zorkian committed Jan 25, 2015
1 parent e5aeaa1 commit fd7d31f
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 350 deletions.
47 changes: 0 additions & 47 deletions bin/update-tor-exits

This file was deleted.

3 changes: 0 additions & 3 deletions bin/upgrading/base-data.sql
Expand Up @@ -262,8 +262,6 @@ REPLACE INTO codes (code, item, sortorder, type) VALUES ('wa', 'Western Australi
REPLACE INTO codes (code, item, sortorder, type) VALUES ('yt', 'Yukon Territory', '0', 'stateca');
INSERT IGNORE INTO priv_list (des, is_public, privcode, privname, scope) VALUES ('Allows a user to grant or revoke privileges to/from other users. arg=Unique privcode that the user has access to grant/deny for, or \"*\" for all privileges.', '0', 'admin', 'Administer privileges', 'general');
UPDATE priv_list SET des='Allows a user to grant or revoke privileges to/from other users. arg=Unique privcode that the user has access to grant/deny for, or \"*\" for all privileges.',is_public='0',privname='Administer privileges',scope='general' WHERE privcode='admin';
INSERT IGNORE INTO priv_list (des, is_public, privcode, privname, scope) VALUES ('Allows a user to set an IP address as being allowed if it\'s listed as an open proxy.', '0', 'allowopenproxy', 'Allow Open Proxy', 'general');
UPDATE priv_list SET des='Allows a user to set an IP address as being allowed if it\'s listed as an open proxy.',is_public='0',privname='Allow Open Proxy',scope='general' WHERE privcode='allowopenproxy';
INSERT IGNORE INTO priv_list (des, is_public, privcode, privname, scope) VALUES ('Allows a user to view information that isn\'t otherwise available. All use is logged. arg=Arg=\"*\": can view everything, Arg=\"suspended\": can view public posts in a suspended journal, Arg=\"userlog\": can see userlog data.', '0', 'canview', 'View All Entries', 'general');
UPDATE priv_list SET des='Allows a user to view information that isn\'t otherwise available. All use is logged. arg=Arg=\"*\": can view everything, Arg=\"suspended\": can view public posts in a suspended journal, Arg=\"userlog\": can see userlog data.',is_public='0',privname='View All Entries',scope='general' WHERE privcode='canview';
INSERT IGNORE INTO priv_list (des, is_public, privcode, privname, scope) VALUES ('Allows a user to change another user\'s journal type.', '1', 'changejournaltype', 'Change Journal Type', 'general');
Expand Down Expand Up @@ -641,7 +639,6 @@ REPLACE INTO schematables (des, public_browsable, redist_mode, redist_where, tab
REPLACE INTO schematables (des, public_browsable, redist_mode, redist_where, tablename) VALUES ('Global. Stores log of viewings of individual [dbtable[faq]]s by logged-in users.', '0', 'off', NULL, 'faquses');
REPLACE INTO schematables (des, public_browsable, redist_mode, redist_where, tablename) VALUES ('Global. Stores metadata on Support requests.', '0', 'off', NULL, 'supportprop');
REPLACE INTO schematables (des, public_browsable, redist_mode, redist_where, tablename) VALUES ('Global. Stores new S2 layer sources, and those lazily migrated from [dbtable[s2source]].\n\r\nCreated to do a live migration from the old MyISAM table ([dbtable[s2source]]) to this new InnoDB table without requiring downtime.', '0', 'off', NULL, 's2source_inno');
REPLACE INTO schematables (des, public_browsable, redist_mode, redist_where, tablename) VALUES ('Global. Stores open HTTP proxies data. Site administrators can set open proxy lookup sources using the @LJ::RBL_LIST site variable.', '0', 'off', NULL, 'openproxy');
REPLACE INTO schematables (des, public_browsable, redist_mode, redist_where, tablename) VALUES ('Global. Stores partialstats calculation times.', '0', 'off', NULL, 'partialstats');
REPLACE INTO schematables (des, public_browsable, redist_mode, redist_where, tablename) VALUES ('Global. Stores per-cluster partialstats data.', '0', 'off', NULL, 'partialstatsdata');
REPLACE INTO schematables (des, public_browsable, redist_mode, redist_where, tablename) VALUES ('Global. Stores per-user backup status.', '0', 'off', NULL, 'backupdirty');
Expand Down
21 changes: 2 additions & 19 deletions bin/upgrading/update-db-general.pl
Expand Up @@ -979,6 +979,8 @@
register_tabledrop("site_messages");
register_tabledrop("navtag");
register_tabledrop("syndicated_hubbub2");
register_tabledrop("openproxy");
register_tabledrop("tor_proxy_exits");

register_tablecreate("infohistory", <<'EOC');
CREATE TABLE infohistory (
Expand Down Expand Up @@ -1661,18 +1663,6 @@
)
EOC

# track open HTTP proxies
register_tablecreate("openproxy", <<'EOC');
CREATE TABLE openproxy (
addr VARCHAR(15) NOT NULL,
status ENUM('proxy', 'clear'),
asof INT UNSIGNED NOT NULL,
src VARCHAR(80),
PRIMARY KEY (addr)
)
EOC

register_tablecreate("spamreports", <<'EOC'); # global
CREATE TABLE spamreports (
reporttime INT(10) UNSIGNED NOT NULL,
Expand Down Expand Up @@ -3111,13 +3101,6 @@
)
EOC

register_tablecreate('tor_proxy_exits', <<'EOC');
CREATE TABLE tor_proxy_exits (
addr VARCHAR(15) NOT NULL,
PRIMARY KEY (addr)
)
EOC

register_tablecreate('externaluserinfo', <<'EOC');
CREATE TABLE externaluserinfo (
site INT UNSIGNED NOT NULL,
Expand Down
30 changes: 0 additions & 30 deletions cgi-bin/Apache/LiveJournal.pm
Expand Up @@ -249,33 +249,6 @@ sub blocked_anon
return OK;
}

# returns whether or not an IP address is from the Tor proxy exit list, but only if we're configured
# to actually use this data
sub ip_is_via_tor {
return unless $LJ::USE_TOR_CONFIGS;

# try to load the data every few minutes so that we keep it reasonably fresh, but so that we don't
# hammer the database all of the time
unless ( defined $TOR_UPDATE_TIME && $TOR_UPDATE_TIME > time ) {
# either way, wait a few minutes before trying again, that way we don't hammer things if the
# database is down or something
$TOR_UPDATE_TIME = time + 300;

# be very conscientious not to get rid of data if we get a db error
my $dbh = LJ::get_db_writer() or return;
my $ips = $dbh->selectcol_arrayref( 'SELECT addr FROM tor_proxy_exits' );
return if $dbh->err;

if ( $ips && ref $ips eq 'ARRAY' ) {
%TOR_EXITS = ();
$TOR_EXITS{$_} = 1 foreach @$ips;
}
}

# regardless of what happened above we can check and return
return exists $TOR_EXITS{$_[0]};
}

sub resolve_path_for_uri {
my ( $apache_r, $orig_uri ) = @_;

Expand Down Expand Up @@ -482,9 +455,6 @@ sub trans
$apache_r->push_handlers( PerlResponseHandler => \&blocked_bot );
return OK;
}

# determine if this IP is one of the tor exits and set a note on the request
$apache_r->notes->{via_tor_exit} = 1 if ip_is_via_tor( $ip );
}
if ( LJ::Hooks::run_hook( "forbid_request", $apache_r ) ) {
$apache_r->handler( "perl-script" );
Expand Down
4 changes: 0 additions & 4 deletions cgi-bin/DW/Shop.pm
Expand Up @@ -173,10 +173,6 @@ sub remote_sysban_check {
}
}

# now do a tor check
return BML::ml( 'error.blocked', { blocktype => "Tor proxy", email => $LJ::ACCOUNTS_EMAIL } )
if LJ::Sysban::tor_check( 'shop' );

# looks good
return undef;
}
Expand Down
4 changes: 0 additions & 4 deletions cgi-bin/LJ/ConfCheck/General.pm
Expand Up @@ -699,10 +699,6 @@ add_conf('%USERPROP_DEF',
des => "Hash of userprop defaults. See also %USERPROP_INIT."
);

add_conf('@RBL_LIST',
des => "Used by LJ::is_open_proxy."
);

add_conf('@INITIAL_OPTOUT_SUBSCRIPTIONS',
des => "Array of users checked by default on create.bml."
);
Expand Down
59 changes: 0 additions & 59 deletions cgi-bin/LJ/Console/Command/AllowOpenProxy.pm

This file was deleted.

2 changes: 1 addition & 1 deletion cgi-bin/LJ/Setting/CtxPopup.pm
Expand Up @@ -19,7 +19,7 @@ use warnings;
sub should_render {
my ($class, $u) = @_;

return !$LJ::CTX_POPUP || !$u || $u->is_community ? 0 : 1;
return !$u || $u->is_community ? 0 : 1;
}

sub label {
Expand Down
7 changes: 0 additions & 7 deletions cgi-bin/LJ/Sysban.pm
Expand Up @@ -261,13 +261,6 @@ sub sysban_populate {
}


# here because it relates to sysbans ...
sub tor_check {
return 0 unless $LJ::USE_TOR_CONFIGS && $LJ::TOR_CONFIG{$_[0]};
return DW::Request->get->note( 'via_tor_exit' ) ? 1 : 0;
}


sub _db_sysban_populate {
my ($where, $what) = @_;
my $dbh = LJ::get_db_writer();
Expand Down
102 changes: 26 additions & 76 deletions cgi-bin/ljlib.pl
Expand Up @@ -1004,34 +1004,32 @@ sub start_request
if LJ::is_enabled('esn_ajax');

# contextual popup JS
if ( $LJ::CTX_POPUP ) {
LJ::need_res( { priority => $LJ::LIB_RES_PRIORITY, group => "default" }, qw(
js/6alib/ippu.js
js/lj_ippu.js
js/6alib/hourglass.js
js/contextualhover.js
stc/contextualhover.css
));

my @ctx_popup_libraries = qw(
js/jquery/jquery.ui.core.js
js/jquery/jquery.ui.widget.js
js/jquery/jquery.ui.tooltip.js
js/jquery.ajaxtip.js
js/jquery/jquery.ui.position.js
stc/jquery/jquery.ui.core.css
stc/jquery/jquery.ui.tooltip.css
js/jquery.hoverIntent.js
js/jquery.contextualhover.js
stc/jquery.contextualhover.css
);

LJ::need_res( { priority => $LJ::LIB_RES_PRIORITY, group=> 'jquery' }, @ctx_popup_libraries );
LJ::need_res( { priority => $LJ::LIB_RES_PRIORITY, group=> 'foundation' }, @ctx_popup_libraries );
}
LJ::need_res( { priority => $LJ::LIB_RES_PRIORITY, group => "default" }, qw(
js/6alib/ippu.js
js/lj_ippu.js
js/6alib/hourglass.js
js/contextualhover.js
stc/contextualhover.css
));

my @ctx_popup_libraries = qw(
js/jquery/jquery.ui.core.js
js/jquery/jquery.ui.widget.js
js/jquery/jquery.ui.tooltip.js
js/jquery.ajaxtip.js
js/jquery/jquery.ui.position.js
stc/jquery/jquery.ui.core.css
stc/jquery/jquery.ui.tooltip.css
js/jquery.hoverIntent.js
js/jquery.contextualhover.js
stc/jquery.contextualhover.css
);

LJ::need_res( { priority => $LJ::LIB_RES_PRIORITY, group=> 'jquery' }, @ctx_popup_libraries );
LJ::need_res( { priority => $LJ::LIB_RES_PRIORITY, group=> 'foundation' }, @ctx_popup_libraries );

# development JS
LJ::need_res( { priority => $LJ::LIB_RES_PRIORITY }, qw(
Expand Down Expand Up @@ -1440,54 +1438,6 @@ sub is_web_context {
return $ENV{MOD_PERL} ? 1 : 0;
}

sub is_open_proxy
{
my $ip = $_[0] || DW::Request->get;
return 0 unless $ip;

if ( ref $ip ) {
$ip = $ip->get_remote_ip;
}

my $dbr = LJ::get_db_reader();
my $stat = $dbr->selectrow_hashref("SELECT status, asof FROM openproxy WHERE addr=?",
undef, $ip);

# only cache 'clear' hosts for a day; 'proxy' for two days
$stat = undef if $stat && $stat->{'status'} eq "clear" && $stat->{'asof'} > 0 && $stat->{'asof'} < time()-86400;
$stat = undef if $stat && $stat->{'status'} eq "proxy" && $stat->{'asof'} < time()-2*86400;

# open proxies are considered open forever, unless cleaned by another site-local mechanism
return 1 if $stat && $stat->{'status'} eq "proxy";

# allow things to be cached clear for a day before re-checking
return 0 if $stat && $stat->{'status'} eq "clear";

# no RBL defined?
return 0 unless @LJ::RBL_LIST;

my $src = undef;
my $rev = join('.', reverse split(/\./, $ip));
foreach my $rbl (@LJ::RBL_LIST) {
my @res = gethostbyname("$rev.$rbl");
if ($res[4]) {
$src = $rbl;
last;
}
}

my $dbh = LJ::get_db_writer();
if ($src) {
$dbh->do("REPLACE INTO openproxy (addr, status, asof, src) VALUES (?,?,?,?)", undef,
$ip, "proxy", time(), $src);
return 1;
} else {
$dbh->do("INSERT IGNORE INTO openproxy (addr, status, asof, src) VALUES (?,?,?,?)", undef,
$ip, "clear", time(), $src);
return 0;
}
}

# loads an include file, given the bare name of the file.
# ($filename)
# returns the text of the file. if the file is specified in %LJ::FILEEDIT_VIA_DB
Expand Down
8 changes: 0 additions & 8 deletions doc/config-local.pl.txt
Expand Up @@ -61,14 +61,6 @@
api_key => $DW::PRIVATE::TEXTCAPTCHA{api_key},
);

# If enabled, disable people coming in over Tor exits from using various parts of the site.
$USE_TOR_CONFIGS = 0;

# Configure what you want blocked here. Requires $USE_TOR_CONFIGS to be on.
%TOR_CONFIG = (
shop => 1, # Disallow Tor users from accessing the Shop.
);

# PayPal configuration. If you want to use PayPal, uncomment this
# section and make sure to fill in the fields at the bottom of config-private.pl.
#%PAYPAL_CONFIG = (
Expand Down

0 comments on commit fd7d31f

Please sign in to comment.