diff --git a/README.md b/README.md old mode 100644 new mode 100755 index d770fd4..0a6ea7d --- a/README.md +++ b/README.md @@ -1,3 +1,26 @@ -# idleirc +=== IdleIRC === +This is a simple ajax frontend with a very small footprint on web servers. IdleIRC uses a IRC backend +written in PHP to communicate with IRC servers. With that being said, it's not secured by TLS or +anything like that. This is in working condition! -A simple JS / HTML IRC client frontend with a simple PHP irc client backend that operates as a bouncer as well. \ No newline at end of file +---Requirements: + PHP 5.2+ + Read-Write access for working directory + +---Installation: + ~Download IdleIRC + ~Extract it to desired web server / htdocs directory + ~Customize config.php to your liking + ~Use it! + +---Changelog: + v1.0.0: + -Functioning web based front end with PHP based backend + -irc.php performs as an IRC bouncer when web client disconnects + -Controls to start / stop irc.php within web panel + -server.php is used by the AJAX frontend to communicate with irc.php + -Client supports: /join, /msg, and /me currently + -Multi user support + +Legal stuff: + License: GPLv3 diff --git a/config.php b/config.php new file mode 100755 index 0000000..4f8f68d --- /dev/null +++ b/config.php @@ -0,0 +1,26 @@ + diff --git a/index.php b/index.php new file mode 100755 index 0000000..ff1e670 --- /dev/null +++ b/index.php @@ -0,0 +1,306 @@ + +
+
+
+ Username:
+ Password:
+ Password again:
+ +
+
+ +
+
+

+ Welcome to the WebIRC client / bouncer!
+ Don't have an account? Create one here!
+

