I wrote this up because I'm tired of douche bags like these guys pretending to be smart, when the server software itself is free, flyff, mssql, php, apache and so on, and thus so should be any knowledge acquired from it, if you're too bloody lazy to share what you got for free because it takes five damn minutes don't post at all.
Here you go guys.
PHP Code:
<?php
session_start();
//Needs salt to work -- Updated, if using v11 change to nForceisGay
$salt = 'kikugalanet';
//MSSQL Settings
$serverdb = 'CHANGEME1\SQLEXPRESS';
$admin_username = 'sa';
$admin_pass = '*Your password*';
$accounts = 'ACCOUNT_DBF';
$registerurl = 'register.php';
//DB Connection
$link = @mssql_connect($serverdb, $admin_username, $admin_pass) or die ("Server is down!");
$db = @mssql_select_db($accounts) or die ("Accout table is missing!");
//Check Username
function doesUsernameExist($name){
$exit = FALSE;
$rsql = "SELECT * FROM ACCOUNT_TBL WHERE account='" . $name . "'";
$result = @mssql_query($rsql);
if ($result) {
if(mssql_num_rows($result) != 0){
$exit = TRUE;
}
}
else{
$exit = FALSE;
}
return $exit;
}
//Check if something was submitted
if(isset($_POST['submit'])){
$userRev = preg_replace ("[^A-Za-z0-9]", "", $_POST['username']);
$passRev = preg_replace ("[^A-Za-z0-9]", "", $_POST['password']);
$day = (int) $_POST['day'];
$month = (int) $_POST['month'];
$year = (int) $_POST['year'];
$email = $_POST['email'];
if($_POST['username'] == ""){
echo '<script language="JavaScript">';
echo 'window.location="'.$registerurl.'";';
echo '</script>';
$_SESSION['regerror'] = 'Please enter an username';
}
else if($_POST['email'] == ""){
echo '<script language="JavaScript">';
echo 'window.location="'.$registerurl.'";';
echo '</script>';
$_SESSION['regerror'] = 'Please enter an email';
}
else if($_POST['password'] == ""){
echo '<script language="JavaScript">';
echo 'window.location="'.$registerurl.'";';
echo '</script>';
$_SESSION['regerror'] = 'Please enter a password';
}
else if($day == "" || $month == "" || $year == "" || strlen($day) > 2 || strlen($month) > 2 || strlen($year) != 4 || $day == 00 || $month == 00 || $year == 0000){
echo '<script language="JavaScript">';
echo 'window.location="'.$registerurl.'";';
echo '</script>';
$_SESSION['regerror'] = 'Please enter a correct birthday';
}
else if(strlen($_POST['username']) > 15){
echo '<script language="JavaScript">';
echo 'window.location="'.$registerurl.'";';
echo '</script>';
$_SESSION['regerror'] = 'Your username cannot contain more than 15 characters';
}
else if(strlen($_POST['password']) > 36){
echo '<script language="JavaScript">';
echo 'window.location="'.$registerurl.'";';
echo '</script>';
$_SESSION['regerror'] = 'Your password cannot contain more than 36 characters';
}
else if($_POST['username'] != $userRev){
echo '<script language="JavaScript">';
echo 'window.location="'.$registerurl.'";';
echo '</script>';
$_SESSION['regerror'] = 'Your username contains illegal characters or words';
}
else if($_POST['password'] != $passRev){
echo '<script language="JavaScript">';
echo 'window.location="'.$registerurl.'";';
echo '</script>';
$_SESSION['regerror'] = 'Your password contains illegal characters';
}
else if(strlen(filter_var($email, FILTER_VALIDATE_EMAIL)) == 0){
echo '<script language="JavaScript">';
echo 'window.location="'.$registerurl.'";';
echo '</script>';
$_SESSION['regerror'] = 'Your is email is wrong please check it';
}
else {
//Making salt
$passRev = md5($salt . $passRev);
//End salt
$bday = $month.'/'.$day.'/'.$year;
$email = $_POST['email'];
if(!doesUsernameExist($userRev)){
$stmt = mssql_init('webCreateAcc', $link);
mssql_bind($stmt, '@account', $userRev, SQLVARCHAR, false, false, 15);
mssql_bind($stmt, '@password', $passRev, SQLVARCHAR, false, false, 36);
mssql_bind($stmt, '@birthday', $bday, SQLVARCHAR, false, false, 120);
mssql_bind($stmt, '@email', $email, SQLVARCHAR, false, false, 120);
mssql_execute($stmt) or die ("Something is wrong on the execution");
mssql_free_statement($stmt);
$_SESSION['regerror'] = '<font color="green">Thank you for registering with the name "'.$userRev.'".</font>';
echo '<script language="JavaScript">';
echo 'window.location="'.$registerurl.'";';
echo '</script>';
}
else {
$_SESSION['regerror'] = 'Username is already taken.';
echo '<script language="JavaScript">';
echo 'window.location="'.$registerurl.'";';
echo '</script>';
}
}
}
//We need a form to produce results with
else if (!$_POST['submit']) {
if ($_SESSION['regerror'] != '') echo $_SESSION['regerror'] . '<br>';
?>
<form method="post" action="#">
<legend>Username</legend>
<input type="text" name="username">
<legend>Password:</legend>
<input type="password" name="password">
<legend>Birthday (Ex: Month Day Year)</legend>
<input type="text" name="month" value="08"><input type="text" name="day" value="13"><input type="text" name="year" value="1947">
<legend>Email</legend>
<input type="text" name="email">
<legend>Submit Registration</legend>
<input type="submit" name="submit" value="Register!">
</form>
<?php
}
?>
Credits for the functions and base of this script go to the opening poster.