[BACK]Return to register.php CVS log [TXT][DIR] Up to [local] / botnow

File: [local] / botnow / register.php (download)

Revision 1.1, Sat May 15 15:12:32 2021 UTC (2 years, 11 months ago) by bountyht
Branch point for: MAIN

Initial revision

<?php

$hashirc = isset($_REQUEST['hashirc']) ? $_REQUEST['hashirc'] : NULL;
$hashbnc = isset($_REQUEST['hashbnc']) ? $_REQUEST['hashbnc'] : NULL;
$hashshell = isset($_REQUEST['hashshell']) ? $_REQUEST['hashshell'] : NULL;
$hashsmtp = isset($_REQUEST['hashsmtp']) ? $_REQUEST['hashsmtp'] : NULL;
$lines = file('botnow.conf');

foreach ($lines as $i => $line) {
	if (preg_match('/^\#/', $line, $matches)) {
	} elseif (preg_match('/^\s*$/', $line, $matches)) {
	} elseif (preg_match('/^([^=\s]+)\s*=\s*(.*)$/', $line, $matches)) {
		$key = $matches[1];
		$val = $matches[2];
		$conf{$key} = $val;
	}
}

$wordslist = file('words');
$wordslen = sizeof($wordslist);
for ($n = 0; $n < 5; $n++) {
        $i = rand(0, $wordslen-1);
	$words[] = substr($wordslist[$i],0,-1); // remove newline
}
$passphrase = implode(" ", $words);
$passphrase = ucwords($passphrase);
$fpr{"passphrase"} = $passphrase;
$fpr{"remoteaddr"} = $_SERVER['REMOTE_ADDR'];
$fpr{"httpxforwarded"} = $_SERVER['HTTP_X_FORWARDED_FOR'];
$fpr{"time"} = date("Y-m-d H:i:s");
if (isset($hashirc)) {
	$fpr{"hashirc"} = $hashirc;
} elseif (isset($hashbnc)) {
	$fpr{"hashbnc"} = $hashbnc;
} elseif (isset($hashshell)) {
	$fpr{"hashshell"} = $hashshell;
} elseif (isset($hashsmtp)) {
	$fpr{"hashsmtp"} = $hashsmtp;
}

foreach (getallheaders() as $key => $value) {
	if ($key == "User-Agent") {
		$key = "useragent";
	} elseif ($key == "Upgrade-Insecure-Requests") {
		$key = "upgradeinsecure";
	} elseif ($key == "Host") {
		$key = "host";
	} elseif ($key == "Dnt") {
		$key = "dnt";
	} elseif ($key == "Connection") {
		$key = "connection";
	} elseif ($key == "Cache-Control") {
		$key = "cachecontrol";
	} elseif ($key == "Accept-Language") {
		$key = "acceptlanguage";
	} elseif ($key == "Accept-Encoding") {
		$key = "acceptencoding";
	} elseif ($key == "Accept") {
		$key = "accept";
	} elseif ($key == "Cookie") {
		$key = "cookie";
	}
	$fpr{$key} = $value;
}

setcookie("ircnow[hashirc]", $hashirc, time()+86400*30, '/', 'ircnow.org', true);
setcookie("ircnow[hashbnc]", $hashbnc, time()+86400*30, '/', 'ircnow.org', true);
setcookie("ircnow[hashshell]", $hashshell, time()+86400*30, '/', 'ircnow.org', true);
setcookie("ircnow[hashsmtp]", $hashsmtp, time()+86400*30, '/', 'ircnow.org', true);

