diff options
author | V.Krishn <vkrishn@insteps.net> | 2024-11-01 06:25:59 +0530 |
---|---|---|
committer | V.Krishn <vkrishn@insteps.net> | 2024-11-01 06:25:59 +0530 |
commit | 0cc0b27ae93efd3ea5362a5de6e1c9c3d894bb3a (patch) | |
tree | 7c5553c2d5cc202a368825f9af7b83a96d27d12b | |
parent | d2badd9c781184fee2dcb399b9a59a990d90e1cc (diff) | |
download | scripts-0cc0b27ae93efd3ea5362a5de6e1c9c3d894bb3a.tar.bz2 |
add helper script ircdaily.php
-rw-r--r-- | alpine/irc/log/ircdaily.php | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/alpine/irc/log/ircdaily.php b/alpine/irc/log/ircdaily.php new file mode 100644 index 0000000..0d7840d --- /dev/null +++ b/alpine/irc/log/ircdaily.php @@ -0,0 +1,80 @@ +<?php +define('DS', DIRECTORY_SEPARATOR); +//date_default_timezone_set('Asia/Kolkata'); # Asia/Kolkata +date_default_timezone_set('UTC'); # set to server logs are fetched from + +$ConfigAll['site']['domain'] = $domain = $_SERVER['HTTP_HOST']; +$ConfigAll['base']['install']['path'] = realpath($_SERVER['DOCUMENT_ROOT']); +$ConfigAll['base']['install']['url']['http'] = 'http://' . $domain; +$ConfigAll['base']['install']['url']['https'] = 'https://' . $domain; +$ConfigAll['base']['install']['url']['current'] = $ConfigAll['base']['install']['url']['http']; +$ConfigAll['application']['install']['path'] = $ConfigAll['base']['install']['path'].'/01/irc'; +$ConfigAll['application']['script'] = $ConfigAll['base']['install']['url']['current'].$_SERVER['SCRIPT_NAME']; + +$filename = basename($_SERVER['SCRIPT_NAME']); +$thisfile = $ConfigAll['application']['install']['path'].'/'.$filename; +if (! file_exists($thisfile)) { echo "$thisfile not found."; exit; } + +$arr_logname = explode('.', $filename); +$logname = $arr_logname[0]; + +$YYMM = date('Y-m'); +$date = 1; +if (! empty($_GET['dt'])) { + $date = (int) $_GET['dt']; +} +if ($date <= 1 || $date >= 32) $date = 1; +if ($date <= 9) $date = '0'.$date; +//print_r($logname); exit; + +$file = 'alpine-'.$logname.'-'.$YYMM.'.log.html'; +if(! file_exists($file)) { echo "$file not found."; exit; } +$fp = @fopen($file, "r"); + +$a = 0; $str_dts = ''; +$sn = $ConfigAll['application']['script']; +while ($a <= 30) { + $a++; + $href = "$sn?dt=$a"; + $str_dts = $str_dts. "<span class='date'><a href='".$href."'>$a</a></span>"; +} + +if ($fp) { # first 3 line, html header + if (($buffer = fgets($fp, 4096)) !== false) { echo $buffer; } + if (($buffer = fgets($fp, 4096)) !== false) { echo $buffer; } + if (($buffer = fgets($fp, 4096)) !== false) { echo $buffer; } +} +?> +</head><body> +<style> +.dtwrap { width: 100%; padding: 4px; } +.date {line-height: 110%; float: left; padding: 1px 2px; border: 2px solid #333; color: blue;} +.date a { text-decoration: none; display: block; padding: 4px 8px; } +.date a:hover { background-color: #eee; } +.br { height:1px; clear:both; font-size:1px; } +</style> +<?php + echo "<div class='dtwrap'>$str_dts</div>"; + echo '<hr class="br">'; +?> +<div id="ircchat"><ul class="list"> +<?php +$Pat1 = "^<li><span class=\"ts\">".$YYMM."-".$date; +if ($fp) { + while (($buffer = fgets($fp, 4096)) !== false) { + if (preg_match("/$Pat1/", $buffer)) { + echo $buffer; + } + } + if (!feof($fp)) { + echo "Error: unexpected fgets() fail\n"; + } + fclose($fp); +} + +$f = file_get_contents('footer.html'); +echo $f; +?> +</ul> +</div></body></html> + |