+
+ Username:
+ Password:
+ +
+
+\n"); + $_SESSION['idleirc-user'] = $username; + $_SESSION['idleirc-pass'] = $password; + $_SESSION['idleirc-channel'] = $channame; + $_SESSION['idleirc-servaddr'] = $servaddr; + $_SESSION['idleirc-servport'] = $servport; + header("refresh: 0;url=index.php"); + } else { + echo "Please prove a username..."; + } + } else { + echo "ERROR: Passwords did not match..."; + } +} + +// If web frontend is trying to login, process and connect +if (isset($_GET['do']) && $_GET['do']=="login" && isset($_POST['submitBtn']) && isset($_POST['password']) && $_POST['password']!=""){ + $name = isset($_POST['username']) && ($_POST['username'] !== "") && file_exists("users/" . $_POST['username'] . ".php") ? htmlentities(stripslashes($_POST['username'])) : "Unnamed"; + $channame = isset($_POST['channel']) && ($_POST['channel'] !== "") ? htmlentities(stripslashes($_POST['channel'])) : "#theroot"; + $servaddr = isset($_POST['servaddr']) && ($_POST['servaddr'] !== "") ? htmlentities(stripslashes($_POST['servaddr'])) : $server; + $servport = isset($_POST['servport']) && ($_POST['servport'] !== "") ? htmlentities(stripslashes($_POST['servport'])) : $port; + if(file_exists("users/$name.php")) { + include("users/$name.php"); + if(md5($_POST['password']) == $userpass) { + $_SESSION['idleirc-user'] = $name; + $_SESSION['idleirc-pass'] = $userpass; + $_SESSION['idleirc-channel'] = $channame; + $_SESSION['idleirc-servaddr'] = $servaddr; + $_SESSION['idleirc-servport'] = $servport; + header("refresh: 0;url=index.php"); + } else { + echo "ERROR: Failed to login: password incorrect."; + } + } else { + echo "ERROR: Password for $name does not match"; + } +} + +//if(!isset($_SESSION['cwchat-user'])) { header("Location: ?do=login"); } + +?> + + + + + <?php echo $title . " " . $version ?> + + + + + + +
+ +
+ Logout + Connect to server"; + } else { + echo "• Disconnect from server"; + } + ?> + • Clear IRC logs +
+
+ "; + $get = file_get_contents($_SESSION['idleirc-user'] . ".log"); + echo $get; + echo ""; + ?> +
+
+ + + + + +
+ + + +
+
+ + + + diff --git a/irc.php b/irc.php new file mode 100755 index 0000000..ec27ce5 --- /dev/null +++ b/irc.php @@ -0,0 +1,157 @@ +$senderNick
$senderIp left " . stripslashes(trim($exitMsg[1])) . ""; + file_put_contents("$username.log", $socketFileContents . $msgline); + } else if ($ex[1] == "JOIN") { + $senderNick = get_string_between($data, ":", "!"); + $senderIp = get_string_between($data, "@", " "); + $msgline = "$senderNick
$senderIp joined the channel\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); + } else if ($ex[2] == $username && (count(explode(":", $stringMsg[1])) > 1)) { + $senderNick = get_string_between($data, ":", "!"); + $senderIp = get_string_between($data, "@", " "); + $privMsg = explode(":", $stringMsg[1]); + $posprivMsg = array_splice($privMsg, 1); + $msg; + + foreach($posprivMsg as $msgchunk) { + $msg .= $msgchunk; + } + + $msgline = "PM from: $senderNick
$senderIp " . stripslashes(trim($msg)) . "\n"; + file_put_contents("$username.log", $socketFileContents . $msgline); + $msg = ""; + } else if ($stringMsg[1] != "") { + $senderNick = get_string_between($data, ":", "!"); + $senderIp = get_string_between($data, "@", " "); + $channel = explode(" :", $stringMsg[1]); + $msg = explode($channel[0] . " :", $stringMsg[1]); + $msgline = "$senderNick:" . $channel[0] . "
$senderIp " . stripslashes(trim($msg[1])) . "\n"; + file_put_contents("$username.log", $socketFileContents . $msgline); + } else if ($ex[0] != "PING") { + $msgline = "" . $server_address . " ~ " . $data . "\n"; + file_put_contents("$username.log", $socketFileContents . $msgline); + } + } + + // second sleep to prevent insane CPU load + usleep(1000); +} + +?> diff --git a/server.php b/server.php new file mode 100755 index 0000000..d125e39 --- /dev/null +++ b/server.php @@ -0,0 +1,145 @@ +$nick -> " . $cmd[1] . ": "; + foreach($prvmsg as $word) { + // Grab each word in the array after the privmsg username + if($x == 0) { + $line .= ":" . $word; + $logline .= $word; + } else { + $line .= " " . $word; + $logline .= " " . $word; + } + $x++; + } + $line .= "\n"; + $logline .= "\n"; + } else if($cmd[0]=="/me") { // If using /msg, push private message + $prvmsg = array_splice($cmd, 1); // grab private message from string + $line .= "PRIVMSG" . " " . $channel . " :\x01ACTION "; // set for push + $x = 0; + $logline .= "$channel: $nick "; + foreach($prvmsg as $word) { + // Grab each word in the array after the privmsg username + if($x == 0) { + $line .= $word; + $logline .= $word; + } else { + $line .= " " . $word; + $logline .= " " . $word; + } + $x++; + } + $logline .= "\n"; + $line .= "\x01\n"; + } else if ($cmd[0]=="/join") { + doLog("$username: channel switch from $channel to" . $cmd[1] . "($msg)"); + $line .= "PART $channel\n"; // push close command to IRC + $logline .= "$nick: Leaving $channel\n"; // push to client + $line .= "JOIN" . " " . $cmd[1] . "\n"; // set for push + $logline .= "$nick:Joining " . $cmd[1] . "\n"; // push to client + $_SESSION['cwchat-channel'] = trim($cmd[1]); + } else { + // @@ This is a work in progress + // Sends every channel message to each channel :[ + $line .= "PRIVMSG $channel :$msg\n"; + $logline .= "$nick in $channel: $msg\n"; + } + + // Get original content + $content = file_get_contents("$nick.log"); + echo "" . nl2br(stripslashes($content)) . "
"; + // Grab all contents, and push to socket output file. + file_put_contents("$nick.log", $content . $logline); + // Grab user message and push to IRC client + file_put_contents(".$nick.push", $line); + // Throw out your user message + //echo nl2br(stripslashes($line)); + // DONE + +} else if (isset($_GET['get']) && isset($_GET['nick']) && $_GET['nick']!="") { + $nick = stripslashes(htmlentities($_GET['nick'])); // Username + // Grab IRC client output + $content = file_get_contents("$nick.log"); + // Push content to the web frontend + echo "" . nl2br(stripslashes($content)) . " /dev/null 2>/dev/null &"); + } else if($_GET['do']=="logout" && ($acctpass == $userpass)) { // Is user asking for logout? + // Remove ping file if user logs out. IRC server will close + $content = file_get_contents("$nick.log"); + file_put_contents("$nick.log", $content . "\n"); + unlink(".$nick.pingfile"); + } else if($_GET['do']=="keepup") { // Client asking for keepup ping. + // PONG to server. + //file_put_contents(".$nick.pingfile", "ping"); + } +} +?> diff --git a/style.css b/style.css new file mode 100644 index 0000000..7296c2d --- /dev/null +++ b/style.css @@ -0,0 +1,100 @@ +@import url('https://fonts.googleapis.com/css2?family=Ubuntu+Mono&display=swap'); + +@media only screen and (min-width: 2001px) { body { max-width: 1000px; } #msg { width: 780px; } } +@media only screen and (max-width: 2000px) { body { max-width: 1000px; } #msg { width: 780px; } } +@media only screen and (max-width: 1500px) { body { max-width: 800px; } #msg { width: 660px; } } +@media only screen and (max-width: 900px) { body { max-width: 800px; } #msg { width: 660px; } } +@media only screen and (max-width: 800px) { body { max-width: 700px; } #msg { width: 570px; } } +@media only screen and (max-width: 700px) { body { max-width: 600px; } #msg { width: 480px; } } +@media only screen and (max-width: 600px) { body { max-width: 500px; } #msg { width: 380px; } } +/* small windows and phones */ +@media only screen and (max-width: 500px) { body { max-width: 450px; } #msg { width: 330px; } } +@media only screen and (max-width: 400px) { body { max-width: 350px; } #msg { width: 230px; } } + +html { + font-family: "Ubuntu Mono", Arial, sans-serif; + font-size: 14px; + background: #202020; +} + +body { + color:#f3f3f3; + margin: 0 auto; + background-color: #545454; +} + +.info { + padding: 2px; + font-size: 18px; + text-align: center; +} + +.logout { padding: 5px; text-align: center; } + +a { + color: #0080ff; + text-decoration: none; +} + +a:hover { + color: #0099ff; + text-decoration: underline; +} + +input, button, select, textarea{ + background-color: #222222; + border: solid 1px #323232; + outline: none; + border-radius: 6px; + color: #d7d7d7; + padding: 4px; +} + +.login { + text-align: center; +} + +.text { font-size: 14px; } + +@media only screen and (max-height: 2000px) { #msgs { height: 1600px; } } +@media only screen and (max-height: 1800px) { #msgs { height: 1500px; } } +@media only screen and (max-height: 1400px) { #msgs { height: 1100px; } } +@media only screen and (max-height: 1200px) { #msgs { height: 1000px; } } +@media only screen and (max-height: 1000px) { #msgs { height: 800px; } } +@media only screen and (max-height: 900px) { #msgs { height: 700px; } } +@media only screen and (max-height: 800px) { #msgs { height: 600px; } } +@media only screen and (max-height: 700px) { #msgs { height: 500px; } } +@media only screen and (max-height: 600px) { #msgs { height: 400px; } } +@media only screen and (max-height: 500px) { #msgs { height: 300px; } } +@media only screen and (max-height: 400px) { #msgs { height: 200px; } } + +#msg { + height: 21px; +} + +#msgbox { + background-color: #323232; + border: solid 1px #454545; + max-width: 90%; + padding: 8px; + height: 32px; + margin: 0 auto; +} + +#msgs { + background-color: #323232; + border: solid 1px #454545; + padding: 8px; + max-width: 90%; + margin: 0 auto; + overflow-y: hidden; +} + +#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; } + +td.userinfo { + min-width: 120px; + max-width: 200px; +}
$nick ~ left the server...