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

📄 cms.pm

📁 1. 记录每个帖子的访问人情况
💻 PM
📖 第 1 页 / 共 5 页
字号:
                    $param{allow_comments} = $blog->allow_comments_default                        unless defined $q->param('allow_comments');                    $param{allow_pings} = $blog->allow_pings_default                        unless defined $q->param('allow_pings');                }                require POSIX;                $param{created_on_formatted} = $q->param('created_on_manual')                               || POSIX::strftime("%Y-%m-%d %H:%M:%S",                                            offset_time_list(time, $blog));                if ($q->param('is_bm')) {                    $param{selected_text} = $param{text};                    $param{text} = sprintf qq(<a title="%s" href="%s">%s</a>\n\n%s),                        scalar $q->param('link_title'),                        scalar $q->param('link_href'),                        scalar $q->param('link_title'),                        $param{text};                    my $show = $q->param('bm_show') || '';                    if ($show =~ /\b(trackback|t)\b/) {                        $param{show_trackback} = 1;                        ## Now fetch original page and scan it for embedded                        ## TrackBack RDF tags.                        my $url = $q->param('link_href');                        if (my $items = MT::Util::discover_tb($url, 1)) {                            if (@$items == 1) {                                $param{to_ping_urls} = $items->[0]->{ping_url};                            } else {                                $param{to_ping_url_loop} = $items;                            }                        }                    }                    # This is needed for the QuickPost entry screen.                    require MT::Permission;                    my $iter = MT::Permission->load_iter({ author_id =>                        $app->{author}->id });                    my @data;                    while (my $perms = $iter->()) {                        next unless $perms->can_post;                        my $blog = MT::Blog->load($perms->blog_id);                        next unless $blog;                        push @data, { blog_id => $blog->id,                                      blog_name => $blog->name,                                      blog_convert_breaks => $blog->convert_paras,                                      blog_status => $blog->status_default,                                      blog_allow_comments =>                                          $blog->allow_comments_default,                                      blog_allow_pings =>                                          $blog->allow_pings_default, };                        $param{avail_blogs}{$blog->id} = 1;                    }                    @data = sort { $a->{blog_name} cmp $b->{blog_name} } @data;                    $param{blog_loop} = \@data;                }            } elsif ($type eq 'template') {                $app->add_breadcrumb($app->translate('Templates'), $app->uri . '?__mode=list&_type=template&blog_id=' . $blog->id);                $app->add_breadcrumb($app->translate('New Template'));                my $template_type = $q->param('type')                       || return $app->errtrans("Create template requires type");                $param{has_name} = $template_type eq 'index' ||                                   $template_type eq 'custom' ||                                   $template_type eq 'archive' ||                                   $template_type eq 'category' ||                                   $template_type eq 'individual';                $param{has_outfile} = $template_type eq 'index';                $param{has_rebuild} = $template_type eq 'index';                $param{custom_dynamic} = $blog->custom_dynamic_templates eq 'custom';                $param{has_build_options} =                         $blog->custom_dynamic_templates eq 'custom'                          || $param{has_rebuild};                $param{is_special} = $param{type} ne 'index'                                     && $param{type} ne 'archive'                                     && $param{type} ne 'category'                                     && $param{type} ne 'individual';                $param{has_build_options} = $param{has_build_options}                                             && $param{type} ne 'custom'                                             && !$param{is_special};;                $param{rebuild_me} = 1;            } elsif ($type eq 'blog') {                $app->add_breadcrumb($app->translate('New Weblog'));                $param{server_offset_0} = 1;            } elsif ($type eq 'comment') {                return $app->error($app->translate('Permission denied'));            }        }        # Regardless of whether the obj is new, load data into $param        if ($type eq 'entry') {            ## Load categories and process into loop for category pull-down.            require MT::Placement;            my $cat_id = $param{category_id};            my $depth = 0;             my %places;                            if ($id) {                my @places = MT::Placement->load({ entry_id => $id, is_primary => 0});                %places = map { $_->category_id => 1 } @places;            }            my @data = _build_category_list($blog_id, undef, 1);            foreach (@data) {                next unless exists $_->{category_id};                $_->{category_is_primary} = $cat_id && $cat_id == $_->{category_id};                $param{selected_category} = $_->{category_id} if $_->{category_is_primary};                $_->{category_is_selected} = exists $places{$_->{category_id}} || $_->{category_is_primary};            }            my $top = { category_id => '',                        category_label => $app->translate('Select') };            $top->{category_is_selected} = 1 unless $cat_id;            $param{category_loop} = [ $top, @data ];            $param{have_multiple_categories} = scalar @data > 1;            $param{add_category_loop} = \@data;            ## Now load user's preferences and customization for new/edit            ## entry page.            if ($perms) {                my $prefs = $perms->entry_prefs || 'Advanced|Bottom';                ($prefs, my($pos)) = split /\|/, $prefs;                if ($prefs eq 'Basic') {                    $param{'disp_prefs_' . $prefs} = 1;                } elsif ($prefs eq 'Advanced') {                    my @all = qw( category extended excerpt convert_breaks                                  allow_comments authored_on allow_pings                                   ping_urls );                    for my $p (@all) {                        $param{'disp_prefs_show_' . $p} = 1;                    }                } else {                    my @p = split /,/, $prefs;                    for my $p (@p) {                        $param{'disp_prefs_show_' . $p} = 1;                    }                }                if ($pos eq 'Both') {                    $param{'position_buttons_top'} = 1;                    $param{'position_buttons_bottom'} = 1;                    $param{'position_buttons_both'} = 1;                } else {                    $param{'position_buttons_' . $pos} = 1;                }                $param{disp_prefs_bar_colspan} = $param{new_object} ? 1 : 2;            }            ## Load text filters.            my %entry_filters;            if (defined(my $filter = $q->param('convert_breaks'))) {                $entry_filters{$filter} = 1;            } elsif ($obj) {                %entry_filters = map { $_ => 1 }                                 @{ $obj->text_filters };            } else {                my $blog = MT::Blog->load($blog_id);                my $cb = $blog->convert_paras;                $cb = '__default__' if $cb eq '1';                $entry_filters{$cb} = 1;                $param{convert_breaks} = $cb;            }            my $filters = MT->all_text_filters;            $param{text_filters} = [];            for my $filter (keys %$filters) {                push @{ $param{text_filters} }, {                    filter_key => $filter,                    filter_label => $filters->{$filter}{label},                    filter_selected => $entry_filters{$filter},                    filter_docs => $filters->{$filter}{docs},                };            }            $param{text_filters} = [                sort { $a->{filter_key} cmp $b->{filter_key} }                @{ $param{text_filters} } ];            unshift @{ $param{text_filters} }, {                filter_key => '0',                filter_label => $app->translate('None'),                filter_selected => (!keys %entry_filters),            };        } elsif ($type eq 'template') {            $param{"type_$param{type}"} = 1;        } elsif ($type eq 'blog') {            my $cwd = '';            if ($ENV{MOD_PERL}) {                ## If mod_perl, just use the document root.                $cwd = $app->{apache}->document_root;            } else {                ## Try to get the current directory; first try to use                ## getcwd(), in case we are running with taint enabled. If                ## that fails (inability to open directory, for example),                ## try using cwd(). If that fails, use nothing.                require Cwd;                {                    my($bad);                    local $SIG{__WARN__} = sub { $bad++ };                    eval { $cwd = Cwd::getcwd() };                    if ($bad || $@) {                        eval { $cwd = Cwd::cwd() };                        if ($@ && $@ !~ /Insecure \$ENV{PATH}/) {                            die $@;                        }                    }                }            }            $cwd =~ s!([\\/])cgi-bin([\\/].*)?$!$1!;            $cwd =~ s!([\\/])mt[\\/]?$!$1!i;            if (!$param{site_path}) {                $param{site_path} = $cwd;            }            if (!$param{archive_path}) {                $param{archive_path} = File::Spec->catdir($cwd, 'archives');            }            if (!$param{site_url}) {                $param{site_url} = $app->base . '/';                $param{site_url} =~ s!/cgi-bin(/.*)?$!/!;                $param{site_url} =~ s!/mt/?$!/!i;            }            if (!$param{archive_url}) {                $param{archive_url} = $param{site_url} . 'archives/';            }        } elsif ($type eq 'author') {            $app->add_breadcrumb($obj->name);            my $langs = $app->supported_languages;            my @data;            my $preferred = $obj && $obj->preferred_language ?                $obj->preferred_language : 'en-us';            $preferred = 'en-us' if (lc($preferred) eq 'en_us');            for my $tag (keys %$langs) {                my $row = { l_tag => $tag, l_name => $app->translate($langs->{$tag}) };                $row->{l_selected} = 1 if $preferred eq $tag;                push @data, $row;            }            $param{languages} = [ sort { $a->{l_name} cmp $b->{l_name} }                                  @data ];        }	if (($q->param('msg')||"") eq 'nosuch') {	    $param{nosuch} = 1;	}        for my $p ($q->param) {            $param{$p} = $q->param($p) if $p =~ /^saved/;        }        if ($type eq 'comment') {	    my $cmntr = MT::Author->load({ id => $obj->commenter_id(),				           type => MT::Author::COMMENTER });	    $param{email_hidden} = $cmntr && $cmntr->is_email_hidden();            $param{email} = $cmntr ? $cmntr->email : $obj->email;            $param{_return} = 'edit_comment';            $param{comments_script_uri} = MT::ConfigMgr->instance->CommentScript;            if ($cmntr) {                $param{profile_page} = $app->{cfg}->IdentityURL;                $param{profile_page} .= "/" unless $param{profile_page} =~ m|/$|;                $param{profile_page} .= $cmntr->name();            }        }        if ($type ne 'blog' && defined($MT::PluginActions{$type})) {            $param{plugin_action_loop} = $MT::PluginActions{$type};        }        $param{_return} ||= $q->param('_return');        if ($q->param('is_bm')) {            my $show = $q->param('bm_show') || '';            my %opts = ('c' => 'category', 't' => 'trackback', 'ap' => 'allow_pings', 'ac' => 'allow_comments', 'cb' => 'convert_breaks', 'e' => 'excerpt', 'k' => 'keywords', 'm' => 'text_more');            if ($show) {                my @show = map "show_$_", split /,/, $show;                @param{ @show } = (1) x @show;                # map the shortened show options to the long names used in the                # quick post template                foreach (@show) {                    s/^show_//;                    $param{"show_" . $opts{$_}} = 1 if exists $opts{$_};                }            }            if ($show =~ /\b(category|c)\b/) {                #my $iter = MT::Category->load_iter({}, { 'sort' => 'label' });                #my @i;                my @c_data;                my %avail_blogs = %{ $param{avail_blogs} };                #while (my $cat = $iter->()) {                #    my $blog_id = $cat->blog_id;                #    next unless $avail_blogs{$blog_id};                #    my $label = $cat->label;                #    $label =~ s!'!\\'!g;                #    $i[$blog_id] = 0 unless defined $i[$blog_id];                #    push @c_data, {                #            category_blog_id => $blog_id,                #            category_index => $i[$blog_id]++,                #            category_id => $cat->id,                #            category_label => $label                #    };                #}                foreach my $blog_id (keys %avail_blogs) {                    my @blog_cats = _build_category_list($blog_id);                    my $i = 0;                    for my $row (@blog_cats) {                        $row->{category_blog_id} = $blog_id;                        $row->{category_index} = $i++;                        my $spacer = $row->{category_label_spacer} || '';                        $spacer =~ s/\&nbsp;/\\u00A0/g;                        $row->{category_label_js} = $spacer . MT::Util::encode_js($row->{category_label});                    }                    push @c_data, @blog_cats;                }                $param{category_loop} = \@c_data;

⌨️ 快捷键说明

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