Call this v1.1

This commit is contained in:
Pentium44 2020-12-09 21:25:20 -08:00
parent ea6ded0e54
commit 18513d111c
7 changed files with 77 additions and 12 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
*.log *.log
*.txt
*.pingfile *.pingfile
*.push *.push
/users /users

View File

@ -14,6 +14,10 @@ anything like that. This is in working condition!
* Use it! * Use it!
#### Changelog #### Changelog
* v1.1.0:
* Added alias' for /focus (/query, /switch)
* General cleanup.
* v1.0.0: * v1.0.0:
* Functioning web based front end with PHP based backend * Functioning web based front end with PHP based backend
* irc.php performs as an IRC bouncer when web client disconnects * irc.php performs as an IRC bouncer when web client disconnects

View File

@ -7,11 +7,12 @@
$title = "IdleIRC"; // Chat title $title = "IdleIRC"; // Chat title
$desc = "IdleIRC, a simple PHP based IRC client & bouncer."; // Chat description $desc = "IdleIRC, a simple PHP based IRC client & bouncer."; // Chat description
$server = "cddo.cf"; // IRC server connected to (for information display panel) $server = "cddo.cf"; // IRC server connected to (for information display panel and client)
$port = "1337"; // IRC server port (for information display panel) $port = "1337"; // IRC server port (for information display panel)
$server_msgcount = "80"; // Number of messages to leave at the end of the server database $server_msgcount = "80"; // Number of messages to leave at the end of the server database
$default_channel = "#theroot"; $default_channel = "#theroot"; // Default channel to push users into
$logfile = "irclog.txt"; $logfile = "irclog.txt"; // Log instances for each bouncer
//$maxloglength = "10"; // Max line length for flatfile IRC logger ~ bouncer.
///// WEBCLIENT LAYOUT ///// ///// WEBCLIENT LAYOUT /////
$ipcolor = "#00FF00"; $ipcolor = "#00FF00";
@ -23,4 +24,26 @@ function doLog($string) {
file_put_contents($GLOBALS['logfile'], $string . "\r\n", FILE_APPEND); file_put_contents($GLOBALS['logfile'], $string . "\r\n", FILE_APPEND);
} }
/*function check_log_size($filename) {
$linecount = 0;
$handle = fopen($filename, "r");
// Go count log size
while(!feof($handle)){
if (fgets($handle) !== false) {
$linecount++;
}
}
fclose($handle);
if($linecount > $GLOBALS['maxloglength']) {
$to_remove = ($linecount-$GLOBALS['maxloglength']);
$handle = file($filename);
array_splice($handle, 0, $to_remove);
unlink($filename);
file_put_contents($filename, $handle);
}
} */
?> ?>

View File

@ -261,6 +261,18 @@ if (!isset($_SESSION['idleirc-user'])) {
if(!isset($_GET['register'])) { if(!isset($_GET['register'])) {
loginForm(); loginForm();
} }
} else if(isset($_GET['logs'])) {
$username = $_SESSION['idleirc-user'];
$logcontents = file_get_contents("$username.log");
if(file_exists("users/$username.php")) {
include("users/$username.php");
} else {
$userpass = "";
}
if(isset($_SESSION['idleirc-pass']) && $userpass != "" && $userpass == $_SESSION['idleirc-pass']) {
echo "<div id='logmsgs'><table>\n" . $logcontents . "</table></div>\n";
}
} else { } else {
?> ?>
<div class="logout"> <div class="logout">
@ -273,7 +285,8 @@ if (!isset($_SESSION['idleirc-user'])) {
echo "&bull; <a onclick='doLogout();'>Disconnect from server</a>"; echo "&bull; <a onclick='doLogout();'>Disconnect from server</a>";
} }
?> ?>
&bull; <a onclick="doClearLog();">Clear IRC logs</a> <br /><a onclick="doClearLog();">Clear IRC logs</a>
&bull; <a href="index.php?logs">IRC Logs</a>
</div> </div>
<div id="msgs"> <div id="msgs">
<?php <?php

View File

@ -115,8 +115,13 @@ while($bytes = socket_recv($socket, $r_data, 2048, MSG_DONTWAIT) !== '') {
} else if ($ex[1] == "JOIN") { } else if ($ex[1] == "JOIN") {
$senderNick = get_string_between($data, ":", "!"); $senderNick = get_string_between($data, ":", "!");
$senderIp = get_string_between($data, "@", " "); $senderIp = get_string_between($data, "@", " ");
if($senderNick != $username) {
$msgline = "<tr><td class='userinfo'><b>$senderNick</b><br /><span style='color:$ipcolor;'>$senderIp</span></td><td> joined the channel</td></tr>\n"; $msgline = "<tr><td class='userinfo'><b>$senderNick</b><br /><span style='color:$ipcolor;'>$senderIp</span></td><td> joined the channel</td></tr>\n";
file_put_contents("$username.log", $socketFileContents . $msgline); file_put_contents("$username.log", $socketFileContents . $msgline);
} else {
$msgline = "<tr><td class='userinfo'><span style='color:$ipcolor;'>" . $server_address . "</span> ~ </td><td> " . $data . "</td></tr>\n";
file_put_contents("$username.log", $socketFileContents . $msgline);
}
} else if ($ex[1] == "NICK") { } else if ($ex[1] == "NICK") {
$senderNick = get_string_between($data, ":", "!"); $senderNick = get_string_between($data, ":", "!");
$senderIp = get_string_between($data, "@", " "); $senderIp = get_string_between($data, "@", " ");

View File

@ -71,16 +71,23 @@ if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && $_GET['ni
} else if ($cmd[0]=="/join") { } else if ($cmd[0]=="/join") {
doLog("$username: joining " . $cmd[1]); doLog("$username: joining " . $cmd[1]);
$line .= "JOIN" . " " . $cmd[1] . "\n"; // set for push $line .= "JOIN" . " " . $cmd[1] . "\n"; // set for push
$logline .= "<tr><td class='userinfo'><b>$nick</b>:</td><td>Joining " . $cmd[1] . "</td></tr>\n"; // push to client //$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]); $_SESSION['idleirc-channel'] = trim($cmd[1]);
} else if ($cmd[0] == "/part") { } else if ($cmd[0] == "/part") {
doLog("$username: leaving " . $cmd[1]); doLog("$username: leaving " . $cmd[1]);
if ($cmd[1] != "") {
$line .= "PART " . trim($cmd[1]) . " :$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 .= "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") { }
} else if ($cmd[0] == "/focus" || $cmd[0] == "/switch" || $cmd[0] == "/query") {
if(trim($cmd[1]) != $channel) { if(trim($cmd[1]) != $channel) {
$_SESSION['idleirc-channel'] = trim($cmd[1]); $_SESSION['idleirc-channel'] = trim($cmd[1]);
$logline .= "<tr><td class='userinfo'><span style='color:$ipcolor;'>$servaddr</b>: </td><td>$channel is focused, all messages will be sent to $channel</td></tr>\n"; // push to client $logline .= "<tr><td class='userinfo'><span style='color:$ipcolor;'>$servaddr</b>: </td><td>" . trim($cmd[1]) . " is focused, all messages will be sent to " . trim($cmd[1]) . "</td></tr>\n"; // push to client
} else {
$logline .= "<tr><td class='userinfo'><span style='color:$ipcolor;'>$servaddr</b>: </td><td>You're already focused on $channel</td></tr>\n";
} }
} else { } else {
// @@ This is a work in progress // @@ This is a work in progress

View File

@ -90,10 +90,22 @@ input, button, select, textarea{
overflow-y: hidden; overflow-y: hidden;
} }
#logmsgs {
background-color: #323232;
border: solid 1px #454545;
padding: 8px;
max-width: 90%;
margin: 0 auto;
}
#msgs tr:nth-child(even) { background-color: #262626; border: solid 1px #454545; } #msgs tr:nth-child(even) { background-color: #262626; border: solid 1px #454545; }
#msgs tr:nth-child(odd) { background-color: #141414; border: solid 1px #454545; } #msgs tr:nth-child(odd) { background-color: #141414; border: solid 1px #454545; }
#msgs td { padding: 4px; } #msgs td { padding: 4px; }
#logmsgs tr:nth-child(even) { background-color: #262626; border: solid 1px #454545; }
#logmsgs tr:nth-child(odd) { background-color: #141414; border: solid 1px #454545; }
#logmsgs td { padding: 4px; }
td.userinfo { td.userinfo {
min-width: 120px; min-width: 120px;
max-width: 200px; max-width: 200px;