doLogin();";
- }
+ }
- if (!file_exists("." . $_SESSION['idleirc-user'] . ".pingfile"))
- {
+ if (!file_exists("users/." . $_SESSION['idleirc-user'] . ".pingfile"))
+ {
echo "
";
- $get = file_get_contents($_SESSION['idleirc-user'] . ".log");
+ $get = file_get_contents("users/" . $_SESSION['idleirc-user'] . ".log");
echo $get;
echo "";
?>
diff --git a/irc.php b/irc.php
index 184c207..cc87d26 100755
--- a/irc.php
+++ b/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 = "
$senderNick $senderIp | left " . stripslashes(trim($exitMsg[1])) . " |
";
- 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 = "
$senderNick $senderIp | joined the channel |
\n";
- file_put_contents("$username.log", $socketFileContents . $msgline);
+ file_put_contents("users/$username.log", $socketFileContents . $msgline);
} else {
$msgline = "
" . $server_address . " ~ | " . $data . " |
\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 = "
PM from: $senderNick $senderIp | " . htmlentities(stripslashes(trim($msg))) . " |
\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 = "
$senderNick:" . $channel[0] . " $senderIp | " . htmlentities(stripslashes(trim($msg[1]))) . " |
\n";
- file_put_contents("$username.log", $socketFileContents . $msgline);
+ file_put_contents("users/$username.log", $socketFileContents . $msgline);
} else if ($ex[0] != "PING") {
$msgline = "
" . $server_address . " ~ | " . $data . " |
\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);
}
?>
diff --git a/server.php b/server.php
index f0ec504..9a2aeca 100755
--- a/server.php
+++ b/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 "
" . nl2br(stripslashes($content)) . "
";
// 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 "
" . nl2br(stripslashes($content)) . "
" . nl2br(stripslashes($content)) . "";
// 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 . "
$usernick ~ | left the server... |
\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 . "
$usernick ~ | left the server... |
\n");
+ unlink("users/.$nick.pingfile");
}
}
?>
diff --git a/style.css b/style.css
index 28dfba3..fe0e171 100755
--- a/style.css
+++ b/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; }