Call this v1.3.0
This commit is contained in:
parent
a8e85a8226
commit
2ebb907af0
37
.Chraas.socket
Normal file
37
.Chraas.socket
Normal file
@ -0,0 +1,37 @@
|
||||
:cddo.cf 001 Chraas :Hi, welcome to IRC
|
||||
:cddo.cf 002 Chraas :Your host is cddo.cf, running version MintIRCd-0.4.1
|
||||
:cddo.cf 003 Chraas :This server was created sometime
|
||||
:cddo.cf 004 Chraas :cddo.cf MintIRCd-0.4.1 o o
|
||||
:cddo.cf 251 Chraas :There are 7 user(s) and 1 service(s) on 1 server
|
||||
:cddo.cf 375 Chraas :- cddo.cf Message of the day -
|
||||
:cddo.cf 372 Chraas :- * ( (
|
||||
:cddo.cf 372 Chraas :- ( ` ) )\ ) )\ ) ( (
|
||||
:cddo.cf 372 Chraas :- )\))( ( ( /((()/((()/( )\ )\ )
|
||||
:cddo.cf 372 Chraas :- ((_)()\ )\ ( )\())/(_))/(_))(((_) (()/(
|
||||
:cddo.cf 372 Chraas :- (_()((_)((_) )\ ) (_))/(_)) (_)) )\___ ((_))
|
||||
:cddo.cf 372 Chraas :- | \/ | (_) _(_/( | |_ |_ _|| _ \((/ __| _| |
|
||||
:cddo.cf 372 Chraas :- | |\/| | | || ' \))| _| | | | / | (__ / _` |
|
||||
:cddo.cf 372 Chraas :- |_| |_| |_||_||_| \__||___||_|_\ \___|\__,_|
|
||||
:cddo.cf 372 Chraas :-
|
||||
:cddo.cf 372 Chraas :- Hohoho, and Welcome! Radius Root :3
|
||||
:cddo.cf 372 Chraas :-
|
||||
:cddo.cf 372 Chraas :- Local official channels:
|
||||
:cddo.cf 372 Chraas :- #theroot - General chitchat room
|
||||
:cddo.cf 372 Chraas :- #freonlinux - FreonLinux official IRC channel
|
||||
:cddo.cf 376 Chraas :End of /MOTD command
|
||||
:Chraas!Chraas@127.0.0.1 JOIN #theroot
|
||||
:cddo.cf 332 Chraas #theroot :Radius' Root <3 ~ https://cddo.cf
|
||||
:cddo.cf 353 Chraas = #theroot :Chraas Menchers MultiServ OldCoder Pentium44 mrtux zlg
|
||||
:cddo.cf 366 Chraas #theroot :End of NAMES list
|
||||
:MultiServ!MultiServ@127.0.0.1 PRIVMSG #theroot :Welcome Chraas
|
||||
PRIVMSG #theroot :Completely working now
|
||||
|
||||
PRIVMSG #theroot :no issues
|
||||
|
||||
PRIVMSG #freonlinux :Nothing
|
||||
|
||||
PRIVMSG #freonlinux :except some line breaks
|
||||
|
||||
PRIVMSG #freonlinux :should fix that now
|
||||
PRIVMSG #freonlinux :or not lmao
|
||||
PRIVMSG #freonlinux :Oh, I lied it works o/
|
35
.Chraas2.socket
Normal file
35
.Chraas2.socket
Normal file
@ -0,0 +1,35 @@
|
||||
:cddo.cf 001 Chraas2 :Hi, welcome to IRC
|
||||
:cddo.cf 002 Chraas2 :Your host is cddo.cf, running version MintIRCd-0.4.1
|
||||
:cddo.cf 003 Chraas2 :This server was created sometime
|
||||
:cddo.cf 004 Chraas2 :cddo.cf MintIRCd-0.4.1 o o
|
||||
:cddo.cf 251 Chraas2 :There are 7 user(s) and 1 service(s) on 1 server
|
||||
:cddo.cf 375 Chraas2 :- cddo.cf Message of the day -
|
||||
:cddo.cf 372 Chraas2 :- * ( (
|
||||
:cddo.cf 372 Chraas2 :- ( ` ) )\ ) )\ ) ( (
|
||||
:cddo.cf 372 Chraas2 :- )\))( ( ( /((()/((()/( )\ )\ )
|
||||
:cddo.cf 372 Chraas2 :- ((_)()\ )\ ( )\())/(_))/(_))(((_) (()/(
|
||||
:cddo.cf 372 Chraas2 :- (_()((_)((_) )\ ) (_))/(_)) (_)) )\___ ((_))
|
||||
:cddo.cf 372 Chraas2 :- | \/ | (_) _(_/( | |_ |_ _|| _ \((/ __| _| |
|
||||
:cddo.cf 372 Chraas2 :- | |\/| | | || ' \))| _| | | | / | (__ / _` |
|
||||
:cddo.cf 372 Chraas2 :- |_| |_| |_||_||_| \__||___||_|_\ \___|\__,_|
|
||||
:cddo.cf 372 Chraas2 :-
|
||||
:cddo.cf 372 Chraas2 :- Hohoho, and Welcome! Radius Root :3
|
||||
:cddo.cf 372 Chraas2 :-
|
||||
:cddo.cf 372 Chraas2 :- Local official channels:
|
||||
:cddo.cf 372 Chraas2 :- #theroot - General chitchat room
|
||||
:cddo.cf 372 Chraas2 :- #freonlinux - FreonLinux official IRC channel
|
||||
:cddo.cf 376 Chraas2 :End of /MOTD command
|
||||
:Chraas2!Chraas2@127.0.0.1 JOIN #theroot
|
||||
:cddo.cf 332 Chraas2 #theroot :Radius' Root <3 ~ https://cddo.cf
|
||||
:cddo.cf 353 Chraas2 = #theroot :Chraas2 Menchers MultiServ OldCoder Pentium44 mrtux zlg
|
||||
:cddo.cf 366 Chraas2 #theroot :End of NAMES list
|
||||
:MultiServ!MultiServ@127.0.0.1 PRIVMSG #theroot :Welcome Chraas2
|
||||
PART #theroot
|
||||
JOIN #freonlinux
|
||||
|
||||
:Chraas2!Chraas2@127.0.0.1 PART #theroot :Chraas2
|
||||
:Chraas2!Chraas2@127.0.0.1 JOIN #freonlinux
|
||||
:cddo.cf 331 Chraas2 #freonlinux :No topic is set
|
||||
:cddo.cf 353 Chraas2 = #freonlinux :Chraas2 MultiServ Pentium44 mrtux
|
||||
:cddo.cf 366 Chraas2 #freonlinux :End of NAMES list
|
||||
PING :cddo.cf
|
31
.Unnamed.socket
Normal file
31
.Unnamed.socket
Normal file
@ -0,0 +1,31 @@
|
||||
:cddo.cf 001 Unnamed :Hi, welcome to IRC
|
||||
:cddo.cf 002 Unnamed :Your host is cddo.cf, running version MintIRCd-0.4.1
|
||||
:cddo.cf 003 Unnamed :This server was created sometime
|
||||
:cddo.cf 004 Unnamed :cddo.cf MintIRCd-0.4.1 o o
|
||||
:cddo.cf 251 Unnamed :There are 7 user(s) and 1 service(s) on 1 server
|
||||
:cddo.cf 375 Unnamed :- cddo.cf Message of the day -
|
||||
:cddo.cf 372 Unnamed :- * ( (
|
||||
:cddo.cf 372 Unnamed :- ( ` ) )\ ) )\ ) ( (
|
||||
:cddo.cf 372 Unnamed :- )\))( ( ( /((()/((()/( )\ )\ )
|
||||
:cddo.cf 372 Unnamed :- ((_)()\ )\ ( )\())/(_))/(_))(((_) (()/(
|
||||
:cddo.cf 372 Unnamed :- (_()((_)((_) )\ ) (_))/(_)) (_)) )\___ ((_))
|
||||
:cddo.cf 372 Unnamed :- | \/ | (_) _(_/( | |_ |_ _|| _ \((/ __| _| |
|
||||
:cddo.cf 372 Unnamed :- | |\/| | | || ' \))| _| | | | / | (__ / _` |
|
||||
:cddo.cf 372 Unnamed :- |_| |_| |_||_||_| \__||___||_|_\ \___|\__,_|
|
||||
:cddo.cf 372 Unnamed :-
|
||||
:cddo.cf 372 Unnamed :- Hohoho, and Welcome! Radius Root :3
|
||||
:cddo.cf 372 Unnamed :-
|
||||
:cddo.cf 372 Unnamed :- Local official channels:
|
||||
:cddo.cf 372 Unnamed :- #theroot - General chitchat room
|
||||
:cddo.cf 372 Unnamed :- #freonlinux - FreonLinux official IRC channel
|
||||
:cddo.cf 376 Unnamed :End of /MOTD command
|
||||
:Unnamed!Unnamed@127.0.0.1 JOIN #theroot
|
||||
:cddo.cf 332 Unnamed #theroot :Radius' Root <3 ~ https://cddo.cf
|
||||
:cddo.cf 353 Unnamed = #theroot :Menchers MultiServ OldCoder Pentium44 Unnamed mrtux zlg
|
||||
:cddo.cf 366 Unnamed #theroot :End of NAMES list
|
||||
:MultiServ!MultiServ@127.0.0.1 PRIVMSG #theroot :Welcome Unnamed
|
||||
PART #theroot
|
||||
JOIN
|
||||
:Unnamed!Unnamed@127.0.0.1 PART #theroot :Unnamed
|
||||
:cddo.cf 461 Unnamed JOIN :Not enough parameters
|
||||
PING :cddo.cf
|
@ -13,6 +13,12 @@ Installation:
|
||||
~Use it!
|
||||
|
||||
Changelog:
|
||||
v1.3.0:
|
||||
-Add /join commands as well as /msg
|
||||
-Some security fixes
|
||||
-AJax URI formatting
|
||||
-Channel input boxes for login
|
||||
-IRC client bugfixes (irc.php)
|
||||
v1.0.1:
|
||||
-Add message, and server activity timestamps to chat logs.
|
||||
|
||||
|
11
config.php
11
config.php
@ -10,9 +10,14 @@ $desc = "Chris' Website IRC Chat"; // Chat description
|
||||
$server = "127.0.0.1"; // IRC server connected to (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
|
||||
$channels = array("#theroot"); // IRC channel
|
||||
$default_channel = "#theroot";
|
||||
$logfile = "irclog.txt";
|
||||
|
||||
///// NO TOUCHY /////
|
||||
$version = "1.2.0"; // CWChat version
|
||||
///// NO TOUCHY SECTION /////
|
||||
$version = "1.3.0"; // CWChat version
|
||||
|
||||
function doLog($string) {
|
||||
file_put_contents($GLOBALS['logfile'], $string . "\r\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
?>
|
||||
|
13
index.php
13
index.php
@ -7,6 +7,7 @@
|
||||
// https://git.minetest.org/Pentium44/webirc-client
|
||||
///////
|
||||
|
||||
// Start session for username saves.
|
||||
session_start();
|
||||
include "config.php";
|
||||
|
||||
@ -16,6 +17,7 @@ function loginForm(){
|
||||
<div class="login">
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=login" method="post">
|
||||
Username: <input style="padding: 2px;" class="text" type="text" name="username"><br>
|
||||
Channel: <input style="padding: 2px;" class="text" type="text" name="channel"><br>
|
||||
<input style="padding: 2px;" class="text" type="submit" name="submitBtn" value="Login">
|
||||
</form>
|
||||
</div>
|
||||
@ -25,11 +27,15 @@ function loginForm(){
|
||||
//Logout
|
||||
if (isset($_GET['do']) && $_GET['do']=="logout") {
|
||||
$_SESSION['cwchat-user'] = null;
|
||||
$_SESSION['cwchat-channel'] = null;
|
||||
}
|
||||
|
||||
// If web frontend is trying to login, process and connect
|
||||
if (isset($_GET['do']) && $_GET['do']=="login" && isset($_POST['submitBtn'])){
|
||||
$name = isset($_POST['username']) && ($_POST['username'] !== "") ? htmlentities(stripslashes($_POST['username'])) : "Unnamed";
|
||||
$channame = isset($_POST['channel']) && ($_POST['channel'] !== "") ? htmlentities(stripslashes($_POST['channel'])) : "#theroot";
|
||||
$_SESSION['cwchat-user'] = $name;
|
||||
$_SESSION['cwchat-channel'] = $channame;
|
||||
}
|
||||
|
||||
//if(!isset($_SESSION['cwchat-user'])) { header("Location: ?do=login"); }
|
||||
@ -39,7 +45,7 @@ if (isset($_GET['do']) && $_GET['do']=="login" && isset($_POST['submitBtn'])){
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>CWChat</title>
|
||||
<title>IRC Web Chat</title>
|
||||
<link href="style.css" rel="stylesheet" type="text/css" />
|
||||
<script language="javascript" type="text/javascript">
|
||||
<!--
|
||||
@ -83,7 +89,7 @@ if (isset($_GET['do']) && $_GET['do']=="login" && isset($_POST['submitBtn'])){
|
||||
function serverWrite() {
|
||||
ajaxVar = getHTTPObject();
|
||||
if (ajaxVar != null) {
|
||||
link = "server.php?nick="+nickName+"&msg="+document.getElementById('msg').value;
|
||||
link = "server.php?nick="+nickName+"&msg="+encodeURIComponent(document.getElementById('msg').value);
|
||||
ajaxVar.open("GET", link , true);
|
||||
ajaxVar.send(null);
|
||||
}
|
||||
@ -170,7 +176,8 @@ if (isset($_GET['do']) && $_GET['do']=="login" && isset($_POST['submitBtn'])){
|
||||
</script>
|
||||
</head>
|
||||
<body onload="UpdateTimer();">
|
||||
<div class="info"><?php echo "CWChat " . $version . " ~ Connected to: " . $server . ":" . $port . " on " . $channels[0]; ?></div>
|
||||
<div class="info"><?php echo "CWChat " . $version . " ~ Connected to: " . $server . ":" . $port;
|
||||
if(isset($_SESSION['cwchat-user'])) { echo " on " . $_SESSION['cwchat-channel']; } ?></div>
|
||||
<?php
|
||||
if (!isset($_SESSION['cwchat-user'])){
|
||||
loginForm();
|
||||
|
87
irc.php
87
irc.php
@ -1,89 +1,102 @@
|
||||
<?php
|
||||
///////
|
||||
// webirc-client - 2013-2020
|
||||
// (C) Chris Dorman, GPL v3
|
||||
// https://notabug.org/Pentium44/ircchat
|
||||
///////
|
||||
|
||||
// irc.php - used to push and pull data from IRC server.
|
||||
// Currently supports PING / PONG, data receive, and data push
|
||||
// Done via PHP sockets.
|
||||
|
||||
// Prevent PHP from stopping the script after 30 sec
|
||||
set_time_limit(0);
|
||||
|
||||
// Include variables
|
||||
include_once("config.php");
|
||||
|
||||
// Change these values!
|
||||
// Get username from command line argument / PHP-CLI
|
||||
$username = $argv[1];
|
||||
|
||||
// If username isn't set, exit with error.
|
||||
if(!isset($username) || $username == "") {
|
||||
echo "Username not given...";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo "Starting client...";
|
||||
|
||||
file_put_contents(".$username.socket", "Welcome");
|
||||
chmod(".$username.socket", 0777);
|
||||
|
||||
file_put_contents(".$username.pingfile", "pong");
|
||||
chmod(".$username.pingfile", 0777);
|
||||
|
||||
// Opening the socket to the Rizon network
|
||||
// Create a socket to use
|
||||
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
|
||||
// Connect to IRC server via socket above
|
||||
socket_connect($socket, $server, $port);
|
||||
|
||||
|
||||
// Send auth info
|
||||
// fputs($socket, "PASS " . $password . "\n");
|
||||
echo "Connected, sending nickname to IRC server...";
|
||||
|
||||
// NICK and USER calls to IRC
|
||||
$nickline = "NICK " . $username . "\n";
|
||||
$userline = "USER " . $username . " 0 * :" . $username . "'s Bot\n";
|
||||
|
||||
// Pass NICK and USER back to IRC server over socket
|
||||
socket_write($socket, $nickline, strlen($nickline));
|
||||
socket_write($socket, $userline, strlen($userline));
|
||||
|
||||
// Join channel
|
||||
foreach($channels as $channel) {
|
||||
$channelline = "JOIN " . $channel . "\n";
|
||||
socket_write($socket, $channelline, strlen($channelline));
|
||||
}
|
||||
sleep(1);
|
||||
|
||||
// Force an endless while
|
||||
while (1) {
|
||||
// Continue the rest of the script here
|
||||
|
||||
while($bytes = socket_recv($socket, $r_data, 2048, MSG_DONTWAIT) !== '') {
|
||||
// Continue the rest of the script here
|
||||
// While script will continue as long as socket continues to be active
|
||||
while($bytes = socket_recv($socket, $r_data, 2048, MSG_DONTWAIT) !== '') {
|
||||
if($bytes !== FALSE) {
|
||||
//$data = socket_read($socket, 2048, PHP_NORMAL_READ);
|
||||
$data = $r_data;
|
||||
}
|
||||
|
||||
// If client sent something, push it to the IRC server!
|
||||
if(file_exists(".$username.push")) {
|
||||
// Grab IRC command from server.php
|
||||
$pushFile = file_get_contents(".$username.push");
|
||||
// Push this / these commands to socket
|
||||
socket_write($socket, $pushFile, strlen($pushFile));
|
||||
// Remove the push file
|
||||
unlink(".$username.push");
|
||||
}
|
||||
|
||||
// Check if web client still up, if no pong after 15 seconds, connection closed.
|
||||
if(!file_exists(".$username.pingfile") || (date("YmdHis.", filemtime(".$username.pingfile"))<(date("YmdHis.", filemtime(".$username.pingfile"))-10))) {
|
||||
echo "Exiting, leaving IRC server...";
|
||||
$quitline = "QUIT :Timed out\n";
|
||||
socket_write($socket, $quitline, strlen($quitline));
|
||||
socket_close($socket);
|
||||
exit(1);
|
||||
if(!file_exists(".$username.pingfile")) { // If file is missing, quit
|
||||
// Debug logging, check if IRC is exiting properly
|
||||
doLog("Exiting, $username logged out...");
|
||||
$quitline = "QUIT :$username left the web client\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(isset($data)) {
|
||||
$stringMsg = explode('PRIVMSG', $data);
|
||||
// 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.socket");
|
||||
// Push all content to
|
||||
file_put_contents(".$username.socket", $socketFileContents . $data);
|
||||
|
||||
$ex = explode(' ', $data);
|
||||
|
||||
// Send PONG back to the server
|
||||
if ($ex[0] == "PING") {
|
||||
echo "PONG to IRC server...";
|
||||
$pongline = "PONG " . $ex[1] . "\n";
|
||||
// Log pong
|
||||
doLog("PONG, $username response...");
|
||||
$pongline = "PONG " . $ex[1] . "\n"; // PONG IRC CMD
|
||||
// Push to IRC server via socket.
|
||||
socket_write($socket, $pongline, strlen($pongline));
|
||||
}
|
||||
}
|
||||
|
||||
// Half second sleep to prevent insane CPU load
|
||||
usleep(500);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
100
server.php
100
server.php
@ -1,43 +1,97 @@
|
||||
<?php
|
||||
///////
|
||||
// webirc-client - 2013-2020
|
||||
// (C) Chris Dorman, GPL v3 - (C) Microchat devs
|
||||
// https://github.com/Pentium44/cwchat
|
||||
// (C) Chris Dorman, GPL v3
|
||||
// https://notabug.org/Pentium44/ircchat
|
||||
///////
|
||||
|
||||
// server.php - used to communicate between web frontend and irc client
|
||||
// Grabs from IRC client output
|
||||
// Pushes to IRC client input
|
||||
// Keeps IRC client informed on web frontend connection
|
||||
|
||||
// Include PHP config file with server, title, and channel settings
|
||||
include_once("config.php");
|
||||
|
||||
session_start();
|
||||
|
||||
$channel = $_SESSION['cwchat-channel'];
|
||||
|
||||
// If we have a message; grab user and content and push to IRC client
|
||||
if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && $_GET['nick']!=""){
|
||||
$nick = $_GET['nick'];
|
||||
$msg = htmlentities(stripcslashes($_GET['msg']));
|
||||
$line = "";
|
||||
foreach($channels as $channel) {
|
||||
$nick = stripslashes(htmlentities($_GET['nick'])); // Usernick
|
||||
$msg = urldecode(stripslashes(trim($_GET['msg']))); // User message content
|
||||
$line = ""; // start with nothing
|
||||
|
||||
// Seperate message input via space
|
||||
$cmd = explode(" ", $msg);
|
||||
if($cmd[0]=="/msg") { // If using /msg, push private message
|
||||
$prvmsg = array_splice($cmd, 2); // grab private message from string
|
||||
$line .= "PRIVMSG" . " " . $cmd[1] . " :"; // set for push
|
||||
foreach($prvmsg as $word) {
|
||||
// Grab each word in the array after the privmsg username
|
||||
$line .= $word . " ";
|
||||
}
|
||||
$line .= "\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
|
||||
$line .= "JOIN" . " " . $cmd[1] . "\n"; // set for push
|
||||
$_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";
|
||||
}
|
||||
|
||||
// Get original content
|
||||
$content = file_get_contents(".$nick.socket");
|
||||
echo nl2br(htmlentities(stripslashes($content)));
|
||||
echo nl2br(stripslashes($content));
|
||||
// Grab all contents, and push to socket output file.
|
||||
file_put_contents(".$nick.socket", $content . $line);
|
||||
// Grab user message and push to IRC client
|
||||
file_put_contents(".$nick.push", $line);
|
||||
echo nl2br(htmlentities(stripslashes($line)));
|
||||
} else if (isset($_GET['get']) && isset($_GET['nick']) && $_GET['nick']!="") {
|
||||
$nick = $_GET['nick'];
|
||||
$content = file_get_contents(".$nick.socket");
|
||||
echo nl2br(htmlentities(stripslashes($content)));
|
||||
} else if (isset($_GET['do']) && isset($_GET['nick']) && $_GET['nick']!="") {
|
||||
$nick = $_GET['nick'];
|
||||
if($_GET['do']=="login") {
|
||||
// Make sure users DB is clean
|
||||
file_put_contents(".$nick.socket", "Welcome");
|
||||
chmod(".$username.socket", 0777);
|
||||
file_put_contents(".$nick.pingfile", "pong");
|
||||
chmod(".$username.pingfile", 0777);
|
||||
// Throw out your user message
|
||||
echo nl2br(stripslashes($line));
|
||||
// DONE
|
||||
|
||||
$realpath = realpath("./irc.php");
|
||||
} 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.socket");
|
||||
// Push content to the web frontend
|
||||
echo nl2br(htmlentities(stripslashes($content)));
|
||||
// DONE
|
||||
} else if (isset($_GET['do']) && isset($_GET['nick']) && $_GET['nick']!="") {
|
||||
$nick = stripslashes(htmlentities($_GET['nick']));
|
||||
if($_GET['do']=="login") { // Is user asking for login?
|
||||
// Join channel
|
||||
if(!isset($_SESSION['cwchat-channel'])) {
|
||||
file_put_contents(".$nick.push", "JOIN " . $default_channel . "\n");
|
||||
} else {
|
||||
file_put_contents(".$nick.push", "JOIN " . $channel . "\n");
|
||||
}
|
||||
|
||||
// Make sure users DB is clean, put nothing into socket read file
|
||||
file_put_contents(".$nick.socket", "");
|
||||
chmod(".$username.socket", 0755); // file permissions for read / write
|
||||
|
||||
// start pingfile - determines if webclient is active via write timestamp
|
||||
file_put_contents(".$nick.pingfile", "pong");
|
||||
chmod(".$username.pingfile", 0755); // file permissions for read / write
|
||||
|
||||
// Execute IRC client in background
|
||||
// IRC server will die when either 1) pingfile is deleted, or
|
||||
// 2) if pingfile is older than 10 seconds of current sys time
|
||||
$realpath = realpath("./irc.php"); // get full file path
|
||||
|
||||
// Execute IRC client
|
||||
shell_exec("/usr/bin/php $realpath $nick > /dev/null 2>/dev/null &");
|
||||
} else if($_GET['do']=="logout") {
|
||||
} else if($_GET['do']=="logout") { // Is user asking for logout?
|
||||
// Remove ping file if user logs out. IRC server will close
|
||||
unlink(".$nick.pingfile");
|
||||
} else if($_GET['do']=="keepup") {
|
||||
} else if($_GET['do']=="keepup") { // Client asking for keepup ping.
|
||||
// PONG to server.
|
||||
file_put_contents(".$nick.pingfile", "ping");
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
$output = shell_exec("/bin/bash connect.sh Chraas &");
|
||||
echo $output;
|
||||
exit(0);
|
||||
|
||||
?>
|
||||
|
@ -12,7 +12,7 @@ body {
|
||||
min-width: 730px;
|
||||
min-height: 700px;
|
||||
max-height: 700px;
|
||||
overflow: hidden;
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
.info {
|
||||
@ -59,7 +59,7 @@ input, button, select, textarea{
|
||||
background-color: #323232;
|
||||
border: solid 1px #454545;
|
||||
padding: 8px;
|
||||
height: 520px;
|
||||
height: 420px;
|
||||
margin: 0 auto;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user