Call this v1.3.0
This commit is contained in:
parent
bcbc40468c
commit
713dfeb130
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,6 +1,3 @@
|
||||
*.log
|
||||
*.txt
|
||||
*.pingfile
|
||||
*.push
|
||||
/users
|
||||
|
||||
|
11
README.md
11
README.md
@ -60,6 +60,17 @@ Read-Write access for working directory
|
||||
|
||||
|
||||
#### Changelog
|
||||
* v1.3.0:
|
||||
* CSS changes / fixes + cleanup
|
||||
* Added server/port set ability on register + settings (Can toggle on or off in config.php as $allowMultiServer == "false")
|
||||
* More HTML fixes + cleanup
|
||||
* Bugfixes in IRC protocol parsing
|
||||
* Added user QUIT parsing to irc.php
|
||||
* Removed unneeded ping code from server.php from previous project.
|
||||
* Pushed cycle speed up in irc.php for more snappy responses
|
||||
* Removed client passed messages from idleirc log
|
||||
* Moved all client needed files to users/ directory for better file management
|
||||
|
||||
* v1.2.3:
|
||||
* CSS fixes and updates
|
||||
* HTML format fixes within server.php and irc.php generation
|
||||
|
@ -9,16 +9,16 @@ $title = "IdleIRC"; // Chat title
|
||||
$desc = "IdleIRC is a simple web based IRC client & bouncer service."; // Chat description
|
||||
$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"; // Default channel to push users into
|
||||
$logfile = "irclog.txt"; // Log instances for each bouncer
|
||||
$allowMultiServer = "true"; // [true/false] Allow users to set other IRC servers for bouncer connect
|
||||
//$maxloglength = "10"; // Max line length for flatfile IRC logger ~ bouncer.
|
||||
|
||||
///// WEBCLIENT LAYOUT /////
|
||||
$ipcolor = "#00FF00";
|
||||
|
||||
///// NO TOUCHY SECTION /////
|
||||
$version = "1.2.3"; // CWChat version
|
||||
$version = "1.3.0"; // CWChat version
|
||||
|
||||
function doLog($string) {
|
||||
file_put_contents($GLOBALS['logfile'], $string . "\r\n", FILE_APPEND);
|
||||
|
103
index.php
103
index.php
@ -16,33 +16,51 @@ if(!file_exists("users"))
|
||||
}
|
||||
|
||||
function registerForm() {
|
||||
?>
|
||||
<br>
|
||||
<div class="login">
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?register=go" method="post">
|
||||
Username: <input style="padding: 2px; width: 300px;" class="text" type="text" name="username"><br />
|
||||
Password: <input style="padding: 2px; width: 300px;" class="text" type="password" name="password"><br />
|
||||
Password again: <input style="padding: 2px;width: 300px;" class="text" type="password" name="password-again"><br /><br />
|
||||
Default Nickname: <input style="padding: 2px; width: 300px;" class="text" type="text" name="nick"><br />
|
||||
Autoconnect/focus channel: <input style="padding: 2px; width: 300px;" class="text" type="text" name="channel"><br />
|
||||
<input style="padding: 2px;" class="text" type="submit" name="submitBtn" value="Create account">
|
||||
</form>
|
||||
?>
|
||||
<br>
|
||||
<div class="form">
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?register=go" method="post">
|
||||
<table>
|
||||
|
||||
<tr><td>Username:</td><td> <input style="padding: 2px; width: 300px;" class="text" type="text" name="username"></td></tr>
|
||||
<tr><td>Password:</td><td> <input style="padding: 2px; width: 300px;" class="text" type="password" name="password"></td></tr>
|
||||
<tr><td>Password again:</td><td> <input style="padding: 2px;width: 300px;" class="text" type="password" name="password-again"></td></tr>
|
||||
<tr><td>Below forms:</td><td> The nickname form can be left blank and<br /> will be substituted with your username.</td></tr>
|
||||
<tr><td>Default Nickname:</td><td> <input style="padding: 2px; width: 300px;" class="text" type="text" name="nick"></td></tr>
|
||||
<tr><td>Autoconnect/focus channel:</td><td> <input style="padding: 2px; width: 300px;" class="text" type="text" name="channel" value="<?php echo $GLOBALS['default_channel']; ?>"></td></tr>
|
||||
<?php
|
||||
if($GLOBALS['allowMultiServer'] == "true") {
|
||||
?>
|
||||
<tr><td>Server (IP:Port)</td><td> <input style="padding: 2px; width: 236px;" class="text" type="text" name="servaddr" value="<?php echo $GLOBALS['server']; ?>">:<input style="padding: 2px; width: 50px;" class="text" type="text" name="servport" value="<?php echo $GLOBALS['port']; ?>"></td></tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<br />
|
||||
<input style="padding: 2px;" class="text" type="submit" name="submitBtn" value="Create account">
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<br />
|
||||
<?php
|
||||
}
|
||||
|
||||
function loginForm(){
|
||||
?>
|
||||
<br>
|
||||
<div class="login">
|
||||
<div class="form">
|
||||
<p>
|
||||
Welcome to <?php echo $GLOBALS['title'] . " " . $GLOBALS['version'] . ".<br /> " . $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">
|
||||
Username: <input style="padding: 2px; width: 200px;" class="text" type="text" name="username"><br />
|
||||
Password: <input style="padding: 2px; width: 200px;" class="text" type="password" name="password"><br />
|
||||
<input style="padding: 2px;" class="text" type="submit" name="submitBtn" value="Login">
|
||||
<table>
|
||||
|
||||
<tr><td>Username:</td><td> <input style="padding: 2px; width: 200px;" class="text" type="text" name="username"></td></tr>
|
||||
<tr><td>Password:</td><td> <input style="padding: 2px; width: 200px;" class="text" type="password" name="password"></td></tr>
|
||||
|
||||
</table>
|
||||
<input style="padding: 2px;" class="text" type="submit" name="submitBtn" value="Login">
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
@ -58,28 +76,40 @@ if (isset($_GET['do']) && $_GET['do']=="settings") {
|
||||
$username = $_SESSION['idleirc-user'];
|
||||
$password = $_SESSION['idleirc-pass'];
|
||||
|
||||
if(file_exists("users/$username.php")) {
|
||||
if (file_exists("users/$username.php")) {
|
||||
include("users/$username.php");
|
||||
} else {
|
||||
$userpass = "";
|
||||
}
|
||||
|
||||
if(isset($_SESSION['idleirc-pass']) && $userpass != "" && $userpass == $_SESSION['idleirc-pass']) {
|
||||
if(isset($_POST['nick']) && $_POST['nick']!="") {
|
||||
if (isset($_SESSION['idleirc-pass']) && $userpass != "" && $userpass == $_SESSION['idleirc-pass']) {
|
||||
if (isset($_POST['nick']) && $_POST['nick']!="") {
|
||||
file_put_contents("users/$username.php", "<?php \$usernickname='" . stripslashes(htmlentities($_POST['nick'])) . "'; ?>\n", FILE_APPEND);
|
||||
$_SESSION['idleirc-nick'] = stripslashes(htmlentities($_POST['nick']));
|
||||
}
|
||||
|
||||
if(isset($_POST['channel']) && $_POST['channel']!="") {
|
||||
if (isset($_POST['channel']) && $_POST['channel']!="") {
|
||||
file_put_contents("users/$username.php", "<?php \$userchannel='" . stripslashes(htmlentities($_POST['channel'])) . "'; ?>\n", FILE_APPEND);
|
||||
$_SESSION['idleirc-channel'] = stripslashes(htmlentities($_POST['channel']));
|
||||
}
|
||||
|
||||
if(isset($_POST['password']) && $_POST['password']!="") {
|
||||
if (isset($_POST['password']) && $_POST['password']!="") {
|
||||
file_put_contents("users/$username.php", "<?php \$userpass='" . md5($_POST['password']) . "'; ?>\n", FILE_APPEND);
|
||||
$_SESSION['idleirc-pass'] = md5($_POST['password']);
|
||||
}
|
||||
|
||||
if ($allowMultiServer == "true") {
|
||||
if (isset($_POST['servaddr']) && $_POST['servaddr']!="") {
|
||||
file_put_contents("users/$username.php", "<?php \$userserver='" . stripslashes(htmlentities($_POST['servaddr'])) . "'; ?>\n", FILE_APPEND);
|
||||
$_SESSION['idleirc-servaddr'] = stripslashes(htmlentities($_POST['servaddr']));
|
||||
}
|
||||
|
||||
if (isset($_POST['servport']) && $_POST['servport']!="") {
|
||||
file_put_contents("users/$username.php", "<?php \$userserverport='" . stripslashes(htmlentities($_POST['servport'])) . "'; ?>\n", FILE_APPEND);
|
||||
$_SESSION['idleirc-servport'] = stripslashes(htmlentities($_POST['servport']));
|
||||
}
|
||||
}
|
||||
|
||||
header("refresh: 0;url=index.php");
|
||||
} else {
|
||||
header("refresh: 0;url=index.php");
|
||||
@ -95,7 +125,7 @@ if (isset($_GET['register']) && $_GET['register'] == "go") {
|
||||
$nickname = isset($_POST['nick']) && ($_POST['nick'] !== "") ? htmlentities(stripslashes($_POST['nick'])) : $username;
|
||||
$servaddr = isset($_POST['servaddr']) && ($_POST['servaddr'] !== "") ? htmlentities(stripslashes($_POST['servaddr'])) : $server;
|
||||
$servport = isset($_POST['servport']) && ($_POST['servport'] !== "") ? htmlentities(stripslashes($_POST['servport'])) : $port;
|
||||
file_put_contents("users/$username.php", "<?php \$userpass = '" . $password . "'; \$userchannel='" . $channame . "'; \$usernickname='" . $nickname . "'; ?>\n");
|
||||
file_put_contents("users/$username.php", "<?php \$userpass = '" . $password . "'; \$userchannel='" . $channame . "'; \$usernickname='" . $nickname . "'; \$userserver='" . $servaddr . "'; \$userserverport='" . $servport . "'; ?>\n");
|
||||
file_put_contents("users/.$username.first", "First time, start up\n");
|
||||
$_SESSION['idleirc-user'] = $username;
|
||||
$_SESSION['idleirc-nick'] = $nickname;
|
||||
@ -115,8 +145,6 @@ if (isset($_GET['register']) && $_GET['register'] == "go") {
|
||||
// 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";
|
||||
$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) {
|
||||
@ -124,8 +152,8 @@ if (isset($_GET['do']) && $_GET['do']=="login" && isset($_POST['submitBtn']) &&
|
||||
$_SESSION['idleirc-nick'] = $usernickname;
|
||||
$_SESSION['idleirc-pass'] = $userpass;
|
||||
$_SESSION['idleirc-channel'] = $userchannel;
|
||||
$_SESSION['idleirc-servaddr'] = $servaddr;
|
||||
$_SESSION['idleirc-servport'] = $servport;
|
||||
$_SESSION['idleirc-servaddr'] = $userserver;
|
||||
$_SESSION['idleirc-servport'] = $userserverport;
|
||||
header("refresh: 0;url=index.php");
|
||||
} else {
|
||||
echo "ERROR: Failed to login: password incorrect.";
|
||||
@ -300,7 +328,7 @@ if (!isset($_SESSION['idleirc-user'])) {
|
||||
}
|
||||
} else if(isset($_GET['logs'])) {
|
||||
$username = $_SESSION['idleirc-user'];
|
||||
$logcontents = file_get_contents("$username.log");
|
||||
$logcontents = file_get_contents("users/$username.log");
|
||||
if(file_exists("users/$username.php")) {
|
||||
include("users/$username.php");
|
||||
} else {
|
||||
@ -308,12 +336,12 @@ if (!isset($_SESSION['idleirc-user'])) {
|
||||
}
|
||||
|
||||
if(isset($_SESSION['idleirc-pass']) && $userpass != "" && $userpass == $_SESSION['idleirc-pass']) {
|
||||
echo "<div class='logout'><a href='index.php'>Back to IRC</a></div>\n";
|
||||
echo "<div class='navbar'><a href='index.php'>Back to IRC</a></div>\n";
|
||||
echo "<div id='logmsgs'><table>\n" . $logcontents . "</table></div>\n";
|
||||
}
|
||||
} else if(isset($_GET['settings'])) {
|
||||
$username = $_SESSION['idleirc-user'];
|
||||
$logcontents = file_get_contents("$username.log");
|
||||
$logcontents = file_get_contents("users/$username.log");
|
||||
if(file_exists("users/$username.php")) {
|
||||
include("users/$username.php");
|
||||
} else {
|
||||
@ -321,7 +349,7 @@ if (!isset($_SESSION['idleirc-user'])) {
|
||||
}
|
||||
|
||||
if(isset($_SESSION['idleirc-pass']) && $userpass != "" && $userpass == $_SESSION['idleirc-pass']) {
|
||||
echo "<div class='logout'><a href='index.php'>Back to IRC</a></div>\n";
|
||||
echo "<div class='navbar'><a href='index.php'>Back to IRC</a></div>\n";
|
||||
?>
|
||||
|
||||
<br>
|
||||
@ -333,6 +361,11 @@ if (!isset($_SESSION['idleirc-user'])) {
|
||||
<tr><td>Default Nickname: </td><td> <input style="padding: 2px; width: 300px;" class="text" type="text" name="nick"></td></tr>
|
||||
<tr><td>Autoconnect/focus channel: </td><td> <input style="padding: 2px; width: 300px;" class="text" type="text" name="channel"></td></tr>
|
||||
<tr><td>New password: </td><td> <input style="padding: 2px; width: 300px;" class="text" type="password" name="password"></td></tr>
|
||||
<?php
|
||||
if($allowMultiServer == "true") {
|
||||
?> <tr><td>Server (IP:Port)</td><td> <input style="padding: 2px; width: 236px;" class="text" type="text" name="servaddr" value="<?php echo $server; ?>">:<input style="padding: 2px; width: 50px;" class="text" type="text" name="servport" value="<?php echo $port; ?>"></td></tr><?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<input style="padding: 2px;" class="text" type="submit" name="submitBtn" value="Set">
|
||||
|
||||
@ -344,18 +377,18 @@ if (!isset($_SESSION['idleirc-user'])) {
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<div class="logout">
|
||||
<div class="navbar">
|
||||
<a href="index.php?do=logout">Logout</a>
|
||||
<?php
|
||||
|
||||
// If this is the first login, make sure to start the bouncer! From there, the user will have toggle control.
|
||||
if (!file_exists("." . $_SESSION['idleirc-user'] . ".pingfile") && file_exists("users/." . $_SESSION['idleirc-user'] . ".first")) {
|
||||
if (!file_exists("users/." . $_SESSION['idleirc-user'] . ".pingfile") && file_exists("users/." . $_SESSION['idleirc-user'] . ".first")) {
|
||||
unlink("users/." . $_SESSION['idleirc-user'] . ".first");
|
||||
echo "<script language='javascript' type='text/javascript'>doLogin();</script>";
|
||||
}
|
||||
}
|
||||
|
||||
if (!file_exists("." . $_SESSION['idleirc-user'] . ".pingfile"))
|
||||
{
|
||||
if (!file_exists("users/." . $_SESSION['idleirc-user'] . ".pingfile"))
|
||||
{
|
||||
echo "<a onclick='doLogin();'>Connect to server</a>\n";
|
||||
} else {
|
||||
echo "<a onclick='doLogout();'>Disconnect from server</a>\n";
|
||||
@ -368,7 +401,7 @@ if (!isset($_SESSION['idleirc-user'])) {
|
||||
<div id="msgs">
|
||||
<?php
|
||||
echo "<table>";
|
||||
$get = file_get_contents($_SESSION['idleirc-user'] . ".log");
|
||||
$get = file_get_contents("users/" . $_SESSION['idleirc-user'] . ".log");
|
||||
echo $get;
|
||||
echo "</table>";
|
||||
?>
|
||||
|
33
irc.php
33
irc.php
@ -68,38 +68,31 @@ while($bytes = socket_recv($socket, $r_data, 3068, MSG_DONTWAIT) !== '') {
|
||||
}
|
||||
|
||||
// If client sent something, push it to the IRC server!
|
||||
if(file_exists(".$username.push")) {
|
||||
if(file_exists("users/.$username.push")) {
|
||||
// Grab IRC command from server.php
|
||||
$pushFile = file_get_contents(".$username.push");
|
||||
$pushFile = file_get_contents("users/.$username.push");
|
||||
// Push this / these commands to socket
|
||||
socket_write($socket, $pushFile, strlen($pushFile));
|
||||
// Remove the push file
|
||||
unlink(".$username.push");
|
||||
unlink("users/.$username.push");
|
||||
}
|
||||
|
||||
// Check if web client still up, if no pong after 15 seconds, connection closed.
|
||||
if(!file_exists(".$username.pingfile")) { // If file is missing, quit
|
||||
if(!file_exists("users/.$username.pingfile")) { // If file is missing, quit
|
||||
// Debug logging, check if IRC is exiting properly
|
||||
doLog("Exiting, $username logged out...");
|
||||
$quitline = "QUIT :$username toggled disconnect; webirc\n"; // IRC QUIT line
|
||||
socket_write($socket, $quitline, strlen($quitline)); // Push to socket
|
||||
socket_close($socket); // Close the socket
|
||||
exit(0); // Exit the script, nothing to do.
|
||||
} /*else if (date("YmdHis.", filemtime(".$username.pingfile"))<(date("YmdHis.", filemtime(".$username.pingfile"))-10)) {
|
||||
// Debug logging, check if IRC is exiting properly
|
||||
doLog("Exiting, $username timed out...");
|
||||
$quitline = "QUIT :$username's web session timed out\n"; // IRC QUIT line
|
||||
socket_write($socket, $quitline, strlen($quitline)); // Push to socket
|
||||
socket_close($socket); // Close the socket
|
||||
exit(1); // Exit the script, nothing to do.
|
||||
}*/
|
||||
}
|
||||
|
||||
// If data variable is set and buffer has data to recieve
|
||||
// RECIEVE IT!
|
||||
if(isset($data)) { // If data variable is set, there's data from socket
|
||||
$stringMsg = explode('PRIVMSG', $data); // Strip IRC commands
|
||||
// Get original contents from socket
|
||||
$socketFileContents = file_get_contents("$username.log");
|
||||
$socketFileContents = file_get_contents("users/$username.log");
|
||||
$ex = explode(' ', $data);
|
||||
$data = htmlentities($data);
|
||||
|
||||
@ -115,16 +108,16 @@ while($bytes = socket_recv($socket, $r_data, 3068, MSG_DONTWAIT) !== '') {
|
||||
$senderIp = get_string_between($data, "@", " ");
|
||||
$exitMsg = explode('PART', $data);
|
||||
$msgline = "<tr><td class='userinfo'><b>$senderNick</b><br /><span style='color:$ipcolor;'>$senderIp</span></td><td> left " . stripslashes(trim($exitMsg[1])) . "</td></tr>";
|
||||
file_put_contents("$username.log", $socketFileContents . $msgline);
|
||||
file_put_contents("users/$username.log", $socketFileContents . $msgline);
|
||||
} else if ($ex[1] == "JOIN") {
|
||||
$senderNick = get_string_between($data, ":", "!");
|
||||
$senderIp = get_string_between($data, "@", " ");
|
||||
if($senderNick != $usernickname) {
|
||||
$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("users/$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);
|
||||
file_put_contents("users/$username.log", $socketFileContents . $msgline);
|
||||
}
|
||||
} else if ($ex[1] == "NICK") {
|
||||
$senderNick = get_string_between($data, ":", "!");
|
||||
@ -150,7 +143,7 @@ while($bytes = socket_recv($socket, $r_data, 3068, MSG_DONTWAIT) !== '') {
|
||||
}
|
||||
|
||||
$msgline = "<tr><td class='userinfo'>PM from: <b>$senderNick</b><br /><span style='color:$ipcolor;'>$senderIp</span></td><td> " . htmlentities(stripslashes(trim($msg))) . "</td></tr>\n";
|
||||
file_put_contents("$username.log", $socketFileContents . $msgline);
|
||||
file_put_contents("users/$username.log", $socketFileContents . $msgline);
|
||||
$msg = "";
|
||||
} else if ($stringMsg[1] != "") {
|
||||
$senderNick = get_string_between($data, ":", "!");
|
||||
@ -158,15 +151,15 @@ while($bytes = socket_recv($socket, $r_data, 3068, MSG_DONTWAIT) !== '') {
|
||||
$channel = explode(" :", $stringMsg[1]);
|
||||
$msg = explode($channel[0] . " :", $stringMsg[1]);
|
||||
$msgline = "<tr><td class='userinfo'><b>$senderNick</b>:" . $channel[0] . "<br /><span style='color:$ipcolor;'>$senderIp</span></td><td> " . htmlentities(stripslashes(trim($msg[1]))) . "</td></tr>\n";
|
||||
file_put_contents("$username.log", $socketFileContents . $msgline);
|
||||
file_put_contents("users/$username.log", $socketFileContents . $msgline);
|
||||
} else if ($ex[0] != "PING") {
|
||||
$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);
|
||||
file_put_contents("users/$username.log", $socketFileContents . $msgline);
|
||||
}
|
||||
}
|
||||
|
||||
// second sleep to prevent insane CPU load
|
||||
usleep(1000);
|
||||
usleep(600);
|
||||
}
|
||||
|
||||
?>
|
||||
|
43
server.php
43
server.php
@ -14,10 +14,6 @@ include_once("config.php");
|
||||
|
||||
session_start();
|
||||
|
||||
if(isset($_GET['msg'])) {
|
||||
doLog("Msg information: " . trim($_GET['msg']));
|
||||
}
|
||||
|
||||
$username = $_SESSION['idleirc-user'];
|
||||
$usernick = $_SESSION['idleirc-nick'];
|
||||
$acctpass = $_SESSION['idleirc-pass'];
|
||||
@ -158,12 +154,12 @@ if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && $_GET['ni
|
||||
}
|
||||
|
||||
// Get original content
|
||||
$content = file_get_contents("$username.log");
|
||||
$content = file_get_contents("users/$username.log");
|
||||
echo "<table>" . nl2br(stripslashes($content)) . "</table>";
|
||||
// Grab all contents, and push to socket output file.
|
||||
file_put_contents("$username.log", $content . $logline);
|
||||
file_put_contents("users/$username.log", $content . $logline);
|
||||
// Grab user message and push to IRC client
|
||||
file_put_contents(".$username.push", $line);
|
||||
file_put_contents("users/.$username.push", $line);
|
||||
// Throw out your user message
|
||||
//echo nl2br(stripslashes($line));
|
||||
// DONE
|
||||
@ -171,35 +167,35 @@ if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && $_GET['ni
|
||||
} 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");
|
||||
$content = file_get_contents("users/$nick.log");
|
||||
// Push content to the web frontend
|
||||
echo "<table>" . nl2br(stripslashes($content)) . "</table";
|
||||
echo "<table>" . nl2br(stripslashes($content)) . "</table>";
|
||||
// DONE
|
||||
} else if (isset($_GET['do']) && isset($_GET['nick']) && $_GET['nick']!="") {
|
||||
$nick = stripslashes(htmlentities($_GET['nick']));
|
||||
include("users/" . $nick . ".php");
|
||||
if ($_GET['do']=="clearlog") {
|
||||
if(file_exists($nick . ".log") && ($acctpass == $userpass)) {
|
||||
unlink($nick . ".log");
|
||||
if(file_exists("users/" . $nick . ".log") && ($acctpass == $userpass)) {
|
||||
unlink("users/" . $nick . ".log");
|
||||
}
|
||||
} else if($_GET['do']=="login" && !file_exists(".$username.pingfile") && ($acctpass == $userpass)) { // Is user asking for login?
|
||||
} else if($_GET['do']=="login" && !file_exists("users/.$username.pingfile") && ($acctpass == $userpass)) { // Is user asking for login?
|
||||
// Join channel
|
||||
$isachannel = substr_count($_SESSION['idleirc-channel'],'#') > 1 ? TRUE : FALSE ;
|
||||
if(!isset($_SESSION['idleirc-channel']) || $isachannel == FALSE) {
|
||||
file_put_contents(".$username.push", "JOIN " . $default_channel . "\n");
|
||||
file_put_contents("users/.$username.push", "JOIN " . $default_channel . "\n");
|
||||
} else {
|
||||
file_put_contents(".$username.push", "JOIN " . $channel . "\n");
|
||||
file_put_contents("users/.$username.push", "JOIN " . $channel . "\n");
|
||||
}
|
||||
|
||||
// Make sure users DB is clean, put nothing into socket read file
|
||||
if(!file_exists("$username.log")) {
|
||||
file_put_contents("$username.log", "");
|
||||
chmod("$username.log", 0755); // file permissions for read / write
|
||||
if(!file_exists("users/$username.log")) {
|
||||
file_put_contents("users/$username.log", "");
|
||||
chmod("users/$username.log", 0755); // file permissions for read / write
|
||||
}
|
||||
|
||||
// start pingfile - determines if webclient is active via write timestamp
|
||||
file_put_contents(".$username.pingfile", "pong");
|
||||
chmod(".$username.pingfile", 0755); // file permissions for read / write
|
||||
file_put_contents("users/.$username.pingfile", "pong");
|
||||
chmod("users/.$username.pingfile", 0755); // file permissions for read / write
|
||||
|
||||
// Execute IRC client in background
|
||||
// IRC server will die when either 1) pingfile is deleted, or
|
||||
@ -210,12 +206,9 @@ if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && $_GET['ni
|
||||
shell_exec("/usr/bin/php $realpath $username $servaddr $servport > /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 . "<tr><td class='userinfo'><b>$usernick</b> ~ </td><td> left the server...</td></tr>\n");
|
||||
unlink(".$nick.pingfile");
|
||||
} else if($_GET['do']=="keepup") { // Client asking for keepup ping.
|
||||
// PONG to server.
|
||||
//file_put_contents(".$nick.pingfile", "ping");
|
||||
$content = file_get_contents("users/$nick.log");
|
||||
file_put_contents("users/$nick.log", $content . "<tr><td class='userinfo'><b>$usernick</b> ~ </td><td> left the server...</td></tr>\n");
|
||||
unlink("users/.$nick.pingfile");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
33
style.css
33
style.css
@ -29,8 +29,6 @@ body {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logout { padding: 5px; padding-bottom: 10px; text-align: center; }
|
||||
|
||||
a {
|
||||
color: #0080ff;
|
||||
text-decoration: none;
|
||||
@ -50,11 +48,20 @@ input, button, select, textarea{
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.login {
|
||||
.form {
|
||||
text-align: center;
|
||||
margin: auto;
|
||||
min-width: 400px;
|
||||
}
|
||||
|
||||
.logout a {
|
||||
.form table {
|
||||
width: 60%;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.form td:nth-child(odd) { width: 160px; }
|
||||
|
||||
.navbar a {
|
||||
background-color: #282828;
|
||||
color: #ffffff;
|
||||
padding: 3px 5px 3px 5px;
|
||||
@ -64,10 +71,12 @@ input, button, select, textarea{
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.logout a:hover {
|
||||
.navbar a:hover {
|
||||
background-color: #353535;
|
||||
}
|
||||
|
||||
.navbar { padding: 5px; padding-bottom: 10px; text-align: center; }
|
||||
|
||||
.text { font-size: 14px; }
|
||||
|
||||
@media only screen and (min-height: 2001px) { #msgs { height: 1700px; } }
|
||||
@ -102,16 +111,16 @@ input, button, select, textarea{
|
||||
padding: 8px;
|
||||
max-width: 90%;
|
||||
margin: 0 auto;
|
||||
overflow-y: hidden;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
#logmsgs {
|
||||
background-color: #323232;
|
||||
border: solid 1px #454545;
|
||||
padding: 8px;
|
||||
max-width: 90%;
|
||||
margin: 0 auto;
|
||||
overflow-x: auto;
|
||||
background-color: #323232;
|
||||
border: solid 1px #454545;
|
||||
padding: 8px;
|
||||
max-width: 90%;
|
||||
margin: 0 auto;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
#msgs tr:nth-child(even) { background-color: #262626; border: solid 1px #454545; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user