<?
# MLI - Mose Logs IRC - v0.6
# 2005-09: changes from v0.5 removed local dir channels/, now relying on apache SetEnv
# 2005-09: changes from v0.4 replaced exec() by the tail() selfmade function
# 2004-01: changes from v0.3 included the css inside, so the source contains everything
# 2004-01: changes from v0.2 added word wrap $ll, added an optional limit
# 2003-12: changes from v0.1 made it works
# copyright 2003,2004,2005 mose
# free to use at your own risk, no warranty
if (isset($_SERVER['PATH_INFO'])) {
$args = split('/',$_SERVER['PATH_INFO']);
}
if ($args[1] == 'css') {
list ($back, $text, $link, $high, $dimmed, $tab, $tabdim, $note, $dark, $darker ) =
array("#000000","#efefef","#aecefe","#ffffff","#666666","#8CACBB","#668696","#787878","#2c3c42","#1a2029");
$css =<<<_END_
body { background-color: $back; color: $text; margin: 24px; }
form { margin: 0; }
input { background-color: $back; color: $dimmed; border: 0; text-align: left; font-size: 80%; margin-left: 20px; }
a { color: $link; text-decoration: none; font-weight: bold; }
a:hover { color: $high !important; }
.global { margin: 0; }
.tab { padding: 2px 10px 0px 10px; margin-right: 5px; }
.tab a { color: $tab; }
.tabhead { padding: 2px 10px 0px 10px; margin-right: 5px; }
.tabhead a { color: $tabdim; }
.tabsel { padding: 2px 10px 0px 10px; background-color: $tab; -moz-border-radius: 6px 6px 0 0; }
.tabsel a { color: #000000; }
.body { padding:15px; border: 1px solid $tab; -moz-border-radius: 16px; margin: 0; }
.smaller { font-size: 80%; color: $tab; }
.notice { color: $note; }
.name { color: $high; }
div.line { background-color: none; padding: 0 10px 0 10px; }
div.line:hover { padding: 6px 5px 6px 5px; border: 1px solid $dark; -moz-border-radius: 10px; color: $high !important; background-color: $darker !important; }
.linesep { margin-top: 10px; border-top: 1px solid $tab; background-color: none; color: $yabdim; padding: 0 10px 0 10px; }
span.light { -moz-border-radius: 10px; padding: 0 5px 0 5px; background-color: $tab; color: $back; }
_END_;
header("Content-Type: text/css");
die($css);
}
$lines = 52;
$ll = 100;
if (isset($_REQUEST['s'])) {
$args[1] = $_REQUEST['c'];
if (substr($_REQUEST['s'],0,2) == '--') {
$lines = (substr($_REQUEST['s'],2) > 1500) ? 1500 : (int) substr($_REQUEST['s'],2);
$s = '';
} else {
$s = $_REQUEST['s'];
}
}
function tail($file, $lines) {
$content = file($_SERVER['LOGDIR'].$file,1);
return array_slice($content, count($content) - $lines, $lines);
}
if (isset($args[1])) { $c = preg_replace("/[^-_\.a-zA-Z0-9]/","",$args[1]); }
$l = array(
"trollparty" => tail("#trollparty.log",$lines),
"source" => "#"
);
$com = '';
$ld = 'trollparty';
$c = $c?$c:$ld;
foreach ($l as $m=>$n) {
$url = "/index.php";
if ($m != $ld) $url.= '/'.urlencode($m);
if ($c == $m) {
$tabs.= "<span class='tabsel'><a href='$url'>$m</a></span>";
$com = $n;
} else {
$tabs.= "<span class='tab'><a href='$url'>$m</a></span>";
}
}
?>
<html><head>
<title>Irc Logged by mose</title>
<link rel="stylesheet" type="text/css" href="/index.php/css">
<body>
<div class="global">
<form action="" method="post">
<input type="hidden" name="c" value="<? echo $c; ?>" />
<span class="tabhead"><b>
<a href="http://mose.com">Mose</a>
logs
<a href="http://tikiwiki.org/ConnectingToIrc">IRC</a></b></span>
<? echo $tabs ?>
<input type="text" name="s" value="<? echo $s; ?>" />
</form>
</div>
<pre class="body">
<?
if ($com) {
$d = $com;
$in = array(
"/<([^>]*)>/",
"/-<<<-/",
"/::=([^=]*)=::/",
"/((ftp|https?):\/\/)([^ ]*)/",
"/^(\[[^\]]*\])/",
"/^(.* \*\*\* )([^ ]*)( .*$)/"
);
$ex = array(
"[<b class='name'>\$1</b>]",
"<br />".str_repeat(" ",15),
"<span class='light'>\$1</span>",
"<a href='\$0' target='link'>\$1\$3</a>",
"<span class='smaller'>\$1</span>",
"<span class='notice'>\$1<b>\$2</b>\$3</span>"
);
if ($s) {
$pin[] = "/".preg_quote($s)."/";
$pex[] = "::=$s=::";
}
foreach ($d as $e) {
if (substr($c,0,2) == 'tw') {
echo "<div class='line'>$e</div>";
} else {
$time = substr($e,1,8);
if ($oltime != $time) {
echo "<div class='linesep'>$time</div>";
}
if (isset($pin) and is_array($pin)) {
$e = preg_replace($pin, $pex, $e);
}
$f = preg_replace($in, $ex, wordwrap($e,$ll,"-<<<-"));
echo "<div class='line'>$f</div>";
$oltime = $time;
}
}
if ($c == 'source') {
ini_set('highlight.comment','#666666');
ini_set('highlight.default','#decebe');
ini_set('highlight.html', '#6688AA');
ini_set('highlight.keyword','#66AA88');
ini_set('highlight.string', '#AA8866');
highlight_file('index.php');
}
}
?>
</pre>
</body>
</html>