-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtail.php
More file actions
112 lines (68 loc) · 2.8 KB
/
tail.php
File metadata and controls
112 lines (68 loc) · 2.8 KB
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
<?php
$verbose = 0;
function textile_sanitize($string){
$whitelist = '/[^a-zA-Z0-9 \._-]/';
return preg_replace($whitelist, '', $string);
}
$count = textile_sanitize($_REQUEST['count']);
# Check refresh parameter
if (isset($_GET["refresh"])) {
$refresh = "<meta http-equiv='refresh' content='5'>";
}
else { $refresh = ""; }
include 'answers.php';
if (! isset($logfile) ) {
print" Error: logfile not set in answers.php";
exit;
}
$version = "1.00";
$header = "<html><head><title>Scoreboard</title>";
$header .= "<style>";
$header .= "th, td { border-bottom: 1px solid $bottom_border_color;";
$header .= " margin: 0 10 0px; padding: 0 10 0px; vertical-align: middle; }";
$header .= "td.solved { background-clip: padding-box; padding: 6px; ";
$header .= "border-radius: 13px; background-color: $solved_color; ";
$header .= "border: 5px solid $solved_color_border; ";
$header .= "text-align: center; font-size: 0.7em; ";
$header .= "font-weight: 900; }";
$header .= "td.unsolved { background-clip: padding-box; padding: 6px; ";
$header .= "border-radius: 13px; background-color: $unsolved_color;";
$header .= "border: 5px solid $unsolved_color_border; ";
$header .= "text-align: center; font-size: 0.7em; ";
$header .= "font-weight: bold; }";
$header .= "td.label { border: 0px solid $unsolved_color_border; ";
$header .= "</style>";
$header .= $refresh;
$header .= "</head>";
$header .= "<body bgcolor='#ffffff' style='font-family:Arial'>";
print $header;
$solved_prefix = "<td class='solved'><font color='$solved_font_color'> ";
$solved_suffix = " </font></td>";
$unsolved_prefix = "<td class='unsolved'><font color='$unsolved_font_color'> ";
$unsolved_suffix =" </font></td>";
$label_prefix = "<td class='label'><b> ";
$label_suffix = " </b></td>";
print "<table style='border: $border_width solid $border_color; ";
print "border-radius: 15px; ' ";
print "cellpadding=0 cellspacing=0 border=0 align='center'> ";
# print "Reading $logfile<p>";
// Open the file to get existing content
$current = file_get_contents($logfile);
if ($verbose > 0) print "<pre>$current</pre>";
$array = str_getcsv ($current);
$csv = array_map('str_getcsv', file($logfile));
$numlines = count($csv);
if ($verbose > 1) print "<p>CSV contains $numlines lines.<p>\n";
if ($verbose > 1) print "<h2>CSV:</h2><pre>";
if ($verbose > 1) print_r($csv);
if ($verbose > 1) print "</pre>\n";
# print "Found $numlines lines<p>";
for( $i = $numlines-$count; $i<$numlines; $i++ ) {
$n = "<td align='center'><b><big> " . $csv[$i][0] . " </big></b></td>";
$s = "<td align='center'><b> " . (string) $csv[$i][1] . " </b></td>";
print "<tr>" . $n . $s . "</tr>\n";
}
print "</td></tr></table>";
print "</body></html>\n";
echo "<p><small>Version: $version</small></p>";
?>