Add /archive command for log control.

This commit is contained in:
Pentium44 2021-01-03 18:16:13 -08:00
parent f133f5c046
commit 8f8f09e7fe
2 changed files with 63 additions and 35 deletions

View File

@ -50,7 +50,7 @@ function loginForm(){
<br> <br>
<div class="form"> <div class="form">
<p> <p>
Welcome to <?php echo $GLOBALS['title'] . " " . $GLOBALS['version'] . ".<br /> " . $GLOBALS['desc']; ?><br /> <?php echo $GLOBALS['desc']; ?><br />
Don't have an account? <a href="index.php?register">Create one</a> here!<br /> Don't have an account? <a href="index.php?register">Create one</a> here!<br />
</p> </p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=login" method="post"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=login" method="post">
@ -168,7 +168,7 @@ if (isset($_GET['do']) && $_GET['do']=="login" && isset($_POST['submitBtn']) &&
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title><?php echo $title . " " . $version ?></title> <title><?php echo $title . " " . $version; ?></title>
<link href="<?php echo $ui_theme; ?>.css" rel="stylesheet" type="text/css" /> <link href="<?php echo $ui_theme; ?>.css" rel="stylesheet" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="description" content="<?php echo $desc; ?>" /> <meta name="description" content="<?php echo $desc; ?>" />
@ -448,7 +448,6 @@ if (!isset($_SESSION['idleirc-user'])) {
} }
} else if(isset($_GET['logs'])) { } else if(isset($_GET['logs'])) {
$username = $_SESSION['idleirc-user']; $username = $_SESSION['idleirc-user'];
$logcontents = file_get_contents("users/$username.log");
if(file_exists("users/$username.php")) { if(file_exists("users/$username.php")) {
include("users/$username.php"); include("users/$username.php");
} else { } else {
@ -456,8 +455,24 @@ if (!isset($_SESSION['idleirc-user'])) {
} }
if(isset($_SESSION['idleirc-pass']) && $userpass != "" && $userpass == $_SESSION['idleirc-pass']) { if(isset($_SESSION['idleirc-pass']) && $userpass != "" && $userpass == $_SESSION['idleirc-pass']) {
echo "<div class='navbar'><a href='index.php'>Back to IRC</a> &bull; <a onclick='doClearLog();'>Clear IRC logs</a></div><br />\n"; echo "<div class='navbar'><a href='index.php'>Back to IRC</a> &bull; <a onclick='doClearLog();'>Clear IRC logs</a>";
if(file_exists("users/$username.logcount")) {
echo "<br />Archived: ";
$archivedLogCount = file_get_contents("users/$username.logcount");
for($x = $archivedLogCount ; $x > 0 ; $x--) {
echo "<a href='index.php?logs&page=$x'>$x</a>&nbsp;";
}
}
echo "</div><br />\n";
if(isset($_GET['page']) && $_GET['page']!="") {
$logcontents = file_get_contents("users/$username." . $_GET['page'] . ".log");
echo "<div id='logmsgs'><table>\n" . $logcontents . "</table></div>\n"; echo "<div id='logmsgs'><table>\n" . $logcontents . "</table></div>\n";
} else {
$logcontents = file_get_contents("users/$username.log");
echo "<div id='logmsgs'><table>\n" . $logcontents . "</table></div>\n";
}
} }
} else if(isset($_GET['settings'])) { } else if(isset($_GET['settings'])) {
$username = $_SESSION['idleirc-user']; $username = $_SESSION['idleirc-user'];

View File

@ -34,7 +34,7 @@ if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && $_GET['ni
$prvmsg = array_splice($cmd, 2); // grab private message from string $prvmsg = array_splice($cmd, 2); // grab private message from string
$line .= "PRIVMSG" . " " . trim($cmd[1]) . " :"; // set for push $line .= "PRIVMSG" . " " . trim($cmd[1]) . " :"; // set for push
$x = 0; $x = 0;
$logline .= "<tr><td class='userinfo'><b>$nick</b> -> " . trim($cmd[1]) . ": </td><td>"; $logline .= "<tr><td class='userinfo'><b>$nick</b>: " . trim($cmd[1]) . ": </td><td>";
foreach($prvmsg as $word) { foreach($prvmsg as $word) {
// Grab each word in the array after the privmsg username // Grab each word in the array after the privmsg username
if($x == 0) { if($x == 0) {
@ -89,6 +89,18 @@ if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && $_GET['ni
} else { } else {
$logline .= "<tr><td class='userinfo'><span style='color:$ipcolor;'>$title $version</span> ~</td><td>Missing User MODE flags<br /> /usermode [flag(s)]</td></tr>\n"; $logline .= "<tr><td class='userinfo'><span style='color:$ipcolor;'>$title $version</span> ~</td><td>Missing User MODE flags<br /> /usermode [flag(s)]</td></tr>\n";
} }
} else if ($cmd[0]=="/archive") {
if(file_exists("users/$username.logcount")) {
$archivedLogCount = file_get_contents("users/$username.logcount");
$archivedLogCount++;
file_put_contents("users/$username.logcount", $archivedLogCount);
rename("users/$username.log", "users/$username.$archivedLogCount.log");
$logline .= "<tr><td class='userinfo'><span style='color:$ipcolor;'>$title $version</span> ~</td><td>Logs are archived! View under 'IRC logs'</td></tr>\n";
} else {
file_put_contents("users/$username.logcount", "1");
rename("users/$username.log", "users/$username.1.log");
$logline .= "<tr><td class='userinfo'><span style='color:$ipcolor;'>$title $version</span> ~</td><td>Logs are archived! View under 'IRC logs'</td></tr>\n";
}
} else if ($cmd[0]=="/mode") { } else if ($cmd[0]=="/mode") {
if($cmd[1]!="") { if($cmd[1]!="") {
if($cmd[2]!="") { if($cmd[2]!="") {
@ -138,6 +150,7 @@ if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && $_GET['ni
} else if ($cmd[0] == "/help" || $cmd[0] == "/?") { } else if ($cmd[0] == "/help" || $cmd[0] == "/?") {
$logline .= "<tr><td class='userinfo'><span style='color:$ipcolor;'>$title $version ~</span></td>"; $logline .= "<tr><td class='userinfo'><span style='color:$ipcolor;'>$title $version ~</span></td>";
$logline .= "<td>HELP: Information about $title<br />/join [channel] : Join IRC channel [channel]<br />"; $logline .= "<td>HELP: Information about $title<br />/join [channel] : Join IRC channel [channel]<br />";
$logline .= "/archive: Archive current log file, and clear current chat history.";
$logline .= "/focus [channel|user]: Funnel messages to specific channel or user (Alias: /switch; /query)<br />"; $logline .= "/focus [channel|user]: Funnel messages to specific channel or user (Alias: /switch; /query)<br />";
$logline .= "/part (channel): Part channel, part focused channel if none specified<br />"; $logline .= "/part (channel): Part channel, part focused channel if none specified<br />";
$logline .= "/rejoin (channel): Part, and join a channel; focused channel if none is specified<br />"; $logline .= "/rejoin (channel): Part, and join a channel; focused channel if none is specified<br />";