⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mt-nofollow.cgi

📁 1. 记录每个帖子的访问人情况
💻 CGI
字号:
#!/usr/bin/perl -w# $Id: mt-nofollow.cgi 11331 2005-04-15 00:02:51Z bchoate $# Released under the Artistic License# SCRiPTMAFiA 2005 - THE DiRTY HANDS ON YOUR SCRiPTSuse strict;my ($MT_DIR, $PLUGIN_DIR, $PLUGIN_ENVELOPE);eval {    require File::Basename; import File::Basename qw( dirname );    require File::Spec;    $MT_DIR = $ENV{PWD};    $MT_DIR = dirname($0)        if !$MT_DIR || !File::Spec->file_name_is_absolute($MT_DIR);    $MT_DIR = dirname($ENV{SCRIPT_FILENAME})         if ((!$MT_DIR || !File::Spec->file_name_is_absolute($MT_DIR))             && $ENV{SCRIPT_FILENAME});    unless ($MT_DIR && File::Spec->file_name_is_absolute($MT_DIR)) {        die "Plugin couldn't find own location";    }}; if ($@) {    print "Content-type: text/html\n\n$@";     exit(0);}$PLUGIN_DIR = $MT_DIR;($MT_DIR, $PLUGIN_ENVELOPE) = $MT_DIR =~ m|(.*[\\/])(plugins[\\/].*)$|i;unshift @INC, $MT_DIR . 'lib';unshift @INC, $MT_DIR . 'extlib';package MT::App::Nofollow;require MT::App;@MT::App::Nofollow::ISA = 'MT::App';sub init {    my $app = shift;    $app->SUPER::init (@_) or return;     $app->add_methods (        default => \&show_form,        save => \&save_form            );     $app->{default_mode} = 'default';    $app->{requires_login} = 1;     $app;   }sub show_form {    my $app = shift;    my (%param) = @_;    require MT::PluginData;    my $pd = MT::PluginData->load({plugin => 'Nofollow',                                   key => 'configuration'});    my $data = $pd ? $pd->data() || {} : {};    my $author = $app->{author};    return $app->error("You cannot edit the settings for Nofollow")        unless $author->can_create_blog;    $data->{nofollow_enabled} = 1 unless exists $data->{nofollow_enabled};    $data->{follow_auth_links} = 0 unless exists $data->{follow_auth_links};    $param{$_} = $data->{$_} foreach $app->config_params;    $app->add_breadcrumb( 'Nofollow Plugin' );    $app->build_page('nofollow.tmpl', \%param);}sub config_params {    qw(nofollow_enabled follow_auth_links);}sub save_form {    my $app = shift;    my $auth = $app->{author};    my $q = $app->{query};    my $author = $app->{author};    return $app->error("You cannot edit the settings for Nofollow")         unless $author->can_create_blog;    $app->validate_magic() or return;    require MT::PluginData;    my $pd = MT::PluginData->load({plugin => 'Nofollow',                                   key => 'configuration'});    if (!$pd) {        $pd = new MT::PluginData;        $pd->plugin('Nofollow');        $pd->key('configuration');    }    my $config = $pd->data() || {};    $config->{$_} = $q->param($_) || undef foreach $app->config_params;    $pd->data($config);    $pd->save or die $pd->errstr;    # save a reference for the php plugin...    foreach my $param ($app->config_params) {        $pd = MT::PluginData->load({plugin => 'Nofollow',                                    key => 'configuration/' . $param});        if (!$pd) {            $pd = new MT::PluginData;            $pd->plugin('Nofollow');            $pd->key('configuration/'.$param);        }        # prevents data from being serialized...        $pd->column('data', $config->{$param} || '0');        $pd->save or die $pd->errstr;    }    my %param;    $param{message} = "Settings updated.";    $app->show_form(%param);}eval {    my $app = MT::App::Nofollow->new(        Config => $MT_DIR . 'mt.cfg',        Directory => $MT_DIR    ) or die MT::App::Nofollow->errstr;    local $SIG{__WARN__} = sub { $app->trace ($_[0]) };    $app->run;};if ($@) {    print "Content-Type: text/html\n\n";    print "An error occurred: $@";}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -