免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1543 | 回复: 0
打印 上一主题 下一主题

perl高手们帮帮小妹吧!!!! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-09-19 09:28 |只看该作者 |倒序浏览
我在做backuppc,是使用 perl编写的,但其网页上没有logout这一选项,可老板让 我自己写出来,我根本没有用过perl,上网查也查不到有使用perl编写的logout脚本,还望各位高手贴出来一个脚本,让我 参考。谢谢!!!!


在线等待!!!

现我贴出来一个backuppc使用perl编写的其中一个脚本:


squid:/data/BackupPC/backuppc/lib/BackupPC/CGI # more LOGlist.pm

package BackupPC::CGI::LOGlist;

use strict;
use BackupPC::CGI::Lib qw(:all);

sub action
{
    my $Privileged = CheckPermission($In{host});

    if ( !$Privileged ) {
        ErrorExit($Lang->{Only_privileged_users_can_view_log_files});
    }
    my $host = $In{host};
    my($url0, $hdr, @files, $str);
    if ( $host ne "" ) {
        $url0 = "&host=${EscURI($host)}";
        $hdr = "for host $host";
    } else {
        $url0 = "";
        $hdr = "";
    }

    foreach my $file ( $bpc->sortedPCLogFiles($host) ) {
        my $url1 = "&num=$1" if ( $file =~ /LOG\.(\d+)(\.z)?$/ );
        $url1    = "&num="   if ( $file =~ /LOG(\.z)?$/ );
        next if ( !-f $file );
        my $mtimeStr = $bpc->timeStamp((stat($file))[9], 1);
        my $size     = (stat($file))[7];
        (my $fStr    = $file) =~ s{.*/}{};
        $str .= <<EOF;
<tr><td> <a href="$MyURL?action=view&type=LOG$url0$url1"><tt>$fStr</tt></a></td>    <td align="right"> $size </td>
    <td> $mtimeStr </td></tr>
EOF
    }
    my $content = eval("qq{$Lang->{Log_File_History__hdr}}";
    Header($Lang->{BackupPC__Log_File_History},
                $content, !-f "$TopDir/pc/$host/backups";
    Trailer();
}

sub compareLOGName
{
    #my($a, $b) = @_;

    my $na = $1 if ( $a =~ /LOG\.(\d+)/ );
    my $nb = $1 if ( $b =~ /LOG\.(\d+)/ );

    if ( length($na) >= 5 && length($nb) >= 5 ) {
        #
        # Both new style.  Bigger numbers are more recent.
        #
        return $nb <=> $na;
    } elsif ( length($na) >= 5 && length($nb) < 5 ) {
        return -1;
    } elsif ( length($na) < 5 && length($nb) >= 5 ) {
        return 1;
    } else {
        #
        # Both old style.  Smaller numbers are more recent.
        #
        return $na - $nb;
    }
}


1;
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP