| author | fu |
| Thu Feb 23 02:21:54 2012 +0800 | |
| changeset 4315 | 34b3c4ba3afb |
| parent 287 | afd258f377d2 |
| permissions | -rw-r--r-- |
| mark@287 | 1 |
# |
| mark@287 | 2 |
# Hooks to allow posting to Changelog. |
| mark@287 | 3 |
# |
| mark@287 | 4 |
# Authors: |
| mark@287 | 5 |
# Mark Smith <mark@dreamwidth.org> |
| mark@287 | 6 |
# |
| mark@287 | 7 |
# Copyright (c) 2009 by Dreamwidth Studios, LLC. |
| mark@287 | 8 |
# |
| mark@287 | 9 |
# This program is free software; you may redistribute it and/or modify it under |
| mark@287 | 10 |
# the same terms as Perl itself. For a copy of the license, please reference |
| mark@287 | 11 |
# 'perldoc perlartistic' or 'perldoc perlgpl'. |
| mark@287 | 12 |
# |
| mark@287 | 13 |
|
| mark@287 | 14 |
package DW::Hooks::Changelog;; |
| mark@287 | 15 |
|
| mark@287 | 16 |
use strict; |
| mark@2019 | 17 |
use LJ::Hooks; |
| mark@287 | 18 |
|
| mark@2019 | 19 |
LJ::Hooks::register_hook( 'post_noauth', sub {
|
| mark@287 | 20 |
my $req = shift; |
| mark@287 | 21 |
|
| mark@287 | 22 |
# enable or not |
| mark@287 | 23 |
return 0 unless $LJ::CHANGELOG{enabled};
|
| mark@287 | 24 |
|
| mark@287 | 25 |
# the user must be posting TO the changelog journal and the |
| mark@287 | 26 |
# username must be in the allow list |
| mark@287 | 27 |
return 0 unless $req->{usejournal} eq $LJ::CHANGELOG{community};
|
| mark@287 | 28 |
return 0 unless grep { $_ eq $req->{username} } @{ $LJ::CHANGELOG{allowed_posters} || [] };
|
| mark@287 | 29 |
|
| mark@287 | 30 |
# we also enforce that the IP the request is coming from be one of |
| mark@287 | 31 |
# some small list of IPs |
| mark@287 | 32 |
my $ip = BML::get_remote_ip(); |
| mark@287 | 33 |
return 0 unless grep { $_ eq $ip } @{ $LJ::CHANGELOG{allowed_ips} || [] };
|
| mark@287 | 34 |
|
| mark@287 | 35 |
# looks good |
| mark@287 | 36 |
return 1; |
| mark@287 | 37 |
} ); |
| mark@287 | 38 |
|
| mark@287 | 39 |
1; |