This file is indexed.

/usr/share/irssi/scripts/uptime.pl is in irssi-scripts 20120326.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# uptime - irssi 0.7.98.CVS 
#
#    $Id: uptime.pl,v 1.6 2003/02/04 02:43:06 peder Exp $
#
# Copyright (C) 2002, 2003 by Peder Stray <peder@ninja.no>
#

use strict;
use Irssi;
use Irssi::Irc;
use Irssi::TextUI;

# ======[ Script Header ]===============================================

use vars qw{$VERSION %IRSSI};
($VERSION) = '$Revision: 1.6 $' =~ / (\d+\.\d+) /;
%IRSSI = (
          name        => 'uptime',
          authors     => 'Peder Stray',
          contact     => 'peder@ninja.no',
          url         => 'http://ninja.no/irssi/uptime.pl',
          license     => 'GPL',
          description => 'Try a little harder to figure out client uptime',
	  sbitems     => 'uptime',
         );

# ======[ Variables ]===================================================

my($timer) = 0;			# ID of current timer

# ======[ Helper functions ]============================================

# --------[ uptime_linux ]----------------------------------------------

sub uptime_linux {
    my($sys_uptime);
    my($irssi_start);
    local(*FILE);

    open FILE, "< /proc/uptime";
    $sys_uptime = (split " ", <FILE>)[0];
    close FILE;

    open FILE, "< /proc/$$/stat";
    $irssi_start = (split " ", <FILE>)[21];
    close FILE;

    return $sys_uptime - $irssi_start/100;
}

# --------[ uptime_solaris ]--------------------------------------------

sub uptime_solaris {
    my($irssi_start);

    $irssi_start = time - (stat("/proc/$$"))[9];

    return $irssi_start;
}

# --------[ uptime ]----------------------------------------------------

sub uptime {
    my($sysname) = @_;
    my($time);

    if ($sysname eq 'Linux') {
	$time = uptime_linux;
    } elsif ($sysname eq 'SunOS') {
	$time = uptime_solaris;
    } else {
	$time = time - $^T;
    }

    return $time;
}

# --------[ format_interval ]-------------------------------------------

sub format_interval {
    my($interval) = @_;

    my(@interval,$str);
    for (60, 60, 24, 365) {
	push @interval, $interval%$_;
	$interval = int($interval/$_);
    }
    $str = sprintf "%dy %dd %dh %dm %ds", $interval, @interval[3,2,1,0];
    $str =~ s/^(0. )+//;

    return $str;
}

# ======[ Commands ]====================================================

# --------[ cmd_uptime ]------------------------------------------------

sub cmd_uptime {
    my($data,$server,$witem) = @_;
    my($sysname) = Irssi::parse_special('$sysname');
    my($uptime) = uptime($sysname);
    my($str) = format_interval($uptime);

    if ($data && $server) {
	$server->command("MSG $data uptime: $str");
    } elsif ($witem && ($witem->{type} eq "CHANNEL" ||
                        $witem->{type} eq "QUERY")) {
	$witem->command("MSG ".$witem->{name}." uptime: $str");
    } else {
	Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'uptime',
			   $str, $sysname);
    }
}

# ======[ Signal Hooks ]================================================

# --------[ sig_setup_changed ]-----------------------------------------

sub sig_setup_changed {
    my($interval) = Irssi::settings_get_int('uptime_refresh_interval');

    Irssi::timeout_remove($timer);

    if ($interval < 1) {
	$interval = 0;
    }

    return unless $interval;

    $interval *= 1000;
    $timer = Irssi::timeout_add($interval, 'uptime_refresh' , undef);
}

# ======[ Statusbar Hooks ]=============================================

# --------[ sb_uptime ]-------------------------------------------------

sub sb_uptime {
    my($item, $get_size_only) = @_;
    my $format = "";
    my($uptime) = uptime(Irssi::parse_special('$sysname'));
    my($time) = format_interval($uptime);
    
    $format = "{sb %g$time%n}";
    
    $item->default_handler($get_size_only, $format, undef, 1);
}

# ======[ Timers ]======================================================

# --------[ uptime_refresh ]--------------------------------------------

sub uptime_refresh {
    Irssi::statusbar_items_redraw('uptime');
}

# ======[ Setup ]=======================================================

# --------[ Register commands ]-----------------------------------------

Irssi::command_bind('uptime', 'cmd_uptime');

# --------[ Register formats ]------------------------------------------

Irssi::theme_register(
[
 'uptime',
 '{line_start}{hilight Uptime:} $0 ($1)',
]);

# --------[ Register settings ]-----------------------------------------

Irssi::settings_add_int('upgrade', 'uptime_refresh_interval', 12);

# --------[ Register signals ]------------------------------------------

Irssi::signal_add('setup changed', 'sig_setup_changed');

# --------[ Register statusbar items ]----------------------------------

Irssi::statusbar_item_register('uptime', undef, 'sb_uptime');

# --------[ Other setup ]-----------------------------------------------

sig_setup_changed;

# ======[ END ]=========================================================

# Local Variables:
# header-initial-hide: t
# mode: header-minor
# end: