ircchat/server.php
2020-11-09 10:44:42 -08:00

45 lines
1.5 KiB
PHP
Executable File

<?php
///////
// webirc-client - 2013-2020
// (C) Chris Dorman, GPL v3 - (C) Microchat devs
// https://github.com/Pentium44/cwchat
///////
include_once("config.php");
if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && $_GET['nick']!=""){
$nick = $_GET['nick'];
$msg = htmlentities(stripcslashes($_GET['msg']));
$line = "";
foreach($channels as $channel) {
$line .= "PRIVMSG $channel :$msg\n";
}
$content = file_get_contents(".$nick.socket");
echo nl2br(htmlentities(stripslashes($content)));
file_put_contents(".$nick.socket", $content . $line);
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);
$realpath = realpath("./irc.php");
shell_exec("/usr/bin/php $realpath $nick > /dev/null 2>/dev/null &");
} else if($_GET['do']=="logout") {
unlink(".$nick.pingfile");
} else if($_GET['do']=="keepup") {
file_put_contents(".$nick.pingfile", "ping");
}
}
?>