Add /archive command for log control.
This commit is contained in:
parent
f133f5c046
commit
8f8f09e7fe
25
index.php
25
index.php
@ -50,7 +50,7 @@ function loginForm(){
|
||||
<br>
|
||||
<div class="form">
|
||||
<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 />
|
||||
</p>
|
||||
<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>
|
||||
<html>
|
||||
<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" />
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<meta name="description" content="<?php echo $desc; ?>" />
|
||||
@ -448,7 +448,6 @@ if (!isset($_SESSION['idleirc-user'])) {
|
||||
}
|
||||
} else if(isset($_GET['logs'])) {
|
||||
$username = $_SESSION['idleirc-user'];
|
||||
$logcontents = file_get_contents("users/$username.log");
|
||||
if(file_exists("users/$username.php")) {
|
||||
include("users/$username.php");
|
||||
} else {
|
||||
@ -456,8 +455,24 @@ if (!isset($_SESSION['idleirc-user'])) {
|
||||
}
|
||||
|
||||
if(isset($_SESSION['idleirc-pass']) && $userpass != "" && $userpass == $_SESSION['idleirc-pass']) {
|
||||
echo "<div class='navbar'><a href='index.php'>Back to IRC</a> • <a onclick='doClearLog();'>Clear IRC logs</a></div><br />\n";
|
||||
echo "<div id='logmsgs'><table>\n" . $logcontents . "</table></div>\n";
|
||||
echo "<div class='navbar'><a href='index.php'>Back to IRC</a> • <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> ";
|
||||
}
|
||||
}
|
||||
|
||||
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";
|
||||
} else {
|
||||
$logcontents = file_get_contents("users/$username.log");
|
||||
echo "<div id='logmsgs'><table>\n" . $logcontents . "</table></div>\n";
|
||||
}
|
||||
}
|
||||
} else if(isset($_GET['settings'])) {
|
||||
$username = $_SESSION['idleirc-user'];
|
||||
|
73
server.php
73
server.php
@ -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
|
||||
$line .= "PRIVMSG" . " " . trim($cmd[1]) . " :"; // set for push
|
||||
$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) {
|
||||
// Grab each word in the array after the privmsg username
|
||||
if($x == 0) {
|
||||
@ -72,25 +72,37 @@ if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && $_GET['ni
|
||||
//$logline .= "<tr><td class='userinfo'><b>$nick</b>:</td><td>Joining " . $cmd[1] . "</td></tr>\n"; // push to client
|
||||
$_SESSION['idleirc-channel'] = trim($cmd[1]);
|
||||
} else if ($cmd[0]=="/channel" || $cmd[0]=="/focused") {
|
||||
doLog("$username: checking focused channel: " . $channel);
|
||||
$logline .= "<tr><td class='userinfo'><span style='color:$ipcolor;'>$title $version</span> ~</td><td>Focused on $channel</td></tr>\n"; // push to client
|
||||
} else if ($cmd[0]=="/nick") {
|
||||
doLog("$username: checking focused channel: " . $channel);
|
||||
$logline .= "<tr><td class='userinfo'><span style='color:$ipcolor;'>$title $version</span> ~</td><td>Focused on $channel</td></tr>\n"; // push to client
|
||||
} else if ($cmd[0]=="/nick") {
|
||||
if($cmd[1]!="") {
|
||||
doLog("$username: setting nick to " . $cmd[1]);
|
||||
$line .= "NICK " . trim($cmd[1]) . "\n"; // set for push
|
||||
doLog("$username: setting nick to " . $cmd[1]);
|
||||
$line .= "NICK " . trim($cmd[1]) . "\n"; // set for push
|
||||
$_SESSION['idleirc-nick'] = trim($cmd[1]);
|
||||
} else {
|
||||
$logline .= "<tr><td class='userinfo'><span style='color:$ipcolor;'>$title $version</span> ~</td><td>Joining " . $cmd[1] . "</td></tr>\n";
|
||||
}
|
||||
} else if ($cmd[0]=="/usermode") {
|
||||
if($cmd[1]!="") {
|
||||
doLog("$username: setting usermode to " . $cmd[1]);
|
||||
$line .= "MODE $nick +x" . trim($cmd[1]) . "\n"; // set for push
|
||||
} 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";
|
||||
}
|
||||
} else if ($cmd[0]=="/mode") {
|
||||
if($cmd[1]!="") {
|
||||
} else if ($cmd[0]=="/usermode") {
|
||||
if($cmd[1]!="") {
|
||||
doLog("$username: setting usermode to " . $cmd[1]);
|
||||
$line .= "MODE $nick +x" . trim($cmd[1]) . "\n"; // set for push
|
||||
} 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";
|
||||
}
|
||||
} 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") {
|
||||
if($cmd[1]!="") {
|
||||
if($cmd[2]!="") {
|
||||
doLog("$username: setting nick to " . $cmd[1]);
|
||||
$line .= "MODE " . trim($cmd[1]) . " " . trim($cmd[2]) . "\n"; // set for push
|
||||
@ -98,35 +110,35 @@ if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && $_GET['ni
|
||||
$logline .= "<tr><td class='userinfo'><span style='color:$ipcolor;'>$title $version</span> ~</td><td>Missing MODE flags:<br /> /mode [channel] [flag(s)]</td></tr>\n";
|
||||
}
|
||||
} else {
|
||||
$logline .= "<tr><td class='userinfo'><span style='color:$ipcolor;'>$title $version</span> ~</td><td>Missing channel and flags:<br /> /mode [channel] [flag(s)]</td></tr>\n";
|
||||
$logline .= "<tr><td class='userinfo'><span style='color:$ipcolor;'>$title $version</span> ~</td><td>Missing channel and flags:<br /> /mode [channel] [flag(s)]</td></tr>\n";
|
||||
}
|
||||
} else if ($cmd[0]=="/list") {
|
||||
} else if ($cmd[0]=="/list") {
|
||||
if($cmd[1]!="") {
|
||||
doLog("$username: listing users for " . $cmd[1]);
|
||||
$line .= "NAMES " . trim($cmd[1]) . "\n"; // set for push
|
||||
} else {
|
||||
} else {
|
||||
doLog("$username: listing users for $channel");
|
||||
$line .= "NAMES $channel\n"; // set for push
|
||||
$line .= "NAMES $channel\n"; // set for push
|
||||
}
|
||||
} else if ($cmd[0] == "/rejoin") {
|
||||
} else if ($cmd[0] == "/rejoin") {
|
||||
doLog("$username: rejoining channel");
|
||||
if ($cmd[1] != "") {
|
||||
$line .= "PART " . trim($cmd[1]) . " :$username leaving...\n"; // push close command to IRC
|
||||
if ($cmd[1] != "") {
|
||||
$line .= "PART " . trim($cmd[1]) . " :$username leaving...\n"; // push close command to IRC
|
||||
$line .= "JOIN " . trim($cmd[1]) . "\n"; // set for push
|
||||
//$logline .= "<tr><td class='userinfo'><b>$nick</b>: </td><td>Leaving " . trim($cmd[1]) . "</td></tr>\n"; // push to client
|
||||
} else {
|
||||
$line .= "PART $channel :$username leaving...\n"; // push close command to IRC
|
||||
//$logline .= "<tr><td class='userinfo'><b>$nick</b>: </td><td>Leaving " . trim($cmd[1]) . "</td></tr>\n"; // push to client
|
||||
} else {
|
||||
$line .= "PART $channel :$username leaving...\n"; // push close command to IRC
|
||||
$line .= "JOIN $channel\n"; // set for push
|
||||
//$logline .= "<tr><td class='userinfo'><b>$nick</b>: </td><td>Leaving $channel</td></tr>\n"; // push to client
|
||||
}
|
||||
//$logline .= "<tr><td class='userinfo'><b>$nick</b>: </td><td>Leaving $channel</td></tr>\n"; // push to client
|
||||
}
|
||||
} else if ($cmd[0] == "/part") {
|
||||
doLog("$username: leaving " . trim($cmd[1]));
|
||||
if ($cmd[1] != "") {
|
||||
$line .= "PART " . trim($cmd[1]) . " :$nick leaving...\n"; // push close command to IRC
|
||||
//$logline .= "<tr><td class='userinfo'><b>$nick</b>: </td><td>Leaving " . trim($cmd[1]) . "</td></tr>\n"; // push to client
|
||||
$line .= "PART " . trim($cmd[1]) . " :$nick leaving...\n"; // push close command to IRC
|
||||
//$logline .= "<tr><td class='userinfo'><b>$nick</b>: </td><td>Leaving " . trim($cmd[1]) . "</td></tr>\n"; // push to client
|
||||
} else {
|
||||
$line .= "PART $channel :$username leaving...\n"; // push close command to IRC
|
||||
//$logline .= "<tr><td class='userinfo'><b>$nick</b>: </td><td>Leaving $channel</td></tr>\n"; // push to client
|
||||
//$logline .= "<tr><td class='userinfo'><b>$nick</b>: </td><td>Leaving $channel</td></tr>\n"; // push to client
|
||||
}
|
||||
} else if ($cmd[0] == "/focus" || $cmd[0] == "/switch" || $cmd[0] == "/query") {
|
||||
if(trim($cmd[1]) != $channel) {
|
||||
@ -138,6 +150,7 @@ if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && $_GET['ni
|
||||
} else if ($cmd[0] == "/help" || $cmd[0] == "/?") {
|
||||
$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 .= "/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 .= "/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 />";
|
||||
|
Loading…
x
Reference in New Issue
Block a user