Skip to content

Instantly share code, notes, and snippets.

@MaleXachi
Last active December 31, 2015 17:33
Show Gist options
  • Save MaleXachi/b27d564a6db8167b6ee2 to your computer and use it in GitHub Desktop.
Save MaleXachi/b27d564a6db8167b6ee2 to your computer and use it in GitHub Desktop.
This is a method to login with lightIRC, when you fill in your username and gender and about colours of genders. If you want to add more options, feel free to post a comment. Please click on star, if you like this!
Changes 2015-02-24:
Better Security for $_POST with Errormessages:
- If username is Empty
- If a username don't have legal characters (You can add more values in preg_match())
- If Length of username is longer/shorter than default values (You can change both length of username)
- If username have bad names (You can add more bad names in array of $badNames)
- If gender is Empty
- If gender value is other than default values
Extra Options (2015-02-24):
User Password
User Country: https://gist.github.com/MaleXachi/b27d564a6db8167b6ee2#comment-1400059
Note: I don't get any mails, if anyone comment me on my Gist, but u can send a mail to me, if u did comment
on my Gist, but do not send a mail to ask for help, but that you did comment, otherwise i will not help you.
Mail: i.own3d.th3.w0rld@gmail.com
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Welcome to our Chat!</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">jQuery.noConflict();(function($){$(function(){$(function(){$(".text").keyup(function(){var word=$(this).val();$(".word_preview").html(word);return false})})})})(jQuery);</script>
<link href='http://fonts.googleapis.com/css?family=Fontdiner+Swanky' rel='stylesheet' type='text/css'>
<style>
.error {color: red;text-align: center;}
body {font-family: Verdana;margin:50px 0px;padding:0px;text-align:center;}
div#lightForm {text-align: left;width:500px;margin:0px auto;text-align:left;padding:15px;border:1px dashed #333;background-color:#eee;-moz-box-shadow: 0 0 5px #600000;-webkit-box-shadow: 0 0 5px #600000;box-shadow: 0 0 5px #600000;}
div.formInput {text-align: left;width: 300px;margin-left: auto;margin-right: auto;font-size: 12px;color: #600000;}
input[type=text], input[type=password], input[type=submit] {margin: auto;display: block;width: 100%;}
select {margin: auto;display: block;width: 100%;}
.lightText {padding: 1px 1px 1px 1px;margin: 1px 1px 15px 1px;font-family: 'Fontdiner Swanky', cursive;text-align: center;color: #600000;}
.word_preview {color:#000000;}
</style>
</head>
<body>
<?php
$Message = 1;
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
$Username = $_POST['username'];
$UserPassword = $_POST['userpassword'];
$Gender = $_POST['gender'];
$badNames = array('Hitler', 'Fuck', 'Asshole', 'Dickhead');
$Check = array();
$CheckFound = preg_match_all('/\b(' . implode($badNames, '|') . ')\b/i', $Username, $Check);
if (isset($Username, $UserPassword, $Gender))
{
if (empty($Username))
{
$Message = 2;
} elseif (preg_match('/[^A-Za-z0-9_-]/', $Username)) {
$Message = 4;
} elseif (strlen($Username) < 3) {
$Message = 5;
} elseif (strlen($Username) > 15) {
$Message = 6;
} elseif (empty($UserPassword)) {
$Message = 7;
} elseif (preg_match('/[^A-Za-z0-9_-]/', $UserPassword)) {
$Message = 8;
} elseif (strlen($UserPassword) < 3) {
$Message = 9;
} elseif (strlen($UserPassword) > 15) {
$Message = 10;
} elseif ($CheckFound) {
$Names = array_unique($Check[0]);
foreach ($Names as $Name) {
echo '<p class="error"><strong>' . $Name . '</strong> is not allowed. Please give a correct name.</p>';
}
} elseif (empty($Gender)) {
$Message = 3;
} elseif (!preg_match("/Male|Female|Trans/i", $Gender)) {
$Message = 11;
} else {
$Message = 12;
}
}
}
$Html =
'<div id="lightForm">
<h1 class="lightText">lightIRC</h1>
<div class="formInput">
<form action="" method="post">
<label for="username">Username:</label> <input type="text" class="text" name="username">
&lsaquo;<span class="word_preview"></span>&rsaquo; Hello, i am <span class="word_preview"></span><br /><br />
<label for="password">Password:</label> <input type="password" name="userpassword"><br />
<label for="gender">Gender:</label> <select name="gender">
<option>Male</option>
<option>Female</option>
<option>Trans</option>
</select>
<br /><br />
<input type="submit" name="submit" value="Chat now!">
</form>
</div>
</div>';
switch($Message)
{
case 1: $Message = $Html;
break;
case 2: $Message = '<p class="error">Username is required!</p>' . $Html;
break;
case 3: $Message = '<p class="error">Select your gender!</p>' . $Html;
break;
case 4: $Message = '<p class="error">Give a username with legal characters.</p>' . $Html;
break;
case 5: $Message = '<p class="error">Name is too short. Min length is 3.</p>' . $Html;
break;
case 6: $Message = '<p class="error">Name is too long. Max length is 15.</p>' . $Html;
break;
case 7: $Message = '<p class="error">Password is required.</p>' . $Html;
break;
case 8: $Message = '<p class="error">Give a password with legal characters.</p>' . $Html;
break;
case 9: $Message = '<p class="error">Password is too short. Min length is 3.</p>' . $Html;
break;
case 10: $Message = '<p class="error">Password is too long. Max length is 15.</p>' . $Html;
break;
case 11: $Message = '<p class="error">Please, don\'t try to change our values. Choose one of these options!</p>' . $Html;
break;
case 12: $Message = '
<script language="javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" type="text/javascript"></script>
<script language="javascript" src="config.php?name='.$Username.'&amp;gender='.$Gender.'&amp;userpassword='.$UserPassword.'" type="text/javascript"></script>
<br /><div style="text-align: center;">
<div id="lightIRC" style="height:500px; text-align:center;"><p><a href="http://www.adobe.com/go/getflashplayer" title="Get flash player"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p></div>
<script type="text/javascript">swfobject.embedSWF("lightIRC.swf", "lightIRC", "100%", "500", "10.0.0", "expressInstall.swf", params);</script>
</div>';
break;
}
echo $Message;
?>
</body>
</html>
<?php
$name = strip_tags($_GET['name']);
switch($name) {
case preg_match('/[^A-Za-z0-9_-]/', $name):
break;
default:
$name = "Guest_%";
}
$userpassword = strip_tags($_GET['userpassword']);
switch($userpassword) {
case preg_match('/[^A-Za-z0-9_-]/', $userpassword):
break;
default:
$userpassword = "";
}
$gender = strip_tags($_GET['gender']);
switch($gender) {
case "Male":
case "Female":
case "Trans":
break;
default:
$gender = "Unknown";
}
?>
var params = {};
params.host = "YOUR IRC SERVER";
params.port = 6667;
params.policyPort = 843;
params.ident = "ident";
params.realname = "<?php echo $gender; ?>";
params.identifyPassword = "<?php echo $userpassword; ?>";
params.quitMessage = "See You Later";
params.targetFrame = "_blank";
params.showNickSelection = false;
params.fontSize = "16";
params.styleURL = "css/lightblue.css";
params.performContinousWhoRequests = true;
/* userListCustomFormatting - Fixed by Kin Kith: http://redmine.lightirc.com/issues/435#change-1042 */
params.userListCustomFormatting = "realname=(^|\\W)([Mm]ale|[Mm]an):userListMan,realname=[Ff]emale:userListWoman,realname=[Tt]rans:userListTrans";
params.showInfoMessages = false;
params.customSecurityErrorMessage = "There is an error. Please refresh the page!";
params.showNewQueriesInBackground = true;
params.webcam = true;
params.accessKey = "";
params.rtmp = "";
/* Language for the user interface. Currently available translations: ar, bd, bg, br, cz, da, de, el, en, es, et, fi, fr, hu, hr, id, it, ja, nl, no, pl, pt, ro, ru, sl, sq, sr_cyr, sr_lat, sv, th, tr, uk */
params.language = "en";
/* Nick to be used. A % character will be replaced by a random number */
params.nick = "<?php echo $name; ?>";
params.nickAlternate = "<?php echo $name; ?>_";
/* Channel to be joined after connecting. Multiple channels can be added like this: #lightIRC,#test,#help */
params.autojoin = "#chatroom";
/* Commands to be executed after connecting. E.g.: /mode %nick% +x */
params.perform = "";
/* Whether the server window (and button) should be shown */
params.showServerWindow = true;
/* Show button to register a nickname */
params.showRegisterNicknameButton = true;
/* Show button to register a channel */
params.showRegisterChannelButton = true;
/* Opens new queries in background when set to true */
params.showNewQueriesInBackground = false;
/* Position of the navigation container (where channel and query buttons appear). Valid values: left, right, top, bottom */
params.navigationPosition = "bottom";
.userListMan {
color:#1E90FF;
}
.userListWoman {
color:#FF00FF;
}
.userListTrans {
color: #009933;
}
@GHF2014
Copy link

GHF2014 commented Feb 27, 2015

@MaleXachi
After I updated the chatlog, I forgot to change

<script language="javascript" src="config.php?name='.$Username.'&gender='.$Gender.'&userpassword='.$UserPassword.'&usercountry='.$userCountryCode.'" type="text/javascript"></script>

I just edited the code once again and it did work perfect.

Thanks a lot

@MaleXachi
Copy link
Author

@GHF2014

You're welcome.

For some guys of u, u can find start.php of lightIRC here: https://gist.github.com/MaleXachi/660b45e06d685b1e8dc3

@legendsky
Copy link

is that possible, like nicklist appear in the right side same like that channel list appear in the left side??? if that possible please kindly guide it how is that possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment