diff --git a/.gitignore b/.gitignore index 6b9ea86..5f7c146 100755 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.log +*.txt *.pingfile *.push /users diff --git a/README.md b/README.md index cb25d94..3566681 100755 --- a/README.md +++ b/README.md @@ -14,6 +14,10 @@ anything like that. This is in working condition! * Use it! #### Changelog +* v1.1.0: + * Added alias' for /focus (/query, /switch) + * General cleanup. + * v1.0.0: * Functioning web based front end with PHP based backend * irc.php performs as an IRC bouncer when web client disconnects diff --git a/config.php b/config.php index 4f8f68d..e03fb44 100755 --- a/config.php +++ b/config.php @@ -7,11 +7,12 @@ $title = "IdleIRC"; // Chat title $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) $server_msgcount = "80"; // Number of messages to leave at the end of the server database -$default_channel = "#theroot"; -$logfile = "irclog.txt"; +$default_channel = "#theroot"; // Default channel to push users into +$logfile = "irclog.txt"; // Log instances for each bouncer +//$maxloglength = "10"; // Max line length for flatfile IRC logger ~ bouncer. ///// WEBCLIENT LAYOUT ///// $ipcolor = "#00FF00"; @@ -23,4 +24,26 @@ function doLog($string) { 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); + } +} */ + ?> diff --git a/index.php b/index.php index 06a7b7a..aded659 100755 --- a/index.php +++ b/index.php @@ -261,6 +261,18 @@ if (!isset($_SESSION['idleirc-user'])) { if(!isset($_GET['register'])) { 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 "
\n" . $logcontents . "
\n"; + } } else { ?>
@@ -273,7 +285,8 @@ if (!isset($_SESSION['idleirc-user'])) { echo "• Disconnect from server"; } ?> - • Clear IRC logs +
Clear IRC logs + • IRC Logs
$senderNick
$senderIp joined the channel\n"; - file_put_contents("$username.log", $socketFileContents . $msgline); + if($senderNick != $username) { + $msgline = "$senderNick
$senderIp joined the channel\n"; + file_put_contents("$username.log", $socketFileContents . $msgline); + } else { + $msgline = "" . $server_address . " ~ " . $data . "\n"; + file_put_contents("$username.log", $socketFileContents . $msgline); + } } else if ($ex[1] == "NICK") { $senderNick = get_string_between($data, ":", "!"); $senderIp = get_string_between($data, "@", " "); $nickMsg = explode('NICK', $data); $msgline = "$senderNick
$senderIp $senderNick is now known as" . $nickMsg[1] . "\n"; - file_put_contents("$username.log", $socketFileContents . $msgline); + file_put_contents("$username.log", $socketFileContents . $msgline); } else if ($ex[2] == $username && (count(explode(":", $stringMsg[1])) > 1)) { $senderNick = get_string_between($data, ":", "!"); $senderIp = get_string_between($data, "@", " "); diff --git a/server.php b/server.php index 1984467..ded6bd6 100755 --- a/server.php +++ b/server.php @@ -71,16 +71,23 @@ if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && $_GET['ni } else if ($cmd[0]=="/join") { doLog("$username: joining " . $cmd[1]); $line .= "JOIN" . " " . $cmd[1] . "\n"; // set for push - $logline .= "$nick:Joining " . $cmd[1] . "\n"; // push to client + //$logline .= "$nick:Joining " . $cmd[1] . "\n"; // push to client $_SESSION['idleirc-channel'] = trim($cmd[1]); } else if ($cmd[0] == "/part") { doLog("$username: leaving " . $cmd[1]); - $line .= "PART $channel :$username leaving...\n"; // push close command to IRC - $logline .= "$nick: Leaving $channel\n"; // push to client - } else if ($cmd[0] == "/focus") { + if ($cmd[1] != "") { + $line .= "PART " . trim($cmd[1]) . " :$username leaving...\n"; // push close command to IRC + //$logline .= "$nick: Leaving " . trim($cmd[1]) . "\n"; // push to client + } else { + $line .= "PART $channel :$username leaving...\n"; // push close command to IRC + //$logline .= "$nick: Leaving $channel\n"; // push to client + } + } else if ($cmd[0] == "/focus" || $cmd[0] == "/switch" || $cmd[0] == "/query") { if(trim($cmd[1]) != $channel) { $_SESSION['idleirc-channel'] = trim($cmd[1]); - $logline .= "$servaddr: $channel is focused, all messages will be sent to $channel\n"; // push to client + $logline .= "$servaddr: " . trim($cmd[1]) . " is focused, all messages will be sent to " . trim($cmd[1]) . "\n"; // push to client + } else { + $logline .= "$servaddr: You're already focused on $channel\n"; } } else { // @@ This is a work in progress diff --git a/style.css b/style.css index 7296c2d..c2238f5 100755 --- a/style.css +++ b/style.css @@ -90,10 +90,22 @@ input, button, select, textarea{ 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(odd) { background-color: #141414; border: solid 1px #454545; } #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 { min-width: 120px; max-width: 200px;