<?php
// Config
// Title
echo '<title>CABAL Online Register</title>';
// MSSQL server connection details
// Database server
define('DB_ADDR','127.0.0.1');
// Database login
define('DB_USER','sa');
// Database password
define('DB_PASS','password');
// In case you have a different db names
define('DB_ACC','ACCOUNT');
define('DB_GAM','GAMEDB');
$link = mssql_connect(DB_ADDR, DB_USER, DB_PASS);
if (!$link) die('Could not connect to MSSQL database.');
$num_acc=0;
$num_cha=0;
$num_onl=0;
$r=mssql_query('select count (*) from '.DB_ACC.'.dbo.cabal_auth_table');
$num_acc=mssql_result($r,0,0);
$r=mssql_query('select count (*) from '.DB_ACC.'.dbo.cabal_auth_table where Login=1');
$num_onl=mssql_result($r,0,0);
$r=mssql_query('select count (*) from '.DB_GAM.'.dbo.cabal_character_table');
$num_cha=mssql_result($r,0,0);
echo '<div align="center">';
echo '<p style="font-size:24px;font-weight:bold">CABAL Online Account Registration</p>';
echo '<p>Login ID and Password must be at least a minimum of 6 characters, letters and/or numbers only.</p>';
echo '<form method="post" action="'.$_PHP['self'].'">';
echo '<table cellspacing="4" cellpadding="0" border="0">';
echo '<tr><td align="right">Login ID: </td><td><input type="text" name="uname" class="editbox"></td></tr>';
echo '<tr><td align="right">Password: </td><td><input type="password" name="pass" class="editbox"></td></tr>';
echo '<tr><td align="right">Confirm Password: </td><td><input type="password" name="pass2" class="editbox"></td></tr>';
echo '<tr><td colspan="2" align="center"><input type="submit" value="Register" class="button"></td></tr><br \>';
echo '</table>';
echo '</form>';
echo '<p>Registered accounts: <span style="font-size:16px;font-weight:bold">'.$num_acc.'</span> | Characters created: <span style="font-size:16px;font-weight:bold">'.$num_cha.'</span></p>';
$uid='';
$pass='';
$failed=false;
if (isset($_POST['uname'])) {
if (!ctype_alnum($_POST['uname']) || strlen($_POST['uname'])<6) {
$failed=true;
echo '<p class="errortext">Invalid username. Minimum of 6 characters, letters and numbers only.</p> ';
} else {
$uid=$_POST['uname'];
}
}
if (isset($_POST['pass'])) {
if (!ctype_alnum($_POST['pass']) || strlen($_POST['pass'])<6) {
$failed=true;
echo '<p class="errortext">Invalid password. Minimum of 6 characters, letters and numbers only.</p> ';
} else {
$pass=$_POST['pass'];
}
}
if (isset($_POST['pass2'])) {
if (!ctype_alnum($_POST['pass2'])) {
$failed=true;
} else {
if ($_POST['pass2']!=$_POST['pass']) {
$failed=true;
echo '<p class="errortext">Both password fields do not match.</p> ';
}
}
}
if ($failed==true) {
echo '<p class="errortext">Account Registration Failed.</p> ';
} else {
if ($uid!='' && $pass!='') {
$r=mssql_query('select count (*) from '.DB_ACC.'.dbo.cabal_auth_table where ID="'.$uid.'"');
if (mssql_result($r,0,0)==0) {
$r=mssql_query('exec '.DB_ACC.'.dbo.cabal_tool_registerAccount "'.$uid.'","'.$pass.'"');
if ($r==false) {
echo '<p class="errortext">Something went wrong.</p>';
} else {
echo '<p class="goodtext">Account created successfully.</p>';
}
mssql_free_result($r);
mssql_close($link);
} else {
echo '<p class="errortext">Login ID has been used.</p> ';
}
}
}
echo '</div>';
?>