class wwwdb extends SQLite3 {
	function __construct() {
		$this->open('/botnow/botnow.db');
	}
}
$wwwdb = new wwwdb();
if(!$wwwdb) {
	echo $wwwdb->lastErrorMsg();
} else {
	foreach ($fpr as $key => $value) {
		$keys[] = $key;
		$values[] = $value;
	}
	$keystr = '"'.implode('","', $keys).'"';
	$valstr = '"'.implode('","', $values).'"';
	$sql =<<<EOF
INSERT INTO www ($keystr)
VALUES ($valstr);
EOF;
	if (!$wwwdb->exec($sql)) {
		echo $db->lastErrorMsg();
	}
$clients = array("AdiIRC", "Adium", "AndroIRC", "Atomic", "Colloquy", "Hexchat", "HydraIRC", "IRCForAndroid", "IRCCloud", "IceChat", "ircEX", "irssi", "Igloo", "KVIrc", "KiwiIRC", "Limechat", "Mibbit", "mIRC", "nettalk", "Pidgin", "qwebirc", "Quassel", "RevolutionIRC", "SimpleIRC", "Smuxi", "Textual", "Thunderbird", "TurboIRC", "Weechat", "Yaaic", "XChat");
$sql =<<<EOF
SELECT * from irc where hashid = "$hashirc";
EOF;
	$ret = $wwwdb->query($sql);
	while($row = $ret->fetchArray(SQLITE3_ASSOC)) {
		echo "Don't worry I got called";
		$ircid = $row['id'];
		$ctcpversion = $row['ctcpversion'];
		$hostmask = $row['hostmask'];
		foreach ($clients as $i => $value) {
			if (preg_match("/$value/i", $ctcpversion, $matches)) {
				$client = $value;
			}
		}
		if (!isset($client)) {
			if (preg_match('/!~?uid\d+/i', $hostmask, $matches)) {
				$client = "IRCCloud";
			} elseif(preg_match('/!~?quassel/i', $hostmask, $matches)) {
				$client = "Quassel";
			} elseif(preg_match('/!~?IceChat/i', $hostmask, $matches)) {
				$client = "IceChat";
			} elseif(preg_match('/Purple\s+IRC/i', $ctcpversion, $matches)) {
				$client = "Pidgin";
			} elseif(preg_match('/X-Chat/i', $ctcpversion, $matches)) {
				$client = "XChat";
			} elseif(preg_match('/Kiwi\s+IRC/i', $ctcpversion, $matches)) {
				$client = "KiwiIRC";
			} elseif(preg_match('/Android\s+IRC/i', $ctcpversion, $matches)) {
				$client = "AndroIRC";
			} elseif(preg_match('/IRC\s+for\s+Android/i', $ctcpversion, $matches)) {
				$client = "IRCForAndroid";
			} elseif(preg_match('/Revolution\s+IRC/i', $ctcpversion, $matches)) {
				$client = "RevolutionIRC";
			} elseif(preg_match('/Yet\s+another\s+Android\s+IRC\s+client/i', $ctcpversion, $matches)) {
				$client = "Yaaic";
			} else {
				$client = "Bouncer";
			}
		}
		
	}
$sql =<<<EOF
SELECT * from bnc where ircid = "$ircid";
EOF;
	$ret = $wwwdb->query($sql);
	while($row = $ret->fetchArray(SQLITE3_ASSOC)) {
		$username = $row['username'];
	}
	$wwwdb->close();
}
function myURLEncode($string) {
    $replace = array('%20', '%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%23', '%5B', '%5D');
    $search = array(' ', '!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "#", "[", "]");
    return str_replace($search, $replace, $string);
}
$hostname = $conf{"hostname"};
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="robots" content="index, follow"/>
	<title>IRCNow -- Verify Account</title>  
<style>
body {
	width: 80%;
	margin: 5rem auto;
	text-align: center;
	font-family: "Tahoma", "Verdana", "Arial";
}
</style>
<script>
console.log(Intl.DateTimeFormat().resolvedOptions().timeZone);
var offset = new Date().getTimezoneOffset();
console.log(offset);
console.log(new Date().toString());
console.log(window.screen.width);
console.log(window.screen.height);
//console.log(screen.availWidth);
//console.log(screen.availHeight);
console.log(screen.colorDepth);
</script>
</head>

<body>
<p>Please email <a href="mailto:<?php echo $conf{"mailfrom"}."?subject=".myURLEncode("IRCNow Verify: $passphrase")."&body=".myURLEncode("IRCNow Verify: $passphrase") ?>"><?php echo $conf{"mailfrom"} ?></a> with the following passphrase:</p>

<p>IRCNow Verify: <?php echo $passphrase ?></p>

<p><a href="https://wiki.ircnow.org/index.php?n=Bouncer.<?php echo $client ?>">Click here for <?php echo $client ?> connection instructions.</a></p>

<p>To change your password, login to <a href="<?php echo "https://bnc.$hostname/" ?>"><?php echo "https://bnc.$hostname/" ?></a>, fill in the password field, then click on the "Save and Return" button.</p>

<p>Or, you can change the password from your IRC client. Once you have logged in, type:</p>

<code>/msg *controlpanel set password <?php echo $username ?> newpassword</code>

</body>
</html>